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

    +262

    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 <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    #define e if
    #define h while
    #define s return
    #define v NULL
    #define r else
    #define u case
    #define C switch
    #define D for
    #define L0 typedef
    #define L int
    L0 char S;L0 S*Z;L0 Z*U;L0 double N;
    L0 struct Q{L Z;union{N b;S c;}M;struct Q*w;struct Q*q;}Q;
    Q*K(L w){Q*n=(Q*)malloc(sizeof(Q));e(v==n)exit(1);n->Z=w;s n;}
    void A(Z g,U t){h(' '==*g)g++;*t=g;}
    Q*V(Z g,U t){Q*n=K(2);n->M.b=strtod(g,t);s n;}
    Q*I(Z g,U t){e('+'!=*g)s v;Q*n=K(1);n->M.c='+';++*t;s n;}
    Q*W(Z g,U t){e('x'!=*g)s v;Q*n=K(20);g++;e(*g<'0'||*g>'9'){n->M.b=1;*t=g;}r{n->M.b=strtod(g,t);e(*t==g)n->M.b=1;}s n;}
    Q*J(Z g,U t){Q*n,*p=v;h(*g){A(g,&g);Q*l=V(g,&g);A(g,&g);Q*m=W(g,&g);Q*o;e(v==m)o=l;r{o=K(1);o->M.c='*';o->w=l;o->q=m;}e(v==p)n=o;r{p->w=n;p->q=o;n=p;}A(g,&g);p=I(g,&g);e(v==p){*t=g;s n;}}}
    Q**E(Z g){L n=1,i;Z t=g;h(*t){e(';'==*t)n++;t++;}Q**R=(Q**)malloc((n+1)*sizeof(Q*));e(v==R)s v;D(i=0;i<n;++i){R[i]=J(g,&g);e(*g!=';'&&*g!=0)s v;e(v==R[i])s v;g++;}R[n]=v;s R;}
    N P(Q*I,N a){C(I->Z){u 1:C(I->M.c){u '+':s P(I->w,a)+P(I->q,a);u '*':s P(I->w,a)*P(I->q,a);u '/':s P(I->w,a)/P(I->q,a);u '-':s P(I->w,a)-P(I->q,a);}u 2:s I->M.b;u 20:s pow(a,I->M.b);}}
    N O(Q*I){N x=0,y=1,z=2,Z=P(I,x),X=P(I, y),H=P(I,z),j=1e-10;L i;D(i=0;i<100&&fabs(z-y)>j&&fabs(x-y)>j&&fabs(X)>j;i++){e(Z*X<0){z=y;H=X;}r e(H*X<0){x=y;Z=X;}r{N d=z-x;x=x-d;z=z+d;Z=P(I,x);X=P(I,y);}y=(z+x)/2;X=P(I,y);}s y;}
    Z B(Q**A){L n=0,i,j,d=0;D(;A[n]!=v;n++);Z M=(Z)malloc(n*10+1);e(v==M)s v;D(i=0;A[i]!=v;i++)D(j=0;j<10;j++){
      M[i*10+j-d]=(S)fmod(12.51*O(A[i])+j*17,256);
    e(!M[i*10+j-d])d++;}M[n*10-d]=0;s M;}
    L T(Z g,Z M){Z k=M;h(*g){*g++^=*k++;e(!*k)k=M;}s(0);}
    L main(void){
        Q**n=E("2.0x5+6.2x2+7;0.3x6.1+6x5+1");
        L i;
        Z k=B(n);
        S w[]={-91,-35,97,113,89,37,113,32,28,-10,124,67,93,32,123,70,63,-19,-71,-123,-114,45,109,64,96,57,13,7,-91,0};
        T(w,k);
        printf("%s\n",w);
    }

    Nastenka1998, 19 Августа 2016

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

    +313

    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
    <?php
    
    use PHPUnit\Framework\TestCase;
    
    class SecurityTokenTest extends TestCase
    {
    
        /**
         * @dataProvider getData
         */
        public function testGetCookieToken($user, $token, $result)
        {
            $reflect = new \ReflectionClass('AppBundle\Security\TokenCookieStorage');
            /** @var TokenCookieStorage $storage */
            $storage = $reflect->newInstanceWithoutConstructor();
    
            $reflect->getProperty('abstractUser')
                ->setValue($storage, $user);
            $reflect->getProperty('cookieDriver')
                ->setValue($storage, new class($token) {
                    public $token;
    
                    public function __construct($token)
                    {
                        $this->token = $token;
                    }
    
                    public function get($id)
                    {
                        return ($id) ? $this->token : null;
                    }
                });
    
            $this->assertSame($storage->getToken(), $result);
        }
    
    ....

    PHPUnit. Тяжело написать тесты для говнокода. Чувак не слышал про mockbuilder

    konmado, 19 Августа 2016

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

    +314

    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
    <?php
    require 'classes/_func.class.php';
    $func = new func();
    if($_SESSION['user']){
      $user_id = func::clear($_SESSION['user'],'int');
      $time = time();
      $ip = $_SERVER['REMOTE_ADDR'];
      $db->Query("UPDATE users SET last = '{$time}', ip = '{$ip}' WHERE id = '{$user_id}'");
      function stockGen($user_id){
        global $db;
        $db->Query("SELECT * FROM users WHERE id = '{$user_id}'");
        $user_data = $db->FetchArray();
        $db->Query("SELECT * FROM users_conf WHERE user_id = '{$user_id}'");
        $sub_data = $db->FetchArray();
        $data = array_merge($user_data,$sub_data);
        $day = time() - 86400;
        $db->Query("SELECT
          (SELECT ref_1 FROM users_ref WHERE user_id = '{$user_id}') ref_id,
          (SELECT COUNT(*) FROM banner_history WHERE user_id = '{$user_id}') banner_views,
          (SELECT COUNT(*) FROM link_history WHERE user_id = '{$user_id}') link_views,
          (SELECT COUNT(*) FROM users_ref WHERE ref_1 = '$user_id') referals,
          (SELECT time FROM auth WHERE user_id = '{$user_id}' ORDER BY id DESC LIMIT 1) last_auth,
          (SELECT SUM(money) FROM payments WHERE user_id = '{$user_id}' AND status = '2') pay,
          (SELECT SUM(money) FROM inserts WHERE user_id = '{$user_id}' AND status = '2') ins,
          (SELECT SUM(to_ref_1) FROM users_ref WHERE ref_1 = '{$user_id}') from_refs_1,
          (SELECT SUM(to_ref_2) FROM users_ref WHERE ref_2 = '{$user_id}') from_refs_2,
          (SELECT SUM(to_ref_3) FROM users_ref WHERE ref_3 = '{$user_id}') from_refs_3,
          (SELECT to_ref_1 FROM users_ref WHERE user_id = '{$user_id}') to_ref");
        $data += $db->FetchArray();
        $data['from_refs'] = sprintf('%.2f',$data['from_refs_1'] + $data['from_refs_2'] + $data['from_refs_3']);
        $data['all_view'] = intval($data['banner_views']) + intval($data['link_views']);
        $data['all_money'] = 0;/*sprintf('%.2f',(floatval($data['link_money']) + floatval($data['banner_money']) + floatval($data['mails_money'])))*/
        $data['all_money_day'] = 0;/*sprintf('%.2f',(floatval($data['link_money_day']) + floatval($data['banner_money_day']) + floatval($data['mails_money_day'])))*/
        $ref_id = $data['ref_id'];
        if ($ref_id != '0') {
          $db->Query("SELECT login FROM users WHERE id = '{$ref_id}'");
          $data['referer'] = $db->FetchRow();
        }else $data['referer'] = 'Пришел сам';
        $db->Query("SELECT * FROM auth WHERE user_id = '{$user_id}' ORDER BY time DESC LIMIT 10");
        if ($db->NumRows() > 0) {
          $data['auth_history'] = $db->FetchAll();
        }else $data['auth_history'] = '0';
        new gen('account/account',$data);
      }
      if(isset($url[2]) && !empty($url[2])){
        $ctrl = $func->clear($url[2]);
        $file = 'controllers/account/'.$ctrl.'Ctrl.php';
        if(file_exists($file)){
          include $file;
        }else stockGen($user_id);
      }else stockGen($user_id);
    }else header('location: /login');
    
    // (SELECT SUM(money) FROM banner_history WHERE user_id = '{$user_id}') banner_money,
    // (SELECT SUM(money) FROM link_history WHERE user_id = '{$user_id}') link_money,
    // (SELECT SUM(money) FROM mails_history WHERE user_id = '{$user_id}') mails_money,
    // (SELECT SUM(money) FROM link_history WHERE user_id = '{$user_id}' AND time > '{$day}') link_money_day,
    // (SELECT SUM(money) FROM banner_history WHERE user_id = '{$user_id}' AND time > '{$day}') banner_money_day,
    // (SELECT SUM(money) FROM mails_history WHERE user_id = '{$user_id}' AND time > '{$day}') mails_money_day,

    источник: https://toster.ru/q/346342

    riot26, 19 Августа 2016

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

    +317

    1. 1
    $this->db->query("UPDATE `" . DB_PREFIX . "order` SET firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', payment_firstname = '" . $this->db->escape($data['payment_firstname']) . "', payment_lastname = '" . $this->db->escape($data['payment_lastname']) . "', payment_company = '" . $this->db->escape($data['payment_company']) . "', payment_company_id = '" . $this->db->escape($data['payment_company_id']) . "', payment_tax_id = '" . $this->db->escape($data['payment_tax_id']) . "', payment_address_1 = '" . $this->db->escape($data['payment_address_1']) . "', payment_address_2 = '" . $this->db->escape($data['payment_address_2']) . "', payment_city = '" . $this->db->escape($data['payment_city']) . "', payment_postcode = '" . $this->db->escape($data['payment_postcode']) . "', payment_country = '" . $this->db->escape($payment_country) . "', payment_country_id = '" . (int)$data['payment_country_id'] . "', payment_zone = '" . $this->db->escape($payment_zone) . "', payment_zone_id = '" . (int)$data['payment_zone_id'] . "', payment_address_format = '" . $this->db->escape($payment_address_format) . "', payment_method = '" . $this->db->escape($data['payment_method']) . "', payment_code = '" . $this->db->escape($data['payment_code']) . "', shipping_firstname = '" . $this->db->escape($data['shipping_firstname']) . "', shipping_lastname = '" . $this->db->escape($data['shipping_lastname']) . "',  shipping_company = '" . $this->db->escape($data['shipping_company']) . "', shipping_address_1 = '" . $this->db->escape($data['shipping_address_1']) . "', shipping_address_2 = '" . $this->db->escape($data['shipping_address_2']) . "', shipping_city = '" . $this->db->escape($data['shipping_city']) . "', shipping_postcode = '" . $this->db->escape($data['shipping_postcode']) . "', shipping_country = '" . $this->db->escape($shipping_country) . "', shipping_country_id = '" . (int)$data['shipping_country_id'] . "', shipping_zone = '" . $this->db->escape($shipping_zone) . "', shipping_zone_id = '" . (int)$data['shipping_zone_id'] . "', shipping_address_format = '" . $this->db->escape($shipping_address_format) . "', shipping_method = '" . $this->db->escape($data['shipping_method']) . "', shipping_code = '" . $this->db->escape($data['shipping_code']) . "', comment = '" . $this->db->escape($data['comment']) . "', order_status_id = '" . (int)$data['order_status_id'] . "', affiliate_id  = '" . (int)$data['affiliate_id'] . "', date_modified = NOW() WHERE order_id = '" . (int)$order_id . "'");

    Строчечка

    govnozmey, 18 Августа 2016

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

    +318

    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
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>, GenericString<Char, Allocator>> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>&, GenericString<Char, Allocator>> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>&&, GenericString<Char, Allocator>> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<const GenericStringView<Char>&, GenericString<Char, Allocator>> {typedef GenericString<Char, Allocator> _;};
    
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>, GenericString<Char, Allocator>&> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>&, GenericString<Char, Allocator>&> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>&&, GenericString<Char, Allocator>&> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<const GenericStringView<Char>&, GenericString<Char, Allocator>&> {typedef GenericString<Char, Allocator> _;};
    
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>, GenericString<Char, Allocator>&&> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>&, GenericString<Char, Allocator>&&> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>&&, GenericString<Char, Allocator>&&> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<const GenericStringView<Char>&, GenericString<Char, Allocator>&&> {typedef GenericString<Char, Allocator> _;};
    
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>, const GenericString<Char, Allocator>&> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>&, const GenericString<Char, Allocator>&> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>&&, const GenericString<Char, Allocator>&> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<const GenericStringView<Char>&, const GenericString<Char, Allocator>&> {typedef GenericString<Char, Allocator> _;};
    
    
    
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>, GenericStringView<Char>> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>, GenericStringView<Char>&> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>, GenericStringView<Char>&&> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>, const GenericStringView<Char>&> {typedef GenericString<Char, Allocator> _;};
    
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>&, GenericStringView<Char>> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>&, GenericStringView<Char>&> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>&, GenericStringView<Char>&&> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>&, const GenericStringView<Char>&> {typedef GenericString<Char, Allocator> _;};
    
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>&&, GenericStringView<Char>> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>&&, GenericStringView<Char>&> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>&&, GenericStringView<Char>&&> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>&&, const GenericStringView<Char>&> {typedef GenericString<Char, Allocator> _;};
    
    template<typename Char, typename Allocator> struct CommonTypeRef<const GenericString<Char, Allocator>&, GenericStringView<Char>> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<const GenericString<Char, Allocator>&, GenericStringView<Char>&> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<const GenericString<Char, Allocator>&, GenericStringView<Char>&&> {typedef GenericString<Char, Allocator> _;};
    template<typename Char, typename Allocator> struct CommonTypeRef<const GenericString<Char, Allocator>&, const GenericStringView<Char>&> {typedef GenericString<Char, Allocator> _;};

    Кто-нибудь знает, как сократить этот комбинаторный взрыв частичных специализаций без макросов?

    gammaker, 18 Августа 2016

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

    +362

    1. 1
    http://www.crunchzilla.com/code-maven

    Визуальная новелла по манге JS

    HaskellGovno, 18 Августа 2016

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

    +267

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    //форма собственности
    	$('#sobst').change(function(){
    		var $radiouch = $('#uchred1, #uchred2');
    		var valip = 'ИП';
    		var $ip = $('#ip').attr('id');
    		var $obsch = $('.obschestvo').attr('class');
    		var $obsch2 = $('.obschestvo2').attr('class');
    		if($('option:selected', this).attr('id')==$ip){
    			$tab24.fadeOut(500);
    			$tab24.find('input[type!=button][type!=submit], select, #Opis').removeAttr('required').removeClass('err').attr('disabled','');
                $tab24.find('input[type!=button][type!=submit][type!=radio], select, #Opis').val('');
    			$radiouch.prop('checked', false);
    			$novalid.removeAttr('required');  
    		}
    		if($('option:selected', this).attr('class')==$obsch){
    			if($('#i').prop("checked")){
    				$tab24.fadeOut(500);
    				$tab24.find('input[type!=button][type!=submit], select, #Opis').removeAttr('required').removeClass('err').attr('disabled','');
                    $tab24.find('input[type!=button][type!=submit][type!=radio], select, #Opis').val('');
    				$radiouch.prop('checked', false);
                    $novalid.removeAttr('required');
    			}
    			else{
    				$tab24.fadeIn(1000);
    				$tab24.find('input[type!=button][type!=submit], select, #Opis').removeAttr('disabled').removeClass('err').attr('required','');
                    $tab24.find('input[type!=button][type!=submit][type!=radio], select, #Opis').val('');
    				$radiouch.prop('checked', false);
                    $novalid.removeAttr('required');
    			}
    		}
    		if($('option:selected', this).attr('class')==$obsch2){
    			if($('#i').prop("checked")){
    				$tab24.fadeOut(500);
    				$tab24.find('input[type!=button][type!=submit], select, #Opis').removeAttr('required').removeClass('err').attr('disabled','');
                    $tab24.find('input[type!=button][type!=submit][type!=radio], select, #Opis').val('');
    				$radiouch.prop('checked', false);
    			}
    			else{
    				$tab24.fadeIn(1000);
    				$tab24.find('input[type!=button][type!=submit], select, #Opis').removeAttr('disabled').removeClass('err').removeAttr('required','');
                    $tab24.find('input[type!=button][type!=submit][type!=radio], select, #Opis').val('');
    				$radiouch.prop('checked', false);
    			}
    		}
    	});
    	
    	//Выбор учредителя
    	$('#uchrdiv1').find("input[type='radio']").click(function(){
            var $dopuchr = $('#Familia, #Imia, #Otchestvo, #Dola');
    		var $uchr2elem = $('#uchrdiv2').find('input[type!=button][type!=submit][type!=radio], select, #Opis');
    		var $rad = $(this).attr('id');
    		if($rad==$('#uchred2').attr('id')){
    			$("#labfio").text("Форма собственности *");
    			$("#labname").text("Наименование *");
    			$("#labsur").text("УНП *");
    			$("#zagolovok").text("Наименование учредителя *");
    			$uchr2elem.removeAttr('required').removeClass('err').attr('disabled','');
    			$('#surname1').attr('required','');
                $('#uchred1').removeClass('err');
                $dopuchr.removeAttr('required');
    		}
    		else {
    			$("#labfio").text('Фамилия *');
    			$("#labname").text("Имя *");
    			$("#labsur").text("Отчество");
    			$("#zagolovok").text("Ф.И.О учредителя в именительном падеже *");
    			$uchr2elem.removeAttr('disabled').attr('required','').val('');
                $('#table2').find('input[type!=radio]').removeAttr('disabled').attr('required','');
    			$('#surname1, #pomeschenieNum3').removeAttr('required','');
                $('#uchred2').removeClass('err');
                $dopuchr.removeAttr('required');
    		}
    	});
    	
    	//Способ получения
    	$('.forms5').find("input[type='radio']").click(function(){
    		var $grd = $('#grd').find('input[id!=pomeschenieNum6], select');
    		var $ofs = $('#ofs').find('input, select');
    		var $posrad = $(this).attr('id');
    		if($posrad==$('#Ofis').attr('id')){
    			$grd.removeAttr('required').removeClass('err').attr('disabled','').val('');
    			$ofs.removeAttr('disabled').attr('required','').val('');
                $('#Viezd').removeAttr('required').removeClass('err');
                $('#Ofis').attr('required');
    		}
    		if($posrad==$('#Viezd').attr('id')){
    			$ofs.removeAttr('required').removeClass('err').attr('disabled','').val('');
    			$grd.removeAttr('disabled').attr('required','').val('');
                $('#Ofis').removeAttr('required').removeClass('err');
                $('#Viezd').attr('required');
    		}
    	});
    	
    	//кнопка submit
    	$('#otpravit').on({
            mousedown: function(){
                $(this).css('background','linear-gradient(to bottom right, #D77024, #E49656)');
            }, 
            mouseup: function(){
                $(this).css('background','linear-gradient(to bottom right, #EC841C, #EDA24E)');

    страница с формами
    название файла (ВНИМАНИЕ!): dubische_gaz

    petia, 17 Августа 2016

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

    +322

    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
    void worker(int id)
    {
        while (true) {
            std::unique_lock<std::mutex> lock(connPoolMutex);
            connPoolCond.wait(lock, [] { return !connectionsPool.empty(); });
    
            ClientConnection conn = connectionsPool.front();
            connectionsPool.pop();
            lock.unlock();
    
            TCPSocket sock(conn);
            sock.setReadTimeout(READ_TIMEOUT);
    
            char buffer[MAX_PACKET_LEN] = {};
            int sz = sock.recv(buffer, sizeof(buffer));
    
            // [...]
        }
    }
    
    // [...]
    
    int main()
    {
        // [...]
        TCPSocket server("0.0.0.0:1234");
        server.bind();
        server.listen(1000);
    
        while (true) {
            ClientConnection conn = server.accept();
    
            std::unique_lock<std::mutex> l(connPoolMutex);
            connectionsPool.push(conn);
    
            connPoolCond.notify_one();
        }
    }

    Современный, многопоточный и масштабируемый сервер на C++!

    TCPSocket - очень тонкая обёртка над голым сокетом.

    gost, 17 Августа 2016

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

    +119

    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
    <?php header('Content-Type: application/rss+xml'); ?>
    <?='<?xml version="1.0" encoding="utf-8"?>'?>
    <rss xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0">
      <channel>
        <title><![CDATA[Neon Genesis Kode]]></title>
        <link>http://govnokod.ru</link>
        <description><![CDATA[Свежие комментарии]]></description>
        <pubDate><?=date(DATE_RSS)?></pubDate>
        <language>ru-ru</language>
        <docs>http://blogs.law.harvard.edu/tech/rss</docs>
        <ttl>3600</ttl>
    <?php
    
    $curl_context = curl_init(); 
    curl_setopt($curl_context, CURLOPT_URL, 'http://146.185.130.46/ngk/api/v1/latest'); 
    curl_setopt($curl_context, CURLOPT_RETURNTRANSFER, 1); 
    $raw_data = curl_exec($curl_context); 
    curl_close($curl_context);     
    $data = JSON_decode($raw_data);
    
    foreach($data as $item) { ?>
      <item>
          <title><![CDATA[Комментарий к говнокоду #<?=$item->thread_id?>]]></title>
          <link>http://govnokod.ru/<?=$item->thread_id?>#comment<?=$item->comment_id?></link>
          <guid>http://govnokod.ru/<?=$item->thread_id?>#comment<?=$item->comment_id?></guid>
          <description><![CDATA[<?=$item->text?>]]></description>
          <pubDate><?=date(DATE_RSS, strtotime($item->posted))?></pubDate>
      </item>
    <?php } ?>
    </channel>
    </rss>

    Обычный пыхокод. Листайте дальше.

    inkanus-gray, 17 Августа 2016

    Комментарии (191)
  10. Java / Говнокод #20821

    +320

    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
    import java.io.*;
    public class word {
    	static int count = 0;
    public static void main (String[] args)throws IOException{
    	BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    	String word = reader.readLine();
    	reader.close();
    	String r = word.replaceAll("\\d|\\s|\\\\|/|\\]|\\[|\\`|\\~|\\.|\\>|\\<|\\,|\\;|\\:|\\\"|\\'|\\||\\?|\\!|\\@|\\#|\\№|\\$|\\%|\\^|\\&|\\*|\\)|\\(|\\-|\\_|\\+|\\=|\\}|\\{","");
    	char[] letters = r.toCharArray();
    	
    	for(int i = 0;i<letters.length;i++){
    		count++;
    	
    	}
    	System.out.println("Кол-во букв:" + count);
    }
    }

    программа считывает кол-во букв в слове, которое вводит юзер

    TopCodeMonkey, 17 Августа 2016

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