1. Java / Говнокод #3424

    +144

    1. 1
    textPane.setText(<span style="font-size: 20pt">Big</span>);

    http://www.dynamicdrive.com/forums/showthread.php?t=18899

    O_O

    я подозревал, что вас обрезают, но что бы так?

    Lure Of Chaos, 08 Июня 2010

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

    +103

    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
    procedure TForm1.UpDown2Click(Sender: TObject; Button: TUDBtnType);
    begin
    If (UpDown2.Position = 0) or (UpDown2.Position = 5) or (UpDown2.Position = 6) or
       (UpDown2.Position = 7) or (UpDown2.Position = 8) or (UpDown2.Position = 9) or
       (UpDown2.Position = 10) or (UpDown2.Position = 11) or (UpDown2.Position = 12) or
       (UpDown2.Position = 13) or (UpDown2.Position = 14) or (UpDown2.Position = 15) or
       (UpDown2.Position = 16) or (UpDown2.Position = 17) or (UpDown2.Position = 18) or
       (UpDown2.Position = 19) or (UpDown2.Position = 20) or (UpDown2.Position = 25) or
       (UpDown2.Position = 26) or (UpDown2.Position = 27) or (UpDown2.Position = 28) or
       (UpDown2.Position = 29) or (UpDown2.Position = 30) or (UpDown2.Position = 35) or
       (UpDown2.Position = 36) or (UpDown2.Position = 37) or (UpDown2.Position = 38) or
       (UpDown2.Position = 39) or (UpDown2.Position = 40) or (UpDown2.Position = 45) or
       (UpDown2.Position = 46) or (UpDown2.Position = 47) or (UpDown2.Position = 48) or
       (UpDown2.Position = 49) or (UpDown2.Position = 50) or (UpDown2.Position = 55) or
       (UpDown2.Position = 56) or (UpDown2.Position = 57) or (UpDown2.Position = 58) or
       (UpDown2.Position = 59) or (UpDown2.Position = 60)
        then StaticText4.Caption := 'минут';
    
    If (UpDown2.Position = 1) or (UpDown2.Position = 21) or (UpDown2.Position = 31) or
       (UpDown2.Position = 41) or (UpDown2.Position = 51)
    then StaticText4.Caption := 'минуту';
    
    If (UpDown2.Position = 2) or (UpDown2.Position = 22) or (UpDown2.Position = 23) or
       (UpDown2.Position = 24) or (UpDown2.Position = 32) or (UpDown2.Position = 33) or
       (UpDown2.Position = 34) or (UpDown2.Position = 42) or (UpDown2.Position = 43) or
       (UpDown2.Position = 44) or (UpDown2.Position = 52) or (UpDown2.Position = 53) or
       (UpDown2.Position = 54)
    then StaticText4.Caption := 'минуты';
    
    If UpDown2.Position>60 then ShowMessage('больше нельзя');
    
    end;

    Дао создания таймера обратного отсчета.
    Канон второй: вычисление плюральных окончаний.
    Комментарии и форматирование авторские.

    bugmenot, 08 Июня 2010

    Комментарии (10)
  3. Pascal / Говнокод #3422

    +98

    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
    procedure TForm1.Timer1Timer(Sender: TObject);  //ПРОБЛЕМА ТУТ
    begin
    sec:=sec-1;
    ShowTime;     //показывать время
    
    If (sec=0) and (min=0) and(chas>0) then
    begin
    chas:=chas-1;
    min:=59;
    sec:=60;
    end;
    
    If (sec=0) and (min>0) and (chas=0) then
    begin
    min:=min-1;
    sec:=60;
    end;
    
    If (sec=0) and (min>0) and (chas>0) then
    begin
    min:=min-1;
    chas:=chas-1;
    sec:=60;
    end;
    
    
    If (chas=0) and (min=0) and (sec=0) then
    begin
    Timer1.Enabled:=false;
    Button1.Enabled:=True;
    Button2.Enabled:=False;
    Edit1.Enabled:=True;
    Edit2.Enabled:=True;
    Edit3.Enabled:=True;
    
    end;
    
    
    
    end;

    Дао создания таймера обратного отсчета.
    Канон первый: устаревшая и неудобная шестидесятиричная система.
    Комментарии и форматирование авторские.

    bugmenot, 08 Июня 2010

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

    +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
    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
    #include <iostream>
    #include <string.h>
    using namespace std;
    int strsearch(char* from, char* what);
    int getnumberafter(char* from, char* what);
    int strch(char* a, char* b, int pos);
    
    int strsearch(char* from, char* what)
    {
        int n=strlen(from)-strlen(what)+1;
        int i;
        for(i=0; i<n; i++)
    	if(strch(from, what, i)==strlen(what)) return i;
        return 0;
    }
    int getnumberafter(char* from, char* what)
    {
        int p, ret=0;
        if((p=strsearch(from,what))==0) return 0;
        p+=strlen(what);
        while(from[p]<'0'&&from[p]>'9')
        {
    	p++;
    	if(p>=strlen(from)) return 0;
        }
        while(from[p]>='0'&&from[p]<='9'&&p<strlen(from))
        {
    	ret=ret*10+(from[p++]-'0');
        }
        return ret;
    }
    int strch(char* a, char* b, int pos)
    {
        int i,n=min(strlen(a)-pos,strlen(b));
        for(i=0; i<n; i++)
    	if(a[i+pos]!=b[i]) return i;
        return i;
    }
    int main(int argc, char* argv[])
    {
        int i;
        double max=1,vol=0;
        for(i=0; i<argc; i++)
        {
    	cout << i << ": " << argv[i] << endl;
    	if(strch(argv[i],"type",0)==4) {  max=getnumberafter(argv[i],"max=");}
    	if(strch(argv[i],"values",0)==6) { vol=(getnumberafter(argv[i],"=")+getnumberafter(argv[i],","))/2;}
        }
        cout << vol/max << endl;
        return 0;
    }

    Задача из чего-то типа этого:
    numid=2,iface=MIXER,name='Master Playback Volume'
    ; type=INTEGER,access=rw---R--,values=2,min=0,max=31,step=0
    : values=31,31
    | dBscale-min=-46.50dB,step=1.50dB,mute=0
    Получить значение в процентах.
    #./a.out `amixer cget numid=2`
    0,67

    Tanger, 08 Июня 2010

    Комментарии (14)
  5. JavaScript / Говнокод #3420

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    var url = 'djvu_text?nd=808604175&hidx=0&print=1&page=-1&save=1';
    var params = url.split('=');
    var ndarr = params[1].split('&');
    var nd = ndarr[0];
    
    return nd;

    Легко и не навязчиво выдираем значение параметра из строки с URL

    Nexus, 08 Июня 2010

    Комментарии (6)
  6. Си / Говнокод #3419

    +137

    1. 1
    strncat (dstring, " ", 512);

    Калифорнийский код, простенько, но со вкусом. Сам не с первого раза понял в чём дело ;-)

    raorn, 08 Июня 2010

    Комментарии (16)
  7. Java / Говнокод #3418

    +75

    1. 1
    setDouble((float)getAnotherDouble());

    Не могу понять: то ли ето какой-то реликтовый артефакт, то ли в етом есть глубокий смысл.
    Подскажите, а..

    OlegYch, 08 Июня 2010

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

    −93

    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
    if (!DocumentClass.getInstance().branding)
        DocumentClass.getInstance().branding = new Branding;
    if (!DocumentClass.getInstance().encryption)
        DocumentClass.getInstance().encryption = new TEAEncryption;
     if (!DocumentClass.getInstance().eventManager)
        DocumentClass.getInstance().eventManager = new EventManager;
     if (!DocumentClass.getInstance().panelManager)
        DocumentClass.getInstance().panelManager = new PanelManager;
     if (!DocumentClass.getInstance().playLogger)
        DocumentClass.getInstance().playLogger = new PlayLogger;
     if (!DocumentClass.getInstance().sharedObject)
        DocumentClass.getInstance().sharedObject = new SharedObjectManager;
     if (!DocumentClass.getInstance().soundManager)
        DocumentClass.getInstance().soundManager = new SoundManager;
     if (!GameDocumentClass.getInstance().dataManager)
        GameDocumentClass.getInstance().dataManager = new DataManager;

    Кусочек template для игростроя :)

    dimas_art, 08 Июня 2010

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

    +106

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    proxy1.GetMeasurements(
                new AccountingMeasurementType(255, "Тип документа")))
                            .ToList()
                            .FirstOrDefault(item => 
                                        item.Name.Equals("Спецификация")
                            ),
                SpecificationDS.DateFrom as DateTime?,
                SpecificationDS.DateTo as DateTime?)
    );

    Мало того что в коде прошита сразу куча строк, так еще и числовая константа %)

    User123, 08 Июня 2010

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

    +158

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    for (int i = 0; i < m_pTableWidget->rowCount(); i++) {
            m_pFilterList->addFilter(m_pTableWidget->item(i, 0)->text(), 
                                     (qobject_cast<QComboBox*>(m_pTableWidget->cellWidget(i, 1)))->currentText(),
                                     (qobject_cast<QComboBox*>(m_pTableWidget->cellWidget(i, 2)))->itemData((qobject_cast<QComboBox*>(m_pTableWidget->cellWidget(i, 2)))->currentIndex()).toString(),
                                     m_pTableWidget->item(i, 3)->text(),
                                     (qobject_cast<QComboBox*>(m_pTableWidget->cellWidget(i, 4)))->itemData((qobject_cast<QComboBox*>(m_pTableWidget->cellWidget(i, 4)))->currentIndex()).toString(),
                                     ((qobject_cast<QComboBox*>(m_pTableWidget->cellWidget(i, 2)))->currentText().contains("конца") ? "'%" : (qobject_cast<QComboBox*>(m_pTableWidget->cellWidget(i, 2)))->currentText().contains("любой") ? "'%" : "'"),
                                     ((qobject_cast<QComboBox*>(m_pTableWidget->cellWidget(i, 2)))->currentText().contains("начала") ? "%'" : (qobject_cast<QComboBox*>(m_pTableWidget->cellWidget(i, 2)))->currentText().contains("любой") ? "'%" : "'")
                                     );
        }

    Вот так вот брутально выглядит код "в одну строчку"

    JC_NVKZ, 08 Июня 2010

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