- 1
- 2
- 3
- 4
<?php
class Xml {
//Эта библиотека УГ, она не требуется
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+167.2
<?php
class Xml {
//Эта библиотека УГ, она не требуется
}
Волею судеб взялся за поддержку "сайтега", написанного каким-то малограмотным студентом.
В процессе изучению сорцов я увидел много новых гениальных паттернов и практик, phpMyAdmin без пароля, который лежал прямо в корне и был доступен извне, полное отсутствие ясной мысли и трезого ума.
Но сегодня наткнулся на класс, который меня просто добил.
ps. Не формат, просто наболело.
+165.4
<form style="height:15px ; width:100px"method=post name='ChangeCurrencyForm'>
{literal}
<script language='JavaScript'>
function _changeCurrency()
{
document.ChangeCurrencyForm.submit();
}
</script>
{/literal}
<select name='current_currency' onchange='JavaScript:_changeCurrency()'>
{section name=i loop=$currencies}
{if $log eq "" && $currencies[i].CID eq 2 | $currencies[i].CID eq 3 | $currencies[i].CID eq 4 | $currencies[i].CID eq 5 | $currencies[i].CID eq 6}
{*розница*} {elseif ($log eq "" or $log eq "" or $log eq "tigrakiev") && $currencies[i].CID eq 2 | $currencies[i].CID eq 3 | $currencies[i].CID eq 5 | $currencies[i].CID eq 6}
{*мелкий опт*} {elseif ($log eq "" or $log eq "") && $currencies[i].CID eq 2 | $currencies[i].CID eq 3 | $currencies[i].CID eq 4 | $currencies[i].CID eq 6}
{*опт*} {elseif ($log eq "") && $currencies[i].CID eq 2 | $currencies[i].CID eq 3 | $currencies[i].CID eq 4 | $currencies[i].CID eq 5}
{*плейлист*} {elseif ($log ne "" && $log ne "" && $log ne "" && $log ne "" && $log ne "" && $log ne "" && $log ne "") && $currencies[i].CID eq 2 | $currencies[i].CID eq 3 | $currencies[i].CID eq 4 | $currencies[i].CID eq 5 | $currencies[i].CID eq 6}
{else}
<option value='{$currencies[i].CID}'
{if $currencies[i].CID eq $current_currency}
selected
{/if}
>
{$currencies[i].Name}
</option>
{/if}
{/section}
</select>
+144.8
// C:\Program Files\Microsoft Visual Studio 9.0\VC\crt\src\dbghook.c
int __cdecl _CrtDefaultAllocHook(
int nAllocType,
void * pvData,
size_t nSize,
int nBlockUse,
long lRequest,
const unsigned char * szFileName,
int nLine
)
{
return 1; /* allow all allocs/reallocs/frees */
}
// C:\Program Files\Microsoft Visual Studio 9.0\VC\crt\src\dbgheap.c
extern "C" _CRTIMP int __cdecl _CrtIsValidPointer(
const void * pv,
unsigned int nBytes,
int bReadWrite
)
{
return (pv != NULL);
}
вот, в Microsoft Visual Studio 2008 нашёл такие вот перлы...
+98.7
Procedure Halt;
begin
if atomTest<>0 then GlobalDeleteAtom(atomTest);
TerminateProcess(GetCurrentProcess,0);
end;
function RegisterSceenTimer(proc:tproc):dword;
var i:dword;
begin
result:=0;
for i:=1 to sMaxSceenGradient do
if not SceenGradient[i].isNotEmpty then break ;
if i=sMaxSceenGradient then exit;
SceenTimers[i]:=proc;
result:=i;
end;
:D
+73.4
public class SaveBlankElementException extends RuntimeException{
public SaveBlankElementException(Throwable cause){
super(cause);
}
public SaveBlankElementException(String message,Throwable cause){
super(message,cause);
}
public SaveBlankElementException(String message){
super(message);
}
public SaveBlankElementException(){
}
@Override
public String getMessage(){
return "Попытка сохранения пустого элемента\nНе вызван prepareCreate()";
}
}
Зачем, спрашивается было создавать этот класс, когда можно было бы
вызвать исключение
throw new UnsupportedOperationException("Попытка сохранения пустого элемента\nНе вызван prepareCreate()");
+73.8
public class Date extends java.util.Date{
@Override
public String toString(){
return toLocaleString();
}
public Date(String s){
super(s);
}
public Date(int year,int month,int date,int hrs,int min,int sec){
super(year,month,date,hrs,min,sec);
}
public Date(int year,int month,int date,int hrs,int min){
super(year,month,date,hrs,min);
}
public Date(int year,int month,int date){
super(year,month,date);
}
public Date(long date){
super(date);
}
public Date(){
}
public java.sql.Date getSQLDate(){
return new java.sql.Date(getTime());
}
}
из за переопределения и еще какого, а главное как:
@Override
public String toString(){
return toLocaleString();
}
писать целый класс, это не каждый сможет.
+59.4
m = 1;
label:
...block1;
if (m == 1)
{
m++;
goto label;
}
else if (m == 2)
{
m++;
...block2;
goto label;
else
{
...block3;
}
if (m == 3)
m = 1;
else
m--;
из реально работающей математической проги
будет ли выполнено m--? ))
+961.7
int[] a = new int[5];
int i = 0;
foreach (var b in a)
{
a[i] = Convert.ToInt32(Console.ReadLine());
i++;
}
Console.ReadKey();
+124.6
<item>
<title>Mixed Up and Maxi-ed Out at Peter Som</title>
<link>http://www.fashionwiredaily.com/first_word/fashion/article.weml?id=3056</link>
<description>Good news for gym-goers this fall: you can forget about the lunges, the squats and the leg presses,</description>
<pubDate>Sat, 13 Feb 2010 18:25:00 EST</pubDate>
<enclosure url="http://www.fashionwiredaily.com/common_images/feed_images/498955.jpg" length="20713" type="image/jpg" />
</item>
<item>
<title>Mixed Up and Maxi-ed Out at Peter Som</title>
<link>http://www.fashionwiredaily.com/first_word/fashion/article.weml?id=3056</link>
<description>Good news for gym-goers this fall: you can forget about the lunges, the squats and the leg presses,</description>
<pubDate>Sat, 13 Feb 2010 18:25:00 EST</pubDate>
<enclosure url="http://www.fashionwiredaily.com/common_images/feed_images/498953.jpg" length="21716" type="image/jpg" />
</item>
<item>
<title>Mixed Up and Maxi-ed Out at Peter Som</title>
<link>http://www.fashionwiredaily.com/first_word/fashion/article.weml?id=3056</link>
<description>Good news for gym-goers this fall: you can forget about the lunges, the squats and the leg presses,</description>
<pubDate>Sat, 13 Feb 2010 18:25:00 EST</pubDate>
<enclosure url="http://www.fashionwiredaily.com/common_images/feed_images/498951.jpg" length="22238" type="image/jpg" />
</item>
Опять же, обнаружилось на сателитном сайте нашей конторы. Обратите внимание, что все данные в rss повторяются по 3 раза за исключением картинок. Понятно, что rss генерится, но это ж каким... недалеким надо быть, чтобы так сгенерить...
[url]http://www.fashionwiredaily.com/first_word/feed.xml[/url]
+66.9
// Компилировать: g++ -o test reghead.cpp object1.cpp regtail.cpp main.cpp
//================== object.h: ==================
struct Object {
const char *name;
unsigned char props[0];
};
extern Object *head, *tail;
enum {PROPTYPE_BYTE = 0x40, PROPTYPE_WORD = 0x80};
enum {PROP_DESC = 1, PROP_LASTSTRING, PROP_COLOR, PROP_MASS, PROP_END = 0};
#define DECLARE_OBJECT(name) \
extern Object Object_##name, *name##_reg; \
Object *name##_reg __attribute__((section("oreg"))) = &Object_##name;\
Object Object_##name = {#name}; \
namespace name##_props {
#define PROP_BYTE(id, value) unsigned char id##_1 = id | PROPTYPE_BYTE, id##_2 = value;
#define PROP_WORD(id, value) unsigned char id##_1 = id | PROPTYPE_WORD, id##_2[2] = {value & 0xff, value >> 8};
#define PROP_STRING(id, value) unsigned char id##_1 = id; unsigned char id##_2[] = value;
#define END_PROPS unsigned char final = PROP_END; }
//================== reghead.cpp: ==================
#include "object.h"
Object *head __attribute__((section("oreg"))) = 0;
//================== regtail.cpp: ==================
#include "object.h"
Object *tail __attribute__((section("oreg"))) = 0;
//================== object1.cpp: ==================
#include "object.h"
DECLARE_OBJECT(object1)
PROP_BYTE(PROP_COLOR, 14)
PROP_WORD(PROP_MASS, 300)
PROP_STRING(PROP_DESC, "description")
END_PROPS
//================== main.cpp: ==================
#include <stdio.h>
#include <string.h>
#include "object.h"
int main()
{
Object **obj = &head;
while (++obj <= &tail) {
if (*obj == NULL)
continue;
printf("Object: %s\n", (*obj)->name);
unsigned char *props = (*obj)->props;
int id;
while ((id = *props) != PROP_END) {
if (id < PROP_LASTSTRING) {
char *value = (char *)props+1;
props = (unsigned char *)value + strlen(value) + 1;
switch (id) {
case PROP_DESC:
printf(" Description: %s\n", value);
break;
}
} else {
int value;
switch (id >> 6) {
case 1:
value = *((unsigned char *)(props+1));
props += 2;
break;
case 2:
value = *((unsigned short *)(props+1));
props += 3;
break;
}
switch (id & 63) {
case PROP_COLOR:
printf(" Color: %d\n", value);
break;
case PROP_MASS:
printf(" Mass:%d\n", value);
break;
}
}
}
}
}
Прошу прощения за длинный пример, но не мог не поделиться. Написано по мотивом кода из того же ZDaemon – примерно так там задаются и обрабатываются свойства объектов. Работает только с компилятором GCC. Если вы поняли, как это работает, а также почему подобный говнокод работает с gcc версии 3.2 и может зависать с более поздними версиями – можете по праву гордиться собой.