1. C++ / Говнокод #23836

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    #include <xmmintrin.h>
    
    void crasher() {
        constexpr __m128 w = {1,2,3,4};
        asm ("addps %[w], %[w]" : : [w] ""(w));
    }

    Крашим GCC
    https://ideone.com/iIAN0i

    Antervis, 28 Февраля 2018

    Комментарии (58)
  2. C++ / Говнокод #23835

    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
    class PriceCache {
    public:
      FlightStorage(const std::size_t count) {
        for (std::size_t i = 0; i < count; ++i) {
          flights.emplace_back(FlightCache::get(i));
          prices.emplace_back(&flights.back(), Price::getFor(flights.back()));
        }
      }
    
    private:
      std::vector<Flight> flights;
      std::vector<const Flight *, double> prices;
    };

    "случайные сегфолты при обращении к PriceCache::prices"

    Elvenfighter, 28 Февраля 2018

    Комментарии (6)
  3. Си / Говнокод #23832

    +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
    typedef unsigned int uint;
    
    uint inc(uint i) {
        return i+1;
    }
    uint dec(uint i) {
        return i-1;
    }
    uint add(uint a, uint b) {
        return 0==b ? a : add(inc(a),dec(b));
    }
    
    inline uint _mul(uint a, uint b, uint r) {
        return 0==b ? r : _mul(a,b-1,r+a);
    }
    uint mul(uint a, uint b) {
        return _mul(a,b,0);
    }
    
    uint dec_mul(uint a, uint b, uint r) {
        return 0==b ? r : dec_mul(a,dec(b),r+a);
    }
    
    //gcc 7 здесь сходит с ума на O3, шланг невозмутимо ставит  imul    edi, esi
    uint crazy_mul(uint a, uint b, uint r) {
        return 0==b ? r : crazy_mul(a,dec(b),add(r,a));
    }
    //арифметическая прогрессия. 
    inline uint _sum(uint a,uint s) {
        return a==0 ? s :_sum(a-1,s+a);
    }
    //gcc: сложна нипанятна
    uint sum(uint a) {
        return _sum(a,0);
    }
    //шланг:
    //        imul    rcx, rax
    //        shr     rcx
    uint sum1(uint a) {
        uint s=0;
        for (int i=0;i<a;++i){
            s+=i;
        }
        return s;
    }

    Смотрим как компиляторы решают разные упоротые рекурентные задачки.
    https://godbolt.org/g/4JZuPr

    3.14159265, 27 Февраля 2018

    Комментарии (27)
  4. PHP / Говнокод #23826

    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
    <?php
    
    $zero = '!![]';
    $nums = ['![]','${![]}','${!![]}','$${[]}','$${![]}','$${!![]}','$$${[]}','${[].[]}'];
    $initChr = "\${[]}=([].[])[![]+![]+![]];\${[]}++;\${[]}++;\${+![]}=\${[]};" .
    "\${[]}++;\${[]}++;\${[]}++;\${[]}++;\${[]}++;\${+![]}.=\${[]};" .
    "\${[]}=\${+![]}.([].[])[![]];";
    $chr = '${[]}';
    
    function initNumbers() {
        global $nums;
        $n = $nums[0];
        $code  = '';
        foreach ($nums as $v => $num) {
            if (!$v) continue;
            $v = join('+', array_fill(0, 2, $n));
            $code .= "$num=$v;";
            $n = $num;
        }
        return $code;
    }
    
    function number($n) {
        global $nums, $zero;
        if ($n < 0 || $n > 255) die("Invalid number: $n.");
        if (!$n) return $zero[0];
        $i = 0;
        while($n) {
            $d = $n % 2;
            if($d) $code[] = join('+', array_fill(0, $d, $nums[$i]));
            $n /= 2;
            $i++;
        }
        return join('+', $code);
    }
    
    function char($c) {
        global $chr;
        $c = number(ord($c));
        return "$chr($c)";
    }
    
    function str($s) {
        return join('.', array_map('char', str_split($s)));
    }
    
    function prettify($fucked) {
        $line = '';
        $ops = preg_split('/([;.])/', $fucked, -1, PREG_SPLIT_DELIM_CAPTURE);
        foreach($ops as $op) {
            if(strlen($line) + strlen($op) + 1 > 80) {
                $lines[] = $line;
                $line = '';
            }
            $line .= $op;
        }
        $lines[] = $line;
        return join("\n", $lines);
    }
    
    function fuckify($code) {
        global $chr, $initChr;
        $nums = initNumbers();
        $php = '$$$${[]}';
        $initPHP = $php . '=(' . str('popen') . ')(' . str('php') . ',' . char('w') . ');';
        $fputs = str('fputs');
        $pclose = str('pclose');
        $code = str($code);
        return prettify("<?php\n$initChr$nums$initPHP($fputs)($php,$code);($pclose)($php);");
    }
    
    $code = '';
    while ($line = fgets(STDIN)) $code .= $line;
    print(fuckify($code));

    Автаматизировала пхпфак почти как в http://govnokod.ru/23690
    програма вводет код пхп из stdin и выводет в stdout его перивод на пхпфак

    HACTEHbKA, 25 Февраля 2018

    Комментарии (4)
  5. Куча / Говнокод #23825

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    Whether or not you check in your Pods folder is up to you, as workflows vary from project to project. We recommend that you keep the Pods directory under source control, and don't add it to your .gitignore
    
    Benefits of checking in the Pods directory
    
        After cloning the repo, the project can immediately build and run, even without having CocoaPods installed on the machine. There is no need to run pod install, and no Internet connection is necessary.
        The Pod artifacts (code/libraries) are always available, even if the source of a Pod (e.g. GitHub) were to go down.
        The Pod artifacts are guaranteed to be identical to those in the original installation after cloning the repo.

    https://guides.cocoapods.org/using/using-cocoapods.html

    Desktop, 25 Февраля 2018

    Комментарии (99)
  6. Куча / Говнокод #23823

    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
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    let src1 = r#"
            __kernel void add1(__global float* A, __global float* BBB, __global float* B, int m, int n) 
            {
                __local float Blo[64];
                int x = get_local_id(0);
                int y = get_local_id(1);
                int i = get_global_id(0);
                int j = get_global_id(1);
                int k = get_global_id(2);
                i += k / 8;
                j += k % 8;
    
                if (i >= n || j >= m) return;
    
    
                Blo[x * 8 + y] = A[i * m + j];
    
    
    
    
                barrier(CLK_LOCAL_MEM_FENCE);
    
                float BB = 0;
    
                for (int xx = 0; xx < 8; ++xx)
                    for (int yy = 0; yy < 8; ++yy)
                    {
        
                            float c = (2 * xx + 1) * x * 3.1415926535 / 16;
                            float cc = (2 * yy + 1) * y * 3.1415926535 / 16;
                            c = cos(c);
                            cc = cos(cc);
                            BB += Blo[xx * 8 + yy] * c * cc;
    
                    }
    
                float Ci, Cj;
                if (x == 0)
                    Ci = 1 / 1.4142135623;
                else
                    Ci = 1;
    
                if (y == 0)
                    Cj = 1 / 1.4142135623;
                else
                    Cj = 1;
                B[k * m * n + i * m + j] = Ci * Cj / 4 * BB;
    
                barrier(CLK_LOCAL_MEM_FENCE);
    
                i = get_global_id(0);
                j = get_global_id(1);
    
                float summ = 0;
                for (int ii = 0; ii < 64; ++ii)
                    summ += B[ii * m * n + i * m + j];
                BBB[i * m + j] = summ / 64;
                
            }
        "#;
    
    
    let pro_que = ProQue::builder().src(src1).dims((hi, wi, 64)).build().unwrap();
    
    
       let matr11 = Buffer::builder()
            .queue(pro_que.queue().clone())
            .flags(MemFlags::new().read_only().use_host_ptr())
            .dims((hi, wi))
            .host_data(&Resr)
            .build().unwrap();
    
            let matg11 = Buffer::builder()
            .queue(pro_que.queue().clone())
            .flags(MemFlags::new().read_only().use_host_ptr())
            .dims((hi, wi))
            .host_data(&Resg)
            .build().unwrap();
    
    ...
    
        let mut kernel;
        {
                let wi = wi as i32;
                let hi = hi as i32;
                kernel = pro_que.create_kernel("add1").unwrap().arg_buf(&matr11).arg_buf(&resr11).arg_buf(&bor1).arg_scl(wi).arg_scl(hi);
                kernel.lws((8, 8)).enq().unwrap();
                kernel = pro_que.create_kernel("add1").unwrap().arg_buf(&matg11).arg_buf(&resg11).arg_buf(&bog1).arg_scl(wi).arg_scl(hi);
                kernel.lws((8, 8)).enq().unwrap();
                kernel = pro_que.create_kernel("add1").unwrap().arg_buf(&matb11).arg_buf(&resb11).arg_buf(&bob1).arg_scl(wi).arg_scl(hi);
                kernel.lws((8, 8)).enq().unwrap();
        }

    Ничего особенного, лаба по opencl, написанная на Rustе

    gorthauer87, 24 Февраля 2018

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

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    https://github.com/wiistriker/govnokod_legacy
    
    Вот почему всё через жопу?
    Почему, блядь, я просто не могу положить проект в htdocs, и чтобы всё заработало?
    
    Что это за поебень, кто-то в курсе?
    mzz не может быть запущен по причине:
    Directory "" is not readable
    Directory "/templates_c" is not readable
    Directory "" is not writable
    Directory "/templates_c" is not writable

    inho, 23 Февраля 2018

    Комментарии (559)
  8. PHP / Говнокод #23814

    +1

    1. 1
    2. 2
    3. 3
    if (count($this->session->userdata('search_data') > 0)) {
    ...
    }

    Видимо, это "проверка", что массив не пустой

    gorsash, 22 Февраля 2018

    Комментарии (0)
  9. C# / Говнокод #23813

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    while(true) 
    {
        i++;
        if (i > Int32.MaxValue - 10)
        {
            MessageBox.Show("Зациклилось!");
            break;
        }
    }

    mazhuravlev, 22 Февраля 2018

    Комментарии (12)
  10. PHP / Говнокод #23807

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    $female = $image->getOwner();
    if ($female->isMale()) {
        return true;
    }

    из дейтинг проекта

    chizdrel, 21 Февраля 2018

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