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

    −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
    #include <iostream>
    #include <windows.h>
    
    int i;
    
    using namespace std;
    
    
    int main() {
    	setlocale(LC_ALL, "RUSSIAN");
    	cout << "супер антиверус "чистелка гавна" от леомакс готов к запуську" << endl;
    		for (i;i<101;i++) {
    			switch(i) {
    				case 11:{
    					cout << "проверка на наличие говнакода" << endl;
    					break;
    				};
    				case 28:{
    					cout << "говнакод не найдет" << endl;
    					break;
    				}
    				case 50:{
    					cout << "исчу трайани" << endl;
    					break;
    				}
    				case 64:{
    					cout << "песдец" << endl;
    					break;
    				}
    				case 90:{
    					cout << "готова!!111!!!11!" << endl;
    					break;
    				}
    			}
    		Sleep(100);
    		}
    	cout << "супер антиверус от леосракс "чистелка гавна" нашел верус в вашем компьюктере, с вас всего 999р на нашу карту, если не скинете, вам песдъа"
    	return 0;
    }

    Антивирус "Чистилка Говна" от Leomax. Всего за 999Р!!! Успейте купить сегодня!!!

    COBA_KEK, 13 Августа 2020

    Комментарии (6)
  2. SQL / Говнокод #26859

    +1

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    SELECT 
        `1000, 1000000 field`
        (SELECT group_concat(band_category_languages.name SEPARATOR ', ')
        FROM calendar_entry_categories
        LEFT JOIN band_category_languages ON band_category_languages.band_category_id = calendar_entry_categories.band_category_id
        WHERE calendar_entry_categories.calendar_entry_id = calendar_entries.id
        AND band_category_languages.language_id = 1
        GROUP BY calendar_entry_categories.calendar_entry_id) AS band_category_string,
        (SELECT entry.id
        FROM calendar_entries AS entry
        WHERE entry.entry_kind_parent_id = calendar_entries.id
        AND entry.profile_type_id = 10869
        AND entry.profile_type = 1) AS move_to_personal_calendar,
        (SELECT count(moved_entry.id)
        FROM calendar_entries AS moved_entry
        WHERE moved_entry.entry_kind_parent_id = calendar_entries.id
        AND moved_entry.status = 3) AS count_moved,
        (SELECT user_images.image
        FROM calendar_entries AS calendar_entries1
        LEFT JOIN user_images ON user_images.id = calendar_entries1.image
        WHERE calendar_entries1.id = calendar_entries.entry_kind_parent_id
        AND calendar_entries.entry_kind = 4) AS festival_image,
        (SELECT countries1.code
        FROM calendar_entries AS calendar_entries1
        LEFT JOIN locations AS locations1 ON locations1.id = calendar_entries1.location_id
        LEFT JOIN countries AS countries1 ON countries1.id = locations1.country_id
        WHERE calendar_entries1.id = calendar_entries.entry_kind_parent_id
        AND calendar_entries.entry_kind = 4) AS festival_country_code,
        (SELECT count(*)
        FROM calendar_entry_likes
        WHERE calendar_entry_likes.calendar_entry_id = calendar_entries.id) AS count_of_likes,
        (SELECT count(*)
        FROM calendar_entry_likes
        WHERE calendar_entry_likes.calendar_entry_id = calendar_entries.id
        AND calendar_entry_likes.user_id = 10869 ) AS is_like,
        (SELECT group_concat(entry_type_languages.name SEPARATOR ', ')
        FROM calendar_entry_types
        LEFT JOIN entry_type_languages ON entry_type_languages.entry_type_id = calendar_entry_types.entry_type_id
        WHERE (calendar_entry_types.calendar_entry_id = calendar_entries.id
        OR calendar_entry_types.calendar_entry_id = calendar_entries.entry_kind_parent_id)
        AND entry_type_languages.language_id = 1
        GROUP BY calendar_entry_types.calendar_entry_id) AS entry_types_string,
        (SELECT band_addresses.city_name
        FROM band_addresses
        WHERE band_addresses.band_id = calendar_entries.profile_type_id) AS band_city_name,
        (SELECT countries.code
        FROM band_addresses
        LEFT JOIN countries ON countries.id = band_addresses.country_id
        WHERE band_addresses.band_id = calendar_entries.profile_type_id) AS band_country_code,
        (SELECT group_concat(genre_languages.name SEPARATOR ', ')
        FROM calendar_entry_genres
        LEFT JOIN genre_languages ON genre_languages.genre_id = calendar_entry_genres.genre_id
        WHERE calendar_entry_genres.calendar_entry_id = calendar_entries.id
        AND genre_languages.language_id = 1
        GROUP BY calendar_entry_genres.calendar_entry_id) AS genre_string
    FROM `calendar_entries`
    LEFT JOIN `locations` ON `locations`.`id` = `calendar_entries`.`location_id`
    LEFT JOIN `calendar_entries` AS `festival` ON `festival`.`id` = `calendar_entries`.`entry_kind_parent_id`
    LEFT JOIN `locations` AS `festival_location` ON `festival_location`.`id` = ( 
        SELECT calendar_entries1.id
        FROM calendar_entries AS calendar_entries1
        WHERE calendar_entries1.id = calendar_entries.entry_kind_parent_id
        AND calendar_entries.entry_kind = 4
    )
    LEFT JOIN `countries` ON `countries`.`id` = `locations`.`country_id`
    LEFT JOIN `country_languages` ON `country_languages`.`country_id` = `locations`.`country_id`
    LEFT JOIN `states` ON `states`.`id` = `locations`.`state_id`
    LEFT JOIN `bands` ON `bands`.`id` = `calendar_entries`.`profile_type_id`
    AND `bands`.`soft_delete` = 0
    AND `bands`.`status` = 1
    LEFT JOIN `band_images` ON `band_images`.`id` = `calendar_entries`.`image`
    LEFT JOIN `band_privacy_settings` ON `band_privacy_settings`.`band_id` = `calendar_entries`.`profile_type_id`
    WHERE (`bands`.`soft_delete` = 0 OR `bands`.`soft_delete` IS NULL)
    AND (`bands`.`status` = 1 OR `bands`.`status` IS NULL)
    AND ((
            (SELECT count(*)
            FROM band_administrators
            WHERE band_administrators.band_id = bands.id
            AND band_administrators.user_id = 10869 ) > ? OR `band_privacy_settings`.`band_privacy_level` != ?
        ) AND (
            (SELECT user_type
            FROM users
            WHERE users.id = 10869 ) = ? OR `band_privacy_settings`.`band_privacy_level` != ?
        ) AND (
            (SELECT count(*)
            FROM user_bands
            WHERE user_bands.band_id = bands.id
            AND user_bands.status = 1
            AND user_bands.user_id = 10869 ) > ? OR `band_privacy_settings`.`band_privacy_level` != ?
        ) OR `band_privacy_settings`.`band_privacy_level` IS NULL
    ) AND (`festival`.`entry_kind` = ? OR `festival`.`id` IS NULL)
    AND (date(`calendar_entries`.`date_from`) >= ?)
    AND `calendar_entries`.`soft_delete` = ?
    AND (`country_languages`.`language_id` = ? OR `country_languages`.`language_id` IS NULL)
    AND `calendar_entries`.`entry_kind` IN (?, ?)
    AND `calendar_entries`.`event_class` IN (?, ?)
    AND `calendar_entries`.`status` = ?
    GROUP BY `1000, 1000000 field`
    ORDER BY calendar_entries.date_from
    LIMIT 1000, 20

    Сидить замовник такий не тужить тай думку гадає, а що це я буду платити півтори куска спеціалусту за роботу, як є "профі" за 500 доларів, а тут ше і Вася програміст каже, а шо це ти будеш платити таку суму, як я зроблю дешевше за 300! Настрій хороший, угода укладена, робота кипить. Проходить не так багато часу, як замовник каже, а що це сторінка 2хв грузиться, а Вася каже, то нічо ми то все оптимізуємо! Проходить ще декілька місяців, а результату нема. Тоді замовнек розуміє, що Вася не профі і шукає профі в Х рази дорощого! Не так багато часу пройшло, як профі за 1000 каже, я в два рази оптимізував, більше не реально! Замовник пригнічений, шукає профі, і в один прекрасний момент знаходиться дійсно профі, який по домовленості в зарплату X оптимізував, повикидував, переписав, дописав і в результаті 50 мс при 500000 записів. Підсумок: 300 + 1000 + X != 300 :)

    silverreve23, 12 Августа 2020

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

    +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
    using System;
    using System.Collections.Generic;
    using System.Globalization;
    using System.Windows.Data;
    using Indusoft.PolypropylenPowder.Info;
    
    //СУКИ ИНДАСОФТОВСКИЕ
    namespace Indusoft.PolypropylenPowder.Converters
    {
        public class BeginXxConverter : IValueConverter
        {
            public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
            {
                if (value == null) return null;
                var s = value as IEnumerable<object>;
    
                var res = 45.0;
                var flag = false;
                if (s != null)
                {
                    foreach (var a in s)
                    {
                        var b = a as DataTemplate5Item;
                        if (b != null)
                        {
                            if (b.IsActive5)
                            {
                                flag = true;
                                break;
                            }
                        }
                        res += 91;
                    }
                }
                if (!flag)
                {
                    return 0;
                }
                return res;
            }
    
            public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
            {
                throw new NotImplementedException();
            }
        }
    }

    ух сука питухи, а мне это говно поддерживать

    GreatMASTERcpp, 12 Августа 2020

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

    −2

    1. 1
    2. 2
    3. 3
    Ещё раз о «лицензиях»
    
    https://sun1-95.userapi.com/LR_BeKxXR6XXDG2k-dpOCzUf63zRdc6491VvIg/1J2iS0o6d_Y.jpg

    Кому они нужны?
    Это имеет какую-то юридическую силу?
    Что будет, если нарушить? Пацаны не поймут?

    OCETuHCKuu_nemyx, 10 Августа 2020

    Комментарии (89)
  5. PHP / Говнокод #26855

    0

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    <?php
    /* -= Developed by [email protected] =- */
    // -= О П Ц И И =-
    require("config.php");
    // Технические настройки скрипта
    header('Content-Type: text/html; charset=utf-8');
    ini_set('memory_limit', '-1');
    // -=-=-=-=-=-=-=-
    
    // -= Функции инкапсуляции технических аспектов =-
    // Функция печати логов, добавляет "date n time now" и перенос строки
    function printLog($text) { echo sprintf("[%s] %s", date("Y-m-d H:i:s"), $text) . "\n"; }
    // Функция преобразования текста в ключ индекса, убирает пробелы, переводит в верхний регистр и добавляет префикс "_"
    function str2idx($str) { return "_" . strtoupper( str_replace(' ', '', (string)$str) ); }
    // Функция генерации ассоциативного массива индексов, использует str2idx
    function genIdxs($array, $val_key, $idx_keys, $filter_func=NULL) {
        $idxs = [];
        foreach ($array as $item) {
        	if ($filter_func && !$filter_func($item)) { continue; } 
        	if (is_string($idx_keys)){
        		foreach (preg_split("/\s?;\s?/", $item[$idx_keys]) as $idx) {
        			if ($idx) { $idxs[str2idx($idx)] = str2idx((string)$item[$val_key]); }
        		} unset($idx);
        	} else {
        		foreach ($idx_keys as $idx_key) {
        			foreach (preg_split("/\s?;\s?/", $item[$idx_key]) as $idx) {
        				if ($idx) { $idxs[str2idx($idx)] = str2idx((string)$item[$val_key]); }
        			}
        		} unset($idx_key);
        	}
        } unset($item);
        return $idxs;
    }
    // Функция сравнения изображений
    function compareImages($image1, $image2) {
        $compare_result = $image1->compareImages($image2, IMAGICK_METRIC);
        return (int)$compare_result[1] > THRESHOLD_SIMILARITY_VALUE;
    }
    // Функция исполнения SQL-запросов в БД, инкапсулирующая все ужасы взаимодействия с БД MySQL на PHP
    function execSQL($sql, $mode="fetch_assoc") {
        // Проверяем коннект к БД, в случае проблем - пытаемся переподключ
        if (!$GLOBALS["mysqli"] || $GLOBALS["mysqli"]->connect_errno) { 
        	$GLOBALS["mysqli"] = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); 
        	if ($GLOBALS["mysqli"]->connect_errno) {
        		throw new Exception("Can't connect to DB: (".$GLOBALS["mysqli"]->connect_errno.") ".$GLOBALS["mysqli"]->connect_error);
        	}
        	printf("default charset: %s\n", $GLOBALS["mysqli"]->character_set_name());
        	/* изменение набора символов на utf8 */
        	if (!$GLOBALS["mysqli"]->set_charset("utf8")) {
        		throw new Exception("set charset utf8 error: %s\n", $GLOBALS["mysqli"]->error);
        	} else { printf("current charset: %s\n", $GLOBALS["mysqli"]->character_set_name()); }
        }
        $_result = $GLOBALS["mysqli"]->query($sql);
        if (!$_result) { printLog("SQL ERROR: ". $GLOBALS["mysqli"]->error . "\n executable SQL: " . $sql . "\n\n"); }
        if (is_bool($_result)) { return $_result; }
        elseif ($mode==="num_rows") { return $_result->num_rows; }
        elseif ($mode==="fetch_assoc") {
        	$result = [];
        	while($row = $_result->fetch_assoc()) {
        		reset($row);
        		$key = str2idx($row[key($row)]);
        		$result[$key] = $row;
            } unset($row);
            return $result;
        }
        throw new Exception("Recieved unexpected mode (".$mode.") or query result by execute SQL: ".$sql );
    }
    // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    
    // -= Старт работы скрипта =-
    $start = microtime(true);
    printLog("Updater script started");
    // Инициализация глобальных переменных, счетчиков
    $GLOBALS["mysqli"] = NULL;
    $kingsilk_offers_count = 0;
    // Проверка хранилища фотографий
    if (!is_dir(IMAGES_PATH)) throw new Exception("ERROR: images path not found!");
    $IMAGES_FULL_PATH = IMAGES_PATH . IMAGE_PATH_PREFIX;
    if (!is_dir($IMAGES_FULL_PATH)) mkdir($IMAGES_FULL_PATH);
    // -=-=-=-=-=-=-=-=-=-=-=-=-=-
    
    // -= Получение YML-данных от поставщика Кингсилк, формирование индексов =-
    $yml_catalog = new SimpleXMLElement(
        file_get_contents(YML_URL_KINGSILK)
    );
    // Формирование индекса импортируемых категорий по id'шнику категории поставщика
    $GLOBALS['cats_outer_idxs'] = [];
    foreach ($yml_catalog->categories->category as $cat){
        $GLOBALS['cats_outer_idxs'][str2idx((string)$cat["id"])] = $cat;
    } unset($cat);
    // Группировка предложений поставщика по схожести картинок,
    // формирование древовидного индекса по md5 хэшу картинок
    $offers_groups_idxs = [];
    foreach ($yml_catalog->offers->offer as $offer) {
        // Отсеиваем не опубликованные товары
        if ((string)$offer["available"] != "true"){
        	continue;
        }
        $kingsilk_offers_count++;
        $hash = NULL;

    - = А ЧО ТУТ НЕЛЬЯ ПОСТИТЬ ПОЛНЫЙ КОД = - ???
    ===~ ТАМ ДОХРЕНА ЕЩЁ ~==

    P.S - вот как кодят питонисты на php
    продолжение: <a href="https://raw.githubusercontent.com/Siyet/goods-updater-oc3-php7/master/updater.php">Перейти</a>

    vasily2808, 10 Августа 2020

    Комментарии (136)
  6. Lua / Говнокод #26853

    +2

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    if thr < 0.1 then
    		one()
    	elseif thr > 0.1 and thr < 0.2 then
    		one()
    		two()
    	elseif thr > 0.2 and thr < 0.3 then
    		one()
    		two()
    		three()
    	elseif thr > 0.3 and thr < 0.4 then
    		one()
    		two()
    		three()
    		four()
    	elseif thr > 0.4 and thr < 0.5 then
    		one()
    		two()
    		three()
    		four()
    		five()
    	elseif thr > 0.5 and thr < 0.6 then
    		one()
    		two()
    		three()
    		four()
    		five()
    		six()
    	elseif thr > 0.6 and thr < 0.7 then
    		one()
    		two()
    		three()
    		four()
    		five()
    		six()
    		seven()
    	elseif thr > 0.7 and thr < 0.8 then
    		one()
    		two()
    		three()
    		four()
    		five()
    		six()
    		seven()
    		eight()
    	elseif thr > 0.8 and thr < 0.9 then
    		one()
    		two()
    		three()
    		four()
    		five()
    		six()
    		seven()
    		eight()
    		nine()
    	elseif thr > 0.9 and thr < 1 then
    		one()
    		two()
    		three()
    		four()
    		five()
    		six()
    		seven()
    		eight()
    		nine()
    		ten()
    	elseif thr == 1 then
    		one()
    		two()
    		three()
    		four()
    		five()
    		six()
    		seven()
    		eight()
    		nine()
    		ten()
    		eleven()
    	end
    
    ........
    
    function one()
    	screen.setColor(0, 255, 0)
    	screen.drawRectF(12, 53, 4, 5)
    end
    	
    function two()
    	screen.setColor(0, 255, 0)
    	screen.drawRectF(16, 53, 4, 5)
    end
    	
    function three()
    	screen.setColor(0, 255, 0)
    	screen.drawRectF(20, 53, 4, 5)
    end
    	
    function four()
    	screen.setColor(0, 255, 0)
    	screen.drawRectF(24, 53, 4, 5)
    end

    Говнокод для рисования полоски загрузки

    griffi1, 08 Августа 2020

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

    +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
    private static final String CITY_PREFIX = "г.";
    private static final Map<String, String> CITIES = new HashMap<>() {
      {
        put("В.Новгород", "Великий Новгород");
        put("Н.Новгород", "Нижний Новгород");
        put("В. Новгород", "Великий Новгород");
        put("Н. Новгород", "Нижний Новгород");
        put("Великий Новгород", "Великий Новгород");
        put("Нижний Новгород", "Нижний Новгород");
        put("Петербург", "Санкт-Петербург");
        put("Челны", "Набережные Челны");
        put("Уренгой", "Новый Уренгой");
        put("ПсковS", "Псков");
      }
    };
    private static final Map<String, String> CITIES_WITH_PREFIX = new HashMap<>() {
      {
        put("г.Пушкино", "Пушкино");
      }
    };

    ну просто офигенный мапинг

    varg, 07 Августа 2020

    Комментарии (48)
  8. Куча / Говнокод #26850

    0

    1. 1
    Тестовый тред, можно игнорить

    Desktop, 07 Августа 2020

    Комментарии (255)
  9. PHP / Говнокод #26849

    +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
    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
    $data = [];
            $firstGenreId = Genre::where('homepage_filter_band', 1)->first()->id;
            $bandSearch = [
                'limit' => request('limit') ?? 6,
                'genre' => $firstGenreId,
                'category' => BandCategory::where('homepage_filter', 1)->first()->id,
                'status' => 1
            ];
    
            $subGenres = Genre::getGenresByCategory($bandSearch['genre']);
            $bandSearch['genre'] = [$bandSearch['genre']];
            foreach ($subGenres as $subGenre){
                array_push($bandSearch['genre'], $subGenre->id);
            }
    
            $data['bandsGenre']['bands'] = Band::getBandsLimitListByGenre($bandSearch);
            $data['bandsGenre']['filters'] = Genre::isExistGenreByBandFilter();
            $data['bandsGenre']['active_filter'] = $firstGenreId;
            $data['bandsGenre']['type'] = 'genre';
    
            $data['bandsCategories']['bands'] = Band::getBandsLimitListByCategory($bandSearch);
            $data['bandsCategories']['filters'] = BandCategory::isExistCategoryByBandFilter();
            $data['bandsCategories']['active_filter'] = $bandSearch['category'];
            $data['bandsCategories']['type'] = 'category';
    
            $data['bandsStatus']['bands'] = Band::getBandsLimitListByStatus($bandSearch);
            $data['bandsStatus']['active_filter'] = 1;
            $data['bandsStatus']['filters'] = (object)[
                0 => [
                    'id' => 1,
                    'name' => trans('validation-custom.newest')
                ],
                1 => [
                    'id' => 2,
                    'name' => trans('validation-custom.lastUpdated')
                ]
            ];
            $data['bandsStatus']['type'] = 'status';
    
            $firstGenreId = Genre::where('homepage_filter_musician', 1)->first()->id;
            $firstInstrumentId = Instrument::where('homepage_filter', 1)->first()->id;
            $musicianSearch = [
                'limit' => request('limit') ?? 6,
                'genre' => $firstGenreId,
                'instrument' => $firstInstrumentId,
                'status' => 1
            ];
    
            $subGenres = Genre::getGenresByCategory($musicianSearch['genre']);
            $musicianSearch['genre'] = [$musicianSearch['genre']];
            foreach ($subGenres as $subGenre){
                array_push($musicianSearch['genre'], $subGenre->id);
            }
    
            $subInstruments = Instrument::getInstrumentsByCategory($musicianSearch['instrument']);
            $musicianSearch['instrument'] = [$musicianSearch['instrument']];
            foreach ($subInstruments as $subInstrument){
                array_push($musicianSearch['instrument'], $subInstrument->id);
            }
    
            $data['musiciansGenre']['musicians'] = User::getMusiciansLimitListByGenre($musicianSearch);
            $data['musiciansGenre']['filters'] = Genre::isExistGenreByFilter();
            $data['musiciansGenre']['active_filter'] = $firstGenreId;
            $data['musiciansGenre']['type'] = 'genre';
    
            $data['musiciansInstrument']['musicians'] = User::getMusiciansLimitListByInstrument($musicianSearch);
            $data['musiciansInstrument']['filters'] = Instrument::isExistInstrumentByFilter();
            $data['musiciansInstrument']['active_filter'] = $firstInstrumentId;
            $data['musiciansInstrument']['type'] = 'instrument';
    
            $data['musiciansStatus']['musicians'] = User::getMusiciansLimitListByStatus($musicianSearch);
            $data['musiciansStatus']['active_filter'] = 1;
            $data['musiciansStatus']['filters'] = (object)[
                0 => [
                    'id' => 1,
                    'name' => trans('validation-custom.newest')
                ],
                1 => [
                    'id' => 2,
                    'name' => trans('validation-custom.lastUpdated')
                ]
            ];
            $data['musiciansStatus']['type'] = 'status';
    
            return response()->json($data, 200);

    Кажуть - шота сторінка довго грузиться :)

    silverreve23, 07 Августа 2020

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

    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
    #include <stdio.h>
    #include <stddef.h>
    #include <stdlib.h>
    #include <stdint.h>
    
    #define GEN_NAME(type) struct myvec_ ## type
    
    #define MK_VEC_TYPE(type) GEN_NAME(type) {size_t sz; type arr[];}; 
    
    #define MK_VEC_NEW(type) \
    GEN_NAME(type) *myvec_new_ ## type (size_t num) \
    { \
      struct myvec_ ## type *tmp = malloc(sizeof(type) * num); \
      if (tmp == NULL) \
      { \
        return NULL; \
      } \
      tmp->sz = num; \
      return tmp; \
    }
    
    #define MK_VEC_DELETE(type) \
    void myvec_delete_ ## type (GEN_NAME(type) *v) \
    { \
      free(v); \
    }
    
    
    #define MK_VEC_GET(type) \
    type myvec_get_ ## type (GEN_NAME(type) *v, size_t pos) \
    { \
      if(pos < v->sz) \
      { \
        return v->arr[pos]; \
      } \
      else \
      { \
        exit(-1); \
      } \
    }
    // исключения - говно
    
    #define MK_VEC_SET(type) \
    void myvec_set_ ## type (GEN_NAME(type) *v, size_t pos, type val) \
    { \
      if(pos < v->sz) \
      { \
        v->arr[pos] = val; \
      } \
      else \
      { \
        exit(-1); \
      } \
    }
    
    
    #define MK_VEC_GETSZ(type) \
    size_t myvec_getsz_ ## type (GEN_NAME(type) v) \
    { \
      return v.sz; \
    }
    
    #define MK_SHIT(type) \
    MK_VEC_TYPE(type) \
    MK_VEC_NEW(type) \
    MK_VEC_DELETE(type) \
    MK_VEC_GET(type) \
    MK_VEC_GETSZ(type) \
    MK_VEC_SET(type)
    
    MK_SHIT(int)
    MK_SHIT(float)
    MK_SHIT(double)
    
    #define test(a) _Generic(a, int : 1, GEN_NAME(int) : 2, default : 0)
    
    #define MTD_C(val,mtd) _Generic( val,\
      GEN_NAME(int): myvec_ ## mtd ##_int, \
      GEN_NAME(float): myvec_ ## mtd ##_float, \
      GEN_NAME(double): myvec_ ## mtd ##_double, \
      default: 0) // хуй там!
    
    #define GET(vec,pos) MTD_C(vec,get)(&vec,pos)
    #define SET(vec, pos, val) MTD_C(vec,set)(&vec,pos,val)
    #define GETSZ(vec) MTD_C(vec,getsz)(vec)
      
    int main(void)
    {
      GEN_NAME(int) *vec1 = myvec_new_int(10);
      SET(*vec1, 0, 123);
      size_t size = GETSZ(*vec1);
      printf("vector size is %zu\n", size);
      printf("vector vec1[0] is %d\n", GET(*vec1,0));
      return 0;
    }

    Какое ООП)))

    j123123, 07 Августа 2020

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