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

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

    +179

    1. 1
    $.datepicker.formatDate('yy-mm-dd', new Date(2007, 1 - 1, 26));

    Форматирование даты в жс. Без jQuery ясное дело не обойтись.
    If you are already using jQuery UI in your project, you can use the built-in datepicker method for formatting your date object:
    http://stackoverflow.com/a/7022296
    Раз уж неделя стековерфловочки...

    3.14159265, 01 Марта 2013

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

    +140

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    fixed (char* p = "A")
    {
        p[0] = 'B';
    }
    
    Console.WriteLine("A");

    Immutable strings

    Ccik, 24 Февраля 2013

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

    −107

    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
    - (void)viewDidLoad
    {
        [super viewDidLoad];
    	[self performSegueWithIdentifier:@"manWomanView" sender:self];
    	return;
    //40 строк кода...
            NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
    // 5 строк формируем реквест
            NSData *responseData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:nil error:&err];
    if (!responseData) {
    			NSLog(@"Connection Error: %@", [err localizedDescription]);
    		}
    		NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
    		NSLog(@"Response: %@", responseString);
    		NSString *isSucces = [AYDataFetcher isSucces:responseString];
    		if ([isSucces isEqualToString:@"success"]) {
    			NSLog(@"Signup Succes");
    				// Проверяем и записываем оплату
    			NSNumber *isPlat = [AYDataFetcher isPlat:responseString];
    				//NSLog(@"%@", isPlat);
    			NSLog(@"%@", [isPlat boolValue]?@"Paid account":@"No paid account");
    			[[NSUserDefaults standardUserDefaults] setBool:[isPlat boolValue] forKey:PLAT];
    			[[NSUserDefaults standardUserDefaults] synchronize];
    			
    			if(FALSE) // if([[MKStoreManager sharedManager] isSubscriptionActive:kMyFeatureIdentifier])
    			{
    // 80 строк кода
    			} else {
    				if (FALSE) {
    //50 строк кода......

    Клиент обратился - Приложение сделано фрилансером по имени Андрей Андреев. При переходе с одного таба на другой приложение подвисало на 5-10 секунд. Смотрим код, радуемся - все запросы к апи шлются через NSURLConnection sendSynchronousRequest, в коде куча блоков вроде if(FALSE). И это уже в релизе.

    mas_an, 21 Февраля 2013

    Комментарии (19)
  5. Куча / Говнокод #12527

    +126

    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
    ZipWith[f_, vector1_, vector2_] := Table[ f[ vector1[[i]], vector2[[i]] ], {i, Min[Length[vector1], Length[vector2]] } ]
    
    UnZip[list_] := {Map[First, list], Map[Rest, list]}
    
    Zip[vector1_, vector2_] :=  ZipWith[{#1, #2} &, vector1, vector2]
    ZipWithIndex[vector_] := Zip[vector, Range[1, Length[vector]]]
    ZipWithIndexed[f_, vector1_, vector2_] := Map[f @@ # &, Map[Flatten, Zip[vector1, ZipWithIndex[vector2]]]] 
    
    Fold2[f_, initialState_, list1_ , list2_ ] := Fold[f @@ Prepend[#2, #1] &, initialState, Zip[list1, list2]]
    
    ZipWith1[f_, {}, any_] := {}
    ZipWith1[f_, any_, {}] := {}
    ZipWith1[f_, {h1_, t1___}, {h2_, t2___}] := Prepend[ZipWith1[f, {t1}, {t2}], f[h1, h2]]; (*Extremal version, but recursion depth is 256 *)
     
    GroupByIndex[list_, indexesOfGroup_] := (UnZip[#][[1]]) & /@ Gather[ZipWithIndex[list], (And @@ Map[(MemberQ[indexesOfGroup, #]) &, {#1[[2]], #2[[2]]}]) &]

    Wolfram Mathematica

    Говногость, 01 Февраля 2013

    Комментарии (19)
  6. JavaScript / Говнокод #12491

    +149

    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
    Wreqr.Commands = (function(Wreqr){
      "use strict";
    
      return Wreqr.Handlers.extend({
        execute: function(){
          var name = arguments[0];
          var args = Array.prototype.slice.call(arguments, 1);
    
          this.getHandler(name).apply(this, args);
        }
      });
    
    })(Wreqr);

    из библиотеки которая претендует на популярность, шаблонность (в модном нынче смысле слова) и стэйт-оф-зэ-артность
    вопрос - НАХ8Я СТРОКА 6???????

    dimalev, 29 Января 2013

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

    +67

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    class IntegerUtils
    {
        public static function isInteger($value)
        {
            return preg_match('/[0-9]+/', $value);
        }
    }

    Must have класс, который должен быть у каждого в его библиотеке "велоприседов". Поистине краткий, лаконичный, гениальный. Даешь 100% говнокод!

    SunnyMagadan, 22 Января 2013

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

    −90

    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
    95. 95
    - (void)movementScreenUp
    {
        int shift;
        switch (_numberCell) {
            case 3:
                if (clickButtonGameCells.tag == 1 || clickButtonGameCells.tag == 10) {
                    shift = startPosition.y;
                    break;
                }
                if (clickButtonGameCells.tag == 2 || clickButtonGameCells.tag == 20) {
                    shift = - 50;
                    break;
                }
                if (clickButtonGameCells.tag == 3 || clickButtonGameCells.tag == 30) {
                    shift = - 90;
                    break;
                }
                
            case 4:
                if (clickButtonGameCells.tag == 1 || clickButtonGameCells.tag == 10) {
                    shift = startPosition.y;
                    break;
                }
                if (clickButtonGameCells.tag == 2 || clickButtonGameCells.tag == 20) {
                    shift = - 25;
                    break;
                }
                if (clickButtonGameCells.tag == 3 || clickButtonGameCells.tag == 30) {
                    shift = - 90;
                    break;
                }
                if (clickButtonGameCells.tag == 4 || clickButtonGameCells.tag == 40) {
                    shift = - 90;
                    break;
                }
                
            case 5:
                if (clickButtonGameCells.tag == 1 || clickButtonGameCells.tag == 10) {
                    shift = startPosition.y;
                    break;
                }
                if (clickButtonGameCells.tag == 2 || clickButtonGameCells.tag == 20) {
                    shift = - 1;
                    break;
                }
                if (clickButtonGameCells.tag == 3 || clickButtonGameCells.tag == 30) {
                    shift = - 40;
                    break;
                }
                if (clickButtonGameCells.tag == 4 || clickButtonGameCells.tag == 40) {
                    shift = - 86;
                    break;
                }
                if (clickButtonGameCells.tag == 5 || clickButtonGameCells.tag == 50) {
                    shift = - 86;
                    break;
                }
            
            case 6:
                if (clickButtonGameCells.tag == 1 || clickButtonGameCells.tag == 10) {
                    shift = startPosition.y;
                    break;
                }
                if (clickButtonGameCells.tag == 2 || clickButtonGameCells.tag == 20) {
                    shift = startPosition.y;
                    break;
                }
                if (clickButtonGameCells.tag == 3 || clickButtonGameCells.tag == 30) {
                    shift = - 2;
                    break;
                }
                if (clickButtonGameCells.tag == 4 || clickButtonGameCells.tag == 40) {
                    shift = - 52;
                    break;
                }
                if (clickButtonGameCells.tag == 5 || clickButtonGameCells.tag == 50) {
                    shift = - 105;
                    break;
                }
                if (clickButtonGameCells.tag == 6 || clickButtonGameCells.tag == 60) {
                    shift = - 105;
                    break;
                }
                
            default:
                break;
                 
        }
    
        [UIView animateWithDuration:0.25 animations:^{
            CGRect view_frame = self.frame;
            view_frame.origin = CGPointMake(self.frame.origin.x, shift);
            self.frame = view_frame;
        }];
    }

    Магия цифр

    tyler, 20 Января 2013

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

    +46

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $week['monday'] = date("d.m.Y", $week_start);
    $week['tuesday'] = date("d.m.Y", $week_start + 1 * 86400);
    $week['wednesday'] = date("d.m.Y", $week_start + 2 * 86400);
    $week['thursday'] = date("d.m.Y", $week_start + 3 * 86400);
    $week['friday'] = date("d.m.Y", $week_start + 4 * 86400);
    $week['saturday'] = date("d.m.Y", $week_start + 5 * 86400);
    $week['sunday'] = date("d.m.Y", $week_start + 6 * 86400);

    1allen, 20 Декабря 2012

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

    +37

    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
    <?php
    session_start();
    if(!empty($_SESSION['UserLogin']) or !empty($_SESSION['UserId']))
    {
      header('Location: user');
    }
    if(isset($_POST['UserName'])) 
    { 
      $UserName = $_POST['UserName']; 
      if($UserName == '') 
      {
       unset($UserName);
      } 
    }
    if(isset($_POST['UserEmail'])) 
    { 
      $UserEmail = $_POST['UserEmail']; 
      if($UserEmail == '') 
      {
       unset($UserEmail);
      } 
    } 
    if(isset($_POST['UserLogin'])) 
    { 
      $UserLogin = $_POST['UserLogin']; 
      if($UserLogin == '') 
      {
       unset($UserLogin);
      } 
    }
    if(isset($_POST['UserPassword'])) 
    { 
      $UserPassword = $_POST['UserPassword']; 
      if($UserPassword == '') 
      {
       unset($UserPassword);
      } 
    }
    if (empty($UserName) or empty($UserEmail) or empty($UserLogin) or empty($UserPassword))
    {
     header('Location: registration?error_code=1');
    }
    else
    {
      include("application/db.config.php");
      $UserLogin = stripslashes($UserLogin);
      $UserLogin = htmlspecialchars($UserLogin);
      $UserLogin = trim($UserLogin);
      $UserPassword = stripslashes($UserPassword);
      $UserPassword = htmlspecialchars($UserPassword);
      $UserPassword = trim($UserPassword);
      $SelectQuery = mysql_query("SELECT id FROM Users WHERE UserLogin ='$UserLogin'", $db);
      $QueryResult = mysql_fetch_array($SelectQuery);
      if(!empty($QueryResult['id']))
      {
        header('Location: registration?error_code=2');
      }
      else
      {
        $InsertQuery = mysql_query("INSERT INTO Users(UserName, UserSName, UserLogin, UserPassword, UserEmail, 
        UserPhone, UserStatus) VALUES('$UserName', 'Фамилия не указана', '$UserLogin', '$UserPassword', '$UserEmail', 'Телефон не указан', 'Статус не указан')");
        if($InsertQuery == true)
        {
          header("Location: action_status?reg_code=good&UserLogin=$UserLogin&UserPassword=$UserPassword");
        }
        else
        {
          header('Location: registration?error_code=3'); 
        }
      }
      
    }
    ?>

    Извержение.

    Govnisti_Diavol, 04 Декабря 2012

    Комментарии (19)
  11. Куча / Говнокод #12075

    +119

    1. 1
    2. 2
    3. 3
    4. 4
    data Fuuu = Fuuu
    instance Eq Fuuu
     
    main = print $ if Fuuu == Fuuu then "I dosen't seen this" else "and this"

    Вот за что мне нравится сверх надежный высокоуровневый хаскель, так за то, что если забыл переопределить какой-то метод или оператор из класа типов (в нормальных языках это интерфейс или один из базовых класов) стандартной библиотеки языка или неподходящим образом от него отнаследовался, то мы получаем надежное поведение:
    http://ideone.com/6faPct
    результат: Ошибка выполнения время: 0.01s память: 3580 kB сигнал: -1
    ввод: нет
    вывод: нет
    stderr:
    prog: <<loop>>

    HaskellGovno, 07 Ноября 2012

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