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

    В номинации:
    За время:
  2. Куча / Говнокод #6743

    +134

    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
    -module(common_io).
    -export([read_utf8/2, default_fallback/1]).
    
    default_fallback(<<Data>>)->
        erlang:display(Data).
    
    read_utf8(Collected, <<Utf8Char/utf8>>, _CallAfter)->
        lists:append(Collected, [Utf8Char]);
    read_utf8(Collected, <<Utf8Char/utf8, Data/binary>>, CallAfter)->
        lists:append([Collected, [Utf8Char], read_utf8(Data, CallAfter)]);
    read_utf8(Collected, <<Data/binary>>, CallAfter)->
        CallAfter(Data),
        Collected;
    read_utf8(Collected, <<>>, _CallAfter)->
        Collected.
    
    read_utf8(<<>>, _CallAfter)->
        [];
    read_utf8(<<Utf8Char/utf8>>, _CallAfter)->
        [Utf8Char];
    read_utf8(<<Data/binary>>, CallAfter)->
        read_utf8([], Data, CallAfter).

    Первый раз в жизни пишу что-то на Эрланге. Чует сердце, что что-то тут не так...

    wvxvw, 24 Мая 2011

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

    +83

    1. 1
    2. 2
    Float.parseFloat(obj.getPrice() + ""));
    // int obj.getPrice()

    int to float

    dshulgin, 17 Мая 2011

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

    +82

    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
    //request reading
            String allData = "";
            try {
                int data = input.read();
                while (true) {
                    allData += (char) data;
                    if (input.available() < 1) {
                        break;
                    }
                    data = input.read();
                }
            } catch (IOException ex) {
                Logger.getLogger(HttpProtocolProcessor.class.getName()).log(Level.SEVERE,
                        "Problems occured while reading the stream.", ex);
            }

    Прямо свежего наклада. Вот таким вот нетривиальным способом член команды читает из InputStream'a всё в одну строку. Он не только читает по байтно, но еще и для каждого байта создаёт новую строку. О мой боже. Т_Т.

    sogekoder, 15 Мая 2011

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

    +164

    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
    //----------------------------------------------------------------------------
    void TChimesMinigame::InventoryEndDrag(str aId)
    { 
      TSceneObject * drag_object = getScene(1)->FindObject(aId);
    
      if (!drag_object) 
      {
        iInventory->CheckEndDrag(NULL);
        return; 
      }
        
      iInventory->CheckEndDrag(NULL);
    }
    //----------------------------------------------------------------------------

    w100, 15 Мая 2011

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

    +116

    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
    IList<Hashtable> records = crit.List<Hashtable>();
    Guid[] personsId = records.Select(item => (Guid)item["PersonID"]).Distinct().ToArray();
    List<EmployeeData> empDatas = new List<EmployeeData>();
    
    foreach(Guid personId in personsId) {
    	IEnumerable<Hashtable> employeeRecords = records.Where(item => (Guid)item["PersonID"] == personId);
    	Hashtable employeeRecord = employeeRecords.FirstOrDefault(item => !(bool)item["IsLoad"] || (DateTime)item["EventDate"] == employeeRecords.Max(unit => (DateTime)unit["EventDate"]));
    
    	Hashtable employeeRecordAddition = new GenericNHibernateDao<BaseDocument>().CreateCriteria()
    		.CreateAlias("Department", "department")
    		.CreateAlias("Employee", "employee")
    		.CreateAlias("WorkDescription.Schedule", "schedule", JoinType.LeftOuterJoin)
    		.CreateAlias("WorkDescription.EmployeeApperance", "employeeApperance", JoinType.LeftOuterJoin)
    		.Add(Restrictions.Eq("EmployeeStamp.TabNo", employeeRecord["TabNo"]))
    		.Add(Restrictions.Eq("IsHalf", false))
    	...
    }

    No comments %)

    Guid, 12 Мая 2011

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

    +167

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    /* DO NOT UNCOMMENT THIS CODE AGAIN.  THIS IS THE 3rd TIME I'VE HAD TO REMOVE THIS.
        if($("form#purchase_form").length) {
            var currentPaymentValue = $("input[name='paymentFormOverride']:checked", "#purchase_form").val();
            if (currentPaymentValue == 'cc')
                $("#pp_payment_method").click(function(){paymentRedirect('pp')});
            else
                $("#cc_payment_method").click(function(){paymentRedirect('cc')});
        }
    	*/

    Чоткая обратная связь :))

    kovel, 11 Мая 2011

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    $value = "";
    $content = $content;
    $val = "\$content->" . $field->name;
    $fieldname = $field->name;
    
    eval("if (isset($val)) \$value = \"$val\";");
    $value = JText::_($value);
    $value = stripslashes($value);

    Joomla. Adsmanager

    Jetti, 10 Мая 2011

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    function get_phrase()
    {
    	global $words;
    	global $phrase;
    	$phrase = implode(" ", $words);
    	if(strlen($phrase) < 4) return;
    }

    I was amazed to find this!?! The last line of the function rationalized my day...

    wyand, 05 Мая 2011

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

    +159

    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
    function CreateLayer(text, id, t, l,m) {
    if(document.layers && m==1)
     {
      var str="<LAYER ID=menu" + id + " TOP=" + t + " LEFT=" + l + " onmouseover=\"occupied_menu[" + id + "]=1;\" onmouseout=\"Turn('" + id + "',0);occupied_menu[" + id + "]=0;\" VISIBILITY=hide Z-INDEX=2 bgcolor=\"#0066CC\">" + text + "</LAYER>";
      document.write(str);
     }
     else if(document.layers && m==2)
     {
     id = id.substring(0,1);
      var str="<LAYER ID=menu" + id + "a TOP=" + t + " LEFT=" + l + " onmouseover=\"occupied_menu[" + id + "]=1;occupied_header[" + id + "]=1;\" onmouseout=\"Turn('" + id + "',0);occupied_menu[" + id + "]=0;occupied_header[" + id + "]=0\" VISIBILITY=hide Z-INDEX=2 bgcolor=\"#EF1010\">" + text + "</LAYER>";
      document.write(str);
     }
     else if(document.all)
     {
      var strng="<div id=menu" + id + " style=\"position:absolute;top:" + t + ";left:" + l + ";visibility:hidden;width:100;z-index:1;\" onmouseover=\"occupied_menu[" + id + "]=1;\" onmouseout=\"Turn('" + id + "',0);occupied_menu[" + id + "]=0;\">" + text + "</div>";
      document.write(strng);
     }
     }

    moonie, 05 Мая 2011

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

    +140

    1. 1
    2. 2
    3. 3
    4. 4
    if ((u[i]!=100500)&&(v[j]==100500))
        v[j]=matr[i+1][j+1].cost-u[i];
    if ((u[i]==100500)&&(v[j]!=100500))
        u[i]=matr[i+1][j+1].cost-v[j];

    пересчет платежей в ТЗЛП

    resettik, 04 Мая 2011

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