- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
function checked(obj) {
var undefined;
obj = '#'+obj;
if ($(obj+':checked').attr('id') == undefined) {
return 0;
}
else {
return 1;
}
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+151
function checked(obj) {
var undefined;
obj = '#'+obj;
if ($(obj+':checked').attr('id') == undefined) {
return 0;
}
else {
return 1;
}
}
можно встретить и такое
+139
<?php
function string_size($string){
$temporary_file = md5(rand().rand()).".temporary";
$a=fopen($temporary_file,"w+");
fwrite($a,$string);
$size = filesize($temporary_file);
fclose($a);
unset($temporary_file);
return $size;
}
?>
Аналог функции filesize() для строк.
+76
public static final String RANDOM_VALUE_QUERY = "select to_number(to_char(dbms_random.value(100,999),'999'),'999') from dual";
Прогрессивный способ генерации случайных чисел=.
+127
<form action="/b/wakaba.pl" method="post" enctype="multipart/form-data">
<input type="hidden" name="task" value="search" />
<input id="dynamicNamed" name="scommsubj" value="" type="text" placeholder="Поиск" required />
<select>
<option id="opt0" value="scommsubj">везде</option>
<option id="opt1" value="searchsubj">в любом заголовке</option>
<option id="opt2" value="searchcomm">в любом сообщении</option>
<option id="opt3" value="tscommsubj">в главном посте треда</option>
<option id="opt4" value="tsearchsubj">в главном заголовке треда</option>
<option id="opt5" value="tsearchcomm">в главном сообщении треда</option>
</select>
<input type="submit" value="GO" onclick="javascript: buttonOK(); this.submit;" />
</form>
function buttonOK()
{
$id('dynamicNamed').name = $id('opt' + select.selectedIndex).value;
}
Сосач.
Новое слово в передаче параметров.
+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;
}
}
Бывает, на меня находит состояние "сначала делай, потом думай", благо результат был быстро обнаружен отладчиком.