1. Лучший говнокод

    В номинации:
    За время:
  2. JavaScript / Говнокод #7064

    +160

    1. 1
    2. 2
    3. 3
    uWeb_b = function(text,cl,onclick,width){return '<div style="width:'+width+'px" class='+cl+' onclick='+onclick+' id="uWeb_Button">'+text+'</div>';}
    uWeb_b2 = function(text,cl,onclick,width){return '<div style="width:'+width+'px" class='+cl+' onclick='+onclick+' id="uWeb_Button2">'+text+'</div>';}
    uWeb_b3 = function(text,cl,onclick,width){return '<div style="width:'+width+'px" class='+cl+' onclick='+onclick+' id="uWeb_Button3">'+text+'</div>';}

    stuffort, 26 Июня 2011

    Комментарии (3)
  3. Си / Говнокод #6978

    +139

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    #include <cstdio>
    #include <malloc.h>
    
    int number;
        printf("Int to c_str convertation whith separator: ");
        do {
            printf("Enter a number (int): ");
        }
        while (!scanf ("%d",&number));
        bool negative = number<0;
        number=abs(number);
        char* reversed = (char*)(malloc(sizeof(char)));
        *reversed = 0;
        int divider=1;
        unsigned char i=3;
        int buf;
        int val = 0;
        int size=1;
       forever{
            buf=number%(divider*10);
            i--;
            size++;
            reversed = (char*)(realloc(reversed,size*sizeof(*reversed)));
            *(reversed+size*sizeof(*reversed)-1) = (buf-val)/divider+48;
            divider*=10;
            val=buf;
            if (!i){
                size++;
                reversed = (char*)(realloc(reversed,size*sizeof(*reversed)));
                *(reversed+size*sizeof(*reversed)-1)=32;
                i=3;
            }
            if (buf==number) {break;}
        }
        if (negative){
            size++;
            reversed = (char*)(realloc(reversed,size*sizeof(*reversed)));
            *(reversed+size*sizeof(*reversed)-1)='-';
        }
        char* output = (char*)(malloc(size*sizeof(*reversed)));
        for (i=0;i<size*sizeof(*reversed);i++){
            *(output+i) = *(reversed+size*sizeof(*reversed)-((1+i)*sizeof(*reversed)));
        }
         printf("Number as char* is: %s",output);

    Выводит число в строку, вставляя пробел после каждых 3-х цифр.

    Sacha_D, 17 Июня 2011

    Комментарии (3)
  4. PHP / Говнокод #6967

    +157

    1. 1
    print str_replace('collapsed', '', str_replace('expanded', '', str_replace('leaf', '', menu_tree($menu_name = 'menu-fabric'))))

    Вывод меню через файл шаблона в Drupal…

    Razunter, 16 Июня 2011

    Комментарии (3)
  5. SQL / Говнокод #6949

    −121

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    create or replace procedure rout_cancel (
      p_sql varchar2
    ) is
      v_curs sys_refcursor;
    begin
      if v_curs%isopen then
        close v_curs;
      end if;
      begin
        open v_curs for p_sql;
      exception
        when others then
          raise_application_error(-20000, 'Unable to open cursor');
      end;
      rout_cancel_details(v_curs);
      close v_curs;
    end;

    6-8: Кто ж тебя открыть-то успел?!

    dwinner, 14 Июня 2011

    Комментарии (3)
  6. PHP / Говнокод #6933

    +164

    1. 1
    2. 2
    3. 3
    foreach ($params as $k => $v) {
                eval('$this->' . $k . ' = $v;');
            }

    Yurik, 12 Июня 2011

    Комментарии (3)
  7. ActionScript / Говнокод #6793

    −108

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    addEventListener(Event.ENTER_FRAME, function(e){clip.mov.apply(clip,[e])});
    
    clip.mov = function(e:Event):void{
    	if(!this.is_mov && !this.is_mov_end) return;
    		this.ii++;
    		if(this.ii == this.speed){
    			this.clip.x = this.end_x;
    			this.clip.y = this.end_y;
    		if(this.is_mov_end){
      			this.is_mov = false;
      			this.is_mov_end = false;
    		} else {
      			this.getNewCoord.apply(this);
    		}
     	return;
    	}
    	this.clip.x = this.start_x + int((this.end_x - this.start_x)/this.speed)*this.ii + int(Math.random()*2)-1;
    	this.clip.y = this.start_y + int((this.end_y - this.start_y)/this.speed)*this.ii + int(Math.random()*2)-1;
    }

    Дело было вечером, делать было нечего...
    Здесь имеет место вызов функции с подменой this.

    kyzi007, 31 Мая 2011

    Комментарии (3)
  8. Си / Говнокод #6744

    +140

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    // connection reset by peer?
          if(tcpflags & TCP_FLAG_RST)
          {
             st->status = TCP_CLOSED;
             if( (st->status == TCP_ESTABLISHED) ||
                (st->status == TCP_FIN_WAIT) )
             {
                tcp_closed(id, 1);
             }
             return;
          }

    из одного маленького эмбеддед-проектика)

    odmin, 24 Мая 2011

    Комментарии (3)
  9. PHP / Говнокод #6715

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if ($rightDisplayDelete == 1) {
        $images = $model->getData(1);
        $this->tmpl['pagination']	= &$model->getPagination(1);
    } else {
        $images = $model->getData(0);
        $this->tmpl['pagination']	= &$model->getPagination(0);
    }

    И снова модуль Phocagallery для Joomla!

    somebody, 20 Мая 2011

    Комментарии (3)
  10. ActionScript / Говнокод #6694

    −109

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    override public function call(... rest):void
    {
    	var callname:String = rest[0];
    	var paramsStr:String = "";
    	
    	for(var i:int = 1; i < rest.length; i++)
    	{
    		paramsStr += rest[i] + ((i == rest.length - 1) ? "" : ",");
    	}
    	
    	ExternalInterface.call("page.appplicationToVideoPage", callname, paramsStr);
    }

    Все тот же автор продолжает говнореализацию встроенных функций и классов. (Особого внимания заслуживает говноархитектура предполагающая вызывать reflection API через reflection. Т.е. page.appplicationToVideoPage - это функция, которая парсит аргументы обратно, и вызывает функцию callname с параметрами полученными из paramsStr. Человека не устроил ExternalInterface, и он решил его тоже, через жопу, реализовать еще раз, средствами, естесственно ExternalInterface).

    wvxvw, 17 Мая 2011

    Комментарии (3)
  11. ActionScript / Говнокод #6625

    −110

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public function setCategory(categoryType:String):void
    {
    	giftIcon.visible 		= (categoryType == ActionsEnum.GIFTS);
    	effectIcon.visible 		= (categoryType == ActionsEnum.EFFECTS);
    	skinIcon.visible 		= (categoryType == ActionsEnum.SKINS);	
    	gamesIcon.visible 		= (categoryType == ActionsEnum.GAMES);
    	activtiesIcon.visible 	= (categoryType == ActionsEnum.APPLICATIONS);
    }

    Глядя на мир нельзя не удивлятся.

    wvxvw, 11 Мая 2011

    Комментарии (3)