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

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

    +51

    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
    std::list<COptions *> COptions::m_InstanceList;
    ..........
    COptions::COptions()
    {
    	for (int i = 0; i < OPTIONS_NUM; ++i)
    		m_OptionsCache[i].bCached = FALSE;
    	m_pOptionsHelperWindow = new COptionsHelperWindow(this);
    	simple_lock lock(m_mutex);
    #ifdef _DEBUG
    	for (std::list<COptions *>::iterator iter=m_InstanceList.begin(); iter != m_InstanceList.end(); ++iter)
    		ASSERT(*iter != this);
    #endif _DEBUG
    	m_InstanceList.push_back(this);
    	m_SpeedLimits[0] = m_sSpeedLimits[0];
    	m_SpeedLimits[1] = m_sSpeedLimits[1];
    }
    
    COptions::~COptions()
    {
    	{
    		simple_lock lock(m_mutex);
    		std::list<COptions *>::iterator iter;
    		for (iter=m_InstanceList.begin(); iter != m_InstanceList.end(); ++iter) {
    			if (*iter == this)
    				break;
    		}
    
    		ASSERT(iter != m_InstanceList.end());
    		if (iter != m_InstanceList.end())
    			m_InstanceList.erase(iter);
    	}
    
    	if (m_pOptionsHelperWindow)
    		delete m_pOptionsHelperWindow;
    	m_pOptionsHelperWindow=0;
    }
    .......

    В отладке включается тяжелый героиновый бред разработчиков FileZilla

    fsmoke, 24 Ноября 2014

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

    +49

    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
    void ZModulesDlg::OnDestroy(HWND hwnd)
    {
    	LVITEM lvi = { LVIF_PARAM };
    
    	if (lvi.iItem = ListView_GetItemCount(hwnd))
    	{
    		do 
    		{
    			lvi.iItem--;
    			if (ListView_GetItem(hwnd, &lvi))
    			{
    				((ZDll*)lvi.lParam)->Release();
    			}
    		} while (lvi.iItem);
    	}
    }

    zhukas, 17 Ноября 2014

    Комментарии (1)
  4. PHP / Говнокод #17091

    +156

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    // Real itemid is "contained" in public itemid in a bit tricky way. The formula is:
    
    public_itemid = itemid * 256 + anum
    
    // Quite easy, isn't it? Except where to get that anum. anum is some number assigned when you create a new post in LJ.
    
    // But in fact, you don't need it. Because it is always less than 256, we can avoid searching for it, and just use simple Math to find itemid.
    
    $anum = $public_itemid - floor($public_itemid / 256) * 256;
    $itemid = ($public_itemid - $anum) / 256;

    Прекрасный подход, то место, где вордпресс и ЖЖ сошлись воедино.

    http://drumrock.skipitnow.org/livejournal-tools/itemid/

    Fike, 10 Ноября 2014

    Комментарии (1)
  5. Python / Говнокод #17000

    −106

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    qdev_id, iops = _update_device_iops(instance, device_for_change)
    try:
    	qemu.volumes.set_io_throttle(controller.qemu(), qdev_id, iops)
    except Exception as e:
    	# Check if we turn off this instance? just a moment ago.
    	if "'NoneType' object has no attribute 'connected'" in e:
    		LOG.warning("kemu process seems to be killed")
    	else:
    		raise

    Метод set_io_throttle не бросает exception.
    Мы так проверяем,есть ли connection к qemu или нет.

    gmmephisto, 30 Октября 2014

    Комментарии (1)
  6. Куча / Говнокод #16990

    +126

    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
    .cat_mid a{
    color: #ffa10e !important;
    }
    .cat_mid {
    padding: 0 10px;
    display: inline-block;
    font-family: georgia, "times new roman", times, serif;
    font-weight: normal;
    font-size: 14px;
    height: 64px !important;
    overflow: hidden;
    margin-bottom: -3px !important;
    padding: 10px 10px 0;
    }
    .cat_hid {
    color: #bc843f;
    padding: 0 10px;
    text-align: left; 
    z-index: 100;
    position: relative;
    display: none;
    }
    .cat_hid.not{
    display: block !important;
    padding: 8px 10px 19px;
    }
    .cat_hid.not.price{
    height: 25px;
    padding: 12px 10px 17px;
    }

    css

    UncaughtException, 30 Октября 2014

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

    +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
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    $(function() {
    			$('#diametr').on('change', function() {
    				window.location = '/catalog/<?=$arResult['SECTION']['CODE']?>/'+this.value+'/';
    			});
    			
    			$('#type_s').on('change', function() {
    				$('#size_s').find('option:enabled').prop("disabled", true);
    				$('#size_s').find('option[data-prop-material='+$(this).find('option:selected').data('propMaterial')+']').prop("disabled", false).first().prop("selected", true);
    				$('#size_s').trigger('change')
    			});
    			
    			$('#type_p').on('change', function() {
    				$('#size_p').find('option:enabled').prop("disabled", true);
    				$('#size_p').find('option[data-prop-type='+$(this).find('option:selected').data('propType')+']').prop("disabled", false).first().prop("selected", true);
    				$('#size_p').trigger('change')
    			});
    			
    			
    			$(document)
    				.on('change', '#size_s, #size_p', function() {
    					
    					$('#selected_prop').val('csone_19_'+$(this).find('option:selected').data('propId'));
    				})
    				.on('click', '.but_sita', function() {
    					console.log($(this).parent().find('select').first());
    					$(this).parent().find('select').first().trigger('change');
    				});
    			$('.but_sita').last().trigger('click');
    			
    			$('#additional_spoiler').on('click', function(e) {
    				e.preventDefault();
    				$('#additional').fadeIn();
    			});
    		});

    UncaughtException, 29 Октября 2014

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

    −122

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    Public m_Values As Hashtable    
    
    Public Function GetSensorType(p_SensorType As SensorType) As SensorValue
            For Each de As DictionaryEntry In m_Values
                If CType(de.Key, SensorType) = p_SensorType Then
                    Return de.Value
                End If
            Next
            Return Nothing
     End Function

    Отличный пример работы с Hashtable!

    IlyaS, 24 Октября 2014

    Комментарии (1)
  9. C# / Говнокод #16921

    +134

    1. 1
    2. 2
    3. 3
    4. 4
    //#if UNITY_IPHONE && !(UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_3_6 || UNITY_3_7 || UNITY_3_8 || UNITY_3_9 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9)
    if (Selection.activeGameObject != null)
    control = (IControl)Selection.activeGameObject.GetComponent("IControl");
    //#endif

    принял код от юнити юниора

    sladkijBubaleh, 23 Октября 2014

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

    +135

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    bool result = false;
    if (xmlString != null)
    {
       result = reportService.SaveQ360Report(questionnaireId, xmlString, publishReport);
       UpdateCurrentReportModel(questionnaireId, reportService);
    }
    // string errorMessage;
    if (result == false)
       result = true; //because model is not changed
    return Json(new { Success = result, ErrorMessage = DisplayLabels.InvalidModelError });

    sharpman, 23 Октября 2014

    Комментарии (1)
  11. JavaScript / Говнокод #16912

    +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
    <script>
    	$(function() {
    		$('#current').load('current.php');
    	}
    </script>
    
    // Тем временем в current.php :
    <?
    $result = ... ; // данные как-то вытаскиваются из базы
    ob_start();?>
    <table><?
    foreach($result as $res) {?>
    <tr><td><?=$res[0]?></td><td><?=$res[1]?></td><td><?=$res[2]?></td></tr>
    <?}?>
    </table>
    <?$table = ob_get_clean();?>
    <script>
              $('#current').empty();
              $('#current').append('<?=str_replace(array("\r","\n"),"",$table)?>'); 
    </script>

    Извиняюсь за возможные опечатки: сократил, чтобы оставить только самую мякотку.

    clauclauclau, 23 Октября 2014

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