- 1
https://i.imgur.com/7uRLULs.mp4
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Всего: 335
+1
https://i.imgur.com/7uRLULs.mp4
Аппаратная нейросеть в мозгах петуха совершила ошибку классификации.
+2
void add_SSE(uint8_t a[static 7], uint8_t b[static 7], uint8_t out[static 7])
{
uint64_t a_64 = 0;
uint64_t b_64 = 0;
for (size_t i = 0; i < 7; i++) // можно наанроллить
{
a_64 |= (uint64_t)a[i] << (i*9);
b_64 |= (uint64_t)b[i] << (i*9);
}
uint64_t c_64 = a_64 + b_64;
for (size_t i = 0; i < 7; i++) // можно наанроллить
{
out[i] = (uint64_t)c_64 >> (i*9);
}
}
SSE
+3
// https://github.com/TigerVNC/tigervnc/blob/8c6c584377feba0e3b99eecb3ef33b28cee318cb/java/com/jcraft/jsch/Buffer.java#L65-L85
public void putInt(int val) {
tmp[0]=(byte)(val >>> 24);
tmp[1]=(byte)(val >>> 16);
tmp[2]=(byte)(val >>> 8);
tmp[3]=(byte)(val);
System.arraycopy(tmp, 0, buffer, index, 4);
index+=4;
}
public void putLong(long val) {
tmp[0]=(byte)(val >>> 56);
tmp[1]=(byte)(val >>> 48);
tmp[2]=(byte)(val >>> 40);
tmp[3]=(byte)(val >>> 32);
System.arraycopy(tmp, 0, buffer, index, 4);
tmp[0]=(byte)(val >>> 24);
tmp[1]=(byte)(val >>> 16);
tmp[2]=(byte)(val >>> 8);
tmp[3]=(byte)(val);
System.arraycopy(tmp, 0, buffer, index+4, 4);
index+=8;
}
Жабовское байтоебство (судя по всему это такой ntohl) из реализации VNC.
Вот интересно, в жабке-то unsigned типов нет нихера, но почему-то сделали unsigned двоичный сдвиг (>>>), который работает для этих встроенных signed типов как если б это были unsigned. А как насчет unsigned умножения и деления (сложение и вычитание - то один хер, без разницы, если у нас two's complement)?
+2
https://www.opennet.ru/opennews/art.shtml?num=50026
После двух лет разработки компания The Qt Company представила
компактный встроенный http-сервер для Qt, доступный для
разработчиков приложений в виде класса QHttpServer. Сервер
пока развивается как экспериментальный проект Qt Labs, но
запланирован для включения в основной состав Qt 6.
Вот жеж этим [censored] делать нехер. Вы уже в Qt встроили жабаскрипт ( https://doc.qt.io/qt-5/topics-scripting.html ), и даже встроили браузер, но вам этого мало, вы еще и вебсервер встроили. Встройте еще туда и PHP, чтоб вообще всё возможное говно в себя вобрать
+4
Yandere Simulator
https://f0ck.me/b/09d3f680.mp4
+2
// https://www.tutorialspoint.com/Read-a-character-from-standard-input-without-waiting-for-a-newline-in-Cplusplus
// A portable solution doesn't exist for doing this. On windows, you can use the getch() function from the conio(Console I/O) library to get characters pressed. For example,
#include<iostream>
#include<conio.h>
using namespace std;
int main() {
char c;
while(1){ // infinite loop
c = getch();
cout << c;
}
}
// This will output whatever character you input to the terminal. Note that this will only work on windows as the conio library exists only on windows. On UNIX, you can achieve this by entering in system raw mode. For example,
#include<iostream>
#include<stdio.h>
int main() {
char c;
// Set the terminal to raw mode
system("stty raw");
while(1) {
c = getchar();
// terminate when "." is pressed
if(c == '.') {
system("stty cooked");
exit(0);
}
std::cout << c << " was pressed."<< std::endl;
}
}
Вариант под UNIX еще и очень секурный, ЕВПОЧЯ
−1
void sort8(uint64_t a[8])
{
uint64_t a0;
uint64_t a1;
uint64_t a2;
uint64_t a3;
uint64_t a4;
uint64_t a5;
uint64_t a6;
uint64_t a7;
SORT2(a[0], a[1], a0, a1);
SORT2(a[2], a[3], a2, a3);
SORT2(a[4], a[5], a4, a5);
SORT2(a[6], a[7], a6, a7);
uint64_t a_tmp[8];
MERGE_2_4(a0, a1, a2, a3, a_tmp[0], a_tmp[1], a_tmp[2], a_tmp[3]);
MERGE_2_4(a4, a5, a6, a7, a_tmp[4], a_tmp[5], a_tmp[6], a_tmp[7]);
uint64_t *ptra1 = &a_tmp[0];
uint64_t *ptra2 = &a_tmp[4];
for (size_t i = 0; i < 4; i++)
{
if (*ptra1 < *ptra2)
{
a[i] = *ptra1;
ptra1++;
}
else
{
a[i] = *ptra2;
ptra2++;
}
}
for (size_t i = 4; i < 8; i++)
{
if (ptra1 == &a_tmp[4])
{
while (ptra2 != &a_tmp[8])
{
a[i++] = *ptra2;
ptra2++;
}
break;
}
if (ptra2 == &a_tmp[8])
{
while (ptra1 != &a_tmp[4])
{
a[i++] = *ptra1;
ptra1++;
}
break;
}
if (*ptra1 < *ptra2)
{
a[i] = *ptra1;
ptra1++;
}
else
{
a[i] = *ptra2;
ptra2++;
}
}
}
Мерж сорт, специализированный на 8 элементов. Вот доказательство корректности https://paste.debian.net/hidden/cce6d31a/
+2
https://www.researchgate.net/publication/325358150_cQASM_v10_Towards_a_Common_Quantum_Assembly_Language
cQASM v1.0: Towards a Common Quantum Assembly Language
The quantum assembly language (QASM) is a popular intermediate representation used in many quantum compilation and simulation tools to describe quantum circuits. Currently, multiple different dialects of QASM are used in different quantum computing tools. This makes the interaction between those tools tedious and time-consuming due to the need for translators between theses different syntaxes. Beside requiring a multitude of translators, the translation process exposes the constant risk of loosing information due to the potential incompatibilities between the different dialects. Moreover, several tools introduce details of specific target hardware or qubit technologies within the QASM syntax and prevent porting the code to other hardwares. In this paper, we propose a common QASM syntax definition, named cQASM, which aims to abstract away qubit technology details and guarantee the interoperability between all the quantum compilation and simulation tools supporting this standard. Our vision is to enable an extensive quantum computing toolbox shared by all the quantum computing community.
Вот это я понимаю, а то вон там мелкософт какие-то говношарпы придумывает очередные:
https://docs.microsoft.com/en-us/quantum/language/?view=qsharp-preview
+1
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define SQARESZ 3
void rotateclockwise(char *ptra, size_t sz)
{
char (*a_ar)[sz] = (void *)ptra;
char b_ar[sz][sz];
for (size_t y = 0; y < sz; y++)
{
for (size_t x = 0; x < sz; x++)
{
b_ar[y][x] = a_ar[sz-1-x][y];
}
}
memcpy(a_ar, b_ar, sz*sz);
}
void print_ar(char *ptra, size_t sz)
{
char (*a_ar)[sz] = (void *)ptra;
for (size_t y = 0; y < sz; y++)
{
for (size_t x = 0; x < sz; x++)
{
printf("%i ", a_ar[y][x]);
}
printf("\n");
}
}
int main()
{
char a[SQARESZ][SQARESZ] =
{
{1,2,3},
{4,5,6},
{7,8,9}
};
print_ar((char *)a, SQARESZ);
printf("\n");
rotateclockwise((char *)a, SQARESZ);
print_ar((char *)a, SQARESZ);
printf("\n");
rotateclockwise((char *)a, SQARESZ);
print_ar((char *)a, SQARESZ);
printf("\n");
rotateclockwise((char *)a, SQARESZ);
print_ar((char *)a, SQARESZ);
printf("\n");
rotateclockwise((char *)a, SQARESZ);
print_ar((char *)a, SQARESZ);
printf("\n");
return 0;
}
https://habr.com/post/317300/ В C++17 до сих пор нет нормальных многомерных массивов, которые были в Fortran начиная с Fortran 90
> UPD от 2016-12-10 14:03. Посмотрел на этот коммент от @selgjos, поэкспериментировал с компилятором и понял, что с помощью C99 VLA всё-таки можно добиться нужного мне эффекта.
> В общем, окей, в C есть нужные мне массивы. Как и в Fortran. А в C++ их по-прежнему нет.
+2
/*
x86-64 clang (trunk) -O3
https://godbolt.org/z/t8NDGG
#include <inttypes.h>
uint32_t saturation_add(uint32_t a, uint32_t b)
{
const uint64_t tmp = (uint64_t)a + b;
if (tmp > UINT32_MAX)
{
return UINT32_MAX;
}
return tmp;
}
*/
saturation_add:
mov edx, esi
mov eax, edi
add edi, esi
add rax, rdx
mov edx, 4294967295
cmp rax, rdx
mov eax, -1 // ЗАЧЕМ???
cmovbe eax, edi
ret
https://en.wikipedia.org/wiki/Saturation_arithmetic
Почему компиляторы до сих пор такое говно