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

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

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

    cdpoma, 01 Июня 2021

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

    +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
    15. 15
    16. 16
    17. 17
    18. 18
    template<typename ReturnType, typename... Arguments>
    std::enable_if_t<!std::is_same_v<ReturnType, void>, std::deque<ReturnType>>
    emit(Event<ReturnType, Arguments...>& event, const std::tuple<Arguments...>& args)
    {
    	std::deque<ReturnType> toReturn;
    
    	for (auto&& c : event.subscribers | std::views::values)
    		toReturn.push_back(std::apply(c, args));
    
    	return toReturn;
    }
    
    template<typename ReturnType, typename... Arguments>
    void emit(Event<ReturnType, Arguments...>& event, const std::tuple<Arguments...>& args)
    {
    	for (auto&& c : event.subscribers | std::views::values)
    		std::apply(c, args);
    }

    кодить всё же надо трезвым.

    digitalEugene, 30 Мая 2021

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

    +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
    15. 15
    16. 16
    17. 17
    from bs4 import BeautifulSoup
    import requests
    
    user = "**********"
    r = requests.get('https://www.last.fm/user/' + user)
    soup = BeautifulSoup(r.content, 'html.parser')
    page = soup.prettify()
    
    #Top artists
    print(
    page[int(page.find('’s top artists: ') + len('’s top artists: ')):int(page.find('. Get your own music profile at Last.fm')):]
    )
    
    #Top track
    print(
    ''.join(i if i != "+" else " " for i in (page[int(page.find('data-analytics-action="FeaturedTrackTrackName" href="/music/') + len('data-analytics-action="FeaturedTrackTrackName" href="/music/')):int(page.find('/_/', int(page.find('data-analytics-action="FeaturedTrackTrackName" href="/music/') + len('data-analytics-action="FeaturedTrackTrackName" href="/music/')))):] + " - " + page[int(page.find('/_/')) + 3:page.find('"', int(page.find('/_/'))):]))
    )

    Сбор с lastfm любимых исполнителей и любимого трека

    G-Chist, 28 Мая 2021

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

    +1

    1. 1
    1/-~a

    Если тоже задолбались писать скобочки

    1/(a+1)

    3_dar, 26 Мая 2021

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

    +1

    1. 1
    IT Оффтоп #90

    #60: https://govnokod.ru/26949 https://govnokod.xyz/_26949
    #61: https://govnokod.ru/26980 https://govnokod.xyz/_26980
    #62: https://govnokod.ru/26999 https://govnokod.xyz/_26999
    #63: https://govnokod.ru/27004 https://govnokod.xyz/_27004
    #64: https://govnokod.ru/27020 https://govnokod.xyz/_27020
    #65: https://govnokod.ru/27027 https://govnokod.xyz/_27027
    #66: https://govnokod.ru/27040 https://govnokod.xyz/_27040
    #67: https://govnokod.ru/27049 https://govnokod.xyz/_27049
    #68: https://govnokod.ru/27061 https://govnokod.xyz/_27061
    #69: https://govnokod.ru/27071 https://govnokod.xyz/_27071
    #70: https://govnokod.ru/27097 https://govnokod.xyz/_27097
    #71: https://govnokod.ru/27115 https://govnokod.xyz/_27115
    #72: https://govnokod.ru/27120 https://govnokod.xyz/_27120
    #73: https://govnokod.ru/27136 https://govnokod.xyz/_27136
    #74: https://govnokod.ru/27160 https://govnokod.xyz/_27160
    #75: https://govnokod.ru/27166 https://govnokod.xyz/_27166
    #76: https://govnokod.ru/27168 https://govnokod.xyz/_27168
    #77: https://govnokod.ru/27186 https://govnokod.xyz/_27186
    #78: https://govnokod.ru/27219 https://govnokod.xyz/_27219
    #79: https://govnokod.ru/27254 https://govnokod.xyz/_27254
    #80: https://govnokod.ru/27270 https://govnokod.xyz/_27270
    #81: https://govnokod.ru/27280 https://govnokod.xyz/_27280
    #82: https://govnokod.ru/27284 https://govnokod.xyz/_27284
    #83: https://govnokod.ru/27296 https://govnokod.xyz/_27296
    #84: https://govnokod.ru/27336 https://govnokod.xyz/_27336
    #85: https://govnokod.ru/27381 https://govnokod.xyz/_27381
    #86: https://govnokod.ru/27405 https://govnokod.xyz/_27405
    #87: https://govnokod.ru/27429 https://govnokod.xyz/_27429
    #88: https://govnokod.ru/27432 https://govnokod.xyz/_27432
    #89: https://govnokod.ru/27435 https://govnokod.xyz/_27435

    nepeKamHblu_nemyx, 25 Мая 2021

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

    +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
    15. 15
    16. 16
    17. 17
    using Headbin=System;
    
    namespace NVidiaOptimizer
    {
    	class NVO
    	{
    		[Headbin.STAThread]
    		static unsafe void Main(string[]args)
    		{
    			while (true)
    			{
    				Headbin.Runtime.InteropServices.Marshal.PrelinkAll(typeof(NVO));
    				float piz = (float)Headbin.Runtime.InteropServices.Marshal.AllocHGlobal(sizeof(float) * 45);
    			}
    		}
    	}
    }

    Утечка ОЗУ наглядно...
    (Осторожно, утекает быстро, как в речке)

    DartPower, 25 Мая 2021

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

    +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
    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
    _Return_type_success_(return != false) bool CEnumerateSerial::UsingCreateFile(_Inout_ CPortsArray& ports)
    {
      //Reset the output parameter
      ports.clear();
    
      //Up to 255 COM ports are supported so we iterate through all of them seeing
      //if we can open them or if we fail to open them, get an access denied or general error error.
      //Both of these cases indicate that there is a COM port at that number. 
      for (UINT i=1; i<256; i++)
      {
        //Form the Raw device name
        ATL::CAtlString sPort;
        sPort.Format(_T("\\\\.\\COM%u"), i);
    
        //Try to open the port
        bool bSuccess = false;
        ATL::CHandle port(CreateFile(sPort, GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr));
        if (port == INVALID_HANDLE_VALUE)
        {
          const DWORD dwError = GetLastError();
    
          //Check to see if the error was because some other app had the port open or a general failure
          if ((dwError == ERROR_ACCESS_DENIED) || (dwError == ERROR_GEN_FAILURE) || (dwError == ERROR_SHARING_VIOLATION) || (dwError == ERROR_SEM_TIMEOUT))
            bSuccess = true;
        }
        else
        {
          //The port was opened successfully
          bSuccess = true;
        }
    
        //Add the port number to the array which will be returned
        if (bSuccess)
    #pragma warning(suppress: 26489)
          ports.push_back(i);
      }
    
      //Return the success indicator
      return true;
    }

    некоторые джавамэны вот таким гордятся

    > Internally the code provides 10 different ways (yes you read that right: Ten)

    еще и выложено под ни с чем не совместимой лицензией

    gologub, 23 Мая 2021

    Комментарии (32)
  9. Assembler / Говнокод #27418

    +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
    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
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    .ALIAS HALT 10h
    .ALIAS VBI   0h
    .ALIAS VPUSCRADDR 3000h
    .ALIAS VPUATRADDR 3002h
    .ALIAS VPUCTRL 3004h
    .ALIAS VPUCTRL_WH 3005h
    .ALIAS VPUCTRL_F 3006h
    .ALIAS VPUCTRL_VBI 0
    .ALIAS VPUCTRL_ACT 1
    .ALIAS VPUCTRL_TICK 2
    
    .ALIAS W 10
    .ALIAS H 5
    
    .ALIAS I   %BL
    .ALIAS PTR %C
    
    .ORG 2000h SCR:
    .ORG 2100h ATR:
    
    .ORG #VBI
    DD @VBI
    
    .ORG 30h
    DATA:
    
    .ORG 40h
    STATE:
    	X: DB 0
    	
    .ORG 80h
    _START:
    	SET   %AL #VPUCTRL_VBI
    	SET   %AL #VPUCTRL_ACT
    	STORE %AL #VPUCTRL_F
    	MOV   %AL #H
    	SHL   %AL 4
    	OR    %AL #W
    
    	STORE %AL #VPUCTRL_WH
    	
    	MOV   %A @SCR
    	STORE %A #VPUSCRADDR
    	MOV   %A @ATR
    	STORE %A #VPUATRADDR
    	
    	LOAD  %AL #VPUCTRL_F
    	SET   %AL #VPUCTRL_TICK
    	STORE %AL #VPUCTRL_F
    	STORE %AL #VPUCTRL_F
    	LOOP:
    	JMP @LOOP
    
    VBI:
    	PUSH  %A
    	PUSH  %B
    	PUSH  %C
    	
    	LOAD  %AL @X
    	ADD   %AL 1
    	
    	CMP   %AL #W JNE @VBI_CONTINUE
    	XOR   %AL %AL     VBI_CONTINUE:
    	STORE %AL @X
    	
    	CMP   %AL 0  JNE @VBI_ELSE
    		MOV   #PTR @SCR
    		ADD   #PTR #W
    		SUB   #PTR 1
    		STORE #PTR %AL 
    		JMP @VBI_SKIP
    	
    	VBI_ELSE:
    		MOV   #PTR @SCR
    		ADD   #PTR %AL
    		SUB   #PTR 1
    		MOV   %BH 0
    		STORE #PTR %BH
    	VBI_SKIP:
    
    	MOV   #PTR @SCR
    	ADD   #PTR %AL
    	MOV   %BH  FFh
    	STORE #PTR %BH
    	
    	POP %C
    	POP %B
    	POP %A
    	RET

    похождения моей ебанутой вмки продолжаются.
    bormand сказало что писать подставным прерыванием в консольку это читерство. реализовал видеовывод. теперь нормально? (слегка криво, и на
    атрибуты вмке похуй, как и мне.)

    вопреки моим огромным сомнениям, выдает 600 фпс даже на моей скромной конфигурации.

    https://imgur.com/fdLlQvx

    digitalEugene, 11 Мая 2021

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function main() {    
        const x = 21;
        let s = "foo";
        const r = `a${x * 2}X${s}X${s}Z`;
        print(r);
    }

    Продолжаем будни говно-писания говно-компилятора на LLVM. серия - а ваш говно-компилятор может так...

    и результат работы
    >>
    C:\temp\MLIR_to_exe>out.exe
    a42XfooXfooZ

    ASD_77, 10 Мая 2021

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if constexpr (BusMode::BLOCKING == mode) {
        derived()->send_block(arr, num);
    } else if (BusMode::IT == mode){
        derived()->send_it(arr, num);
    } else if (BusMode::DMA == mode){
        derived()->send_dma(arr, num);
    }

    https://habr.com/ru/post/556144/
    > Отладочный вывод на микроконтроллерах: как Concepts и Ranges отправили мой printf на покой
    Стреляем себе в ногу при помощи if constexpr.

    PolinaAksenova, 10 Мая 2021

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