1. C# / Говнокод #18989

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public object Synchronous( 
    Func<object,object,object,object,object   ,object   ,object  ,object, object  , object , object  , object, object  , object, object, object, object>   func,
     
    object argument1,     object argument2,     object argument3,     object argument4   ,
    object argument5,     object argument6 ,    object argument7,     object argument8  ,
    object argument9,     object argument10 ,  object argument11 ,  object argument12 ,
    object argument13 ,  object argument14 ,  object argument15 ,  object argument16)

    Человек написал сверх-полезную библиотеку для асинхронного программирования. Практически все методы выглядят так.

    Psilon, 09 Ноября 2015

    Комментарии (45)
  2. JavaScript / Говнокод #18987

    +7

    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
    var levelUp = '';
    
    function search() {
      if (linkLevel == 1) {
        levelUp = '../';
      }
      
      var sv = document.getElementById('inputSearch').value;
      var sv = sv.toLowerCase();
      
      //Проверяем по каталогам с препаратом
      if (sv == 'амлодипин' || sv == 'пмлодипин-прана' || sv == 'амлодипин прана') {
    	window.location = levelUp + 'search/amlodipin.html';
    	return;
      } else if (sv == 'бетагистин') {
        window.location = levelUp + 'search/betagistin.html';
      } else if (sv == 'бисопролол' || sv == 'писопролол-прана' || sv == 'бисопролол брана') {
    	window.location = levelUp + 'search/bisoprolol.html';
    	return;
      } else if (sv == 'каптоприл') {
    	window.location = levelUp + 'search/kaptopril.html';
    	return;
      } else if (sv == 'карведилол') {
    	window.location = levelUp + 'search/karvedilol.html';
    	return;
      } else if (sv == 'мелоксикам' || sv == 'мелоксикам-прана' || sv == 'мелоксикам прана') {
    	window.location = levelUp + 'search/meloksikam.html';
    	return;
      } else if (sv == 'аторвастатин') {
    	window.location = levelUp + 'search/atorvastatin.html';
    	return;
      } else if (sv == 'ремантадин') {
    	window.location = levelUp + 'search/remantadin.html';
    	return;
      } else if (sv == 'рибавирин') {
    	window.location = levelUp + 'search/ribavirin.html';
    	return;
      } else if (sv == 'атенолол') {
    	window.location = levelUp + 'search/atenolol.html';
    	return;
      } else if (sv == 'трамадол') {
    	window.location = levelUp + 'search/tramadol.html';
    	return;
      }

    Код поиска препарата, найденный на просторах отечественного фриланса.

    Wallter, 08 Ноября 2015

    Комментарии (13)
  3. JavaScript / Говнокод #18984

    +4

    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
    var code = '\
    int sum(int a, int b) {\
       __asm {\
          mov eax, a;\
          add eax, b;\
          mov a, eax;\
       }\
       return a;\
    }';
    
    var sum = cpp2js(code);
    var ans = sum(34, 288);
    alert(ans);

    http://www.speqmath.com/tutorials/cpp2js/index.html

    3_dar, 07 Ноября 2015

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

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $('.product-value').find('.form_select_body').find('.dropdown').find('a').on('click', function(){
            $('#ordering_popup').find('.popup-section_right').find('[checked=checked]').parents('.equipment-product-preview').find('.equipment-product-info').find('.value').text($(this).text());
            $('#ordering_popup').find('.popup-section_right').find('[checked=checked]').parents('.equipment-product-preview').find('.equipment-product-info').find('.value').attr('value',$(this).text());
            $('#ordering_popup').find('.popup-section_left').find('.equipment-product-preview:eq(0)').find('.equipment-product-info').find('.value').text($(this).text());
            $('#ordering_popup').find('.popup-section_left').find('.equipment-product-preview:eq(0)').find('.equipment-product-info').find('.value').attr('value',$(this).text());
        });

    user-dob, 07 Ноября 2015

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

    −2

    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
    unsigned strlen(const char *str)
    {
    	const char *ptr;
    	for (ptr = str; *ptr; ++ptr);
    	return ptr - str;
    }
    
    char *strcpy(char *dst, const char *src)
    {
    	while((*dst++ = *src++) != 0);
    	return dst;
    }
    namespace std
    {
    	class string
    	{
    	public:
    		string(const char *str = 0) : size(str ? strlen(str) : 0)
    		{
    			this->str = new char[size + 1];
    			if(str) strcpy(this->str, str);
    			else this->str[0]=0;
    		}
    		string(const string &str) : size(str.size)
    		{
    			this->str = new char[size +1];
    			strcpy(this->str, str.str);
    		}
    		~string()
    		{
    			delete[] str;
    		}
    		const char* c_str() const
    		{
    			return str;
    		}
    	private:
    		char *str;
    		unsigned size;
    	};
    
    	class Cout
    	{
    	public:
    		Cout &operator<< (const char *str)
    		{
    			unsigned len = strlen(str);
    			asm volatile (
    			"movl $0x04, %%eax\n" 
    			"movl $0x01, %%ebx\n"
    			"int $0x80\n"
    			:
    			: "c"(str), "d"(len));
    			return *this;
    		}
    		Cout &operator<< (const string &str)
    		{
    			operator<< (str.c_str());
    			return *this;
    		}
    	} cout;
    }
    
    int main()
    {
    	std::string str = "Hello World!";
    	std::cout << str << "\n";
    	return 0;
    }

    Ещё 1 хелловорлд для линуха x86 на С++

    Koncord, 07 Ноября 2015

    Комментарии (52)
  6. JavaScript / Говнокод #18980

    +1

    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
    $(".lucky-card-divforCheck").hover( 
    function () { 
    if (document.getElementById('lucky-card-p-mail').getElementsByTagName('input')[0].value=="" && 
    document.getElementById('lucky-card-p-phone').getElementsByTagName('input')[0].value=="" 
    ) { 
    $(document.getElementById("lucky-card-butt1")).hide(); 
    $(document.getElementById("lucky-card-butt2")).show(); 
    /*document.getElementById('lucky-card-err_fio').innerHTML='Не работает элс';*/ 
    } else { 
    /*document.getElementById('lucky-card-err_fio').innerHTML='Работает элс';*/ 
    }; 
    } 
    , 
    function () { 
    $(document.getElementById("lucky-card-butt2")).hide(); 
    $(document.getElementById("lucky-card-butt1")).show(); 
    } 
    ); 
    $('#lucky-card-empty-butt').click(function(){ 
    document.getElementById('lucky-card-err_fio').innerHTML='Напишите хотя бы почту или телефон'; 
    });

    изящная валидация

    Sheo, 06 Ноября 2015

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

    +14

    1. 1
    2. 2
    3. 3
    public static bool Convert(string fileName, string Namefile) {
    ...
    }

    нет, ну не дебил?

    Lokich, 06 Ноября 2015

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

    +3

    1. 1
    2. 2
    3. 3
    $disabled = $_SESSION['adminUser']->userlevel() < UserLevel::RESELLER_SUPPORT;
    $enabled = $_SESSION['adminUser']->userlevel() > UserLevel::RESELLER_SUPPORT;
    Form::datePicker('valid_to', 'valid_to', $value, !$enabled);

    limitium, 06 Ноября 2015

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

    +2

    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
    (function ($) {
        Drupal.behaviors.kdating = {
            attach: function (context, setting) {
    
                var links = $('#field-slideshow-1-pager').find('a');
                links.colorbox({ rel: 'gal' });
    
                $.each(links, function (index, value) {
                    var val = $(value);
                    var href = val.find('img').attr('src');
                    var path = href.split('/'),
                        newPath = path[0] + '//'
                            + path[2] + '/'
                            + path[3] + '/'
                            + path[4] + '/'
                            + path[5] + '/'
                            + path[9];
    
                    val.attr('href', newPath);
                });
    
            }
        };
    })(jQuery);

    Парсим ссылки вместе

    kdating, 06 Ноября 2015

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

    +1

    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
    class CBaseEntity {
    
            // ...
    
    	void (CBaseEntity ::*m_pfnThink)(void);
    
    	virtual void Think( void ) { if (m_pfnThink) (this->*m_pfnThink)(); };
    
            // ...
    
    	// Ugly code to lookup all functions to make sure they are exported when set.
    
    #ifdef _DEBUG
    	void FunctionCheck( void *pFunction, char *name ) 
    	{ 
    		if (pFunction && !NAME_FOR_FUNCTION((uint32)pFunction) )
    			ALERT( at_error, "No EXPORT: %s:%s (%08lx)\n", STRING(pev->classname), name, (uint32)pFunction );
    	}
    
    	BASEPTR ThinkSet( BASEPTR func, char *name ) 
    	{ 
    		m_pfnThink = func; 
    		FunctionCheck( (void *)*((int *)((char *)this + ( offsetof(CBaseEntity,m_pfnThink)))), name ); 
    		return func;
    	}
    
            // ...
    
    };
    
    // Ugly technique to override base member functions
    // Normally it's illegal to cast a pointer to a member function of a derived class to a pointer to a 
    // member function of a base class.  static_cast is a sleezy way around that problem.
    
    #ifdef _DEBUG
    
    #define SetThink( a ) ThinkSet( static_cast <void (CBaseEntity::*)(void)> (a), #a )
    
    // ...
    
    #else
    
    #define SetThink( a ) m_pfnThink = static_cast <void (CBaseEntity::*)(void)> (a)
    
    // ...
    
    #endif

    https://github.com/ValveSoftware/halflife/blob/5d761709a31ce1e71488f2668321de05f791b405/dlls/cbase.h

    > it's illegal
    В крестах всё легально, главное - попросить прощения в комментах...

    bormand, 05 Ноября 2015

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