- 1
$where = str_replace("post_status = 'publish'","post_status = 'publish' OR post_status = 'future' OR post_status = 'draft' OR post_status = 'inherit'", $where);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+56
$where = str_replace("post_status = 'publish'","post_status = 'publish' OR post_status = 'future' OR post_status = 'draft' OR post_status = 'inherit'", $where);
Wordpress. Govnocode is poetry
+128
rotate n xs = b ++ a
where n' = n `mod` (length xs)
(a, b) = splitAt ((length xs) - n') xs
rotateAmount xs = _ra 0 ((length xs) - 1) (listArray (0, ((length xs) - 1)) xs)
where _ra s e ys = if (e - s) == 1
then (if ((ys ! s) < (ys ! e)) then s else e) -- base case
else let h = ys ! s -- first item
l = ys ! e -- last item
mi = s + ((e - s) `div` 2) -- middle index
m = ys ! mi -- middle item
in if (h < l)
then s -- return start index
else if (h > m)
then _ra s mi ys
else _ra mi e ys
A “rotated array” is an array of integers in ascending order, after which for every element i, it has been moved to element (i + n) mod sizeOfList. Write a function that takes a rotated array and, in less-than-linear time, returns n (the amount of rotation). http://techguyinmidtown.com/2008/07/05/my-answers-to-the-microsoft-interview-questions
+70
$device->logicalDevices = $device->getLogicalDevices();
ООП, такой ООП.
+66
$pr = array();
foreach ($params as $k => $v)
$pr[] .= urlencode($k).'='.urldecode($v);
$data = join('&', $pr);
http_build_query() для слабаков! Только велосипеды, только выстрел себе в ногу.
/netcat/admin/nc_adminnotice.class.php
+138
code = _factorCodeMax[factorUnid];
code++;
_factorCodeMax[factorUnid] = code;
return code;
+23
QHash<QByteArray, QSharedPointer<KeywordAnalyzerResult::Statistics> >::const_iterator i = res.result()->constBegin();
Создание STL-style итератора для Qt-ных контейнеров обычно выглядит уродски.
+58
if (!$output) {
$output = 'R0lGODlhMAAQAPUuALV7Z6p9ZkUiDkEhDIpMPSgcC2pAMFI9ibSEbZxpTP///7uJciodDTMkEYNVO7eCcpZfQJBeQ5xjRkIdCsaWgL2OdL';
$output .= '6IbL2OcqJqRyweDj8qFXpOMy8fDyQYCC8gDUIqEiYaCraJbL2Lco9ePoBTNG1DKpxyXK2AbbN7Yqx2WjQlEoFTOW9FLCseDQAAAAAAAAA';
$output .= 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C1hNUCBEYXRhWE1QRD94cDIzRThDRkQwQzcyIiB4';
$output .= 'bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOkU2RTVBQzAwMDFwYWNrZXQgZW5kPSJyIj8+ACH5BAUAAC4ALAAAAAAwABAAQAZkQJdwSCwaj';
$output .= '8ik0uVpcQodUIuxrFqv2OwRoTgAFgdFQEsum8/ocit0oYgqKVVaG4EMCATBaDXv+/+AgYKDVS2GDR8aGQWESAEIAScmCwkJjUcSKA8GBh';
$output .= 'YYJJdGLCUDEwICDhuEQQA7';
$output = base64_decode($output);
}
Хранение картинки прямо в PHP коде.
+72
private String getMessage(String prop, boolean suffixEnabled) {
String title = null;
if (prop.equals("headerTitle.suffix")) {
try {
title = messageSource.getMessage("headerTitle.suffix", null, locale);
} catch (NoSuchMessageException e) {
//e.printStackTrace();
}
if (title == null)
title = "";
} else {
try {
title = messageSource.getMessage(prop, null, locale);
if (suffixEnabled)
title += " " + messageSource.getMessage("headerTitle.suffix", null, locale);
} catch (NoSuchMessageException e) {
//e.printStackTrace();
}
if (title == null) {
try {
title = messageSource.getMessage("headerTitle.default", null, locale);
} catch (NoSuchMessageException ex) {
title = "";
}
}
}
return title;
}
+60
$action = $_POST['action'];
$function = "ajax_{$action}";
if (!function_exists($function)) die("<b>Указанного действия не существует</b>");
call_user_func($function);
Что передали, то и выполнили.
+139
var priorities = Repository.Get<IIncidentPriority>().Query().OrderBy(x => x.Priority)
.Select(x => new InputItem { Id = x.Id.ToString(CultureInfo.InvariantCulture), Value = x.LocalizationValue })
.ToList();
priorities.Add(new InputItem { Id = "-1", Value = Localizator.Get("X4.Incident.Undefined") });
priorities.Reverse();
тру хацкеры презирают метод Insert )