- 1
<b><b><b><b><b><b><strong>В стоимость входит:</strong></b></b></b></b></b></b>
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+142
<b><b><b><b><b><b><strong>В стоимость входит:</strong></b></b></b></b></b></b>
Нужно больше жирного!
+100
procedure print(RTK_select:boolean; RLK_select:boolen;MOLK_select:boolean)
begin
if (RTK_select and not RLK_select and not MOLK_select) then
Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'РТК';
if (not RTK_select and RLK_select and not MOLK_select) then
Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'РЛК';
if (not RTK_select and not RLK_select and MOLK_select) then
Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'МОЛК';
if (RTK_select and RLK_select and not MOLK_select) then
Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'РТК,РЛК';
if (not RTK_select and RLK_select and MOLK_select) then
Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'РЛК,МОЛК';
if (RTK_select and not RLK_select and MOLK_select) then
Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'РТК,МОЛК';
if (RTK_select and RLK_select and MOLK_select) then
Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'РТК,РЛК,МОЛК';
if (not RTK_select and not RLK_select and not MOLK_select) then
Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := '';
end
Обнаружено в недрах старинного проекта. Запись строчки по флажкам.
+154
public static function checkPath($path)
{
if (substr($path, -1) == '/')
$path = $path;
else
$path = $path.'/';
return $path;
}
facepalm.jpg
+156
if( SITE == 'http://dev.example.com' ) die( file_get_contents( 'http://www.example.com/error.php?error=xml' ) );
die( file_get_contents( SITE.'/error.php?error=xml' ) );
некоторые 404-ую выводят вот так
+20
#define STR(a) #a
#define EXCEPTION_CLASS_CREATE(a) \
class a : public std::exception \
{ \
public: \
a() \
{ \
d(STR(a)"\n"); \
} \
\
a(const char * format, ...) \
{ \
char buffer[ 1024 ]; \
va_list vl; \
va_start( vl, format ); \
vsnprintf( buffer, sizeof(buffer), format, vl ); \
va_end( vl ); \
_str.append( buffer ); \
d(STR(a)" %s\n", buffer); \
} \
\
~a() throw() \
{ \
} \
\
const char* what() const throw() \
{ \
return _str.c_str(); \
} \
private: \
std::string _str; \
};
// ...
EXCEPTION_CLASS_CREATE( InternalException )
Мы очень любим varargs
−117
ПриФлагЖилое0(запросАДО,КодЧастиДома,ПредыдущийКонтрагент,обУК,предыдущаяУК,ДокДата,
квплулицы,квплуслуги,квплБлагоустр,ФлагПрервать,ДокНачНФ,ДокПостПД,ДокСтроение,
ИтогоКОплатеЗаМесяц,Оплаты,ПредыдущийКод,ДокНачНас,ДокПостОтНас,ВремТЧ_ДокНачНас_Услуги,
ВремТЧ_ДокПостОтНас_Услуги,счетСтроений,счетДокНачНас,счетДокПостОтНас,СтроениеКолвоЛицевыхНФ,
СтроениеКолвоЛицевых,СтроениеКолвоПроживающих,техПаспСтроениеОбщаяПлощадь);
Всего 27 параметров. Форматирование от автора.
+14
struct base {
template <class Foo>
base() {}
};
struct derived {
derived()
: base::base<int>() // why not?? WHHYYYY?
{}
};
base b1 = base::base<int>();
base b2<int>();
долбанный комитет
им проще запретить, чем продумать нормальный способ вызова шаблонного конструктора
+71
String currentDate = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").format(new Date());
accountNumber.append(String.valueOf(1900 + new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse(currentDate).getYear()));
accountNumber.append(String.valueOf(new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse(currentDate).getMonth()));
accountNumber.append(String.valueOf(new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse(currentDate).getDate()));
accountNumber.append(String.valueOf(new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse(currentDate).getHours()));
accountNumber.append(String.valueOf(new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse(currentDate).getMinutes()));
accountNumber.append(String.valueOf(new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse(currentDate).getSeconds()));
ну а чо, зато внушительно выглядит
−110
- (void)shutdown {
...
// shutdown routine
...
[self retain];
dispatch_async(_decodeQueue, ^{
[self cleanup];
});
}
- (void)cleanup {
[self release];
}
Старый-добрый memory management.
Между прочим, код из платной библиотеки...
+7
template<typename T>
class Enumerable
{
public:
Enumerable() : enumerableInProcess(false) { };
virtual void begin() = 0;
virtual void end() = 0;
virtual bool enumeration(T* item) = 0;
protected:
bool enumerableInProcess;
};
template<typename T>
class List : Enumerable<T*>
{
public:
class ListItem
{
public:
friend class List;
T item;
ListItem(T item) : item(item), next(nullptr), previous(nullptr)
{
}
private:
class ListItem* next;
class ListItem* previous;
};
/* ... */
void begin()
{
if(enumerableInProcess) {
throw Exception("Error Enumerable!");
}
enumerableInProcess = true;
enumerationItem = first;
}
bool enumeration(T** item)
{
if(enumerableInProcess) {
if(enumerationItem != nullptr) {
(*item) = &(enumerationItem->item);
enumerationItem = enumerationItem->next;
return (true);
} else {
(*item) = nullptr;
return (false);
}
} else {
throw Exception("Error Enumerable!");
}
}
bool enumeration(ListItem **listItem)
{
if(enumerableInProcess) {
if(enumerationItem != nullptr) {
(*listItem) = enumerationItem;
enumerationItem = enumerationItem->next;
return (true);
} else {
(*listItem) = nullptr;
return (false);
}
} else {
throw Exception("Error Enumerable!");
}
}
void end()
{
if(!enumerableInProcess) {
throw Exception("Error Enumerable!");
}
enumerableInProcess = false;
}
private:
const int size;
int count;
ListItem *first;
ListItem *last;
ListItem *enumerationItem;
};
void list_t_1()
{
List<int> list(8);
List<int>::ListItem *item;
list.add(1);
list.add(2);
list.add(4);
list.add(8);
list.add(16);
list.begin();
while(list.enumeration(&item))
{
printf("%i\n", (item->item));
}
list.end();
}