ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

COMPETITION - Who can create the most pointless functionality?

September 13, 2010 10:01am

Subscribe [15]
  • #1 / Sep 13, 2010 10:01am

    Angel Web Design

    11 posts

    After reading this (http://ellislab.com/forums/viewthread/157706/) and sharing it with the office, the lads started writing their own “pointless code” entries.

    So im opening a competition, The Most Pointless Functionality Competition.

    Rules:
    1. Has to be stupid.
    2. Has to be completely irrelevant.
    3. Has to make the same people who laugh at the above thread, laugh.

    My Entry:

    function echo($string){
    $size = sizeof($string);
    for($i=0;$i<$size;$i++)
    {
    echo $string[$i];
    }
    }

  • #2 / Sep 13, 2010 11:03am

    stevefrost

    1 posts

    function return_value($__value)
    {
    return $__value;
    }

  • #3 / Sep 13, 2010 11:18am

    anonymous41542

    436 posts

    Does my “use CodeIgniter functions in CamelCase” hack qualify?

    Also could you add rule #4: put the code between [code ][/code ] tags

    And just in case that other bit of crazyness didn’t qualify:
    [code]function is_true( $var )
    {
    // Set the default value for the return just in case
    // according to the rule: innocent until proven guilty
    $return = TRUE;

    // If the input is boolean the truth can be decided immediately
    if ( is_bool( $var ) )
    {
    if ( $var === TRUE )
    {
    $return = TRUE;
    }
          elseif ( $var === FALSE )
          {
    $return = FALSE;
    }
          // Throw error when $var has an invalid value
          else
          {
    throw new Exception( 'Boolean value has to be TRUE or FALSE.' );
    }
      }
      // If the input isn’t boolean the $var has to be converted to boolean before truth
      // can be determined
      else
      {
    if ( is_null( $var ) )
    {
    $return = FALSE;
    }
          elseif ( is_numeric( $var ) )
          {
    if ( $var > 0 )
    $return = TRUE;
    else
    $return = FALSE;
    }
          elseif ( is_string( $var ) )
          {
    if ( strlen( $var ) > 0 )
    $return = TRUE;
    else
    $return = FALSE;
    }
          elseif ( is_array( $var ) )
          {
    if ( count( $var ) > 0 )
    $return = TRUE;
    else
    $return = FALSE;
    }
          elseif ( is_object( $var ) )
          {
    if ( ! is_null( $var ) )
    $return = TRUE;
    else
    $return = FALSE;
    }
          // If type wasn’t determined yet use empty()
          else
          {
    if ( ! empty( $var ) )
    $return = TRUE;
    else
    $return = FALSE;
    }
      }

      // Return the truth of the matter
      return $return;
    }</code></pre>

  • #4 / Sep 13, 2010 12:15pm

    danmontgomery

    1802 posts

  • #5 / Sep 14, 2010 12:39am

    niechen

    1 posts

    1. Has to be stupid.
    2. Has to be completely irrelevant.
    3. Has to make the same people who laugh at the above thread, laugh.
    4. Mod Edit: Has to not be spam. G’day.

  • #6 / Sep 17, 2010 6:51pm

    usmc

    74 posts

    Zend Framework won this competition a while back.  Once they wrapped existing php functions with their own it was over.

  • #7 / Sep 17, 2010 8:42pm

    cahva

    662 posts

    Whats the prize for the winner? 😉

    I found this piece of “code” that I made in 2004(according to file creation time). Its run from shell and creates big letters from string and scrolls the text from right to left. Whee! Impressed? Me neither :cheese:

    Heres the code. Needed fontfile included as attachment.

    #!/usr/bin/php
    <?php
    
    scroll('greetings to megalamers!!!! my first php-intro ever.. and last');
    
    function scroll($text) {
        echo "\033c";
        $font=file('font.txt');
        for ($i=33; $i<94;$i++) {
            $letter=chr($i);
            $key=array_search($letter."\n",$font);
            if ($key!==false) {
                for($j=0;$j<7;$j++) {
                    $bigletter[$letter][$j]=chop($font[$key+($j+1)]);
                }
            }
        }
    
        $scrolltext=strtoupper('       '.$text);
        $lenght=strlen($scrolltext);
        $row=array();
        $row=array_fill(0, 7, '');
    
        for($i=0;$i<$lenght; $i++) {
            for ($j2=0;$j2<7;$j2++) {
                if ($scrolltext{$j}==' ')
                    $row[$j2].='        ';
                else
                    $row[$j2].=' '.str_pad($bigletter[$scrolltext{$i}][$j2],7);
            }
        }
    
        $maxlen=strlen($row[0]);
    
        for ($i=0;$i<$maxlen;$i++) {
            for ($i2=0;$i2<7;$i2++) {
                $row2[$i2]=substr($row[$i2],$i,50);
            }
    
            echo implode("\n",$row2);
            usleep(10000);
            echo "\033c";
        }
    }
  • #8 / Sep 19, 2010 1:47am

    tyteen4a03

    2 posts

    function select($thing='') {
        $return = empty($thing) ? 'SELECT '.$thing : 'SELECT *';
        return $return;
    }
    
    function from($where) {
        return 'FROM `'.$where.'`';
    }
    function where($condition) {
        return 'WHERE '.$condition;
    }
    
    $query = select('crap').from('crappytable').where('crap="crap"');
    mysql_query($query);
  • #9 / Sep 22, 2010 7:31am

    Angel Web Design

    11 posts

    Zend Framework won this competition a while back.  Once they wrapped existing php functions with their own it was over.

    Extend that into Magento and we’re onto a winner..

  • #10 / Sep 22, 2010 8:34am

    Vheissu

    278 posts

    Zend Framework won this competition a while back.  Once they wrapped existing php functions with their own it was over.

    Extend that into Magento and we’re onto a winner..

    Zend for first prize without-a-doubt. Having been subjected to this framework for over one year now (and counting) as the lead developer at work is pretty big on using it even though it seems to complicate and bury things through multiple levels of abstraction.

    Magento definitely for second though.

  • #11 / Sep 22, 2010 10:08pm

    skunkbad

    1326 posts

    <?php
    class echo {
        public $word;
        public function display($word){
            $this->word = $word;
            return $this->word;
        }        
    }
    
    $output = new echo;
    $hello_world = 'Hello World';
    echo $output->display($hello_world);
  • #12 / Sep 23, 2010 4:19am

    Jamie Rumbelow

    546 posts

    <?php
    
    /* Master class */
    class Object {    
        public function __construct() {
            if (method_exists($this, "__construct")) {
                call_user_func_array(array($this, '__construct'), func_get_args());
            }
        }
    
        public function __call($method, $params = array()) {
            if (method_exists($this, $method)) {
                call_user_func_array(array($this, $method), $params);
            }
        }
    }
  • #13 / Sep 23, 2010 9:56am

    danmontgomery

    1802 posts

    public function __construct() {
    if (method_exists($this, "__construct")) {
        call_user_func_array(array($this, '__construct'), func_get_args());
    }
        }

    Haven’t tried this, but wouldn’t it just loop infinitely?

  • #14 / Sep 23, 2010 10:08am

    Jamie Rumbelow

    546 posts

    public function __construct() {
    if (method_exists($this, "__construct")) {
        call_user_func_array(array($this, '__construct'), func_get_args());
    }
        }

    Haven’t tried this, but wouldn’t it just loop infinitely?

    Only if you called parent::__constructor(); Haha. That’s why it’s so useless - it’s never even called.

  • #15 / Oct 06, 2010 11:51am

    Angel Web Design

    11 posts

    @vheissu Magento is built on top of zend, but incorporates a load of crap on the top of it to boot 😛

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases