- 1
- 2
- 3
- 4
- 5
public string ValidationTitle
{
get { return this.Title; }
set { }
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+139
public string ValidationTitle
{
get { return this.Title; }
set { }
}
+129
Margin="0"
mc:Ignorable="d" Margin="0,0,-191,-31" d:DesignHeight="477.612" d:DesignWidth="671.642" >
Это кусочек XAML (WPF). Даже не знаю что сказать, наверное мысли были такие: "Мне нужно именно туда и именно так"
+8
if (dequeueBuffer_) {
delete dequeueBuffer_;
dequeueBuffer_ = NULL;
}
if (enqueueBuffer_) {
delete enqueueBuffer_;
enqueueBuffer_ = NULL;
}
if (readBuff_) {
delete[] readBuff_;
readBuff_ = NULL;
}
if (currentEvent_) {
delete currentEvent_;
currentEvent_ = NULL;
}
Apache Thrift 0.9.1, made in Facebook
Код в деструкторе:
−167
foreach my $ex (@excluded)
{
.....
}
О чем думал, когда имя переменной давал?
+68
StringBuffer serialNum = new StringBuffer ();
for (int i = 0; i < 0; i++)
serialNum = serialNum.append (Byte.toString (serial[ i ]));
+154
var bl = ['Stertor'];
$('li.hentry').each(function(){
var elem = $(this),
against = elem.find('p.vote > a.vote-against'),
who = elem.find('p.author a:nth-child(2)').text();
if(bl.indexOf(who) != -1) {
if(against.length) against.click();
elem.hide();
}
});
"не поленись, пройдись по всем постам, и поставь каждому участнику по минусу;"
Like this?
+34
class A
{
public:
unsigned int m_value;
inline bool operator != ( const A & value )
{
unsigned int temp;
temp = 0 != ( m_value != value.m_value );
return 0 == temp;
}
inline bool operator == ( const A & value )
{
unsigned int temp;
temp = 0 != ( m_value == value.m_value );
return 0 != temp;
}
};
Фрагмент кода одной коммерческой библиотеки. Имя класса изменено, 100500 прочих методов вырезано, но они похожи на эти.
Я не буду акцентировать внимание на том, что операторы невозможно использовать для константных объектов, даже не буду говорить о странном способе сравнения целых чисел... Но я упомяну о том, что 'operator !=' работает немножко не так, как руссо-индусы ожидали.
+12
namespace predicate {
using ...;
typedef boost::function<bool (const object &obj)> bool_func;
typedef boost::function<int (const object &obj)> int_func;
// ... скучные реализации операторов ...
template <class I, class S> struct predicate_grammar :
qi::grammar<I, bool_func(), S>
{
predicate_grammar() : predicate_grammar::base_type(bool_expr)
{
identifier = char_("a-z") >> *(char_("a-z_0-9"));
bool_prop = identifier [ _val = bind(&make_bool_prop_reader, _1, _pass) ];
bool_expr = (bool_expr2 >> "||" >> bool_expr) [ _val = bind(&make_logic_op, &op_or, _1, _2) ]
| bool_expr2 [ _val = _1 ];
bool_expr2 = (bool_expr3 >> "&&" >> bool_expr2) [ _val = bind(&make_logic_op, &op_and, _1, _2) ]
| bool_expr3 [ _val = _1 ];
bool_expr3 = ('(' >> bool_expr >> ')') [ _val = _1 ]
| ('!' >> bool_expr3) [ _val = bind(&make_not, _1) ]
| int_comp [ _val = _1 ]
| bool_prop [ _val = _1];
int_comp = (int_expr >> "<" >> int_expr) [ _val = bind(&make_cmp_op, &op_less, _1, _2) ]
| (int_expr >> "<=" >> int_expr) [ _val = bind(&make_cmp_op, &op_less_eq, _1, _2) ]
| (int_expr >> ">" >> int_expr) [ _val = bind(&make_cmp_op, &op_greater, _1, _2) ]
| (int_expr >> ">=" >> int_expr) [ _val = bind(&make_cmp_op, &op_greater_eq, _1, _2) ]
| (int_expr >> "==" >> int_expr) [ _val = bind(&make_cmp_op, &op_eq, _1, _2) ]
| (int_expr >> "!=" >> int_expr) [ _val = bind(&make_cmp_op, &op_not_eq, _1, _2) ];
int_expr = int_prop [ _val = _1 ]
| int_const [ _val = bind(&make_int_const, _1) ];
int_const = int_ [ _val = _1 ];
int_prop = identifier [ _val = bind(&make_int_prop_reader, _1, _pass) ];
}
qi::rule<I, std::string(), S> identifier;
qi::rule<I, int(), S> int_const;
qi::rule<I, int_func(), S> int_expr, int_prop;
qi::rule<I, bool_func(), S> bool_expr, bool_expr2, bool_expr3, int_comp, bool_prop;
};
boost::function<bool (const object &)> parse(const std::string &src) {
if (src.empty())
return make_bool_const(true);
bool_func p;
std::string::const_iterator b = src.begin(), e = src.end();
predicate_grammar<std::string::const_iterator, boost::spirit::ascii::space_type> grammar;
if (!phrase_parse(b, e, grammar, boost::spirit::ascii::space, p) || b != e) {
std::stringstream s;
s << "Predicate parsing failed at " << (b - src.begin()) << " in \"" << src << "\"";
throw std::runtime_error(s.str());
}
return p;
}
Обещанный в http://govnokod.ru/12936#comment175980 говнокодец с использованием бусто-духа.
+143
$('table.list th').each(function () {
$(this).attr('class', $('> div', this).remove().text()); // хе-хе
});
берем див на первом уровне, удаляем его, читаем с него текст (работает, не ругайтесь) и подставляем его в класс текущему элементу
+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");
Мое :( А что делать?