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

    +83

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    try{
        name.toLowerCase();
      }catch (NullPointerException e) {
       report().error("java.lang.NullPointerException", e);
       name = "";
      }

    Перспективная проверка на null

    nafania217518, 13 Декабря 2012

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

    +61

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if(!$del){
         throw new Exception("При добавлении .......... возникла ошибка, обратитесь к администрации");
         return false;
        }
        return true;

    AndryG, 13 Декабря 2012

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

    +45

    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
    <html>
    <head>
    <title></title>
    </head>
    <body>
    <?php
    mysql_connect ("mysql.site.com","мшадрм","пароль") or die (mysql_error());
    mysql_select_db ("mjdjadmjg") or die (mysql_error());
    $strSQL = "INSERT INTO people(";
    $strSQL = $strSQL . "Name, ";
    $strSQL = $strSQL . "E-mail, ";
    $strSQL = $strSQL . "LastName, ";
    $strSQL = $strSQL . "BirthDate) ";
    $strSQL = $strSQL . "VALUES(";
    $strSQL = $strSQL . "'Gus', ";
    $strSQL = $strSQL . "'[email protected]', ";
    $strSQL = $strSQL . "'kruz', ";
    $strSQL = $strSQL . "'1964-04-20')";
    // SQL-оператор выполняется
    mysql_query($strSQL) or die (mysql_error());
    // Закрытие соединения
    mysql_close();
    ?>
    <h1>БД обновлена!</h1>
    </body>
    </html>

    Steep, 13 Декабря 2012

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

    +140

    1. 1
    for (size_t i=cnt-1; i<cnt; --i)

    цикол наоборот для типа без знака

    TarasB, 13 Декабря 2012

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

    +127

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    IF context.page_name == 'company' or context.page_name == 'accessibility' or context.page_name == 'arbitrage'  or context.page_name == 'arbitrage_income' or context.page_name == 'family_income' or context.page_name == 'family_income_acc' or context.page_name == 'family_income_fac' or context.page_name == 'family_income_summary' or context.page_name == 'arbitrage-rf' or context.page_name == 'federal-arbitrage' or context.page_name == 'appelate-arbitrage' or context.page_name == 'citation-index' or context.page_name == 'openness' or context.page_name == 'openness-mo' or context.page_name == 'openness-moscow' or context.page_name == 'openness-spb' or context.page_name == 'openness-lenob' or context.page_name == 'media-moscow' or context.page_name == 'media-mo' or context.page_name == 'media-general-jurisdiction' or context.page_name == 'media-spb' or context.page_name == 'media-lenob' or context.page_name == 'court-site-msk' or context.page_name == 'phone-court-general-jurisdiction' or context.page_name == '
    court-site-mo' or context.page_name == 'court-site-spb' or context.page_name == 'court-site-lo' or context.page_name == 'citation-court-general-jurisdiction' or context.page_name == 'phone-openness-msk' or context.page_name == 'phone-openness-mo' or context.page_name == 'phone-openness-spb' or context.page_name == 'phone-openness-lo' or context.page_name == 'court-transparency-msk' or context.page_name == 'court-transparency-mo' or context.page_name == 'court-transparency-spb' or context.page_name == 'court-transparency-lo' or context.page_name == 'court-transparency-general-jurisdiction' or context.page_name == 'court-arbitrage-citation-rf' or context.page_name == 'court-arbitrage-appellate-citation' or context.page_name == 'court-federal-arbitrage-citation' or context.page_name == 'court-arbitrage-citation-summary' or context.page_name == 'phone-openness-sub' or context.page_name == 'phone-openness-aac' or context.page_name == 'phone-openness-fas' or context.page_name == 'phone-openness-svod' or context.
    page_name == 'media-court-subjects-rf' or context.page_name == 'media-court-arbitration-appeal' or context.page_name == 'media-court-federal-arbitration-courts-districts' or context.page_name == 'media-all';
    	context.xslt_name = "casual/raiting_${context.page_name}.xslt";
    ELSE;
    	context.http_status = 404;
    END;

    Template Toolkit

    Un1oR, 13 Декабря 2012

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

    +13

    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
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    #include <iostream>
    
    using namespace std;
    
    class Manager
    {
    private:
        int *ar;
        int _size;
    public:
        void CreateArray(int size);
        void ResizeArray(int size);
    
        void MakeIntArray(int iter, int number);
        int GetIntArray(int iter);
    
        ~Manager()
        {
            delete [] ar;
        }
    };
    
    void Manager::CreateArray(int size)
    {
        _size = size;
    
        ar = new int[size];
    }
    
    void Manager::ResizeArray(int size)
    {
        int *nar = new int[size];
    
        for(int i = 0; i < _size; i++)
        {
            *(nar+i) = *(ar+i);
        }
    
        _size = size;
    
        delete [] ar;
    
        *ar = *nar;
    }
    
    int Manager::GetIntArray(int iter)
    {
        return iter < _size ? *(ar+iter) : NULL;
    }
    
    void Manager::MakeIntArray(int iter, int number)
    {
        if(iter < _size)
            *(ar+iter) = number;
    }
    
    int main()
    {
        Manager Man;
        Man.CreateArray(10);
    
        for(int i = 0; i < 10; i++)
            Man.MakeIntArray(i, i);
    
        for(int i = 0; i < 10; i++)
            cout << Man.GetIntArray(i) << " ";
    
        Man.ResizeArray(20);
        cout << endl;
    
        for(int i = 10; i < 20; i++)
            Man.MakeIntArray(i, i);
    
        for(int i = 0; i < 20; i++)
            cout << Man.GetIntArray(i) << " ";
    
        return 0;
    }

    > Собственно написал менеджер для массива, хочется узнать правильно ли все сделано, и нет ли утечек памяти?
    Очередной шедевр с самизнаетеоткуда.

    LispGovno, 12 Декабря 2012

    Комментарии (27)
  7. Куча / Говнокод #12279

    +126

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    rename-wiki:
    	$(shell cd ${WIKIDST} && rename 'i-iterate' 'Iterate' *.wiki)
    	$(shell find ${WIKIDST} -name "*.wiki" -exec \
    sed -i 's/\[i-iterate/\[Iterate/g' '{}' \;)
    	$(shell find ${WIKIDST} -name "*.wiki" -exec \
    sed -i 's/\.html\#/\#/g' '{}' \;)
    	$(shell find ${WIKIDST} -name "*.wiki" -exec \
    sed -i 's/&lt;/\</g' '{}' \;)
    	$(shell find ${WIKIDST} -name "*.wiki" -exec \
    sed -i 's/&gt;/\>/g' '{}' \;)

    Чтоль порадовать вас чем-нибудь?

    wvxvw, 12 Декабря 2012

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

    +59

    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
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    if ($myrow['dop1']) { echo "<tr><td class='td_18'>$myrow[dop1]</td></tr>"; }
      if ($myrow['dop2']) { echo "<tr><td class='td_18'>$myrow[dop2]</td></tr>"; }
      if ($myrow['dop3']) { echo "<tr><td class='td_18'>$myrow[dop3]</td></tr>"; }
      if ($myrow['dop4']) { echo "<tr><td class='td_18'>$myrow[dop4]</td></tr>"; }
      if ($myrow['dop5']) { echo "<tr><td class='td_18'>$myrow[dop5]</td></tr>"; }
      if ($myrow['dop6']) { echo "<tr><td class='td_18'>$myrow[dop6]</td></tr>"; }
      if ($myrow['dop7']) { echo "<tr><td class='td_18'>$myrow[dop7]</td></tr>"; }
      if ($myrow['dop8']) { echo "<tr><td class='td_18'>$myrow[dop8]</td></tr>"; }
      if ($myrow['dop9']) { echo "<tr><td class='td_18'>$myrow[dop9]</td></tr>"; }
      if ($myrow['dop10']) { echo "<tr><td class='td_18'>$myrow[dop10]</td></tr>"; }
      if ($myrow['dop11']) { echo "<tr><td class='td_18'>$myrow[dop11]</td></tr>"; }
      if ($myrow['dop12']) { echo "<tr><td class='td_18'>$myrow[dop12]</td></tr>"; }
      if ($myrow['dop13']) { echo "<tr><td class='td_18'>$myrow[dop13]</td></tr>"; }
      if ($myrow['dop14']) { echo "<tr><td class='td_18'>$myrow[dop14]</td></tr>"; }
      if ($myrow['dop15']) { echo "<tr><td class='td_18'>$myrow[dop15]</td></tr>"; }
      if ($myrow['dop16']) { echo "<tr><td class='td_18'>$myrow[dop16]</td></tr>"; }
      if ($myrow['dop17']) { echo "<tr><td class='td_18'>$myrow[dop17]</td></tr>"; }
      if ($myrow['dop18']) { echo "<tr><td class='td_18'>$myrow[dop18]</td></tr>"; }
      if ($myrow['dop19']) { echo "<tr><td class='td_18'>$myrow[dop19]</td></tr>"; }
      if ($myrow['dop20']) { echo "<tr><td class='td_18'>$myrow[dop20]</td></tr>"; }
      if ($myrow['dop21']) { echo "<tr><td class='td_18'>$myrow[dop21]</td></tr>"; }
      if ($myrow['dop22']) { echo "<tr><td class='td_18'>$myrow[dop22]</td></tr>"; }
      if ($myrow['dop23']) { echo "<tr><td class='td_18'>$myrow[dop23]</td></tr>"; }
      if ($myrow['dop24']) { echo "<tr><td class='td_18'>$myrow[dop24]</td></tr>"; }
      if ($myrow['dop25']) { echo "<tr><td class='td_18'>$myrow[dop25]</td></tr>"; }
      if ($myrow['dop26']) { echo "<tr><td class='td_18'>$myrow[dop26]</td></tr>"; }
      if ($myrow['dop27']) { echo "<tr><td class='td_18'>$myrow[dop27]</td></tr>"; }
      if ($myrow['dop28']) { echo "<tr><td class='td_18'>$myrow[dop28]</td></tr>"; }
      if ($myrow['dop29']) { echo "<tr><td class='td_18'>$myrow[dop29]</td></tr>"; }
      if ($myrow['dop30']) { echo "<tr><td class='td_18'>$myrow[dop30]</td></tr>"; }
      if ($myrow['dop31']) { echo "<tr><td class='td_18'>$myrow[dop31]</td></tr>"; }
      if ($myrow['dop32']) { echo "<tr><td class='td_18'>$myrow[dop32]</td></tr>"; }
      if ($myrow['dop33']) { echo "<tr><td class='td_18'>$myrow[dop33]</td></tr>"; }
      if ($myrow['dop34']) { echo "<tr><td class='td_18'>$myrow[dop34]</td></tr>"; }
      if ($myrow['dop35']) { echo "<tr><td class='td_18'>$myrow[dop35]</td></tr>"; }
      if ($myrow['dop36']) { echo "<tr><td class='td_18'>$myrow[dop36]</td></tr>"; }
      if ($myrow['dop37']) { echo "<tr><td class='td_18'>$myrow[dop37]</td></tr>"; }
      if ($myrow['dop38']) { echo "<tr><td class='td_18'>$myrow[dop38]</td></tr>"; }
      if ($myrow['dop39']) { echo "<tr><td class='td_18'>$myrow[dop39]</td></tr>"; }
      if ($myrow['dop40']) { echo "<tr><td class='td_18'>$myrow[dop40]</td></tr>"; }
      if ($myrow['dop41']) { echo "<tr><td class='td_18'>$myrow[dop41]</td></tr>"; }
      if ($myrow['dop42']) { echo "<tr><td class='td_18'>$myrow[dop42]</td></tr>"; }
      if ($myrow['dop43']) { echo "<tr><td class='td_18'>$myrow[dop43]</td></tr>"; }
      if ($myrow['dop44']) { echo "<tr><td class='td_18'>$myrow[dop44]</td></tr>"; }
      if ($myrow['dop45']) { echo "<tr><td class='td_18'>$myrow[dop45]</td></tr>"; }
      if ($myrow['dop46']) { echo "<tr><td class='td_18'>$myrow[dop46]</td></tr>"; }  
      if ($myrow['dop47']) { echo "<tr><td class='td_18'>$myrow[dop47]</td></tr>"; }  
      if ($myrow['dop48']) { echo "<tr><td class='td_18'>$myrow[dop48]</td></tr>"; }  
      if ($myrow['dop49']) { echo "<tr><td class='td_18'>$myrow[dop49]</td></tr>"; }
      if ($myrow['dop50']) { echo "<tr><td class='td_18'>$myrow[dop50]</td></tr>"; }

    facepalm.

    invision70, 12 Декабря 2012

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

    +156

    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
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    this.start = function() {
    		// Инициализирует парсинг выгрузки из Агента Плюс.
    		if (this.open()) {
    			this.catalogs = this.getTags("catalogs", true)[0].childs;
    			this.subdocuments = this.getTags("documents", true)[1].childs;
    			this.guids = this.document.childs[0].childs[0].childs;
    			this.sellhistory = this.getCatalog("ИсторияПродаж").childs[0].childs;
    			this.sellpoints = this.getCatalog("ТорговыеТочки").childs[0].childs;
    			this.contragents = this.getCatalog("Контрагенты").childs[1].childs;
    			this.deals = this.getCatalog("Договоры").childs[0].childs;
    			this.nomenclature = this.getCatalog("Номенклатура").childs;
    			this.measure = this.getCatalog("ЕдиницыИзмерения").childs[0].childs;
    			this.route = this.getDocument("Маршрут").childs[0].childs[0].childs[0].childs[0]
    			this.names = {deals: [], catalog: [], nomenclature: [], measure: [], contragents: [], sellpoints: []};
    			this.info = {deals: [], catalog: [], nomenclature: [], measure: [], contragents: [], sellpoints: []};
    			this.hash = {deals: {}, nomenclature: {}, consts: {}, contragents: {}, sellpoints: [], measure: {}};
    			for (var i = 0; i < this.catalogs.length; i++) {
    				this.names.catalog.push(this.catalogs[i].attrib.Comment.replace(/Справочник\./g, ""));
    				this.info.catalog.push(this.catalogs[i].attrib);
    			}
    			for (var i = 0; i < this.nomenclature[1].childs.length; i++) {
    				this.names.nomenclature.push(this.nomenclature[1].childs[i].attrib.Name);
    				this.info.nomenclature.push(this.nomenclature[1].childs[i].attrib);
    				this.hash.nomenclature[this.nomenclature[1].childs[i].attrib.GUID] = this.nomenclature[1].childs[i].attrib;
    			}
    			for (var i = 0; i < this.deals.length; i++) {
    				this.names.deals.push(this.deals[i].attrib.Name);
    				this.info.deals.push(this.deals[i].attrib);
    				this.hash.deals[this.deals[i].attrib.GUID] = this.deals[i].attrib;
    			}
    			for (var i = 0; i < this.measure.length; i++) {
    				this.names.measure.push(this.measure[i].attrib.Name);
    				this.info.measure.push(this.measure[i].attrib);
    				this.hash.measure[this.measure[i].attrib.GUID] = this.measure[i].attrib;
    			}
    			for (var i = 0; i < this.contragents.length; i++) {
    				this.names.contragents.push(this.contragents[i].attrib.Name);
    				this.info.contragents.push(this.contragents[i].attrib);
    				this.hash.contragents[this.contragents[i].attrib.GUID] = this.contragents[i].attrib;
    			}
    			for (var i = 0; i < this.sellpoints.length; i++) {
    				this.names.sellpoints.push(this.sellpoints[i].attrib.Name);
    				this.info.sellpoints.push(this.sellpoints[i].attrib);
    				this.hash.sellpoints[this.sellpoints[i].attrib.GUID] = this.sellpoints[i].attrib;
    			}
    			for (var i = 0; i < this.guids.length; i++) {
    				this.hash.consts[this.guids[i].attrib.GUID] = this.guids[i].attrib.VALUE;
    			}
    			
    			this.dynamic.routes = new Array();
    			for (var i = 0; i < this.route.childs.length; i++) {
    				var sp = this.getSPointByGUID(this.route.childs[i].attrib.A02);
    				var adr = sp.Name;
    				var ca = this.getCAgentByGUID(this.route.childs[i].attrib.A01);
    				var ptypeguid = this.hash.deals[ca.A08].A06;
    				var cagent = ca.Name;
    				var dealguid = ca.A08;
    				var exists = false;
    				for (var j = 0; j < this.dynamic.routes.length; j++) if (this.dynamic.routes[j].address.trim().toLowerCase() == adr.trim().toLowerCase()) exists = exists || true;
    				if (!exists) this.dynamic.routes.push({ptypeguid: ptypeguid, spointguid: sp.GUID, address: adr, dealguid: dealguid, cagent: cagent, cagentguid: ca.GUID, datestamp: this.convRouteDate(this.route.childs[i].attrib.A03)});
    			}
    		} else return;
    	};

    Маленькая часть нашего скрипта для работы с 1С - Node.JS - WebClient.

    Govnisti_Diavol, 12 Декабря 2012

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

    +133

    1. 1
    2. 2
    3. 3
    4. 4
    if ((frequency < config->frequency_max) || (frequency > config->frequency_min)) {
          printk(KERN_ERR "%s: Frequency beyond limits, frequency=%d\n", __func__, frequency);
          return -EINVAL;
        }

    Коллега отыскал где-то в недрах dvb подсистемы, в драйвере mopll'ки TDA6651.

    Necromant, 12 Декабря 2012

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