- 1
ты гей!
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
ты гей!
0
echo first >first.txt
echo second >second.txt
ln -s first.txt second.txt
# Выведет: ln: cannot create symbolic link from 'first.txt' to 'second.txt': File exists
mount --bind first.txt second.txt
# А так работает.
cat second.txt
#Выведет first.
Какие способы хитрой подмены файлов помимо mount --bind знаете?
0
Бесконечный оффтоп имени Гологуба #9
#1: https://govnokod.ru/28992 https://govnokod.xyz/_28992
#2: https://govnokod.ru/29053 https://govnokod.xyz/_29053
#3: https://govnokod.ru/29075 https://govnokod.xyz/_29075
#4: https://govnokod.ru/29110 https://govnokod.xyz/_29110
#5: https://govnokod.ru/29127 https://govnokod.xyz/_29127
#6: https://govnokod.ru/29140 https://govnokod.xyz/_29140
#7: https://govnokod.ru/29170 https://govnokod.xyz/_29170
#8: https://govnokod.ru/29192 https://govnokod.xyz/_29192
+1
diff -uwrd RedmiNote12/vendor_a/etc/usecaseKvManager.xml RedmiNote13/vendor_a/etc/usecaseKvManager.xml
...
- <keys_and_values StreamType="PAL_STREAM_VOIP_TX" CustomConfig="dual-mic">>
+ <keys_and_values StreamType="PAL_STREAM_VOIP_TX" CustomConfig="dual-mic">
Сравнил две прошивки. Это неполный пример, зато пиздец полный.
0
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
if CONFIG['OS_ARCH'] == 'WINNT':
DIRS += ['win']
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
DIRS += ['mac']
elif CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3'):
DIRS += ['unix']
else:
DIRS += ['emacs']
2 часа пытался понять, почему ctrl+a работает как в терминале...
Это мёртвый код или пасхалка?
0
cin >> N >> L >> T;
total = 0;
for (int i = 0; i < N; i++) {
cin >> S[i] >> H[i] >> P[i];
total += H[i] * P[i];
}
fix_order();
for (int ind = 0; ind < N; ind++) {
int len = ind + 1;
set<pair<long long, int>> events, comps;
vector<long long> sum_hp(len);
copy(H, H + len, sum_hp.begin());
sum_hp[ind] = 0;
vector<int> ord(len);
iota(ord.begin(), ord.end(), 0);
sort(ord.begin(), ord.end(), [&](int i, int j) {
return S[i] < S[j];
});
comps.emplace(T, -1);
for (int i = 0; i < len; i++) {
int j = i + 1;
while (j < len && S[ord[i]] == S[ord[j]]) {
sum_hp[ord[i]] += sum_hp[ord[j]];
++j;
}
comps.emplace(S[ord[i]], ord[i]);
i = j - 1;
}
for (auto it = comps.begin(); next(it) != comps.end(); ++it) {
long long dist = next(it)->first - it->first;
int idx = it->second;
if (sum_hp[idx] > 0) {
events.emplace((dist + sum_hp[idx] - 1) / sum_hp[idx], idx);
}
}
vector<bool> visited(len);
vector<bool> added(len);
long long good_sum = 0, last_time = 0, govno = T, rakom_bokom = 0;
for (auto [spawn, i] : comps) {
if (spawn >= S[ind] && i != -1) {
good_sum += sum_hp[i];
added[i] = true;
}
}
auto Upd = [&](long long time) -> void {
long long F = govno - S[ind] - rakom_bokom;
if (F <= 0) {
return;
}
long long r1 = clamp(F / (H[ind] + good_sum) + 1, last_time, time);
long long r2 = good_sum == 0 ? time : clamp(F / good_sum + 1, last_time, time);
dp_diff_i[last_time] += H[ind] * P[ind];
dp_diff_i[r1] -= H[ind] * P[ind];
dp_diff[r1] += F * P[ind];
dp_diff[r2] -= F * P[ind];
dp_diff_i[r1] -= good_sum * P[ind];
dp_diff_i[r2] += good_sum * P[ind];
last_time = time;
};
vector<bool> skip(len), finished(len);
while (!events.empty()) {
auto [time, i] = *events.begin();
events.erase(events.begin());
if (time > L) {
break;
}
if (skip[i] || sum_hp[i] == 0) {
continue;
}
Upd(time);
auto it = comps.upper_bound({S[i], INT_MAX});
if (it->second == -1 || finished[it->second]) {
good_sum -= sum_hp[i];
finished[i] = true;
govno = S[i];
continue;
}
if (!added[i] && it->second + sum_hp[i] * time >= S[ind]) {
added[i] = true;
good_sum += sum_hp[i];
rakom_bokom += S[i] - S[ind];
}
sum_hp[i] += sum_hp[it->second];
skip[it->second] = true;
long long next_pos = next(it)->first;
comps.erase(it);
events.emplace(time + (next_pos - S[i] - sum_hp[i] * time + sum_hp[i] - 1) / sum_hp[i], i);
}
Upd(L + 1);
}
long long cur_diff = 0, cur_diff_i = 0;
for (int i = 0; i <= L; i++) {
cur_diff += dp_diff[i];
cur_diff_i += dp_diff_i[i];
dp[i] = cur_diff + cur_diff_i * i;
}
олимпиадное говно
0
ORDER BY (|lng - :lng| + |lat - :lat|) ASC LIMIT 1
«Иногда нам нужно определить местоположение пользователя, когда мы точно знаем его координаты (например получили их используя датчики GPS устройства или Geolocation API в браузере). Тут есть два варианта — обратное геокодирование нам возвращает название того места, где находится пользователь. Но что произойдет, если пользователь находится где-то на трассе между городами, или в пригороде или просто в чистом поле и хочет посмотреть объявления о продаже участков на этом поле? Не всегда обратный геокодер с этим справится.
В этом случае лично я поступаю так — у меня в базе данных хранятся все координаты городов России, в которых у нас имеются объявления и с которыми мы вообще работаем. И по координатам пользователя я просто определяю ближайший к нему город из нашей базы, с помощью простого запроса.»
С Х-ра. Кто сразу поймёт, почему эта формула плоха?
0
import itertools
import time
n = int(input())
a = []
sm = 0
for i in range(n):
a.append(list(map(int, input().split())))
a[i].sort()
sm += a[i][0] + a[i][1]
mx = 0
a.sort()
for i in itertools.product([0, 1], repeat=n - 1):
if time.process_time() > 0.75:
break
s = 0
for j in range(n):
if j >= 1:
s += a[j][i[j - 1]]
else:
s += a[j][0]
s2 = sm - s
if s % 3 == 0 and s > mx:
mx = s
if s2 > mx and s2 % 3 == 0:
mx = s2
print(mx)
Задача с ЕГЭ: "Даны пары (A[i][0], A[i][1]), в каждой паре нужно выбрать одно число, при этом сумма выбранных чисел должна делится на 3, среди таких сумм найти максимальную"
Автор данного кода не справился нормально соптимизировать решение, поэтому написал какую-то х**ню, результат видите выше (особенно строчка 13)
Оно зашло на тестах, где n <= 20
0
/* IOCTL calls for E-Ink paper update */
#define EPAPER_UPDATE_LOCAL 0x101 /** Update localarea */
#define EPAPER_UPDATE_PART 0x102 /** ??? */
#define EPAPER_UPDATE_FULL 0x103 /** Fully update */
#define EPAPER_UPDATE_DISPLAY_QT 0x120d /** Update all display
/* Helper FB update function */
int epaper_update_helper(int fb, unsigned long int ioctl_call, void *mode)
{
if (framebuffer_descriptor >= 0)
{
errno=0;
ioctl(fb, ioctl_call, mode);
// sleep_timer=sleep_timeout; // Reset sleep timer on every display refresh = we are not have any constantly refreshing display parts now!
return errno;
}
return TRUE;
}
void epaperUpdate(__attribute__((unused)) unsigned long int ioctl_call, __attribute__((unused)) void *mode)
{
#ifndef __amd64
int ioctl_result;
#endif //__amd64
TRACE("Called void epaperUpdate()\n");
if (enable_refresh == FALSE)
{
TRACE("Display refresh was locked, IGNORED!\n");
(void) ioctl_call;
(void) mode;
return;
}
#ifndef __amd64
/* Иначе запись в видеопамять не успевает завершиться и получаем верхний левый угол новой картинки и нижний правый - прежней. */
// if (hw_platform != HW_PLATFORM_SIBRARY_GTK) {
// const struct timespec delay = {0, QT_REFRESH_DELAY};
// nanosleep(&delay, NULL);
// }
ioctl_result=epaper_update_helper(framebuffer_descriptor, ioctl_call, mode);
#ifdef debug
if (ioctl_result != 0)
{
TRACE("Display refresh ioctl call FAILED %d (%s)\n", ioctl_result, strerror(ioctl_result));
// GTK прошивка, обновление от Qt: 1 (Операция не позволяется)
// Qt прошивка, обновление от GTK: 22 (Недопустимый аргумент)
}
#else
(void) ioctl_result;
#endif
#endif
return;
}
int detect_refresh_type (void)
{
int mode=3;
#if 0
struct mxcfb_update_data data = {
.update_region =
{ .top = 0,
.left = 0,
.width = 1,
.height = 1
},
.update_mode = UPDATE_MODE_FULL,
.update_marker = 0,
.waveform_mode = WAVEFORM_MODE_AUTO,
.temp = TEMP_USE_AMBIENT,
.flags = 0
};
#endif
if (epaper_update_helper(framebuffer_descriptor, EPAPER_UPDATE_DISPLAY_QT, &mode) == 0)
{
refresh_type=REFRESH_NEW;
TRACE("Display refresh was successed, new\n");
}
else if (epaper_update_helper(framebuffer_descriptor, EPAPER_UPDATE_FULL, &mode) == 0)
{
refresh_type=REFRESH_LEGACY;
TRACE("Display refresh was successed, legacy\n");
}
// else if (epaper_update_helper(framebuffer_descriptor, MXCFB_SEND_UPDATE_ORG, &data) == 0)
// {
// refresh_type=REFRESH_KOBO;
// TRACE("Display refresh was successed, kobo\n");
// }
else
{
TRACE("Display refresh was not detected!\n");
}
return (refresh_type);
}
Источник:
https://github.com/gheorghe-crihan/digma-e605-qt-apps-framework/blob/master/firstapp/digma_hw.c
Не то, чтобы говно, просто код испещрён #if 0 и комментариями.
0
IT Оффтоп #227
#197: https://govnokod.ru/28935 https://govnokod.xyz/_28935
#198: https://govnokod.ru/28938 https://govnokod.xyz/_28938
#199: https://govnokod.ru/28942 https://govnokod.xyz/_28942
#200: https://govnokod.ru/28945 https://govnokod.xyz/_28945
#201: https://govnokod.ru/28948 https://govnokod.xyz/_28948
#202: https://govnokod.ru/28951 https://govnokod.xyz/_28951
#203: https://govnokod.ru/28954 https://govnokod.xyz/_28954
#204: https://govnokod.ru/28971 https://govnokod.xyz/_28971
#205: https://govnokod.ru/28986 https://govnokod.xyz/_28986
#206: https://govnokod.ru/28991 https://govnokod.xyz/_28991
#207: https://govnokod.ru/29002 https://govnokod.xyz/_29002
#208: https://govnokod.ru/29060 https://govnokod.xyz/_29060
#209: https://govnokod.ru/29070 https://govnokod.xyz/_29070
#210: https://govnokod.ru/29079 https://govnokod.xyz/_29079
#211: https://govnokod.ru/29092 https://govnokod.xyz/_29092
#212: https://govnokod.ru/29093 https://govnokod.xyz/_29093
#213: https://govnokod.ru/29104 https://govnokod.xyz/_29104
#214: https://govnokod.ru/29114 https://govnokod.xyz/_29114
#215: https://govnokod.ru/29125 https://govnokod.xyz/_29125
#216: https://govnokod.ru/29132 https://govnokod.xyz/_29132
#217: https://govnokod.ru/29147 https://govnokod.xyz/_29147
#218: https://govnokod.ru/29156 https://govnokod.xyz/_29156
#219: https://govnokod.ru/29166 https://govnokod.xyz/_29166
#220: https://govnokod.ru/29181 https://govnokod.xyz/_29181
#221: https://govnokod.ru/29185 https://govnokod.xyz/_29185
#222: https://govnokod.ru/29190 https://govnokod.xyz/_29190
#223: https://govnokod.ru/29203 https://govnokod.xyz/_29203
#224: https://govnokod.ru/29211 https://govnokod.xyz/_29211
#225: https://govnokod.ru/29212 https://govnokod.xyz/_29212
#226: https://govnokod.ru/29218 https://govnokod.xyz/_29218