- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
services:
zookeeper:
image: docker.io/bitnami/zookeeper:3.7
environment:
ALLOW_ANONYMOUS_LOGIN: yes
volumes:
- zookeeper_data:/bitnami
volumes:
zookeeper_data:
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
services:
zookeeper:
image: docker.io/bitnami/zookeeper:3.7
environment:
ALLOW_ANONYMOUS_LOGIN: yes
volumes:
- zookeeper_data:/bitnami
volumes:
zookeeper_data:
Кто найдёт ошибку в docker-compose.yaml — тому нихуя.
0
def number_to_words(n):
if n == 1:
print('один')
exit()
elif n == 2:
print('два')
exit()
elif n == 3:
print('три')
exit()
elif n == 4:
print('четыре')
exit()
elif n == 5:
print('пять')
exit()
elif n == 6:
print('шесть')
exit()
elif n == 7:
print('семь')
exit()
elif n == 8:
print('восемь')
exit()
elif n == 9:
print('девять')
exit()
elif n == 10:
print('десять')
exit()
elif n == 11:
print('одиннадцать')
exit()
elif n == 12:
print('двенадцать')
exit()
elif n == 13:
print('тринадцать')
exit()
elif n == 14:
print('четырнадцать')
exit()
elif n == 15:
print('пятнадцать')
exit()
elif n == 16:
print('шестнадцать')
exit()
elif n == 17:
print('семнадцать')
exit()
elif n == 18:
print('восемнадцать')
exit()
elif n == 19:
print('девятнадцать')
exit()
elif n == 20:
print('двадцать')
exit()
elif n == 21:
print('двадцать один')
exit()
elif n == 22:
print('двадцать два')
exit()
elif n == 23:
print('двадцать три')
exit()
elif n == 24:
print('двадцать четыре')
exit()
elif n == 25:
print('двадцать пять')
exit()
elif n == 26:
print('двадцать шесть')
exit()
elif n == 27:
print('двадцать семь')
exit()
elif n == 28:
print('двадцать восемь')
exit()
elif n == 29:
print('двадцать девять')
exit()
elif n == 30:
print('тридцать')
exit()
elif n == 31:
print('тридцать один')
exit()
elif n == 32:
print('тридцать два')
exit()
так до 99. Оригинал: https://www.cyberforum.ru/python-beginners/thread2390750.html
P.S. exit-ы то зачем????
+2
union bitdata {
struct {
unsigned int bit1 : 1;
unsigned int bit2 : 1;
unsigned int bit3 : 1;
unsigned int bit4 : 1;
unsigned int bit5 : 1;
unsigned int bit6 : 1;
unsigned int bit7 : 1;
unsigned int bit8 : 1;
};
unsigned char byte;
} first_byte, second_byte;
<...>
for ( j = 0; j < bytes_count; j++ ) {
unsigned char t;
ret = gzread( gz_fd, &t, sizeof( t ) );
if ( ret != sizeof( t ) ) {
printf( "Failed to read file %s: %s\n", argv[i], strerror( errno ) );
gzclose( gz_fd );
return EXIT_FAILURE;
}
first_byte.byte = t;
second_byte.byte = ready_bytes[j];
first_byte.bit1 = first_byte.bit1 == 0 && second_byte.bit1 == 0 ? 0 : 1;
first_byte.bit2 = first_byte.bit2 == 0 && second_byte.bit2 == 0 ? 0 : 1;
first_byte.bit3 = first_byte.bit3 == 0 && second_byte.bit3 == 0 ? 0 : 1;
first_byte.bit4 = first_byte.bit4 == 0 && second_byte.bit4 == 0 ? 0 : 1;
first_byte.bit5 = first_byte.bit5 == 0 && second_byte.bit5 == 0 ? 0 : 1;
first_byte.bit6 = first_byte.bit6 == 0 && second_byte.bit6 == 0 ? 0 : 1;
first_byte.bit7 = first_byte.bit7 == 0 && second_byte.bit7 == 0 ? 0 : 1;
first_byte.bit8 = first_byte.bit8 == 0 && second_byte.bit8 == 0 ? 0 : 1;
ready_bytes[j] = first_byte.byte;
}
Всё еще не можем понять, зачем в конце тернарник. Всё остальное уже не смущает.
+3
rule_t block_r = ch_p('{') >> *(~ch_p('}') | (~ch_p('{') >> block_r));
rule_t bin_r = str_p("0b") >> bin_p[assign(m)];
rule_t hex_r = str_p("0x") >> hex_p[assign(m)];
rule_t dec_r = uint_p[assign(m)];
rule_t id_r = alpha_p >> *(alnum_p | ch_p('_') | ch_p('.'));
rule_t string_r = ch_p('"') >> (*(~ch_p('"')))[assign(s)] >> ch_p('"');
rule_t channel_r = str_p("channel") >> *(space_p) >> id_r[assign(s)][assign_a(ch.name,s)][push_back_a(lstJSVars_,s)] >> *(space_p) >> ch_p('{') >>
*(space_p
| (str_p("mode") >> *(space_p) >> ch_p('=') >> *(space_p) >>
(str_p("in")[assign_a(ch.mode,(int)channel::IN)] | str_p("out")[assign_a(ch.mode,(int)channel::OUT)]) >> *(space_p) >> ch_p(';'))
| (str_p("number") >> *(space_p) >> ch_p('=') >> *(space_p) >> int_p[assign(ch.number)] >> *(space_p) >> ch_p(';'))
| (str_p("channel") >> *(space_p) >> ch_p('=') >> *(space_p) >> int_p[assign(ch.ch)] >> *(space_p) >> ch_p(';'))
| (str_p("gain") >> *(space_p) >> ch_p('=') >> *(space_p) >> int_p[assign(ch.gain)] >> *(space_p) >> ch_p(';'))
| (str_p("type") >> *(space_p) >> ch_p('=') >> *(space_p) >>
(str_p("analog")[assign_a(ch.type,(int)channel::ANALOG)] | str_p("discrete")[assign_a(ch.type,(int)channel::DISCRETE)]) >> *(space_p) >> ch_p(';'))
| (str_p("mask") >> *(space_p) >> ch_p('=') >> *(space_p) >>
(bin_r[assign_a(ch.mask,m)] | hex_r[assign_a(ch.mask,m)] | dec_r[assign_a(ch.mask,m)]) >> *(space_p) >> ch_p(';'))
) >>
ch_p('}') >> *(space_p) >> ch_p(';');
rule_t device_r = str_p("device_info") >> *(space_p) >> id_r[assign(dev_info_.name)] >> *(space_p) >> ch_p('{') >>
*(space_p |
(str_p("device") >> *(space_p) >> ch_p('=') >> *(space_p) >> string_r[assign_a(dev_info_.dev,s)] >> *(space_p) >> ch_p(';')) |
(str_p("blocking") >> *(space_p) >> ch_p('=') >> *(space_p) >>
(str_p("true")[assign_a(dev_info_.blocking,true)] | str_p("false")[assign_a(dev_info_.blocking,false)]) >> *(space_p) >> ch_p(';')) |
(str_p("freq_ch") >> *(space_p) >> ch_p('=') >> *(space_p) >> int_p[assign(dev_info_.freq_ch)] >> *(space_p) >> ch_p(';')) |
(str_p("freq_sel_ch") >> *(space_p) >> ch_p('=') >> *(space_p) >> int_p[assign(dev_info_.freq_sel_ch)] >> *(space_p) >> ch_p(';')) |
(str_p("speed") >> *(space_p) >> ch_p('=') >> *(space_p) >> int_p[assign(dev_info_.speed)] >> *(space_p) >> ch_p(';')) |
channel_r[assign_a(v,ch)][push_back_a(lstChannels_,v)]
) >>
ch_p('}') >> *(space_p) >> ch_p(';');
rule_t var_r = (str_p("var") >> *(space_p) >> id_r[assign(s)][push_back_a(lstJSVars_,s)] >>*(~ch_p(';')) >> ch_p(';'))[assign(s)][push_back_a(lstVars,s)];
rule_t function_r = str_p("function") >> *(~ch_p('`'));
//rule_t function_r = str_p("function") >> *(~ch_p('{')) >> block_r;
rule_t script_r = str_p("script") >> *(space_p) >> ch_p('{') >>
*(space_p |
var_r[assign(s)][push_back_a(lstJSVars_,s)] |
(function_r[assign(s)][push_back_a(lstFunc,s)] >> *(space_p) >> ch_p('`'))
) >>
ch_p('}') >> *(space_p) >> ch_p(';');
Из системы эмуляции полёта на тренажере.
−1
IT Оффтоп #143
#113: https://govnokod.ru/27652 https://govnokod.xyz/_27652
#114: https://govnokod.ru/27659 https://govnokod.xyz/_27659
#115: https://govnokod.ru/27665 https://govnokod.xyz/_27665
#116: https://govnokod.ru/27671 https://govnokod.xyz/_27671
#117: https://govnokod.ru/27675 https://govnokod.xyz/_27675
#118: https://govnokod.ru/27685 https://govnokod.xyz/_27685
#119: https://govnokod.ru/27701 https://govnokod.xyz/_27701
#120: https://govnokod.ru/27703 https://govnokod.xyz/_27703
#121: https://govnokod.ru/27710 https://govnokod.xyz/_27710
#122: https://govnokod.ru/27728 https://govnokod.xyz/_27728
#123: https://govnokod.ru/27729 https://govnokod.xyz/_27729
#124: https://govnokod.ru/27730 https://govnokod.xyz/_27730
#125: https://govnokod.ru/27732 https://govnokod.xyz/_27732
#126: https://govnokod.ru/27733 https://govnokod.xyz/_27733
#127: https://govnokod.ru/27737 https://govnokod.xyz/_27737
#128: https://govnokod.ru/27742 https://govnokod.xyz/_27742
#129: https://govnokod.ru/27747 https://govnokod.xyz/_27747
#130: https://govnokod.ru/27755 https://govnokod.xyz/_27755
#131: https://govnokod.ru/27766 https://govnokod.xyz/_27766
#132: https://govnokod.ru/27790 https://govnokod.xyz/_27790
#133: https://govnokod.ru/27828 https://govnokod.xyz/_27828
#134: https://govnokod.ru/27834 https://govnokod.xyz/_27834
#135: https://govnokod.ru/27839 https://govnokod.xyz/_27839
#136: https://govnokod.ru/27845 https://govnokod.xyz/_27845
#137: https://govnokod.ru/27857 https://govnokod.xyz/_27857
#138: https://govnokod.ru/27867 https://govnokod.xyz/_27867
#139: https://govnokod.ru/27887 https://govnokod.xyz/_27887
#140: https://govnokod.ru/27900 https://govnokod.xyz/_27900
#141: https://govnokod.ru/27914 https://govnokod.xyz/_27914
#142: https://govnokod.ru/27942 https://govnokod.xyz/_27942
+2
int f6(int* a,int k, double& min, int& n, int& count) {
int i;
min = a[0];//8
n = 0;
count = 0;
for (i = 0; i < k; i++) {
if (a[i] == 0) {
count += 1;
}
if (abs(10-abs(a[i])) < abs(min)) {
min = a[i];
n = i;
}
}
return 0;
}
Помогите!!Пожалуйста!!Надо найти ближайший элемент к 10ти и его номер, почему не работает??
+3
public getWay(path: string) {
const arrPath = path.slice(1).split('/');
arrPath.map(item => {
this.crumbs.push(MathcPath[item]);
this.crumbs = this.crumbs.filter(crumb => crumb);
});
}
Используем map в качестве forEach + зачем-то фильтруем полученный массив в каждой итерации.
Причем этот код можно записать в одну строку, которая еще и будет работать быстрее.
0
// @strict: true
// @lib: es2020
// @declaration: true
type BadFlatArray<Arr, Depth extends number> = {
obj: {
"done": Arr,
"recur": Arr extends ReadonlyArray<infer InnerArr>
? BadFlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][Depth]>
: Arr
}[Depth extends -1 ? "done" : "recur"]
}["obj"];
declare function flat<A, D extends number = 1>(
arr: A,
depth?: D
): BadFlatArray<A, D>[]
function foo<T>(arr: T[], depth: number) {
return flat(arr, depth);
}
function main() {
foo<number>([1.0, 2.0], 2);
}
спорим вы нихрена не поняли что это такое?
−1
Питушня #21
#1: https://govnokod.ru/26692 https://govnokod.xyz/_26692
#2: https://govnokod.ru/26891 https://govnokod.xyz/_26891
#3: https://govnokod.ru/26893 https://govnokod.xyz/_26893
#4: https://govnokod.ru/26935 https://govnokod.xyz/_26935
#5: (vanished) https://govnokod.xyz/_26954
#6: (vanished) https://govnokod.xyz/_26956
#7: https://govnokod.ru/26964 https://govnokod.xyz/_26964
#8: (vanished) https://govnokod.xyz/_26966
#9: https://govnokod.ru/27017 https://govnokod.xyz/_27017
#10: https://govnokod.ru/27045 https://govnokod.xyz/_27045
#11: https://govnokod.ru/27058 https://govnokod.xyz/_27058
#12: https://govnokod.ru/27182 https://govnokod.xyz/_27182
#13: https://govnokod.ru/27260 https://govnokod.xyz/_27260
#14: https://govnokod.ru/27343 https://govnokod.xyz/_27343
#15: https://govnokod.ru/27353 https://govnokod.xyz/_27353
#16: https://govnokod.ru/27384 https://govnokod.xyz/_27384
#17: https://govnokod.ru/27482 https://govnokod.xyz/_27482
#18: https://govnokod.ru/27514 https://govnokod.xyz/_27514
#19: https://govnokod.ru/27620 https://govnokod.xyz/_27620
#20: https://govnokod.ru/27816 https://govnokod.xyz/_27816
0
namespace Generics {
function swap<T>(arr: T[], i: number, j: number): void {
let temp: T = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
function sortHelper<T>(arr: T[], callbackfn?: (value1: T, value2: T) => number): T[] {
if (arr.length <= 0 || !callbackfn) {
return arr;
}
let len = arr.length;
// simple selection sort.
for (let i = 0; i < len - 1; ++i) {
for (let j = i + 1; j < len; ++j) {
if (callbackfn(arr[i], arr[j]) > 0) {
swap(arr, i, j);
}
}
}
return arr;
}
export function arraySort<T>(arr: T[], callbackfn?: (value1: T, value2: T) => number): T[] {
return sortHelper(arr, callbackfn);
}
}
function main() {
print("testGenerics")
let inArray = [4.0, 3.0, 4593.0, 23.0, 43.0, -1.0]
Generics.arraySort(inArray, (x: number, y: number) => { return x - y })
let expectedArray = [-1.0, 3.0, 4.0, 23.0, 43.0, 4593.0]
for (let i = 0; i < expectedArray.length; i++) {
assert(inArray[i] == expectedArray[i])
}
}
ну вот и все.. можно считать последний говнокод... подходит миссия к концу.... и ... потом заархивить все и положить на полочку