1. C++ / Говнокод #6021

    +167

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    PopupWindow* GameLocations::getCurrentPopup()
    {
    	if(m_curPopup != nullptr && m_curPopup->needsClose())
    	{
    		m_curPopup->onClose();
    		m_curPopup = nullptr;
    		m_walker->BeginWalk(m_graph->getClosestNode(m_currentLocationId));
    	}
    	return m_curPopup;
    }

    Kirinyale, 18 Марта 2011

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

    +114

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    if (defaultOrderType == OrderType.NoCharge || defaultOrderType == OrderType.Claims)
    {
        noChargeItemEntry.Style.Add(HtmlTextWriterStyle.Display, "block");
        itemEntryPanel.Style.Add(HtmlTextWriterStyle.Display, "none");
        items.Style.Add(HtmlTextWriterStyle.Display, "none");
    }
    else
    {
        noChargeItemEntry.Style.Add(HtmlTextWriterStyle.Display, "none");
        itemEntryPanel.Style.Add(HtmlTextWriterStyle.Display, "block");
        items.Style.Add(HtmlTextWriterStyle.Display, "block");
    }

    abatishchev, 18 Марта 2011

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

    +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
    18. 18
    19. 19
    20. 20
    21. 21
    // Method that returns anonymous type as object
    object ReturnAnonymous() {
      return new { City="Prague", Name="Tomas" };
    }
    
    void Main() {
      // Get instance of anonymous type with 'City' and 'Name' properties
      object o = ReturnAnonymous();
    
      // This call to 'Cast' method converts first parameter (object) to the
      // same type as the type of second parameter - which is in this case 
      // anonymous type with 'City' and 'Name' properties
      var typed = Cast(o, new { City="", Name="" });
      Console.WriteLine("{0}, {1}", typed.City, typed.Name)
    }
    
    // Cast method - thanks to type inference when calling methods it 
    // is possible to cast object to type without knowing the type name
    T Cast<T>(object obj, T type) {
      return (T)obj;
    }

    via http://social.msdn.microsoft.com/forums/en-US/linqprojectgeneral/thread/c1c179bb-ea88-4633-970a-947f0dd1e71f/

    Jopa123, 18 Марта 2011

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

    +119

    1. 1
    http://rabota.1777.ru/one_rezume.php?job_rezume_id=33838&job_cat_id2=1&doljnost2=&pol2=&vozrast_ot2=21&vozrast_do2=21&obrazovanie2=&opit2=&plata2=&pajina=&new=&doljnost3=

    Супер человек, всего 21 год, умеет все и деньги ему не нужны.

    Vasiliy, 18 Марта 2011

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

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    /*
     * Корректировка даты.
     *	если дата в будущем - то показываем сегодня.
     */
    
    $row['created'] = ( strtotime( date("Y-m-d", strtotime($row['created'])) ) > strtotime( date("Y-m-d") ) )? 
    		date("r")
    		: date("r", strtotime($row['created']));

    4x4 off-road racing...

    istem, 17 Марта 2011

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

    +161

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    <?
    function save($author,$title,$pubyear,$price) {
            $sql = "INSERT INTO catalog(author,title,pubyear,price) 
                            VALUES('$author','$title',$pubyear,$price)";
            mysql_query($sql) or die (mysql_error());
    }
     function selectAll() {
                    $sql = "SELECT * FROM catalog";
                    $result = mysql_query($sql) or die(mysql_error());
                    return $result;
    }

    qbasic, 17 Марта 2011

    Комментарии (10)
  7. Java / Говнокод #6015

    +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
    int cont = 1;
    String d01 = turnsSubscribedByUsers.contains(cont++) ? "S" : "N";
    String d02 = turnsSubscribedByUsers.contains(cont++) ? "S" : "N";
    ....
    String d36 = turnsSubscribedByUsers.contains(cont++) ? "S" : "N";
    
    ...
    
    os.write(d01.getBytes("UTF-8"));
    os.write(d02.getBytes("UTF-8"));
    ...
    os.write(d36.getBytes("UTF-8"));

    Генерация какого-то файла :)

    voice, 17 Марта 2011

    Комментарии (22)
  8. JavaScript / Говнокод #6014

    +161

    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
    function explode( delimiter, string ) {	// Split a string by string
    	// 
    	// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    	// +   improved by: kenneth
    	// +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    
    	var emptyArray = { 0: '' };
    
    	if ( arguments.length != 2
    		|| typeof arguments[0] == 'undefined'
    		|| typeof arguments[1] == 'undefined' )
    	{
    		return null;
    	}
    
    	if ( delimiter === ''
    		|| delimiter === false
    		|| delimiter === null )
    	{
    		return false;
    	}
    
    	if ( typeof delimiter == 'function'
    		|| typeof delimiter == 'object'
    		|| typeof string == 'function'
    		|| typeof string == 'object' )
    	{
    		return emptyArray;
    	}
    
    	if ( delimiter === true ) {
    		delimiter = '1';
    	}
    
    	return string.toString().split ( delimiter.toString() );
    }

    Из сборника JS-реализаций PHP функций : http://javascript.ru/php/explode
    Сюда можно половину этого сборника постить.

    scalar4eblo4no, 17 Марта 2011

    Комментарии (10)
  9. Assembler / Говнокод #6013

    +240

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    lea    0x0(%esi),%esi
    sub    $0x1,%eax
    cmp    $0xffffffff,%eax
    je     0x8048e07
    mov    (%ecx,%eax,4),%esi
    test   %esi,%esi
    je     0x8048df8

    Чудеса оптимизации -О3 на gcc 4.4
    (код в интелловской аннотации, сначала источник, потом назначение)

    SIGSEGV, 17 Марта 2011

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

    +169

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    $pattern = "/\w{0,5}[хx]([хx\s\!@#\$%\^&*+-\|\/]{0,6})[уy]([уy\s\!@#\$%\^&*+-\|\/]{0,6})
    [ёiлeеюийя]\w{0,7}|\w{0,6}[пp]([пp\s\!@#\$%\^&*+-\|\/]{0,6})[iие]([iие\s\!@#\$%\^&*+-\|\/]{0,6})
    [3зс]([3зс\s\!@#\$%\^&*+-\|\/]{0,6})[дd]\w{0,10}|[сcs][уy]([уy\!@#\$%\^&*+-\|\/]{0,6})[4чkк]\w{1,3}
    |\w{0,4}[bб]([bб\s\!@#\$%\^&*+-\|\/]{0,6})[lл]([lл\s\!@#\$%\^&*+-\|\/]{0,6})[yя]\w{0,10}|\w{0,8}[её][bб]
    [лске@eыиаa][наи@йвл]\w{0,8}|\w{0,4}[еe]([еe\s\!@#\$%\^&*+-\|\/]{0,6})[бb]([бb\s\!@#\$%\^&*+-\|\/]{0,6})[uу]
    ([uу\s\!@#\$%\^&*+-\|\/]{0,6})[н4ч]\w{0,4}|\w{0,4}[еeё]([еeё\s\!@#\$%\^&*+-\|\/]{0,6})[бb]([бb\s\!@#\$%\^&*+-\|\/]{0,6})
    [нn]([нn\s\!@#\$%\^&*+-\|\/]{0,6})[уy]\w{0,4}|\w{0,4}[еe]([еe\s\!@#\$%\^&*+-\|\/]{0,6})[бb]([бb\s\!@#\$%\^&*+-\|\/]{0,6})
    [оoаa@]([оoаa@\s\!@#\$%\^&*+-\|\/]{0,6})[тnнt]\w{0,4}|\w{0,10}[ё]([ё\!@#\$%\^&*+-\|\/]{0,6})[б]\w{0,6}|\w{0,4}[pп]
    ([pп\s\!@#\$%\^&*+-\|\/]{0,6})[иeеi]([иeеi\s\!@#\$%\^&*+-\|\/]{0,6})[дd]([дd\s\!@#\$%\^&*+-\|\/]{0,6})
    [oоаa@еeиi]([oоаa@еeиi\s\!@#\$%\^&*+-\|\/]{0,6})[рr]\w{0,12}/i";

    Думал навсегда потерял, а вчера случайно нашел в мемориз на одном из сайтов. Кусок этот встретил лет семь назад.

    Rpsl, 17 Марта 2011

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