1. Pascal / Говнокод #15982

    +89

    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
    var
      Form1: TForm1;
      i:integer; // глобальные переменные - "общие"
      CritSec:TCriticalSection; // объект критической секции
    implementation
    
    {$R *.dfm}
    
    procedure ThreadFunc;
    begin
    while (i<100000) do
      begin
      CritSec.Enter; // открываем секцию
      i:=i+1; //увеличиваем i
      Form1.Label1.Caption:=IntToStr(i); //из потока к элементам формы нужно обращаться через имя формы
      CritSec.Leave; // закрываем
      end;
    
    endthread(0); // красиво выходим из потока.
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    var tid1,tid2,id:longword;
    begin
    i:=0;
    tid1:=beginthread(nil,0,Addr(ThreadFunc),nil,0,id); //запускаем функцию ThreadFunc в потоке
    tid2:=beginthread(nil,0,Addr(ThreadFunc),nil,0,id); //в tid2 присваиваем Идентификатор потока, который пригодится позже.
    end;
    
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    CritSec:=TCriticalSection.Create; // создаём объект критической секции, на всё время работы программы
    end;
    
    procedure TForm1.FormDestroy(Sender: TObject);
    begin
    CritSec.Free; // разрушаем
    end;
    
    end.

    Уебище, блять, лесное.
    http://grabberz.com/showthread.php?t=24619

    brutushafens, 14 Мая 2014

    Комментарии (39)
  2. JavaScript / Говнокод #15981

    +160

    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
    if (deltaLeft == 1) {
    	left -= 16;
    } else if (deltaLeft == 2) {
    	left -= 36;
    } else if (deltaLeft == 3) {
    	left -= 52;
    } else if (deltaLeft == 4) {
    	left -= 68;
    } else if (deltaLeft == 5) {
    	left -= 84;
    } else if (deltaLeft == -1) {
    	left += 16;
    } else if (deltaLeft == -2) {
    	left += 36;
    } else if (deltaLeft == -3) {
    	left += 52;
    } else if (deltaLeft == -4) {
    	left += 68;
    } else if (deltaLeft == -5) {
    	left += 84;
    }
    
    if (deltaTop == 1) {
    	top -= 30;
    } else if (deltaTop == -1) {
    	top += 27;
    } else if (deltaTop == -2) {
    	top += 50;
    } else if (deltaTop == 2) {
    	top -= 55;
    }

    И снова привет передают магические числа.

    kostoprav, 14 Мая 2014

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

    +131

    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
    #include <stdio.h>
    #include <stdint.h>
    
    #define ARR_L 11
    #define INS_P (arr[0])
    #define MOD_L(a) ((a) % ARR_L)
    #define INS_P_M (MOD_L(INS_P))
    #define ARR_ACS(a) (arr[MOD_L(a)]) //access to arr
    
    
    void foo (uint8_t *arr)
    {
      if (ARR_ACS(0) == 0)
      {
        printf("%u ", ARR_ACS(1));
        ARR_ACS(1) += ARR_ACS(2);
        ARR_ACS(0) = 1;
      }
      else
      {
        printf("%u ", ARR_ACS(2));
        ARR_ACS(2) += ARR_ACS(1);
        ARR_ACS(0) = 0;
      }
    
    }
    
    int main(void) {
      uint8_t arr[ARR_L] = {1,1,1,0,0,0,0,0,0,0,0};
      for (size_t a = 0; a < 13; a++)
      {
        foo(arr);
      }
      return 0;
    }

    Считалка чисел Фибоначчи на основе фигни, придуманной в http://govnokod.ru/15967
    Надо сделать метаязык для удобного составления набора инструкций для этой штуки. И еще надо осилить длинную арифметику, ну это вообще круто будет

    j123123, 14 Мая 2014

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

    +158

    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
    $(document).ready(function() {
    	$('#about').click(function(about){    
    		$('#outside, #outside2, #outside3, #outside4, #outside5, #outside6, #outside7, #outside8, #outside9, #outside10, #outside11').fadeToggle('slow');
    	});
    
    	$('#whyus').click(function(whyus){    
    		$('#outsidewhy, #outsidewhy2, #outsidewhy3, #outsidewhy4, #outsidewhy5, #outsidewhy6, #outsidewhy7, #outsidewhy8, #outsidewhy9, #outsidewhy10, #outsidewhy11').fadeToggle('slow');
    	});
    
    	$('#portfolio').click(function(port){    
    		$('#outsideport, #outsideport2, #outsideport3, #outsideport4, #outsideport5, #outsideport6, #outsideport7, #outsideport8, #outsideport9, #outsideport10, #outsideport11').fadeToggle('slow');
    	});
    
    	$('#contact').click(function(con){    
    		$('#outsidecon, #outsidecon2, #outsidecon3, #outsidecon4, #outsidecon5, #outsidecon6, #outsidecon7, #outsidecon8, #outsidecon9, #outsidecon10, #outsidecon11').fadeToggle('slow');
    	});
    });

    В этом коде все хорошо и солнечно

    kostoprav, 14 Мая 2014

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

    +16

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    #include <windows.h>
     #include <iostream>
     int main ()
     {
         HINSTANCE result;
         result=ShellExecute(NULL,NULL,L"E:\\.mp3",NULL,NULL,SW_SHOWDEFAULT);
         if ((int)result<=32)
         std::cout << "Error!\nReturn value: " << (int)result << "\n";
         return 0;
     }

    Как написать mp3-плеер на с++ в 10 строк без использования сторонних библиотек?
    Гении с cyberforum знают ответ!

    http://www.cyberforum.ru/cpp-beginners/thread444490-page3.html

    gost, 13 Мая 2014

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

    +72

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    @Test(timeout = 120000)
    public void testFlow() throws MuleException, InterruptedException {
    	MuleClient client = new MuleClient(muleContext);
    	MuleMessage message = client.send("vm://sfdc.process", new DefaultMuleMessage("abakadabra", muleContext));
    
    	Thread.sleep(30000);
    	Assert.assertNotNull(message);
    }

    Боремся с потусторонними силами с помощью священных sleep'ов.

    pingw33n, 13 Мая 2014

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

    +17

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    switch (impl->used_hash)
                {
                case false:
                    break;
                case true :
                    ..........
            }

    Разбирал сырцы одного "гения" и нашел это...

    LuCiFer, 13 Мая 2014

    Комментарии (31)
  8. JavaScript / Говнокод #15974

    +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
    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
    function loading() {
         $('#close').hide(function() {
          $('#loading').show(function () {
            setTimeout(function(){
                $('#loading2').show(function() {
                setTimeout(function(){
                  $('#loading3').show(function () {
                    setTimeout(function(){
                      $('#vk').show(function() {
                        setTimeout(function(){
                         $('#odn').show(function() {
                          setTimeout(function(){
                            $('#fb').show(function() {
                              setTimeout(function(){
                               $('#tw').show(function () {
                                $('#geo').show();
                                setTimeout(function(){
                                  payment();
                                },1300);
                               });
                              },1600);
                            });
                          },1700);
                         });
                        },1400);
                      });
                    },1600);
                  });
                },1900);
              });
            },1600);
          });
         });
         }

    Из исходного кода сайта, "раскрывающего" анонимов на аск.фм

    TRANE73, 13 Мая 2014

    Комментарии (94)
  9. Perl / Говнокод #15973

    −149

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    my $query = "select * from client where <...>";
    ...
    $params{'first_name'} = $v_client[6];
    if (defined $v_client[11]) {
         $params{'address1'} = $v_client[11];
    }
    if (defined ($v_client[10])) {
      $params{'zip_code'} = $v_client[10];
    }

    No comments.

    bormand, 13 Мая 2014

    Комментарии (32)
  10. Java / Говнокод #15972

    +73

    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
    public static int getWordCount(String getInput, int e){
        int numberOfWords = 0;
        char l1 = 0;
        char l2 = 0;
        StringBuilder convertInput = new StringBuilder(getInput);
        System.out.println(convertInput);
        for (int i = 0, i1 = 1; i < getInput.length();i++, i1++){
            l2 = convertInput.charAt(i);
            if (l2 == ' '){
                numberOfWords += 1;
                l1 = convertInput.charAt(i1);
            }
            if (i == getInput.length() - 1){
                numberOfWords += 1;
            }
            if (l2 == ' ' && l1 == ' '){
                numberOfWords -= 1;
            }
        }
        return numberOfWords;
     } // end of getWordCount method

    http://docs.oracle.com/javase/7/docs/api/java/util/StringTokenizer.html да и просто регексп на крайняк как видно запрещены религией.

    kostoprav, 13 Мая 2014

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