- 1
return ((Dirty = (Buff = ((uint8 *)realloc (Buff, BuffLen = new_len))) !=0));
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+60.9
return ((Dirty = (Buff = ((uint8 *)realloc (Buff, BuffLen = new_len))) !=0));
−151.7
SELECT
CASE WHEN Subtask.ParentTask_ID = 1
THEN 0 ELSE CASE WHEN
(
SELECT SUM([Percent]) AS SumOfPercent
FROM Reports GROUP BY Zadanie_ID
HAVING (Zadanie_ID = SubTask.SubTask_ID)) IS NULL
THEN 0 ELSE (SELECT SUM([Percent]) AS SumOfPercent
FROM Reports GROUP BY Zadanie_ID
HAVING (Zadanie_ID = SubTask.SubTask_ID)
) END
END
AS SumOfPercent,
CASE WHEN Subtask.isContinued <> 1
THEN ((persons_1.Baza / 0.25) * (
CASE WHEN Subtask.dateEnding IS NULL
THEN CAST(SubTask.SubTask_EndDate - DATEADD(dd, DATEDIFF(dd, 0, GETDATE()), 0) AS integer)
ELSE CAST(SubTask.SubTask_EndDate - SubTask.DateEnding AS integer)
END -
DATEDIFF(ww, CASE WHEN Subtask.dateending IS NOT NULL THEN Subtask.dateending ELSE getdate() END,
SubTask.SubTask_EndDate) * 2) / 8 * CAST( Priority.Priority_Name AS numeric) / 1000)
ELSE CASE WHEN ((persons_1.Baza / 0.25)* (CASE WHEN Subtask.dateEnding IS NULL THEN
CAST(SubTask.SubTask_EndDate - DATEADD(dd, DATEDIFF(dd, 0, GETDATE()), 0) AS integer)
ELSE CAST(SubTask.SubTask_EndDate - SubTask.DateEnding AS integer)END -
DATEDIFF(ww, CASE WHEN Subtask.dateending IS NOT NULL THEN Subtask.dateending ELSE getdate() END,
SubTask.SubTask_EndDate) * 2)/ 8 * CAST( Priority.Priority_Name AS numeric)/ 1000) > 0 THEN 0
ELSE (persons_1.Baza / 0.25) * (CASE WHEN Subtask.dateEnding IS NULL
THEN CAST(SubTask.SubTask_EndDate - DATEADD(dd, DATEDIFF(dd, 0, GETDATE()), 0) AS integer)
ELSE CAST(SubTask.SubTask_EndDate - SubTask.DateEnding AS integer) END -
DATEDIFF(ww, CASE WHEN Subtask.dateending IS NOT NULL THEN Subtask.dateending ELSE getdate() END,
SubTask.SubTask_EndDate) * 2) / 8 * CAST( Priority.Priority_Name AS numeric) / 1000 END END AS timebonus,
CASE WHEN Subtask.isContinued <> 1 THEN (CASE WHEN (CASE WHEN SubTask.executed = 0
THEN CAST(Subtask.Subtask_EndDate - DATEADD(dd, DATEDIFF(dd, 0, GETDATE()), 0) AS int)
ELSE CAST(Subtask.Subtask_EndDate - Subtask.DateEnding AS int) END >= 0)
THEN (0.40 * (persons_1.Baza * CASE WHEN
(SELECT SUM([Hours]) AS sumHours FROM Reports where (isreal=1) or (isReal=null) GROUP BY Zadanie_ID
HAVING (Zadanie_ID = Subtask.Subtask_ID)) IS NULL THEN 0 ELSE
(SELECT SUM([Hours]) AS sumHours FROM Reports where (isreal=1) or (isReal=null) GROUP BY Zadanie_ID
HAVING (Zadanie_ID = Subtask.Subtask_ID)) END))
* (CAST( Priority.Priority_Name AS numeric) / 1000) ELSE 0 END) ELSE 0 END AS PriorityBonus
...
Я знаю, это трудно понять, но это алгоритм расчета правду о Жизни, Вселенной и Всего Такого. Это SQL выполняется на каждом Login в систему.
+144.9
class SmoothingModeManager
{
public:
SmoothingModeManager(Context* context, Gdiplus::SmoothingMode mode = Gdiplus::SmoothingModeHighQuality);
virtual ~SmoothingModeManager();
protected:
Context* context_;
};
////////////////////////
SmoothingModeManager::SmoothingModeManager(Context* context, Gdiplus::SmoothingMode mode)
: context_(context)
{
context_->getCanvas()->SetSmoothingMode(mode);
}
SmoothingModeManager::~SmoothingModeManager()
{
context_->getCanvas()->SetSmoothingMode(Gdiplus::SmoothingModeNone);
}
Инициализируем класс и контекст со сглаживанием до конца метода.
−154.7
WITH days(num, aday) AS
(
SELECT 1 AS num, 1 AS aday
UNION ALL
SELECT num, aday+1 AS aday FROM days
WHERE days.[aday] < DAY( DATEADD(DAY, -DAY(@date), DATEADD(MONTH, 1 , @date)))
)
SELECT SUM(day1) AS d1, SUM(day2) AS d2, SUM(day3) AS d3, SUM(day4) AS d4, SUM(day5) AS d5, SUM(day6) AS d6, SUM(day7) AS d7, SUM(day8) AS d8,
SUM(day9) AS d9, SUM(day10) AS d10, SUM(day11) AS d11, SUM(day12) AS d12, SUM(day13) AS d13, SUM(day14) AS d14, SUM(day15) AS d15,
SUM(day16) AS d16, SUM(day17) AS d17, SUM(day18) AS d18, SUM(day19) AS d19, SUM(day20) AS d20, SUM(day21) AS d21, SUM(day22) AS d22,
SUM(day23) AS d23, SUM(day24) AS d24, SUM(day25) AS d25, SUM(day26) AS d26, SUM(day27) AS d27, SUM(day28) AS d28, SUM(day29) AS d29,
SUM(day30) AS d30, SUM(day31) AS d31
FROM (SELECT CASE aday WHEN 1 THEN 1 ELSE 0 END AS day1, CASE aday WHEN 2 THEN 2 ELSE 0 END AS day2,
CASE aday WHEN 3 THEN 3 ELSE 0 END AS day3, CASE aday WHEN 4 THEN 4 ELSE 0 END AS day4,
CASE aday WHEN 5 THEN 5 ELSE 0 END AS day5, CASE aday WHEN 6 THEN 6 ELSE 0 END AS day6,
CASE aday WHEN 7 THEN 7 ELSE 0 END AS day7, CASE aday WHEN 8 THEN 8 ELSE 0 END AS day8,
CASE aday WHEN 9 THEN 9 ELSE 0 END AS day9, CASE aday WHEN 10 THEN 10 ELSE 0 END AS day10,
CASE aday WHEN 11 THEN 11 ELSE 0 END AS day11, CASE aday WHEN 12 THEN 12 ELSE 0 END AS day12,
CASE aday WHEN 13 THEN 13 ELSE 0 END AS day13, CASE aday WHEN 14 THEN 14 ELSE 0 END AS day14,
CASE aday WHEN 15 THEN 15 ELSE 0 END AS day15, CASE aday WHEN 16 THEN 16 ELSE 0 END AS day16,
CASE aday WHEN 17 THEN 17 ELSE 0 END AS day17, CASE aday WHEN 18 THEN 18 ELSE 0 END AS day18,
CASE aday WHEN 19 THEN 19 ELSE 0 END AS day19, CASE aday WHEN 20 THEN 20 ELSE 0 END AS day20,
CASE aday WHEN 21 THEN 21 ELSE 0 END AS day21, CASE aday WHEN 22 THEN 22 ELSE 0 END AS day22,
CASE aday WHEN 23 THEN 23 ELSE 0 END AS day23, CASE aday WHEN 24 THEN 24 ELSE 0 END AS day24,
CASE aday WHEN 25 THEN 25 ELSE 0 END AS day25, CASE aday WHEN 26 THEN 26 ELSE 0 END AS day26,
CASE aday WHEN 27 THEN 27 ELSE 0 END AS day27, CASE aday WHEN 28 THEN 28 ELSE 0 END AS day28,
CASE aday WHEN 29 THEN 29 ELSE 0 END AS day29, CASE aday WHEN 30 THEN 30 ELSE 0 END AS day30,
CASE aday WHEN 31 THEN 31 ELSE 0 END AS day31
FROM days) AS col
Думаю в комментариях не нуждается T_T.
−155.2
%words = map { $_ => $hash{$_} } grep { !proper($_) } keys %words;
Фильтрация хэша - удаление элементов, чьи ключи не удовлетворяют некому условию.
Конечно же использование православного for для Perl-истов ниже собственного достоинства.... :X
+72.9
public class CountUnique {
//here objects will be stored
private Object[] variants;
//temporaly array to store copying variants
private Object[] temparr;
private int total = 0;
public CountUnique() {}
public boolean test(Object obj) {
total++;
boolean hasSame = false;
if(variants == null) {
variants = new Object[1];
variants[0] = obj;
hasSame = false;
} else {
for(int i = 0; i < variants.length; i++) {
if(variants[i] == null) {} else {
if(variants[i].equals(obj)) {
hasSame = true;
break;
}
}
}
if(hasSame == false) {
temparr = variants;
variants = new Object[temparr.length+1];
for(int i = 0; i < temparr.length; i++) {
variants[i] = temparr[i];
}
variants[temparr.length] = obj;
temparr = null;
}
}
return hasSame;
}
public int unique() {
if(variants == null) {
return 0;
} else return variants.length;
}
public int total() {
return total;
}
public void free() {
variants = null;
temparr = null;
}
}
некий класс для подсчета уникальных обьектов.
особенно умиляет функция test()
+961.7
int[] a = new int[5];
int i = 0;
foreach (var b in a)
{
a[i] = Convert.ToInt32(Console.ReadLine());
i++;
}
Console.ReadKey();
+157.7
<?php
//fsockopen, fputs..
$content = "";
$header = "not yet";
while( !feof( $pointer ) ) {
$line = fgets( $pointer, 128 );
if( $line == "\r\n" && $header == "not yet" ) {
$header = "passed";
}
if( $header == "passed" ) {
$content .= $line;
}
}
//fclose..
echo( substr( $content, 2 ) );
?>
По просьбе знакомого. Я в этом мало чего понимаю :)
+161.8
$tpl->assign("L_OPENER", ($arr[7] == 40 || $arr[7] == 41 || $arr[7] == 42) ? 'opener.opener' : 'opener');
Вот так в один из шаблонов в зависимости от одного из параметров передаётся сами видите что. Почему так? Потому что бесчётное количество людей переделывали код. По мне, так это уже перебор.
−104.3
# (S) (рекурсивного вызова) Генерирует контент слота рекурсивного дерева (с плюсиками). Возвращает ('RecursiveSlot'=>$textbuf) или ()
sub PlusTreeSlot {
# (P) Путь к шаблону контентной ячейки
# (P) ghm
# (P) pid
# (P) treename
# (P) Уровень
# (P) функция
# (P) $ret
return () if !exists($_[1]->{$_[2]}); # Не вкладываем ничего в слот если там ничего нет
my $textbuf;
foreach (@{$_[1]->{$_[2]}}){
my $ret=&{$_[5]}($_,$_[4],ref($_[6])?dclone($_[6]):$_[6]) if $_[5];
$textbuf.=${tmpl_prepare($_[0],{
PlusTreeSlot($_[0],$_[1],$_->{'id'},$_[3],($_[4]+1),$_[5],$ret),
%{$_},
'trname'=>$_[3],
})};
};
return ('RecursiveSlot'=>$textbuf);
};
А вам тоже нравятся безымянные параметры?
А писать код без пробелов?
Кроме того, эта функция, вызывая себя рекурсивно, каждый раз заново открывает, читает, парсит и закрывает один и тот же файл шаблона.