-
Лучший говнокод
- В номинации:
-
- За время:
-
-
+115.4
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
public partial class AbstractPickerBrw : Form
{
//...
public AbstractPickerBrw ()
{
this.Shown += new System.EventHandler(this.AbstractPickerBrw_Shown);
}
//...
private void AbstractPickerBrw_Shown(object sender, System.EventArgs e)
{
Width = Width % 2 == 0 ? Width + 1 : Width - 1;
}
}
Это мой код, просто не мог добиться перерисовки диалога при смене данных в WinForms и решил не заморачиваться.
xaoc,
01 Апреля 2010
-
+74
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
lstCmsObject = OpenCms.getOrgUnitManager().getGroups(obj, "/", true);
for (int i = 0; i < lstCmsObject.size(); i++)
{
lstUnits.add(new Units(lstCmsObject.get(i).getDisplayName(obj, Locale.US).replaceAll("Users from ","").replaceAll("[a-zA-Z]*","").replaceAll("[(/)]+",""),lstCmsObject.get(i).getOuFqn()));
}
for (int i = 0; i < lstCmsObject.size(); i++) {
for (int j = 0; j < lstCmsObject.size(); j++) {
if (lstUnits.get(i).GetName().compareTo(lstUnits.get(j).GetName())<0) {
Collections.swap(lstUnits, i, j);
}
}
}
des-1008d,
30 Марта 2010
-
−116.2
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
# TODO: выбросить нахер метод with_company_and_state и правильно написать
# этот named scope
named_scope :with_company_and_state_non_uniq, lambda { |company, state|
{ :conditions => [ 'products.company_id = :company_id AND ' +
'state_mask = :state_mask', { :company_id => company,
:state_mask => OrderSet::STATES.index(state) || 0 } ],
:order => 'order_sets.created_at DESC',
:joins => 'INNER JOIN products' }
}
def self.with_company_and_state(company, state)
with_company_and_state_non_uniq(company, state).uniq
end
Бывает, что SELECT DISTINCT сделать не всегда возможно. На самом деле, такая выборка сосёт.
eveel,
28 Марта 2010
-
+76.8
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
public void isChangenabledExc(){
if(isNew){
return;
}
if(true)return;//TODO
if(!isChangenabled()){
throw new ChangeEIsNotLockedException();
}
}
В этой функции находится единственный коментарий из всего файла.
Видимо в планах эта функция должна была делать нечто хорошее, но
планы так и не были осуществелны.
В результате получилась функция, которая ничего не делает, а только проверяет какие то условия.
поиском обнаружил 5 вызовов этой функции.
maxt,
26 Марта 2010
-
+118
- 1
- 2
- 3
- 4
- 5
<asp:Repeater runat="server" ID="rpAccountType">
<ItemTemplate>
<input type="checkbox" name="cbGroupAccountType" id="cbAccountType_<%#((KeyValuePair<string, object>)Container.DataItem).Value %>" value="<%#((KeyValuePair<string, object>)Container.DataItem).Value %>" <asp:Literal Id="lAccountTypeChecked" runat="server" />/><label for="cbAccountType_<%#((KeyValuePair<string, object>)Container.DataItem).Value %>"><asp:Literal runat="server" ID="lAccountTypeName" /></label><br />
</ItemTemplate>
</asp:Repeater>
ASP.NET. Значения генерируемых чекбоксов, в задумке, еще и на code-behind сильно влияют.
terR0Q,
23 Марта 2010
-
−88
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
if (_root["currKeyState"] == 3 and _root["currKeyStateCaps"] == "off") {
_root["currKeyState"] = 1;
if ("titleNewRec" == _root["currentInput"] or "msgText" == _root["currentInput"] or "prvSearchStr" == _root["currentInput"] or "mdengiId" == _root["currentInput"] or "fio" == _root["currentInput"] or "alfabplace" == _root["currentInput"] or "commut" == _root["currentInput"]) {
} else {
}
} else if (_root["currKeyState"] == 4 and _root["currKeyStateCaps"] == "off") {
_root["currKeyState"] = 2;
if ("titleNewRec" == _root["currentInput"] or "msgText" == _root["currentInput"] or "prvSearchStr" == _root["currentInput"] or "mdengiId" == _root["currentInput"] or "fio" == _root["currentInput"] or "alfabplace" == _root["currentInput"] or "commut" == _root["currentInput"]) {
} else {
}
}
Хотел посмотреть, как реализована логика в старом коде и нашел вот это...
-=Deus=-,
22 Марта 2010
-
+152.9
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
procedure TForm1.Button2Click(Sender: TObject);
var i:dword;
begin
if (Checkbox1.Checked)or(Checkbox3.Checked)or(Checkbox2.Checked) then
begin
form1.Cursor:=crhourglass;
Sleep(500);
progressbar1.Position:=10;
Sleep(1000);
progressbar1.Position:=20;
Sleep(500);
progressbar1.Position:=50;
Sleep(1000);
progressbar1.Position:=100;
Sleep(500);
end;
Трудимся в поте лица. :D
Говногость,
13 Марта 2010
-
+99.3
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
procedure setrandomdoubleprecision(value:byte);
begin
precision:=10*value;
end;
function rangerandomdouble(minrandomdouble,maxrandomdouble:double):double;
begin
result:=randomdouble(maxrandomdouble+(-minrandomdouble))+minrandomdouble
end;
function randomdouble(maxdouble:double):double;
var
l1,l2:integer;
begin
l1:=random(trunc(maxdouble));
l2:=random(trunc(frac(maxdouble)*precision));
result:=l1+(l2/precision)
end;
Рандом с заданной точностью. O_o
Говногость,
13 Марта 2010
-
+87.9
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
function LockBack:bool;
var sd:tddsurfacedesc2;
begin
fillchar(sd,sizeof(sd),0);
sd.dwSize:=sizeof(sd);
result:=fbacksurface.Lock(nil,sd,DDLOCK_SURFACEMEMORYPTR or ddlock_nosyslock or DDLOCK_WAIT,0)=dd_ok;
if not result then exit;
BackPtr:=sd.lpSurface;
end;
function UnLockBack:bool;
begin
result:=fbacksurface.UnLock(nil)=dd_ok;
BackPtr:=nil;
end;
function MakeSceenBackPtr:bool;
begin
result:=true;
if backptr=nil then
result:=lockBack;
end;
function GetSceenSafeBackPtr:pointer;//use only this
begin
result:=nil;
if not MakeSceenBackPtr then exit;
result:=backptr;
end;
Тот же проЭкт, что и ниже на DirectDraw7.
Не смотря на то, что была функция function UnLockBack:bool; - она никогда не вызывалась. Странно, что на многих машинах это работало, тк я успешно выполнял блитинг в заблокированные поверхности в течении многих часов. :D
Говногость,
13 Марта 2010
-
+66.2
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
<!-- Подготавливаем счётчик для цикла -->
<xsl:variable name="i-tree">
<i/><i/><i/><i/><i/><i/>
<i/><i/> <i/><i/> <i/><i/>
<i/><i/><i/> <i/><i/><i/> <i/>
<i/><i/><i/><i/><i/><i/><i/>
<i/> <i/>
<i/><i/><i/><i/><i/><i/>
</xsl:variable>
<xsl:variable name="i" select="exslt:node-set($i-tree)/i" />
<!-- Подготавливаем параметр ссылок -->
<xsl:variable name="links">
<links next="0" previous="1">
<xsl:for-each select="$i[position() <= $date/@mday]">
<link mday="{position()}" />
</xsl:for-each>
</links>
</xsl:variable>
<div id="archive">
<xsl:call-template name="calendar">
<xsl:with-param name="title" select="'Архив'" />
<xsl:with-param name="url" select="concat($url_path,'%date%/')" />
<xsl:with-param name="links" select="exslt:node-set($links)/links" />
</xsl:call-template>
</div>
Вот так и мучаемся без for циклов в xsl
Suor,
12 Марта 2010