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

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

    +132

    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
    procedure TNewThread.Execute;
    var Shellapi,  Account, Username, Password:string;
        Pars_1, Pars_2:integer;
    begin
    Form1.Caption:='E-mail spamer by klychev - Work!'; 
    while Work do
    begin
    Form1.ProgressBar1.Position:=Form1.ProgressBar1.Position+1;
    if Form1.Edit3.Text=Form1.Edit4.Text then
    begin
    Work:=False;
    Form1.Button1.Enabled:=True;
    Form1.Button2.Enabled:=False;
    Form1.Caption:='E-mail spamer by klychev - Finish!';
    end
    else
    begin
    Account:='.'+Form1.Memo1.Lines[strtoint(Form1.Edit1.Text)]+'.';
    Pars_1:=Pos('.',Account)+Length('.');
    for Pars_2:=Pars_1 to Length(Account) do
    if Account[Pars_2]=';' then Break;
    Username:=Copy(Account,Pars_1,Pars_2-Pars_1);
    Pars_1:=Pos(';',Account)+Length(';');
    for Pars_2:=Pars_1 to Length(Account) do

    Попытка посношаться, через открытое окно движущегося поезда.

    Stertor, 04 Июля 2013

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

    +132

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
    
      type
      tmythread=class(tthread)
      private
      filename:string;
      procedure execute;override;
      public
        constructor create(filename:string);
        destructor destroy;
      end;
    
    type
      TForm1 = class(TForm)
        Button2: TButton;
        Button3: TButton;
        procedure FormCreate(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
      tlst:tthreadlist;
    
    implementation
    
    {$R *.dfm}
    
    function getCount : integer;
    begin
        Result := tlst.LockList.Count;
        tlst.UnlockList;
    end;
    
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    tlst:=tthreadlist.Create;
    end;
    
    { tmythread }
    
    constructor tmythread.create(filename: string);
    begin
      self.FreeOnTerminate:=true;
      self.filename:=filename;
      inherited create(true);
      self.Priority:=tphigher;
      self.Resume;
      tlst.LockList.Add(self);
      tlst.UnlockList;
    end;
    
    destructor tmythread.destroy;
    begin
    tlst.Remove(self);
    tlst.UnlockList;
    end;
    
    procedure tmythread.execute;
    begin
    while not terminated do
    sleep(100);    // в качестве примера, чем-то нагружаем цикл.
    end;
    
    procedure TForm1.Button2Click(Sender: TObject);
    var
      i:integer;
      n:string;
      temp:tmythread;
      s:string;
    begin
    try
      for i:=0 to getcount-1 do
      begin
        temp:=tlst.LockList.Items[i]; // вот это место. Как Вам кажется, это правильно, или не?
        if assigned(temp) then
        n:=temp.filename;
        if n='ololo' then   // это просто пример, не смеемся) АХАХАХАХ )
        begin
          showmessage('Сканирование этого файла уже выполняется') ;
          exit;
        end;
      end;
      tmythread.create('ololo');
      except
      end;
    end;
    
    end.

    Стоит задача сканировать файлы в разных потоках. Как Вам кажется, это адекватное решение?

    Код полностью.

    Stertor, 02 Июля 2013

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

    +132

    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
    public static string[] GetLogicalDrives()
    {
    	// System.Environment.GetLogicalDrives()
    	new EnvironmentPermission(PermissionState.Unrestricted).Demand();
    	// System.IO.Directory.GetLogicalDrives()
    	new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
    
    	int logicalDrives = Win32Native.GetLogicalDrives();
    	if (logicalDrives == 0)
    	{
    		__Error.WinIOError();
    	}
    	uint num = (uint)logicalDrives;
    	int num2 = 0;
    	while (num != 0u)
    	{
    		if ((num & 1u) != 0u)
    		{
    			num2++;
    		}
    		num >>= 1;
    	}
    	string[] array = new string[num2];
    	char[] array2 = new char[]
    	{
    		'A',
    		':',
    		'\\'
    	};
    	num = (uint)logicalDrives;
    	num2 = 0;
    	while (num != 0u)
    	{
    		if ((num & 1u) != 0u)
    		{
    			array[num2++] = new string(array2);
    		}
    		num >>= 1;
    		char[] expr_6E_cp_0 = array2;
    		int expr_6E_cp_1 = 0;
    		expr_6E_cp_0[expr_6E_cp_1] += '\u0001';
    	}
    	return array;
    }

    Копался сегодня в дебрях .NET'а и нашёл 2 метода получения списка дисков:
    System.Environment.GetLogicalDrives() и System.IO.Directory.GetLogicalDrives()
    Различается код только первой срокой запроса разрешений.

    Если один метод устарел-бы, то можно было его форварднуть через атрибут TypeForwardedTo.
    Или хотя-бы объединить код вынеся запрос разрешений.

    Оба метода доступны ещё с .NET 1.1. Но вот класс DriveInfo, который появился только в .NET 2.0 использует метод Directory.GetLogicalDrives()

    Это такая "фича" с копипастом кода или тут есть какой-то сакральный смысл?

    TauSigma, 25 Июня 2013

    Комментарии (13)
  5. Pascal / Говнокод #13214

    +132

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    var
        FormMeh: TFormMeh;
        x,y,len:integer;
          x2,y2:integer;
          x3,y3:integer;
          x0,y0, y20:integer;
          xa , ya : integer;
          v1 , v2 : integer;
        x1,y1,ar,dar:integer;
        anim:integer;

    Глобальные переменные отныне РАЗРЕШЕНЫ. Утверждаю, подпись моя.

    Stertor, 23 Июня 2013

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

    +132

    1. 1
    private static string TestExistFiles(ref int maxd, ref Hashtable executedgroups)

    taburetka, 10 Июня 2013

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

    +132

    1. 1
    int count = _repository.GetObjectList().Select(x => x).Where(x => x.Id > 4).Count();

    Sql style

    neeedle, 04 Июня 2013

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

    +132

    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
    if (dest_lstat_ok)
        {
          if (S_ISDIR (dest_stats.st_mode))
            {
              error (0, 0, _("%s: cannot overwrite directory"), quote (dest));
              return false;
            }
          if (interactive)
            {
              fprintf (stderr, _("%s: replace %s? "), program_name, quote (dest));
              if (!yesno ())
                return true;
              remove_existing_files = true;
            }
    
          if (backup_type != no_backups)
            {
              dest_backup = find_backup_file_name (dest, backup_type);
              if (rename (dest, dest_backup) != 0)
                {
                  int rename_errno = errno;
                  free (dest_backup);
                  dest_backup = NULL;
                  if (rename_errno != ENOENT)
                    {
                      error (0, rename_errno, _("cannot backup %s"), quote (dest));
                      return false;
                    }
                }
            }
        }
    
      if (relative)
        source = rel_source = convert_abs_rel (source, dest);
    
      ok = ((symbolic_link ? symlink (source, dest)
             : linkat (AT_FDCWD, source, AT_FDCWD, dest,
                       logical ? AT_SYMLINK_FOLLOW : 0))
            == 0);

    Coreutils такой coreutils

    serpinski, 15 Мая 2013

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

    +132

    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
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <sys/types.h>
    
    void usage(char *progname)
    {
        fprintf(stderr,"Usage: %s [-i <interval>]\n",progname);
        exit(1);
    }
    
    int main(int argc, char *argv[])
    {
        int arg;
        size_t alloc = 1000;
        uid_t userid = getuid();
    
        while ((arg = getopt(argc,argv,"")) != -1) {
            switch(arg) {
                default:
                    usage(argv[0]);
                    break;
            }
        }
    
        //const char *basecmd = "sudo turbostat -s -i 1 2>&1";
        char ghz[8];
        char *junkbuffer = malloc(sizeof(char)*1000);
        const char *basecmd = "turbostat -s -i 1 2>&1";
    
        seteuid(0);
        setuid(0);
        FILE *turboPipe = popen(basecmd,"r");
        seteuid(userid);
        setuid(userid);
    
        /* ignore first line */
        getline(&junkbuffer,&alloc,turboPipe);
        fscanf(turboPipe,"%*s %s %*s %*s %*s %*s %*s %*s %*s %*s %*s\n",ghz);
        free(junkbuffer);
    
        fprintf(stdout,"%s\n",ghz);
        pclose(turboPipe);
    
        return 0;
    }

    Установил новый Debian на ноут. Искал инфу по Intel TurboBoost.
    Наткунлся на это
    http://technicallyliving.blogspot.com/2012/06/intel-turboboost-and-linux.html

    Улыбнул вайл-свитч. Что мешало автору обойтись без свитча?

    denis90, 09 Мая 2013

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

    +132

    1. 1
    TempClass.Area = Convert.ToDecimal(dt.Rows[0]["Area"].ToString()).ToString("F1", CultureInfo.CreateSpecificCulture("en-US"));

    Про string.format видимо мы не знаем....

    bars, 27 Апреля 2013

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

    +132

    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
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    <div class="breadcrumbs">
      <ul>
        <li>
          @if (curMenu != null)
          {
            <a href="@Url.Action("index", "main")">Главная</a><span class="breadcrumbs__dash"> / </span>
            if (depth == 1)
            {
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 2)
            {
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a> <span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 3)
            {
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 4)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 5)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 6)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 7)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 8)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }                                  
          }
          else if (ViewBag.Title != null && url!="/")
          {
            <a href="@Url.Action("index", "main")">Главная</a><span class="breadcrumbs__dash"> / </span>
            <span>@ViewBag.Title</span>
          }
        </li>
      </ul>
    </div>

    Хлебные крошки в каталоге "неограниченной" вложенности.

    validol, 19 Апреля 2013

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