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

    +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
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    //Перевод в 2/10 систему
    BOOL
    CChannel::DecTo2Dec(UCHAR Dec,
    					CHAR *Dec2)
    {
    	TCHAR digitstring[10] = {0};
    	INT	Hi = 0;
    	INT	Lo = 0;
    
    	_stprintf_s(digitstring,TEXT("%d"),Dec);
    	INT digitstringLen = _tcslen(digitstring);
    	Lo = _ttoi(digitstring + 1);
    	*(digitstring + 1) = 0;
    	Hi = _ttoi(digitstring);
    	
    	if(digitstringLen>1)
    	{
    		*Dec2 = Lo + Hi * 0x10;
    	}
    	else
    		*Dec2 = Hi;
    	return TRUE;
    }

    Перевод в BCD через строку!

    azote, 27 Января 2012

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

    +71

    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
    package com.govnoistochnik.servleti;
    
    ...
     
    import javax.servlet.GenericServlet;
    ...
     
    public class GenericReportingServlet extends GenericServlet {
    
    PrintWriter oos;   // Говно источник
    ...
    
    public synchronized void  createReport(...)
    {
    oos = new PrintWriter();
    ...
    // pessot strok govnokoda vida
    oos.println("report");
    ...
    saveToDB(oos.toString());
    
    oos.close;
    }
    
    public synchronized void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
    // Kucha govnokoda
       createReport(...);
    // Prodoljeniye kuchi
    }
    
     ...
     
    }

    Продолжение говнокода
    http://govnokod.ru/9146

    Мы нашли почему там Синхронный метод.

    Глобальная переменная в коде. Какому идеоту пришло в голову так писать.....пи......

    kirpi, 27 Января 2012

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

    +1000

    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
    class set_ftp: public QObject
    {
    public:
        typedef class impl_set_ftp: QObject
        {
            QString url     ;
            QString login   ;
            QString password;
            QString siis    ;
            QString ssm     ;
            QString ssl     ;
            QString url_siis;
            QString url_ssm ;
            QString url_ssl ;
    
            friend class set_ftp;
            impl_set_ftp(QObject* p): QObject(p) {}
        } Impl;
    
        inline QString& url     () const {return impl->url     ;}
        inline QString& login   () const {return impl->login   ;}
        inline QString& password() const {return impl->password;}
        inline QString& siis    () const {return impl->siis    ;}
        inline QString& ssm     () const {return impl->ssm     ;}
        inline QString& ssl     () const {return impl->ssl     ;}
        inline QString& url_siis() const {return impl->url_siis;}
        inline QString& url_ssm () const {return impl->url_ssm ;}
        inline QString& url_ssl () const {return impl->url_ssl ;}
    
        inline void set_url     (const QString& _url     ) {impl->url      = _url     ;}
        inline void set_login   (const QString& _login   ) {impl->login    = _login   ;}
        inline void set_password(const QString& _password) {impl->password = _password;}
        inline void set_siis    (const QString& _siis    ) {impl->siis     = _siis    ;}
        inline void set_ssm     (const QString& _ssm     ) {impl->ssm      = _ssm     ;}
        inline void set_ssl     (const QString& _ssl     ) {impl->ssl      = _ssl     ;}
        inline void set_url_siis(const QString& _url_siis) {impl->url_siis = _url_siis;}
        inline void set_url_ssm (const QString& _url_ssm ) {impl->url_ssm  = _url_ssm ;}
        inline void set_url_ssl (const QString& _url_ssl ) {impl->url_ssl  = _url_ssl ;}
    
        set_ftp()          : QObject(0), impl(new Impl(this)) {}
        set_ftp(QObject* p): QObject(p), impl(new Impl(this)) {}
    private:
        Impl* impl;
    };

    Код написанный человеком, считающим себя "гуру разработки программирования", а так же "активным научным деятелем".
    Главная мысль глядя на это у меня - охренное тестовое задание с вопросом - укажите абсолютно все бредни в этом коде, но разумеется в более нормальной формулировке... а чО - неплохой тест...
    з.ы. этот же человек никогда не пишет cpp файлы все в хедерах собачит....

    LuCiFer, 27 Января 2012

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

    +111

    1. 1
    vTreeNode1.SelectedForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));

    Присвоение чёрного цвета. Hell yeah!

    pewpew, 27 Января 2012

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

    +127

    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
    resid := "ANeNaidenVidShortNameNA";
    defval := "(Не найден вид '(ShortNameNA)')";
    nenay:=@DbLookup("":"NoCache";"":"ResDB.nsf";"(Res)";lng+resid;2);
    nenay:=@If(@IsError(nenay);defval;nenay);
    
    key:=@Name([Abbreviate]; @UserName);
    
    serv:=@GetProfileField("CommonDBProfile"; "StructServer"; @ServerName);
    db:=@GetProfileField("CommonDBProfile"; "StructDB"; @ServerName);
    
    @If (serv="" | db=""; @Do(
    @Prompt([Ok];osh; vstr);
    @Return(vstr)
    ); "");
    
    StructServer1:=@DbLookup("":"NoCache"; serv:db; "(NAShortNamePost)"; key; "StructServer" ) ;
    StructDB1:=@DbLookup("":"NoCache"; serv:db; "(NAShortNamePost)"; key; "StructDB" ) ;
    
    @If(StructDB1 = ""; @Do(@Prompt([Ok]; vnim; vstr); @Return("")); @Success);
    a := @Trim(@PickList([Custom];StructServer1 :StructDB1; "(ShortNameNA)";sel; sel1; 5));
    @If(@IsError(a); @Do(@Prompt([Ok]; osh; nenay); @Return("")); @Success);
    @If(a = ""; @Do(@Prompt([Ok]; vnim; vneob); @Return("")); @Success);
    
    FIELD NamesAlias:=  @Middle(a; "$"; "#");
    FIELD IndDepart := @Explode(@Implode(@Trim(@Left(a;"*"));";");";");
    FIELD Depart := @Middle(a; "*"; "$");
    FIELD Empl :=  @Middle(a; "$"; "#");
    
    FIELD EmplNotesAdr:= @Explode(@Implode(@Trim(@Middle(a; "#"; "%"));";");";");
    FIELD Replacer := @Trim(@Middle(a; "%"; "?"));
    
    FIELD ReplacerNotesAdr := @Explode(@Implode(@Trim(@Middle(a; "?"; "+"));";");";");
    
    FIELD ServerName:=@Explode(@Implode(@Trim(@Right(a;"+"));";");";");
    REM {FIELD CtrlDate:=@Adjust(@Today;0;1;0;0;0;0 )};
    FIELD a3:=@Date(@Today);
    
    FIELD a6:=@Middle(a; "$"; "#")+"<< >> " ;
    
    FIELD IndDepart:=IndDepart ;
    FIELD Depart:=Depart;
    FIELD Replacer :=@Unique(Replacer );
    FIELD ReplacerNotesAdr:=@Unique(@Name([Abbreviate];  ReplacerNotesAdr));
    FIELD ServerName:=@Unique(@Name([Abbreviate];ServerName));
    @Command([RunAgent];"(CheckWall)");
    @Command([RefreshFrame];"Document")

    документооборот епта

    d_dev, 27 Января 2012

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

    +80

    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
    public class SQLExecutor {
     
        ..............
    
        private static class Done extends RuntimeException {}
    
        private static class Break extends RuntimeException {}
    
        ...............
    
        public boolean init(....) {
            Connection conn = null;
            try {
                ..........
            } catch (Done d) {
                return true;
            } catch (Break b) {
                return false;
            } finally {
                cleanup();
            }
            return true;
        }
    
    
    }

    Anonimous, 27 Января 2012

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

    +150

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public function getBrandId() {
            if (key_exists("id", $_GET)) {
                return $_GET['id'];
            } else {
                return false;
            }
        }

    Писала значимая фигура студии, между прочим.

    Grockles, 26 Января 2012

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

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $nodes = $this->xmlDoc->getElementsByTagName($nodeName);
    		$count = 0;
                    for($i = 0; $i< $nodes->length; $i++)
    		{
    			$count++;
    		}
    		return $count;

    И это при обработке 35-метрового xml файла с десятками и сотнями тысяч элементов.
    Ять! За ногу и наизнанку, cyk@!

    phgrey, 26 Января 2012

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

    +146

    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
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    Battle = new Class({
    	// Options
    	selected: 1,
    	onPopupClose: function() {},
    	
    	// Class initalisation
    	initialize: function(options) {
    		Object.append(this, options);
    	},
    	
    	// Open popup
    	initPopup: function(title, selection) {
    		this.selected = selection;
    		this.popup = new LightFace.Static({
    			title: title,
    			content: 'vote-options'
    		});
    	},
    	
    	// Vote
    	vote: function(social_network) {
    		var share = this.selected == 1 ? this.share1 : this.share2;
    		var pic   = this.selected == 1 ? this.pic1   : this.pic2;
    		var url   = '';
    		
    		if(social_network == 'fb') {
    			url  = 'http://www.facebook.com/sharer.php?s=100';
    			url += '&p[title]='     + encodeURIComponent(this.text);
    			url += '&p[summary]='   + encodeURIComponent(share);
    			url += '&p[url]='       + encodeURIComponent(this.url);
    			url += '&p[images][0]=' + encodeURIComponent(pic);
    		} else if(social_network == 'tw') {
    			url  = 'http://twitter.com/share?';
    			url += 'text='      + encodeURIComponent(this.text);
    			url += '&url='      + encodeURIComponent(this.url);
    			url += '&counturl=' + encodeURIComponent(this.url);
    		} else if(social_network == 'vk') {
    			url  = 'http://vkontakte.ru/share.php?';
    			url += 'url='          + encodeURIComponent(this.url);
    			url += '&title='       + encodeURIComponent(this.text);
    			url += '&description=' + encodeURIComponent(share);
    			url += '&image='       + encodeURIComponent(pic);
    			url += '&noparse=true';
    		} else if(social_network == 'ok') {
    			url  = 'http://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=1';
    			url += '&st.comments=' + encodeURIComponent(share);
    			url += '&st._surl='    + encodeURIComponent(this.url);
    		} else if(social_network == 'ml') {
    			url  = 'http://connect.mail.ru/share?';
    			url += 'url='          + encodeURIComponent(this.url);
    			url += '&title='       + encodeURIComponent(this.text);
    			url += '&description=' + encodeURIComponent(share);
    			url += '&imageurl='    + encodeURIComponent(pic);
    		}
    
    		window.open(url,'','toolbar=0,status=0,width=626,height=436');
    		
    		return this.vote_ns()
    	},
    	
    	// Vote count
    	vote_ns: function() {
    		new Request({
    			url: '/vote/' + this.id + '/' + this.selected
    		}).send();
    
    		this.popup.close();
    		this.onPopupClose.delay(400);
    
    		var vote_count = $('vote-num-'+this.selected);
    		vote_count.set('text', vote_count.get('text').toInt() + 1);
    
    		$('vote-1').destroy();
    		$('vote-2').destroy();
    		$('voted_thank_you').show();
    
    		return false
    	},
    	
    	// Askbook Promo
    	promoAskbook: function() {
    		this.promoBox = new LightFace.Static({
    			width:     500,
    			draggable: true,
    			title:     'AskBook.me',
    			content:   'askbook_promo'
    		});
    	}
    
    });

    Класс битв на 1001golos.ru

    eriko, 26 Января 2012

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

    +135

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    class Program
    {
        static void Main(String[] args)
        {
            for (int i = 0; i < 10; i++)
            {
                Main();
            }
        }
    }

    Студент выдал такое в ответ на задание написать код, вызывающий функцию 10 раз. Пол часа бедняга втыкал откуда стэк оверфлоу...

    vistefan, 26 Января 2012

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