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

    +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
    (** Set of all possible interleaving of two traces is a trace
      ensemble. As we later prove in [interleaving_to_permutation], this
      definition is dual to [Permutation]. *)
      Inductive Interleaving : list TE -> list TE -> TraceEnsemble :=
      | ilv_cons_l : forall te t1 t2 t,
          Interleaving t1 t2 t ->
          Interleaving (te :: t1) t2 (te :: t)
      | ilv_cons_r : forall te t1 t2 t,
          Interleaving t1 t2 t ->
          Interleaving t1 (te :: t2) (te :: t)
      | ilv_nil : Interleaving [] [] [].
    
    Попытка оптимизации:
    
      (* Left-biased version of [Interleaving] that doesn't make
      distinction between schedulings of commuting elements: *)
      Inductive UniqueInterleaving : list TE -> list TE -> TraceEnsemble :=
      | uilv_cons_l : forall l t1 t2 t,
          UniqueInterleaving t1 t2 t ->
          UniqueInterleaving (l :: t1) t2 (l :: t)
      | uilv_cons_r1 : forall l r t1 t2 t,
          ~trace_elems_commute l r ->
          UniqueInterleaving (l :: t1) t2 (l :: t) ->
          UniqueInterleaving (l :: t1) (r :: t2) (r :: l :: t)
      | uilv_cons_r2 : forall r1 r2 t1 t2 t,
          UniqueInterleaving t1 (r1 :: t2) (r1 :: t) ->
          UniqueInterleaving t1 (r2 :: r1 :: t2) (r2 :: r1 :: t)
      | uilv_nil : forall t, UniqueInterleaving [] t t.

    Сложный говнокод. Почему вторая "оптимизированная" версия работает хуже первой?

    CHayT, 01 Ноября 2021

    Комментарии (26)
  2. Куча / Говнокод #27779

    0

    1. 1
    2. 2
    Be gone, malicious spirit from the anus!
    We don't say "amen", because we may step on the mines; we say "True"!

    Херня рулит.

    nPOnOBeDHuK, 01 Ноября 2021

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

    0

    1. 1
    https://twitter.com/RCS/status/1452367702727831565

    Ай, Молодца !!!

    gne4do, 31 Октября 2021

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    Щас продукты перетекают в сервисы, разработка ПО делится на фронт и бэк, всякие аджайлоскрамы со спринтами, 
    ретро и бэклог-ревью, автотесты, проверить работает ли код можно на лету. 
    
    А как выглядела работа у разработчиков ПО в начале 10-х, 00-х, 90-х? 
    Как контролировали выполнение задач? 
    Насколько часто переключались на проверку работоспособности кода?
    Как тестили приложения с GUI (десктоп, игры всякие)? 
    Какие задачи давали на техническом интервью кандидатам?

    JaneBurt, 27 Октября 2021

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

    0

    1. 1
    Давайте флудить и троллить ;-)

    Давайте флудить и троллить ;-)

    bot_batbot_batbot, 27 Октября 2021

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

    −1

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

    #101: https://govnokod.ru/27511 https://govnokod.xyz/_27511
    #102: https://govnokod.ru/27518 https://govnokod.xyz/_27518
    #103: https://govnokod.ru/27526 https://govnokod.xyz/_27526
    #104: https://govnokod.ru/27534 https://govnokod.xyz/_27534
    #105: https://govnokod.ru/27544 https://govnokod.xyz/_27544
    #106: https://govnokod.ru/27552 https://govnokod.xyz/_27552
    #107: https://govnokod.ru/27554 https://govnokod.xyz/_27554
    #108: https://govnokod.ru/27557 https://govnokod.xyz/_27557
    #109: https://govnokod.ru/27581 https://govnokod.xyz/_27581
    #110: https://govnokod.ru/27610 https://govnokod.xyz/_27610
    #111: https://govnokod.ru/27644 https://govnokod.xyz/_27644
    #112: https://govnokod.ru/27648 https://govnokod.xyz/_27648
    #113: https://govnokod.ru/27652 https://govnokod.xyz/_27652
    #114: https://govnokod.ru/27659 https://govnokod.xyz/_27659
    #115: https://govnokod.ru/27665 https://govnokod.xyz/_27665
    #116: https://govnokod.ru/27671 https://govnokod.xyz/_27671
    #117: https://govnokod.ru/27675 https://govnokod.xyz/_27675
    #118: https://govnokod.ru/27685 https://govnokod.xyz/_27685
    #119: https://govnokod.ru/27701 https://govnokod.xyz/_27701
    #120: https://govnokod.ru/27703 https://govnokod.xyz/_27703
    #121: https://govnokod.ru/27710 https://govnokod.xyz/_27710
    #122: https://govnokod.ru/27728 https://govnokod.xyz/_27728
    #123: https://govnokod.ru/27729 https://govnokod.xyz/_27729
    #124: https://govnokod.ru/27730 https://govnokod.xyz/_27730
    #125: https://govnokod.ru/27732 https://govnokod.xyz/_27732
    #126: https://govnokod.ru/27733 https://govnokod.xyz/_27733
    #127: https://govnokod.ru/27737 https://govnokod.xyz/_27737
    #128: https://govnokod.ru/27742 https://govnokod.xyz/_27742
    #129: https://govnokod.ru/27747 https://govnokod.xyz/_27747
    #130: https://govnokod.ru/27755 https://govnokod.xyz/_27755

    nepeKamHblu_nemyx, 23 Октября 2021

    Комментарии (701)
  7. Куча / Говнокод #27765

    +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
    waiting_for_data(info, {Driver,Socket,Data},
                     #state{socket=Socket, driver=Driver, driver_mod=DriverMod, peer=Peer, control=Control, list=List} = State) ->
        %% The meat of the whole project: process a function call and return
        %% the data
        try erlang:binary_to_term(Data) of
            {{CallType,M,F,A}, Caller} when CallType =:= call; CallType =:= async_call ->
                {ModVsnAllowed, RealM} = check_module_version_compat(M),
                case check_if_module_allowed(RealM, Control, List) of
                    true ->
                        case ModVsnAllowed of
                            true ->
                                WorkerPid = erlang:spawn(?MODULE, call_worker, [CallType, RealM, F, A, Caller, Socket, Driver, DriverMod]),
                                ?log(debug, "event=call_received driver=~s socket=\"~s\" peer=\"~s\" caller=\"~p\" worker_pid=\"~p\"",
                                     [Driver, gen_rpc_helper:socket_to_string(Socket), gen_rpc_helper:peer_to_string(Peer), Caller, WorkerPid]),
                                {keep_state_and_data, gen_rpc_helper:get_inactivity_timeout(?MODULE)};
                            false ->
                                ?log(debug, "event=incompatible_module_version driver=~s socket=\"~s\" method=~s module=~s",
                                     [Driver, gen_rpc_helper:socket_to_string(Socket), CallType, RealM]),
                                waiting_for_data(info, {CallType, Caller, {badrpc,incompatible}}, State)
                        end;
                    false ->
                        ?log(debug, "event=request_not_allowed driver=~s socket=\"~s\" control=~s method=~s module=~s",
                             [Driver, gen_rpc_helper:socket_to_string(Socket), Control, CallType, RealM]),
                        waiting_for_data(info, {CallType, Caller, {badrpc,unauthorized}}, State)
                end;
            {cast, _M, _F, _A} = Cast ->
                handle_cast(Cast, State),
                {keep_state_and_data, gen_rpc_helper:get_inactivity_timeout(?MODULE)};
            BatchCast when is_list(BatchCast) ->
                [handle_cast(Cast, State) || Cast <- BatchCast],
                {keep_state_and_data, gen_rpc_helper:get_inactivity_timeout(?MODULE)};
            {abcast, Name, Msg} ->
                _Result = case check_if_module_allowed(erlang, Control, List) of
                    true ->
                        ?log(debug, "event=abcast_received driver=~s socket=\"~s\" peer=\"~s\" process=~s message=\"~p\"",
                             [Driver, gen_rpc_helper:socket_to_string(Socket), gen_rpc_helper:peer_to_string(Peer), Name, Msg]),
                        Msg = erlang:send(Name, Msg);
                    false ->
                        ?log(debug, "event=request_not_allowed driver=~s socket=\"~s\" control=~s method=~s",
                             [Driver, gen_rpc_helper:socket_to_string(Socket), Control, abcast])
                    end,
                {keep_state_and_data, gen_rpc_helper:get_inactivity_timeout(?MODULE)};
            {sbcast, Name, Msg, Caller} ->
                Reply = case check_if_module_allowed(erlang, Control, List) of
                    true ->
                        ?log(debug, "event=sbcast_received driver=~s socket=\"~s\" peer=\"~s\" process=~s message=\"~p\"",
                             [Driver, gen_rpc_helper:socket_to_string(Socket), gen_rpc_helper:peer_to_string(Peer), Name, Msg]),
                        case erlang:whereis(Name) of
                            undefined -> error;
                            Pid -> Msg = erlang:send(Pid, Msg), success
                        end;
                    false ->
                        ?log(debug, "event=request_not_allowed driver=~s socket=\"~s\" control=~s method=~s",
                             [Driver, gen_rpc_helper:socket_to_string(Socket), Control, sbcast]),
                         error
                end,
                waiting_for_data(info, {sbcast, Caller, Reply}, State);
            ping ->
                ?log(debug, "event=ping_received driver=~s socket=\"~s\" peer=\"~s\" action=ignore",
                     [Driver, gen_rpc_helper:socket_to_string(Socket), gen_rpc_helper:peer_to_string(Peer)]),
                {keep_state_and_data, gen_rpc_helper:get_inactivity_timeout(?MODULE)};
            OtherData ->
                ?log(debug, "event=erroneous_data_received driver=~s socket=\"~s\" peer=\"~s\" data=\"~p\"",
                     [Driver, gen_rpc_helper:socket_to_string(Socket), gen_rpc_helper:peer_to_string(Peer), OtherData]),
                {stop, {badrpc,erroneous_data}, State}
        catch
            error:badarg ->
                {stop, {badtcp,corrupt_data}, State}
        end;
    
    %% Handle the inactivity timeout gracefully
    waiting_for_data(timeout, _Undefined, #state{socket=Socket, driver=Driver} = State) ->
        ?log(info, "message=timeout event=server_inactivity_timeout driver=~s socket=\"~s\" action=stopping",
             [Driver, gen_rpc_helper:socket_to_string(Socket)]),
        {stop, normal, State};
    
    waiting_for_data(info, {DriverClosed, Socket} = Msg, #state{socket=Socket, driver_closed=DriverClosed} = State) ->
        handle_event(info, Msg, waiting_for_data, State);
    
    waiting_for_data(info, {DriverError, Socket, _Reason} = Msg, #state{socket=Socket, driver_error=DriverError} = State) ->
        handle_event(info, Msg, waiting_for_data, State).

    Срочно требуется учитель литературы, чтобы объяснить, что хотел сказать автор.

    CHayT, 22 Октября 2021

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    make_process_name("client", {Node,Key}) when is_atom(Node) ->
        %% This function is going to be called enough to warrant a less pretty
        %% process name in order to avoid calling costly functions
        KeyStr = erlang:integer_to_list(erlang:phash2(Key)),
        NodeStr = erlang:atom_to_list(Node),
        erlang:list_to_atom("gen_rpc.client." ++ NodeStr ++ "/" ++ KeyStr);

    Самый страшный грех, который только возможен в Erlang.

    CHayT, 22 Октября 2021

    Комментарии (10)
  9. Куча / Говнокод #27759

    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
    Let's count a number of rules that can be built in GoL-like automatas. Rule is the matrix that maps some condition of cells to new state.
    Cell itself could be alive or dead. And cell could have 0-8 neighbors. So, there are 2^(2*9) = 262144 different rules. Well known, that
    the majority of them are primitive and produces some pure pattern or just dies in finite number of generations / infinitely fills the world
    with alive cells. We also know that some rules are symmetric to each other as if we just rename (swap colors of) alive and dead cells.
    
    Conway found the most interesting rule from entropy point of view.
    
    2^18 is not so much. Let's take a look at 2D automata known as Rule 110. State 100 keeps cell dead:
    
    100 -> 0
    
    While state 001 makes cell alive:
    
    001 -> 1
    
    In terms of neighborhood, this two rules are indifferent: both means one live neighbor next to dead cell. But in Rule 110 not only a /number/
    of neighbors is meaningful, but the /position/ of separate neighbor.
    
    Let's imagine the GoL-like rule with the same property: we will look not only at number of neighbors, but at their position. What if to have one
    neighbor at north-west gives not the same result as if neighbor were at south-east.
    
    This change gives us much more different rules. If each neighbor is meaningful, then we have 2 ^ 8 different states of neighborhood, and cell
    could be still alive or dead. If I'm not wrong there must be 2 ^ (2 * (2 ^ 8)) = 2 ^ 512 different rules.
    
    Obviously, this space includes Conway's Game of Life and all different rules from that 262144, and gives billions of new ones. Obviously,
    the majority of them are trivial too. But there may be some interesting entropy-like rules different from the Conway's one.
    
    This space is too huge to be discovered manually, and even with bruteforce algorithms too. But evolution algorithms could be used to find rules
    with some special properties.
    
    So, I have two questions:
    
    1) Does this space has a given name, anybody researched that?
    
    2) I will be glad to hear any ideas on how to make this space simpler by excluding symmetric states etc. to save the time for discovering.

    Any cellular nerds here?

    vistefan, 20 Октября 2021

    Комментарии (15)
  10. Куча / Говнокод #27746

    0

    1. 1
    Время вечерней молитвы.

    Примите положение А1. Постарайтесь сосредоточиться, соберитесь с мыслями. Прочтите молитву.
    Инициализируйте процедуру-коллбек.

    nPOnOBeDHuK, 15 Октября 2021

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