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

    В номинации:
    За время:
  2. JavaScript / Говнокод #4799

    +160

    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
    TINY.accordion=function(){
    	function slider(n){this.n=n; this.a=[]}
    	slider.prototype.init=function(t,e,m,o,k){
    		var a=T$(t), i=s=0, n=a.childNodes, l=n.length; this.s=k||0; this.m=m||0;
    		for(i;i<l;i++){
    			var v=n[i];
    			if(v.nodeType!=3){
    				this.a[s]={}; this.a[s].h=h=T$$(e,v)[0]; this.a[s].c=c=T$$('div',v)[0]; h.onclick=new Function(this.n+'.pr(0,'+s+')');
    				if(o==s){h.className=this.s; c.style.height='auto'; c.d=1}else{c.style.height=0; c.d=-1} s++
    			}
    		}
    		this.l=s
    	};
    	slider.prototype.pr=function(f,d){
    		for(var i=0;i<this.l;i++){
    			var h=this.a[i].h, c=this.a[i].c, k=c.style.height; k=k=='auto'?1:parseInt(k); clearInterval(c.t);
    			if((k!=1&&c.d==-1)&&(f==1||i==d)){
    				c.style.height=''; c.m=c.offsetHeight; c.style.height=k+'px'; c.d=1; h.className=this.s; su(c,1)
    			}else if(k>0&&(f==-1||this.m||i==d)){
    				c.d=-1; h.className=''; su(c,-1)
    			}
    		}
    	};
    	function su(c){c.t=setInterval(function(){sl(c)},20)};
    	function sl(c){
    		var h=c.offsetHeight, d=c.d==1?c.m-h:h; c.style.height=h+(Math.ceil(d/5)*c.d)+'px';
    		c.style.opacity=h/c.m; c.style.filter='alpha(opacity='+h*100/c.m+')';
    		if((c.d==1&&h>=c.m)||(c.d!=1&&h==1)){if(c.d==1){c.style.height='auto'} clearInterval(c.t)}
    	};
    	return{slider:slider}
    }();

    http://installauto.ru/ajax/script.js
    чья-то реализация аккордиона. и почему же оно хреново в ИЕ пашет?

    noRerih, 01 Декабря 2010

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

    +147

    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
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    #include <algorithm>
    #include <vector>
    #include <string>
    
    #define N 5
    #define TSK "durak"
    
    using namespace std;
    
    int m[N];
    
    int main(void){
      freopen(TSK".in",  "rt", stdin);
      freopen(TSK".out", "wt", stdout);
    
      scanf("%d%d%d%d", &m[0], &m[1], &m[2], &m[3]);
    
      sort(m, m + 4);
    
      int ans(0);
    
      for(int i = 1; i < 4; i++){
        if(m[i] == m[i-1] && m[i] != 0)
          ans++;
      }
    
      printf("%d\n", ans);
    
      return 0;
    }

    MadMag, 27 Ноября 2010

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

    +155

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    void CVC6_SampleCodeDlg::OnCHECKForceGDI() 
    {
    	// TODO: Add your control notification handler code here
    	CButton *pBut = (CButton *) GetDlgItem(IDC_CHECK_ForceGDI);
    	m_vportsdk.SetForceGDI(pBut->GetCheck());	
    	if(pBut->GetCheck() == 0)
    		m_ForceGDI = false;
    	else if(pBut->GetCheck() == 1)
    		m_ForceGDI = true;
    }

    VPort ActiveX SDK PLUS от Moxa
    часть 3

    absolut, 27 Ноября 2010

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

    +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
    void CVC6_SampleCodeDlg::Onbuttonstartrecord() 
    {
    	// TODO: Add your control notification handler code here
    	CString strFileName, strFileTime, strFileSize, strTemp;
    
    	GetDlgItem(IDC_EDIT_filepath)->GetWindowText(strFileName);
    	GetDlgItem(IDC_EDIT_filetime)->GetWindowText(strFileTime);
    	GetDlgItem(IDC_EDIT_filelength)->GetWindowText(strFileSize);
    	GetDlgItem(IDC_button_startrecord)->GetWindowText(strTemp);
    
    	m_vportsdk.SetRecordVideoPath(strFileName);
    	m_vportsdk.SetRecordMaxFileTimeLength(atoi(strFileTime));
    	m_vportsdk.SetRecordMaxFileSize(atoi(strFileSize));
    
    	CComboBox *pRecordType = (CComboBox *) GetDlgItem(IDC_COMBO_recordtype);
    	if(strTemp == "Start Record"){
    		if(pRecordType->GetCurSel() == 0)
    			m_vportsdk.StartRecording(0);
    		else
    			m_vportsdk.StartRecording(1);
    		GetDlgItem(IDC_button_startrecord)->SetWindowText("Stop Record");
    	}
    	else{
    		if(pRecordType->GetCurSel() == 0)
    			m_vportsdk.StopRecording(0);
    		else
    			m_vportsdk.StopRecording(1);
    		GetDlgItem(IDC_button_startrecord)->SetWindowText("Start Record");
    	}
    }

    VPort ActiveX SDK PLUS от Moxa
    часть 2

    absolut, 27 Ноября 2010

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

    +145

    1. 1
    2. 2
    3. 3
    function CalculateShippingCost() {
      return 20.00;
    }

    Из одного "реального" интернет-магазина!

    dwinner, 25 Ноября 2010

    Комментарии (3)
  7. SQL / Говнокод #4751

    −859

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    CREATE Procedure [dbo].[usp_InsertFleets]
    @SSQL text
    As
          EXEC(@SSQL)
    GO

    Минутка индусского кода

    bas1l, 25 Ноября 2010

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

    +145

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    // php5.1 to php4 functional, thanks for nic.ru fucked hosting
    function html_decode($str){
    	if(function_exists("htmlspecialchars_decode")){
    		return stripslashes(htmlspecialchars_decode($str, ENT_QUOTES));
    	}else{
    		return stripslashes(str_replace(array("&amp;", "&quot;", "&#039;", "&lt;", "&gt;"), array("&", "\"", "'", "<", ">"), $str));
    	}
    }

    Sunny, 25 Ноября 2010

    Комментарии (3)
  9. Pascal / Говнокод #4749

    +101

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    procedure TSomeForm.DBGridEhDrawColumnCell(SomeParams);
    begin
      ShowRecordCount(GridDataSet);
    end;
    ...
    procedure ShowRecordCount(const FibDataSet: TpFibDataSet);
    begin
      FormMain.StatusBar1.Panels[2].Text := 'записей='+ IntToStr(FibDataSet.VisibleRecordCount);
      FormMain.StatusBar1.Refresh;
    end;

    По ходу решения задачи решил-таки глянуть, почему так дико тормозит главная, вся цветная грида формы, ожидая там дикие отрисовки, а там...

    labutinpa, 25 Ноября 2010

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

    +122

    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
    public enum SqlCallType {
    		Text = 1,
    		StoredProcedure = 2
    	}
    
    		private SqlCallType ConvertToSqlCallType(int sqlCallType) {
    			SqlCallType type = (SqlCallType)0;
    			if (sqlCallType == (int)SqlCallType.Text) {
    				type = SqlCallType.Text;
    			}
    			else if (sqlCallType == (int)SqlCallType.StoredProcedure) {
    				type = SqlCallType.StoredProcedure;
    			}
    			return type;

    приведение enum-->int по индусски для enum'а с двумя значениями....

    Unknown_2, 25 Ноября 2010

    Комментарии (3)
  11. Python / Говнокод #4734

    −166

    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
    import cgi
    import MySQLdb
     
    MyDB=MySQLdb.connect(host='localhost', user='root', passwd='', db='serv')
    cursor=MyDB.cursor()
    cursor.execute("""SELECT * FROM IndexPage WHERE id=2""")
    zg1=cursor.fetchall()
    zp=cgi.FieldStorage()
    p=zp.has_key('pages')
    lixt='lrof'
    title='{TITLE}'
    Block1='{BLOCK_1}'
     
    if p==1:
        print 'Content-Type: text/html\n'
        sh=open(r'themplates/sh2')
        res=sh.read()
        ...

    Пхпшники пересаживаются на Питон

    qbasic, 24 Ноября 2010

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