1. Си / Говнокод #6537

    +140

    1. 1
    2. 2
    3. 3
    4. 4
    if ((u[i]!=100500)&&(v[j]==100500))
        v[j]=matr[i+1][j+1].cost-u[i];
    if ((u[i]==100500)&&(v[j]!=100500))
        u[i]=matr[i+1][j+1].cost-v[j];

    пересчет платежей в ТЗЛП

    resettik, 04 Мая 2011

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

    +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
    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
    94. 94
    /*Windows 8 source code.*/
    /*
    TOP SECRET Microsoft(c) Code
    Project: Cairo(tm)
    Projected release-date: Summer 2012
    */
    
    #include "winnt.h"
    #include "evenmore.h"
    #include "oldstuff.h"
    #include "billrulz.h"
    #define INSTALL_HARD_C
    #define INSTALL_DIR_WINDOWS
    
    char make_prog_look_big[160000000] ;
    
    void main()
    {
        while(!CRASHED)
        {
             display_copyright_message();
             display_bill_rules_message();
             do_nothing_loop();
    
             if (first_time_installation)
             {
                 make_4gb_megabyte_swapfile();
                 do_nothing_loop();
                 display_funny_3d();
                 hang_system();
             }
     
             write_something(anything);
             display_copyright_message();
             do_nothing_loop();
             do_some_stuff();
             if (still_not_crashed)
             {
                 display_copyright_message();
                 do_nothing_loop();
                 basically_run_windows_vista();
                 show3d_in_loop();
                 do_nothing_loop();
                 do_nothing_loop();
             }
         }
     
         if (detect_cache())
             disable_cache();
     
         if (fast_cpu())
         {
             set_wait_states(lots);
             set_mouse(speed, very_slow);
             set_mouse(action, jumpy);
             set_mouse(reaction, sometimes);
         }
        
         if (fast_gpu())
         {
             setitonfire(dx12);
         }
    
         if (lotofmemory()) 
         {  
            //achtung: red alert!
            /* allocateforfutureuse(200mb); */
             allocateforfutureuse(2gb);
    
         }
     
         /* printf("Welcome to Windows Vista"); */
         /* printf("Welcome to Windows 7"); */
         printf("Welcome to Windows 8");
     
         if (system_ok())
             crashex(aero3denalbed());
         else;
         /*    system_memory = open("a:\swp0001.swp", O_CREATE); */
    
     
         while(something)
         {
             allocate_random_memory();
             sleep(5);
             get_user_input();
             sleep(5);
             display_uac_prompt();
             act_on_user_input();
             sleep(5);
         }
         draw_3d_bsod();
         die();
    }

    wwwww, 03 Мая 2011

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

    +153

    1. 1
    $request->request->get('page'); // get a $_POST parameter

    symfony2
    Почему не $request->post->get('page'); ???

    striker, 03 Мая 2011

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

    +129

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    public void UpdateSession()
            {
                this.RequestTypeId = this.RequestTypeId;
                this.ServiceId = this.ServiceId;
                this.Name = this.Name;
            }

    "Обновление" сессии. Взято из реального проекта.

    wader, 03 Мая 2011

    Комментарии (23)
  5. ActionScript / Говнокод #6533

    −104

    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
    function BU(BTN:MovieClip, URL_to){
    BTN.buttonMode = true;
    function STRT_CLOS(BTN:MovieClip, K_P){
     BTN.removeEventListener(Event.ENTER_FRAME,  POS_CLOS)
     BTN.addEventListener(Event.ENTER_FRAME,  POS_CLOS)
    }
    function STRT_OP(BTN:MovieClip, K_P){
     BTN.removeEventListener(Event.ENTER_FRAME,  OPen)
     BTN.addEventListener(Event.ENTER_FRAME,  OPen)
    ...
    
    
    p.p.gotoAndStop ("prav_sr"
    p.p.b.nadp.stop ();
    p.p.f.nadp.stop ();
    p.p.k.nadp.stop ();
    p.p.konf.nadp.stop ();
    p.p.prav.nadp.stop ();
    p.p.raz.stop ();
    raskr (p.p.b);
    raskr (p.p.f);
    raskr (p.p.k);
    raskr (p.p.konf);
    raskr (p.p.prav);
    raskr (p.p.raz);
    p.p.b.t=false;
    p.p.f.t=false;
    p.p.k.t = false;
    
    ....
    
    var SS:MovieClip = this.parent.parent as MovieClip
    var SSSS = this.parent.parent.parent as MovieClip
    var OOOO:MovieClip = SSSS.BAZ_LOER.getChildByName("ZaGl")
    
    ....
    
    BTN.otkr="otkr";
    BTN.kloc="klos";
    if (BTN.otkr!="otkr") return;

    Код на кадрах, в проекте не одна к строк подобного содержания.

    kyzi007, 03 Мая 2011

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

    +166

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    // Если регистрация, то показываем контрольный вопрос
    if($_GET['op'] == 'registration') {
    $vars['c_question'] = true;
    } else {
    $vars['c_question'] = false;
    }

    Классика

    Мартин, 02 Мая 2011

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

    +168

    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
    typedef union Variant
        {
        public:
            Variant() {}
    
            Variant(signed int val) :
                v_int(val)
            {}
            operator signed int &() { return const_cast<signed int&>(this->operator const signed int &()); }
            operator const signed int&() const { return v_int; }
    
            Variant(unsigned int val) :
                v_uint(val)
            {}
            operator unsigned int &() { return const_cast<unsigned int&>(this->operator const unsigned int &()); }
            operator const unsigned int &() const { return v_uint; }
    
            Variant(char val) :
                v_char(val)
            {}
            operator char &() { return const_cast<char&>(this->operator const char &()); }
            operator const char&() const { return v_char; }
    
            Variant(double val) :
                v_float(val)
            {}
            operator double &() { return const_cast<double&>(this->operator const double &()); }
            operator const double &() const { return v_float; }
    
            Variant(void *val) :
                v_ptr(val)
            {}
            operator void*& () { return const_cast<void*&>(this->operator void *&()); }
            operator const void* const& () const { return v_ptr; }
    
            static size_t getValueSize(const Type::OfType &type)
            {
                size_t result = 0;
                switch ( type )
                {
                case Type::Pointer:
                case Type::CharPtr:
                case Type::IntPtr:
                case Type::UIntPtr:
                case Type::RealPtr:
                case Type::String:
                    result = sizeof(v_ptr);
                    break;
                case Type::Char:
                    result = sizeof(v_char);
                    break;
                case Type::Int:
                    result = sizeof(v_int);
                    break;
                case Type::UInt:
                    result = sizeof(v_uint);
                    break;
                case Type::Real:
                    result = sizeof(v_float);
                    break;
                case Type::Void:
                    result = 0;
                    break;
                }
                return result;
            }
    
        private:
            void* v_ptr;
            char v_char;
            unsigned int v_uint;
            signed int v_int;
            double v_float;
        } Variant;

    Небольшая имплементация безтиповости ;-[

    Elvenfighter, 02 Мая 2011

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

    +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
    void tolowerStr(char *Str)
    {
         #include <windows.h>
         #include <ctype.h>
    
         SetConsoleCP(1251);
         SetConsoleOutputCP(1251);
         setlocale(LC_CTYPE,"Russian");
         
         int len = strlen(Str);
         for(int c=0; c<len; c++)
           Str[c] = tolower(Str[c]);
    }

    инклайд в теле ф-и :D

    Antichat, 02 Мая 2011

    Комментарии (9)
  9. PHP / Говнокод #6529

    +161

    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
    if($age != '') {
    			$d_m_y = explode('-', $age); // Разделяем на day(0) month(1) year(2)
    		// ГЕНЕРАЦИЯ ФОРМЫ С ДНЕМ РОЖДЕНИЯ
    		$vars['bday'] = "<select name=\"b_day\">\n<option>-</option>\n";
    		$i = 1;
    		while ($i <= 31) {
    			if($d_m_y[0] == $i) {
    				$sel = ' selected';
    			} else {
    				$sel = '';
    			}
    			$vars['bday'] .= '<option'.$sel.'>'.$i."</option>\n";
    			$i++;
    		}
    		$vars['bday'] .= "</select>\n";
    		// ГЕНЕРАЦИЯ СПИСКА С МЕСЯЦАМИ
    		$i = 1;
    		$vars['bmonth'] = "<select name=\"b_month\">\n<option>-</option>\n";
    		while ($i <= 12) {
    			if($d_m_y[1] == $i) {
    				$sel = ' selected';
    			} else {
    				$sel = '';
    			}
    			$vars['bmonth'] .= '<option'.$sel.'>'.$i."</option>\n";
    			$i++;
    		}
    		$vars['bmonth'] .= "</select>\n"; // Месяц ДР при ред
    		// ГЕНЕРАЦИЯ СПИСКА С ГОДАМИ
    		$i = 1940;
    		$vars['byear'] = "<select name=\"b_year\"\n<option>-</option>\n"; // Год ДР при ред
    		while ($i <= 2003) {
    			if($d_m_y[2] == $i) {
    				$sel = ' selected';
    			} else {
    				$sel = '';
    			}
    			$vars['byear'] .= '<option'.$sel.'>'.$i."</option>\n";
    			$i++;
    		}
    		$vars['byear'] .= "</select>\n";
    		$vars['use_age'] = false; // ОТКЛЮЧАЕМ ПОКАЗ ПУСТОГО СПИСКА
    		} else {
    		$vars['use_age'] = true;
    		$vars['bday'] = false;
    		$vars['bmonth'] = false;
    		$vars['byear'] = false;
    		}

    Генерация SELECT'ов для выбора даты рождения

    Мартин, 02 Мая 2011

    Комментарии (5)
  10. PHP / Говнокод #6528

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    /**
       * Строка парсится в аргументы функции
       * @param string
       * @return <type>
       */
      protected function _parse_func_arg ( $str ) {
        return func_get_args();
      }

    Поколупал netсat. Получил много эмоций... Спасибо.
    ( PS. По-моему, скоро netсat останется только в unix... )

    istem, 02 Мая 2011

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