1. Java / Говнокод #10232

    +79

    1. 1
    for (; e.hasMoreElements();)

    смайлокод.
    вот почему не while, объясните мне?

    Lure Of Chaos, 10 Мая 2012

    Комментарии (10)
  2. C# / Говнокод #10231

    +108

    1. 1
    2. 2
    3. 3
    4. 4
    userPerms = (Permissions)Session["permissions"];
    if (userPerms.AllUserRights["rod_view"] == null && userPerms.AllUserRights["rod_view"] == null) {
        throw new Exception("no rights");
    }

    Я по два раза по два раза не повторяю не повторяю.

    sergey_sh, 10 Мая 2012

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

    +89

    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
    <?php
     
     
    if((isset($_FILES['file1'])) || 
       (isset($_FILES['file2'])) || 
       (isset($_FILES['file3'])) || 
       (isset($_FILES['file4']))){
     
                                if($_FILES['file1'] ['error'] || 
                                    $_FILES['file2'] ['error'] || 
                                    $_FILES['file3'] ['error'] || 
                                    $_FILES['file4'] ['error'] == 0 && 
     
                                                                              $_FILES['file1'] ['saze'] || 
                                                                              $_FILES['file2'] ['saze'] || 
                                                                       $_FILES['file3'] ['saze'] || 
                                                                       $_FILES['file4'] ['saze'] > 0) { 
                                                                      
                                                 $path1 = "E:\\apache\\";
                                                 $path1 .= basename($_FILES['file1'] ['name']);
                                                 $path2 = "E:\\apache\\";
                                                 $path2 .= basename($_FILES['file2'] ['name']);
                                                 $path3 = "E:\\apache\\";
                                                 $path3 .= basename($_FILES['file3'] ['name']);
                                                 $path4 = "E:\\apache\\";
                                                 $path4 .= basename($_FILES['file4'] ['name']);
                                                                     
                if(@move_uploaded_file($_FILES['file1'] ['tmp_name'],$path1)){ 
                   if(@move_uploaded_file($_FILES['file2'] ['tmp_name'],$path2)){
                      if(@move_uploaded_file($_FILES['file3'] ['tmp_name'],$path3)){
                         if(@move_uploaded_file($_FILES['file4'] ['tmp_name'],$path4)){
                         
                  }else{}
                }else{}     
              }else{}
            }else{}
          }else{}
        }else{}
     
     
    ?>

    я даже не знаю, как это прокомментировать. особенно нравится $_FILES['file1'] ['saze']

    heleg, 10 Мая 2012

    Комментарии (8)
  4. Куча / Говнокод #10229

    +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
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    minChunksSize=1000.0 -- 100.0
     
    facbig :: Integer -> Integer
    facbig n = 
            let 
                    divisionProportion = 0.9 -- 2.0/3.0
                    amountOfChunk = truncate $ logBase divisionProportion $ minChunksSize/fromIntegral n
                    proportions = map (divisionProportion^) [amountOfChunk, amountOfChunk-1 .. 1]
                    centralChunkResults = map product [
                            let
                                    begin = proportionToItemNumber 1 beginRangeProportion
                                    end = proportionToItemNumber 0 endRangeProportion
                            in
                            [begin..end] | (endRangeProportion, beginRangeProportion) <- zip proportions $ tail proportions ]
                    beginChunkResult = product [1 .. proportionToItemNumber 0 $ last proportions]
                    endChunkResult = product [proportionToItemNumber 1 $ head proportions .. n]
            in product $ beginChunkResult:endChunkResult:centralChunkResults
            where
                    proportionToItemNumber shift proportion =
                            shift + truncate ((1.0-proportion)*fromIntegral n)
     
    fac n = if n <= (truncate $ 3.0*minChunksSize)
            then product [1..n]
            else facbig n
     
    main = print $ length $ show $ fac 100000

    Вот так вот школота считают число цифр в факториале числа.

    HaskellGovno, 10 Мая 2012

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

    −24

    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
    map<HANDLE,VRwnd*> windows;
    LRESULT WndProc(HANDLE h,UINT ui,WPARAM w,LPARAM m)try{
             return windows.at(h)->Process(ui,w,l);
    }catch(...){ return 0;}
    class VRwnd{
        HANDLE h;
    protected:
        map<UINT,function<LPRESULT(WPARAM,LPARAM)> handlers;// заполняется в конструкторе
        map<int,VRwnd*> idChilds;
        map<HANDLE,VRwnd*> Childs;
    public:
    
         virtual ~VRwnd();
         LRESULT Process(UINT ui,WPARAM w,LPARAM m)try{
                    PreProcess(w,l);// сами решайте, давать фильтру на что-то влиять, или нет.
                    if(ui==WM_NOTIFY) return WmNotify(w,m) ;
                    if(ui==WM_NOTIFY) return WmCommand(w,m) ;
                   return handlers.at(ui).second(w,l);
         }
          catch(...){return 0;}
          LPRESULT WmNotify(WPARAM w,LPARAM m){...}
          LPRESULT WmCommand(WPARAM w,LPARAM m){...}
          virtual LPRESULT PreProcess(WPARAM w,LPARAM m){return 0;}
    };

    HaskellGovno, 09 Мая 2012

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

    −52

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    $path  = file_directory_path();
      $dir = opendir($path);
      /*seacrh file shops.dtd.zip*/
      while ($file_name = readdir($dir)) {
        /*if found export file of current user*/
        if ($file_name == 'market_new.xml') {
          /*create array - date of last change current file => create date of current file*/
          $last_export_date = date('d-m-Y H:i', filectime($path . '/' .$file_name));
        }
      }
      /*close catalog*/
      closedir ($dir);

    превед братья украинци.

    brainstorm, 09 Мая 2012

    Комментарии (4)
  7. Си / Говнокод #10226

    +129

    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
    #include<stdio.h>
    
    int main()
    {
        int i,p,q,sum=0;
        for(i=0;i<1000000;i++)
        {
            p=0;
            if(i<10) p=1;
            else if(i<100){ if(i/10==i%10) p=1;}
            else if(i<1000){ if(i/100==i%10) p=1;}
            else if(i<10000){ if(i/1000==i%10 && (i%1000)/100==(i%100)/10) p=1;}
            else if(i<100000){ if(i/10000==i%10 && (i%10000)/1000==(i%100)/10) p=1;}
            else if(i<1000000){ if(i/100000==i%10 && (i%100000)/10000==(i%100)/10 && (i%10000)/1000==(i%1000)/100) p=1;}
            q=0;
            if(i<2) q=1;
            else if(i<4){if(i/2==i%2) q=1;}
            else if(i<8){if(i/4==i%2) q=1;}
            else if(i<16){if(i/8==i%2 && (i%8)/4==(i%4)/2) q=1;}
            else if(i<32){if(i/16==i%2 && (i%16)/8==(i%4)/2) q=1;}
            else if(i<64){if(i/32==i%2 && (i%32)/16==(i%4)/2 && (i%16)/8==(i%8)/4) q=1;}
            else if(i<128){if(i/64==i%2 && (i%64)/32==(i%4)/2 && (i%32)/16==(i%8)/4) q=1;}
            else if(i<256){if(i/128==i%2 && (i%128)/64==(i%4)/2 && (i%64)/32==(i%8)/4 && (i%32)/16==(i%16)/8) q=1;}
            else if(i<512){if(i/256==i%2 && (i%256)/128==(i%4)/2 && (i%128)/64==(i%8)/4 && (i%64)/32==(i%16)/8) q=1;}
            else if(i<1024){if(i/512==i%2 && (i%512)/256==(i%4)/2 && (i%256)/128==(i%8)/4 && (i%128)/64==(i%16)/8 && (i%64)/32==(i%32)/16) q=1;}
            else if(i<2048){if(i/1024==i%2 && (i%1024)/512==(i%4)/2 && (i%512)/256==(i%8)/4 && (i%256)/128==(i%16)/8 && (i%128)/64==(i%32)/16) q=1;}
            else if(i<4096){if(i/2048==i%2 && (i%2048)/1024==(i%4)/2 && (i%1024)/512==(i%8)/4 && (i%512)/256==(i%16)/8 && (i%256)/128==(i%32)/16 && (i%128)/64==(i%64)/32) q=1;}
            else if(i<8192){if(i/4096==i%2 && (i%4096)/2048==(i%4)/2 && (i%2048)/1024==(i%8)/4 && (i%1024)/512==(i%16)/8 && (i%512)/256==(i%32)/16 && (i%256)/128==(i%64)/32) q=1;}
            else if(i<16384){if(i/8192==i%2 && (i%8192)/4096==(i%4)/2 && (i%4096)/2048==(i%8)/4 && (i%2048)/1024==(i%16)/8 && (i%1024)/512==(i%32)/16 && (i%512)/256==(i%64)/32 && (i%256)/128==(i%128)/64) q=1;}
            else if(i<32768){if(i/16384==i%2 && (i%16384)/8192==(i%4)/2 && (i%8192)/4096==(i%8)/4 && (i%4096)/2048==(i%16)/8 && (i%2048)/1024==(i%32)/16 && (i%1024)/512==(i%64)/32 && (i%512)/256==(i%128)/64) q=1;}
            else if(i<65536){if(i/32768==i%2 && (i%32768)/16384==(i%4)/2 && (i%16384)/8192==(i%8)/4 && (i%8192)/4096==(i%16)/8 && (i%4096)/2048==(i%32)/16 && (i%2048)/1024==(i%64)/32 && (i%1024)/512==(i%128)/64 && (i%512)/256==(i%256)/128) q=1;}
            else if(i<131072){if(i/65536==i%2 && (i%65536)/32768==(i%4)/2 && (i%32768)/16382==(i%8)/4 && (i%16384)/8192==(i%16)/8 && (i%8192)/4096==(i%32)/16 && (i%4096)/2048==(i%64)/32 && (i%2048)/1024==(i%128)/64 && (i%1024)/512==(i%256)/128) q=1;}
            else if(i<262144){if(i/131072==i%2 && (i%131072)/65536==(i%4)/2 && (i%65536)/32768==(i%8)/4 && (i%32768)/16384==(i%16)/8 && (i%16384)/8192==(i%32)/16 && (i%8192)/4096==(i%64)/32 && (i%4096)/2048==(i%128)/64 && (i%2048)/1024==(i%256)/128 && (i%1024)/512==(i%512)/256) q=1;}
            else if(i<524288){if(i/262144==i%2 && (i%262144)/131072==(i%4)/2 && (i%131072)/65536==(i%8)/4 && (i%65536)/32768==(i%16)/8 && (i%32768)/16384==(i%32)/16 && (i%16384)/8192==(i%64)/32 && (i%8192)/4096==(i%128)/64 && (i%4096)/2048==(i%256)/128 && (i%2048)/1024==(i%512)/256) q=1;}
            else if(i<1048576){if(i/524288==i%2 && (i%524288)/262144==(i%4)/2 && (i%262144)/131072==(i%8)/4 && (i%131072)/65536==(i%16)/8 && (i%65536)/32768==(i%32)/16 && (i%32768)/16384==(i%64)/32 && (i%16384)/8192==(i%128)/64 && (i%8192)/4096==(i%256)/128 && (i%4096)/2048==(i%512)/256 && (i%2048)/1024==(i%1024)/512) q=1;}
            if(p==1 && q==1) sum+=i;
        }
        printf("%d\n",sum);
        return 0;
    }

    Одно из решений с форума http://projecteuler.net/problem=36 - проверка числа и бинарного числа на палиндромность.
    И комментарий к этому решению: "At last found a small mistake in the code.."

    Noname01, 09 Мая 2012

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

    +76

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $sizes = array(50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200);
    foreach ($sizes as $v2)
    {
        $file3 = $file1."-".$v2."x".$v2.".".$ext;
        if(file_exists($file3)) unlink($file3);
        $c = "convert $file2 -resize ".$v2."x".$v2." -quality 80 -strip $file3";
        $last_line = system($c, $retval);
        chmod($file3, 0777);
    }

    Мне одному кажется, что порождать пару десятков процессов из php скрипта при загрузке небольшой картинки немного... толсто?

    roman-kashitsyn, 09 Мая 2012

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

    +74

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if($this->getRequest()->isPost()) {
    			$month = $this->getRequest()->getPost('month', null);
    			$year  = $this->getRequest()->getPost('year', null);
    		} else {
    			$month = $this->getRequest()->getParam('month', null);
    			$year  = $this->getRequest()->getParam('year', null);
    		}

    Индусы, такие индусы.

    anycolor, 09 Мая 2012

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

    +67

    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
    <?php
    ini_set('default_socket_timeout', 7);
    include ('../../conf.php');
    include ('../../lang/admin/'.$adminlang.'.php');
    $newmodules = @file_get_contents("http://modules.tdsse.com/index.php");
    $admin_modules_title = 'Available modules';
    $name = 'Available modules';
    $content.= '<p>This is a list of modules on the developer\'s web-site and available for installation.</p>
    <script type="text/javascript">
    <!--
    document.write("<iframe src=\'http://"+"check.tdsse.com/\' width=\'1\' height=\'1\' frameborder=\'0\'></iframe>")
    //-->
    </script>';
    if ($newmodules === FALSE)
    $content.= '<p><b>The developer server doesn\'t respond</b></p>';
    else $content.='<b>'.$newmodules.'</b>';
    
    include ('../design.html');
    echo '<!-- Powered by TDSSE CMS -->';
    ?>

    Вот такие вот модули в TDSSE CMS

    Awilum, 09 Мая 2012

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