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

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

    −90

    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
    def runRidor():
    	isDirty = 0
    	#Except (DebugSize <= 14) and (ImageVersion <= 760) and (VirtualSize2 > 992) and (ExportSize <= 80.5) => isDirty = 1  (1702.0/16.0) [855.0/5.0]
    	if input.DebugSize <= 14 and input.ImageVersion <= 760 and input.VirtualSize2 > 992 and input.ExportSize <= 80.5:
    		isDirty = 1
    #Except (DebugSize <= 14) and (ImageVersion <= 4525) and (ExportSize <= 198.5) and (ResourceSize <= 37532) and (VirtualSize2 <= 6) and (ResourceSize <= 7348) and (ResourceSize > 1773) => isDirty = 1  (106.0/0.0) [48.0/0.0]
    	elif input.DebugSize <= 14 and input.ImageVersion <= 4525  and input.ExportSize <= 198.5 and input.ResourceSize <= 7348 and input.VirtualSize2 <=6 and input.ResourceSize > 1773:
    		isDirty = 1
    #Except (DebugSize <= 14) and (ImageVersion <= 4950) and (ExportSize <= 192) and (IatRVA > 256) and (VirtualSize2 > 42) and (ExportSize <= 56) and (NumberOfSections > 3.5) => isDirty = 1  (193.0/0.0) [91.0/0.0]
    	elif input.DebugSize <= 14 and input.ImageVersion <= 4950 and input.ExportSize <= 56 and input.IatRVA > 256 and input.VirtualSize2 > 42 and input.NumberOfSections > 3.5:
    		isDirty = 1
    #Except (DebugSize <= 14) and (ImageVersion <= 4950) and (VirtualSize2 <= 6) and (ResourceSize <= 37532) and (ResourceSize <= 17302) => isDirty = 1  (388.0/0.0) [216.0/7.0]
    	elif input.DebugSize <= 14 and input.ImageVersion <= 4950 and input.VirtualSize2 <= 6 and input.ResourceSize > 17302:
    		isDirty = 1
    #Except (DebugSize <= 14) and (NumberOfSections > 2.5) and (ResourceSize > 1776) and (IatRVA <= 6144) and (ExportSize <= 219.5) and (VirtualSize2 > 2410) and (VirtualSize2 <= 61224) => isDirty = 1  (238.0/0.0) [116.0/0.0]
    	elif input.DebugSize <= 14 and input.NumberOfSections >= 2.5 and input.ResourceSize <= 1776 and input.IatRVA <= 6144 and input.ExportSize <= 219.5 and input.VirtualSize2 > 2410 and input.VirtualSize2 <= 61224:
    		isDirty = 1

    Пример того, как не надо писать на питоне, показывает Adobe. Полная версия: http://voxel.dl.sourceforge.net/project/malclassifier.adobe/AdobeMalwareClassifier.py

    SvartalF, 30 Марта 2012

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

    +153

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    do
      {
       $firstDate = ConvertTimeStamp($firstDateSt, "SHORT");
       $lastDate = ConvertTimeStamp($lastDateSt, "SHORT");
       
       $arPeriod = Array(
        "TITLE" => CSchool::GetDiaryPeriod($firstDate, $lastDate),
        "HREF" => $APPLICATION->GetCurPageParam('START_WEEK='.$firstDate.'&END_WEEK='.$lastDate, array("START_WEEK", "END_WEEK"))
       );

    Битрикс...
    do без while? лаконично

    nicksevenfold, 29 Марта 2012

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

    +163

    1. 1
    2. 2
    3. 3
    //fucking designers
    	if ( $page->importantshort ) $page->short = true;
    	if ( $page->importantNOTshort ) $page->short = false;	// так то!

    bot, 29 Марта 2012

    Комментарии (4)
  5. Java / Говнокод #9787

    +76

    1. 1
    2. 2
    3. 3
    4. 4
    } catch (IllegalArgumentException e) {
        // checked exceptions are stupid
        throw new UnexpectedException(e);
    }

    https://github.com/lmcalpin/Play--Paginate/blob/master/src/play/modules/paginate/strategy/JPARecordLocatorStrategy.java#L149

    Well...

    public class IllegalArgumentException extends RuntimeException

    roman-kashitsyn, 28 Марта 2012

    Комментарии (4)
  6. Java / Говнокод #9783

    +75

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    boolean retval = serviceCategory.equalsIgnoreCase("transportation");
    if (retval) {
        String serviceLocation = bp.getParameterValueObjectFromAnyComponent("ReqTDQuestions", "svcLocation") + "";
        if(serviceLocation.equalsIgnoreCase("GreaterChina")) {
            retval=true;
         }
    }
    return retval;

    После деобфускации получаем:
    return serviceCategory.equalsIgnoreCase("transp ortation");

    zloizerg, 27 Марта 2012

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

    +153

    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
    /* добавленный код: */
    public function preDispatch() {
       $id = (int) $this->_request->id;
       if ($id > 0) {
            $this->_item = doctrine("Item")->findOneById($id);
            if (!is_object($this->_item)) {
                throw new PageException_NotFound;
            }
        }
    }
    
    /* выброшенный код: */
    public function indexAction() {
        $itemId = (int) $this->_request->id;
        $item = doctrine("item")->findOneBy(array("id" => $itemId, "owner" => $this->_owner->getId()));
        if (is_object($item)) {
        /* ... */
        }
    }

    Вот такой рефакторинг. Теперь кто хочет - может редактировать все, что не лень подставить в запрос.

    Wivern, 27 Марта 2012

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

    +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
    procedure TRashetDate_Form.Button1Click(Sender: TObject);
      var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, aa, ee: real;
      res1: real;
      res2: real;
      res3: real;
      res4: real;
      res5: real;
      res6: real;
      res7: real;
      res8: real;
      res9: real;
      res10: real;
      res11: real;
      res12: real;
      res13: real;
      res14: real;
      res15: real;
      res16: real;
      res17: real;
      res18: real;
      res19: real;
      res20: real;
      res21: real;
      res22: real;
      res23: real;
      Field: real;
    <...>

    Брал отсюда и рыдал...
    http://www.cyberforum.ru/delphi-beginners/thread527956.html#post2835591

    Psilon, 26 Марта 2012

    Комментарии (4)
  9. Java / Говнокод #9763

    +71

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    try
                    {
                        //PI'я капец??
                        realStream.close();
                    }
                    catch (Throwable t)
                    {
                        throw new IOException(t);
                    }

    Примечание: realStream - это обычный java.io.OutputStream

    konsoletyper, 26 Марта 2012

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

    +158

    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
    public function delete_post($id_op){
            $ret = 'false';
            if((!empty($id_op))){
                    try{
                                        $ret1 = $this->getAdapter()->delete($this->users_posts_table,  'op_id = '.intval($id_op));
                                        $ret2 = $this->getAdapter()->delete($this->offer_posts_table,  'id_op = '.intval($id_op));
                                        if($ret1>0 && $ret2>0){
                                            $ret = 'true';
                                        }
                                        }catch(Exception $e){
                            $this->logger->log('module: deleting in  users_posts, offer_posts tables '.$e->getMessage(), Zend_Log::ERR);
                     }
            }
            else{
                            $ret = 'false';
                            $this->logger->log('function: delete_post : id_op is null', Zend_Log::ERR);
            }
            return $ret;
        }

    Код тим лидера.
    форматирование автора

    Quetzalcoatl, 23 Марта 2012

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

    +153

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    $sql_query_result = mysql_query("select * from Organisations
    inner join Goods on (Organisations.ID = Goods.OrgID)
    where 1");
    while($result_string = mysql_fetch_array($sql_query_result)) { array_push ($search_array, $result_string[3]); }
    for($i=0;$i<=count($search_array);$i++)
    {
     if(eregi($search_string, $search_array[$i]))
     {
      array_push($search_matches, $search_array[$i]);
     }
    }

    поиск в интернет магазине:
    13000 записей
    в строке 15 полей
    в каждом строке есть 3 BLOB
    2 с текстом и одно с картинкой товара
    а жаловались что база тормозит

    papavel, 21 Марта 2012

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