1. Куча / Говнокод #16828

    +132

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    @font-face {
        font-family: 'MyWebFont';
        src: url('webfont.eot#') format('eot'),
             url('webfont.woff') format('woff');
    }

    Если в «src» поместить больше одного формата шрифта, то IE не сможет загрузить его и сообщит об ошибке 404. Причина в том, что IE пытается использовать как адрес файла всё, что записано после первой открывающей скобки и до самой последней закрывающей скобки.

    IE как всегда в своём стиле...

    bormand, 09 Октября 2014

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

    +158

    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
    function country_code_to_country( $code ){
        $country = '';
        if( $code == 'AF' ) $country = 'Afghanistan';
        if( $code == 'AX' ) $country = 'Aland Islands';
        if( $code == 'AL' ) $country = 'Albania';
        if( $code == 'DZ' ) $country = 'Algeria';
        if( $code == 'AS' ) $country = 'American Samoa';
        if( $code == 'AD' ) $country = 'Andorra';
        if( $code == 'AO' ) $country = 'Angola';
        if( $code == 'AI' ) $country = 'Anguilla';
        if( $code == 'AQ' ) $country = 'Antarctica';
        if( $code == 'AG' ) $country = 'Antigua and Barbuda';
        if( $code == 'AR' ) $country = 'Argentina';
        if( $code == 'AM' ) $country = 'Armenia';
        if( $code == 'AW' ) $country = 'Aruba';
        if( $code == 'AU' ) $country = 'Australia';
        if( $code == 'AT' ) $country = 'Austria';
        if( $code == 'AZ' ) $country = 'Azerbaijan';
        if( $code == 'BS' ) $country = 'Bahamas the';
        if( $code == 'BH' ) $country = 'Bahrain';
        if( $code == 'BD' ) $country = 'Bangladesh';
        if( $code == 'BB' ) $country = 'Barbados';
        if( $code == 'BY' ) $country = 'Belarus';
        if( $code == 'BE' ) $country = 'Belgium';
        if( $code == 'BZ' ) $country = 'Belize';
        if( $code == 'BJ' ) $country = 'Benin';
        if( $code == 'BM' ) $country = 'Bermuda';
        if( $code == 'BT' ) $country = 'Bhutan';
        if( $code == 'BO' ) $country = 'Bolivia';
        if( $code == 'BA' ) $country = 'Bosnia and Herzegovina';
        if( $code == 'BW' ) $country = 'Botswana';
        if( $code == 'BV' ) $country = 'Bouvet Island (Bouvetoya)';
        if( $code == 'BR' ) $country = 'Brazil';
        if( $code == 'IO' ) $country = 'British Indian Ocean Territory (Chagos Archipelago)';
        if( $code == 'VG' ) $country = 'British Virgin Islands';
        if( $code == 'BN' ) $country = 'Brunei Darussalam';
        if( $code == 'BG' ) $country = 'Bulgaria';
        if( $code == 'BF' ) $country = 'Burkina Faso';
        if( $code == 'BI' ) $country = 'Burundi';
        if( $code == 'KH' ) $country = 'Cambodia';
        if( $code == 'CM' ) $country = 'Cameroon';
        if( $code == 'CA' ) $country = 'Canada';
        if( $code == 'CV' ) $country = 'Cape Verde';
        if( $code == 'KY' ) $country = 'Cayman Islands';
        if( $code == 'CF' ) $country = 'Central African Republic';
        if( $code == 'TD' ) $country = 'Chad';
        if( $code == 'CL' ) $country = 'Chile';
        if( $code == 'CN' ) $country = 'China';
        if( $code == 'CX' ) $country = 'Christmas Island';
        if( $code == 'CC' ) $country = 'Cocos (Keeling) Islands';
        if( $code == 'CO' ) $country = 'Colombia';
        if( $code == 'KM' ) $country = 'Comoros the';
        if( $code == 'CD' ) $country = 'Congo';
        if( $code == 'CG' ) $country = 'Congo the';
        if( $code == 'CK' ) $country = 'Cook Islands';
        if( $code == 'CR' ) $country = 'Costa Rica';
        if( $code == 'CI' ) $country = 'Cote d\'Ivoire';
        if( $code == 'HR' ) $country = 'Croatia';
        if( $code == 'CU' ) $country = 'Cuba';
        if( $code == 'CY' ) $country = 'Cyprus';
        if( $code == 'CZ' ) $country = 'Czech Republic';
        if( $code == 'DK' ) $country = 'Denmark';
        if( $code == 'DJ' ) $country = 'Djibouti';
        if( $code == 'DM' ) $country = 'Dominica';
        if( $code == 'DO' ) $country = 'Dominican Republic';
        if( $code == 'EC' ) $country = 'Ecuador';
        if( $code == 'EG' ) $country = 'Egypt';
        if( $code == 'SV' ) $country = 'El Salvador';
        if( $code == 'GQ' ) $country = 'Equatorial Guinea';
        if( $code == 'ER' ) $country = 'Eritrea';
        if( $code == 'EE' ) $country = 'Estonia';
        if( $code == 'ET' ) $country = 'Ethiopia';
        if( $code == 'FO' ) $country = 'Faroe Islands';
        if( $code == 'FK' ) $country = 'Falkland Islands (Malvinas)';
        if( $code == 'FJ' ) $country = 'Fiji the Fiji Islands';
        if( $code == 'FI' ) $country = 'Finland';
        if( $code == 'FR' ) $country = 'France, French Republic';
        if( $code == 'GF' ) $country = 'French Guiana';
        if( $code == 'PF' ) $country = 'French Polynesia';
        ----------------------------------------------------------------
        if( $code == 'VE' ) $country = 'Venezuela';
        if( $code == 'VN' ) $country = 'Vietnam';
        if( $code == 'WF' ) $country = 'Wallis and Futuna';
        if( $code == 'EH' ) $country = 'Western Sahara';
        if( $code == 'YE' ) $country = 'Yemen';
        if( $code == 'ZM' ) $country = 'Zambia';
        if( $code == 'ZW' ) $country = 'Zimbabwe';
        if( $country == '') $country = $code;
        return $country;
    }

    Кто-то очень много старался

    win32, 08 Октября 2014

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

    +140

    1. 1
    (𝓹𝓻𝓲𝓷𝓽 "𝓗𝓮𝓵𝓵𝓸, 𝓦𝓸𝓻𝓵𝓭!")

    В продолжение темы юникода. К сожалению, крестокомпилятор не захотел кушать эти символы, а в других языках нет препроцессора. Поэтому пришлось на лиспе.

    http://ideone.com/14yidz

    bormand, 08 Октября 2014

    Комментарии (54)
  4. Perl / Говнокод #16825

    −165

    1. 1
    our @hilight_critical_files = ( 'celebrities.txt', 'obscene.txt', 'lekarstva.txt' );

    Глобальная переменная, неверно написанное английское слово, захардкоженные значения, транслит, транслит вперемешку с английскими словами<s>, и вообще perl</s>.

    И всё это в одной короткой строке.

    kainwinterheart, 08 Октября 2014

    Комментарии (5)
  5. Java / Говнокод #16824

    +83

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    TextView v = (TextView)
                            ((RelativeLayout)
                                ((AbsoluteLayout)
                                    ((LinearLayout)
                                        ((RelativeLayout)(
                                            (LinearLayout)activty.findViewById(R.id.container)).getChildAt(1))
                                        .getChildAt(0))
                                    .getChildAt(element))
                                .getChildAt(0))
                            .getChildAt(0);

    (Android)

    когда нет idшников...

    danpetruk, 08 Октября 2014

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

    −405

    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
    float scaleFactor = param1/172;
            if (scaleFactor < -1)
            {
                scaleFactor = -1;
            }
            _releaseTheKraken.transform = CGAffineTransformMakeScale(-scaleFactor,-scaleFactor);
            float krakenPosition = param1/2.4571;
            
            if (param1<-172)
            {
                krakenPosition = -70 + 172 + param1;
                _activityIndicator.center = CGPointMake(25, param1+15);
            }
            _releaseTheKraken.center = CGPointMake(147.5, krakenPosition);
            if (param1<-100)
            {
                float param2 = (-param1 - 100)/7.5;
                int param3 = floor(param2);
                if (param3<10)
                {...

    soprof, 08 Октября 2014

    Комментарии (11)
  7. Си / Говнокод #16822

    +136

    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
    DIR_STRUCT * fill_dir_struct(DIR_STRUCT * dir_stc, _ptr_by_val_(char *) base_dir_path, _ptr_by_val_(char *) offset_dir)
    {
    	DIR_STRUCT * 		sub_dir;
    	DIR * 				srcdir;
    	struct 				stat st;
    	char 				full_sub_dir_path[MAX_PATH_SIZE];
    	struct dirent * 	dent;
    
    	sprintf(full_sub_dir_path, "%s/%s", base_dir_path, offset_dir);
    	dbgprintln("Directory %s", full_sub_dir_path);
    
    	if(NULL != (dir_stc = malloc(sizeof(DIR_STRUCT))))
    	{
    		memset(dir_stc, 0x00, sizeof(DIR_STRUCT));
    		if (NULL != (srcdir = opendir(full_sub_dir_path)))
    		{
    			if(NULL != (dir_stc->dir_path = malloc(strlen(offset_dir) + 1)))
    			{
    				strcpy(dir_stc->dir_path, offset_dir);
    				for( ;(NULL != (dent = readdir(srcdir))); )
    				{
    					if((0 != strcmp(dent->d_name, ".")) &&
    					   (0 != strcmp(dent->d_name, "..")) &&
    					   (0 <= fstatat(dirfd(srcdir), dent->d_name, &st, 0)))
    					{
    						if (S_ISDIR(st.st_mode)) //Directory
    						{
    							if(NULL != (sub_dir = fill_dir_struct(sub_dir, full_sub_dir_path, dent->d_name)))
    							{
    								dir_stc->sub_dirs 		 	  = list_append_node(dir_stc->sub_dirs, sub_dir);
    								dir_stc->dir_files_size 	 += sub_dir->dir_files_size;
    								dir_stc->sub_dir_files_count += sub_dir->sub_dir_files_count;
    							}
    							else
    							{
    								dir_stc = destroy_dir_struct(dir_stc);
    								break;
    							}
    						}
    						else 					//File
    						{
    							dbgprintln("File %s, size %lu bytes", dent->d_name, st.st_size);
    							dir_stc->dir_files 		 	 = list_append_node(dir_stc->dir_files, allocate_and_copy_char_buffer(dent->d_name, strlen(dent->d_name) + 1));
    							dir_stc->dir_files_size 	+= st.st_size;
    							dir_stc->sub_dir_files_count++;
    						}
    					}
    				}//End of for(;NULL != (dent = readdir(srcdir)); )
    				closedir(srcdir);
    			}
    			else//End of if(NULL != (dir_stc->dir_path = malloc(strlen(offset_dir) + 1)))
    			{
    				dir_stc = destroy_dir_struct(dir_stc);
    			}
    		}//End of if (NULL != (srcdir = opendir(full_sub_dir_path)))
    		else
    		{
    			dir_stc = destroy_dir_struct(dir_stc);
    		}
    	}//End of if(NULL != (dir_stc = malloc(sizeof(DIR_STRUCT))))
    
    	return dir_stc;
    }

    Восьмикратный индент, Йода нотейшн, const *(x) const в аргументах. Есть подозрение, что велосипедисты не знали о scandir.

    Это кладезь говна.

    codemonkey, 08 Октября 2014

    Комментарии (33)
  8. Си / Говнокод #16821

    +138

    1. 1
    if ((NULL != (string_array = (0 == *length) ? malloc((*length + 1) * REG_SIZE) : realloc(string_array, (*length + 1) * REG_SIZE))))

    А кому-то это говно меинтейнить надо будет...

    codemonkey, 08 Октября 2014

    Комментарии (9)
  9. Lua / Говнокод #16820

    −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
    function SAEController:GetPointVariableValue(WayNet,CurPoint)
      local waypointVars = {};
      for i = 0, WayNet:GetPointsCount() - 1 do
         local Link = WayNet:GetPoint(i);
        local PlaySound1 = Link:GetVariableValue("PlaySound1");
        local PlaySound2 = Link:GetVariableValue("PlaySound2");
        local PlaySound3 = Link:GetVariableValue("PlaySound3");
        
        local Effect1 = Link:GetVariableValue("Effect1");
        local Effect2 = Link:GetVariableValue("Effect2");
        local Effect3 = Link:GetVariableValue("Effect3");
        
        if PlaySound1 and CurPoint == Link then
          waypointVars.PlaySound1 = PlaySound1;  
        end;
        if PlaySound2 and CurPoint == Link then
          waypointVars.PlaySound2 = PlaySound2;  
        end;
        if PlaySound3 and CurPoint == Link then
          waypointVars.PlaySound3 = PlaySound3;  
        end;
        
        if Effect1 and CurPoint == Link then
          waypointVars.Effect1 = Effect1;  
        end;
        if Effect2 and CurPoint == Link then
          waypointVars.Effect2 = Effect2;  
        end;
        if Effect3 and CurPoint == Link then
          waypointVars.Effect3 = Effect3;  
        end;
      end;
      return waypointVars;
    end;

    Кусок игровой логики на Lua. Функция проверяет значение переменных в текущей точке пути моба.
    Мы перебираем все точки пути и сравниваем с текущей точкой моба, но это не нужно, так как именно текущая точка в функцию и передаётся!

    hdkeeper, 08 Октября 2014

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

    −120

    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
    CREATE TABLE `numbers` (
      `number` BIGINT(20) DEFAULT NULL
    ) ENGINE=InnoDB;
    
    CREATE TABLE `numbers_small` (
      `number` INT(11) DEFAULT NULL
    ) ENGINE=InnoDB;
    
     -- numbers
    
    INSERT INTO `numbers` (`number`) VALUES('0');
    INSERT INTO `numbers` (`number`) VALUES('1000');
    INSERT INTO `numbers` (`number`) VALUES('2000');
    INSERT INTO `numbers` (`number`) VALUES('3000');
    INSERT INTO `numbers` (`number`) VALUES('4000');
    INSERT INTO `numbers` (`number`) VALUES('5000');
    
    -- 10 000 lines of inserting numbers into table numbers
    -- ...
    INSERT INTO `numbers` (`number`) VALUES('5999');
    INSERT INTO `numbers` (`number`) VALUES('6999');
    INSERT INTO `numbers` (`number`) VALUES('7999');
    INSERT INTO `numbers` (`number`) VALUES('8999');
    INSERT INTO `numbers` (`number`) VALUES('9999');
    
    -- numbers small
    
    INSERT INTO `numbers_small` (`number`) VALUES('0');
    INSERT INTO `numbers_small` (`number`) VALUES('1');
    INSERT INTO `numbers_small` (`number`) VALUES('2');
    INSERT INTO `numbers_small` (`number`) VALUES('3');
    INSERT INTO `numbers_small` (`number`) VALUES('4');
    INSERT INTO `numbers_small` (`number`) VALUES('5');
    INSERT INTO `numbers_small` (`number`) VALUES('6');
    INSERT INTO `numbers_small` (`number`) VALUES('7');
    INSERT INTO `numbers_small` (`number`) VALUES('8');
    INSERT INTO `numbers_small` (`number`) VALUES('9');

    Сделали нам программу на java. Прислали скрипт для обновления базы данных DatabaseUpdateScript.sql на 874 KB.

    ftr, 08 Октября 2014

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