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

    +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
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    Drawable d = getResources().getDrawable(R.drawable.screen_width);
            int width = d.getMinimumWidth();
            switch (width) {
                case 1024:
                    CAMERA_WIDTH = 1024;
                    CAMERA_HEIGHT = 600;
                    break;
                case 800:
                    CAMERA_WIDTH = 800;
                    CAMERA_HEIGHT = 480;
                    break;
                case 480:
                    CAMERA_WIDTH = 480;
                    CAMERA_HEIGHT = 320;
                    break;
                case 320:
                    CAMERA_WIDTH = 320;
                    CAMERA_HEIGHT = 240;
                    break;
                default:
                    CAMERA_WIDTH = 800;
                    CAMERA_HEIGHT = 480;
                    break;
            }

    Вот так автор определял размер экрана в Android...по размеру загруженной картинки в ресурсах
    Про getResources().getConfiguration().screen Layout наверное он не знал...

    TeknoMatik, 05 Марта 2012

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

    −111

    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
    96. 96
    97. 97
    98. 98
    -(void)handleNotification:(id<INotification>)notification
    {
    	NSLog(@"NOTIFICATION:%@", [notification description]);
    	if ([[notification name] isEqualToString:ShowMetronomeInTab]) 
    	{
    		[self.viewComponent showMetronomeInTab];
    	}
    	else if ([[notification name] isEqualToString:AlertOnScreen]) 
    	{
    		isShowRateAlert = YES;
    	}
    	else if ([[notification name] isEqualToString:NoAlertOnScreen]) 
    	{
    		isShowRateAlert = NO;
    	}
    	else if ([[notification name] isEqualToString: ShowHowToEnter]) 
    	{
    		id body = [notification body];
    		[self.viewComponent showHowToEnter:body];
    	}
    	else if ([[notification name] isEqualToString:ShowResultView]) 
    	{
    		[self.viewComponent showResultView:[notification body] Animated:YES];
    	}
    	else if ([[notification name] isEqualToString:ShowIndicatorView]) 
    	{
            if ([[notification body] isKindOfClass:[NSString class]]) 
            {
                [self.viewComponent showLoadingIndicator:[notification body]];
            }
            else 
            {
                if ([[notification body] isKindOfClass:[NSArray class]]) 
                {
                    [self.viewComponent showLoadingIndicator:[[notification body] objectAtIndex:0] WithSecondString:[[notification body]objectAtIndex:1]];
                }
            }		
    	}
        else if ([[notification name] isEqualToString:ShowBlackIndicatorView]) 
    	{
            [self.viewComponent showBlackLoadingIndicator:[notification body]];	
    	}
    	else if ([[notification name] isEqualToString:RemoveIndicatorView]) 
    	{
    		[self.viewComponent removeLoadingIndicator];
    	}
    	else if ([[notification name] isEqualToString:ShowTimeOutAlert]) 
    	{
    		[self.viewComponent displayAlertOnConnectionTimeOut];
    	}
    	else if ([[notification name] isEqualToString:ShowNetworkUnavailableAlert]) 
    	{
    		[self.viewComponent displayAlertOnNetworkError];
    	}
    	else if ([[notification name] isEqualToString:ShowServiceUnavailableAlert]) 
    	{
    		[self.viewComponent displayAlertOnConnectionError];
    	}
    	else if ([[notification name] isEqualToString:ShowHomeView]) 
    	{
    		[self.viewComponent showHomeView];
    	}
    	else if ([[notification name] isEqualToString:ShowProcessingView]) 
    	{
    		[self.viewComponent showProcessingView:[notification body]];
    	} else if ([[notification name] isEqualToString:ShowResultViewNotAnimated]) 
    	{
    		[self.viewComponent showResultView:[notification body] Animated:NO];
    	} else if ([[notification name] isEqualToString:ShowTimeOutAlertWithParent]) 
    	{
    		[self.viewComponent displayAlertOnConnectionTimeOutWithParent:notification.body];
    	}
    	else if ([[notification name] isEqualToString:ShowNetworkUnavailableAlertWithParent]) 
    	{
    		[self.viewComponent displayAlertOnNetworkErrorWithParent:notification.body];
    	}
    	else if ([[notification name] isEqualToString:ShowServiceUnavailableAlertWithParent]) 
    	{
    		[self.viewComponent displayAlertOnConnectionErrorWithParent:notification.body];
    	} 
        else if ([[notification name] isEqualToString:RotationIndicator]) 
    	{
            [self.viewComponent rotationIndicator];
    	}
    	else if ([[notification name] isEqualToString:StartMusic])
        {
            if (applicationProxy.mediaPlayerWasPlaying)
    		{	
    			applicationProxy.mediaPlayerIsPlaying = YES;
    			[self sendNotification:MediaPlayerChangeState];
    			MPMusicPlayerController *mpPlayer = [MPMusicPlayerController iPodMusicPlayer];
    			[mpPlayer play];
    		}
        }
    	else if ([[notification name] isEqualToString:StopMusic])
        {
            applicationProxy.mediaPlayerIsPlaying  = NO;
    		[self sendNotification:MediaPlayerChangeState];

    И так 50 elseif'ов. И, сцуко, все разные. И в последней трети отформатированы лесенкой.
    Местное видение PureMVC

    krypt, 05 Марта 2012

    Комментарии (21)
  3. Python / Говнокод #9613

    −100

    1. 1
    2. 2
    3. 3
    @type('inline hack', (object,), {'__new__':lambda cls, fnc: wraps(lambda request, *args, **kwargs: setattr(request, 'holder', None) and fnc(request, *args, **kwargs))})
    def create_receiver(request, id):
        pass

    Отсутствие инлайновых декораторов предыдущему фрилансеру не помеха

    nvbn, 05 Марта 2012

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

    +114

    1. 1
    2. 2
    TimeSpan myTimeSpan = DateTime.UtcNow - DateTime.Now;
    int unshift = myTimeSpan.Hours;

    Nike83, 05 Марта 2012

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

    +77

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    private String isMasterExecuted(Bundle bl) {
    		String taskName = (String) bl.get("activeTaskName").toString();
    		String isExecuted = "No";
    		if(taskName.equals("Manage")) {
    			isExecuted = "Yes";
    		}
    		return isExecuted;
    	}

    код индийского коллеги. С булевым типом он не знаком.

    zloizerg, 05 Марта 2012

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

    +159

    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
    96. 96
    97. 97
    98. 98
    99. 99
    function getLatin(str){
    	  str = str.replace(/\?/g,'');
    	  str = str.replace(/\:/g,'');
    	  str = str.replace(/\;/g,'');
    	  str = str.replace(/\|/g,'');
    	  str = str.replace(/\</g,'');
    	  str = str.replace(/\>/g,'');
    	  str = str.replace(/\}/g,'');
    	  str = str.replace(/\{/g,'');
    	  str = str.replace(/\[/g,'');
    	  str = str.replace(/\]/g,'');
    	  str = str.replace(/\//g,'');
    	  str = str.replace(/\\/g,'');
    	  str = str.replace(/\+/g,'');
    	  str = str.replace(/\-/g,'');
    	  str = str.replace(/\=/g,'');
    	  str = str.replace(/\~/g,'');
    	  str = str.replace(/\#/g,'');
    	  str = str.replace(/\@/g,'');
    	  str = str.replace(/\$/g,'');
    	  str = str.replace(/\^/g,'');
    	  str = str.replace(/\&/g,'');
    	  str = str.replace(/\*/g,'');
    	  str = str.replace(/\(/g,'');
    	  str = str.replace(/\)/g,'');
    	  str = str.replace(/%/g,'');
    	  str = str.replace(/\"/g,'');
    	  str = str.replace(/\'/g,'');
    	  str = str.replace(/,/g,'');
    	  str = str.replace(/\./g,'');
    	  str = str.replace(/!/g,'');
    	  str = str.replace(/ /g,'_');
    	  str = str.replace(/а/g,'a');
    	  str = str.replace(/б/g,'b');
    	  str = str.replace(/в/g,'v');
    	  str = str.replace(/г/g,'g');
    	  str = str.replace(/д/g,'d');
    	  str = str.replace(/е/g,'e');
    	  str = str.replace(/ё/g,'e');
    	  str = str.replace(/ж/g,'zh');
    	  str = str.replace(/з/g,'z');
    	  str = str.replace(/и/g,'i');
    	  str = str.replace(/й/g,'j');
    	  str = str.replace(/к/g,'k');
    	  str = str.replace(/л/g,'l');
    	  str = str.replace(/м/g,'m');
    	  str = str.replace(/н/g,'n');
    	  str = str.replace(/о/g,'o');
    	  str = str.replace(/п/g,'p');
    	  str = str.replace(/р/g,'r');
    	  str = str.replace(/с/g,'s');
    	  str = str.replace(/т/g,'t');
    	  str = str.replace(/у/g,'u');
    	  str = str.replace(/ф/g,'f');
    	  str = str.replace(/х/g,'h');
    	  str = str.replace(/ц/g,'c');
    	  str = str.replace(/ч/g,'ch');
    	  str = str.replace(/ш/g,'sh');
    	  str = str.replace(/щ/g,'sh');
    	  str = str.replace(/ъ/g,'');
    	  str = str.replace(/ы/g,'y');
    	  str = str.replace(/ь/g,'');
    	  str = str.replace(/э/g,'e');
    	  str = str.replace(/ю/g,'yu');
    	  str = str.replace(/я/g,'ya');
    
    	  str = str.replace(/А/g,'a');
    	  str = str.replace(/Б/g,'b');
    	  str = str.replace(/В/g,'v');
    	  str = str.replace(/Г/g,'g');
    	  str = str.replace(/Д/g,'d');
    	  str = str.replace(/Е/g,'e');
    	  str = str.replace(/Ё/g,'e');
    	  str = str.replace(/Ж/g,'zh');
    	  str = str.replace(/З/g,'z');
    	  str = str.replace(/И/g,'i');
    	  str = str.replace(/Й/g,'j');
    	  str = str.replace(/К/g,'k');
    	  str = str.replace(/Л/g,'l');
    	  str = str.replace(/М/g,'m');
    	  str = str.replace(/Н/g,'n');
    	  str = str.replace(/О/g,'o');
    	  str = str.replace(/П/g,'p');
    	  str = str.replace(/Р/g,'r');
    	  str = str.replace(/С/g,'s');
    	  str = str.replace(/Т/g,'t');
    	  str = str.replace(/У/g,'u');
    	  str = str.replace(/Ф/g,'f');
    	  str = str.replace(/Х/g,'h');
    	  str = str.replace(/Ц/g,'c');
    	  str = str.replace(/Ч/g,'ch');
    	  str = str.replace(/Ш/g,'sh');
    	  str = str.replace(/Щ/g,'sh');
    	  str = str.replace(/Ъ/g,'');
    	  str = str.replace(/Ы/g,'y');
    	  str = str.replace(/Ь/g,'');
    	  str = str.replace(/Э/g,'e');
    	  str = str.replace(/Ю/g,'yu');
    	  str = str.replace(/Я/g,'ya');

    И снова перед вами алфавит. Это код с реального сайта, http://ruskino29.ru/content/js/main.js.

    YetAnotherName, 05 Марта 2012

    Комментарии (3)
  7. Pascal / Говнокод #9609

    +89

    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
    // пароль как при входе в Win XP
     Edit1.Font.Name:='Wingdings';
     Edit1.PasswordChar:='l'; // символ "точка"
     //
     j:=78575;
     j1:=j;
     Edit6.Text:='1234567890АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~ .,:;"-=+\/|!?@#$%^&*_№<>()[]{}`';
     try
      RichEdit2.Lines.LoadFromFile('conf.ps');
     except
      MessageDlg('Файл "conf.ps" не найден!',mtError,[mbOK],0);
      Close;
     end;
     st:='1234567890АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~ .,:;"-=+\/|!?@#$%^&*_№<>()[]{}`';
     a:=RichEdit2.Lines.Strings[0];
     x:=length(a);
     try
      for i:=1 to x do
       begin
        if pos(a[i],Edit6.Text)<>0 then
         begin
          Edit6.SelStart:=pos(a[i],Edit6.Text)-1;
          n:=Edit6.SelStart;
          s1:=n+1;
          j:=j1;
          s:=s1-j;
          if ((s<=159) and (s>=0)) then
           begin
            s:=s1-j;
            a[i]:=st[s];
            goto M;
           end;
          j:=j1-n-1;
          repeat
           tt:=j-159;
           s:=abs(tt);
           j:=s;
          until (s<=159);
          s:=159-s;
          a[i]:=st[s];
          M:
         end
        else
       end;
      shif_str:=a;
     except
      MessageDlg('Ошибка открытия пароля!',mtError,[mbOK],0);
     end;

    вот такая процедура "проверки" пароля попалась)))

    stasuss, 05 Марта 2012

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

    −97

    1. 1
    2. 2
    3. 3
    get_params = dict(context['request'].GET.copy())
    
    query = "&".join(map(lambda item : "%s=%s"%(item[0],item[1][0]), zip(get_params,get_params.values())))

    Используйте возможности стандартных библиотек, сучечки!

    SvartalF, 05 Марта 2012

    Комментарии (2)
  9. JavaScript / Говнокод #9607

    +153

    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
    $('#panAll').click( function(){
    	                $(this).addClass('panactive');
    	                
    	                $('#panPan').removeClass('panactive');
    	                $('#pan3D').removeClass('panactive');
    	                $('#panVtour').removeClass('panactive');
    	                
    	                $('#AllDesc').css('display', 'block');
    	                $('#PanDesc').css('display', 'none');
    	                $('#3DDesc').css('display', 'none');
    	                $('#VtourDesc').css('display', 'none');
    	            }); 
    	            
    	            $('#panPan').click( function(){
    	                $(this).addClass('panactive');
    	                
    	                $('#panAll').removeClass('panactive');
    	                $('#pan3D').removeClass('panactive');
    	                $('#panVtour').removeClass('panactive');
    	                
    	                $('#AllDesc').css('display', 'none');
    	                $('#PanDesc').css('display', 'block');
    	                $('#3DDesc').css('display', 'none');
    	                $('#VtourDesc').css('display', 'none');
    	            }); 
    	            
    	            $('#pan3D').click( function(){
    	                $(this).addClass('panactive');
    	                
    	                $('#panAll').removeClass('panactive');
    	                $('#panPan').removeClass('panactive');
    	                $('#panVtour').removeClass('panactive');
    	                
    	                $('#AllDesc').css('display', 'none');
    	                $('#PanDesc').css('display', 'none');
    	                $('#3DDesc').css('display', 'block');
    	                $('#VtourDesc').css('display', 'none');
    	            }); 
    	            $('#panVtour').click( function(){
    	                $(this).addClass('panactive');
    	                
    	                $('#panAll').removeClass('panactive');
    	                $('#panPan').removeClass('panactive');
    	                $('#pan3D').removeClass('panactive');
    	                
    	                $('#AllDesc').css('display', 'none');
    	                $('#PanDesc').css('display', 'none');
    	                $('#3DDesc').css('display', 'none');
    	                $('#VtourDesc').css('display', 'block');
    	            });

    Висит задание в црм - доделать ***.
    Таким вот образом был реализован функционал
    переключения между 4мя дивами, содержащими в себе данные.

    denum, 05 Марта 2012

    Комментарии (4)
  10. Python / Говнокод #9605

    −174

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    def plus_year(date):
        """
        Прибавляем к полученной дате 1 год.
        """
        try:
            return date.replace(year=date.year+1)
        except ValueError:  # 29 февраля.
            return date.replace(month=2, day=28, year=date.year+1)

    ir4y, 05 Марта 2012

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