1. Java / Говнокод #26042

    +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
    private Map<Iterable<ItemStack>, Predicate<ItemStack>> getSubInventories(Map<Iterable<ItemStack>, Predicate<ItemStack>> subInventories, EntityPlayer player) {
        InventoryPlayer inv = player.inventory;
        ItemStack heldItem = inv.getCurrentItem();
    
        int wireless = tile.getNetwork().getSetting(NetworkSettings.NETWORK_WIRELESS);
        if((wireless >> 1 & 1) == 1) {
            subInventories.put(Lists.newArrayList(heldItem), NOT_EMPTY);
        }
        if((wireless >> 2 & 1) == 1) {
            subInventories.put(inv.offHandInventory, NOT_EMPTY);
        }
        if((wireless >> 3 & 1) == 1) {
            subInventories.put(inv.mainInventory.subList(0, 9), stack -> !stack.isEmpty() && (heldItem.isEmpty() || heldItem != stack));
        }
        if((wireless >> 4 & 1) == 1) {
            subInventories.put(inv.armorInventory, NOT_EMPTY);
        }
        if((wireless >> 5 & 1) == 1) {
            if(FluxNetworks.proxy.baublesLoaded) {
                if(player.hasCapability(BaublesCapabilities.CAPABILITY_BAUBLES, null)){
                    IItemHandler handler = player.getCapability(BaublesCapabilities.CAPABILITY_BAUBLES, null);
                    subInventories.put(() -> new ItemHandlerIterator(handler), NOT_EMPTY);
                }
            }
        }
    
        return subInventories;
    }

    gost, 24 Ноября 2019

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

    +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
    case Type::Instruction:
            {
              if (o == "movzwl") return OpCode::movzwl;
              if (o == "movzbl") return OpCode::movzbl;
              if (o == "shrb") return OpCode::shrb;
              if (o == "shrl") return OpCode::shrl;
              if (o == "xorl") return OpCode::xorl;
              if (o == "andl") return OpCode::andl;
              if (o == "ret") return OpCode::ret;
              if (o == "movb") return OpCode::movb;
              if (o == "cmpb") return OpCode::cmpb;
              if (o == "movl") return OpCode::movl;
              if (o == "jmp") return OpCode::jmp;
              if (o == "testb") return OpCode::testb;
              if (o == "incl") return OpCode::incl;
              if (o == "sarl") return OpCode::sarl;
              if (o == "decl") return OpCode::decl;
              if (o == "jne") return OpCode::jne;
              if (o == "je") return OpCode::je;
              if (o == "js") return OpCode::js;
              if (o == "subl") return OpCode::subl;
              if (o == "subb") return OpCode::subb;
              if (o == "addl") return OpCode::addl;
              if (o == "addb") return OpCode::addb;
              if (o == "sall") return OpCode::sall;
              if (o == "orl") return OpCode::orl;
              if (o == "andb") return OpCode::andb;
              if (o == "orb") return OpCode::orb;
              if (o == "decb") return OpCode::decb;
              if (o == "incb") return OpCode::incb;
              if (o == "rep") return OpCode::rep;
              if (o == "notb") return OpCode::notb;
              if (o == "negb") return OpCode::negb;
              if (o == "sbbb") return OpCode::sbbb;
              if (o == "pushl") return OpCode::pushl;
              if (o == "retl") return OpCode::retl;
            }

    Фрагмент транслятора из ассемблера в ассемблер.

    https://github.com/lefticus/x86-to-6502

    XYPO3BO3, 24 Ноября 2019

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

    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
    #include <iostream>
    using namespace std;
    
    struct Rooster {
       int id = 0;
    };
    
    
    void asshole(const Rooster* roosters) {
        Rooster* r = (Rooster*)roosters;
        for (int i = 0; i < 3; i++) {
            r[i].id = i + 1;
        }
    }
    
    
    int main() {
    	Rooster roosters[3];
        asshole(roosters);
        for (int i = 0; i < 3; i++) {
            printf("%d\n", roosters[i].id);
        }
    	return 0;
    }

    https://ideone.com/Xk9Ukg

    Нахуй так жить?

    BJlADuMuPCKuu_nemyx, 22 Ноября 2019

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

    0

    1. 1
    do { code = randomCode(); } while (code.contains("FUCK"));

    Пользователь с ником «Чапаев» опубликовал скриншот рекламного SMS-сообщения от
    сбербанка, содержащего код «CRYVKILLJEWS», что можно перевести с английского
    как «плачь, убивай евреев».

    Интересно, а как генерируют все эти случайные коды? Там ведь много чего вылезти может... Например, мне от банка приходят 4-хзначные коды, но я не помню, чтобы пришли, скажем, 4 одинаковые цифры. Не знаю, случайность ли это или алгоритм такой.

    (проверочный код: 8bog)

    Steve_Brown, 22 Ноября 2019

    Комментарии (13)
  5. JavaScript / Говнокод #26038

    0

    1. 1
    Math.round(400/0).toLocaleString('ru-RU')

    seniorfrontenddev, 21 Ноября 2019

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

    +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
    .server-config
      .component
        .title(translate) protsessor
        .value(ng-if="!server.custom")
          | {{ server.cpu || '—' }}
        .value(ng-if="server.custom")
          span(ng-if="server.custom.cpu && server.custom.cpu.length && server.custom.cpu[0].count > 1")
            | {{ server.custom.cpu[0].count + ' x ' }}
          span(ng-if="server.custom.cpu && server.custom.cpu.length")
            | {{ server.custom.cpu[0].name }}
          span(ng-if="!server.custom.cpu || !server.custom.cpu.length")
            | —
    
      .component
        .title(translate) pamyat
        .value(ng-if="!server.custom")
          | {{ server.memory || '—' }}
        .value(ng-if="server.custom")
          span(ng-if="server.custom.ram && server.custom.ram.length")
            span(ng-if="server.custom.ram[0].count > 1")
              | {{ +server.custom.ram[0].name.split(' ')[0].replace('GB', '') * server.custom.ram[0].count + ' GB — ' }}
            span(ng-if="server.custom.ram[0].count > 1")
              | {{ server.custom.ram[0].count + ' x ' }}
            span
              | {{ server.custom.ram[0].name }}
          span(ng-if="!server.custom.ram || !server.custom.ram.length")
            | —
    
      .component
        .title(translate) disk
        .value(ng-if="!server.custom")
          | {{ server.hdd || '—' }}
        .value(ng-if="server.custom.disk && server.custom.disk.length")
          .line(ng-repeat="hdd in server.custom.disk")
            span(ng-if="hdd.count > 1") {{ hdd.count + ' x ' }}
            span {{ hdd.name }}
        .value(ng-if="server.custom && (!server.custom.disk || !server.custom.disk.length)")
          | —
    
      .component(ng-if="server.custom")
        .title(translate) Platform
        .value(ng-if="server.custom.case && server.custom.case.length")
          | {{ server.custom.case[0].name }}
        .value(ng-if="server.custom && (!server.custom.case || !server.custom.case.length)")
          | —
    
      .component(ng-if="server.custom")
        .title(translate) Motherboard
        .value(ng-if="server.custom.motherboard && server.custom.motherboard.length")
          | {{ server.custom.motherboard[0].name }}
        .value(ng-if="server.custom && (!server.custom.motherboard || !server.custom.motherboard.length)")
          | —
    
      .component(ng-if="server.custom.pcie && server.custom.pcie.length")
        .title(translate) pcie
        .value
          .line(ng-repeat="pcie in server.custom.pcie")
            span(ng-if="pcie.count > 1") {{ pcie.count + ' x ' }}
            span {{ pcie.name }}

    Код написан на Pug, представляет из себя фрагмент шаблона AngularJS, предназначенный для отображения конфигурации сервера. Данный код, через копирование-вставку, был заботливо размещен в нескольких файлах, иногда претерпевая незначительные изменения. Здесь публикую отчищенный от всего лишнего и сильно отформатированный вариант, дабы проще было насладиться полетом фантазии автора, в исходном виде весь этот код - одно сплошное месиво.

    maksim_ovcharik, 21 Ноября 2019

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

    +1

    1. 1
    if (tableOfVariables[i].Name == "replace".ToUpper())

    )))00

    neonmystery, 19 Ноября 2019

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

    +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
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    public class AdvancedBoolean {
        private boolean result;
        private DefenitionDictionary.RESULT_CODE code;
        
        
        
    //------------------------------------------------------------------------------  
    //constructors
    //------------------------------------------------------------------------------       
        public AdvancedBoolean() {
            result = true;
        }
            
        public AdvancedBoolean(boolean _result) {
            result = _result;
        }
     
         
        public AdvancedBoolean(boolean _result, DefenitionDictionary.RESULT_CODE _code) {
            result = _result;
            code = _code;
        }
    
        
        
    //------------------------------------------------------------------------------
    //get methods
    //------------------------------------------------------------------------------     
        public boolean isResult() {
            return result;
        }
    
        public DefenitionDictionary.RESULT_CODE getCode() {
            return code;
        }
    
    
            
    //------------------------------------------------------------------------------
    //set methods
    //------------------------------------------------------------------------------ 
        public void setResult(boolean _result) {
            result = _result;
        }
        
        public void setCode(DefenitionDictionary.RESULT_CODE _code) {
            code = _code;
        }
        
        
        
    //------------------------------------------------------------------------------
    //other methods
    //------------------------------------------------------------------------------     
        public String getLabel() {
            return code.getResultLabel();
        }
    }

    Без комментариев

    Veers, 19 Ноября 2019

    Комментарии (9)
  9. Си / Говнокод #26034

    +2

    1. 1
    2. 2
    Comparing structs with, let's say, memcmp, does not work,
     as you end up comparing the "unspecified" padding bytes as well — you must compare member-by-member.

    While writing this post, the author observed that some verions of GCC (experimentally, >= 4.7, < 8.0) do not zero padding if an empty intializer list is passed, under certain a certain code pattern; if an entire struct (i.e. sizeof(STRUCTNAME)) is subsequently memcpy'd after assigment of its members, and this intermediate buffer is what is used by the code going forward. This appears to be based on how optimization passes interact with GCC's built-in memcpy, since passing -fno-builtin-memcpy returns the behavior to the expected.
    https://www.nccgroup.trust/us/about-us/newsroom-and-events/blog/2019/october/padding-the-struct-how-a-compiler-optimization-can-disclose-stack-memory/

    3.14159265, 18 Ноября 2019

    Комментарии (179)
  10. Assembler / Говнокод #26033

    −1

    1. 1
    2. 2
    Перекат
    http://govnokod.ru/18591

    Этот петух так и не выложил ответ.

    OCETuHCKuu_nemyx, 18 Ноября 2019

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