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

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

    +82

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public class ExceptionAction extends ActionImpl {
    
        public void nullPointer() throws Throwable {
            throw new NullPointerException();
        }
    
    }

    Гениально же!

    nafania217518, 29 Мая 2012

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

    +125

    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
    (defun question-2 ()
      (let ((b '(1 2 3))
            (a '(1 2 3 4))
            (com (make-hash-table :test #'equal)))
        (labels ((put-sorted (x)
                   (let ((key
                          (sort
                           (flatten
                            (copy-tree x)) #'<)))
                     (if (gethash key com)
                         (incf (gethash key com))
                         (setf (gethash key com) 1)))))
          (values (remove-if
           #'(lambda (x)
               (prog ((results
                      (do ((x x (cdr x)) (r))
                          (nil)
                        (setf r (append (cadar x) r))
                        (when (null (cdr x))
                          (return r)))))
                 (dolist (y a)
                   (when (not (member y results))
                     (go remove-it)))
                 (put-sorted results)
                 (go keep-it)
                 remove-it (return t)
                 keep-it nil))
           (all-functions b (cartesian-product a))) com))))

    Ну, чем бы еще порадовать. Вот, родилось во время проверки домашних заданий :)

    wvxvw, 29 Мая 2012

    Комментарии (11)
  4. Perl / Говнокод #10339

    −122

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    my (@data) = $content =~ m#href="/show/\d+.*?">(.*?)</a>.*?(Ep: \d+).*?(at \d{2}:\d{2}).*?</small>#gsi;
    	
    for (my $i; $i < @data;){
    	$data .= $data [$i++].' '.$data [$i++].' '.$data [$i++];
    	$data .= "\n" unless $i == @data;
    }

    Распарсил.

    VictorVonSpok, 21 Мая 2012

    Комментарии (11)
  5. C# / Говнокод #10298

    +96

    1. 1
    2. 2
    3. 3
    4. 4
    OdbcCommand dist_cmd = ifx_conn.CreateCommand();
                    dist_cmd.CommandText = string.Format(@"select  -1 as districtid, '-=ВСІ=-' as districtname from systables where  tabname = 'systables'                               union all 
                                            select id as districtid , cpz_name as districtname from  post_cpz where directorate_id = {0} and id != 0 ORDER BY 2", (String.IsNullOrEmpty(DDL_obl.SelectedValue))?"-1":DDL_obl.SelectedValue);
                    reader = dist_cmd.ExecuteReader();

    в процессе рефакторинга, убирая NHibernate код был заменен на это

    bercerker, 17 Мая 2012

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

    +78

    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
    private function isRussianCar($car){
    
                               # Определялка российских машин.
    
                                if ($car['make_id'] == '107') return true;
                                if ($car['make_id'] == '108') return true;
    		if ($car['make_id'] == '109') return true;
    		if ($car['make_id'] == '110') return true;
    		if ($car['make_id'] == '111') return true;
    		if ($car['make_id'] == '112') return true;
    		if ($car['make_id'] == '113') return true;
    		if ($car['make_id'] == '114') return true;
    		if ($car['make_id'] == '115') return true;
    		if ($car['make_id'] == '116') return true;
    		if ($car['make_id'] == '117') return true;
    		return false;
    	
        }

    Нашёл в одном из проектов

    daemon_master, 15 Мая 2012

    Комментарии (11)
  7. C++ / Говнокод #10187

    +56

    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
    #/*        */include<stdio.h>
                        /*    */int/**/main(int/**/o,char**O){int      y[4],
                      r[4]   ,z[4],C,h,i,n,a,t,s,u[2][3][4]={{{6,9,0,3}     ,
                    {     1,10,4,7},{5,11,2,8}},{{3,0,6,9},{10,1,4,7},{     8,2,5
              ,11}}},    M,I,R,A,K,U[2],RU[2],N[2],_=2;FILE*x[03]      ;  unsigned/*,
           */char/**/ p[2][3<<16],d[12],b[256][256];float/**/f,q        [12];if((o<4)){
          return!puts("<a.ppm>\40<b.ppm>\40<output.ppm>\40[odd]")    ;}else{for(h=0;h<2;
        h++){M=SEEK_SET;if(!(x[h]=fopen(O[h+1],"rb")))goto/**/e;if( (int)fread(*b,1,256,x[h
        ])<1||sscanf((char*)*b,*O="P6\n%d\40%d\n%d\n",&U[h],&N[h],&i)-3||i-255)goto/**/e;for(
       i=C=RU[h]=0;i<256&&!RU[h];i++)if(b[0][i]=='\n')if(++C==3)fseek(x[h],RU[h]=i+1,M);if(!RU
      [h]||U[h]<1||U[h]>(1<<16))goto/**/e;}if(*U-U[1]||*N-N[1])goto/**/s;for(h=0;h<256;h++)for(
      i=0;i<256;b[h][i++]=0) ;for(i=0;i<*N;i++){for(h=0;h<2;h++)if(fread(p[h],3**U,01,x[h])!=1)
     goto/**/e;for(h=0;h<3**  U;h++)b[p[0][h]][p[1][h]]=1; }*y=*r=y[2]=r[2]=64;y[1]=r[1]=y[3]=r[
     3]=192;A=(y[1]-*y)*(y[   3]-y[2]);for(M=64;M>0; M/=2) {for(t=-1;t<=0;t++)if((*z=*r+t*M)>-1)
     for(I=-1;I<1;I++)if((z    [ 2]=r[2]+I*M)> (-1))  for   (s=1;s>-1;s--)if((z[1]=r[1]+s*M)<257
     )for(R=1;R>-1;R--)if(     +  257>(z[3]=r  [3]+R*  M)   )if((K=(z[1]-z[0])*(z[3]-z[2]))>A){
    for(h=C=0;h<256&&C> -1           &&C<256;   h  ++)for      (n=h*(z[1]-z[i=0])/256+*z;C>-1&&
    i<256&&C<256;i++){a =  i*(z[3]-z              [2    ])/256+ z[2];if(b[h][i])C=(3*n-a)/2;}if
     (C>-1&&C<256)for(C  =0     ,   A=           K  ;C   <4;++   C)y[C]=z[C];}for(C=0;C<4;C++)r
     [C]=y[C];}if(!(x[2     ]   =/*                 */   fopen   (O[03],"wb+")))goto/**/e;else{
     fprintf(x[2],*O,2*    *U,2**N,+               255);for(h=   0;h<(2);h++)fseek(x[h],RU[h],
     SEEK_SET);C=(o<5)?    1/***/:00               ;/***/R=1+(  1<<16);for(i=0;i<*N;i++){for(h
     =0;h<2;h++)if(fread   (/****/p[               h/****/],+3  **U,1,x[h])!=1)goto/**/e;for(
      M=0;M<7;M+=6)for(h    =/**/0;*                U/**/>h;h  ++){for(n=0;n<3;n++){for(a=0;
       a<2;a++)q[u[C][n]     [a]]=p                  [a][h    *3+n]*(r[a*2+1]-r[a*2])/256.f
       +r[a*2];q[u[C][n]                                     [2]]=q[u[C][n][3]]=(3*q[*u[C][
        n]]-q[u[C][n][1]]                                    )/2;}for(n=0;n<12;d[n++]=t<0?
        0:(t>255?255:t)){               t       =          q[n];f=q[n]-t;_=(_*75)%R;if(_<f
         *R)++ t;}fwrite(d               +M,6,1,            x[2]);}}}}for(h=0;h<3;h =h + 1
         )  t=   fclose(x [h                               ]);     return  (t*1);s  :
             *O    ="si"    /*                           */       "ze ";   printf  (
               *     /*'      P*/                     O);        ;e  :    return
                      !          /*w*/            puts                      /*;
                                      */("error");                            }

    http://uguu.org/sources.html юзайте ребята.

    KusokGovna, 04 Мая 2012

    Комментарии (11)
  8. C++ / Говнокод #10115

    +18

    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
    //---------------------------------------------------------
    void Link::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
    {
        Q_UNUSED(option);
        Q_UNUSED(widget);
    
    
        if ( mA && mB )
        {
            QPen pen(mColor, mPenWidth);
            painter->setPen(pen);
    
    
            if ( smooth() )
                painter->setRenderHint(QPainter::Antialiasing, true);
    
    
            QString ptname = mA->objectName() + QString("_point%1").arg(mAPoint);
            QDeclarativeItem *aConn = mA->findChild<QDeclarativeItem*>(ptname);
            QDeclarativeItem *bConn = *(QDeclarativeItem**) mB->property("root").constData();
    
    
            QRectF arect(aConn->x() + mA->x() - mB->x(), aConn->y() + mA->y() - mB->y(), aConn->width(), aConn->height());
            QRectF brect(bConn->x(), bConn->y(), bConn->width(), bConn->height());
    
    
            QLineF line(arect.center(), brect.center());
    
    
            painter->drawLine(line);
    
    
            if ( widget )
                widget->update();
       }
    }

    Из коммита где-то в 4:00 :)

    Elvenfighter, 30 Апреля 2012

    Комментарии (11)
  9. JavaScript / Говнокод #10051

    +172

    1. 1
    $(document.getElementById(containerid))

    beardeddev, 26 Апреля 2012

    Комментарии (11)
  10. PHP / Говнокод #10013

    +120

    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
    if(isset($_POST['myinfo'])){
    	if(trim($_POST['email'])=="" && !mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `userid`='".$_SESSION['userid']."' AND `vkid`!='';"))){
    		$aSuccess=false;
    		$aErrorType="eEMail";
    		$aErrorMsg="Введите адрес электронной почты.";
    	} elseif(strlen(trim($_POST['email']))>"128" && !mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `userid`='".$_SESSION['userid']."' AND `vkid`!='';"))){
    		$aSuccess=false;
    		$aErrorType="eEMail";
    		$aErrorMsg="Слишком длинный адрес электронной почты.";
    	} elseif(!preg_match("/^([-a-zA-Z0-9._]+@[-a-zA-Z0-9.]+(\.[-a-zA-Z0-9]+)+)*$/", trim($_POST['email'])) && !mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `userid`='".$_SESSION['userid']."' AND `vkid`!='';"))){
    		$aSuccess=false;
    		$aErrorType="eEMail";
    		$aErrorMsg="Некорректный адрес электронной почты.";
    	} elseif(mysql_num_rows(mysql_query("SELECT `email` FROM `users` WHERE `email` = '".htmlspecialchars(trim(strtolower($_POST['email'])))."' AND `userid`!='".$_SESSION['userid']."' LIMIT 1"))>0 && !mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `userid`='".$_SESSION['userid']."' AND `vkid`!='';"))){
    		$aSuccess=false;
    		$aErrorType="eEMail";
    		$aErrorMsg="Пользователь с таким адресом электронной почты уже зарегистрирован.";
    	} elseif(strlen(trim($_POST['about']))>"12000"){
    		$aSuccess=false;
    		$aErrorType="eAbout";
    		$aErrorMsg="Вы предоставили слишком много информации о себе.";
    	} else {
    		if(!mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `userid`='".$_SESSION['userid']."' AND `vkid`!='';"))){
    		$mail="`email`='".htmlspecialchars(trim(strtolower($_POST['email'])))."', ";
    		} else {
    		$mail="";
    		}
    		mysql_query("UPDATE users SET ".$mail."`about`='".mysql_real_escape_string(trim($_POST['about']))."' WHERE userid='".$_SESSION['userid']."';");
    		$aSuccess=true;
    		header("Location: editme.php?msg=SUCCESSFULLY_UPDATED");
    		exit();
    	}
    }

    Код, используемый в моём самописном движке для изменения пользователем своего профиля на сайте.

    BiggestFox, 22 Апреля 2012

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

    +128

    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
    Unsigned long int getset (void)
    {unsigned long int a; int k; h=0;
    While (‘<не конец файла>==<читать число в k>’);
    {switch k
    {case 1: h = h/0x 0001; break;
    case 2: h = h/0x 0002; break;
    case 3: h = h/0x 4; break;
    case 4: h = h/0x 8; break;
    case 5: h = h/0x 10; break;
    case 6: h = h/0x 20; break;
    case 7: h = h/0x 40; break;
    case 8: h = h/0x 80; break;
    …
    case 30: h = h/0x 2000 0000; break;
    case 31: h = h/0x 4000 0000; (- 1 на 31 месте) break;
    case 32: h = h/0x 8000 0000; (- 1 на 32 месте) break;
    }
    }
    return (h)
    }

    Мне кажется или весь смысл сводиться к h = h/2^(k-1)

    ApeNN, 21 Апреля 2012

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