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

    −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
    (* basic power axiom
    safe_comp_power x y =
        case
            (x = 0) and (y <> 0) -> 1
            (x = 1) -> x
            ((x <> 0) and (y >= 0)) or ((x = 0) and (y > 0)) -> x * (safe_comp_power x (y - 1))
    *)
    
    logic safe_comp_pow : int, int -> int
    
    axiom safe_comp_pow_int_A_1 : forall x : int. (x <> 0) -> safe_comp_pow(x, 0) = 1
    
    axiom safe_comp_pow_int_A_2 : forall x : int. safe_comp_pow(x, 1) = x
    
    axiom safe_comp_pow_int_A_3 : forall x,y : int. ((x <> 0) and (y >= 0)) or ((x = 0) and (y > 0)) -> safe_comp_pow(x, y) = x*(safe_comp_pow(x,y-1))
    
    
    goal g_1 :
      forall a,n : int.
      a <> 0 -> n >= 0 ->
      safe_comp_pow(a,n+1) = safe_comp_pow(a,n)*a

    Язык для SMT солвера alt-ergo https://alt-ergo.ocamlpro.com/try.php . Аксиомы для возведения в степень. Возводить в отрицательную степень нельзя. Ноль в степени ноль - нельзя. Логика первого порядка. Должна быть справедлива для целых. Правда в одной аксиоме я допустил баг. Я его уже нашел. Можете тоже попробовать найти его

    j123123, 22 Марта 2016

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

    +1

    1. 1
    https://habrahabr.ru/company/tm/blog/279759/

    На Швабре можно постить гоатсе.

    Vasiliy, 21 Марта 2016

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

    +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
    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
    {- This code intentionally was made slightly cryptic -}
    {-# LANGUAGE GADTs, StandaloneDeriving, UnicodeSyntax, KindSignatures, FlexibleInstances, LambdaCase, CPP, BangPatterns #-}
    import System.Exit
    import Data.Functor
    import Control.Monad.IO.Class
    import Control.Monad.Trans.Cont
    import System.Random
    import System.Posix.Signals
    import System.Environment
    import Control.Concurrent.MVar
    
    instance Eq (Int → Int) where
      _ == _ = True -- It's a hack
    
    infixl 7 :.
    
    data T ∷ * where {J, Â, Â', S, K ∷ T; (:.) ∷ T → T → T; Ψ ∷ {σ ∷ String} → T
                     ;F ∷ (Int → Int) → T; N ∷ Int → T; Ø ∷ String → T}
    
    parse ∷ String → [T] → T
    parse ('f':'u':c) t = parse c (J:t)
    parse ('b':'a':'r':c) t = parse c (Â:t)
    parse ('~':c) (a:b:t) = parse c (b:.a:t)
    parse ('~':_) _ = error "Parse error: missing operand(s)"
    parse (_:c) t = parse c t
    parse [] (h:_) = h :. Ψ []
    parse [] [] = error "Parse error: empty program"
    
    s ∷ T → T
    s (J :. x) = (x :. S) :. K
    s (K :. x :. _) = x
    s (S :. x :. y :. z) = (x :. z) :. (y :. z)
    s (F f :. N i) = N $ f i
    s (F f :. F g) = F $ f . g
    s (Â' :. N i :. ψ @ (Ψ {})) = ψ {σ = toEnum i : σ ψ}
    s (Â :. n :. ψ @ (Ψ {})) = Â' :. (n :. F (+1) :. N 0) :. ψ
    -- Other cases
    s (a :. b) = (s a) :. (s b)
    s x = x
    
    eval ∷ (T → t) → (T → t) → T → t
    eval fp done t | t == t'   = done t
                   | otherwise = fp t'
        where t' = s t
    
    ψs a@Ψ{σ=s} = [(a, s)]
    ψs (a:.b) = ψs a ++ ψs b
    ψs _ = []
    
    r' ∷ T → [(T, String)]   -- Very inefficient; should be rewritten
    r' a | null t = [(a, s)] where ((_, s):t) = ψs a
    r' (a :. b) = r' a ++ r' b
    r' _ = []
    
    r ∷ T → IO (Maybe T)
    r t = case r' t of
            [] → return Nothing
            t' → ((t' !!) <$> randomRIO (0, length t' - 1)) >>= \case
               (Ψ{}, s) → putStrLn (reverse s) >> return Nothing
               (t'', s) → putStrLn (reverse s) >> return (Just t'')
    
    setMVar v = (tryTakeMVar v >>) . putMVar v
    
    loop v f n = callCC $ \done → loop1 done (\fp → f fp done) n
      where loop2 interrupt f' n = do
              n' ← liftIO (readMVar v) >>= \case
                0 → f' interrupt n
                _ → callCC $ \fp → f' fp n
              liftIO $ modifyMVar_ v $ (\k → return $ k-1)
              loop2 interrupt f' n'
            loop1 done f' n = do
              n' ← callCC $ \int → loop2 int f' n
              liftIO $ putStrLn "Measure (m) Abort (a) Continue (c) Run steps (number)"
              (liftIO getLine) >>= \case
                "a" → f' done n' >> return ()
                "c" → liftIO $ setMVar v (-1)
                "m" → liftIO (r n') >>= \case
                  Nothing → liftIO exitSuccess
                  Just n'' → loop1 done f' n'' >> return ()
                a → case readsPrec 0 a of
                       (n,_):_ → liftIO $ setMVar v n
                       _ → liftIO $ putStrLn "Not understood."
              loop1 done f' n'
    
    main ∷ IO ()
    main = do
      (file, n) ← getArgs >>= \case
        [f] → return (f, -1)
        ["-s", n, f] → case readsPrec 0 n of
                        (n',_):_ → return (f, n')
                        _ → error "Argument of -s should be a number"
        _ → error "Insufficient arguments. Expected [-s NUMBER_OF_STEPS] FILE"
      cnt ← newMVar n
      installHandler keyboardSignal (Catch $ setMVar cnt 0) Nothing
      void $ (r =<<) (evalContT $ loop cnt eval =<< (parse <$> readFile file))

    больше трясин богу тьюринг-полноты
    1) литературное программирование
    2) зайчатки REPL
    3) чисто функциональное IO без манад и uniq-types
    4) "квантовые" вычисления
    5) только два комбинатора

    CHayT, 18 Марта 2016

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

    −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
    FROM centos:7
    
    RUN yum update -y && yum -y install openssh-server ssh
    
    RUN echo 'root:123456' | chpasswd
    RUN passwd -u root
    RUN ssh-keygen -A
    RUN ssh-keygen -t rsa -b 4096 -C "[email protected]" -N "" -f /root/.ssh/id_rsa
    RUN cat /root/.ssh/id_rsa.pub > /root/.ssh/authorized_keys
    RUN chmod 600 /root/.ssh/id_rsa.pub
    ADD ./ssh_config /etc/ssh/ssh_config
    ADD ./sshd_config /etc/ssh/sshd_config
    
    CMD ["/bin/sh", "-c", "{ while :; do /usr/sbin/sshd -eD ; done }"]

    docker build --name trolleybus-is-hleba .

    Вот так вот.

    wvxvw, 16 Марта 2016

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

    +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
    23. 23
    program Project2;
    
    procedure test1;
    var
      arr:array[0..32] of char;
    begin
      fillchar(arr,sizeof(arr),'A');
    end;
    
    procedure test2;
    var
      arr:array[0..32] of char;
    begin
      fillchar(arr,sizeof(arr) div 2,'B');
      writeln(arr);
    end;
    
    begin
      test1;
      test2;
      //BBBBBBBBBBBBBBBBAAAAAAAAAAAAAAA
      readln;
    end.

    http://ideone.com/qJajnb

    fajes_rown, 15 Марта 2016

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

    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
    objNewFile.WriteLine "	if (!table.nodeType) table = document.getElementById(table)"
    objNewFile.WriteLine "	var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}"
    objNewFile.WriteLine "	window.location.href = uri + base64(format(template, ctx))"
    objNewFile.WriteLine "}"
    objNewFile.WriteLine "})()"
    objNewFile.WriteLine "</script>"
    objNewFile.WriteLine "<input type=""button"" onclick=""tableToExcel('table1', 'Export data')"" value=""Export data to Excel"">"
    	
    objNewFile.WriteLine "<table id=""table1"" BORDER=""1"" width=""100%"">" 
    objNewFile.WriteLine "<tr><th width=""2%"">id</th><th>Computer</th><th>AV Name</th><th>AV Status</th><th>AV Bases</th><th>Host Status</th></tr>"
    
    for each comp in comps 
    	compid = compid + 1 
    		
    	Set WshShell = WScript.CreateObject("WScript.Shell")
    	Ping = WshShell.Run("ping -n 1 " & comp, 0, True)
    	Select Case Ping
    	Case 0
    		On Error Resume next 
    		Set oWMI = GetObject("winmgmts:\\" & comp & "\root\SecurityCenter2") 
    		On Error Resume next 
    		Set colAVItems = oWMI.ExecQuery("Select * from AntiVirusProduct") 
    		If colAVItems.count = 0 Then 
    			objNewFile.WriteLine "<tr><th>" & compid & "</th><th>" & comp & "</th><th><font color=""red"">No AntiViruses found</font></th><th><font color=""red"">Disabled</font></th><th><font color=""red"">NOT Up to Date</font></th><th><font color=""green"">Online</font></th></tr>"

    И это висит на главной Волан-де-сайта!

    gost, 12 Марта 2016

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

    +8

    1. 1
    TOO_ENOUGH_DATA

    3_14dar, 06 Марта 2016

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

    +4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    #!/bin/bash
    echo "(find-file \"$1\")" >> ~/.emacs.d/cmdfile
    
    В emacs периодически дергается
    
    (defun read-cmd-file ()
      (load-file "~/.emacs.d/cmdfile")
      (delete-file "~/.emacs.d/cmdfile"))
    
    (run-with-idle-timer 1 t 'read-cmd-file)

    гуру emacs ЛОРа

    CHayT, 03 Марта 2016

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

    −1

    1. 1
    https://drive.google.com/file/d/0B9WcAoQS5ukUZ1NMQkxMdXBSMWM/view?usp=sharing

    Many-To-One PHP edition.

    хуита, 03 Марта 2016

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

    −3

    1. 1
    2. 2
    3. 3
    >ipconfig   | find "IP"
    ═рёЄЁющър яЁюЄюъюыр IP фы  Windows
            IP-рфЁхё  . . . . . . . . . . . . : 192.168.1.60

    ЧЗХ (кодировка)?

    3_14dar, 01 Марта 2016

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