-
Лучший говнокод
- В номинации:
-
- За время:
-
-
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 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
-
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 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
-
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 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
-
+1
- 1
- 2
- 3
- 4
- 5
- 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
-
+1
- 1
- 2
- 3
- 4
- 5
- 6
- 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
-
+1
- 1
std::ranges::for_each(tasks, [](auto x) {x();});
а ещё теперь не нужно писать std::begin(), std::end().
c++ будущего.
digitalEugene,
10 Мая 2021
-
+1
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
func getTransport(tt string) (iTransport, error) {
if tt == "scooter" {
return newElectricScooter(), nil
}
if tt == "quadcopter" {
return newQuadcopter(), nil
}
return nil, fmt.Errorf("Wrong type")
}
https://habr.com/ru/post/556512/
> Factory Method Pattern
> Привет, друзья. С вами Alex Versus.
> Ранее мы говорили про шаблоны проектирования Одиночка и Стратегия, про тонкости реализации на языке Golang.
> Сегодня расскажу про Фабричный метод.
PolinaAksenova,
10 Мая 2021
-
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
INTERRUPT_TABLE section:
00> FF FF | . .
02> 9F 00 | . .
DATA section:
32> 48 65 6C 6C 6F 20 77 6F | Hello.wo
3A> 72 6C 64 21 00 00 00 00 | rld . . . . .
42> 00 00 00 00 00 00 00 00 | . . . . . . . .
4A> 00 00 00 00 00 00 00 00 | . . . . . . . .
_START section:
8F> 9B 00 32 00 PUSH 32
93> 18 00 00 00 INT 0
97> 18 00 01 00 INT 1
9B> 94 40 01 00 ADD %B 1
EXIT interrupt:
9F> 81 40 16 E8 MOV %B E816
A3> 20 00 00 00 RET
RUNFLOW:
8F> 9B 00 32 00 PUSH 32
93> 18 00 00 00 INT 0 DEBUG OUTPUT: Hello world!
97> 18 00 01 00 INT 1
9F> 81 40 16 E8 MOV %B E816
A3> 20 00 00 00 RET
9B> 94 40 01 00 ADD %B 1
HALT SEQUENCE REACHED: 0xE817
Закодил свою виртуальную машину и ассемблер под неё.
Заспидранил Hello world за неделю.
https://pastebin.com/NmLEuGMU
digitalEugene,
08 Мая 2021
-
+1
- 1
- 2
- 3
- 4
- 5
vector<int> res;
...
for (int i = 0; i < res.size(); i++) {
printf("%d%c", res[i], " \n"[i + 1 == res.size()]);
}
Решил вспомнить как олимпиадные задачки решать.
3_dar,
07 Мая 2021
-
+1
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
%% Generates a Normal-distributed random variable using Box-Muller method
%% from: https://github.com/basho/basho_stats/blob/develop/src/basho_stats_rv.erl
-spec rnd_normal(integer(), integer()) -> non_neg_integer().
rnd_normal(Mean, Sigma) ->
Rv1 = random:uniform(),
Rv2 = random:uniform(),
Rho = math:sqrt(-2 * math:log(1-Rv2)),
abs(trunc(Rho * math:cos(2 * math:pi() * Rv1) * Sigma + Mean)).
Это норма.
CHayT,
07 Мая 2021