1. Куча / Говнокод #26029

    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
    $ objdump -f libyjpagent64.so
    
    libyjpagent64.so:     file format elf64-x86-64
    architecture: i386:x86-64, flags 0x00000150:
    HAS_SYMS, DYNAMIC, D_PAGED
    start address 0x00000000000c2690
    
    
    $ readelf -h  libyjpagent64.so
    ELF Header:
      Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
      Class:                             ELF64
      Data:                              2's complement, little endian
      Version:                           1 (current)
      OS/ABI:                            UNIX - System V
      ABI Version:                       0
      Type:                              DYN (Shared object file)
      Machine:                           Advanced Micro Devices X86-64
      Version:                           0x1
      Entry point address:               0xc2690
      Start of program headers:          64 (bytes into file)
      Start of section headers:          5131216 (bytes into file)
      Flags:                             0x0
      Size of this header:               64 (bytes)
      Size of program headers:           56 (bytes)
      Number of program headers:         7
      Size of section headers:           64 (bytes)
      Number of section headers:         30
      Section header string table index: 29

    куик, зачем на прыщах две дублирующие друг друга утилиты?

    MAKAKA, 14 Ноября 2019

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

    +1

    1. 1
    float sales = new Integer(getSalesCount()).floatValue();

    someone, 13 Ноября 2019

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

    +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 <stdio.h>
    #include <inttypes.h>
    #include <string.h>
    
    // endian dependend
    #define PUT3(a,b,c) (((uint64_t)a<<8*0) | ((uint64_t)b<<8*1) | ((uint64_t)c<<8*2))
    
    void testswitch(uint64_t x)
    {
      switch (x) 
      { 
        case PUT3('a','b','c'): printf("abc\n"); 
          break; 
        case PUT3('d','e','f'): printf("def\n"); 
          break; 
        case PUT3('g','h','i'): printf("ghi\n"); 
          break; 
        default: printf("Choice other than abc, def and ghi\n"); 
          break;   
       }
    }
    
    int main() 
    { 
       uint64_t x = 0;
       char a[] = "abc";
       memcpy(&x, a, sizeof(a)-1);
       testswitch(x);
    
       char b[] = "def";
       memcpy(&x, b, sizeof(a)-1);
       testswitch(x);
    
       char c[] = "ghi";
       memcpy(&x, c, sizeof(a)-1);
       testswitch(x);
       return 0; 
    }

    switch для строк!

    Перечитывал несвежие говнокоды, где я выкладывал творчество вконтактоолимпиадников https://govnokod.ru/23170#comment388376

    j123123, 12 Ноября 2019

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

    0

    1. 1
    IT Оффтоп #25

    #1: https://govnokod.ru/18142 https://govnokod.xyz/_18142
    #2: https://govnokod.ru/18378 https://govnokod.xyz/_18378
    #3: https://govnokod.ru/19667 https://govnokod.xyz/_19667
    #4: https://govnokod.ru/21160 https://govnokod.xyz/_21160
    #5: https://govnokod.ru/21772 https://govnokod.xyz/_21772
    #6: https://govnokod.ru/24063 (потёр пидор сракер) https://govnokod.xyz/_24063
    #7: https://govnokod.ru/24538 https://govnokod.xyz/_24538
    #8: https://govnokod.ru/24815 (потёр пидор сракер) https://govnokod.xyz/_24815
    #9: https://govnokod.ru/24867 https://govnokod.xyz/_24867
    #10: https://govnokod.ru/25328 https://govnokod.xyz/_25328
    #11: https://govnokod.xyz/_25436 https://govnokod.ru/25436 (потёр пидор сракер)
    #12: https://govnokod.xyz/_25471
    #13: https://govnokod.xyz/_25590 (потёр пидор сракер)
    #14: https://govnokod.xyz/_25684
    #15: https://govnokod.xyz/_25694
    #16: https://govnokod.xyz/_25725
    #17: https://govnokod.xyz/_25731
    #18: https://govnokod.xyz/_25762
    #19: https://govnokod.xyz/_25767
    #20: https://govnokod.xyz/_25776
    #21: https://govnokod.xyz/_25798
    #22: https://govnokod.xyz/_25811
    #23: http://govnokod.ru/25863 https://govnokod.xyz/_25863
    #24: http://govnokod.ru/25941 https://govnokod.xyz/_25941

    syoma, 12 Ноября 2019

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

    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
    DBconfig.php
    <?
    function sql_connect($mysqlhost,$mysqluser,$mysqlpass,$mysqldb){
             $sql_conn=mysql_connect($mysqlhost,$mysqluser,$mysqlpass) or die("mysql_query error: " .mysql_error());
             mysql_select_db($mysqldb);
             }
    
    function sql_execute($query, $get_counter = false)
    	{
    	static $sqlquerycounter = 0;
    	if(isset($_GET['_dbg']) && isset($_GET['_sql'])){pr('['.$sqlquerycounter.'] '.$query);}
    
    	if(!$get_counter)
    		{
    		 if (!$query = mysql_query($query)) {
    			trigger_error('MySQL Error: '.mysql_error());
    		  }
    		$sqlquerycounter++;
    		return $query;
    		}
    	else {return $sqlquerycounter;}
    	}
    
    function sql_close(){
            mysql_close($sql_conn);
            }
    
    		
    ?>
    
    file.php
    
    sql_connect($_CONFIG["mysqlhost"], $_CONFIG["mysqluser"], $_CONFIG["mysqlpass"], $_CONFIG["mysqldb"]);
    $sql = sql_execute("SET NAMES UTF8");
    
    $sql = sql_execute("SELECT * FROM publications WHERE id='$_GET[id]' LIMIT 0,1");
    $res = mysql_fetch_array($sql);

    phpBidlokoder2, 11 Ноября 2019

    Комментарии (15)
  6. PHP / Говнокод #26024

    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
    <? foreach ($arResult["ITEMS"] as $i => $arItem):
                $this->AddEditAction($arItem['ID'], $arItem['EDIT_LINK'], CIBlock::GetArrayByID($arItem["IBLOCK_ID"], "ELEMENT_EDIT"));
                $this->AddDeleteAction($arItem['ID'], $arItem['DELETE_LINK'], CIBlock::GetArrayByID($arItem["IBLOCK_ID"], "ELEMENT_DELETE"), array("CONFIRM" => GetMessage('CT_BNL_ELEMENT_DELETE_CONFIRM')));
                switch ($i) {
                    case(0):
                        $case = 'bgd1';
                        break;
                    case(1):
                        $case = 'bgd2';
                        break;
                    case(2):
                        $case = 'bgd2';
                        break;
                    case(3):
                        $case = 'bgd3';
                        break;
                    default:
                        $case = 'bgd4';
                        break;
    }
     ?>

    Вот что я кукареку

    phpBidlokoder2, 11 Ноября 2019

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

    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
    <?if($arParams["DISPLAY_PICTURE"]!="N" && is_array($arItem["PREVIEW_PICTURE"])):?>
    	<?if(!$arParams["HIDE_LINK_WHEN_NO_DETAIL"] || ($arItem["DETAIL_TEXT"] && $arResult["USER_HAVE_ACCESS"])):?>
    		<span class="article_image"><img class="preview_picture" src="<?=$arItem["PREVIEW_PICTURE"]["SRC"]?>" alt="<?=$arItem["NAME"]?>" title="<?=$arItem["NAME"]?>"></span>
    	<?else:?>
    		<span class="article_image"><img class="preview_picture" src="<?=$arItem["PREVIEW_PICTURE"]["SRC"]?>" alt="<?=$arItem["NAME"]?>" title="<?=$arItem["NAME"]?>"></span>
    	<?endif;?>
    <?endif?>
    
    ....
    
    <?if($arParams["DISPLAY_NAME"]!="N" && $arItem["NAME"]):?>
    	<?if(!$arParams["HIDE_LINK_WHEN_NO_DETAIL"] || ($arItem["DETAIL_TEXT"] && $arResult["USER_HAVE_ACCESS"])):?>
    		<header><?echo $arItem["NAME"]?></header>
    	<?else:?>
    		<header><?echo $arItem["NAME"]?></header>
    	<?endif;?>
    <?endif;?>

    От создателя if (true) return true elseif (false) return false;

    phpBidlokoder2, 11 Ноября 2019

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

    +4

    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
    // https://godbolt.org/z/PPAWM0
    #include <embed>
    #include <cstdint>
    
    constexpr std::uint64_t val_64_const = 0xcbf29ce484222325u;
    constexpr std::uint64_t prime_64_const = 0x100000001b3u;
    
    inline constexpr std::uint64_t
    hash_64_fnv1a_const(const char* const ptr, std::size_t ptr_size, const std::uint64_t value = val_64_const) noexcept {
    	return (ptr_size == 1) 
    		? value : 
    		hash_64_fnv1a_const(&ptr[1],
    			ptr_size - 1, 
    			(value ^ static_cast<std::uint64_t>(static_cast<char>(*ptr))) * prime_64_const);
    }
    
    int main () {
    	constexpr std::span<const char> art_data  = std::embed("/dev/urandom", 32);
    	constexpr std::uint64_t actual = hash_64_fnv1a_const(art_data.data(), art_data.size());
    
    	return static_cast<int>(actual);
    }

    Очередная дрисня http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p1040r0.html в крестоговне, теперь можно через std::embed прочитать какое-то говно и даже в constexpr с ним что-то делать, например считать хеш-сумму. Можно constexpr-компилятор сделать, который бы читал код через std::embed и через constexpr хуиту его обрабатывал и компилировал. Скажите им еще про миксины из D

    j123123, 10 Ноября 2019

    Комментарии (95)
  9. Haskell / Говнокод #26021

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    module Voretion.Kobenation (
        trySort
      , natalyze
      , toBase64
      , fromBase64
      , dbgKob
      ) where

    https://github.com/k32/zenmaster

    Чей петух, кто знает?

    Konardinho, 10 Ноября 2019

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

    +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
    Дали тестовое задание.
    Написать хеш таблицу с открытой адресацией. Главное качество, а не скорость, сказали.
    Реализовал на C++.
    Самая тягомотина - это тестирование многопоточности.
    Есть операции: 
    find, equalRange, operator [] - тот же equalRange, но возвращает все найденные вхождения, insert, remove, extend, size, capacity.
    
    И вот надо каждую относительно другой проверять.  
    Только это выходит (9 - 1)^2 тестов. Помимо остальных, уже реализованных.
    
    у меня проверка на значения только в операциях поиска относительно вставки, то бишь, нашелся ли в многопоточном исполнении элемент, или нет.
    относительно удаления проверять - это муторно, потому что после удаления на той же позиции встает соседняя пара, и это случайно, проверено 
    экспериментально.
    
    Сойдет ли просто проверять время блокировки (shared_lock, и lock_guard) 
    каждого параллельного текущему потоку относительно времени блокировки\старта\окончания блокировки текущего?
    кроме связки (access - insert)?
    Тем более, что операции записи\чтения проверяются в немногопоточном исполнении?

    OlegUP, 08 Ноября 2019

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