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

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

    +72

    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
    private String shutdown = "SHUTDOWN";
    
    ........
    
    // Read a set of characters from the socket
    int expected = 1024; // Cut off to avoid DoS attack
    
    <--Зачем это тут?-->
    while (expected < shutdown.length()) {
        if (random == null)
            random = new Random();
        expected += (random.nextInt() % 1024);
    }
    
    
    while (expected > 0) {
        int ch = -1;
        try {
            ch = stream.read();
        } catch (IOException e) {
            log.warn("StandardServer.await: read: ", e);
            ch = -1;
        }
        if (ch < 32)  // Control character or EOF terminates loop
            break;
        command.append((char) ch);
        expected--;
    }

    Не понимаю зачем тут while. Авторы Apache Tomcat расскажите...

    mrFoxs, 25 Ноября 2014

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

    +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
    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
    function get() {
      var a, g, d = app.vk.friend.OSS;
      1 > db.contacts.length && VK.api( "friends.get", {fields: "photo_rec,contacts"}, function ( j )
      {
        if ( j.response )
        {
          try
          {
            app.vk.friend.inited = !1;
            g = j.response.length;
            var e = [], b, f = null, m = null;
            for ( a = 0; a < g; a++ )
            {
              b = j.response[a].mobile_phone || "";
              var m = f = null, c = b.match( /\d/g );
              if ( !c || !(7 == c.length && "9" == c[0] || 10 == c.length || 11 == c.length) )
              {
                b = null;
              }
              b && 11 == c.length && (b = "bbbccccccc".replace( "a", c[0] ).replace( "b", c[1] ).replace( "b", c[2] ).replace( "b", c[3] ).replace( "c", c[4] ).replace( "c", c[5] ).replace( "c", c[6] ).replace( "c", c[7] ).replace( "c", c[8] ).replace( "c", c[9] ).replace( "c", c[10] ));
              b && 10 == c.length && (b = "bbbccccccc".replace( "b", c[0] ).replace( "b", c[1] ).replace( "b", c[2] ).replace( "c", c[3] ).replace( "c", c[4] ).replace( "c", c[5] ).replace( "c", c[6] ).replace( "c", c[7] ).replace( "c", c[8] ).replace( "c", c[9] ));
              b && (7 == c.length && "9" == c[0]) && (b = null);
              b && 10 == c.length && (f = c[0] + c[1] + c[2]);
              b && 11 == c.length && (f = c[1] + c[2] + c[3]);
              b && (e[e.length] = b);
              m = d[null != f ? 2 : 0];
              db.contacts[db.contacts.length] = {uid: j.response[a].uid, first_name: j.response[a].first_name, last_name: j.response[a].last_name, name: j.response[a].first_name + " " + j.response[a].last_name, photo: j.response[a].photo || j.response[a].photo_rec || j.response[a].photo_big, phoneOrig: j.response[a].mobile_phone || "", phone: b, mask: f, oper: m, oper_i: m == d[1] ? 2 : m != d[0] ? 1 : 0, app_status: 0}
            }
            var p, i = app.scnet.form.checkNumbers( e );
            g = i.SUBSCRIBER && i.SUBSCRIBER.length ? i.SUBSCRIBER.length : i.SUBSCRIBER ? 1 : 0;
            1 == g && (i.SUBSCRIBER = [i.SUBSCRIBER]);
            for ( a = 0; a < g; a++, p = null )
            {
              1 == i.SUBSCRIBER[a].SELF && (p = db.contacts.find( "phone", i.SUBSCRIBER[a].MSISDN )), p && (db.contacts.find( "phone", i.SUBSCRIBER[a].MSISDN ).oper = d[1], db.contacts.find( "phone", i.SUBSCRIBER[a].MSISDN ).oper_i = 2);
            }
            document.all ? setTimeout( app.vk.friend.getAppFri, 1E3 ) : document.all || app.vk.friend.getAppFri()
          }
          catch ( t )
          {}
        }
      } )
    }

    Здесь прекрасно всё, и как картины Босха можно рассматривать эту лапшу бесконечно.

    bodeaux, 19 Ноября 2014

    Комментарии (2)
  4. Assembler / Говнокод #17114

    +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
    strnstr proc
    	jrcxz @@3
    	push rdi
    	push rsi
    	mov rdi,rdx
    	mov al,[r9]
    	inc r9
    	dec r8
    @@1:
    	repne scasb
    	jne @@2
    	cmp rcx,r8
    	jb @@2
    	mov rsi,r9
    	mov rdx,rdi
    	mov r10,rcx
    	mov rcx,r8
    	repe cmpsb
    	je @@2
    	mov rcx,r10
    	mov rdi,rdx
    	jmp @@1
    @@2:
    	sete al
    	movzx rax,al
    	neg rax
    	and rax,rdi
    	pop rsi
    	pop rdi
    	ret
    @@3:
    	xor rax,rax
    	ret
    strnstr endp

    PSTR __fastcall strnstr(SIZE_T n1, const void* str1, SIZE_T n2, const void* str2);

    zhukas, 15 Ноября 2014

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

    −382

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    if (present) {
            // only if not pull down
            _isLoading = !self.refreshControl.isRefreshing;
            
            self.tableView.userInteractionEnabled = NO;
        }
        if (!present) {
            _isLoading = NO;
            
            self.tableView.userInteractionEnabled = YES;
        }

    stanislaw, 12 Ноября 2014

    Комментарии (2)
  6. Ruby / Говнокод #17095

    −82

    1. 1
    2. 2
    3. 3
    4. 4
    @old_article_purchase.old_article.warehouse_placement = '102A1'
    if @old_article_purchase.old_article.valid?
       @old_article_purchase.old_article.save   
     end

    andrejlr, 12 Ноября 2014

    Комментарии (2)
  7. Куча / Говнокод #17078

    +136

    1. 1
    2. 2
    -#location=Location
    +location=Localisation

    Прилетел коммит с обновлением французской локализации, а там такое.

    someone, 07 Ноября 2014

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

    +137

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    //Перевести строку в JSON
    #region ConvertToJson
    public static string ConvertToJson(string str)
    {
        return str.Replace(@"/", string.Empty).Replace(@"~", string.Empty).Replace(@":", string.Empty).Replace(@"{", string.Empty).Replace(@"}", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Replace("\n", string.Empty);
    }
    #endregion

    json сериализатор из строки в строку, написанный в одну строчку

    Lokich, 05 Ноября 2014

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

    +133

    1. 1
    2. 2
    3. 3
    TopPassGridBox.ItemsSource = CollectionViewSource.GetDefaultView((from t in Edit_Curent_Pass.PassFieldList
    	where Edit_Curent_Pass.PassFieldList.IndexOf(t) == 0 || Edit_Curent_Pass.PassFieldList.IndexOf(t) == 1 || Edit_Curent_Pass.PassFieldList.IndexOf(t) == 2
    	select t).ToList());

    Я так и не понял, что хотели этим сказать...

    SantePaulinum, 30 Октября 2014

    Комментарии (2)
  10. Куча / Говнокод #16977

    +142

    1. 1
    <img title="(495) 980-68-49" alt="(495) 980-68-49" src="/images/phones/9c1fc37d7d851137eca84579f7346b66">

    Защита от граба данных
    Уровень: Бог

    http://www.plan1.ru/podolsk/magazinyi/salonyi-svyazi/

    dekameron, 29 Октября 2014

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (AllowOperation(array(1,2,3,4,5,9,10,29), array(), array(), array(), -1, -1)) { 
            } else {
            	//скрывать определённые поля для дизайнера
    			$tplCommon->assign("DISPLAY_NONE", "style='display: none;'");  
            }

    В AllowOperation указываются идентификаторы групп пользователей, что забиты в БД.
    Таких AllowOperation(array(1,2,3,4,5,9,10,29). .), но с разными идентификаторами во всей системе больше 1000.

    pavel87, 27 Октября 2014

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