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

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

    +6

    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
    class Log
    {
    
    	ReverseStruct<std::list<std::string> > _logList;
    	semafor semafor;
    	Log()
    	{
    		std::list<std::string> right , left;
    		std::shared_ptr<std::list<std::string> > ptrRight=std::shared_ptr<std::list<std::string> >(*right);
    		std::shared_ptr<std::list<std::string> > ptrLeft=std::shared_ptr<std::list<std::string> >(*left);
    		_logList=TReverseStruct<std::list<std::string> >(ptrRight,ptrLeft);
    	}
    
    
    	void writeMessage(std::string message, Level level ){_logList.getWriteStorage.push_back( currentTime+level+messge); semafor.signal();}
    	void body()
    	{
    		try
    		{
    			semafor.wait();
    			_logList.revers();
    			for (std::list<std::string>::iterator i =_logList.getReadStorage->begin(); i != _logList.getReadStorage->end(); ++i)
    			{
    			fixedBufferString<7000, '\0'> stringLog;
    			stringLog.append(*i);
    			FileDevice flashInternal(FLASHINTERNAL);
    			const DriveErrors::E WriteResult = flashInternal.writeFile("log.iso", (byte*)stringLog.content(), stringLog.length());
    			}
    		}
    		catch()
    		{}
    	}
    }

    laMer007, 11 Декабря 2013

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

    −115

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    
    return (NSUInteger)[application supportedInterfaceOrientationsForWindow:window] | (1<<UIInterfaceOrientationPortrait);
    
    }

    Самый укуренный способ определить флаги UIInterfaceOrientation, который я видел.
    http://stackoverflow.com/questions/14533521/game-center-causing-uiapplicationinvalidinterfaceorientation ?answertab=votes#tab-top

    krypt, 06 Декабря 2013

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

    +124

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    S consume (S) (ref S data, Regex ! ( Unqual!(typeof(S.init[0])) ) rg)
    {
        writeln (typeid(Unqual!(typeof(S.init[0]))));
    
        auto m = match(data, rg);
        return m.hit;
    }

    LispGovno, 03 Декабря 2013

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

    +154

    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
    class Icon extends IconBuilder
    {
    	public static function create($type, $white = false)
    	{
    		$class = __CLASS__;
    		return new $class($type, $white);
    	}
    
    	public function getType()
    	{
    		return $this->_type;
    	}
    
    	public function getWhite()
    	{
    		return $this->_white;
    	}
    }

    Код выдернут из Bootstrap.PHP http://allking.ru/bootstrap.php/
    Особое внимание уделить функции create и константе __CLASS__
    Вопрос: почему не обойтись просто self? В чем магия?

    З.Ы.: Пока писал, нашел в доках, что "волшебная" константа содержит так же пространство имен.
    Извиняюсь, что не узнал об этом раньше.
    Но я все же наложу сюда, с вопросом, даже учитывая всю эту информацию, почему мы не можем обойтись способами, исключающими использование константы?
    (все равно получается говнокод, хоть и работающий)

    oooZinka, 18 Ноября 2013

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

    +156

    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
    function date_to_text($date){
    	
    
    	
    	$now=time();
    	if ($s=strtotime($date)) //the function returns false is $date is not a string (as already in numeric unix date format)
    		$date = $s;
    	$d=round(($now-$date)); //s
    
    	//echo $d;
    	if($d>60){
    		$d=$d/60;//m	
    		if($d>60){
    			$d=$d/60;//h
    			if($d>24){
    				$d=$d/24;//d
    				if($d>7){
    					$d=$d/7;//w						
    					if($d>(52/12)){
    						$d=$d/52*12;//m
    						if($d>12){
    							$d=$d/12;//y
    							$d=floor($d);			
    							$str=$d.' year'.(($d>1)?'s':'');								
    						}else{
    							$d=floor($d);			
    							$str=$d.' month'.(($d>1)?'s':'');		
    						}
    					}else{
    						$d=floor($d);			
    						$str=$d.' wk'.($d>1?'s':'');									
    					}
    				}else{					
    					$d=floor($d);
    					$str=$d.' day'.($d>1?'s':'');											
    				}
    			}else{			
    				$d=floor($d);			
    				$str=$d.' hr'.(($d>1)?'s':'');		
    			}
    		}else{
    			$d=floor($d);			
    			$str=$d.' min'.(($d>1)?'s':'');			
    		}
    	}elseif ($d>0) {
    		$d=floor($d);			
    		$str=$d.' sec'.(($d>1)?'s':'');		
    	}
    	if ($d>0){
    		$str.=' ago';
    	} else {
    		$str = '';
    	}
    	return $str;
    }

    неопiсуемо

    rombik, 22 Октября 2013

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

    +140

    1. 1
    Никому не двигаться! Мы реквизировали, реквизировали этот сайт, смекаешь?

    PragramistOtBoga, 22 Октября 2013

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

    −94

    1. 1
    2. 2
    3. 3
    ЦЫТАТЫ ВЕЛИКЕХ ЛЮДЕЙ:
                 "МАМКУ ТВАЙУ И БАЛ ЛАЛКА ЗАТРАЛИНАЯ)))0)0000))00"
                                             -PragramistOtBoga

    PragramistOtBoga, 22 Октября 2013

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    <?php
    
    if ($user_id == 0 || $user_id == '0') {
        /*НИЧЕГО*/
    }

    1С Битрикс, этим всё сказано...

    P.S давненько ничего не постил...

    qbbr, 09 Октября 2013

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

    +151

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
            try {
                $mySqlData = $this->apiTransport->call('Data', 'checkByHash', $params, $this->ApiClient->getOptions());
            } catch (\Exception $e) {
                throw new \Exception($e->getMessage());
            }

    Не перестают удивлять

    greevex, 19 Сентября 2013

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

    +158

    1. 1
    if ($showwindows*1 == 0) { $content->set('hidden','hidden'); }

    kSM, 18 Сентября 2013

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