1. JavaScript / Говнокод #6026

    +162

    1. 1
    2. 2
    return vars[v] = ($.inArray(v, wndConfig["out_zero"]) !== -1)
      ? (tmp == 0 ? 0 : tmp) : tmp;

    Из серии "в пятницу вечером". Ладно хоть сейчас перечитал этот кусок и увидел.

    telnet, 19 Марта 2011

    Комментарии (5)
  2. Си / Говнокод #6025

    +126

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    format MS COFF
    
    public fuckHighLevel as '_fuckHighLevel@4'
    
    fuckHighLevel:
            pop ebx
    
                pop eax
                add eax, 1
    
            jmp ebx

    Вызываем ассемблерную процедуру из Си.
    Вместо retn используем безусловыный переход на адрес возврата.
    Но работает же!

    danilissimus, 19 Марта 2011

    Комментарии (2)
  3. C# / Говнокод #6024

    +120

    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
    if (clr1 != Color.Black && clr2 != Color.Black)
                {
                    int R1 = clr1.R > clr2.R ? clr1.R - 1 : clr1.R + 1;
                    int R2 = clr1.R < clr2.R ? clr1.R - 1 : clr1.R + 1;
                    int G1 = clr1.G > clr2.G ? clr1.G - 1 : clr1.G + 1;
                    int G2 = clr1.G < clr2.G ? clr1.G - 1 : clr1.G + 1;
                    int B1 = clr1.B > clr2.B ? clr1.B - 1 : clr1.B + 1;
                    int B2 = clr1.B < clr2.B ? clr1.B - 1 : clr1.B + 1;
                    if (R1 > 255) R1 = 255; if (R1 < 0) R1 = 0;
                    if (R2 > 255) R2 = 255; if (R2 < 0) R2 = 0;
                    if (G1 > 255) G1 = 255; if (G1 < 0) G1 = 0;
                    if (G2 > 255) G2 = 255; if (G2 < 0) G2 = 0;
                    if (B1 > 255) B1 = 255; if (B1 < 0) B1 = 0;
                    if (B2 > 255) B2 = 255; if (B2 < 0) B2 = 0;
    
                    outp.b = Color.FromArgb(R1, G1, B1); outp.a = Color.FromArgb(R2, G2, B2);
                }

    Нашёл у себя такого красавца годичной давности - суровое "плавное" целочисленное интерполирование двух цветов для Compact Framework.

    RaZeR, 19 Марта 2011

    Комментарии (1)
  4. Pascal / Говнокод #6023

    +99

    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
    var
      i,c,b,f:integer;
      str:string;
    procedure TForm1.codir;
    begin
    b:=1;
    f:=1;
    c:=length(edit1.Text);
    str:=edit1.Text;
    repeat
    i:=ord(str[f]);
    case i of
    0:inc(i);
    1:inc(i);
    2:inc(i);
    3:inc(i);
    4:inc(i);
    5:inc(i);
    6:inc(i);
    7:inc(i);
    8:inc(i);
    9:i:=0;
    end;
    
    Delete(str, b, 1);
    Insert(inttostr(i),str,b);
    inc(b);
    inc(f);
    until b=c;
    edit2.Text:=str;
    end;

    bugmenot, 19 Марта 2011

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

    +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
    #include <iostream>
    using namespace std;
    void main()
    {
        char U='#';
    int K;
        _asm
        {
            mov eax, 0
            mov al, U
            mov K,eax
        }
        cout<<K<<endl;
    }

    "Получение десятичного представления числа". C wasm.ru

    rat4, 18 Марта 2011

    Комментарии (14)
  6. C++ / Говнокод #6021

    +167

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    PopupWindow* GameLocations::getCurrentPopup()
    {
    	if(m_curPopup != nullptr && m_curPopup->needsClose())
    	{
    		m_curPopup->onClose();
    		m_curPopup = nullptr;
    		m_walker->BeginWalk(m_graph->getClosestNode(m_currentLocationId));
    	}
    	return m_curPopup;
    }

    Kirinyale, 18 Марта 2011

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

    +114

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    if (defaultOrderType == OrderType.NoCharge || defaultOrderType == OrderType.Claims)
    {
        noChargeItemEntry.Style.Add(HtmlTextWriterStyle.Display, "block");
        itemEntryPanel.Style.Add(HtmlTextWriterStyle.Display, "none");
        items.Style.Add(HtmlTextWriterStyle.Display, "none");
    }
    else
    {
        noChargeItemEntry.Style.Add(HtmlTextWriterStyle.Display, "none");
        itemEntryPanel.Style.Add(HtmlTextWriterStyle.Display, "block");
        items.Style.Add(HtmlTextWriterStyle.Display, "block");
    }

    abatishchev, 18 Марта 2011

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

    +116

    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
    // Method that returns anonymous type as object
    object ReturnAnonymous() {
      return new { City="Prague", Name="Tomas" };
    }
    
    void Main() {
      // Get instance of anonymous type with 'City' and 'Name' properties
      object o = ReturnAnonymous();
    
      // This call to 'Cast' method converts first parameter (object) to the
      // same type as the type of second parameter - which is in this case 
      // anonymous type with 'City' and 'Name' properties
      var typed = Cast(o, new { City="", Name="" });
      Console.WriteLine("{0}, {1}", typed.City, typed.Name)
    }
    
    // Cast method - thanks to type inference when calling methods it 
    // is possible to cast object to type without knowing the type name
    T Cast<T>(object obj, T type) {
      return (T)obj;
    }

    via http://social.msdn.microsoft.com/forums/en-US/linqprojectgeneral/thread/c1c179bb-ea88-4633-970a-947f0dd1e71f/

    Jopa123, 18 Марта 2011

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

    +119

    1. 1
    http://rabota.1777.ru/one_rezume.php?job_rezume_id=33838&job_cat_id2=1&doljnost2=&pol2=&vozrast_ot2=21&vozrast_do2=21&obrazovanie2=&opit2=&plata2=&pajina=&new=&doljnost3=

    Супер человек, всего 21 год, умеет все и деньги ему не нужны.

    Vasiliy, 18 Марта 2011

    Комментарии (0)
  10. PHP / Говнокод #6017

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    /*
     * Корректировка даты.
     *	если дата в будущем - то показываем сегодня.
     */
    
    $row['created'] = ( strtotime( date("Y-m-d", strtotime($row['created'])) ) > strtotime( date("Y-m-d") ) )? 
    		date("r")
    		: date("r", strtotime($row['created']));

    4x4 off-road racing...

    istem, 17 Марта 2011

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