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

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

    −86

    1. 1
    movie_data["genres"][i]["ru"].lower().encode("utf-8").decode("utf-8")

    Хм...

    Yurik, 08 Июля 2012

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

    +118

    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
    private String compileOwnerName() {
    		return Joiner.on(' ').skipNulls().
    		String firstName = ownerFirstName.getValue();
    		String lastName = ownerLastName.getValue();
    		
    		final StringBuilder buffer = new StringBuilder();
    		boolean first = true;
    		
    		if (firstName != null) {
    			firstName = firstName.trim();
    			
    			if (!"".equals(firstName)) {
    				buffer.append(firstName);
    				first = false;
    			}
    		}
    
    		if (lastName != null) {
    			lastName = lastName.trim();
    			
    			if (!"".equals(lastName)) {
    				if (!first) {
    					buffer.append(" ");
    				}
    				
    				buffer.append(lastName);
    			}
    		}
    		
    		return buffer.toString();
    	}

    В итоге заменено однострочником на Perl:

    return Joiner.on(' ').skipNulls().join(Strings.emptyToNull(ownerFirstName.getValue().trim()),
    ownerLastName.getValue().trim()));

    someone, 05 Июля 2012

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

    −194

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    function new_object($data) {
    
    	foreach($data as $key=>$item)
    		$array[$key] = $item;
    
    	return $this->db->insert('objects',$array);
    }

    Snickers, 01 Июля 2012

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    WORD StrLen(PChar s)
    {
    	ASSERT(s!=NULL);
    	int i;
    	for (i=0; ( (*(s+i)!=0) && (i<=WORDMAX) ); i++) {};
    	ASSERT(i<=WORDMAX);
    	return (WORD)i;
    };

    По заявкам из http://govnokod.ru/11318

    Говногость, 29 Июня 2012

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

    +62

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function find( &$db, $id) {
    		$statement = Contact::findStatement() . " WHERE id = $id";
    		$dbResult = ActiveRecord::abstractFind( $db, $statement);
    		foreach ($dbResult as $dbRow) {
    			return Contact::load( $db, $dbRow);
    		}
    		return null;
    	}

    shmaltorhbooks, 26 Июня 2012

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

    −155

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    override public function execute():void
    {
    	var maintainProductAttributePresenter:ITableBasedPresentrer = this.appPresenter.maintainProductAttributePresenter;
    	var maintainProductAttributeView:View = maintainProductAttributePresenter.view;
    
    	this.appView.showModuleView(maintainProductAttributeView);
    	this.appView.showModuleHeader(maintainProductAttributePresenter.getModuleTitle());
    
    	maintainProductAttributePresenter.updateData();
    }

    Сижу, копипазжу... Специально не стала выбиваться из стандарта... Может хоть на секунду мысль о том что мы занимаемся маразмом кому нибудь в голову придет?

    kyzi007, 25 Июня 2012

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

    −93

    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
    # -*- coding: utf-8 -*-
    from django.db import models
    
    # Create your models here.
    
    class SheduleItem(models.Model):
      WIKDI = (
        ('monday', 'Понедельник'),
        ('tuesday', 'Вторник'),
        ('wednesday', 'Среда'),
        ('thursday', 'Четверг'),
        ('friday', 'Пятница'),
        ('saturday', 'Суббота'),
        ('sunday', 'Воскресенье'),
      )
      TAIM = (
        ('08:00', '08:00'),
        ('09:00', '09:00'),
        ('10:00', '10:00'),
        ('11:00', '11:00'),
        ('12:00', '12:00'),
        ('13:00', '13:00'),
        ('14:00', '14:00'),
        ('15:00', '15:00'),
        ('16:00', '16:00'),
        ('17:00', '17:00'),
        ('18:00', '18:00'),
        ('19:00', '19:00'),
        ('20:00', '20:00'),
        ('21:00', '21:00'),
      )
      weekday = models.CharField(max_length=20, choices=WIKDI)
      time = models.CharField(max_length=6, choices=TAIM)
      action = models.CharField(max_length=30)
      trainer = models.ForeignKey('trainers.StrongTrainer')
    
      def __unicode__(self):
        return self.action

    Django-модель для таблицы расписания занятий. Выдавлено в 2 часа ночи под Сержа Танкяна.

    fat0troll, 24 Июня 2012

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

    +50

    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
    <?php
     require('url_to_absolute.php');
    ini_set('display_errors','On');
    error_reporting('E_ALL');
    $ext=array(
    'pictures'=>array('bmp','jpg','jpeg','pgm','rgb','tga','png','gif','ico'),
    'docs'=>array('rtf','doc','docx','pdf','txt'),
    'html'=>array('shtml','html','xml','css','htm','xhtml'),
    'audio'=>array('mp3','mp4','mpeg','flv','3gp','webm'),
    'arch'=>array('zip','rar','gz','bz2','tar','7zip','ar','tar\.gz','tar\.bz2','xz'),
    'pack'=>array('deb','rpm','jar'),
    'scripts'=>array('sh','pl','py','php','js')
    );
    $murl="";
    $sext="";
    $routh='|((?<=[" ])[^" ]+/[a-z0-9-_%.]+\.';
    foreach($ext as $sk=>$sval){
    foreach($sval as $exts){
      $routh.='(?!'.$exts.'")';
    }
    }
    $routh.='[a-z0-9]{1,5}(?=[" ]))|i';
    echo $routh."<br\ >";
    if(isset($_GET['url'])){
    $url=$_GET['url'];echo $url."<br>";
    preg_match('|(ftp)?(http)?(?:s)?://[a-z0-9-]+\.[a-z]+(\.[a-z0-9-_&+?=%]+)*(?::[0-9]+)?|i',$url,$ures);
    if(!empty($ures[0])){echo $ures[0];$murl=$ures[0];echo "<br>murl ".$murl."<br> ";}
    $html=file_get_contents($url);
    
    foreach($ext as $key=>$val){
    echo "<h2>$key</h2><br\>";
    foreach($val as $mext){
    echo "$mext<br>";
    preg_match_all('|((/[.a-z0-9_-]*)*/[a-z0-9-_.%]+\.'.$mext.'(?![a-z])(?!/))|i',$html,$result);
      if(!empty($result)){
      if(!empty($result[0])){
        $result[0]=array_unique($result[0]);
      foreach($result[0] as $vres){
        $aurl=url_to_absolute($url,$vres);
        echo("<a href=\"$aurl\">".$aurl."</a> ");}
    }
    }
    preg_match_all('|((http(?:s)?://)[a-z0-9-]+\.[a-z]+(?:\.[a-z0-9-_&+?=%]+)*(?::[0-9]+)?(?:/[a-z0-9_-.]*)/[.a-z0-9-_%]+\.'.$mext.'(?![a-z])(?!/))|i',$html,$result);
    if(!empty($result)){
    if(!empty($result[0])){
      $result[0]=array_unique($result[0]);
      foreach($result[0] as $vres){
        $aurl=url_to_absolute($url,$vres);
    echo("<a href=\"$aurl\">".$aurl."</a> ");}
    }
    }
    preg_match_all('|((?<=[" ])[^" ]+\.'.$mext.'(?=[" ]))|i',$html,$result);
    if(!empty($result)){
    if(!empty($result[0])){
    $result[0]=array_unique($result[0]);
    foreach($result[0] as $vres){
        $aurl=url_to_absolute($url,$vres);
    echo("<a href=\"$aurl\">".$aurl."</a> ");}
    }
    }
    
    }
    }
    preg_match_all($routh,$html,$result);
    if(!empty($result)){
    if(!empty($result[0])){
    $result[0]=array_unique($result[0]);
    echo "<br><h2>Other documents</h2><br>";
    foreach($result[0] as $vres){
        $aurl=url_to_absolute($url,$vres);
    echo("<a href=\"$aurl\">".$aurl."</a><br \> ");
    }
    }
    }
    } else { printf("No url\n");}
    ?>

    Вытягивает ссылки на картинки с html файла

    AliceGoth, 21 Июня 2012

    Комментарии (6)
  10. Pascal / Говнокод #11228

    +110

    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
    if (M[1]<>M[2]) and (M[1]<>M[3]) and (M[1]<>M[4]) and (M[1]<>M[5]) and (M[1]<>M[6]) then
    begin
    if (M[1]<>M[7]) and (M[1]<>M[8]) and (M[1]<>M[9]) and (M[1]<>M[10]) then
    write('  ',M[1],'  ');
    end;
     
    if (M[2]<>M[1]) and (M[2]<>M[3]) and (M[2]<>M[4]) and (M[2]<>M[5]) and (M[2]<>M[6]) then
    begin
    if (M[2]<>M[7]) and (M[2]<>M[8]) and (M[2]<>M[9]) and (M[2]<>M[10]) then
    write('  ',M[2],'  ');
    end;
     
    if (M[3]<>M[1]) and (M[3]<>M[2]) and (M[3]<>M[4]) and (M[3]<>M[5]) and (M[3]<>M[6]) then
    begin
    if (M[3]<>M[7]) and (M[3]<>M[8]) and (M[3]<>M[9]) and (M[3]<>M[10]) then
    write('  ',M[3],'  ');
    end;
     
    if (M[4]<>M[1]) and (M[4]<>M[2]) and (M[4]<>M[3]) and (M[4]<>M[5]) and (M[4]<>M[6]) then
    begin
    if (M[4]<>M[7]) and (M[4]<>M[8]) and (M[4]<>M[9]) and (M[4]<>M[10]) then
    write('  ',M[4],'  ');
    end;
     
    if (M[5]<>M[1]) and (M[5]<>M[2]) and (M[5]<>M[3]) and (M[5]<>M[4]) and (M[5]<>M[6]) then
    begin
    if (M[5]<>M[7]) and (M[5]<>M[8]) and (M[5]<>M[9]) and (M[5]<>M[10]) then
    write('  ',M[5],'  ');
    end;
     
    if (M[6]<>M[1]) and (M[6]<>M[2]) and (M[6]<>M[3]) and (M[6]<>M[4]) and (M[6]<>M[5]) then
    begin
    if (M[6]<>M[7]) and (M[6]<>M[8]) and (M[6]<>M[9]) and (M[6]<>M[10]) then
    write('  ',M[6],'  ');
    end;
     
    if (M[7]<>M[1]) and (M[7]<>M[2]) and (M[7]<>M[3]) and (M[7]<>M[4]) and (M[7]<>M[5]) then
    begin
    if (M[7]<>M[6]) and (M[7]<>M[8]) and (M[7]<>M[9]) and (M[7]<>M[10]) then
    write('  ',M[7],'  ');
    end;
    readln;
     
    if (M[8]<>M[1]) and (M[8]<>M[2]) and (M[8]<>M[3]) and (M[8]<>M[4]) and (M[8]<>M[5]) then
    begin
    if (M[8]<>M[6]) and (M[8]<>M[7]) and (M[8]<>M[9]) and (M[8]<>M[10]) then
    write('  ',M[8],'  ');
    end;
     
    if (M[9]<>M[1]) and (M[9]<>M[2]) and (M[9]<>M[3]) and (M[9]<>M[4]) and (M[9]<>M[5]) then
    begin
    if (M[9]<>M[6]) and (M[9]<>M[7]) and (M[9]<>M[8]) and (M[8]<>M[10]) then
    write('  ',M[9],'  ');
    end;
     
    if (M[10]<>M[1]) and (M[10]<>M[2]) and (M[10]<>M[3]) and (M[10]<>M[4]) and (M[10]<>M[5]) then
    begin
    if (M[10]<>M[6]) and (M[10]<>M[7]) and (M[10]<>M[8]) and (M[10]<>M[9]) then
    write('  ',M[10],'  ');
    end;

    Циклы? Не, не слышал...

    HighPredator, 19 Июня 2012

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

    +67

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <?if($metaid == 16 || $metaid == 44 || $metaid == 52 || $metaid == 60 || $metaid == 90 ||
     $metaid == 132 || $metaid == 136 || $metaid == 174 || $metaid == 192 || $metaid == 196 || 
    $metaid == 238 || $metaid == 388 || $metaid == 462 || $metaid == 470 || $metaid == 480 || 
    $metaid == 500 || $metaid == 530 || $metaid == 533 || $metaid == 548 || $metaid == 580 || 
    $metaid == 584 || $metaid == 662 || $metaid == 666 || $metaid == 678 || $metaid == 690 || 
    $metaid == 772 || $metaid == 780 || $metaid == 833){?>на<?} else if($metaid == 250 || 
    $metaid == 254 || $metaid == 258 || $metaid == 704){?>во<?}else{?>в<?}?>

    Одно из пятнадцати подобных условий в файле. Было написано в одну строку, поэтому тело условия увидели не сразу. Разнес по строкам для удобства чтения.

    kreksoverzum, 15 Июня 2012

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