1. JavaScript / Говнокод #28845

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    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, 'Сейчас нет уроков');
        };
    });

    это я ночью говнокодил, ВАХхфВАХХВхаххвАХАВхаВХАХАХахвх

    qwkz1, 12 Сентября 2023

    Комментарии (0)
  2. JavaScript / Говнокод #28842

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    // ******************************************************************************************************
    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 + '&current_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()

    kib0rg, 06 Сентября 2023

    Комментарии (0)
  3. JavaScript / Говнокод #28831

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    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

    girixok149, 03 Августа 2023

    Комментарии (15)
  4. JavaScript / Говнокод #28827

    +1

    1. 1
    const disabledConditions = [!element.isDraft].some((v) => Boolean(v) === true);

    Из серии String(true).length === 4

    akosenko, 27 Июля 2023

    Комментарии (1)
  5. JavaScript / Говнокод #28802

    0

    1. 1
    https://github.com/HermanKirshin/MainBrainfuck/blob/main/_.cs

    "Если кому интересно - предлагаю угадать что делает этот код" (Ц)

    JloJle4Ka, 23 Июня 2023

    Комментарии (11)
  6. JavaScript / Говнокод #28792

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    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') не знает.

    Izumka, 05 Июня 2023

    Комментарии (53)
  7. JavaScript / Говнокод #28785

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    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

    ISO, 19 Мая 2023

    Комментарии (55)
  8. JavaScript / Говнокод #28756

    −1

    1. 1
    console.log(...($$ = $ => (~-~-$ && $$(~-$), (_$ = $_ => $ % (_[~~$_] ??= $) ? _$(-~$_) : _)()))((_ = []) + -~_ + -_ + -_))

    Как ровные пацаны выводят в консоль первые 25 простых чисел

    sex_mashina, 20 Апреля 2023

    Комментарии (7)
  9. JavaScript / Говнокод #28650

    +1

    1. 1
    https://pastebin.com/MarcPuJc

    говно для подтирания важных комментов в вк. Весь не поместился, прилегаю ссылку.

    AnimeGovno, 26 Марта 2023

    Комментарии (5)
  10. JavaScript / Говнокод #28649

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    private async getNewKey(): Promise<string> {
    		let i: number = 0;
    		let key: string;
    		while (i < 50000) {
    			key = this.generateKey(MIN_REFERRAL_NAME_LENGTH);
    			const inDatabase: number = await ReferralEntity.count({ where: { name: key }, transaction: this._transaction });
    			if (inDatabase === 0) {
    				const inProcess: boolean = newKeyInProcess.has(key);
    				if (!inProcess) {
    					newKeyInProcess.add(key);
    					break;
    				}
    			}
    			i++;
    		}
    		return key;
    	}

    Тайпскрипт. MIN_REFERRAL_NAME_LENGTH = 3
    Как считаете, когда всё приложение встанет колом?

    alek0585, 26 Марта 2023

    Комментарии (2)