1. JavaScript / Говнокод #12868

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function calculateRow(element) {
                var qty = element.val();
                var price = element.parent().next().next().children().text();
                var total = (qty * price).toFixed(2);
                $(element).parent().next().next().next().children().first().text(total);
            }

    _vinka, 09 Апреля 2013

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

    +151

    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 form = jQuery('#' + formId);
    jQuery(form).attr('action', s.url);
    jQuery(form).attr('method', 'POST');
    jQuery(form).attr('target', frameId);
    if(form.encoding)
        {
            jQuery(form).attr('encoding', 'multipart/form-data');      			
        }
    else
        {	
            jQuery(form).attr('enctype', 'multipart/form-data');			
        }			
    jQuery(form).submit();

    Без комментариев.)

    miraage, 09 Апреля 2013

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

    +137

    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
    91. 91
    92. 92
    93. 93
    q = Convert.ToString(a.ToString() + b.ToString() + c.ToString() + d.ToString() + f.ToString() + g.ToString() + h.ToString() + j.ToString() + k.ToString() + l.ToString());
    
    int a = int.Parse(textBox2.Text[0].ToString());
    int b = int.Parse(textBox2.Text[1].ToString());
    int c = int.Parse(textBox2.Text[2].ToString());
    int d = int.Parse(textBox2.Text[3].ToString());
    int f = int.Parse(textBox2.Text[4].ToString());
    int g = int.Parse(textBox2.Text[5].ToString());
    int h = int.Parse(textBox2.Text[6].ToString());
    int j = int.Parse(textBox2.Text[7].ToString());
    int k = int.Parse(textBox2.Text[8].ToString());
    int l = int.Parse(textBox2.Text[9].ToString());
    
    Random rnd = new Random();
    int a = rnd.Next(0, 2);
    int b = rnd.Next(0, 2);
    int c = rnd.Next(0, 2);
    int d = rnd.Next(0, 2);
    int f = rnd.Next(0, 2);
    int g = rnd.Next(0, 2);
    int h = rnd.Next(0, 2);
    int j = rnd.Next(0, 2);
    int k = rnd.Next(0, 2);
    int l = rnd.Next(0, 2);
    
    private void DoWork(int a, int b, int c, int d, int f, int g, int h, int j, int k, int l)
    
    private void ResetState()
    {
          pictureBox5.Visible = false;
          pictureBox6.Visible = false;
          pictureBox7.Visible = false;
          pictureBox8.Visible = false;
          pictureBox9.Visible = false;
          pictureBox2.Visible = false;
          pictureBox3.Visible = false;
          pictureBox4.Visible = false;
          pictureBox10.Visible = false;
          pictureBox11.Visible = false;
          pictureBox12.Visible = false;
          pictureBox13.Visible = false;
          pictureBox14.Visible = false;
          pictureBox15.Visible = false;
          pictureBox16.Visible = false;
          pictureBox17.Visible = false;
          pictureBox18.Visible = false;
          pictureBox19.Visible = false;
          pictureBox20.Visible = false;
          pictureBox27.Visible = false;
          pictureBox28.Visible = false;
          pictureBox29.Visible = false;
          pictureBox31.Visible = false;
          pictureBox32.Visible = false;
          pictureBox33.Visible = false;
          pictureBox34.Visible = false;
          pictureBox35.Visible = false;
          pictureBox36.Visible = false;
          pictureBox30.Visible = false;
          label2.Visible = false;
          label4.Visible = false;
          textBox2.Clear();
          textBox1.Clear();
    }
    
    
    if (((b == 0 && (a == 1)) || ((b == 0) && (a == 0)) || ((b == 1) && (a == 0)) || ((b == 1) && (a == 1))))
    {
    if ((b == 0) && (pictureBox3.Visible)) { pictureBox6.Visible = Enabled; }
    if ((b == 0) && (pictureBox2.Visible)) { pictureBox5.Visible = Enabled; } 
    if ((b == 1) && (pictureBox2.Visible)) { pictureBox6.Visible = Enabled; pictureBox4.Visible = Enabled; }
    if ((b == 1) && (pictureBox3.Visible)) { pictureBox5.Visible = Enabled; pictureBox4.Visible = Enabled; } 
    }
    
    //желательно чтоб здесь была пауза
    
    
    if (((c == 0 && (pictureBox5.Visible)) || ((c == 0) && (pictureBox6.Visible)) || ((c == 1) && (pictureBox5.Visible)) || ((c == 1) && (pictureBox6.Visible))))
    {
    if ((c == 0) && (pictureBox5.Visible)) { pictureBox7.Visible = Enabled; }
    if ((c == 0) && (pictureBox6.Visible)) { pictureBox8.Visible = Enabled; }
    if ((c == 1) && (pictureBox5.Visible)) { pictureBox8.Visible = Enabled; pictureBox29.Visible = Enabled; }
    if ((c == 1) && (pictureBox6.Visible)) { pictureBox7.Visible = Enabled; pictureBox29.Visible = Enabled; } 
    }
    
    //желательно чтоб здесь была пауза
    
    if (((d == 0 && (c == 1)) || ((d == 0) && (c == 0)) || ((d == 1) && (c == 0)) || ((d == 1) && (c == 1))))
    {
    if ((d == 0) && (pictureBox7.Visible)) { pictureBox9.Visible = Enabled; }
    if ((d == 0) && (pictureBox8.Visible)) { pictureBox10.Visible = Enabled; }
    if ((d == 1) && (pictureBox7.Visible)) { pictureBox10.Visible = Enabled; pictureBox30.Visible = Enabled; }
    if ((d == 1) && (pictureBox8.Visible)) { pictureBox9.Visible = Enabled; pictureBox30.Visible = Enabled; } 
    }

    Diman3241, 09 Апреля 2013

    Комментарии (69)
  4. bash / Говнокод #12863

    −110

    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
    GetDSFInstallPath()
    {
    	DSF_INSTALL_PATH=`defaults read "/Library/Preferences/com.ubisoft.${PRODUCT_PREF_NAME}.GameUpdate" execPath | sed -n 's/\(.*\)\/.*/\1/p'`
    
    	# Convert from Unicode codes
    	LOC_IN_STR=${DSF_INSTALL_PATH}
    	LOC_CODES=`echo "${LOC_IN_STR}" | grep -oE [\\\\]u[[:xdigit:]]{4} | sort -u | grep -oE [[:xdigit:]]+`
    	if [ -n "${LOC_CODES}" ]; then
    	 if [ `php -v >/dev/null  2>/dev/null; echo $?` -eq 0 ]; then
    		for LOC_CODE_I in ${LOC_CODES}; do 
    			LOC_CHAR=`php -r "echo(mb_convert_encoding(pack('H*','$LOC_CODE_I'),'UTF-8','UTF-16'));"`
    			LOC_IN_STR=`echo "$LOC_IN_STR" | sed "s/[\\\\]u$LOC_CODE_I/$LOC_CHAR/g"`
    		done
    		DSF_INSTALL_PATH="${LOC_IN_STR}"
    		else
    		 echo "Warning: Game path is undefined: ${DSF_INSTALL_PATH}. Please, remove it manualy."
    	 fi
    	fi
    }

    Фрагмент скрипта uninstall`a от Ubisoft на макинтоше. mb_convert_encoding pack вот для чего нужен этот пхп, который кстати идет в комплекте с игрушкой

    stasyan, 08 Апреля 2013

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

    +143

    1. 1
    2. 2
    3. 3
    $('table.list th').each(function () {
    			$(this).attr('class', $('> div', this).remove().text()); // хе-хе
    		});

    берем див на первом уровне, удаляем его, читаем с него текст (работает, не ругайтесь) и подставляем его в класс текущему элементу

    Serabas, 08 Апреля 2013

    Комментарии (28)
  6. Си / Говнокод #12860

    +136

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    uint16_t min_id, next_id, id;
    
    if (id - min_id < next_id - min_id) {
        // ...
    }

    Сегодня обнаружил в своем, не покрытом тестами, говнокоде этот эпик-фейл.
    Окрестосишкоблядился, что называется, по полной программе.

    Условие должно было проверять, лежит ли id в диапазоне [min_id; next_id) с учетом перехода через 0.
    Например min_id = 0xFFFE, next_id = 0x0003, id = 0x0002 должно вернуть true, а min_id = 43, next_id = 44, id = 42 - false.

    bormand, 07 Апреля 2013

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

    +78

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    #include <unistd.h>
     
     int main()
     {
       while(1)
         fork();
     }

    wlad1994, 06 Апреля 2013

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

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    //***Никогда не использовать))))
    	static function isset_not_empty($val){
    		if(isset($val) and !empty($val)) return true;
    		return false;
    	}

    погорячившийся))

    govnarkod, 06 Апреля 2013

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

    +19

    1. 1
    2. 2
    3. 3
    4. 4
    #include <iostream.h>
    #define TRUE 1
    #define FALSE 0
    typedef int Boolean;

    vortexx1, 06 Апреля 2013

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

    +13

    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
    #include <iostream>
    #include <vector>
    #include <stdlib.h>
    #include <time.h>
    
    using std::vector;
    
    void print_vec(const vector<int> v)
    {   /* Print Vector */
        for(vector<int>::size_type i(0); i!=v.size(); ++i)
            std::cout << v[i] << (i!=v.size()-1 ? "|":"\n");
    }
    
    bool sort_vec(const vector<int> v)
    {   /* Return True if vector sorted */
        bool b(true);
        for(vector<int>::size_type i(v.size()-1);i!=0;--i)
            if (v[i]<v[i-1]) {b=false;}
        return b;
    }
    
    int main()
    {
        vector<int> VectorForNumber;
        const unsigned int ConstMaxElement(10);
        srand(time(NULL));
        for(vector<int>::size_type i(0);i!=ConstMaxElement;++i)
            VectorForNumber.push_back(rand() % 50); // Max Number. Unsigned int && 0<N!
        while (not sort_vec(VectorForNumber))
        {
            print_vec(VectorForNumber);
            std::swap(VectorForNumber[rand() % ConstMaxElement],VectorForNumber[rand() % ConstMaxElement]);
        }
        print_vec(VectorForNumber);
        return 0;
    }

    Менять местами два элемента вектора до тех пор, пока он не станет отсортированным по возрастанию.
    С выводом сортирует примерно за 30 секунд вектор из 10 элементов, без вывода - от 0.5-1 секунды.

    eli, 06 Апреля 2013

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