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

    +62

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public synchronized void changePassword(String password, int id){
    		try {
    			Connection conn = Db.getInstance().createConnection();
    			Statement stmt = conn.createStatement();
    			String sql = "UPDATE "+tableName+"SET `password` ='"+password+"' WHERE `userId` ="+id+"";
    			stmt.executeUpdate(sql);
    		}
    		catch(Exception ex){
    			Logger.writeToFile("Exception occured " + ex.toString());
    		}
    	}

    Типичная лаба

    qsort, 30 Июля 2012

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

    +71

    1. 1
    2. 2
    3. 3
    4. 4
    function __destruct(){
    		$sql = "DELETE FROM Basket";
    		mysql_query($sql);
    	}

    Удаление товаров из корзины в интернет магазине.

    BrdNLSrg, 30 Июля 2012

    Комментарии (20)
  3. JavaScript / Говнокод #11496

    +154

    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
    function reNumberAreas(parent)
    {
     for (i=0;i<parent.childNodes.length;i++)
     {
      try
      {
       parent.childNodes[i].firstChild.firstChild.firstChild.firstChild.id = cutNumber(parent.childNodes[0].firstChild.firstChild.firstChild.firstChild.id) + i;
       parent.childNodes[i].firstChild.firstChild.firstChild.firstChild.nextSibling.nextSibling.id = parent.childNodes[i].firstChild.firstChild.firstChild.firstChild.id + "_text";
       parent.childNodes[i].firstChild.firstChild.firstChild.firstChild.nextSibling.nextSibling.nextSibling.src = parent.childNodes[i].firstChild.firstChild.firstChild.firstChild.nextSibling.nextSibling.nextSibling.src.replace(/index=\d+/g,"index=" + i);
      }
      catch (e)
      {
      }
     }
    }

    Форматирование кода сохранено для придания драматичности.

    Areks, 30 Июля 2012

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

    +2

    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
    auto addition = [] (double a, double b) { return a + b; };
    
    auto substruction = [] (double a, double b) { return a - b; };
    
    auto divide = [] (double a, double b) { return a / b; };
    
    auto multiplie = [] (double a, double b) { return a * b; };
    
    typedef std::function<double (double, double)> DoubleFunc;
    
    int main()
    {
        std::vector<DoubleFunc> funcVector;
    
        funcVector.push_back(addition);
        funcVector.push_back(substruction);
        funcVector.push_back(multiplie);
        funcVector.push_back(divide);
    
        std::for_each(funcVector.begin(), funcVector.end(), []
        (DoubleFunc func)
        {
            std::cout << func(3.14159, 100500) << std::endl;
        });
    
        system("pause");
        return 0;
    }

    А ваш язык такое сможет:)? (я о delphi, java, etc.)
    Кстати, если писать все в таком духе, то параллелиться прога будет безболезненно:), правда это уже какой-то хацкель/лисп...

    suc-daniil, 30 Июля 2012

    Комментарии (134)
  5. Куча / Говнокод #11493

    +144

    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
    Уважаемые пользователи ресурса Говнокод.ру.
    
    В связи с повышением процента неадекватных участников и по этой причине участившимися ЧП.
    А также регулярным нарушением правил оными, сообщаю, что проводится расширение дружного модераторского коллектива.
    Посредством набора новых добровольцев-модераторов.
    
    Получив права модератора Вы сможете:
    - банить неугодных вам пользователей
    - закрывать неудобные для вас темы
    - выигрывать в спорах, если аргументы закончились - достаточно просто зайти под модератором и забанить оппонента (например за троллинг)
    
    Чтобы обеспечить анонимность Вам будут выданы спец. аккаунты. 
    Для обусждения вашей кандидатуры пишите мне на e-mail [email protected] или в личку.

    Модератор

    moderator, 29 Июля 2012

    Комментарии (13)
  6. ActionScript / Говнокод #11492

    −111

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    lv.onData = function(data:String):Void{
      htmlData = data;
      
      xml.parseXML(htmlData);
      trace(xml.firstChild.lastChild.firstChild.lastChild.lastChild.lastChild.childNodes[1].childNodes[1].childNodes[0]);
      trace(xml.firstChild.lastChild.firstChild.lastChild.lastChild.lastChild.childNodes[1].childNodes[2].childNodes[1].firstChild);
    }

    С демиарта.

    kyzi007, 29 Июля 2012

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

    +81

    1. 1
    2. 2
    3. 3
    if (uf.getPath().contains("d:/test.java/uploads/")) {
       uf.setPath(uf.getPath().replace("d:/test.java/uploads/", this.uploadPath));
    }

    хуита, 29 Июля 2012

    Комментарии (1)
  8. Java / Говнокод #11490

    +79

    1. 1
    String url = m_launchUrl.replaceAll(" ", "%20");

    Percent-encode по-Адобовски.

    http://svn.apache.org/repos/asf/incubator/flex/trunk/modules/debugger/src/java/flash/tools/debugger/concrete/PlayerSession.java

    wvxvw, 29 Июля 2012

    Комментарии (117)
  9. Perl / Говнокод #11489

    −136

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    sub parse_http_date($)
    {
    	my ($date)=@_;
    	my %months=(Jan=>0,Feb=>1,Mar=>2,Apr=>3,May=>4,Jun=>5,Jul=>6,Aug=>7,Sep=>8,Oct=>9,Nov=>10,Dec=>11);
    
    	if($date=~/^[SMTWF][a-z][a-z], (\d\d) ([JFMASOND][a-z][a-z]) (\d\d\d\d) (\d\d):(\d\d):(\d\d) GMT$/)
    	{ return eval { timegm($6,$5,$4,$1,$months{$2},$3-1900) } }
    
    	return undef;
    }

    Вакаба.

    7ion, 28 Июля 2012

    Комментарии (142)
  10. ActionScript / Говнокод #11488

    −109

    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
    // код в модели - создаются фильтры для колонок
    override protected function createFiltersData():IList
      {
       var filtersDescription:IList = new ArrayList();
       filtersDescription.addItem(new StatusFilter());
       filtersDescription.addItem(new ProdUIDFilter());
       filtersDescription.addItem(new ProdLongNameFilter());
       filtersDescription.addItem(new ProductTypeFilter());
       filtersDescription.addItem(new LatestRecordFilter());
       
       filtersDescription.addItem(new LastActionFilter(true));
       filtersDescription.addItem(new UsersFilter(this.userModel.users, true));
       filtersDescription.addItem(new PublishFilter(true));
       filtersDescription.addItem(new ProdNameFilter(true));
       filtersDescription.addItem(new ProductComplexityRatingFilter(true));
       filtersDescription.addItem(new ProductDescriptionFilter(true));
       return filtersDescription;
      }
    
    // код в контроллере - создаются сами колонки
    override protected function createTableColumns () : Array
      {
       var columns : Array = new Array();
       columns.push(new ProdUIDColumn(0));
       columns.push(new ProdLongNameColumn(1));
       columns.push(new ProdNameColumn(2));
       columns.push(new ProductDescriptionColumn(8));
       columns.push(new ProdTypeColumn(3));
       columns.push(new ProdComplRatingColumn(4));
       columns.push(new EditorSeparator(40, 5));
       columns.push(new CommentsColumn(9));
       columns.push(new ValidStartDateColumn(6));
       columns.push(new ValidEndDateColumn(7));
       columns.push(new LastActionColumn());
       columns.push(new UserColumn());
       columns.push(new LastActionDateColumn());
       columns.push(new LatestRecordColumn());
       columns.push(new StatusColumn());
       columns.push(new PublishColumn());
       return columns;
      }

    Со слезами в глазах вопрошаю - ну нахуя, а????

    kyzi007, 28 Июля 2012

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