- 1
IT Оффтоп #81Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
IT Оффтоп #81
            #51: https://govnokod.ru/26809 https://govnokod.xyz/_26809
#52: https://govnokod.ru/26817 https://govnokod.xyz/_26817
#53: https://govnokod.ru/26833 https://govnokod.xyz/_26833
#54: https://govnokod.ru/26840 https://govnokod.xyz/_26840
#55: https://govnokod.ru/26844 https://govnokod.xyz/_26844
#56: https://govnokod.ru/26862 https://govnokod.xyz/_26862
#57: https://govnokod.ru/26890 https://govnokod.xyz/_26890
#58: https://govnokod.ru/26916 https://govnokod.xyz/_26916
#59: https://govnokod.ru/26934 https://govnokod.xyz/_26934
#60: https://govnokod.ru/26949 https://govnokod.xyz/_26949
#61: https://govnokod.ru/26980 https://govnokod.xyz/_26980
#62: https://govnokod.ru/26999 https://govnokod.xyz/_26999
#63: https://govnokod.ru/27004 https://govnokod.xyz/_27004
#64: https://govnokod.ru/27020 https://govnokod.xyz/_27020
#65: https://govnokod.ru/27027 https://govnokod.xyz/_27027
#66: https://govnokod.ru/27040 https://govnokod.xyz/_27040
#67: https://govnokod.ru/27049 https://govnokod.xyz/_27049
#68: https://govnokod.ru/27061 https://govnokod.xyz/_27061
#69: https://govnokod.ru/27071 https://govnokod.xyz/_27071
#70: https://govnokod.ru/27097 https://govnokod.xyz/_27097
#71: https://govnokod.ru/27115 https://govnokod.xyz/_27115
#72: https://govnokod.ru/27120 https://govnokod.xyz/_27120
#73: https://govnokod.ru/27136 https://govnokod.xyz/_27136
#74: https://govnokod.ru/27160 https://govnokod.xyz/_27160
#75: https://govnokod.ru/27166 https://govnokod.xyz/_27166
#76: https://govnokod.ru/27168 https://govnokod.xyz/_27168
#77: https://govnokod.ru/27186 https://govnokod.xyz/_27186
#78: https://govnokod.ru/27219 https://govnokod.xyz/_27219
#79: https://govnokod.ru/27254 https://govnokod.xyz/_27254
#80: https://govnokod.ru/27270 https://govnokod.xyz/_27270
        
0
-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.Наметушил.
−1
https://www.kp.ru/online/news/4203427/Ко-ко-кой багор)
0
XRU = "XRU"
PITUH = "PITUH",
KUROCHKA = "KUROCHKA"
PETUH = PITUH.replace('I', 'E')
            Traceback (most recent call last):
  File "./prog.py", line 4, in <module>
AttributeError: 'tuple' object has no attribute 'replace'
        
+2
(set-logic UF)
; https://smtlib.cs.uiowa.edu/logics.shtml
; UF for the extension allowing free sort and function symbols 
(set-option :produce-proofs true)
(declare-sort M_list)
(declare-fun m_node (M_list M_list) M_list)
; один хер какой порядок, можно переписать (a, b) на (b, a)
(assert
  (forall ( (a M_list) (b M_list) )
    (=
      (m_node a b)
      (m_node b a)
    )
  )
)
; если есть (a (b c)) то можно переписать на (с (a b))
(assert
  (forall ( (a M_list) (b M_list) (c M_list) )
    (=
      (m_node a (m_node b c) )
      (m_node c (m_node a b) )
    )
  )
)
; Можно создавать или удалять повторы, (a a) <=> a
(assert
  (forall ( (a M_list))
    (=
      (m_node a a)
      a
    )
  )
)
; Чтоб узнать, выводима ли такая-то хернь
(declare-fun m_node_select (M_list M_list) Bool)
(assert
  (forall ( (a M_list) (b M_list) )
    (m_node_select
      a (m_node a b)
    )
  )
)
; проверяем, можно ли сконструировать (a a) из (c ((b d) a))
(assert
  (not (forall ( (a M_list) (b M_list) (c M_list) (d M_list) )
    (m_node_select
      (m_node a a)
      (m_node c (m_node (m_node b d) a) )
    )
  ))
)
(check-sat)
(get-proof)
            Вот вам немного гомоикон SMT-солвера. Эта вот хренотень сама доказывает, не то что какой-то там Coq.
Понятно что по тем вот говноправилам можно чтоб всплыло 'a' и потом его удвоить "(a a) <=> a"
потом через m_node_select вытащить этот дубликат
        
0
require(ggplot2)
x=-10:10
X = data.frame(x=x, y=x^2, col=ifelse(x > 0, 1, 2))
ggplot(X, aes(x, y)) + geom_point(aes(colour=col))Очевидный и понятный интерфейс, да?
0
var object = {a: 123, b:"abc"};
var newObject = ko.observableProps(object);
newObject.a(345);
newObject.b("def");
newObject.a(); => 345
newObject.b(); => "def"Ко-ко-ко-ко-ко-обсервабле
0
import math
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--type")
parser.add_argument("--principal", type=int)
parser.add_argument("--periods", type=int)
parser.add_argument("--interest", type=float)
parser.add_argument("--payment", type=float)
args = parser.parse_args()
choose = args.type
p = args.principal
n = args.periods
i = args.interest
a = args.payment
if i is None or p is None and a is None:
    print("Incorrect parameters.")
    exit(0)
i = (i * 0.01) / (12 * 1)
if choose == "diff":
    m = 1
    overpayment_all = 0
    while m <= n:
        d = math.ceil(p / n + i * (p - ((p * (m - 1)) / n)))
        m += 1
        overpayment_all += d
        print(f"Month {m - 1}: payment is {d}")
    print()
    print(f"Overpayment = {overpayment_all - p}")
elif choose == "annuity" and a is None:
    a = math.ceil(p * (i * math.pow((1 + i), n)) / (math.pow((1 + i), n) - 1))
    print(f"Your monthly payment = {a}!")
    over = a * n - p
    print(f"Overpayment = {math.ceil(over)}")
elif choose == "annuity" and p is None:
    p = int(a / (i * math.pow(1 + i, n) / (math.pow(1 + i, n) - 1)))
    print(f"Your loan principal = {p}!")
    m = 1
    over = a * n - p
    print(f"Overpayment = {math.ceil(over)}")
elif choose == "annuity":
    n = math.ceil(math.log(a / (a - i * p), 1 + i))
    zxc = math.ceil(math.log(a / (a - i * p), 1 + i))
    years = 0
    while n >= 12:
        n -= 12
        years += 1
    if years == 0:
        print(f"It will take {n} months to repay this loan!")
        over = a * zxc - p
        print(f"Overpayment = {math.ceil(over)}")
    elif n == 0:
        print(f"It will take {years} years to repay this loan!")
        over = a * zxc - p
        print(f"Overpayment = {math.ceil(over)}")
    else:
        print(f"It will take {years} years and {n} months to repay this loan!")
        over = a * zxc - p
        print(f"Overpayment = {math.ceil(over)}")
            Ебучий универ и ебучее задание на питоне. Всё было бы збс, если бы не математика.
Прога считает проценты, бабки, переплаты и чёт ещё, наверное
        
0
var utils = require('util');
module.exports = class Client {
    constructor(Socket) {
        this.Socket = Socket;
        this.TLSSocket = require('tls');
        this.XmlParser = new require('xml2js').Parser();
        this.XmlBuilder = require('xmlbuilder');
        this.Client = this;
        this.Authorized = false;
        this.OnlineId = '1';
        this.Socket.on('data', (Packet) => this.OnData(Packet));
        this.Player = null;
        this.Status = 0;
    }
// Авторизация.
    OnData(Packet) {
        if (Packet[0] == 0xad || Packet[1] == 0xde || Packet[2] == 0xed || Packet[3] == 0xfe) {
            var PacketBuffer = Buffer.alloc(Number(Packet.readBigInt64LE(4)));
            Packet.copy(PacketBuffer, 0, 12);
            var Query = PacketBuffer.toString();
            console.log('[CLIENT] ',Query);
            this.XmlParser.parseString(PacketBuffer.toString(), (err, result) => {
                if (result) 
                {
                    if (result.starttls && !this.TLSSocket.Authorized && !this.Authorized) {
                        this.Send(this.XmlBuilder.create({
                            proceed: {
                                '@xmlns': 'urn:ietf:params:xml:ns:xmpp-tls'
                            }
                        }, {
                                headless: true
                            }).end({
                                pretty: false
                            }));
                        this.TLSSocket = new this.TLSSocket.TLSSocket(this.Socket, {
                            cert: global.Cert,
                            key: global.CertKey,
                            ca: global.CertBundle,
                            minVersion: 'TLSv1',
                            isServer: true
                        })
                        this.TLSSocket.once('secure', () => {
                            this.TLSSocket.Authorized = true;
                            console.log('TLS Connection established!');
                        });
                        this.TLSSocket.on('data', (Packet)=>this.OnData(Packet));
                    }
                    else if (result.iq && result.iq.bind) {
                        this.Send(this.XmlBuilder.create({
                            iq: {
                                '@id': result.iq.$.id,
                                '@type': 'result',
                                bind: {
                                    '@xmlns': 'urn:ietf:params:xml:ns:xmpp-bind',
                                    jid: this.OnlineId
                                }
                            }
                        }, {
                            headless: true
                        }).end({
                            pretty: false
                        }));
                    } else if (result.iq && result.iq.session) {
                        this.Send(this.XmlBuilder.create({
                            iq: {
                                '@id': result.iq.$.id,
                                '@type': 'result',
                                '@to': this.OnlineId,
                                session: {
                                    '@xmlns': 'urn:ietf:params:xml:ns:xmpp-session'
                                }
                            }
                        }, {
                            headless: true
                        }).end({
                            pretty: false
                        }));
                    }
                    else if (result.iq && result.iq.query) {
                        var QueryName = Object.keys(result.iq.query[0]).filter(function (str) {
                            return str != '_' && str != '$'
                        })[0];
                        var QueryFunction = global.PacketFactory[QueryName];
                        if (QueryFunction) {
                            var Stanza = result.iq.query[0][QueryName][0];
                            console.log(`\x1b[32mQueryname: ${QueryName} ${utils.inspect(Stanza.$)}\x1b[0m`);
                            global.PacketFactory[QueryName].handle(this, Stanza, result.iq.$.to, result.iq.$.id);
                        }Nodejs вход пользователя
0
// -------------------------------------------
// 2.2. binary calls
// -------------------------------------------
/*
    combination table:
      +-   | c a n
        ---|-------
         c | C A N
         a | A A N
         n | N N N
      *    | c a n
        ---|-------
         c | C A N
         a | A N N
         n | N N N
      /    | c a n
        ---|-------
         c | C N N
         a | A N N
         n | N N N
    argument:
      c : constant, as scalar, point, tensor, ect
      l : affine homogeneous expr argument: as field, field_indirect or field_expr_node::is_affine_homogeneous
      n : function, functor or ! field_expr_node::is_affine_homogeneous
    result:
      C : constant : this combination is not implemented here
      A,N : are implemented here
    rules:
      at least one of the two args is not of type "c"
      when c: c value is embeded in bind_first or bind_second
              and the operation reduces to an unary one
      when a: if it is a field_convertible, it should be wrapped
              in field_expr_v2_nonlinear_terminal_field
      when c: no wrapper is need
    implementation:
      The a and n cases are grouped, thanks to the wrapper_traits
      and it remains to cases :
        1) both args are  field_expr_v2_nonlinear or a function 
        2) one  arg  is a field_expr_v2_nonlinear or a function and the second argument is a constant
*/
#define _RHEOLEF_make_field_expr_v2_nonlinear_binary(FUNCTION,FUNCTOR)	\
template<class Expr1, class Expr2>						\
inline										\
typename									\
std::enable_if<									\
     details::is_field_expr_v2_nonlinear_arg<Expr1>::value			\
  && details::is_field_expr_v2_nonlinear_arg<Expr2>::value			\
  && ! details::is_field_expr_v2_constant   <Expr1>::value			\
  && ! details::is_field_expr_v2_constant   <Expr2>::value			\
 ,details::field_expr_v2_nonlinear_node_binary<					\
    FUNCTOR									\
   ,typename details::field_expr_v2_nonlinear_terminal_wrapper_traits<Expr1>::type	\
   ,typename details::field_expr_v2_nonlinear_terminal_wrapper_traits<Expr2>::type 	\
  >										\
>::type										\
FUNCTION (const Expr1& expr1, const Expr2& expr2)				\
{										\
  typedef typename details::field_expr_v2_nonlinear_terminal_wrapper_traits<Expr1>::type wrap1_t; \
  typedef typename details::field_expr_v2_nonlinear_terminal_wrapper_traits<Expr2>::type wrap2_t; \
  return details::field_expr_v2_nonlinear_node_binary <FUNCTOR,wrap1_t,wrap2_t> \
	(FUNCTOR(), wrap1_t(expr1), wrap2_t(expr2)); 				\
}										\
template<class Expr1, class Expr2>						\
inline										\
typename 									\
std::enable_if<									\
     details::is_field_expr_v2_constant     <Expr1>::value			\
  && details::is_field_expr_v2_nonlinear_arg<Expr2>::value			\
  && ! details::is_field_expr_v2_constant   <Expr2>::value			\
 ,details::field_expr_v2_nonlinear_node_unary<					\
    details::binder_first<							\
      FUNCTOR									\
     ,typename details::field_promote_first_argument<				\
        Expr1