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

    В номинации:
    За время:
  2. 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)
  3. 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)
  4. 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)
  5. PHP / Говнокод #4754

    +145

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

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

    dwinner, 25 Ноября 2010

    Комментарии (3)
  6. 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)
  7. 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)
  8. 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)
  9. 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)
  10. 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)
  11. C++ / Говнокод #4719

    +155

    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
    /* use <first> of a [std::pair] */
    template<typename _type_, typename _pred_>
    struct use_first {
    	use_first(_type_ val, _pred_ pred) { value = val; predicate = pred; }
    	
    	template<typename _first_type_, typename _second_type_>
    	bool operator()(const std::pair<_first_type_, _second_type_> &pr)
    	{
    		return predicate(pr.first, value);
    	}
    
    private:
    	_type_ value;
    	_pred_ predicate;
    };
    
    /* factory function: use it to init a [use_first] object */
    template<typename _type_, typename _pred_>
    use_first<_type_, _pred_> make_use_first(_type_ value, _pred_ pred)
    {
    	return use_first<_type_, _pred_>(value, pred);
    }
    
    /* usage of [use_first] */
    std::vector< std::pair<int, int> > lol;
    std::vector< std::pair<int, int> >::iterator = std::find_if(lol.begin(), lol.end(), make_use_first(0, std::equal_to()));

    собственно была проблема в том, что в контейнерах(например std::vector, std::deque) хранятся пары(std::pair) и зачастую нужно организовать какие-либо действия либо по первому(first), либо по второму(second) члену из std::pair.
    приведен код только для first, ибо код для second немного похож

    в итоге получилось сие поделие, а еще я люблю обмазаться несвежим....

    Govnoeb, 23 Ноября 2010

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