- 1
- 2
- 3
if (url == null) {
throw new RuntimeException("Error reading resource " + url.getFile());
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+68
if (url == null) {
throw new RuntimeException("Error reading resource " + url.getFile());
}
ха.
туториалы jogl
+68
def InvoicedExtra(JobExtra extra) {
type = extra.type
clientPrice = extra.price ?: ZERO
vatPrice = (extra.type.vatBand?.band ?: 0) * extra.price / 100
grossPrice = vatPrice ?: ZERO + clientPrice ?: ZERO
}
Мой код на Groovy. Обратите внимание на строку 5. Это типа хитрый способ суммирования который не бросает NullPointerException. Однако не учтены приоритеты операторов. Оцените красоту выстрела в ногу =)
+68
char *GetNumRenderedObjectsString() { char *mString = new char [128]; itoa (mNumRenderedObjects, mString, 10); return mString; };
char *GetNumDiscardedObjectsString() { char *mString = new char [128]; itoa (mNumDiscardedObjects, mString, 10); return mString; };
Отличная работа с памятью.
+68
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
PortletSettings other = (PortletSettings) obj;
if (column == null) {
if (other.column != null)
return false;
} else if (!column.equals(other.column))
return false;
if (configurator == null) {
if (other.configurator != null)
return false;
} else if (!configurator.equals(other.configurator))
return false;
if (library == null) {
if (other.library != null)
return false;
} else if (!library.equals(other.library))
return false;
if (maximize != other.maximize)
return false;
if (portletId == null) {
if (other.portletId != null)
return false;
} else if (!portletId.equals(other.portletId))
return false;
if (row != other.row)
return false;
return true;
}
+68
// right now. I can't find how to make fucking @DirectLink
// to necessary book, therefore it'll be a cocksucking crutch.
// from eveel, with love :)
writer.attribute("href",
"?component=%24DirectLink&page=Home&service=direct&session=T&sp=" +
i);
Гоняем Tapestry «на посмотреть».
Действительно, понять сходу каким образому внутри компонента использовать другой компонент (тот же DirectLink) у меня не получилось. Вообще, вопрос в силе.
+67.9
char blt=0;
void WriteBit(bool bit)
{
if(BitCount<9)
{
if(bit){blt|=(1<<BitCount);BitCount++;}
if(!bit){blt&=~(1<<BitCount);BitCount++;}
}
else
{
out_file<<blt;
BitCount=0;
blt=0;
}
}
че-то типа запись в байт битов))
+67.9
#!/bin/bash
ln -s /tomcat/tc1/logs/CR.log /tomcat/logs/tc1.log
ln -s /tomcat/tc2/logs/CR.log /tomcat/logs/tc2.log
ln -s /tomcat/tc3/logs/CR.log /tomcat/logs/tc3.log
ln -s /tomcat/tc4/logs/CR.log /tomcat/logs/tc4.log
ln -s /tomcat/tc5/logs/CR.log /tomcat/logs/tc5.log
ln -s /tomcat/tc6/logs/CR.log /tomcat/logs/tc6.log
ln -s /tomcat/tc7/logs/CR.log /tomcat/logs/tc7.log
ln -s /tomcat/tc8/logs/CR.log /tomcat/logs/tc8.log
rm -fR /tomcat/webapps
mv /tomcat/tc1/webapps /tomcat/webapps
rm -fR /tomcat/tc1/webapps
rm -fR /tomcat/tc2/webapps
rm -fR /tomcat/tc3/webapps
rm -fR /tomcat/tc4/webapps
rm -fR /tomcat/tc5/webapps
rm -fR /tomcat/tc6/webapps
rm -fR /tomcat/tc7/webapps
rm -fR /tomcat/tc8/webapps
ln -s /tomcat/webapps /tomcat/tc1/webapps
ln -s /tomcat/webapps /tomcat/tc2/webapps
ln -s /tomcat/webapps /tomcat/tc3/webapps
ln -s /tomcat/webapps /tomcat/tc4/webapps
ln -s /tomcat/webapps /tomcat/tc5/webapps
ln -s /tomcat/webapps /tomcat/tc6/webapps
ln -s /tomcat/webapps /tomcat/tc7/webapps
ln -s /tomcat/webapps /tomcat/tc8/webapps
rm -fR /tomcat/tc2/conf/Catalina/localhost
rm -fR /tomcat/tc3/conf/Catalina/localhost
rm -fR /tomcat/tc4/conf/Catalina/localhost
rm -fR /tomcat/tc5/conf/Catalina/localhost
rm -fR /tomcat/tc6/conf/Catalina/localhost
rm -fR /tomcat/tc7/conf/Catalina/localhost
rm -fR /tomcat/tc8/conf/Catalina/localhost
ln -s /tomcat/tc1/conf/Catalina/localhost /tomcat/tc2/conf/Catalina/localhost
ln -s /tomcat/tc1/conf/Catalina/localhost /tomcat/tc3/conf/Catalina/localhost
ln -s /tomcat/tc1/conf/Catalina/localhost /tomcat/tc4/conf/Catalina/localhost
ln -s /tomcat/tc1/conf/Catalina/localhost /tomcat/tc5/conf/Catalina/localhost
ln -s /tomcat/tc1/conf/Catalina/localhost /tomcat/tc6/conf/Catalina/localhost
ln -s /tomcat/tc1/conf/Catalina/localhost /tomcat/tc7/conf/Catalina/localhost
ln -s /tomcat/tc1/conf/Catalina/localhost /tomcat/tc8/conf/Catalina/localhost
rm -fR /tomcat/tc2/lib
rm -fR /tomcat/tc3/lib
rm -fR /tomcat/tc4/lib
rm -fR /tomcat/tc5/lib
rm -fR /tomcat/tc6/lib
rm -fR /tomcat/tc7/lib
rm -fR /tomcat/tc8/lib
ln -s /tomcat/tc1/lib /tomcat/tc2/lib
ln -s /tomcat/tc1/lib /tomcat/tc3/lib
ln -s /tomcat/tc1/lib /tomcat/tc4/lib
ln -s /tomcat/tc1/lib /tomcat/tc5/lib
ln -s /tomcat/tc1/lib /tomcat/tc6/lib
ln -s /tomcat/tc1/lib /tomcat/tc7/lib
ln -s /tomcat/tc1/lib /tomcat/tc8/lib
rm -fR /tomcat/tc2/common
rm -fR /tomcat/tc3/common
rm -fR /tomcat/tc4/common
rm -fR /tomcat/tc5/common
rm -fR /tomcat/tc6/common
rm -fR /tomcat/tc7/common
rm -fR /tomcat/tc8/common
ln -s /tomcat/tc1/common /tomcat/tc2/common
ln -s /tomcat/tc1/common /tomcat/tc3/common
ln -s /tomcat/tc1/common /tomcat/tc4/common
ln -s /tomcat/tc1/common /tomcat/tc5/common
ln -s /tomcat/tc1/common /tomcat/tc6/common
ln -s /tomcat/tc1/common /tomcat/tc7/common
ln -s /tomcat/tc1/common /tomcat/tc8/common
+67.7
for(__=_;__<___;__++) C++;
Недавно увидел такие имена переменных, очарован, теперь срочно переделываю весь проект!
PS. Тело цикла сами знаете для кого.
+67.4
Apache POI
The apache project has a library which called POI that can read and write the HSSF (Horrible Spread Sheet Format)
Не говнокод, но официальное название формата доставляет :)
+67.4
// die elemente aufbauen
// wasserstoff (gruppe 1, Nichtmetalle)
Element* wasserstoff = new Element(this);
wasserstoff->setObjectName("wasserstoff");
wasserstoff->setze_element_namen(tr("Hydrogen"));
wasserstoff->setze_atomzahl(1);
wasserstoff->setze_symbol("H");
wasserstoff->setze_masse("1,00794 u");
wasserstoff->setze_exakte_masse("1.007825032");
wasserstoff->setze_ionisation("13,5984 kJ/mol");
wasserstoff->setze_elektronenaffinitaet("1.007825032");
wasserstoff->setze_elektronen_negativitaet("2,2");
wasserstoff->setze_kovalenter("37 pm");
wasserstoff->setze_van_der_waals_radius("120 pm");
wasserstoff->setze_schmelzpunkt("13.81");
wasserstoff->setze_siedepunkt("20.28");
wasserstoff->setze_familie(tr("nonmetal"));
wasserstoff->setze_gruppenfarbe(gruppenfarben.at(1));
wasserstoff->setze_entdeckungsjahr(1766);
wasserstoff->setze_position(0, 1);
elementliste.insert(wasserstoff->atomzahl(), wasserstoff);
wasserstoff->registriere_agrgatzustandsfarben(agregatzustandsfarben);
wasserstoff->fuege_elektronen_hinzu(1, 1);
// helium (gruppe 18, Edelgase)
Element* helium = new Element(this);
helium->setObjectName("helium");
helium->setze_element_namen(tr("Helium"));
helium->setze_atomzahl(2);
helium->setze_symbol("He");
helium->setze_masse("4,0026 u");
helium->setze_exakte_masse("4.002603254");
helium->setze_ionisation("24,5874 kJ/mol");
helium->setze_elektronenaffinitaet("4.002603254");
helium->setze_elektronen_negativitaet("-1");
helium->setze_kovalenter("32 pm");
helium->setze_van_der_waals_radius("140 pm");
helium->setze_schmelzpunkt("0.95");
helium->setze_siedepunkt("4.216");
helium->setze_familie(tr("noble gases"));
helium->setze_gruppenfarbe(gruppenfarben.at(18));
helium->setze_entdeckungsjahr(1868);
helium->setze_position(17, 1);
elementliste.insert(helium->atomzahl(), helium);
helium->fuege_elektronen_hinzu(1, 2);
// lithium (gruppe 1, Alkalimetalle)
Element* lithium = new Element(this);
...
// ununhexium (gruppe 16, Metalle)
Element* ununhexium = new Element(this);
ununhexium->setObjectName("ununhexium");
ununhexium->setze_element_namen(tr("Ununhexium"));
ununhexium->setze_atomzahl(116);
ununhexium->setze_symbol("Uuh");
ununhexium->setze_masse("292 u");
ununhexium->setze_exakte_masse("292.19979");
ununhexium->setze_ionisation("-1");
ununhexium->setze_elektronenaffinitaet("292.19979");
ununhexium->setze_elektronen_negativitaet("-1");
ununhexium->setze_kovalenter("-1");
ununhexium->setze_van_der_waals_radius("-1");
ununhexium->setze_schmelzpunkt(QString::number(INT_MAX));
ununhexium->setze_siedepunkt(QString::number(INT_MAX));
ununhexium->setze_familie(tr("other metal"));
ununhexium->setze_gruppenfarbe(gruppenfarben.at(16));
ununhexium->setze_entdeckungsjahr(2000);
ununhexium->setze_position(15, 7);
elementliste.insert(ununhexium->atomzahl(), ununhexium);
ununhexium->fuege_elektronen_hinzu(1, 2);
ununhexium->fuege_elektronen_hinzu(2, 8);
ununhexium->fuege_elektronen_hinzu(3, 18);
ununhexium->fuege_elektronen_hinzu(4, 32);
ununhexium->fuege_elektronen_hinzu(5, 32);
ununhexium->fuege_elektronen_hinzu(6, 18);
ununhexium->fuege_elektronen_hinzu(7, 6);
ЗЫ: итого порядка 3000 строк кода
http://sourceforge.net/projects/qperiodictable