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

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

    −143

    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
    IF @Detail is not null
          AND (SELECT
                COUNT(AppraisalResponseID)
                FROM AppraisalResponseHistory
                WHERE AppraisalResponseID = @AppraisalResponseID) >0
          BEGIN
                INSERT INTO AppraisalResponseHistory 
                ( AppraisalResponseID, 
                      PermissionID, 
                      AppraisalTypeQuestionPromptID, 
                      Detail, 
                      ModifiedDate, 
                      PersonID )
          
                SELECT AppraisalResponse.ID, 
                      AppraisalResponse.PermissionID,
                       AppraisalResponse.AppraisalTypeQuestionPromptID,
                       AppraisalResponse.Detail, 
                      AppraisalResponse.ModifiedDate,
                      PersonID
                FROM AppraisalResponse
                WHERE AppraisalResponse.ID=@AppraisalResponseID AND AppraisalResponse.Detail<>@Detail
          
          END
    ELSE
          IF COALESCE(@Detail, '') = ''
    --if the reviewer is inserting a blank record after having filled in a response, insert into history
    --if the blank record is the place holder, do not insert into history
          AND (SELECT
                COUNT(AppraisalResponseID)
                FROM AppraisalResponseHistory
                WHERE AppraisalResponseID = @AppraisalResponseID) >0
          BEGIN
                INSERT INTO AppraisalResponseHistory 
                ( AppraisalResponseID, 
                      PermissionID, 
                      AppraisalTypeQuestionPromptID, 
                      Detail, 
                      ModifiedDate, 
                      PersonID )
          
                SELECT AppraisalResponse.ID, 
                      AppraisalResponse.PermissionID,
                       AppraisalResponse.AppraisalTypeQuestionPromptID,
                       AppraisalResponse.Detail, 
                      AppraisalResponse.ModifiedDate,
                      PersonID
                FROM AppraisalResponse
                WHERE AppraisalResponse.ID=@AppraisalResponseID AND AppraisalResponse.Detail<>@Detail
    END

    If @Detail is not null or blank, I need to check if AppraisalResponse.Detail is blank or null (- I think this is where I am running into so much trouble). If it is blank or null then
    I need to check if there is already a record in AppraisalHistory with this ID. If there is, I need to insert the blank record to history, otherwise not.

    If @Detail is null.
    I need to check if there is already a record in Appraisal History with this ID. If there is, I need to insert the blank record to history, otherwise not.

    Даже описание скопипащено

    3.14159265, 23 Февраля 2011

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

    +163

    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
    $year = date("Y");
    $month = date("m");
    $day = date("d"); 
    
    if ($month == 9 or $month == 10 or $month == 11)
    {
    $month_new = $month + 1;
    echo $year.'-'.$month_new.'-'.$day;  
    }
    else 
    {
    
    if ($month == 12) {$year_new = $year + 1; 
    $year_new = $year + 1;
    $month_new = 1; 
    echo $year_new.'-0'.$month_new.'-'.$day;  }
    else {
    $month_new = $month + 1;
    echo $year.'-0'.$month_new.'-'.$day;} 
    }

    не удержался )

    Sulik78, 22 Февраля 2011

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

    −115

    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
    # Функция обновляет файл базы
            # Пользоваться: cut_jnl($bc, $local_ip, $jnl_string_new);
            sub cut_jnl
            {
    
                         my ( $bc, $ip_old, $string_new ) = @_;
                         open (JNL, "<$bc->{const}{base_jnl}");
                         undef $\;
                         my @all_file = <JNL>;
                         close JNL;
                         chomp($string_new);
                         $string_new .= "\n" if ($string_new ne '');
                         grep { s/.*$ip_old;.*/$string_new/sg } @all_file;
                         open (JNL, ">$bc->{const}{base_jnl}");
                         grep { print JNL } @all_file;
                         close JNL;
                         $bc->{const}{info}->debug("Update jnl, update string: $ip_old on $string_new");
    
            }

    no comments... особенно доставляют инструкции grep {}, это похлеще map {} будет.

    SadKo, 22 Февраля 2011

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

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    CString sLineNumber = _T("Line");
    	for(int lineIndex = 0; lineIndex < 255; lineIndex++)
    	{
    		sLineNumber += (_itot(lineIndex + 1, temp, 10));
    		...
    		sLineNumber = _T("Line");
    	}

    Build the string variable in loop, instead of use CString::Format(...)

    ShuraKotov, 21 Февраля 2011

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

    +130

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    csu = 0;
    for i=1:1:devices
    	csu = csu + device_twt(i);
    end;
    csu = csu / (devices * time);
    fprintf('коэффициент использования системы = %f\n', csu);

    Говнокод на MATLAB.

    1_and_0, 21 Февраля 2011

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

    +76

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    String DataStr = null;
    try {
        DataStr = new String(Data.toByteArray(), "UTF-8");
    } catch (Exception e) {
    }
    DataStr = DataStr.substring(1);

    Обработка ошибок, чо

    zeac, 20 Февраля 2011

    Комментарии (3)
  8. bash / Говнокод #5674

    −135

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    parsemask() {
            echo -n "$@" | tr -d "\n" | sed -e "s#%%#\n#g" | sed -e "s#%C#$CLUSTER#g" | sed -e "s#%R#$XENXROOT#g" | tr "\n" "%";
            return;
    }
    
    for pvar in STATUSPATH LOGPATH DRBDLOGPATH XENXPREFIX CLUSTERSPATH; do
            eval R${pvar}="`parsemask "$(eval echo \\\$${pvar})"`"
    done

    Реализация разыменовки и замены в цикле, для того, чтобы для каждой переменной (например LOGPATH="%R/var/log/xenx/%C.log") определилась соответствующая переменная с произведёнными подстановками (например RLOGPATH="/usr/local/xenx/var/log/xenx/stormrage.log").

    xaionaro, 14 Февраля 2011

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

    +164

    1. 1
    2. 2
    RewriteRule ^tn_([0-9]*)x([0-9]*)_([a-z]+)_([0-9]*)_([0-9]+)_(.*)_([c]*)_([f]*)_([0-9]*).[a-z]*$ перенос
    /index.php?exception=imageModification&width=$1&height=$2&module=$3&id=$4&time=$5&name=$6&crop=$7&force=$8&query=$9&file_name=%{REQUEST_URI} [L]

    В .htaccess:
    Победа над ресайзом картинок. Чуваки еще не успели ощутить на себе всю мощь ананимуса

    ifeya, 10 Февраля 2011

    Комментарии (3)
  10. ActionScript / Говнокод #5593

    −104

    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
    if( mIsTarget )
    {
    	...
    	if( !mTargetUnit )
    	{
    		panel.isTarget = true;
    	}
    	else
    	{
    		mTargetUnit.isTarget = true;
    	}
    
    	if( targetUnitId )
    	{
    		targetId = targetUnitId;
    	}
    	else
    	{
    		if( !mTargetUnit )
    		{
    			targetId = panel.getId();
    		}
    		else
    		{
    			targetId = mTargetUnit.getId();
    		}
    	}
    }
    else if( !mIsTarget )
    {
    	if( mUnitManager.getUnitList())
    	{
    		for( i = 0; i < mUnitManager.getUnitList().length; i++ )
    		{
    			( mUnitManager.getUnit( mUnitManager.getUnitList()[ i ]) as BattleUnit ).hasTarget = false;
    			( mUnitManager.getUnit( mUnitManager.getUnitList()[ i ]) as BattleUnit ).isTarget = false;
    		}
    	}
    }

    отак от

    Werdn, 08 Февраля 2011

    Комментарии (3)
  11. ActionScript / Говнокод #5543

    −106

    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
    public class XMLParser extends Sprite
    {
    	private var _xmlData:XML;
    	private var _xmlLoader:URLLoader;
    	
    	public function XMLParser() {}
    
    	public function loadXML(url:String):void
    	{
    		_xmlLoader = new URLLoader();
    		_xmlLoader.addEventListener(Event.COMPLETE, onXMLLoad);
    		_xmlLoader.load(new URLRequest(url));
    	}
    
    	private function onXMLLoad(e:Event):void
    	{
    		_xmlData = new XML(e.target.data);
    		parent.dispatchEvent(new Event("LOAD"));				
    	}
    
    	public function parseXML():Array
    	{
    		var infoData:Array = new Array();
    			
    		for(var i:int=0; i <= _xmlData.item.length()-1; i++)
    		infoData.push([ _xmlData.item.attribute("src")[i],
    					    _xmlData.item[i].title,
    						_xmlData.item[i].image,
    						_xmlData.item[i].call,
    						_xmlData.item[i].description,
    						_xmlData.item[i].place,
    						_xmlData.item[i].file]);
    		return infoData;
    	}
    }

    XML Parser, ёпт =\

    Slippy, 05 Февраля 2011

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