- 1
Похоже Сальвадор Дали посвятил свою картину "Великий мастурбатор" мне.
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−2
Похоже Сальвадор Дали посвятил свою картину "Великий мастурбатор" мне.
0
def neg(x): return int(bin(x)[2:].rjust(8, '0').replace('1','x').replace('0','1').replace('x','0'), 2)
Операция "NEG"
+1
/* Python:
def A004086(n):
return int(str(n)[::-1])
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int A004086(int n) {
char str[12]; // Enough to hold the string representation of an int
sprintf(str, "%d", n);
int len = strlen(str);
char reversed[12];
for (int i = 0; i < len; i++) {
reversed[i] = str[len - 1 - i];
}
reversed[len] = '\0'; // Null-terminate the string
return atoi(reversed);
}
Результат переписывание с "Python" на "C". A004086 это последовательность из OEIS https://oeis.org/A004086
0
Если Пользователи.ТекущийПользователь() = Справочники.Пользователи.НайтиПоРеквизиту("ИдентификаторПользователяИБ",
Новый УникальныйИдентификатор("4479997c-b5d3-4928-a870-47fdf5bb1977"))
ИЛИ Пользователи.ТекущийПользователь() = Справочники.Пользователи.НайтиПоРеквизиту("ИдентификаторПользователяИБ",
Новый УникальныйИдентификатор("a1c3d77c-e00e-11e7-6d89-fa163e419b69")) Тогда
ЗапретНайден = ДИТ_ПолучитьЗапретИзмененияДанных();
Если ЗапретНайден Тогда
ДИТ_УстановитьТолькоПросмотрДляПользователя();
КонецЕсли;
КонецЕсли;
+2
Итак, господа.
...В этом году послания от Шугар Плюм Файри-и не будет. Вместо нее вас поздравлю я.
...Зимандр будет умеренно суровый, от слова "умеренно".
...Войнах, как мы видим, в этом году не закончился, более того, нас уже осыпают поздравляшками с самолетиков. Похоже, поэтому и не пришла снегурочка - стало стыдно, что подпиздела, ну, или что уже не целка. Ладно. Не суть.
Суть в том, что в этом году (и в последующих) многие семьи получат по украинской шкатулочке. А к тем, кто был не настолько глуп, чтобы идти на убой, морозя жопу и попутно разбазаривая боезапас на белок (а может, просто очко играло?), дедушка-мороз прилетит на дроне.
В общем, с праздником. Пусть не последним он будет.
+1
Новогодний оффтоп #5
░░░░░░░░░░░░░░░░░▐▌░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░▀████▀░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░▄█▀▀█▄░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░▄▄░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░▄████▄░░░░░░░░░░░░░░░
░░░░░░░░░░░▄▄██╬██╬████▄▄░░░░░░░░░░░
░░░░░░░░▀███████╬███╬██████▀░░░░░░░░
░░░░░░░░░░▄▄█╬████╬█████▄▄░░░░░░░░░░
░░░░▄▄▄▄██╬████╬█████╬███╬██▄▄▄▄░░░░
░░░░░░▀▀████╬█████╬█████████▀▀░░░░░░
░░░░░░░░░▄█████╬██████╬███▄░░░░░░░░░
░░▄▄▄▄██████╬█████╬███████╬███▄▄▄▄░░
░░▀▀▀████╬█████╬████╬███╬██████▀▀▀░░
░░░░░░░░████╬████████╬██████░░░░░░░░
░░▄▄▄█████╬██████╬█████╬███╬███▄▄▄░░
▀▀▀████╬█████╬█████╬████╬███╬████▀▀▀
░░░░░░▀▀▀██████████████████▀▀▀░░░░░░
░░░░░░░░░░░░░░░░████░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░████░░░░░░░░░░░░░░░░
#1: https://govnokod.ru/27188 https://govnokod.xyz/_27188
#2: https://govnokod.ru/27893 https://govnokod.xyz/_27893
#3: https://govnokod.ru/28484 https://govnokod.xyz/_28484
#4: https://govnokod.ru/28896 https://govnokod.xyz/_28896
0
/* Windows doesn't support the fork() call; so we fake it by invoking
another copy of Wget with the same arguments with which we were
invoked. The child copy of Wget should perform the same initialization
sequence as the parent; so we should have two processes that are
essentially identical. We create a specially named section object that
allows the child to distinguish itself from the parent and is used to
exchange information between the two processes. We use an event object
for synchronization. */
static void
fake_fork (void)
{
char exe[MAX_PATH + 1];
DWORD exe_len, le;
SECURITY_ATTRIBUTES sa;
HANDLE section, event, h[2];
STARTUPINFO si;
PROCESS_INFORMATION pi;
struct fake_fork_info *info;
char *name;
BOOL rv;
section = pi.hProcess = pi.hThread = NULL;
/* Get the fully qualified name of our executable. This is more reliable
than using argv[0]. */
exe_len = GetModuleFileName (GetModuleHandle (NULL), exe, sizeof (exe));
if (!exe_len || (exe_len >= sizeof (exe)))
return;
sa.nLength = sizeof (sa);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
/* Create an anonymous inheritable event object that starts out
non-signaled. */
event = CreateEvent (&sa, FALSE, FALSE, NULL);
if (!event)
return;
/* Create the child process detached form the current console and in a
suspended state. */
xzero (si);
si.cb = sizeof (si);
rv = CreateProcess (exe, GetCommandLine (), NULL, NULL, TRUE,
CREATE_SUSPENDED | DETACHED_PROCESS,
NULL, NULL, &si, &pi);
if (!rv)
goto cleanup;
/* Create a named section object with a name based on the process id of
the child. */
name = make_section_name (pi.dwProcessId);
section =
CreateFileMapping (INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0,
sizeof (struct fake_fork_info), name);
le = GetLastError();
xfree (name);
/* Fail if the section object already exists (should not happen). */
if (!section || (le == ERROR_ALREADY_EXISTS))
{
rv = FALSE;
goto cleanup;
}
/* Copy the event handle into the section object. */
info = MapViewOfFile (section, FILE_MAP_WRITE, 0, 0, 0);
if (!info)
{
rv = FALSE;
goto cleanup;
}
info->event = event;
UnmapViewOfFile (info);
/* Start the child process. */
rv = ResumeThread (pi.hThread);
if (!rv)
{
TerminateProcess (pi.hProcess, (DWORD) -1);
goto cleanup;
}
/* Wait for the child to signal to us that it has done its part. If it
terminates before signaling us it's an error. */
h[0] = event;
h[1] = pi.hProcess;
rv = WAIT_OBJECT_0 == WaitForMultipleObjects (2, h, FALSE, 5 * 60 * 1000);
if (!rv)
goto cleanup;
info = MapViewOfFile (section, FILE_MAP_READ, 0, 0, 0);
if (!info)
{
rv = FALSE;
goto cleanup;
}
Из исходников wget.
https://git.savannah.gnu.org/cgit/wget.git/tree/src/mswindows.c
0
public static String getJoinedHeaderTypes(List<String> types, String delimiter) {
if (!types.isEmpty() && types.size() > 1) {
return String.join(delimiter, types);
} else if (types.size() == 1) {
return types.stream().findFirst().get();
}
return "";
}
Когда тебе рассказали, что есть стримы...
0
Говновозный оффтоп #1
_.--,_......----..__
\ .' ' ```--...__ \
\; ' . '. ||
: ' ' \ .''.
.'; : ' .| |.--..___
/ \ | : :| /.------.\
/ .'._ : | || || |\\
/.-. /|-| `-. : ;| ||______|_\`.______
// // |-| \ ' ' / | ||=' | | `.
// //\\|-| `-._' ' .' | || | | \
/.-.// \\-|_________```------------` ___'. || | '_.--. <)
'._.' / .-----. .-----. .''''''''. |'--..____| / _ \ |
|_/.' '.\_/.' '.\_[ [ [ ] ] ]___|_________.'.' '.\ ]
: .-. : : .-. : '........' (_________): .-. :`-'
: '-' : : '-' : : '-' :
'._ _.' '._ _.' '._ _.'
Предыдущих оффтопов нету.
0
Просто оффтоп #41
#11: https://govnokod.ru/27122 https://govnokod.xyz/_27122
#12: https://govnokod.ru/27153 https://govnokod.xyz/_27153
#13: https://govnokod.ru/27159 https://govnokod.xyz/_27159
#14: https://govnokod.ru/27200 https://govnokod.xyz/_27200
#15: https://govnokod.ru/27237 https://govnokod.xyz/_27237
#16: (vanished) https://govnokod.xyz/_27282
#17: https://govnokod.ru/27319 https://govnokod.xyz/_27319
#18: https://govnokod.ru/27380 https://govnokod.xyz/_27380
#19: (vanished) https://govnokod.xyz/_27500
#20: https://govnokod.ru/27607 https://govnokod.xyz/_27607
#21: https://govnokod.ru/27951 https://govnokod.xyz/_27951
#22: https://govnokod.ru/28076 https://govnokod.xyz/_28076
#23: https://govnokod.ru/28266 https://govnokod.xyz/_28266
#24: https://govnokod.ru/28373 https://govnokod.xyz/_28373
#25: https://govnokod.ru/28474 https://govnokod.xyz/_28474
#26: https://govnokod.ru/28563 https://govnokod.xyz/_28563
#27: https://govnokod.ru/28645 https://govnokod.xyz/_28645
#28: (vanished) https://govnokod.xyz/_28664
#29: https://govnokod.ru/28674 https://govnokod.xyz/_28674
#30: https://govnokod.ru/28680 https://govnokod.xyz/_28680
#31: https://govnokod.ru/28688 https://govnokod.xyz/_28688
#32: https://govnokod.ru/28695 https://govnokod.xyz/_28695
#33: https://govnokod.ru/28702 https://govnokod.xyz/_28702
#34: (vanished) https://govnokod.xyz/_28708
#35: https://govnokod.ru/28715 https://govnokod.xyz/_28715
#36: https://govnokod.ru/28725 https://govnokod.xyz/_28725
#37: https://govnokod.ru/28733 https://govnokod.xyz/_28733
#38: (vanished) https://govnokod.xyz/_28748
#39: https://govnokod.ru/28758 https://govnokod.xyz/_28758
#40: https://govnokod.ru/28885 https://govnokod.xyz/_28885