- 1
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
Адская супер-хуйня отсюда https://github.com/deneruaraujo/daily-diet-api
Я не понял что она делает, даже небо, даже Аллах
0
bot.onText(/\/now/, (message) => {
const DayOfTheWeek = new Date().toLocaleString('en-GB', { weekday: 'long' });
const currentTime = new Date();
let timeLeft = null;
let currentLesson = "";
for (let LessonId of Object.keys(lessons.v1[DayOfTheWeek])) {
const lesson = lessons.v1[DayOfTheWeek][LessonId];
const date = `${currentTime.getFullYear()}-${(currentTime.getMonth()+1).toString().padStart(2, '0')}-${currentTime.getDate().toString().padStart(2, '0')}`;
const startLessonTime = new Date(`${date}T${lesson.start}:00.001Z`);
const endLessonTime = new Date(`${date}T${lesson.end}:00.001Z`);
if (currentTime.toLocaleString('en-GB', {timeZone: 'Europe/Moscow'}) >= startLessonTime.toLocaleString('en-GB', {timeZone: 'Africa/Ouagadougou'}) && currentTime.toLocaleString('en-GB', {timeZone: 'Europe/Moscow'}) <= endLessonTime.toLocaleString('en-GB', {timeZone: 'Africa/Ouagadougou'})) {
currentLesson = lesson.name;timeLeft = (endLessonTime-currentTime) / 1000;
timeLeft=timeLeft-10800+2;
break;
};
};
if (currentLesson && timeLeft) {
const minutes = Math.floor(timeLeft / 60);
const seconds = Math.floor(timeLeft % 60);
bot.sendMessage(message.chat.id, `щяс урок: ${currentLesson}\nдо конца осталось ${minutes} минут ${seconds} секунд`);
} else {
bot.sendMessage(message.chat.id, 'Сейчас нет уроков');
};
});
это я ночью говнокодил, ВАХхфВАХХВхаххвАХАВхаВХАХАХахвх
0
// ******************************************************************************************************
function ch_new_nav()
{
if((document.getElementById('navig_dat').value.length==10)&&(document.getElementById('navig_smen').value>0)&&(document.getElementById('sel_res_div').value>0))
{
current_resource_id = document.getElementById('val_res_new_nav').getAttribute('data-user-id');
document.getElementById('cur_res_pred_op').src='index.php?do=show&formid=159&p0='+document.getElementById('navig_dat').value.substr(0,4)+document.getElementById('navig_dat').value.substr(5,2)+document.getElementById('navig_dat').value.substr(8,2)+'&p1='+document.getElementById('navig_smen').value+'&p2='+document.getElementById('sel_res_div').value + '¤t_resource_id='+current_resource_id;
document.getElementById('cur_res_pred_op').style.display='block';
// $("#vpdiv").animate({scrollTop:$('#cur_res_pred_op').offset().top+"px"});
document.getElementById('nav_tekysh_1').innerText = document.getElementById('navig_dat').value.substr(8,2)+'.'+document.getElementById('navig_dat').value.substr(5,2)+'.'+document.getElementById('navig_dat').value.substr(0,4);
document.getElementById('nav_tekysh_2').innerText = document.getElementById('navig_smen').value;
document.getElementById('nav_tekysh_3').innerText = document.getElementById('val_res_new_nav').value;
document.getElementById('nav_tekysh_4').innerText = document.getElementById('sel_res_div').value;
document.getElementById('nav_tekysh_1').name = document.getElementById('navig_dat').value.substr(0,4)+document.getElementById('navig_dat').value.substr(5,2)+document.getElementById('navig_dat').value.substr(8,2);
document.getElementById('nav_tekysh_2').name = document.getElementById('navig_smen').value;
document.getElementById('nav_tekysh_3').name = document.getElementById('sel_res_div').value;
var spl_op_res = arr_oprs_c_r_2[document.getElementById('sel_res_div').value].split('|');
var spl_op_res_arr = [];
for (var spl_f_ar=0; spl_f_ar<spl_op_res.length; spl_f_ar++)
spl_op_res_arr[spl_op_res[spl_f_ar]] = spl_op_res[spl_f_ar];
document.getElementById('park_sel_cur_res').innerHTML='<option value="0" selected>Получение списка</option>';
document.getElementById('park_sel_cur_res').setAttribute('onchange', 'check_sel_park_pr(this.value)');
vote3('full_plan_sz_ch_park.php?p1='+document.getElementById('sel_res_div').value);
for (var td_c_pr=0; td_c_pr<document.getElementsByName('pr_cur_r_op').length; td_c_pr++)
{
var split_rgb_obj = document.getElementsByName('pr_cur_r_park')[td_c_pr].parentNode.style.background;
var split_rgb_obj_repl = split_rgb_obj.replace('rgb(','');
split_rgb_obj_repl = split_rgb_obj_repl.replace(')','');
split_rgb_obj_repl = split_rgb_obj_repl.replace(' ','');
split_rgb_obj_repl = split_rgb_obj_repl.replace(' ','');
split_rgb_obj_repl = split_rgb_obj_repl.replace(' ','');
split_rgb_obj_repl = split_rgb_obj_repl.split(',');
if ((split_rgb_obj_repl[0]=='221')&&(split_rgb_obj_repl[1]=='255')&&(split_rgb_obj_repl[2]=='221'))
{
document.getElementsByName('pr_cur_r_op')[td_c_pr].style.background='#ddffdd';
document.getElementsByName('pr_cur_r_park')[td_c_pr].style.background='#ddffdd';
}
else
{
document.getElementsByName('pr_cur_r_op')[td_c_pr].style.background='#fff';
document.getElementsByName('pr_cur_r_park')[td_c_pr].style.background='#fff';
}
if (document.getElementsByName('pr_cur_r_op')[td_c_pr].parentNode.cells[8].innerHTML.indexOf('<img') !== -1)
{
var id_op_add_ind_0 = document.getElementsByName('pr_cur_r_op')[td_c_pr].parentNode.cells[8].getElementsByTagName('a')[0].getAttribute('onclick').indexOf('del_op_in_sz');
var id_op_add_ind = document.getElementsByName('pr_cur_r_op')[td_c_pr].parentNode.cells[8].getElementsByTagName('a')[0].getAttribute('onclick').indexOf('(',id_op_add_ind_0);
var id_op_add_ind_1 = document.getElementsByName('pr_cur_r_op')[td_c_pr].parentNode.cells[8].getElementsByTagName('a')[0].getAttribute('onclick').indexOf(',',id_op_add_ind);
var id_op_add_ind_2 = document.getElementsByName('pr_cur_r_op')[td_c_pr].parentNode.cells[8].getElementsByTagName('a')[0].getAttribute('onclick').substr((id_op_add_ind+1),(id_op_add_ind_1-id_op_add_ind-1));
document.getElementsByName('pr_cur_r_op')[td_c_pr].parentNode.cells[8].getElementsByTagName('a')[0].innerHTML='<b name="pr_cur_r_op_b">>>></b>';
document.getElementsByName('pr_cur_r_op')[td_c_pr].parentNode.cells[8].getElementsByTagName('a')[0].setAttribute('onclick','add_op_in_sz('+id_op_add_ind_2+',this)');
}
document.getElementsByName('pr_cur_r_op_b')[td_c_pr].setAttribute('style','font-size:100%; color:#23609E;');
if (spl_op_res_arr[document.getElementsByName('pr_cur_r_op')[td_c_pr].id.substr(9)])
{
document.getElementsByName('pr_cur_r_op')[td_c_pr].style.background='#99ff99';
document.getElementsByName('pr_cur_r_op_b')[td_c_pr].setAttribute('style','font-size:150%; color:#13BD13;');
}
} // for (var td_c_pr=0; td_c_pr<document.getElementsByName('pr_cur_r_op').length; td_c_pr++)
} // if((document.getElementById('navig_dat').value.length==10)&&(document.getElementById('navig_smen').value>0)&&(document.getElementById('sel_res_div').value>0))
else
alert('Выберите дату, смену, ресурс!');
} // function ch_new_nav()
0
Events.on(EventType.ClientLoadEvent, () => {
const oneDialog = new BaseDialog(" ");
oneDialog.cont.add(" ").row();
oneDialog.cont.button("OK", () => {
oneDialog.hide();
const twoDialog = new BaseDialog(" ");
twoDialog.cont.add(" ").row();
twoDialog.cont.button("OK", () => {
twoDialog.hide();
const threeDialog = new BaseDialog(" ");
threeDialog.cont.add(" ").row();
threeDialog.cont.button("OK", () => {
threeDialog.hide();
const fourDialog = new BaseDialog(" ");
fourDialog.cont.add(" ").row();
fourDialog.cont.button("OK", () => {
fourDialog.hide();
const fiveDialog = new BaseDialog(" ");
fiveDialog.cont.add(" ").row();
fiveDialog.cont.button("OK", () => {
fiveDialog.hide();
const sixDialog = new BaseDialog(" ");
sixDialog.cont.add(" ").row();
sixDialog.cont.button("OK", () => {
sixDialog.hide();
const sevenDialog = new BaseDialog(" ");
sevenDialog.cont.add(" ").row();
sevenDialog.cont.button("OK", () => {
sevenDialog.hide();
const eightDialog = new BaseDialog(" ");
eightDialog.cont.add(" ").row();
eightDialog.cont.button("OK", () => {
eightDialog.hide();
const nineDialog = new BaseDialog(" ");
nineDialog.cont.add(" ").row();
nineDialog.cont.button("OK", () => {
nineDialog.hide();
const tenDialog = new BaseDialog(" ");
tenDialog.cont.add(" ").row();
tenDialog.cont.button("OK", () => {
tenDialog.hide();
const elevenDialog = new BaseDialog(" ");
elevenDialog.cont.add(" ").row();
elevenDialog.cont.button("OK", () => {
elevenDialog.hide();
const twelveDialog = new BaseDialog(" ");
twelveDialog.cont.add(" ").row();
twelveDialog.cont.button("OK", () => {
twelveDialog.hide();
const thirteenDialog = new BaseDialog(" ");
thirteenDialog.cont.add(" ").row();
thirteenDialog.cont.button("OK", () => {
thirteenDialog.hide();
const fourteenDialog = new BaseDialog(" ");
fourteenDialog.cont.add(" ").row();
fourteenDialog.cont.button("OK", () => {
fourteenDialog.hide();
const fifteenDialog = new BaseDialog(" ");
fifteenDialog.cont.add(" ").row();
fifteenDialog.cont.button("OK", () => {fifteenDialog.hide();if(Core.settings.get("wentdowntherabbithole",false)){
const again = new BaseDialog(" ");
// ...
https://github.com/camelStyleUser/popup-unforked/blob/main/scripts/main.js
0
const disabledConditions = [!element.isDraft].some((v) => Boolean(v) === true);
Из серии String(true).length === 4
0
https://github.com/HermanKirshin/MainBrainfuck/blob/main/_.cs
"Если кому интересно - предлагаю угадать что делает этот код" (Ц)
0
const ttfMeta = require('ttfmeta');
const fs = require('fs');
let oldName = process.argv[2];
ttfMeta.ttfInfo(oldName, (err, result) => {
if (err) {
console.log('error', err)
} else {
let newName = result.tables.name[6];
if(newName.charCodeAt(0) === 0) {
let buf = new ArrayBuffer(newName.length);
let bufView = new Uint16Array(buf);
for (let i = 0, strLen = newName.length / 2; i < strLen; i++) {
bufView[i] = (newName.charCodeAt(2 * i) << 8) + newName.charCodeAt(2 * i + 1);
}
newName = String.fromCharCode.apply(null, bufView);
}
newName = 'renamed/' + newName + '.ttf';
fs.createReadStream(oldName).pipe(fs.createWriteStream(newName));
}
});
Дано: 100500 ttf-файлов с рандомными именами файла (цифры, гуиды, что угодно, но только не название шрифта).
Требуется: переименовать файлы так, чтобы название хоть как-то было похоже на имя шрифта.
Решение: есть 100500 библиотек на сишке для вытаскивания метушни из ttf-файлов, но мы же извращенцы, поэтому напишем на скриптушне.
Багор: пакет «ttfmeta» из «npm» иногда возвращает нормальные текстовые строки, а иногда хуйню (детектируемую условием newName.charCodeAt(0) === 0), когда пара соседних «символов» — это на самом деле половинки кодпоинта из кодировки utf16be. «Нода» умеет только в toString('utf16le'), а кодировку с большим индейцем ('utf16be') не знает.
0
if (this.$arg0 == 'inc') this.$ret = this.$math = args[0] + 1;
if (this.$arg0 == 'dec') this.$ret = this.$math = args[0] - 1;
if (this.$arg0 == 'div') this.$ret = this.$math = args[0] / args[1];
if (this.$arg0 == 'ceil') this.$ret = this.$math = Math.ceil(args[0]);
if (this.$arg0 == 'floor') this.$ret = this.$math = Math.floor(args[0]);
if (this.$arg0 == 'sqrt') this.$ret = this.$math = Math.sqrt(args[0]);
if (this.$arg0 == 'exp') this.$ret = this.$math = Math.exp(args[0]);
if (this.$arg0 == 'log') this.$ret = this.$math = Math.log(args[0]);
if (this.$arg0 == 'sin') this.$ret = this.$math = Math.sign(args[0]);
if (this.$arg0 == 'log10') this.$ret = this.$math = Math.log10(args[0]);
if (this.$arg0 == 'cos') this.$ret = this.$math = Math.cos(args[0]);
if (this.$arg0 == 'tan') this.$ret = this.$math = Math.tan(args[0]);
if (this.$arg0 == 'acos') this.$ret = this.$math = Math.acos(args[0]);
if (this.$arg0 == 'atan') this.$ret = this.$math = Math.atan(args[0]);
if (this.$arg0 == 'round') this.$ret = this.$math = Math.round(args[0]);
if (this.$arg0 == 'atan2') this.$ret = this.$math = Math.atan2(args[0]);
Исходный код интерпретатора компилятора (!) Языка Программирования «AsmX».
https://github.com/langprogramming-AsmX/AsmX/blob/main/compiler.js#L215
0
console.log(...($$ = $ => (~-~-$ && $$(~-$), (_$ = $_ => $ % (_[~~$_] ??= $) ? _$(-~$_) : _)()))((_ = []) + -~_ + -_ + -_))
Как ровные пацаны выводят в консоль первые 25 простых чисел
0
https://pastebin.com/MarcPuJc
говно для подтирания важных комментов в вк. Весь не поместился, прилегаю ссылку.