1. PHP / Говнокод #25891

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    https://ru.wikipedia.org/wiki/Деление_с_остатком#В_программировании
    
    Смотрим табличку справа.
    
    Именно поэтому я против PHP

    OlegUP, 01 Октября 2019

    Комментарии (20)
  2. Python / Говнокод #25890

    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
    from xml.sax.saxutils import unescape
    
    HEADERS = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36',
               'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
               'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
               'Accept-Language': 'ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3'}
    
    GOOGLE_RE = re.compile(r'<h3 class="r"><a href="([^"]+)" ')
    YANDEX_RE = re.compile(r'<span class="serp-url__mark">.</span><a class="link serp-url__link" target="_blank" href="([^"]+)"')
    PROXY_RE = re.compile(r'(\d+\.\d+\.\d+\.\d+)[:\s]+(\d+)')
    
    def search_google(requests_list, qdr=None, interval=2):
        res = []
        qdr = 'd' if qdr is None or not qdr in ['w', 'd'] else qdr
        REQ_FORMAT = 'https://www.google.com/search?q={0}&num=100&tbs=qdr:' + qdr
        i = 0
    
        for term in requests_list:
            req = REQ_FORMAT.format(term)
            response = requests.get(req, headers=HEADERS)
            if response.status_code != 200:
                print ('Google returned {0}'.format(response.status_code))
                time.sleep(interval)
                continue
    
            txt = response.text
            found = GOOGLE_RE.findall(txt)
            res += found
            print ('done term {0}, found {1} URLs'.format(i, len(found)))
            i += 1
    
            time.sleep(interval)
    
        map(unescape, res)
        
        return res

    Древняя граббилка открытых прокси при помощи поисковых систем. Когда-то даже работала.

    gost, 01 Октября 2019

    Комментарии (29)
  3. PHP / Говнокод #25889

    +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
    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
    <?php
    $fin = fopen($argv[1], 'r');
    if($fin === false) die();
    
    $fout = fopen('dump.csv', 'w');
    if($fout === false) die();
    
    while(!feof($fin)) {
        $rawline = fgets($fin);
        if(!preg_match('#\[+(.*)\]+,?#', $rawline, $matches)) continue;
        $fields = str_getcsv($matches[1]);
        $parts = explode(')', $fields[0]);
        if(count($parts) < 2) continue;
        list($host, $path) = $parts;
        $domains = explode(',', $host);
        $dirs    = explode('/', $path);
        if($domains[0] === 'ru' && $domains[1] === 'mail') {
            $email = $dirs[2] . '@' . $dirs[1] . '.ru';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
        } else if($domains[0] === 'ru' && $domains[1] === 'rambler' && $dirs[1] = 'users') {
            if(strpos($dirs[2], '@') === false) {
                $email = $dirs[2] . '@rambler.ru';
            } else {
                $email = $dirs[2];
            }
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
        } else if($domains[0] === 'ru' && $domains[1] === 'ya') {
            $email = $domains[2] . '@yandex.ru';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
            $email = $domains[2] . '@yandex.by';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
            $email = $domains[2] . '@yandex.ua';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
            $email = $domains[2] . '@yandex.kz';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
            $email = $domains[2] . '@yandex.com';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
            $email = $domains[2] . '@ya.ru';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
        } else if($domains[0] === 'ru' && $domains[1] === 'yandex' && $dirs[1] = 'users') {
            $email = $dirs[2] . '@yandex.ru';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
            $email = $dirs[2] . '@yandex.by';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
            $email = $dirs[2] . '@yandex.ua';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
            $email = $dirs[2] . '@yandex.kz';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
            $email = $dirs[2] . '@yandex.com';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
            $email = $dirs[2] . '@ya.ru';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
        }
    }
    
    fclose($fout);
    fclose($fin);

    Генератор радужных таблиц для е-мейлов.

    Особенность программы в том, что «JSON» парсится как «CSV» в целях экономии оперативки.

    ropuJIJIa, 01 Октября 2019

    Комментарии (34)
  4. C++ / Говнокод #25888

    −8

    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
    #include <iostream>
    using namespace std;
    int_main()
    {
        double a, c;
        char b;
        cout << "Enter the example: ";
        cin >> a, b, c;
        if (b == '+')
        {
            cout << a+c;
        }
        if (b == '-')
        {
            cout << a-c;
        }
        if (b == '*')
        {
            cout << a*c;
        }
        if (b == '/')
        {
            cout << a/c;
        }
        return 0;
    }

    Почему не работает парню на SO так и не ответили...

    EMWD, 30 Сентября 2019

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

    −98

    1. 1
    Давайте рисовать кривые Безьё.

    Crabbe, 30 Сентября 2019

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

    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
    var infScroll = throttle(function() {
        if ((window.innerHeight + window.pageYOffset) >= document.body.offsetHeight) {
            $scope.loadMoreResults();
        }
    }, 1500);
    
    var infScrollListener = function(ev) {
        if ((window.innerHeight + window.pageYOffset) >= document.body.offsetHeight) {
            infScroll();
        }
    };
    
    window.addEventListener('scroll', infScrollListener);
    
    $scope.$on('$destroy', function() {
        infScroll.cancel();
        window.removeEventListener('scroll', infScrollListener);
    });

    Какой бесконечный скроллинг )))

    gost, 30 Сентября 2019

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    var a = ['a', 'b', 'c'];
    var b = ['d', 'e', 'f'];
    b.forEach(item => a.push(item));  // a == ["a", "b", "c", "d", "e", "f"]
    
    // Но:
    var a = ['a', 'b', 'c'];
    var b = ['d', 'e', 'f'];
    b.forEach(a.push.bind(a));  // a == ["a", "b", "c", "d", 0, Array(3), "e", 1, Array(3), "f", 2, Array(3)]

    Кто поймёт, что за хуйня, тому нихуя.

    gost, 30 Сентября 2019

    Комментарии (24)
  8. Java / Говнокод #25884

    +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
    public void addDisplayMethodNoAttribute()
    {
            addHeaderMethod();
            pyScript.append("def doPrint(row, columns):\n");
            pyScript.append("  line=\"\"\n");
            pyScript.append("  for column in columns:\n");
            pyScript.append("    if(line == \"\"):\n");
            pyScript.append("      line = line + str(row[column])\n");
            pyScript.append("    else:\n");
            pyScript.append("      if(column == \"translations\"):\n");
            pyScript.append("        line = line + separator+ \"[\"\n");
            pyScript.append("        buf = \"\"\n");
            pyScript.append("        for item in row[column]:\n");
            pyScript.append("          if(buf != \"\"):\n");
            pyScript.append("            buf = buf + \", \"\n");
            pyScript.append(
                    "          buf = buf + \"[\" + str(item[\"source\"]) + \", \" + item[\"code\"] + \", \" + item[\"comment\"] + \"]\"\n");
            pyScript.append("        line = line + buf + \"]\"\n");
            pyScript.append("      else:\n");
            pyScript.append("        line = line + separator + str(row[column])\n");
            pyScript.append("  print(line)\n");
            pyScript.append("\n");
            pyScript.append("list = df.collect()\n");
            pyScript.append("for row in list:\n");
            pyScript.append("    doPrint(row, df.columns)\n");
            pyScript.append("\n");
            addSessionDestroy();
            generatePySparkScript();
    }

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

    kazuzbek, 30 Сентября 2019

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

    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
    #include "pch.h"
    #include <iostream>
    #include <conio.h>
    #include <math.h>
    #include <stdlib.h>
    
    using namespace std;
    
    int main()
    {
    	setlocale(0, "rus");
    	int a[100], min = 0, sum=0, n, k=0;
    	double sr;
    	cout << "введите количество элементов массива: "; cin >> n;
    	cout << "\n---элементы массива должны быть ЦЕЛЫМИ---\n\n";
    	
    	for (int i = 0; i < n; i++) {
    		cout << "a[" << i + 1 << "] = "; cin >> a[i];
    		if (a[i] > 0) {
    			k++;
    			sum += a[i];
    		}
    		else {
    			if (a[i] < min) min = a[i];
    		}
    	}
    	sr = (double)sum / k;
    	cout << "произведение минимального среди отрицательных (" << min << ") на среднее арифметическое всех положительных (" << sr << ") равно: " << min * sr;
    	
            _getch();
    	return 0;
    }

    Произведение минимального среди отрицательных на среднее арифметическое всех положительных.

    maxrbs, 30 Сентября 2019

    Комментарии (7)
  10. Java / Говнокод #25882

    +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
    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
    public class Main {
        public static void main(String[] args) {
            ThreeD[] f = {new ThreeD(5, 9, 7), new FourD(1,3,8,5)};
            Coords<ThreeD> c = new Coords<>(f);
            showXYZ(c);
            FiveD[] x = new FiveD[] {new FiveD(11,22,3,4, 123)};
            Coords<FiveD> b = new Coords<>(x);
            showAll(b);
            FiveD[] z = new FiveD[] {new FiveD(1,2,1,6,5)};
            Coords<FiveD> zz = new Coords<>(z);
        }
        private static void showXY(Coords<? super FourD> c) {
            for(int i = 0; i < c.coords.length; i++) {
                System.out.println(c.coords[i].x +" "+ c.coords[i].y+" ");
            }
        }
    
        private static void showXYZ(Coords<? extends ThreeD> c) {
            for(int i = 0; i < c.coords.length; i++) {
                System.out.println(c.coords[i].x +" "+ c.coords[i].y+" "+c.coords[i].z+" ");
            }
        }
        private static void showAll(Coords<? extends FiveD> c) {
            for(int i = 0; i < c.coords.length; i++) {
                System.out.println(c.coords[i].x +" "+ c.coords[i].y+" "+c.coords[i].z+" "+c.coords[i].t+" "+c.coords[i].m);
            }
        }
    }
    
    class Coords<T extends TwoD> {
        T[] coords;
        Coords(T[] o) {
            coords = o;
        }
    }
    
    class TwoD {
        int x,y;
        TwoD(int a, int b) {
            x = a;
            y = b;
        }
    }
    class ThreeD extends TwoD {
        int z;
        ThreeD(int a, int b, int c) {
            super(a, b);
            z = c;
        }
    }
    class FourD extends ThreeD {
        int t;
        FourD(int a, int b, int c, int d) {
            super(a, b, c);
            t = d;
        }
    }
    class FiveD extends FourD {
        int m;
        FiveD(int a, int b, int c, int d, int e) {
            super(a, b, c, d);
            m = e;
        }
    }

    говнецо или нет

    codershitter, 29 Сентября 2019

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