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

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

    0

    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
    // реализация интерфейса IArguments2 для самодельного скриптового движка, aka vbs to exe
    
    unit Arguments;
    
    interface
    
    uses
      Windows, ComObj, ActiveX, Stub_TLB, SysUtils,WSHNamedArguments,WSHUnNamedArguments, CmdUtils;
    
    type
      TIarguments=class(TAutoObject, IArguments2, IEnumVariant)
          FAArgs:array of WideString;
          FWSHNamedArguments:TIWSHNamedArguments;
          FWSHUnNamedArguments:TIWSHUnNamedArguments;
          function Item(Index: Integer): WideString; safecall;
        function Count: Integer; safecall;
        function Get_length: Integer; safecall;
        function _NewEnum: IUnknown; safecall;
        property length: Integer read Get_length;
            function Get_Named: IWSHNamedArguments; safecall;
        function Get_Unnamed: IWSHUnnamedArguments; safecall;
        procedure ShowUsage; safecall;
        property Named: IWSHNamedArguments read Get_Named;
        property Unnamed: IWSHUnnamedArguments read Get_Unnamed;
            function Next(celt: LongWord; var rgvar : OleVariant;
          out pceltFetched: LongWord): HResult; stdcall;
        function Skip(celt: LongWord): HResult; stdcall;
        function Reset: HResult; stdcall;
        function Clone(out Enum: IEnumVariant): HResult; stdcall;
        public
        constructor Create;
        end;

    implementation

    uses ComServ;

    var
    FIndex:Integer=0;

    { TIarguments }

    function TIarguments._NewEnum: IUnknown;
    begin
    Result:=self;
    end;

    function TIarguments.Count: Integer;
    begin
    Result:=System.Length(FAArgs);
    end;

    function TIarguments.Get_length: Integer;
    begin
    Result:=Count;
    end;

    function TIarguments.Item(Index: Integer): WideString;
    begin
    if (Index >= System.Length(FAArgs)) then
    raise EOleSysError.Create('Range check error', HRESULT($800A0009),0)
    else
    Result:=FAArgs[Index]
    end;

    function TIarguments.Get_Named: IWSHNamedArguments;
    begin
    Result:=FWSHNamedArguments;
    end;

    function TIarguments.Get_Unnamed: IWSHUnnamedArguments;
    begin
    Result:=FWSHUnNamedArguments;
    end;

    procedure TIarguments.ShowUsage;
    begin
    OleError(E_NOTIMPL);
    end;

    constructor TIarguments.Create;
    var
    I,J, PCnt:Integer;
    S, CmdLine:string;
    begin
    inherited Create;
    FIndex:=0;
    FWSHNamedArguments:=TIWSHNamedArguments.Create;
    FWSHUnNamedArguments:=TIWSHUnNamedArguments.Create;
    PCnt:=ParamCount;
    SetLength(FAArgs, PCnt);
    for I:=1 to PCnt do
    begin
    J:=I-1;
    FAArgs[J]:=ParamStr(I);
    end;

    //Parsing named args.

    CmdLine:='';
    S:=GetCommandLine;
    PCnt:=iParamCount(PChar(S));
    if PCnt > 1 then
    begin
    for I:=1 to PCnt-1 do
    begin
    CmdLine:=CmdLine+iParamStr(PChar(S), I);
    if I < PCnt-1 then
    CmdLine:=CmdLine+' ';
    end;
    end;

    Support, 09 Июня 2022

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

    0

    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
    // Takes a printf-style format string and returns a formatted string.
    char *format(char *fmt, ...) {
      char *buf;
      size_t buflen;
      FILE *out = open_memstream(&buf, &buflen);
    
      va_list ap;
      va_start(ap, fmt);
      vfprintf(out, fmt, ap);
      va_end(ap);
      fclose(out);
      return buf;
    }

    kcalbCube, 25 Февраля 2022

    Комментарии (6)
  4. Python / Говнокод #28053

    +1

    1. 1
    2. 2
    if x == 2 or 3: # если x равен 2 или 3
        print('Пыщь.')

    Вот уже не впервый раз натыкаюсь на подобный "машинный перевод с русского на питон".

    Vindicar, 25 Февраля 2022

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

    0

    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
    void pong_game(void)
       {
          /*Set the first random direction the ball will be traviling*/
          direction=random_direction();
          
          /*Play the game while the ESC key is not pressed*/
          while(!key[KEY_ESC]) {
             /*Move the Ball*/
             move_ball();
             /*Respond to the input*/
             key_respond();
             
             /*Put the information on the Screen*/
             textout(buffer,pong_datafile[pong_text].dat,"Player 1 Score:",
                     150,0,254);
             textout(buffer,pong_datafile[pong_text].dat,itoa(score_p1,NULL,10),
                     text_length(pong_datafile[pong_text].dat,
                     "Player 1 Score:")+150,0,10);
             textout(buffer,pong_datafile[pong_text].dat,"Player 2 Score:",
                     350,0,254);
             textout(buffer,pong_datafile[pong_text].dat,itoa(score_p2,NULL,10),
                     text_length(pong_datafile[pong_text].dat,
                                 "Player 2 Score:")+350,0,10);
             textout(buffer,pong_datafile[pong_text].dat,"keyboard",0,0,255);
             textout(buffer,pong_datafile[pong_text].dat,"joystick",
                     640-text_length(pong_datafile[pong_text].dat,"joystick"),
                     0,255);
             /*Draw a line to set the boundries*/
             line(buffer,0,30,640,30,10);
             
             /*Put the buffer screen on the screen*/
             blit(buffer,screen,0,0,0,0,640,480);
             
             /*Clear the buffer*/
             clear(buffer);
          }
          return;
       }

    помните?

    kcalbCube, 20 Февраля 2022

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

    −4

    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
    Функция ПолучитьОсновногоБухгалтераПоОрганизации(организация) Экспорт
    
    	текстЗапроса = "
    		|ВЫБРАТЬ ПЕРВЫЕ 1
    		|	ПользовательБухгалтер
    		|ИЗ
    		|	РегистрСведений.СКАНИЯ_ОтветственныеБухгалтерыПоОрганизациям
    		|ГДЕ
    		|	Организация = &организация
    		|	И Основной = ИСТИНА
    		|";
    
    	запрос = Новый Запрос(текстЗапроса);
    	запрос.УстановитьПараметр("организация", организация);
    	
    	выборка = запрос.Выполнить().Выбрать();
    	Если выборка.Следующий() Тогда
    		возврат выборка.ПользовательБухгалтер;
    	Иначе
    		возврат Справочники.Пользователи.ПустаяСсылка();
    	КонецЕсли;
    
    КонецФункции

    alexey85, 31 Января 2022

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

    +1

    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 <stdio.h>
    #include <string.h>
    
    int main() 
    {
        char* lalka = "bagor";
        if (0!=strcmp(lalka, "bagor‮ ⁦// comment⁩ ⁦")) {
            puts("Kakoi gabor )))");
        }
        if (0!=strcmp(lalka, "bagor")){
            puts("Pituz!");
        }    
        return 0;
    }

    https://ideone.com/RiM3LX

    #stdout
    Kakoi gabor )))

    3.14159265, 27 Января 2022

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

    0

    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
    using System;
    					
    public class Program
    {
    	public static void Main()
    	{
    		69.Doeb();
    		typeof(Ext).Doeb();
    	}
    }
    
    public static class Ext
    {
    	public static void Doeb(this object o)
    	{
    		string s;
    		Type type = o.GetType();
    		s = type.ToString();
    		while(type != null)
    		{
    			type = type.BaseType;
    			try
    			{
    				s += $" > {type.ToString()}";
    			}
    			catch
    			{
    				break;
    			}
    		}
    		Console.WriteLine(s);
    	}
    }

    Ты с какого района? Чьих будешь?

    SystemGCCollect, 22 Января 2022

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

    +3

    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
    buf = malloc(8 * 1024);
    
    snprintf(buf, 8 * 1024,
         "{\n"
         "\t\"tilejson\": \"2.0.0\",\n"
         "\t\"schema\": \"xyz\",\n"
         "\t\"name\": \"%s\",\n"
         "\t\"description\": \"%s\",\n"
         "\t\"attribution\": \"%s\",\n"
         "\t\"minzoom\": %i,\n"
         "\t\"maxzoom\": %i,\n"
         "\t\"tiles\": [\n",
         tile_config->xmlname, (tile_config->description ? tile_config->description : ""), tile_config->attribution, tile_config->minzoom, tile_config->maxzoom);
    
    for (i = 0; i < tile_config->noHostnames; i++) {
        strncat(buf, "\t\t\"", 8 * 1024 - strlen(buf) - 1);
        strncat(buf, tile_config->hostnames[i], 8 * 1024 - strlen(buf) - 1);
        strncat(buf, tile_config->baseuri, 8 * 1024 - strlen(buf) - 1);
        strncat(buf, "{z}/{x}/{y}.", 8 * 1024 - strlen(buf) - 1);
        strncat(buf, tile_config->fileExtension, 8 * 1024 - strlen(buf) - 1);
        strncat(buf, "\"", 8 * 1024 - strlen(buf) - 1);
    
        if (i < tile_config->noHostnames - 1) {
            strncat(buf, ",", 8 * 1024 - strlen(buf) - 1);
        }
    
        strncat(buf, "\n", 8 * 1024 - strlen(buf) - 1);
    }
    
    strncat(buf, "\t]\n}\n", 8 * 1024 - strlen(buf) - 1);
    len = strlen(buf);
    
    /*
     * Add HTTP headers. Make this file cachable for 1 week
     */
    md5 = ap_md5_binary(r->pool, (unsigned char *)buf, len);
    apr_table_setn(r->headers_out, "ETag",
               apr_psprintf(r->pool, "\"%s\"", md5));
    ap_set_content_type(r, "application/json");
    ap_set_content_length(r, len);
    apr_table_mergen(t, "Cache-Control",
             apr_psprintf(r->pool, "max-age=%" APR_TIME_T_FMT,
                      maxAge));
    timestr = apr_palloc(r->pool, APR_RFC822_DATE_LEN);
    apr_rfc822_date(timestr, (apr_time_from_sec(maxAge) + r->request_time));
    apr_table_setn(t, "Expires", timestr);
    ap_rwrite(buf, len, r);
    free(buf);

    https://github.com/openstreetmap/mod_tile/blob/master/src/mod_tile.c#L1212

    ISO, 10 Января 2022

    Комментарии (6)
  10. JavaScript / Говнокод #27899

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    type Tree<T> = T;
    
    function main() {
    
        let a: Tree<TypeOf<1>>;
    
        a = 10;
    
        print(a);
    
        print("done.");
    }

    новый виток развития TypeScript компайлера.

    ASD_77, 28 Декабря 2021

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    Ltac2 make_match fields :=
      destruct x;
      iter (fun a => focus 1 1 (fun () =>
                               let a := a ()
                               in refine (fun () => '((w_rep $a) _)))
             ) fields.

    Итерация по конструкторам индуктивного типа данных.

    CHayT, 03 Декабря 2021

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