1. Java / Говнокод #17846

    +78

    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
    /*
         Внимание, хардкод!
         С сервера приходит время в формате 2014-09-25 00:30:00.000010+04:00
         Метод convertDate() возвращает время в формате "24:30", поэтому такой костыль
    */
    public static String getTimeFromServerDate(String input_date) {
        int start = 10;
        int end = 16;
    
        if(input_date.length()>end){
            return input_date.substring(start, end);
        }
        return null;
    }

    Не знаю кто эту хуйню писал, но мы её теперь поддерживаем =(

    pr0gl, 23 Марта 2015

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

    +162

    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
    if(isset($_POST['submit']) AND $_POST['submit'] == 'add_program')
          {
             if($this->form_validation->run('add_program') == TRUE)
             {
                // Добавляем программу обучения
                $this->Settings_model->add_program($_POST['title']);
                $id = $this->db->insert_id();
                for ($x = 0; $x < 61; $x++)
                {
                   if ($x <= 12) 
                   {
                      $title = $x;
                      $year = 1;
                   }
                   elseif ($x > 12 AND $x <= 24) 
                   {
                      if($x == 13) {$title = 1;}
                      if($x == 14) {$title = 2;}
                      if($x == 15) {$title = 3;}
                      if($x == 16) {$title = 4;}
                      if($x == 17) {$title = 5;}
                      if($x == 18) {$title = 6;}
                      if($x == 19) {$title = 7;}
                      if($x == 20) {$title = 8;}
                      if($x == 21) {$title = 9;}
                      if($x == 22) {$title = 10;}
                      if($x == 23) {$title = 11;}
                      if($x == 24) {$title = 12;}
                      $year = 2;
                   }
                   elseif ($x > 24 AND $x <= 36) 
                   {
                      if($x == 25) {$title = 1;}
                      if($x == 26) {$title = 2;}
                      if($x == 27) {$title = 3;}
                      if($x == 28) {$title = 4;}
                      if($x == 29) {$title = 5;}
                      if($x == 30) {$title = 6;}
                      if($x == 31) {$title = 7;}
                      if($x == 32) {$title = 8;}
                      if($x == 33) {$title = 9;}
                      if($x == 34) {$title = 10;}
                      if($x == 35) {$title = 11;}
                      if($x == 36) {$title = 12;}
                      $year = 3;
                   }
                   elseif ($x > 36 AND $x <= 48) 
                   {
                      if($x == 37) {$title = 1;}
                      if($x == 38) {$title = 2;}
                      if($x == 39) {$title = 3;}
                      if($x == 40) {$title = 4;}
                      if($x == 41) {$title = 5;}
                      if($x == 42) {$title = 6;}
                      if($x == 43) {$title = 7;}
                      if($x == 44) {$title = 8;}
                      if($x == 45) {$title = 9;}
                      if($x == 46) {$title = 10;}
                      if($x == 47) {$title = 11;}
                      if($x == 48) {$title = 12;}
                      $year = 4;
                   }
                   else
                   {
                      if($x == 49) {$title = 1;}
                      if($x == 50) {$title = 2;}
                      if($x == 51) {$title = 3;}
                      if($x == 52) {$title = 4;}
                      if($x == 53) {$title = 5;}
                      if($x == 54) {$title = 6;}
                      if($x == 55) {$title = 7;}
                      if($x == 56) {$title = 8;}
                      if($x == 57) {$title = 9;}
                      if($x == 58) {$title = 10;}
                      if($x == 59) {$title = 11;}
                      if($x == 60) {$title = 12;}
                      $year = 5;
                   }
                   
                   if($x != 0)
                   {
                      // Добавляем месяцы обучения
                      $this->Settings_model->add_tutorial_months($id,$year,$title);
                   }
                }

    Тяжело супортить чейто проект

    Zilot, 23 Марта 2015

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

    −406

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    Код конца 2014 года
    
        CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
        if (iOSDeviceScreenSize.height == 480)
            isRetina = true;
        else
            isRetina = false;5

    Headless, 23 Марта 2015

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

    −407

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    #define RETURN_CREATED_SGINGLETON_MUTABLE_ARRAY \
      static NSMutableArray* _singletonArray = nil; \
      static dispatch_once_t onceToken; \
      dispatch_once(&onceToken, ^{ \
        _singletonArray = [[NSMutableArray alloc] init]; \
      }); \
      return _singletonArray;

    Используется массив для хранения заданий. Эдакий самописный NSOperationQueue.

    ProFFeSSoR, 23 Марта 2015

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

    +780

    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
    public class B
    {
        private readonly List<M> ms = new List<M>(); 
    
        // ...
    
        public void Match(M m) { ms.Add(m); }
    
        public int IndexOf(M m) { return ms.IndexOf(m) == 0 ? 0 : 1; }
    
        // ...
    }
    
    public class M
    {
        // ...
    
        public void Match(B b)
        {
            try { b.Match(this); }
            catch (Exception e)
            {
                // ...
            }
        }
    
        // ...
    }

    Угадай песню по говнокоду. Сложность: 2/10.
    Можете минусовать, в общем-то.

    pushistayapodmyshka, 23 Марта 2015

    Комментарии (8)
  6. Java / Говнокод #17841

    +72

    1. 1
    2. 2
    3. 3
    4. 4
    resultWhereClause += " AND (lower(concat(per.firstName,' ',per.lastName,' ',per.middleName)) like lower(#{utils.concat(\"%\", \"" + applicant + "\", \"%\")})";
    resultWhereClause += " or lower(concat(per.lastName,' ',per.firstName,' ',per.middleName)) like lower(#{utils.concat(\"%\", \"" + applicant + "\", \"%\")})";
    resultWhereClause += " or lower(concat(per.firstName,' ',per.middleName,' ',per.lastName)) like lower(#{utils.concat(\"%\", \"" + applicant + "\", \"%\")}))";
    resultWhereClause += "))";

    Изящный хак для (на самом деле нет) для поиска по ФИО

    chsh, 23 Марта 2015

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

    +168

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $salt = 'fghjghjfhjfjhnbvmnbmvhjgfgjh785678tyutyu76678xcvbxcvb67hdfghdfgh67e657ytryerty5674567ryerty6574567tryertye75467657trhgfbvnhmhkijiluiotyiueuwyertsdrgfhndhgjdtyuerghddjghjhgjfktryudghgfhrthrtdhgfhdtyerghfghrtyer74576ytreuyytu6756yertytryet756745yhhgfnmdfgsreyyrteu676584678677795785687ytujhgfnvgsgomsjgsfguhjhgsdfujsdfgpousgjpsihsgubsfug89e6w5hisfdgbsidfgh5467woaiybvsdfghewtuhrty90w465uiregthshuaert90wuitre97gfuhfsujghhntigfjhtkh90eruheiuhfdiuhtruhghrthr9ugfgijdfngifdgijfgnsdfghwe9065hutriosgdfojdfigodfhgeiurtwhe9057yer9tud9fsoiudfshgert9y435trhgfdiuhgsdiufghidfghfffff';
    $hash = md5(sha1(md5(md5($salt . $oplata . $rnd . $summ . $time . $id . $kl . $magas . $xxtea . $salt) . $salt . $time . $id . $magas . $rnd) . $salt . $time . $id . $magas . $rnd) . $salt . $kl . $kl);
    $hash = hash('sha512', $hash);
    $hash = hash('whirlpool', $hash);
    $hash = hash('ripemd320', $hash);
    $hash = hash('haval256,5', $hash);
    $hash = hash('ripemd320', $hash);
    $hash = hash('snefru', $hash);
    $hash = hash('crc32', $hash);

    Безопаснейший и неподбираемейший хэш =)
    Оригинал тут: https://toster.ru/q/204698

    SagePtr, 23 Марта 2015

    Комментарии (137)
  8. JavaScript / Говнокод #17839

    +154

    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
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    	<title></title>
    </head>
    <body>
    
    </body>
    </html>
    
    <script>
    
    var text = "adsdmdlmf 34vfvf";
    var regex = /\s /
    if (regex != 0){
    	alert("Тут два слова")
    }
    else {
    	alert("Тут одно слово")
    }
    </script>

    Первый говнопост (задача проверить является ли текст одним словом)

    kychagovn, 22 Марта 2015

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

    +772

    1. 1
    var ecwld = (from path in args let dirs = Directory.GetDirectories(path) from dirName in dirs.Select(dir => dir.Replace(path, "").Replace("\\", "")) let files = Directory.GetFiles(path + dirName) from file in files where file.Contains(dirName + ".ecwld") select file).ToList();

    skydev, 22 Марта 2015

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

    +160

    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
    $Result = MySQL_Query("SELECT name FROM users WHERE name='$Login'") or ("Can't execute query.");
                    
    if (MySQL_Num_Rows($Result))
    {
              echo "Account <b>".$Login."</b> is exists";
    }
    ...
    elseif ((StrLen($Pass) < 4) or (StrLen($Pass) > 10)) 
    
    {
    echo "Password must have more 4 and not more 10 symbols.";
    }
    
    elseif ((StrLen($Repass) < 4) or (StrLen($Repass) > 10)) 
    {
    echo "Repeat password must have more 4 and not more 10 symbols.";
    }
    
    elseif ((StrLen($Email) < 4) or (StrLen($Email) > 25)) 
    {
    echo "Email must have more 4 and not more 25 symbols.";
    }
    
    elseif ($Pass != $Repass)
    {
    echo "Password mismatch.";
    }

    Фрагмент регистрации из кода сайта MMO игры. Видимо die забыли и в итоге вся проверка фтопку. Так же там педантично кроме проверки несовпадения введенных паролей оба проверяют на длину и содержание символов (это еще можно описать заботой о юзвере).

    Мартин, 22 Марта 2015

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