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

    +2

    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
    var buf = Buffer.allocUnsafe(kexInitSize);
        var p = 17;
    
        buf[0] = MESSAGE.KEXINIT;
    
        if (myCookie !== false)
          myCookie.copy(buf, 1);
    
        writeUInt32BE(buf, kexBuf.length, p);
        p += 4;
        kexBuf.copy(buf, p);
        p += kexBuf.length;
    
        writeUInt32BE(buf, hostKeyBuf.length, p);
        p += 4;
        hostKeyBuf.copy(buf, p);
        p += hostKeyBuf.length;
    
        writeUInt32BE(buf, algos.cipherBuf.length, p);
        p += 4;
        algos.cipherBuf.copy(buf, p);
        p += algos.cipherBuf.length;
    
        writeUInt32BE(buf, algos.cipherBuf.length, p);
        p += 4;
        algos.cipherBuf.copy(buf, p);
        p += algos.cipherBuf.length;
    
        writeUInt32BE(buf, algos.hmacBuf.length, p);
        p += 4;
        algos.hmacBuf.copy(buf, p);
        p += algos.hmacBuf.length;
    
        writeUInt32BE(buf, algos.hmacBuf.length, p);
        p += 4;
        algos.hmacBuf.copy(buf, p);
        p += algos.hmacBuf.length;
    
        writeUInt32BE(buf, algos.compressBuf.length, p);
        p += 4;
        algos.compressBuf.copy(buf, p);
        p += algos.compressBuf.length;
    
        writeUInt32BE(buf, algos.compressBuf.length, p);
        p += 4;
        algos.compressBuf.copy(buf, p);
        p += algos.compressBuf.length;
    
        // Skip language lists, first_kex_packet_follows, and reserved bytes
        buf.fill(0, buf.length - 13);

    Мечтают ли скриптухи об Электросишке?

    https://github.com/mscdex/ssh2-streams/blob/master/lib/ssh.js

    3.14159265, 07 Марта 2020

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

    +2

    1. 1
    2. 2
    3. 3
    Global Install
    Installing Yarn 2.x globally is discouraged as we're moving to a per-project install strategy. 
    We advise you to keep Yarn 1.x (Classic) as your global binary by installing it via the instructions you can find here.

    https://yarnpkg.com/getting-started/install

    Мы выпустили вторую версию приложеньки, в которой исправили все недочёты первой.
    Именно поэтому запускать вы её будете через первую версию, которая с вами навсегда.
    Мы проработали другие варианты и пришли к решению, что они все неправильные.

    Сердечно ваши,
    джаваскриптеры.

    Fike, 07 Марта 2020

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

    +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
    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
    function isVowel(char){
        return "аоэиуыеёюя".indexOf(char.toLocaleLowerCase())>=0 ? 1 : 0;
    }
    
    function vorefy(text)
    {
        // Г => C 0.85
        // Г => Г 0.15
        // С => С 0.30
        // С => Г 0.70   
        var markov = [[0.3,0.7],[0.85,0.15]]; 
        var mCorr = [ 1/Math.sqrt(0.3*0.7), 1/Math.sqrt(0.85*0.15) ];
        //степень влияния марковских вореантностей
        var pow = x => Math.pow(x,2);
        
        var prev=null;
        return text.replace(/./g,(char,offset,text) => 
        {
            if (E2R[char]){
                var replace = Object.entries(E2R[char]);
                if (1==replace.length) {
                    prev = replace[0][0];
                    return prev;
                }
                var r = Math.random()*200, probability=0;
                for (const [k, v] of replace) {
                    vowel = isVowel(k);
                    probability += v * ((null==prev) ? 1 
                        : pow( 
                            mCorr[vowel]*2*markov[isVowel(prev)][vowel]
                        ));
                    if (r<=probability) {
                        prev = k;
                        return prev;
                    }
                }
            }
            prev=null;
            return char;
        });        
    }

    Марковым отмечена еще одна устойчивая закономерность открытых текстов, связанная с чередованием гласных и согласных букв. Им были подсчитаны частоты встречаемости биграмм вида гласная-гласная (г, г), гласная-согласная (г, с), согласная-гласная (с, г), согласная-согласная (с, с)

    [color=blur]https://ideone.com/VpkwXT[/color]

    3.14159265, 22 Февраля 2020

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

    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
    // sorry, I don't want to use any JS templater
    // so I'll concatenate html as strings, which is the worst practice
    // but my IntelliJ IDEA highlights html in strings well :)
    // and I write this code just4fun
    //
    // but to respect production I'll leave here something that will never be fixed
    // TODO: rewrite in Angular.js
    //
    // done!
    
    // ...
    
    // u still read this spaghetti?
    
    let evaluate = (s) => {
        completion = [];
        hist = [];
    
        let tokens = s.split(' ').filter((s) => s !== '');
    
        if (!tokens[0]) return;
        histfile.push(s);
    
        if (tokens[0] === 'clear') clear();
        else if (tokens[0] === 'aplay') aplay();
        else if (tokens[0] === 'man') try {
            template(tokens.slice(0, 2).join('_'))();
        } catch {
            stdout('No manual entry for <span class="red">' + tokens[1] + '</span>')
        }

    Сайт-визитка на plain js для подкаста в виде эмулятора терминала с пасхалками
    https://deveeps.prost.host/

    vistefan, 19 Февраля 2020

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

    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
    $('#search-map').on('click', '.v-card-prev', function () {
                var v_next = $(this)
                    .parent()
                    .find('.v-card-img-block .v-card-img-hidden.active')
                    .prev();
                if ($(v_next).length == 0) {
                    $(this)
                        .parent()
                        .find('.v-card-img-hidden.active')
                        .removeClass('active');
                    $(this)
                        .parent()
                        .find('.v-card-img-hidden:last')
                        .addClass('active');
                } else {
                    $(this)
                        .parent()
                        .find('.v-card-img-hidden.active')
                        .removeClass('active');
                    $(this)
                        .parent()
                        .find(v_next)
                        .addClass('active');
                }
                $(this)
                    .parent()
                    .find('.v-card-img-hidden.active')
                    .click();
            });
    
            $('#search-map').on('click', '.offers-favorite', function () {
                var favorID = $(this)
                    .closest('.js__product')
                    .attr('data-item');
                if ($(this).hasClass('active')) var doAction = 'delete';
                else var doAction = 'add';
                updateFavorite(favorID, doAction);
                return false;
            });

    phpBidlokoder2, 18 Февраля 2020

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    //Use this to convert OffSet to postive:
    
    var offset = new Date().getTimezoneOffset();
    console.log(offset);
    this.timeOffSet = offset + (-2*offset);
    console.log(this.timeOffSet);

    Это такой особый JS way, или я чего-то не понимаю?

    eukaryote, 10 Февраля 2020

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

    0

    1. 1
    let randomHexColor = (g = () => (a => (a < 16 ? '0' : '') + a.toString(16))(~~(Math.random() * 255)))() + g() + g();

    fuckyounoob, 09 Февраля 2020

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

    +3

    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
    onst addAdjacencies = (
      nodes,
    ) => (
      nodes
      .map(({
        colorId,
        id,
        x,
        y,
      }) => ({
        color: colors[colorId],
        eastId: (
          getNodeAtLocation({
            nodes,
            x: x + 1,
            y,
          })
        ),
        id,
        northId: (
          getNodeAtLocation({
            nodes,
            x,
            y: y - 1,
          })
        ),
        southId: (
          getNodeAtLocation({
            nodes,
            x,
            y: y + 1,
          })
        ),
        westId: (
          getNodeAtLocation({
            nodes,
            x: x - 1,
            y,
          })
        ),
      }))
      .map(({
        color,
        id,
        eastId,
        northId,
        southId,
        westId,
      }) => ({
        adjacentIds: (
          [
            eastId,
            northId,
            southId,
            westId,
          ]
          .filter((
            adjacentId,
          ) => (
            adjacentId !== undefined
          ))
        ),
        color,
        id,
      }))
    )

    https://medium.com/free-code-camp/bet-you-cant-solve-this-google-interview-question-4a6e5a4dc8ee

    джаваскриптер натужно пытается решить простейшую задачу "гугл уровня" с обходом, для увеличения кринжа прилагается поехавший кодстайл и решение на RxJS

    Fike, 08 Февраля 2020

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

    +3

    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
    var   words=
        [
     
            {   
                 'тупая русня ':1/10
                ,'на бутылку':1/8
                ,'у тебя же прыщи':1/12
                ,'руснявый':1/8
                ,'прыщеблядский':1/8
                ,',обоссался':1/10
                ,'обоссал':1/10
                ,', маму твою ебал,':1/12
                ,'стекломойная русня':1/8
                ,'гермашка': 1/10
                ,'туши пердак':1/8
            }
            ,{
                'садись на бутылку':1/8
            }
            ,{'стекломойный русачок':1/11,' пуйло':1/7,'ко-ко-ко':1/6,'рашка':1/10,', пидорахен':1/10}        
            ,{'пидораха,': 1/6,', пидораха полыхнула,': 1/12
                ,'козлодойч': 1/12
                ,'гермашка': 1/10
             }
            ,{  
                'свинособака':1/6
                ,', мамку ебал,':1/12
                ,'бамп отсосу ':1/13
                ,', маму твою,':1/12            
                ,'скрепы':1/11
                ,' пидораха,':1/8
                ,'cтекломойный':1/8
                ,'стекломоя наебнул':1/8
                ,'садись на бутылку':1/10
                ,'днище':1/7
                ,'русня':1/9
                ,'кремлебот ':1/6
                ,'порватка':1/10            
                ,'порвался':1/15
                ,'руснявая пидараха': 1/11
                ,'бубарех': 1/10
                ,'хуйня': 1/10
                ,'залупин': 1/13
                ,'хуйло': 1/12
            }
    ];

    Словарь слов-маркеров анона с /po для склейки крупных кусков кобенады и твердой мелкой психозы.

    Даже простейший скрипт, рандомно вставляющий данные фразы показывает весьма аутентичный результат.

    3.14159265, 05 Февраля 2020

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    for (var i = 0; i < self.Collection().length; i++) {
                ///НЕ УДАЛЯЙТЕ ОТОРВУ РУКИ!!!!!
                if (self.Collection()[i].IsSecuringApplications() == true) {
                    continue;
                }
                TotalContractSumm = Math.round((TotalContractSumm + parseFloat(self.Collection()[i].ContractGuarantee)) * 100) / 100;
                TotalApplicationSumm = Math.round((TotalApplicationSumm + parseFloat(self.Collection()[i].ApplicationGuarantee)) * 100) / 100;
    }

    Вот что бывает, когда нет code review.

    sevser, 03 Февраля 2020

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