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

    В номинации:
    За время:
  2. 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)
  3. 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)
  4. 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)
  5. 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)
  6. Куча / Говнокод #13631

    +125

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    int prev, next;
    // next should not be equal to prev;
    next = radnom(MAX);
    if (next = prev)
        next = random(MAX);

    Просто передаю концепцию на общеславянском.
    Будет интересно посчитать насколько всё-таки это говно уменьшает вероятность совпадения при разных MAX.

    vistefan, 21 Августа 2013

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

    +134

    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
    class Slovo
        {
            public string Word;
            public int Count;
            public Slovo(string slovo, int kolichestvo)
            {
                Word = slovo;
                Count = kolichestvo;
            }
        }
    
        class Program
        {
            static void Main(string[] args)
            {
                string s = "Один два четыре восемь число один и два дают вместе восемь а один умножить на один будет один";
                List<string> word = new List<string>();
                List<int> count = new List<int>();
                string[] word_collection = s.ToLower().Split(' ');
                foreach (string str in word_collection) if (!word.Contains(str))
                    {
                        word.Add(str);
                        count.Add(1);
                    }
                    else count[word.IndexOf(str)]++;
                List<Slovo> spisok = new List<Slovo>();
                for (int i = 0; i < word.Count; i++) spisok.Add(new Slovo(word[i], count[i]));
                spisok.Sort((a, b) => b.Count - a.Count);
                foreach (Slovo slovo in spisok) Console.WriteLine(slovo.Word.PadRight(12) + slovo.Count.ToString());
                Console.ReadKey();
            }
        }

    Найти в строке самые частоповторяющиеся слова

    sbs, 10 Июня 2013

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

    +109

    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
    GLOBAL _start
        SEGMENT .text
    _start:
         mov eax,4 ; N function=write
         mov ebx,1 ; N handle=1 (stdout)
         mov ecx, txt ; address of buf
         mov edx,16 ; number of byte
         int 80h
    
         mov eax,3 ; N function=read
         mov ebx,0 ; 0 handle=0 (stdin)
         mov ecx, buf ; address of buf
         mov edx,80 ; number of byte
         int 80h
    
         mov [len],eax ;save length buf
         mov byte [buf+1],'!'
    
         mov eax,4 ; N function=write
         mov ebx,1 ; N handle=1 (stdout)
         mov ecx, buf ; address of buf
         mov edx,[len] ; number of byte
         int 80h
    
         mov eax,1 ; function=exit
         int 80h 
         
    SEGMENT .data
    	buf times 80 db 0 ;
    	len dd 0
    	txt db 'Enter the text '

    dos_, 15 Ноября 2012

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

    −99

    1. 1
    2. 2
    3. 3
    4. 4
    private function onClick(e:MouseEvent):void 
    {
            dispatchEvent(new MouseEvent(MouseEvent.CLICK, true, false))
    }

    Еще один кусочек очень полезного кода. (this для этого обработчика - MovieClip).

    wvxvw, 30 Октября 2012

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

    +15

    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
    #include <iostream>
    #include <cxxabi.h>
    #include <typeinfo>
    
    int main(void)
    {
       uint8_t i = 63;
       int  status;
    
       std::cout << i << std::endl;
    
       char *realname = abi::__cxa_demangle(typeid(i).name(), 0, 0, &status);
       std::cout << "Real type of uint8_t is: " << realname << std::endl;
       delete (realname);
    
       std::cout << (unsigned int)i << std::endl;
    
    return 0;
    }

    ...нативный 8bit-ый беззнаковый int.

    sayidandrtfm, 28 Октября 2012

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

    +120

    1. 1
    2. 2
    3. 3
    4. 4
    final TextField passwordField = UIFactory.createTextField(loginInfo, null);
    passwordField.setWidth(textFieldWidthPx);
    // Yes, they really want the password field to be shown openly.
    // Don't blame me, I'm just following orders!

    Безопасность такая безопасность.

    someone, 18 Сентября 2012

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