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

    −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
    export const getBasketProductsWithCount = state => {
      const productCount = id => R.compose(
        R.length,
        R.filter(basketId => R.equals(id, basketId.id))
      )(state.basket);
      const productWithCount = product => R.assoc('count', productCount(product.id), product);
    
      const uniqueIds = R.uniq(state.basket);
      const products = R.compose(
        R.map(productWithCount),
        R.map(id => id)
      )(uniqueIds);
    
      return products;
    };

    greshnik, 21 Марта 2018

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

    −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
    def chicken():
    	print("Курица")
    	return egg()
    
    def egg():
    	print("Яйцо")
    	return chicken()
    
    try:
    	chicken()
    except RecursionError:
    	print("ТЫ ПИДОР")

    ScythepX, 21 Марта 2018

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

    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
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    //Они относятся к посту ниже
    #include "stdafx.h"
    #include<iostream>
    
    
    using namespace std;
    /*Доказать что (АВ)^-1=B^-1*A^-1*/
    void printLine(int n) {
    	n *= 2;
    	n--;
    	for (int i = 0; i < n;i++) {
    		cout << '*';
    	}
    	cout << endl;
    }
    void obr(bool **arr1,bool **arr2, int  m, int n) {
    	for (int i = 0; i < n; i++) {
    		for (int j = 0; j < m; j++) {
    		arr2[i][j]=arr1[j][i];
    			//cout << arr1[j][i];
    			//cout << ' ';
    		}
    		//cout << endl;
    	}
    }
    void obr(bool **arr1, int  m, int n) {
    	for (int i = 0; i < n; i++) {
    	for (int j = 0; j < m; j++) {
    		
    			cout << arr1[j][i];
    			cout << ' ';
    		}
    		cout << endl;
    	}
    }
    void multiple(bool **arr1, bool **arr2,bool **tempAr, int  m, int n) {
    	for (int i = 0; i < m; i++) {
    		for (int j = 0;j < n; j++) {
    			tempAr[i][j]= arr1[i][j]* arr2[i][j];
    			cout << tempAr[i][j];
    			cout << ' ';
    		}
    		cout << endl;
    	}
    }
    void multiple(bool **arr1, bool **arr2, int  m, int n) {
    	for (int i = 0; i < m; i++) {
    		for (int j = 0; j < n; j++) {
    			cout << arr1[i][j] * arr2[i][j];
    			cout << ' ';
    		}
    		cout << endl;
    	}
    }
    void subtractionMatr(bool **arr1, bool **arr2, bool **tempAr, int  m, int n) {
    	for (int i = 0; i < m; i++) {
    		for (int j = 0; j < n; j++) {
    			if ((arr1[i][j] == true) && (arr2[i][j] == false)) {
    				tempAr[i][j] = true;
    			}
    			else {
    				tempAr[i][j] = false;
    			}
    			cout << tempAr[i][j];
    			cout << ' ';
    		}
    		cout << endl;
    	}
    }
    void subtractionMatr(bool **arr1, bool **arr2,  int  m, int n) {
    	for (int i = 0; i < m; i++) {
    		for (int j = 0; j < n; j++) {
    			if ((arr1[i][j] == true) && (arr2[i][j] == false)) {
    				 cout<< true;
    			}
    			else {
    				cout<< false;
    			}
    			cout << ' ';
    		}
    		cout << endl;
    	}
    }
    bool** setMemory(int m,int n) {
    	bool** ar;
    	ar = new bool*[m];
    	for (int i = 0; i < n; i++) {
    		ar[i] = new bool[n];
    	}
    	return ar;
    }
    void inputElements(bool **bar,int m,int n) {
    	for (int i = 0; i < m; i++) {
    		for (int j = 0; j < n; j++) {
    			cin >> bar[i][j];
    		}
    	}
    }

    Код относящийся к посту ниже

    ArthurMakaev, 20 Марта 2018

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

    +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
    int main()
    {
    	//Все функции в посте выше
    	int m,n;
    	bool **ar1;
    	bool **ar2,**ar3;
    	bool **tar;
    	bool **temp;
    	setlocale(LC_ALL, "RUS");
    	system("color F0");
    	
    	
    	cout << "\tЗАДАНИЕ 1" << endl;
    	cout << "Требуется доказать что (A*B)^-1=(B^-1)*(A^-1)" << endl;
    	cout << "Введите размерность матриц" << endl;
    	cin >> m;
    	cin >> n;
    	ar1 = setMemory(m, n);
    	ar2 = setMemory(m, n);
    	ar3 = setMemory(m, n);
    	tar = setMemory(m, n);
    	temp = setMemory(m, n);
    	cout << "Введите элементы матрицы А" << endl;
    	inputElements(ar1, m, n);
    
    	
    
    	cout << "Введите элементы матрицы В" << endl;
    	inputElements(ar2, m, n);
    	cout << "Введите элементы матрицы C" << endl;
    	inputElements(ar3, m, n);
    	cout << "Cначала найдём (A*B)^-1" << endl;
    	cout << "A*B:" << endl;
    	multiple(ar1, ar2,tar, m, n);
    	cout << "Обратная (A*B): " << endl;
    	printLine(m);
    	obr(tar, m, n);
    	printLine(m);
    	cout << "Теперь переёдём к правой части, найдём (B^-1)*(A^-1) " << endl;
    	obr(ar2,tar, m, n);
    	obr(ar1, temp, m, n);
    	printLine(m);
    	multiple(tar, temp, m, n);
    	printLine(m);
    	cout << endl;
    	cout << endl;
    	printLine(40);
    	cout << "\tЗадание 2 " << endl;
    	cout << "Доказать что (А\\В)\\С=(А\\С)\\В " << endl;
    	cout << "А\\В :" << endl;
    	subtractionMatr(ar1, ar2, tar, m, n);
    	cout << "(А\\В)\\С :" << endl;
    	printLine(m);
    	subtractionMatr(tar, ar3, m, n);
    	printLine(m);
    
    
    
    	cout << "А\\C :" << endl;
    	subtractionMatr(ar1, ar3, tar, m, n);
    	cout << "(А\\C)\\B :" << endl;
    	printLine(m);
    	subtractionMatr(tar, ar2, m, n);
    	printLine(m);
    	system("pause");
        return 0;
    }

    ArthurMakaev, 20 Марта 2018

    Комментарии (2)
  5. Java / Говнокод #23967

    −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
    public bool WaitForElement(Action testMethod)
            {
                try
                {
                    testMethod();
                }
                catch (StaleElementReferenceException)
                {
                    testMethod();
                }
                catch (ElementNotVisibleException)
                {
                    return false;
                }
                catch (NoSuchElementException)
                {
                    return false;
                }
                return true;
            }

    http://software-testing.ru/forum/index.php?/topic/21965-borba-so-staleelementreferenceexception-element-is-no-longer-attached-to-the-dom/?p=138795
    "Не боян, а классика!"

    хуита, 20 Марта 2018

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

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    -define(foo, foo).
    -define(bar, bar).
    -define(baz, baz).
    ...
    
    foo(A, B) ->
      gen_server:call(?MODULE, {?foo, A, B}).
    
    ...
    handle_call({?foo, A, B}, _From, State) ->
      ...

    Паттерн "мирный атом в каждый call".

    CHayT, 20 Марта 2018

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

    +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
    #include "stdafx.h"
    #include<iostream>
    #include<fstream>
    #include<string>
    #include<map>
    #include<iomanip>
    using namespace std;
    int main()
    {
    	string word;
    	setlocale(LC_ALL, "Russian");
    	char s[80];
    	fstream inOut;
    	multimap<string, int>my;
    	multimap<string, int>::iterator it;
    	inOut.open("text.txt", ios::in);
    	for (int i = 1; i < 40; i++) {
    		inOut.getline(s, 256);
    		char* pch;
    		pch = strtok(s, " ,-:;");
    		while (pch != NULL) {
    			word = string(pch);
    			my.insert(pair <string, int>(pch, i));
    			//cout << pch <<'\t'<<i<< endl;
    			pch = strtok(NULL, " ,-:");
    		}
    	}
    		inOut.close();
    	//cout << s;
    		for (it = my.begin(); it != my.end(); it++) {
    			cout.width(25);
    			cout << (*it).first <<setw(5) << (*it).second  << endl;
    		}
    	
    	
    	system("pause");
        return 0;
    }

    Берёт из текста строки и сортирует в алфавитном порядке

    ArthurMakaev, 19 Марта 2018

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

    +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
    foreach ($imagesData['file_title'] as $i1 => $d1) {
                usleep(5);
                
                if($i1>0) {
                    Media::find($i1)->update(['title'=>$imagesData['file_title'][$i1]]);
                }
            }
            foreach ($imagesData['author_name'] as $i2 => $d2) {
                usleep(5);
                
                if($i2>0) {
                    Media::find($i2)->update(['author_name'=>$imagesData['author_name'][$i2]]);
                } 
            }
            foreach ($imagesData['author_link'] as $i3 => $d3) {
                usleep(5);
                
                if($i3>0) {
                    Media::find($i3)->update(['author_url'=>$imagesData['author_link'][$i3]]);
                } 
            }
            foreach ($imagesData['source_link'] as $i4 => $d4) {
                usleep(5);
                
                if($i4>0) {
                    Media::find($i4)->update(['source_url'=>$imagesData['source_link'][$i4]]);
                } 
            }
            foreach ($imagesData['license_name'] as $i5 => $d5) {
                usleep(5);
                
                if($i5>0) {
                    Media::find($i5)->update(['license_name'=>$imagesData['license_name'][$i5]]);
                } 
            }
            foreach ($imagesData['license_link'] as $i6 => $d6) {
                usleep(5);
                
                if($i6>0) {
                    Media::find($i6)->update(['license_url'=>$imagesData['license_link'][$i6]]);
                } 
            }

    Laravel, блять.
    Вот и пусти араба в свою ветку.

    Romanovich095, 19 Марта 2018

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

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    enum BitNumber {
    	Bit0 = 0,
    	Bit1 = 1,
    	Bit2 = 2,
    	Bit3 = 3,
    	Bit4 = 4,
    	Bit5 = 5,
    	Bit6 = 6,
    	Bit7 = 7
    };

    Из крупного проекта, крупной конторы... Но это еще цветочки, ягодки дальше будут.

    elapidae, 19 Марта 2018

    Комментарии (8)
  10. C++ / Говнокод #23958

    −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
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        int a, b, c;
        cin>>a>>b;
        if(a==0&&b==0&&c==0)
            cout<<"Black";
        if(a==1&&b==0&&c==0)
            cout<<"Red";
            if(a==0&&b==1&&c==0)
            cout<<"Green";
            if(a==0&&b==0&&c==1)
            cout<<"Blue";
            if(a==1&&b==1&&c==0)
            cout<<"Yellow";
            if(a==1&&b==0&&c==1)
            cout<<"Magenta";
            if(a==0&&b==1&&c==1)
            cout<<"Cyan";
            if(a==1&&b==1&&c==1)
            cout<<"White";
    }

    не спрашивайте, для чего

    ramune, 18 Марта 2018

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