- 1
https://docs.google.com/forms/d/1mhNCSYPqeLT7pXJEV_BpRkV1sdKJsPdJZcagSafOLVc/viewform
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+124
https://docs.google.com/forms/d/1mhNCSYPqeLT7pXJEV_BpRkV1sdKJsPdJZcagSafOLVc/viewform
Опрос на тему того, кто и как сможет принять участие в разработке аналога говнокода.
+146
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;
}
}
+153
$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");
Мое :( А что делать?
+113
http://habrahabr.ru/post/172129/
«Мне нужен был online-сервис для генерации GUID»
Пожалуйста, подключитесь к интернету, чтобы сгенерировать гуид. Что дальше? Конкатенация строк через RESTful сервер в облаке амазона?
+128
<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 :)
+16
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;
}
}
Бывает, на меня находит состояние "сначала делай, потом думай", благо результат был быстро обнаружен отладчиком.
−105
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
+96
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;
Попытка запретить запуск копии программы. Неудачная.
+14
struct base {
template <class Foo>
base() {}
};
struct derived {
derived()
: base::base<int>() // why not?? WHHYYYY?
{}
};
base b1 = base::base<int>();
base b2<int>();
долбанный комитет
им проще запретить, чем продумать нормальный способ вызова шаблонного конструктора
+12
http://pastebin.com/kG05YmBX
Поиск подстроки в строке, написано однокурсником