1. Список говнокодов пользователя CHayT

    Всего: 86

  2. Куча / Говнокод #27293

    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
    start_link(Shard, Subscriber) ->
        gen_server:start_link(?MODULE, {server, Shard, Subscriber}, []).
    
    start_link_client(Shard, RemoteNode, Parent) ->
        gen_server:start_link(?MODULE, {client, Shard, RemoteNode, Parent}, []).
    
    
    init({server, Shard, Subscriber}) ->
        {ok, #server{ shard      = Shard
                    , subscriber = Subscriber
                    }};
    init({client, Shard, RemoteNode, Parent}) ->
        {ok, #client{ parent     = Parent
                    , shard      = Shard
                    }}.

    CHayT, 12 Марта 2021

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

    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
    -define(snk_int_match_arg(ARG),
            fun(__SnkArg) ->
                case __SnkArg of
                  ARG -> true;
                  _   -> false
                end
            end).
    
    -define(snk_int_match_arg2(M1, M2, GUARD),
            fun(__SnkArg1, __SnkArg2) ->
                case __SnkArg1 of
                  M1 ->
                    case __SnkArg2 of
                      M2 -> (GUARD);
                      _  -> false
                    end;
                  _ -> false
                end
            end).
    
    
    ....
    
    -spec maybe_delay(map()) -> ok.
    maybe_delay(Event) ->
      [{_, Delays}] = ets:lookup(?DELAY_TAB, ?SINGLETON_KEY),
      [snabbkaffe_collector:block_until( fun(WU) -> ContP(Event, WU) end
                                       , infinity
                                       , infinity
                                       )
       || #delay{ continue_predicate = ContP
                , delay_predicate    = DelayP
                } <- Delays, DelayP(Event)],
      ok.

    Наметушил.

    CHayT, 02 Марта 2021

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

    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
    Fixpoint mint_add0 {N} (i k : Fin.t N) te_i te' t0 vec
                 (Ht : MInt nonCommRel N k vec (te' :: t0))
                 (Hik : k < i)
                 (Hcomm0 : trace_elems_commute te_i te')
                 {struct Ht} :
          exists t' : list TE,
              MInt nonCommRel N k (vec_append i te_i vec) (te' :: t') /\
              Permutation trace_elems_commute (te_i :: te' :: t0) (te' :: t').
        Proof with eauto.
          (* Welcome to the hell proof! *)
          remember (te' :: t0) as t_.
          destruct Ht as [k
                         |k j vec te_k t Hij Ht
                         |k j vec te_k te_j t Hij Hcomm Ht
                         ];
            [discriminate
            |replace te' with te_k in * by congruence; clear Heqt_..
            ].
          2:{ destruct (trace_elems_commute_dec te_i te_j).
              - apply mint_add0 with (te_i := te_i) (i := i) in Ht; [|lia|assumption].
                destruct Ht as [t' [Ht' Hperm']].
                exists (te_j :: t'). split.
                + swap_vec_append.
                  eapply mint_cons2...
                + apply permut_cons with (a := te_k) in Hperm'.
                  eapply permut_trans...
                  now apply permut_head'.
              - exists (te_i :: te_j :: t). split.
                + swap_vec_append.
                  apply mint_cons1 with (j0 := i); [lia|].
                  apply mint_cons2 with (j0 := j); [lia|auto..].
                + now apply permut_head'.
          }
          { inversion_ Ht.
            - exists [te_i]. split.
              + swap_vec_append.
                apply mint_cons1 with (j0 := i); [lia|].
                apply mint_cons1 with (j0 := i); [lia|].
                constructor.
              + now apply permut_head'.
            - rename te into te_j.
              destruct (PeanoNat.Nat.lt_ge_cases j i).
              2:{ exists (te_i :: te_j :: t1). split.
                  - swap_vec_append.
                    apply mint_cons1 with (j1 := i); [lia|].
                    apply mint_cons1 with (j1 := j); [lia|assumption].
                  - now apply permut_head'.
              }
              { destruct (trace_elems_commute_dec te_i te_j) as [Hte_ij|Hte_ij].
                - apply mint_add0 with (i := i) (te_i := te_i) in Ht; [|lia|assumption].
                  destruct Ht as [t' [Ht' Hperm']].
                  exists (te_j :: t'). split.
                  + swap_vec_append.
                    eapply mint_cons1...
                  + apply permut_cons with (a := te_k) in Hperm'.
                    now apply permut_head.
                - exists (te_i :: te_j :: t1). split.
                  + swap_vec_append.
                    apply mint_cons1 with (j1 := i); [lia|].
                    apply mint_cons2 with (j1 := j); [lia|assumption..].
                  + apply permut_head; [assumption|constructor].
              }
            - rename j0 into i0. cbn in H0.
              destruct (PeanoNat.Nat.lt_ge_cases j i).
              2:{ exists (te_i :: te_i0 :: te_j :: t1). split.
                  + swap_vec_append.
                    apply mint_cons1 with (j0 := i); [lia|].
                    apply mint_cons1 with (j0 := j); [lia|assumption].
                  + now apply permut_head'.
              }
              { destruct (trace_elems_commute_dec te_i te_i0).
                - apply mint_add0 with (i := i) (te_i := te_i) in Ht; [|lia|assumption].
                  destruct Ht as [t' [Ht' Hperm']].
                  exists (te_i0 :: t'). split.
                  + swap_vec_append.
                    eapply mint_cons1...
                  + apply permut_cons with (a := te_k) in Hperm'.
                    now apply permut_head.
                - exists (te_i :: te_i0 :: te_j :: t1). split.
                  + swap_vec_append.
                    apply mint_cons1 with (j0 := i); [lia|].
                    apply mint_cons2 with (j0 := j); [lia|assumption..].
                  + apply permut_head.
                    * assumption.
                    * constructor.
              }
          }
        Qed.

    Мой magnum opus. Часть доказательства про выкидывание из рассмотрения коммутирующих системных вызовов.

    CHayT, 17 Ноября 2020

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

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    Lemma mint_head_eq CR1 CR2 (te : TE) l m r (t t' : list TE) :
        MInt CR1 (l, m, r) (te :: t) ->
        MInt CR2 (l, m, r) t' ->
        exists t'', t' = te :: t''.
      Proof.
        intros H1 H2.
        inversion_ H1; inversion_ H2; (* generates 25 goals *)
        match goal with
          |- (exists _, te :: ?T = te :: _) => now exists T
        end.
      Qed.

    Против метушни нет приёма.

    CHayT, 14 Октября 2020

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

    +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
    Definition read_t key cont : Thread :=
          call tx_context <- get_tx_context;
          call cell <- get_cell key tx_context;
          match cell.(cell_write) with
          | Some v =>
              do _ <- log (read key v);
              cont v
          | None =>
              do v <- read_d key;
              let tx_context' := set tx_cells <[key := cell]> tx_context in
              do _ <- pd_set tx_context';
              do _ <- log (read key v);
              cont v
          end.

    Continuations are like violence, if they don't work then you're not using enough of them.

    CHayT, 16 Сентября 2020

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    Definition idx_compl_r {i : Fin.t N} (j : Fin.t i) : Fin.t N.
          remember (fin_to_nat i) as i'.
          assert (Hlt : i' < N).
          { rewrite Heqi'. eapply fin_to_nat_lt. }
          assert (Heq : i' + (N - i') = N) by lia.
          set (j' := Fin.L (N - i') j).
          rewrite Heq in j'.
          exact j'.
        Defined.

    Ещё один говношедевр. Как кастовать значения типа Fin.t (число в интервале от 1 до N) друг в друга. Разворачивается в 12000 строк кода. "Тому, кто это придумал, надо в голову гвоздь забить".

    CHayT, 27 Августа 2020

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

    +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
    Definition uilv_add_trivial {N} te (t : list TE) (traces : Traces N)
                 i j (Ht : MInt_ trace_elems_don't_commute j true traces t)
                 s s' (Hls : LongStep s (te :: t) s')
                 (Htriv : trivial_add i j traces) :
        MInt_ trace_elems_don't_commute i true (push_te traces i te) (te :: t).
      Proof with autorewrite with vector; eauto with vector; try vec_forall_eq_contradiction.
        unfold push_te.
        unfold trivial_add in Htriv.
        destruct (Fin.eq_dec i j) as [Hij|Hij].
        (* [i=j], solving by constructor: *)
        { subst.
          unfold trivial_add.
          eapply mint_keep with (rest := traces[@j])...
        }
        remember traces[@j] as t2_.
        destruct t2_ as [|te2 t2]; subst.
        { inversion Ht as [vec Hvec|? ? ? ? ? Hj Hcont|? ? ? ? ? ? Hjj0 Hswitch Hj Hcont];
            subst.
          - eapply mint_keep with (prog := true)...
            eapply mint_nil...
          - rewrite Hj in Heqt2_.
            discriminate.
        }
        remember traces[@i] as t1_.
        destruct t1_ as [|te1 t1]; subst.
        (* [te] is the last element in i-th trace: *)
        { eapply mint_keep with (rest := []) (prog := false)...
          inversion Ht as [vec Hvec|? ? ? ? ? Hj Hcont|? ? ? ? ? ? Hjj0 Hswitch Hj Hcont];
            subst...
          rewrite Heqt1_ in *.
          eapply mint_switch...
          rewrite <-Heqt1_...
        }
        destruct Htriv as [|[Hij' Hcomm]]; [contradiction Hij|idtac].
        eapply mint_keep with (rest := te1 :: t1) (prog := false)...
        rewrite Heqt1_, Vec.replace_id.
        inversion Ht as [vec Hvec|? ? ? ? ? Hj Hcont|? ? ? ? ? ? Hjj0 Hswitch Hj Hcont]; subst...
        replace te0 with te2 in * by congruence.
        eapply mint_switch...
        rewrite <-Heqt1_...
      Defined.

    Кто сказал, что хуже C++ темплейтов ничего уже нет? Вы ничего не понимаете в метушне. Это говно разворачивается в 12000 строк, например.

    CHayT, 20 Августа 2020

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

    +3

    1. 1
    Infinity = 1 bsl 64,

    Не говнокод, но просто смешно

    CHayT, 07 Июня 2019

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

    0

    1. 1
    2. 2
    3. 3
    We could replace the nonce with a deterministic value, but it's not entirely clear what the cryptographic implications are. At the very least, it allows attackers to obverse that a secret has changed, or that it has changed back to a previously observed value.
    
    https://github.com/edolstra/rfcs/blob/nix-encryption/rfcs/0005-nix-encryption.md

    Продолжаем наблюдения

    CHayT, 04 Июня 2019

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

    0

    1. 1
    Onetime = ?config(onetime, Config) =:= true,

    Boolshit? Нет, это динамическая питуизация.

    CHayT, 24 Апреля 2019

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