1. Куча / Говнокод #12721

    +124

    1. 1
    https://docs.google.com/forms/d/1mhNCSYPqeLT7pXJEV_BpRkV1sdKJsPdJZcagSafOLVc/viewform

    Опрос на тему того, кто и как сможет принять участие в разработке аналога говнокода.

    scriptin, 10 Марта 2013

    Комментарии (101)
  2. PHP / Говнокод #12720

    +146

    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 User {
    
      protected $login;
      protected $password;
      protected $email;
    
      public function __construct($login, $password, $email) {
        $this->login = $login;
        $this->password = $password;
        $this->email = $email;
      }
    
      public function __get($name) {
        $reflector = new ReflectionClass($this);
        return $reflector->hasProperty($name) ? $this->{$name} : null;
      }
    
    }

    __proto__, 10 Марта 2013

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

    +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
    $statement = $pdo->prepare(
         "if not exists
          (select daily_serving_start, daily_serving_end,
                  weekly_service_off, one_time_service_off
          from menu_availability_rules
          where
            (daily_serving_start = :start0 or
             (daily_serving_start is null and :start1 is null)) and
            (daily_serving_end = :end0 or
             (daily_serving_end is null and :end1 is null)) and
            (weekly_service_off = :weekly0 or
             (weekly_service_off is null and :weekly1 is null)) and
            (one_time_service_off = :once0 or
             (one_time_service_off is null and :once1 is null)))
          begin
            insert into menu_availability_rules
             (daily_serving_start, daily_serving_end,
              weekly_service_off, one_time_service_off)
            values (:start2, :end2, :weekly2, :once2)
          end
    
          if not exists
          (select menu_id, daily_serving_start, daily_serving_end,
                  weekly_service_off, one_time_service_off
          from menu_availability
          where
           menu_id = :menu_id0 and
           (daily_serving_start = :start3 or
             (daily_serving_start is null and :start4 is null)) and
            (daily_serving_end = :end3 or
             (daily_serving_end is null and :end4 is null)) and
            (weekly_service_off = :weekly3 or
             (weekly_service_off is null and :weekly4 is null)) and
            (one_time_service_off = :once3 or
             (one_time_service_off is null and :once4 is null)))
          begin
            insert into menu_availability
             (menu_id, daily_serving_start, daily_serving_end,
              weekly_service_off, one_time_service_off)
            values (:menu_id1, :start5, :end5, :weekly5, :once5)
          end");

    Мое :( А что делать?

    wvxvw, 10 Марта 2013

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

    +113

    1. 1
    http://habrahabr.ru/post/172129/

    «Мне нужен был online-сервис для генерации GUID»

    Пожалуйста, подключитесь к интернету, чтобы сгенерировать гуид. Что дальше? Конкатенация строк через RESTful сервер в облаке амазона?

    vse_govno, 10 Марта 2013

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

    +128

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <style>
    a img, input, #hndl-show-loginpass-fields, .checkout_buttons, #shipping-method-7, #shipping-method-6, #shipping-method-5,  #shipping-method-4,  #shipping-method-3, #shipping-method-2, #shipping-method-1, #payment-method-7, #payment-method-6, #payment-method-5, #payment-method-4, #payment-method-3, #payment-method-2, #payment-method-1, #payment-method-8, #payment-method-9, #payment-method-12
    {
    	border: 0;
    }
    </style>

    Отрыл в проекте заказчика вот такую строчку CSS :)

    invision70, 10 Марта 2013

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

    +16

    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
    class Context;
    
    class AbstractState
    {
    	Context * m_context;
    
    protected:
    	Context * context() const { return m_context; }
    
    public:
    	AbstractState(Context * context) : m_context(context) { };
    	virtual ~AbstractState() { }
    	virtual void doSomething() = 0;
    };
    
    class Context
    {
    	std::unique_ptr<AbstractState> m_state;
    
    public:
    	enum State
    	{
    		State1,
    		State2,
    	};
    	Context() { switchToState(State1); }
    	void switchToState(State newState);
    	void doSomething() { m_state->doSomething(); }
    	void someCleanup() { }
    };
    
    class ConcreteState1 : public AbstractState
    {
    public:
    	ConcreteState1(Context * context) : AbstractState(context) { }
    	virtual void doSomething()
    	{
    		context()->switchToState(Context::State2);
    		context()->someCleanup();
    	}
    };
    
    class ConcreteState2 : public AbstractState
    {
    public:
    	ConcreteState2(Context * context) : AbstractState(context) { }
    	virtual void doSomething()
    	{
    		context()->switchToState(Context::State1);
    		context()->someCleanup();
    	}
    };
    
    void Context::switchToState(State newState)
    {
    	switch(newState)
    	{
    	case State1:
    		m_state.reset(new ConcreteState1(this));
    		return;
    	case State2:
    		m_state.reset(new ConcreteState2(this));
    		return;
    	}
    }

    Бывает, на меня находит состояние "сначала делай, потом думай", благо результат был быстро обнаружен отладчиком.

    Xom94ok, 10 Марта 2013

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

    −105

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    def f(x):
        return x.strip()
    
    lines = map(f, open("1.txt", "r"))
    open("1.txt", "w").write(" ".join(lines))

    ХАСКЕЛЕПРОБЛЕМЫ™. Теперь и в питоне.

    Исходный файл содержит 3 строчки:

    just
    as
    planned
    Питон 2.7:
    $ python2.7 1.py
    $ cat 1.txt
    just as planned
    Питон 3.0:
    $ python3.2 1.py
    $ cat 1.txt

    bormand, 09 Марта 2013

    Комментарии (42)
  8. Pascal / Говнокод #12714

    +96

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    procedure TForm1.FormCreate(Sender: TObject);
    var formattedDateTime : string; S: TSearchRec; sf : Int64;
    begin
      Application.OnException := MyHandler;
      if IsRunningEXEName(ExtractFileName(Application.ExeName)) = true then
      begin
        Application.Terminate;
        Exit;
      end;

    Попытка запретить запуск копии программы. Неудачная.

    increazon, 09 Марта 2013

    Комментарии (26)
  9. C++ / Говнокод #12713

    +14

    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
    struct base {
       template <class Foo>
    	base() {}
    };
    
    struct derived {
    	derived()
    		: base::base<int>()		// why not?? WHHYYYY?
    	{}
    };
    
    base b1 = base::base<int>();
    base b2<int>();

    долбанный комитет
    им проще запретить, чем продумать нормальный способ вызова шаблонного конструктора

    defecate-plusplus, 09 Марта 2013

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

    +12

    1. 1
    http://pastebin.com/kG05YmBX

    Поиск подстроки в строке, написано однокурсником

    jQuery, 09 Марта 2013

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