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

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

    +136

    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
    class Program
        {        
            class A
            {
    
                //-----------------------------------------------------------------------
                public static A CurrentRoot;
                public static Dictionary<object, A> RootMap = new Dictionary<object, A>();
                public static object Lock = new object();
                //-----------------------------------------------------------------------
    
                public int Test;
    
                public A()
                {
                    lock (Lock)
                    {
                        CurrentRoot = this; 
                        b = new B();
                    }   
                }   
                internal class B
                {
                    public B() { RootMap.Add(this, CurrentRoot); }
    
                    public A root { get { return RootMap[this]; } }                
    
                    ~B() { RootMap.Remove(this); }                
                }
                public B b;
            }
         
            static void Main(string[] args)
            {
    
                A a1 = new A(); a1.Test = 555;
                A a2 = new A(); a2.Test = 888;
    
                Console.WriteLine(a1.b.root.Test); Console.WriteLine(a1.Test);
                Console.WriteLine(a2.b.root.Test); Console.WriteLine(a2.Test);
    
    
                Console.WriteLine(a1.b.root.b.root.b.root.b.root.b.root.Test);
            }

    Класс создан для того чтобы вложенные структуры имели доступ к структуре родителя. Safe thread support.

    maxillion, 20 Сентября 2014

    Комментарии (33)
  3. Си / Говнокод #16601

    +129

    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
    #include <stdio.h>
    
    #define квот [
    #define квзак ]
    #define фигот {
    #define фигзак }
    #define главный main
    #define напечатать(x) printf("%s", x)
    #define псевдоним typedef
    #define конст const
    
    псевдоним int цел;
    псевдоним char символ;
    
    цел главный()
    фигот
    
    конст символ* строки квот квзак = фигот "Привет, ", "мир!" фигзак;
    напечатать(строки квот 0 квзак);
    напечатать(строки квот 1 квзак);
    
    фигзак

    http://www.gamedev.ru/code/forum/?id=192614
    У человека проблема - его напрягает переключение раскладок при написании кода.
    Я в шутку предложил такое решение проблемы. Для написания кода главной функции теперь не нужно переключения раскладок!

    gammaker, 27 Августа 2014

    Комментарии (33)
  4. C++ / Говнокод #16589

    +53

    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
    void _debugPrintWaveHeader(const char *path, const WAVHEADER &source_header)
    {
    	FILE *debug = fopen("path", "wt");
    	fprintf(debug, "chunkId    = %s\n", source_header.chunkId);
    	fprintf(debug, "chunkSize  = %u\n", source_header.chunkSize);
    	fprintf(debug, "format     = %s\n", source_header.format);
    	fprintf(debug, "subCh1Id   = %s\n", source_header.subchunk1Id);
    	fprintf(debug, "subCh1Size = %u\n", source_header.subchunk1Size);
    	fprintf(debug, "audioform  = %u\n", source_header.audioFormat);
    	fprintf(debug, "numChanels = %u\n", source_header.numChannels);
    	fprintf(debug, "sampleRate = %u\n", source_header.sampleRate);
    	fprintf(debug, "byteRate   = %u\n", source_header.byteRate);
    	fprintf(debug, "blockAlign = %u\n", source_header.blockAlign);
    	fprintf(debug, "bitsPerSam = %u\n", source_header.bitsPerSample);
    	fprintf(debug, "subCh2Id   = %s\n", source_header.subchunk2Id);
    	fprintf(debug, "subCh2Size = %u\n", source_header.subchunk2Size);
    	fclose(debug);
    }

    Начал разгребать один говнопроект... При отладке программа всё падает и падает, падает и не может остановится. Смотрю на код - все в норме, а потом, по прошествии нескольких часов...

    GreatMASTERcpp, 25 Августа 2014

    Комментарии (33)
  5. PHP / Говнокод #16263

    +158

    1. 1
    for($month = 1 ; $month <= intval(12); $month ++)

    clauclauclau, 01 Июля 2014

    Комментарии (33)
  6. Java / Говнокод #15612

    +65

    1. 1
    grade : 100 >= "A" >= 90 > "B" >= 80 > "C" >= 70 > "D" >= 60 > "E" >= 0;

    Кто-нибудь догадается, что сие может значить? :)

    parzh, 28 Марта 2014

    Комментарии (33)
  7. C# / Говнокод #14509

    +105

    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
    //Невероятные приключения Microsoft'а в Индии:
    
            private string ExtractHttpVerb(XmlDocument configDOM)
            {
                string httpVerb;
    
                string hv = IfExistsExtract(configDOM, "/Config/method", "2");
    
                switch (hv)
                {
                    case "0":
                        httpVerb = HttpVerbs[0];
                        break;
    
                    case "1":
                        httpVerb = HttpVerbs[1];
                        break;
    
                    case "2":
                        httpVerb = HttpVerbs[2];
                        break;
    
                    default:
                        httpVerb = HttpVerbs[2];
                        break;
                }
    
                return httpVerb;
            }

    HellMaster_HaiL, 05 Февраля 2014

    Комментарии (33)
  8. C# / Говнокод #14338

    +137

    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
    public static string AddControlDigits(string input)
    {
          if (String.IsNullOrEmpty(input))
              return "";
          try
          {
              XDocument doc = XDocument.Parse(input.JavaSubString(input.IndexOf("<contracts>"), input.IndexOf("</contracts>") + "</contracts>".Length));
              String s = new String(doc.ToString().ToCharArray());
                    
              XElement rootElement = doc.Root.Element("list_item");
    
              string basicNumber = rootElement.Element("basicNumber").Value;
              string endNumber = rootElement.Element("endNumber").Value;
              string loanCaseNumber = rootElement.Element("loanCaseNumber").Value;
              string loanCaseComplementNumber = rootElement.Element("loanCaseComplementNumber").Value;
              string bridgeLoanComplementNumber = rootElement.Element("bridgeLoanComplementNumber").Value;
    
              int checkNumber = CalcCheckDigitCU(basicNumber + endNumber);
              int loanCaseCheckNumber = calcCheckDigitUP(loanCaseNumber);
              int bridgeLoanCheckNumber = CalcCheckDigitCU(basicNumber + bridgeLoanComplementNumber);
    
              rootElement.Add(new XElement("checkNumber", checkNumber));
              rootElement.Add(new XElement("loanCaseCheckNumber", loanCaseCheckNumber));
              rootElement.Add(new XElement("bridgeLoanCheckNumber", bridgeLoanCheckNumber));
    
              input = input.Replace(s, doc.ToString());
    
              return "";
         }
         catch (Exception ex)
         {
             throw;
          }
     }

    жопа

    taburetka, 10 Января 2014

    Комментарии (33)
  9. C++ / Говнокод #14173

    +13

    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
    auto write =    [&buf](future<int> size) -> future<bool>    { 
      return streamW.write(size.get(), buf).then(
        [](future<int> op){
          return op.get() > 0; });    };   
    auto flse = [](future<int> op){
     return future::make_ready_future(false);};  auto copy = do_while(
        [&buf]() -> future<bool>    {
         return streamR.read(512, buf)    .then(
           [](future<int> op){ return (op.get() > 0) ? write : flse;});    });  
    
    ///////////////////////////////////////////////////////////////////////////
    
    int cnt = 0;   
    do  {  
    cnt = await streamR.read(512, buf);   
    if ( cnt == 0 ) break;   
    cnt = await streamW.write(cnt, buf);   
    } while (cnt > 0);

    Первое и второе угадайте что? Правильно, С++. В компиляторе студии и первое и второе будет. Первое уже даже есть. Ни первое ни второе не приняли в стандарт на сколько мне известно и надеюсь лобисты Майкрософт во главе с Саттером пойдут на ... подальше от крестов.

    www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3722.pdf

    LispGovno, 03 Декабря 2013

    Комментарии (33)
  10. JavaScript / Говнокод #13913

    +163

    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
    AdlAdbPromptDialog.callIfPromptDialogNeverClosedBefore(function(){
      AdlAdbPromptDialog.callIfAdblockerInDafaultState(function(){
       AdlAdbPromptDialog.callIfAdblockerEverTurnedOff(function(){
        AdlAdbPromptDialog.callIfAdblockerConfigShown(function(){
         AdlAdbPromptDialog.callIfPromptDialogSaveClicked(function(){
          AdlAdbPromptDialog.callIfAdsPresent(function(){
           AdlAdbPromptDialog.callIfUsingAdlMoreThanXdays(3, function(){
            callback();
           });
          });
         });
        }, AdlAdbPromptDialog.promptDialog.AdblockerConfigShown);
       }, AdlAdbPromptDialog.promptDialog.AdblockerEverTurnedOff);
      }, AdlAdbPromptDialog.promptDialog.AdblockerInDafaultState);
     });

    mxvz, 09 Октября 2013

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

    +16

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    void setEnabled(bool enabled)
    {
        super.setEnabled(enabled)
        if (enabled) {
            objectsArray.disable();
            return;
        }
        enable();
    }

    ZevsVU, 23 Августа 2013

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