- 1
- 2
- 3
- 4
- 5
- 6
- 7
void operator()()
{
for (std::list<SmartPointer<FunctorTriggerParent > >::iterator it = _listFunctorOnTrigger.begin(); it != _listFunctorOnTrigger.end(); ++it)
{
(*it)->operator ()();
}
};
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+10
void operator()()
{
for (std::list<SmartPointer<FunctorTriggerParent > >::iterator it = _listFunctorOnTrigger.begin(); it != _listFunctorOnTrigger.end(); ++it)
{
(*it)->operator ()();
}
};
+154
class Icon extends IconBuilder
{
public static function create($type, $white = false)
{
$class = __CLASS__;
return new $class($type, $white);
}
public function getType()
{
return $this->_type;
}
public function getWhite()
{
return $this->_white;
}
}
Код выдернут из Bootstrap.PHP http://allking.ru/bootstrap.php/
Особое внимание уделить функции create и константе __CLASS__
Вопрос: почему не обойтись просто self? В чем магия?
З.Ы.: Пока писал, нашел в доках, что "волшебная" константа содержит так же пространство имен.
Извиняюсь, что не узнал об этом раньше.
Но я все же наложу сюда, с вопросом, даже учитывая всю эту информацию, почему мы не можем обойтись способами, исключающими использование константы?
(все равно получается говнокод, хоть и работающий)
+159
$st=$_GET['st'];
// проверяем допустимый номер категории
if ((((((($st != "1")&($st != "2"))&($st != "3"))&($st != "4"))&($st != "5"))&($st != "6")&($st != "7")&($st != "8")&($st != "0"))) {$st="0";};
// Гениальная реализация отношения многие-ко-многим - по флагу на каждый номер категории, проверяем какой флаг установлен
$zapros = "
SELECT
product.cod,
product.`name`,
sector.s0,
sector.s1,
sector.s2,
sector.s3,
sector.s4,
sector.s5,
sector.s6,
sector.s7,
sector.s8
FROM
product ,
sector
WHERE
product.cod = sector.cod AND sector.s".$st."=1
ORDER BY
product.id ASC
";
Вот такой код мне попался в самописном магазине, который заказали доработать (
+158
$(document).ready(function () {
$("#FollowingChoicesWebpart-ProjectsAndCommunities").hide();
$("#FollowingChoicesWebpart-Sites").hide();
$("#FollowingChoicesWebpart-News").show();
});
$("#FChoices_tab1").click(function () {
$("#FollowingChoicesWebpart-ProjectsAndCommunities").hide();
$("#FollowingChoicesWebpart-Sites").hide();
$("#FollowingChoicesWebpart-News").show();
$("#FChoices_tab1").addClass("active-button_FChoices");
$("#FChoices_tab2").removeClass("active-button_FChoices");
$("#FChoices_tab3").removeClass("active-button_FChoices");
});
$("#FChoices_tab2").click(function () {
$("#FollowingChoicesWebpart-ProjectsAndCommunities").hide();
$("#FollowingChoicesWebpart-Sites").show();
$("#FollowingChoicesWebpart-News").hide();
$("#FChoices_tab1").removeClass("active-button_FChoices");
$("#FChoices_tab2").addClass("active-button_FChoices");
$("#FChoices_tab3").removeClass("active-button_FChoices");
});
$("#FChoices_tab3").click(function () {
$("#FollowingChoicesWebpart-ProjectsAndCommunities").show();
$("#FollowingChoicesWebpart-Sites").hide();
$("#FollowingChoicesWebpart-News").hide();
$("#FChoices_tab1").removeClass("active-button_FChoices");
$("#FChoices_tab2").removeClass("active-button_FChoices");
$("#FChoices_tab3").addClass("active-button_FChoices");
});
$("#FChoices_tab3").click(function () {
$("#FollowingChoicesWebpart-ProjectsAndCommunities").hide();
$("#FollowingChoicesWebpart-Sites").hide();
$("#FollowingChoicesWebpart-News").hide();
$("#FChoices_tab1").removeClass("active-button_FChoices");
$("#FChoices_tab2").removeClass("active-button_FChoices");
$("#FChoices_tab3").addClass("active-button_FChoices");
});
Голландский джаваскриптик для реализации функционала Tabs. Видимо, написано под кумаром)))
+68
// setting simple fields that couldn't be null
if (firstOperDay != null) {
dto.setFirstClosedDay(firstOperDay);
} else {
dto.setFirstClosedDay(null);
}
if (lastOperDay != null) {
dto.setLastClosedDay(lastOperDay);
} else {
dto.setLastClosedDay(null);
}
+70
private boolean isVincodeDisabled() {
if (Long.valueOf(PaymentValidationStatus.vin_code_incorrect.getValue()).equals(paymentDTO.getErrorCode())) {
return false;
} else if (paymentDTO.getVincode() == null) {
return true;
} else {
return false;
}
}
+115
#define TEN 10
#define TEEN 100
#define TEEEN 1000
+137
int memcmp (const void* v1, const void* v2, size_t n)
{
uint32_t *s1;
uint32_t *s2;
size_t i;
s1 = (uint32_t*) v1;
s2 = (uint32_t*) v2;
for (i = 0; i < n; i++) {
if (*s1 != *s2) {
return *(const uint32_t *)s1 >
*(const uint32_t *)s2 ? 1 : -1;
}
s1++;
s2++;
}
return 0;
}
Реализация memcmp в библиотеке одной малоизвестной "учебной" ОС реального времени. Учебной в том смысле, что по этой системе разве что доклады, презентации и статьи делали, где-то реально она вряд ли использовалась.
Для интересующихся http://pok.safety-critical.net/
−122
- (void)_syncThread:(NSDictionary*)args
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
ERFeedStatusDB *feedStatusDB;
NSError *error = nil;
[self retain];
// Open FeedStatusDB
feedStatusDB = [[ERFeedStatusDB alloc] init];
if (![feedStatusDB openWithPath:[args objectForKey:ERFeedStatusDBSyncFilePathKey] error:&error])
goto error;
// Perform the sync
NSAutoreleasePool *pool2 = [[NSAutoreleasePool alloc] init]; // workaround for SQLITE_BUSY issue during -[feedStatusDB close] call
// (autoreleased objects are sticking around that keep the DB locked)
[self performSyncOnBackgroundThreadWithParams:[args objectForKey:ERFeedStatusDBSyncParamsDictKey] feedStatusDB:feedStatusDB];
[pool2 release];
[feedStatusDB close];
[feedStatusDB release];
feedStatusDB = nil;
[self _setExecuting:NO];
[_executingCondition lock];
[_executingCondition signal];
[_executingCondition unlock];
[self release];
[pool release];
return;
error:
[self notifyDelegateOfFailureWithError:error];
[feedStatusDB close];
[feedStatusDB release];
feedStatusDB = nil;
[self _setExecuting:NO];
[_executingCondition lock];
[_executingCondition signal];
[_executingCondition unlock];
[self release];
[pool release];
}
Авторелиз пулы. Goto. [self retain] и [self release]. NSLock. Все это в кастомной реализации NSOperation.
Код выносит прогулки по базе в бэкграунд. Другого способа, видать, не нашлось.
+80
new