1. C# / Говнокод #18354

    +143

    1. 1
    2. 2
    3. 3
    4. 4
    public static bool IsEmpty(this string input)
            {
                return String.IsNullOrEmpty(input);
            }

    А почему бы и да?

    alexCoder2007, 17 Июня 2015

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

    +144

    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
    $ git log --pretty=oneline
    
    c8220f95d1b11d2e8a2d57cf4349c40a180bd7f3 Commit 33
    6eeac872fa772c2ea1d57faf286f6520fc831777 Commit 32
    fba42d3f0a6678e670d477bcc0c56819cafd34f9 Commit 31
    4292c5dc9cb9c4360f7ad03b2d5ecabbeb451a55 Commit 30
    2ba640394371f0fd44296c41b99fd42f6abfaf95 Commit 29
    80aa4d6754e5f82f3b111075747fd74f63e1a26c Commit 28
    7f43aa08d9d94e6c09f6435635942010320a824e Commit 27
    574524bf2b0dcb8070ce46ced75cec626e7c84ad Commit 26
    eb620063a690c489e746e2f5633771da66df0903 Commit 25
    
    ...

    https://github.com/gikraychik/bets

    eg0r, 17 Июня 2015

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

    +142

    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
    public function uninstall()
    	{
    		if (!Configuration::deleteByName('YC_SHOPID')
    				|| !Configuration::deleteByName('YC_SCID')
    				|| !Configuration::deleteByName('YC_SHOPPASSWORD')
                                    || !!Configuration::deleteByName('YC_ALLOW_YANDEXMONEY')
                                    || !!Configuration::deleteByName('YC_ALLOW_BANK_CARD')
                                    || !!Configuration::deleteByName('YC_ALLOW_MOBILE')
                                    || !!Configuration::deleteByName('YC_ALLOW_TERMINAL')
                                    || !!Configuration::deleteByName('YC_ALLOW_WEBMONEY')
                                    || !!Configuration::deleteByName('YC_ALLOW_SBERBANK')
                                    || !!Configuration::deleteByName('YC_ALLOW_MPOS')                        
                                    || !!Configuration::deleteByName('YC_DEMO_MODE')
    				|| !parent::uninstall())
    			return false;
    		return true;
    	}

    https://github.com/anisimow/yacassa/blob/master/yacassa/yacassa.php#L64

    eg0r, 17 Июня 2015

    Комментарии (0)
  4. Ruby / Говнокод #18350

    −119

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    def has_children_pages(id)
      unless Page.where(:parent_id => id, :public => true).blank?      
        return true
      end      
      return false
    end

    мне сказали, что этот проект php-шники писали

    Fuelen, 16 Июня 2015

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

    +144

    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
    // Класс валидации в PrestaShop
    class ValidateCore
    {
    ...
    	public static function isIp2Long($ip)
    	{
    		return preg_match('#^-?[0-9]+$#', (string)$ip);
    	}
    
    	public static function isAnything()
    	{
    		return true;
    	}
    ...

    invision70, 16 Июня 2015

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

    +141

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    string log;
    ...
    try
    {
              Logger.SaveLog(fullPath, log);
    }
    catch (Exception ex)
    {
             Logger.SaveLog(fullPath, ex.ToString());
    }

    Senior developer...

    kiberg, 16 Июня 2015

    Комментарии (0)
  7. Lua / Говнокод #18346

    −85

    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
    local sol_lines = {}
    local i = 1; local j = 0;
    	
    while (i <= solution:len()) do
    	local begin_pos = i
    	while(i <= solution:len() and solution:sub(i, i) ~= '\n') do
    		i = i + 1
    	end
    
    	if i > solution:len() then
    		i = solution:len()
    	end
    
    	local cur_line = solution:sub(begin_pos, i)
    	sol_lines[j] = trim(cur_line)
    	i = i + 1
    	j = j + 1
    end

    Lua
    Как я разбивал строку на отдельные линии. Вместо того, чтобы использовать string.find(s, "\n", i + 1). Так я писал код 0.027397 года назад назад.

    Janycz, 15 Июня 2015

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

    +142

    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
    public void AllocateMemory(ref int[] segmentSizeProcess)
            {
                int[] difference;
                int j = 0;
                int tempo = 0;
    
                for (int i = 0; i < segmentSizeProcess.Count(); i++)
                {
                    difference = new int[memory.Count]; // храним разность размера блока памяти и требуемого размера для процесса
                    for (int count = 0; count < memory.Count; count++)
                    {
                        difference[count] = -2; // предварительно инициализируем 
                    }
                    for (int count_memory=0; count_memory<memory.Count();
                        count_memory++)
                    {
                        if (memory[count_memory].size - segmentSizeProcess[i] >= 0) // если равно 0, значит 
                        // сегмент полностью распределён
                        {
                            if (!memory[count_memory].isAllocate)
                            { difference[count_memory] = memory[count_memory].size - segmentSizeProcess[i]; }
                            else
                            { difference[count_memory] = -1; } // если сегмент занят - 
                            // то он недоступен
                        }
                    }
                    tempo = GetMinDifference(ref difference); // получаем индекс минимальной разности
                    // если результат "-", значит секторы заняты, выходим из цикла
                    if (difference[tempo] >= 0)
                    {
                        memory.ElementAt(tempo).isAllocate = true; // процесс занял сегмент
                        if (difference[tempo] > 0) // если остаётся фрагмент памяти
                        {
                            CreateDifferenceSegment(difference[tempo]); // создаем новый сегмент, равный
                            // наименьшей разности памяти сегмента и памяти для процесса
                        }
                            memory[tempo].size = segmentSizeProcess[i]; // распределяем память
                    }
                    else
                    {
                        break;
                    }
                }
            }

    Примерная реализация алгоритма best-fit

    qstd, 15 Июня 2015

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

    +142

    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
    orders_list_app.constant('User', {
        auth : ('False' == 'True') ? true : false,
        contractor : ('' == 'True')  ? true : false,
        user_id : ('False' == 'True') ? None : false
    });
    
    // goes in another place
    
    angular.forEach(rootCategory.categories, function(category_2){
        angular.forEach(category_2.service_orders, function(service_2){
            rootCategory.service_orders.push(service_2);
                angular.forEach(category_2.categories, function(category_3){
                    angular.forEach(category_3.service_orders, function(service_3){
                        rootCategory.service_orders.push(service_3);
                    });
                });
            });
        });
        rootCategory.service_orders.push({name:"Другие услуги" ,text: "", title: "Другие услуги"});
    });

    На одном из отечественном сайте в продакшыне..

    alek0585, 15 Июня 2015

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

    +144

    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
    public String tommorowCalendarCountry(String date, String country){
    		String tommorowCountry = null;
    		if(date.equals(getTommorow())){
    			tommorowCountry =  country;
    		}
    		return tommorowCountry;
    	}
    	
    	public String tommorowCalendarIndicator(String date, String indicator){
    		String tommorowIndicator = null;
    		if(date.equals(getTommorow())){
    			tommorowIndicator =  indicator;
    		}
    		return tommorowIndicator;
    	}
    	
    	public String tommorowCalendarImportance(String date, String importance){
    		String tommorowImportance = null;
    		if(date.equals(getTommorow())){
    			tommorowImportance =  importance;
    		}
    		return tommorowImportance;
    	}
    	
    	public String tommorowCalendarForecast(String date, String forecast){
    		String tommorowForecast = null;
    		if(date.equals(getTommorow())){
    			tommorowForecast =  forecast;
    		}
    		return tommorowForecast;
    	}
    	
    	public String tommorowCalendarPrevious(String date, String previous){
    		String tommorowPrevious = null;
    		if(date.equals(getTommorow())){
    			tommorowPrevious =  previous;
    		}
    		return tommorowPrevious;
    	}
    	
    	public String tommorowCalendarActual(String date, String actual){
    		String tommorowActual = null;
    		if(date.equals(getTommorow())){
    			tommorowActual =  actual;
    		}
    		return tommorowActual;
    	}
    	
    	public String tommorowCalendarDescription(String date, String description){
    		String tommorowDescription = null;
    		if(date.equals(getTommorow())){
    			tommorowDescription =  description;
    		}
    		return tommorowDescription;
    	}
    	
    	public String tommorowCalendarPeriod(String date, String period){
    		String tommorowPeriod = null;
    		if(date.equals(getTommorow())){
    			tommorowPeriod =  period;
    		}
    		return tommorowPeriod;
    	}
    	
    	public String tommorowCalendarLocation(String date, String location){
    		String tommorowLocation = null;
    		if(date.equals(getTommorow())){
    			tommorowLocation =  location;
    		}
    		return tommorowLocation;
    	}

    пришло с аутсорса. Такого в проекте очень много)

    slavik, 15 Июня 2015

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