Page 1 of 6 123 ... LastLast
Results 1 to 10 of 58

Thread: Funny Code

  1. #1
    Join Date
    Mar 2011
    Location
    N 11 19' 0.0012 E 142 15' 0
    Posts
    1,509
    Thanks
    41
    Thanked 89 Times in 88 Posts
    Blog Entries
    3

    Default Funny Code

    Anyone seen some especially hilarious or painfull code over the years?

    Found this whilst browsing the internet... can't remember where it's from now...

    Code:
    x = x;
    When asked to explain their code, the person said "I wanted to make sure that x doesn't lose it's value".
    Last edited by keyboard; 08-06-2012 at 03:17 AM.

  2. #2
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,321
    Thanks
    30
    Thanked 137 Times in 132 Posts
    Blog Entries
    29

    Default

    This is hilarious, of course. But there are cases very similar to the one you mention where seemingly tautologous lines are not a real tautology. For instance, the following script will not work without the lines in red:
    Code:
    <script>
    var x=document.createElement('div')
    function hilarious(laughing,some_id)
    {
    x.innerHTML='<div>'+laughing+'<\/div>'; 
    x.setAttribute("id",some_id);
    ssome_id=some_id;
    setTimeout('some_id=ssome_id',0);
    setTimeout('document.getElementById(some_id).innerHTML=document.body.appendChild(x).innerHTML',100)
    }
    </script>
    
    <a style="cursor: pointer" onclick="hilarious('hihi')">let us laugh</a>
    ===
    Arie.

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,926
    Thanks
    43
    Thanked 3,192 Times in 3,155 Posts
    Blog Entries
    12

    Default

    Code:
    <noscript><!-- hide from older browsers
    document.write('Your browser doesn\'t support javascript')
    //--> end hiding
    </noscript>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Mar 2011
    Location
    N 11 19' 0.0012 E 142 15' 0
    Posts
    1,509
    Thanks
    41
    Thanked 89 Times in 88 Posts
    Blog Entries
    3

    Default

    Quote Originally Posted by jscheuer1 View Post
    Code:
    <noscript><!-- hide from older browsers
    document.write('Your browser doesn\'t support javascript')
    //--> end hiding
    </noscript>
    Wow, that's precious....

    Thanks for that molendijk!

    EDIT - Here's some more from here

    Code:
    stop(); // Hammertime!
    Code:
    return 1; # returns 1
    Code:
    // Replaces with spaces the braces in cases where braces in places cause stasis 
       $str = str_replace(array("\{","\}")," ",$str);
    Code:
    Catch (Exception e) {
     //who cares?
    }
    Code:
    /* Emits a 7-Hz tone for 10 seconds.
      True story: 7 Hz is the resonant frequency of a
      chicken's skull cavity. This was determined
      empirically in Australia, where a new factory
      generating 7-Hz tones was located too close to a
      chicken ranch: When the factory started up, all the
      chickens died.
      Your PC may not be able to emit a 7-Hz tone. */
    
    main()
    {
        sound(7);
        delay(10000);
        nosound();
    }

    Not from the link provided, but still funny
    Code:
    motor[Wheel_Left] = 50;
    motor[Wheel_Right] = 45; // to make it go in a straight line
    Last edited by keyboard; 08-06-2012 at 11:16 PM.

  5. #5
    Join Date
    Mar 2011
    Location
    N 11 19' 0.0012 E 142 15' 0
    Posts
    1,509
    Thanks
    41
    Thanked 89 Times in 88 Posts
    Blog Entries
    3

    Default

    Any more anyone?

  6. #6
    Join Date
    Jul 2012
    Posts
    44
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    Code:
    <noscript><!-- hide from older browsers
    document.write('Your browser doesn\'t support javascript')
    //--> end hiding
    </noscript>
    Hilarious

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,926
    Thanks
    43
    Thanked 3,192 Times in 3,155 Posts
    Blog Entries
    12

    Default

    Thanks.

    This one actually works. I just find it a little humorous how it's worded (highlighted added due to lack of context):

    Code:
    (function(){
      var dash = /-(.)/g;
      function toHump(a, b){return b.toUpperCase();};
      String.prototype.encamel = function(){return this.replace(dash, toHump);};
    })();
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #8
    Join Date
    Mar 2011
    Location
    N 11 19' 0.0012 E 142 15' 0
    Posts
    1,509
    Thanks
    41
    Thanked 89 Times in 88 Posts
    Blog Entries
    3

    Default

    I don't really get it???
    Last edited by keyboard; 08-08-2012 at 11:19 PM.

  9. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,926
    Thanks
    43
    Thanked 3,192 Times in 3,155 Posts
    Blog Entries
    12

    Default

    Which? What it does, or why (dash, toHump) is a little funny?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  10. #10
    Join Date
    Mar 2011
    Location
    N 11 19' 0.0012 E 142 15' 0
    Posts
    1,509
    Thanks
    41
    Thanked 89 Times in 88 Posts
    Blog Entries
    3

    Default

    (dash, toHump)
    that bit

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •