- 1
- 2
- 3
$('table.list th').each(function () {
$(this).attr('class', $('> div', this).remove().text()); // хе-хе
});
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+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");
Мое :( А что делать?
+155
function alertObj(obj) {
var str = "";
for(k in obj) {
if (typeof obj[k] == "object") {
str += k+":<br />";
for(kk in obj[k]) {
if (typeof obj[k][kk] == "object") {
str += "--"+kk+":<br />";
for(kkk in obj[k][kk]) {
str += "----"+kkk+": "+ obj[k][kk][kkk]+"<br />";
}
} else {
str += "--"+kk+": "+ obj[k][kk]+"<br />";
}
}
} else {
str += k+": "+ obj[k]+"<br />";
}
}
alert(str);
}
Алерт объектов
+113
private int GenerateRandom(int MaxValue)
{
var mas = Guid.NewGuid().ToByteArray();
return BitConverter.ToInt32(mas, 4) % MaxValue;
}
....
+161
function toInt(number) {
return number && + number | 0 || 0;
}
http://ideone.com/igo7ag
Минут 10 назад меня ошарашили фразой о методе toInt(), который, якобы, есть в javascript. Гугл выдал всего одну ссылочку, в которой говорится о нем: http://javascript.ru/forum/misc/22100-funkciya-toint-razyasnite-pozhalujjsta-neskolko-momentov.html. Увидев данный код, я просто не мог не выложить его сюда.
+41
....
<table border="0" cellspacing="0" cellpadding="1">
<tr>
<td width="45%" valign="top">
<?if($arResult["AUTH"]["new_user_registration"]=="Y"):?>
<b><?echo GetMessage("STOF_2REG")?></b>
<?endif;?>
</td>
<td width="10%"> </td>
<td width="45%" valign="top">
<?if($arResult["AUTH"]["new_user_registration"]=="Y"):?>
<b><?echo GetMessage("STOF_2NEW")?></b>
<?endif;?>
</td>
</tr>
<tr>
....
наткнулся в Битриксе, в шаблоне стандартного компонента sale.order.full
Видимо не судьба одной проверкой <?if($arResult["AUTH"]["new_user_registration"]=="Y"):?> исключить всю строку <tr>...</tr>
+165
function findeFreePlace()
{
try
{
var x = random(gs.cells.x - 1),
y = random(gs.cells.y - 1);
if (gs.balls[y][x] != null)
{
return findeFreePlace();
}
else
{
return [x, y];
}
}
catch (e)
{
isEndGame = true;
showfinish();
return false;
}
}
Игра "линии". Нужно случайно выбрать клеточку, в которую будет добавлен новый шарик. Ну, а чтобы узнать, что пустых клеточек нет, ловим ошибку переполнения стека.
+34
int main()
try
{
}
catch (...)
{
}
http://ideone.com/luh8p
+131
o?o.f():{};
Мне было стыдно постить это в С++.
http://www.gamedev.ru/flame/forum/?id=167142&page=2#m25
+22
string toString( int i ) {
stringstream s;
s << i;
return s.str();
}
Наткнулся на эту функцию в одном из своих старых проектом.