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

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

    +63

    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
    function projects_action($action)
    {
    	switch ($action) {
    		 case '1': return 'Создал проект'; break;
    		 case '2': return 'Изменил название'; break;
    		 case '3': return 'Изменил бюджет'; break;
    		 case '4': return 'Изменил дату добавления'; break;
    		 case '5': return 'Изменил дату окончания'; break;
    		 case '6': return 'Изменил приоритет'; break;
    		 case '7': return 'Изменил язык'; break;
    		 case '8': return 'Сменил клиента'; break
    
                     # …
    
    		 case '32': return 'Изменил схему'; break;
    		 default: return;
    	}
    }

    smileart, 20 Сентября 2012

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

    +141

    1. 1
    2. 2
    3. 3
    4. 4
    'constraints' => array(
                            'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                            'id'     => '[0-9]+',
                        ),

    И опять регулярки, но уже на уровне гигантов...
    http://framework.zend.com/manual/2.0/en/user-guide/routing-and-controllers.html

    1_and_0, 07 Сентября 2012

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

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    var temp = new Date(),
        diff = parseInt(($('#calrlimit1').data('datebox').theDate - temp) / ( 1000 * 60 * 60 * 24 ));
        diffstrt = (diff * -1)-1; // If you want a minimum of 1 day between, make this -2 instead of -1
        diffend = diff + 11; // Why 11 instead of 10?  No idea...

    Документация к плагину jQuery Mobile DateBox2

    UnnamedUser, 30 Августа 2012

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

    +125

    1. 1
    sed -e 's/^/;;/g;s/$/ /g' -e :a -e '1!x;1h;s/.*\(.\)$/\1/;p;x;s/\(.*\).$/\1/;h;ta' ~/src/find_world.sh |  sed -e :a -e 'N;s/\n//g;ba' | sed -e 's/;;/\n/g' -e 's/^[ ]*//g'

    rev

    AliceGoth, 20 Августа 2012

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

    +71

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    // *** Функция truncation - округление числа до сотых ***
    // ******************************************************
    function truncation($number)
    {
    	global $n;
    	$n = strpos($number,'.');
    	if ($n > 0) {$n = substr($number,0,$n).substr($number,$n,3);} else {$n = $number;}
    	return;
    }

    Комментарии излишни

    UnnamedUser, 16 Августа 2012

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

    +134

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    private string GetNextDishCode()
    {
        string[] vesCode = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
        for (int i = 0; i < vesCode.Length; i++)
            if (!CheckDishes(vesCode[i]))
                return vesCode[i];
        return "AA";
    }

    В одном, довольно крупном и дорогом проекте.

    minuzZ, 15 Августа 2012

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

    +122

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    Уважаемые знатоки, вопрос такой:
    sizeof('a') для  С и Сpp имеет различное значение и это вам известно из 
    C99 Standard: 6.4.4.4 Character constants  Para 2
    и
    C++03 Standard: 2.13.2 Character literals Para 1. 
    
    Интересует ваше предположение/мнение/версия/etc, для чего такое приняли?

    Стандартоособенности и внезапнонесовместимости.

    sayidandrtfm, 15 Июля 2012

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

    +67

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if ($_GET['search'] == ' Поиск' || $_GET['search'] == 'Поиск') {
    	$_GET['search'] = '';
    }
    if ($_GET['date'] == ' Дата' || $_GET['date'] == 'Дата') {
    	$_GET['date'] = '';
    } else {
    	$_GET['date'] = preg_replace('/(\d+).(\d+).(\d+)/i','$3-$2-$1', $_GET['date']);
    }

    Уж не знаю, что и сказать... А вдруг перед текстом попадутся 2 пробела? Или 3?

    domaster, 02 Июля 2012

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

    −92

    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
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    	
        self.view.frame=CGRectMake(10,10, 300, 200);
        
    	return 3;
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    	
    	static NSString *CellIdentifier = @"Cell";
        
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        }
        
        // Configure the cell...
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        switch (indexPath.row) {
            case 0:
                //ToDo: Add UserInfo's view into TableView
                [cell.contentView addSubview:upperView];
                break;
            case 1:{
                //Remove preous view/tableview
                for (id vw in cell.contentView.subviews) {
                    if ([vw isKindOfClass:[UITableView class]]) {
                        [vw removeFromSuperview];
                    }
                }
                //
                
                //Add View which contain tableview
                 EditListViewController *editlistvw=[[EditListViewController alloc] initWithNibName:@"EditListViewController" bundle:nil]  ;
                
                editlistvw.view.frame=CGRectMake(10, 10, 300, 20);
                
                [cell.contentView addSubview:editlistvw.tableView];
                //
                break;
            }
            case 2:
                //Remove previous view/tableview
                for (id vw in cell.contentView.subviews) {
                    if ([vw isKindOfClass:[UITableView class]]) {
                        [vw removeFromSuperview];
                    }
                }
                break;
            default:
                break;
        }
        return cell;
    }

    Творение индийского джуниора, совместно с которым приходится делать проект

    GLvRzZZ, 29 Июня 2012

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

    +137

    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
    public class Problem33 {
        public static void main(String arg[]){
            long l1 = Calendar.getInstance().getTimeInMillis();
            int amount = 0;
            for(int a=1; a<=9; a++){
                for(int b=1; b<=9; b++){
                    for(int c=1; c<=9; c++){
                        for(int d=1; d<=9; d++){
                            int numerator = a*10+b;
                            int denominator = c*10+d;
                            double fraction = 1.0*numerator/denominator;
                            if(numerator < denominator){
                                if(
                                  (a==c && (1.0*b/d == fraction)) ||
                                  (a==d && (1.0*b/c == fraction)) ||
                                  (b==c && (1.0*a/d == fraction)) ||
                                  (b==d && (1.0*a/c == fraction))
                                  ){
                                    amount++;
                                    System.out.println(a + "" +  b + "/" + c + "" + d);
                                 }
                            }
                        }
                    }
                }
            }
            System.out.println(amount);
            long l2 = Calendar.getInstance().getTimeInMillis();
            System.out.println("Time: " + (l2-l1) + "ms");
        }
    }

    http://projecteuler.net/problem=33
    http://projecteuler.net/thread=33

    TheHamstertamer, 24 Июня 2012

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