- 1
Лошади уже здесь.
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+142
Лошади уже здесь.
−123
select ...
case
-- периоды пересекаются только в одной точке (2)
when (vw.hEndDate=vw.rStartDate)
then vw.hEndDate
when (vw.rEndDate=vw.hStartDate)
then vw.rEndDate
-- периоды пересекаются в определенной области (2)
when (vw.hStartDate > vw.rstartdate and IsNull(vw.hEndDate,'01-01-2099')<IsNull(vw.rEndDate,'01-01-2099')) then vw.hStartDate
when ((vw.rStartDate between vw.hStartDate and vw.hEndDate) and (vw.hEndDate between vw.rStartDate and vw.rEndDate))
then vw.rStartDate
when ((vw.hStartDate between vw.rStartDate and vw.rEndDate) and (vw.rEndDate between vw.hStartDate and vw.hEndDate))
then vw.hStartDate
-- периоды полностью совпадают (1)
when (vw.hStartDate=vw.rStartDate and vw.hEndDate=vw.rEndDate)
then vw.hStartDate
-- периоды совпадают в одной точке и перекрываются (4)
when (vw.hStartDate=vw.rStartDate and vw.rEndDate<vw.hEndDate)
then vw.hStartDate
when (vw.hStartDate=vw.rStartDate and vw.hEndDate<vw.rEndDate)
then vw.hStartDate
when (vw.hEndDate=vw.rEndDate and vw.rStartDate>vw.hStartDate)
then vw.rStartDate
when (vw.hEndDate=vw.rEndDate and vw.rStartDate<vw.hStartDate)
then vw.hStartDate
end as MainStartDate
,case
-- периоды пересекаются только в одной точке (2)
when (vw.hEndDate=vw.rStartDate)
then vw.hEndDate
when (vw.rEndDate=vw.hStartDate)
then vw.rEndDate
-- периоды пересекаются в определенной области (2)
when (vw.hStartDate > vw.rstartdate and IsNull(vw.hEndDate,'01-01-2099')<IsNull(vw.rEndDate,'01-01-2099')) then vw.hEndDate
when ((vw.rStartDate between vw.hStartDate and vw.hEndDate) and (vw.hEndDate between vw.rStartDate and vw.rEndDate))
then vw.hEndDate
when ((vw.hStartDate between vw.rStartDate and vw.rEndDate) and (vw.rEndDate between vw.hStartDate and vw.hEndDate))
then vw.rEndDate
-- периоды полностью совпадают (1)
when (vw.hStartDate=vw.rStartDate and vw.hEndDate=vw.rEndDate)
then vw.hEndDate
-- периоды совпадают в одной точке и перекрываются (4)
when (vw.hStartDate=vw.rStartDate and vw.rEndDate<vw.hEndDate)
then vw.rEndDate
when (vw.hStartDate=vw.rStartDate and vw.hEndDate<vw.rEndDate)
then vw.hEndDate
when (vw.hEndDate=vw.rEndDate and vw.rStartDate>vw.hStartDate)
then vw.hEndDate
when (vw.hEndDate=vw.rEndDate and vw.rStartDate<vw.hStartDate)
then vw.hEndDate
end as MainEndDate
from (select ...
case when (IsNull(h.[EndDate],'01-01-2099')=r.[StartDate]) then '1 периоды пересекаются только в одной точке (2) h.[EndDate]=r.[StartDate]'
when(IsNull(r.[EndDate],'01-01-2099')=h.[StartDate]) then '2 периоды пересекаются только в одной точке (2) r.[EndDate]=h.[StartDate]'
-- периоды пересекаются в определенной области (2)
when (h.startdate > r.startdate and IsNull(h.[EndDate],'01-01-2099')<IsNull(r.[EndDate],'01-01-2099')) then 'Период иерархии полностью входит в период территории'
when((r.StartDate between h.StartDate and IsNull(h.[EndDate],'01-01-2099')) and (IsNull(h.[EndDate],'01-01-2099') between r.StartDate and IsNull(r.[EndDate],'01-01-2099'))) then 'периоды пересекаются в определенной области (2) 3 ((r.StartDate between h.StartDate and IsNull(h.[EndDate],01-01-2099)) and (IsNull(h.[EndDate],01-01-2099) between r.StartDate and r.EndDate))'
when((h.startdate between r.startdate and IsNull(r.[EndDate],'01-01-2099')) and (IsNull(r.[EndDate],'01-01-2099') between h.Startdate and IsNull(h.[EndDate],'01-01-2099'))) then 'периоды пересекаются в определенной области (2) 4 ((h.startdate between r.startdate and r.enddate) and (r.EndDate between h.Startdate and IsNull(h.[EndDate],01-01-2099)))'
-- периоды полностью совпадают (1)
when(h.startdate=r.startdate and IsNull(h.[EndDate],'01-01-2099')=IsNull(r.[EndDate],'01-01-2099')) then 'периоды полностью совпадают (1) 5 (h.startdate=r.startdate and IsNull(h.[EndDate],01-01-2099)=r.enddate)'
-- периоды совпадают в одной точке и перекрываются (4)
when(h.startdate=r.startdate and IsNull(r.[EndDate],'01-01-2099')<IsNull(h.[EndDate],'01-01-2099')) then 'периоды совпадают в одной точке и перекрываются (4) 6 (h.startdate=r.startdate and r.enddate<IsNull(h.[EndDate],01-01-2099))'
when(h.startdate=r.startdate and IsNull(h.[EndDate],'01-01-2099')<IsNull(r.[EndDate],'01-01-2099')) then 'периоды совпадают в одной точке и перекрываются (4) 7 (h.startdate=r.startdate and IsNull(h.[EndDate],01-01-2099)<r.enddate)'
when(IsNull(h.[EndDate],'01-01-2099')=IsNull(r.[EndDate],'01-01-2099') and r.startdate>h.startdate) then 'периоды совпадают в одной точке и перекрываются (4) 8 (IsNull(h.[EndDate],01-01-2099)=r.enddate and r.startdate>h.startdate)'
when(IsNull(h.[EndDate],'01-01-2099')=IsNull(r.[EndDate],'01-01-2099') and r.startdate<h.startdate) then 'периоды совпадают в одной точке и перекрываются (4) 9 (IsNull(h.[EndDate],01-01-2099)=r.enddate and r.startdate<h.startdate)'
... where ...
(IsNull(h.[EndDate],'01-01-2099')=r.[StartDate])
or (IsNull(r.[EndDate],'01-01-2099')=h.[StartDate])
-- периоды пересекаются в определенной области (2)
or ((r.StartDate between h.StartDate and IsNull(h.[EndDate],'01-01-2099')) and (IsNull(h.[EndDate],'01-01-2099') between r.StartDate and IsNull(r.[EndDate],'01-01-2099')))
or ((h.startdate between r.startdate and IsNull(r.[EndDate],'01-01-2099')) and (IsNull(r.[EndDate],'01-01-2099') between h.Startdate and IsNull(h.[EndDate],'01-01-2099')))
or (h.startdate > r.startdate and IsNull(h.[EndDate],'01-01-2099')<IsNull(r.[EndDate],'01-01-2099'))
-- периоды полностью совпадают (1)
or (h.startdate=r.startdate and IsNull(h.[EndDate],'01-01-2099')=IsNull(r.[EndDate],'01-01-2099'))
-- периоды совпадают в одной точке и перекрываются (4)
or (h.startdate=r.startdate and IsNull(r.[EndDate],'01-01-2099')<IsNull(h.[EndDate],'01-01-2099'))
or (h.startdate=r.startdate and IsNull(h.[EndDate],'01-01-2099')<IsNull(r.[EndDate],'01-01-2099'))
or (IsNull(h.[EndDate],'01-01-2099')=IsNull(r.[EndDate],'01-01-2099') and r.startdate>h.startdate)
or (IsNull(h.[EndDate],'01-01-2099')=IsNull(r.[EndDate],'01-01-2099') and r.startdate<h.startdate)
я даже знать не хочу, что в этом запросе на 140 строк происходит, и молю богу, чтобы это не ломалось, пока автор этого в декрете.
форматирование убрал, а то в 6к символов не помещался
отформатировать можно тут http://poorsql.com/
−128
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
gradle wrapper
+134
/* A C statement or statements which output an assembler instruction
opcode to the stdio stream STREAM. The macro-operand PTR is a
variable of type `char *' which points to the opcode name in its
"internal" form--the form that is written in the machine description.
GAS version 1.38.1 doesn't understand the `repz' opcode mnemonic.
So use `repe' instead. */
#undef ASM_OUTPUT_OPCODE
#define ASM_OUTPUT_OPCODE(STREAM, PTR) \
{ \
if ((PTR)[0] == 'r' \
&& (PTR)[1] == 'e' \
&& (PTR)[2] == 'p') \
{ \
if ((PTR)[3] == 'z') \
{ \
fputs ("repe", (STREAM)); \
(PTR) += 4; \
} \
else if ((PTR)[3] == 'n' && (PTR)[4] == 'z') \
{ \
fputs ("repne", (STREAM)); \
(PTR) += 5; \
} \
} \
else \
ASM_OUTPUT_AVX_PREFIX ((STREAM), (PTR)); \
}
Костыль из GCC. Ассемблер GAS версии 1.38.1 не переваривает мнемоники repz и repnz. Эта макрохрень перекодирует их в repe и repne соответственно
https://github.com/mirrors/gcc/blob/master/gcc/config/i386/gas.h#L81
+153
public function getPagination($page, $rows, $limit){
$pageArray = array();
if ($rows > $limit){
$allPage = ceil($rows/$limit);
if ($allPage <= 7){
for ($i=1;$i<=$allPage;$i++){$pageArray[]=$i;}
}else{
if ($page < 5){
for ($i=1;$i<=($page+3);$i++){$pageArray[]=$i;}
$pageArray[]=$allPage;
}else{
if ($allPage <= ($page+3)){
$pageArray[]=1;
for ($i=($page-3);$i<=$allPage;$i++){$pageArray[]=$i;}
}else{
$pageArray[]=1;
for ($i=($page-3);$i<=($page+3);$i++){$pageArray[]=$i;}
$pageArray[]=$allPage;
}
}
}
return array(
'pages' => $pageArray,
'page' => $page
);
}else{
return array(
'pages' => 1,
'page' => $page
);
}
}
My friend wrote pagination function. takes current page, number of rows (from query), and limit on each page. function works really good but :D govno kod :D
+69
public void startApp() {
StringItem si = new StringItem("Some label","Some text");
try{
Image img = Image.createImage("/res/path/to/image.gif");
FORM.append(img);
}catch (java.io.IOException ioe){
ioe.printStackTrace();
}
FORM.append(si);
DISPLAY.setCurrent(FORM);
}
Wtf?
http://www.gfs-team.ru/articles/read/107
−131
protected function ignite(event:FlexEvent):void {
imgCooser.dataProvider = new ArrayList([new ObjectProxy({w:Math.round(Math.random()*100+55),t:'0 one'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'1 two'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'2 three'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'3 four'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'4 five'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'5 six'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'6 seven'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'7 eight'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'8 nine'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'9 ten'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'10 eleven'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'11 twelve'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'12 one'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'13 two'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'14 three'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'2 three'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'3 four'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'4 five'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'5 six'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'6 seven'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'7 eight'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'8 nine'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'9 ten'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'10 eleven'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'11 twelve'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'12 one'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'13 two'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'14 three'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'1 two'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'2 three'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'3 four'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'4 five'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'5 six'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'6 seven'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'7 eight'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'8 nine'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'9 ten'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'10 eleven'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'11 twelve'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'12 one'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'13 two'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'14 three'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'2 three'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'3 four'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'4 five'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'5 six'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'6 seven'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'7 eight'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'8 nine'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'9 ten'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'10 eleven'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'11 twelve'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'12 one'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'13 two'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'14 three'}),
new ObjectProxy({w:Math.round(Math.random()*100+55),t:'15 four'})]);
От нечего делать сижу и перебираю коммиты в репозитории, вот наткнулся...
−136
public function TweenMax(target:Object, duration:Number, vars:Object) {
super(target, duration, vars);
if (TweenLite.version < 11.2) {
throw new Error("TweenMax error! Please update your TweenLite class or try deleting your ASO files. TweenMax requires a more recent version. Download updates at http://www.TweenMax.com.");
}
Тут нужно дополнительно подчеркнуть, что оба класса TweenMax и TweenLite распространяются вместе, и случайно получить несоответствующую версию очень тяжело (ее надо самому поменять).
Но самое интересное в другом: ASO файлы - это артефакт механизма кеширования использовавшегося в AS2. В AS3 механизм кеширования другой, и об этих файлах давным-давно никто не слышал. Тем не менее, сообщение об ошибке по прежнему предлагает пользователям с ними побороться.
−407
//
// @property (nonatomic, strong) NSString *name; @property (nonatomic, strong) NSString *name;.m
// Govnocode
//
// Created by Khrishna on 28/03/14.
// Copyright (c) 2014 Khrishna Ravi. All rights reserved.
//
#import "@property (nonatomic, strong) NSString *name; @property (nonatomic, strong) NSString *name;.h"
@implementation _property__nonatomic__strong__NSString__name___property__nonatomic__strong__NSString__name_
@end
Безжалостные русские индусы
+11
float fNumber;
//...
//Куча бреда
//...
if(fNumber == +0)
cout << "Неверно.;
else if(fNumber == -0)
cout << "Неверно.;
else if(fNumber < +0 && fNumber > -0)
cout << "У вас неправильная система счисления.";
else{
//...
}