1. PHP / Говнокод #10481

    +78

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    public function monthToString($month)
    {	
    	$months = array('никогдарь', 'январь', 'февраль', 'март', 'апрель', 'май', 'июнь', 'июль', 'август', 'сентябрь', 'октябрь', 'ноябрь', 'декабрь');
    	if(is_numeric($month))
    	{
    		$month = ltrim($month, "0");
    		$month = $months[$month];
    	}
    	return $month;
    }

    Стажер нашел весьма нетривиальный способ получить месяц текстом =D

    s1Paris, 31 Мая 2012

    Комментарии (49)
  2. Java / Говнокод #10480

    +111

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    // WARNING!
    // This has to be optional=true so that OpenJPA uses
    // LEFT JOIN instead of INNER JOIN. Otherwise, MySQL tries
    // using a temporary table (horrible for performance) and dies.
    @ManyToOne(optional = true)
    @NotNull
    private Font font;

    someone, 31 Мая 2012

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

    +136

    1. 1
    http://www.jackrussell-italy.it/

    Весь сайт - одни картинки с мапами.
    Страница, на ней картинка, к ней привязана карта.
    Причем разные версии для каждого языка.
    Fuck html5! Fuck css3!

    7ion, 30 Мая 2012

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

    −43

    1. 1
    int eger;

    dos_, 30 Мая 2012

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

    −32

    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
    #pragma once
    
    #include <vector>
    #include <assert.h>
    
    class Obj
    {
    public:
    	virtual ~Obj(void) { }
    };
    
    
    class Sig
    {
    	typedef void (Obj::*slot_t)(void*);
    	mutable std::vector<std::pair<Obj*, Sig::slot_t>> m_connSlots;
    
    public:
    	void operator()(void* arg) const
    	{
    		std::vector< std::pair<Obj *, slot_t> >::const_iterator iter = m_connSlots.cbegin();
    		while(iter != m_connSlots.cend())
    		{
    			Obj * object = iter->first;
    			slot_t slot = iter->second;
    			(object->*slot)(arg);
    			iter++;
    		}
    	}
    
    	template<class obj_T> void connect(obj_T* object, void (obj_T::*slot)(void*)) const
    	{
    		assert(dynamic_cast<Obj*>(object)!=0);
    		m_connSlots.push_back(std::make_pair(reinterpret_cast<Obj*>(object),
    			reinterpret_cast<Sig::slot_t>(slot)));
    	}
    };

    QBicycle

    Xom94ok, 30 Мая 2012

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

    +101

    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
    private void FillLocalService(int SelectedPageIndex)
            {
                //Set category by search
                string search = inputSearch.Value == inputSearchValue ? string.Empty : inputSearch.Value;
                if (inputSearch.Value != inputSearchValue && !string.IsNullOrWhiteSpace(inputSearch.Value))
                {
                    if (inputSearch.Value.StartsWith("landscap", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Landscapers";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.StartsWith("baby sitter", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Baby sitters";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.StartsWith("doctor", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Doctor";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.StartsWith("cleaning service", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Cleaning services";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.StartsWith("pet sitter", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Pet sitters";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.StartsWith("handyman", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Handyman";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.StartsWith("electrical service", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Electrical services";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.StartsWith("tutor", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Tutor";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.StartsWith("dog walker", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Dog walker";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.StartsWith("plumb", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Plumbing";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.StartsWith("Caterer", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Caterers";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.Equals("misc", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Misc";
                        search = string.Empty;
                    }
                }
    
    200+ строк кода
    }

    тот же девелопер, та же .aspx страница)))))

    mangyst, 30 Мая 2012

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

    +65

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $update_result = mysql_query($update) or die("failed");
    	
    	if($update_result != false)
    		header("location: index.php");
    	else
    		die("Something Failed.");

    Rusik58, 30 Мая 2012

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

    −32

    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
    //
    //	std::string wrapper
    //
    namespace priv {
    	class string {
    		std::string &m_s;
    
    		std::string &(std::string::*m_pAssign1)( const char *, std::string::size_type );
    		std::string &(std::string::*m_pAssign2)( const char * );
    
    	public:
    		string( std::string &str ): m_s(str),
    			m_pAssign1(&std::string::assign), m_pAssign2(&std::string::assign) {}
    
    		string &assign( const char *s, std::string::size_type n )
    		{
    			(m_s.*m_pAssign1)( s, n ); return *this;
    		}
    		string &assign( const char *s )
    		{
    			(m_s.*m_pAssign2)( s ); return *this;
    		}
    	};
    }

    сегодня ассимилирую старый хлам на работе (проекты VC6) в студию с нормальными свойствами проектов, конфигурациями, неабсолютными путями и т.д.
    наткнулся в одной из либ на вот это

    defecate-plusplus, 30 Мая 2012

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

    +123

    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
    #include <stdio.h>
    int getLen(long long num)
    {
        int count=0;
        while (num > 0)
        {
            count++;
            num/=10;
        }
        return count;
    }
    
    int main(void)
    {
        int count = 0;
        for (long long i=1; i<=9; i++)
        {
            long long num = 1;
            int modify=0;
    
            for (int j=1; j<30; j++)
            {
                if (i==7 && j == 5)
                {
                    int a= 1;
                    a++;
                }
                num *= i;
                if (getLen(num) == j-modify)
                {
                    printf("%d^%d=%lld OK  %d\n", i, j, num, count+1);
                    count++;
                }
                if (num > 10000000)
                {
                    num/=10;
                    modify++;
                }
            }
        }
        printf("%d\n", count);
        return 0;
    }

    http://projecteuler.net/problem=63
    http://projecteuler.net/thread=63&page=8



    >I don't want to write again an big number rendering algorithm, so I played a little trick on it and hoped it won't cause any trouble..

    TheHamstertamer, 30 Мая 2012

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

    +112

    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
    switch (SelectedCategory)
                {
                    case "Landscapers":
                        inputSearch.Value = "Landscapers";
                        break;
    
                    case "Baby sitters":
                        inputSearch.Value = "Baby sitters";
                        break;
    
                    case "Doctor":
                        inputSearch.Value = "Doctor";
                        break;
    
                    case "Cleaning services":
                        inputSearch.Value = "Cleaning services";
                        break;
    
                    case "Pet sitters":
                        inputSearch.Value = "Pet sitters";
                        break;
    
                    case "Handyman":
                        inputSearch.Value = "Handyman";
                        break;
    
                    case "Electrical services":
                        inputSearch.Value = "Electrical services";
                        break;
    
                    case "Tutor":
                        inputSearch.Value = "Tutor";
                        break;
    
                    case "Dog walker":
                        inputSearch.Value = "Dog walker";
                        break;
    
                    case "Plumbing":
                        inputSearch.Value = "Plumbing";
                        break;
    
                    case "Caterers":
                        inputSearch.Value = "Caterers";
                        break;
    
                    case "Misc":
                        inputSearch.Value = "Misc";
                        break;
                }

    обычный switch

    mangyst, 30 Мая 2012

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