问:
How to insert a Collection into Solr with Spring Data Solr
I want to insert Collections into solr with Spring Data Solr but I am unable to do so.

Following is my CustomerSolr Class which I want to insert in Solr

```<code>    @Id
    @Indexed(name = "id", type = "int")
    private Integer id;

    @Indexed("profile")
    private Map<String, ?> profile;

    @Indexed("phone_*")
    private Map<String, ?> phone;

    @Indexed(name = "addresses")
    private ArrayList addresses;

    @Indexed("orders")
    private Map<String, ?> orders;

    @Indexed(name = "customs")
    private ArrayList customs;

//Getters and Setters
</code>```

My CustomerDTO Class is:

```<code>private Map<String, ?> profile;
private Map<String, ?> phone;
private ArrayList<?> addresses;
private Map<String, ?> orders;
private ArrayList<?> customs;

// Getters and Setters
</code>```

Finally my Data is:

```<code>{
   "profile":{
      "salutation":"Mr",
      "title":null,
      "company":null,
      "job_title":null,
      "first_name":"Veronica",
      "last_name":"Costello",
      "name_suffix":"NONE",
      "gender":"Female",
      "birthday":"1973-12-15",
      "email":"roni_cost@example.com",
      "next_birthday":"2022-12-15",
      "second_name":null
   },
   "phone":{
      "home_phone":"123-321-21",
      "business_phone":null,
      "mobile_phone":null,
      "fax_number":null
   },
   "addresses":[
      {
         "address_id":"1",
         "title":"",
         "company":null,
         "salutation":null,
         "first_name":"Veronica",
         "last_name":"Costello",
         "second_name":null,
         "suffix":"NONE",
         "address_1":"6146 Honey Bluff Parkway",
         "address_2":"",
         "suite_no":"",
         "postal_box":"",
         "city":"Calder",
         "postal_code":"49628-7978",
         "country":"US",
         "state":"Michigan",
         "contact_phone":"(555) 229-3326"
      }
   ],
   "orders":{
      "placed_orders_count":2,
      "0":{
         "order_id":"000000001",
         "order_date":"2019-03-27 14:25:03"
      },
      "1":{
         "order_id":"000000002",
         "order_date":"2019-03-27 14:25:03"
      }
   },
   "customs":[
      {
         "custom": "custom"
      }
   ]
}
</code>```

I have tried:

```<code>CustomerFeedSolr customerFeedsolr = mapper.map(customerDTO, CustomerFeedSolr.class);
String customerFeedJson = new Gson().toJson(customerFeedsolr);
String solrUrl = solrServerUrl.concat(customerFeedPrefix).concat(Constants.HYPHEN).concat(String.valueOf(siteID))
                        .concat(Constants.SOLR_URL_QUERIES);
                HttpEntity<String> requestEntity = new HttpEntity<String>(Arrays.asList(customerFeedJson).toString());
                restTemplate.exchange(solrUrl, HttpMethod.POST, requestEntity, String.class);
</code>```

But I am not getting any data on Solr except for some random id like: "id":"33eaf02e-7fac-4e5e-9e2f-67994792b55c"

Also there is no error on the console

Body:
I want to insert Collections into solr with Spring Data Solr but I am unable to do so.

Following is my CustomerSolr Class which I want to insert in Solr

    @Id
    @Indexed(name = "id", type = "int")
    private Integer id;

    @Indexed("profile")
    private Map<String, ?> profile;

    @Indexed("phone_*")
    private Map<String, ?> phone;

    @Indexed(name = "addresses")
    private ArrayList addresses;

    @Indexed("orders")
    private Map<String, ?> orders;

    @Indexed(name = "customs")
    private ArrayList customs;

//Getters and Setters

My CustomerDTO Class is:

private Map<String, ?> profile;
private Map<String, ?> phone;
private ArrayList<?> addresses;
private Map<String, ?> orders;
private ArrayList<?> customs;

// Getters and Setters

Finally my Data is:

{
   "profile":{
      "salutation":"Mr",
      "title":null,
      "company":null,
      "job_title":null,
      "first_name":"Veronica",
      "last_name":"Costello",
      "name_suffix":"NONE",
      "gender":"Female",
      "birthday":"1973-12-15",
      "email":"roni_cost@example.com",
      "next_birthday":"2022-12-15",
      "second_name":null
   },
   "phone":{
      "home_phone":"123-321-21",
      "business_phone":null,
      "mobile_phone":null,
      "fax_number":null
   },
   "addresses":[
      {
         "address_id":"1",
         "title":"",
         "company":null,
         "salutation":null,
         "first_name":"Veronica",
         "last_name":"Costello",
         "second_name":null,
         "suffix":"NONE",
         "address_1":"6146 Honey Bluff Parkway",
         "address_2":"",
         "suite_no":"",
         "postal_box":"",
         "city":"Calder",
         "postal_code":"49628-7978",
         "country":"US",
         "state":"Michigan",
         "contact_phone":"(555) 229-3326"
      }
   ],
   "orders":{
      "placed_orders_count":2,
      "0":{
         "order_id":"000000001",
         "order_date":"2019-03-27 14:25:03"
      },
      "1":{
         "order_id":"000000002",
         "order_date":"2019-03-27 14:25:03"
      }
   },
   "customs":[
      {
         "custom": "custom"
      }
   ]
}

I have tried:

CustomerFeedSolr customerFeedsolr = mapper.map(customerDTO, CustomerFeedSolr.class);
String customerFeedJson = new Gson().toJson(customerFeedsolr);
String solrUrl = solrServerUrl.concat(customerFeedPrefix).concat(Constants.HYPHEN).concat(String.valueOf(siteID))
                        .concat(Constants.SOLR_URL_QUERIES);
                HttpEntity<String> requestEntity = new HttpEntity<String>(Arrays.asList(customerFeedJson).toString());
                restTemplate.exchange(solrUrl, HttpMethod.POST, requestEntity, String.class);

But I am not getting any data on Solr except for some random id like: "id":"33eaf02e-7fac-4e5e-9e2f-67994792b55c"

Also there is no error on the console


来源: stackexchange

问:
Problem with Foreman --- > engine.rb:201:in `kill': Invalid argument (Errno::EINVAL)
I am trying to start a ruby on rails server along with React JS; in my procfile.dev I have the following:

```<code>web: rails server -p 3000
js: yarn build --watch

</code>```

But when I try to run foreman I get this error :

```<code>$ foreman start -f Procfile.dev
13:03:37 web.1  | started with pid 21400
13:03:37 js.1   | started with pid 9904
13:03:37 js.1   | yarn run v1.22.19
13:03:37 js.1   | $ esbuild app/javascript/application.js --bundle --sourcemap --outdir=app/assets/builds --public-path=assets --watch
13:03:37 js.1   | [watch] build finished, watching for changes...
13:03:37 js.1   | Done in 0.39s.
13:03:38 js.1   | exited with code 0
13:03:38 system | sending SIGTERM to all processes
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/lib/foreman/engine.rb:201:in `kill': Invalid argument (Errno::EINVAL)
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/lib/foreman/engine.rb:201:in `kill_children'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/lib/foreman/engine.rb:473:in `terminate_gracefully'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/lib/foreman/engine.rb:439:in `wait_for_shutdown_or_child_termination'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/lib/foreman/engine.rb:60:in `start'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/lib/foreman/cli.rb:42:in `start'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/lib/foreman/vendor/thor/lib/thor/command.rb:27:in `run'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/lib/foreman/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/lib/foreman/vendor/thor/lib/thor.rb:369:in `dispatch'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/lib/foreman/vendor/thor/lib/thor/base.rb:444:in `start'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/bin/foreman:7:in `<top (required)>'
        from C:/Ruby31-x64/bin/foreman:32:in `load'
        from C:/Ruby31-x64/bin/foreman:32:in `<main>'

</code>```

I already tried to fixed the problem looking at the manifest file and the procfile.dev but I couldnt.

ContentLicense: CC BY-SA 4.0

Body:
I am trying to start a ruby on rails server along with React JS; in my procfile.dev I have the following:

web: rails server -p 3000
js: yarn build --watch

But when I try to run foreman I get this error :

$ foreman start -f Procfile.dev
13:03:37 web.1  | started with pid 21400
13:03:37 js.1   | started with pid 9904
13:03:37 js.1   | yarn run v1.22.19
13:03:37 js.1   | $ esbuild app/javascript/application.js --bundle --sourcemap --outdir=app/assets/builds --public-path=assets --watch
13:03:37 js.1   | [watch] build finished, watching for changes...
13:03:37 js.1   | Done in 0.39s.
13:03:38 js.1   | exited with code 0
13:03:38 system | sending SIGTERM to all processes
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/lib/foreman/engine.rb:201:in `kill': Invalid argument (Errno::EINVAL)
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/lib/foreman/engine.rb:201:in `kill_children'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/lib/foreman/engine.rb:473:in `terminate_gracefully'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/lib/foreman/engine.rb:439:in `wait_for_shutdown_or_child_termination'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/lib/foreman/engine.rb:60:in `start'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/lib/foreman/cli.rb:42:in `start'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/lib/foreman/vendor/thor/lib/thor/command.rb:27:in `run'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/lib/foreman/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/lib/foreman/vendor/thor/lib/thor.rb:369:in `dispatch'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/lib/foreman/vendor/thor/lib/thor/base.rb:444:in `start'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/foreman-0.87.2/bin/foreman:7:in `<top (required)>'
        from C:/Ruby31-x64/bin/foreman:32:in `load'
        from C:/Ruby31-x64/bin/foreman:32:in `'

I already tried to fixed the problem looking at the manifest file and the procfile.dev but I couldnt.


问:
java.lang.OutOfMemoryError: GC overhead limit exceeded : Spark
I am executing one Spark SQL query.

```<code>INSERT OVERWRITE TABLE desttable PARTITION(prtition_date,hour)

select .....from srctable..
</code>```

This query is running inside a thread every 10 minutes. It was working fine, but after 6 hrs. I observed below error message.

```<code>Exception in thread "dispatcher-event-loop-5" java.lang.OutOfMemoryError: GC overhead
limit exceeded
22/12/13 19:07:42 ERROR FileFormatWriter: Aborting job null.
org.apache.spark.sql.catalyst.errors.package$TreeNodeException: execute, tree:
Exchange hashpartitioning
+- *HashAggregate
   +- Exchange hashpartitioning
  +- *HashAggregate
     +- *Filter
</code>```

Can someone Please suggest me what is the issue here and How should I resolve this. within 10 min there is not much data I am expecting 1k records in every thread.

sample Code :

```<code>new Thread(new Runnable {
override def run(): Unit = {
while (true) {
spark.sql(sparksql)
 Thread.sleep(120000)
}
}
}).start()
scala.io.StdIn.readLine()
}
</code>```

This is what I found  on some website

"The java.lang.OutOfMemoryError: GC overhead limit exceeded error is the JVM’s way of signalling that your application spends too much time doing garbage collection with too little result. By default the JVM is configured to throw this error if it spends more than 98% of the total time doing GC and when after the GC only less than 2% of the heap is recovered."

can some Please suggest some configuration to handle in spark.

Body:
I am executing one Spark SQL query.

INSERT OVERWRITE TABLE desttable PARTITION(prtition_date,hour)

select .....from srctable..

This query is running inside a thread every 10 minutes. It was working fine, but after 6 hrs. I observed below error message.

Exception in thread "dispatcher-event-loop-5" java.lang.OutOfMemoryError: GC overhead
limit exceeded
22/12/13 19:07:42 ERROR FileFormatWriter: Aborting job null.
org.apache.spark.sql.catalyst.errors.package$TreeNodeException: execute, tree:
Exchange hashpartitioning
+- *HashAggregate
   +- Exchange hashpartitioning
  +- *HashAggregate
     +- *Filter

Can someone Please suggest me what is the issue here and How should I resolve this. within 10 min there is not much data I am expecting 1k records in every thread.

sample Code :

new Thread(new Runnable {
override def run(): Unit = {
while (true) {
spark.sql(sparksql)
 Thread.sleep(120000)
}
}
}).start()
scala.io.StdIn.readLine()
}

This is what I found  on some website

"The java.lang.OutOfMemoryError: GC overhead limit exceeded error is the JVM’s way of signalling that your application spends too much time doing garbage collection with too little result. By default the JVM is configured to throw this error if it spends more than 98% of the total time doing GC and when after the GC only less than 2% of the heap is recovered."

can some Please suggest some configuration to handle in spark.


问:
Animation wont play on React-Three-Fiber
I have a model that I created in Blender, currently in development phase. But I wanted to try to load the animation in React/fiber to see how it looks, but unfortunately animation wont work, here is the code sandbox https://codesandbox.io/s/cold-wave-cpcsyo?file=/src/Watch.js</p>


问:
Why does this TaskFailedException happened?
I apologize if this question is too long I couldn't find a better way to ask this question. So I am not an expert in parallel computing, and this is the biggest code I've written using it, it is an MCMC code but I want to use parallel computing in Julia to get better results.

```<code>
@everywhere function relay_basis(alpha,delta,name::String,n)   #n is the number of sources for 1 relay we have 2 sources

    chi = fill(sqrt(0.06), n)                  # the parameter chi
    phi = im*tanh.(chi)
    omega = 1.0 / prod(cosh.(chi))^2
    syms, op = qrelay_op(n, phi, alpha, delta)
    op_a, op_ab, mat, coef = op_mat(op)

    op_q2 = [syms.apH[1], syms.apV[1], syms.bpH[end], syms.bpV[end]]
    op_q1 = [syms.apH[2:end]..., syms.apV[2:end]..., syms.bpH[1:end-1]..., syms.bpV[1:end-1]...]
    mask_q1 = [op in op_q1 for op in op_a];

    mask_q2 = [op in op_q2 for op in op_a];
    qq = [x in syms.apH || x in syms.bpV ? 1 : 0 for x in op_a]

    pdet0 = pdet_maker(0.04, 1e-5)
    qrs = QRelaySampler(mat, coef, omega, pdet0)
    targetcache=Dict{Vector{Int}, Float64}()
    target(x::Vector)= log(qrs.prob(qq, x, mask_q1) * qrs.prob(x))      #the target function of MCMC
    Iteration=100_000
    burnin=1000
    samples=Iteration+burnin
    step=25
    save_iter=burnin:step:samples
    dist= qrs.psetproposal           #the proposal distribution
    selected=[]
    Q = []

    current_x = zeros(length(qq))
    @time @distributed (+) for i= 2:samples            #from this line the MCMC algorithm starts

        proposed_x= rand(dist(current_x))

        prop_proposed= pdf(dist(current_x), proposed_x)

        prop_current= pdf(dist(proposed_x), current_x)

        C=prop_current/ prop_proposed

        A= min(1,C * exp(target(proposed_x) - target( current_x)))

        if rand() < A
            if i in save_iter
                 push!(selected, proposed_x)
                 push!(Q, qrs.prob(qq, proposed_x, mask_q2))
             end

            current_x = proposed_x
        end

    end

    return selected, Q
end
</code>```

I call this function:

```<code>for i = 0:2
    beta = i*pi/2
    name = string(i)
    selected, Q = relay_basis(pi/4, beta, name,2)
    println("beta:", beta)
    push!(prob,Q)
    df=DataFrame(selected=selected)

end
</code>```

And I get this long error message:

```<code>TaskFailedException

    nested task error: MethodError: no method matching write(::Sockets.TCPSocket, ::Cstring)
    Closest candidates are:
      write(::IO, ::Any) at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/base/io.jl:637
      write(::IO, ::Any, ::Any...) at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/base/io.jl:638
      write(::FilePathsBase.AbstractPath, ::Any) at ~/.julia/packages/FilePathsBase/dVWLK/src/path.jl:771
      ...
    Stacktrace:
      [1] write(io::Sockets.TCPSocket, x::Cstring)
        @ Base ./io.jl:637
      [2] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:664
      [3] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
      [4] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
      [5] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
      [6] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
      [7] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
      [8] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
      [9] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
     [10] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
     [11] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
     [12] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
     [13] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
     [14] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
     [15] serialize
        @ /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653 [inlined]
     [16] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, a::Vector{JuMP.VariableRef})
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:277
     [17] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
     [18] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
     [19] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
     [20] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
     [21] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
     [22] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
     [23] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
     [24] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
     [25] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
     [26] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
     [27] serialize_msg(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, o::Distributed.CallMsg{:call_fetch})
        @ Distributed /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Distributed/src/messages.jl:78
     [28] #invokelatest#2
        @ ./essentials.jl:716 [inlined]
     [29] invokelatest
        @ ./essentials.jl:714 [inlined]
     [30] send_msg_(w::Distributed.Worker, header::Distributed.MsgHeader, msg::Distributed.CallMsg{:call_fetch}, now::Bool)
        @ Distributed /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Distributed/src/messages.jl:181
     [31] send_msg
        @ /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Distributed/src/messages.jl:122 [inlined]
     [32] remotecall_fetch(::Function, ::Distributed.Worker, ::Function, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
        @ Distributed /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Distributed/src/remotecall.jl:464
     [33] remotecall_fetch(::Function, ::Distributed.Worker, ::Function, ::Vararg{Any})
        @ Distributed /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Distributed/src/remotecall.jl:461
     [34] #remotecall_fetch#158
        @ /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Distributed/src/remotecall.jl:496 [inlined]
     [35] remotecall_fetch
        @ /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Distributed/src/remotecall.jl:496 [inlined]
     [36] (::Distributed.var"#169#170"{typeof(+), var"#4#9"{Main.Quantum.var"#psetproposal#10"{Matrix{Float64}}, var"#target#8"{QRelaySampler, Vector{Int64}, Vector{Bool}}}, UnitRange{Int64}, Vector{UnitRange{Int64}}, Int64, Int64})()
        @ Distributed /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Distributed/src/macros.jl:270

Stacktrace:
 [1] wait
   @ ./task.jl:334 [inlined]
 [2] fetch
   @ ./task.jl:349 [inlined]
 [3] preduce(reducer::Function, f::Function, R::UnitRange{Int64})
   @ Distributed /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Distributed/src/macros.jl:274
 [4] macro expansion
   @ ./timing.jl:220 [inlined]
 [5] relay_basis(alpha::Float64, delta::Float64, name::String, n::Int64)
   @ Main ./In[3]:31
 [6] top-level scope
   @ ./In[4]:4
 [7] eval
   @ ./boot.jl:373 [inlined]
 [8] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base ./loading.jl:1196
</code>```

I understood that the error might have occurred in the for loop, if it is how can I use the for loop for parallel computing.

Body:
I apologize if this question is too long I couldn't find a better way to ask this question. So I am not an expert in parallel computing, and this is the biggest code I've written using it, it is an MCMC code but I want to use parallel computing in Julia to get better results.

@everywhere function relay_basis(alpha,delta,name::String,n)   #n is the number of sources for 1 relay we have 2 sources

    chi = fill(sqrt(0.06), n)                  # the parameter chi
    phi = im*tanh.(chi)
    omega = 1.0 / prod(cosh.(chi))^2
    syms, op = qrelay_op(n, phi, alpha, delta)
    op_a, op_ab, mat, coef = op_mat(op)

    op_q2 = [syms.apH[1], syms.apV[1], syms.bpH[end], syms.bpV[end]]
    op_q1 = [syms.apH[2:end]..., syms.apV[2:end]..., syms.bpH[1:end-1]..., syms.bpV[1:end-1]...]
    mask_q1 = [op in op_q1 for op in op_a];

    mask_q2 = [op in op_q2 for op in op_a];
    qq = [x in syms.apH || x in syms.bpV ? 1 : 0 for x in op_a]

    pdet0 = pdet_maker(0.04, 1e-5)
    qrs = QRelaySampler(mat, coef, omega, pdet0)
    targetcache=Dict{Vector{Int}, Float64}()
    target(x::Vector)= log(qrs.prob(qq, x, mask_q1) * qrs.prob(x))      #the target function of MCMC
    Iteration=100_000
    burnin=1000
    samples=Iteration+burnin
    step=25
    save_iter=burnin:step:samples
    dist= qrs.psetproposal           #the proposal distribution
    selected=[]
    Q = []

    current_x = zeros(length(qq))
    @time @distributed (+) for i= 2:samples            #from this line the MCMC algorithm starts

        proposed_x= rand(dist(current_x))

        prop_proposed= pdf(dist(current_x), proposed_x)

        prop_current= pdf(dist(proposed_x), current_x)

        C=prop_current/ prop_proposed

        A= min(1,C * exp(target(proposed_x) - target( current_x)))

        if rand() < A
            if i in save_iter
                 push!(selected, proposed_x)
                 push!(Q, qrs.prob(qq, proposed_x, mask_q2))
             end

            current_x = proposed_x
        end

    end

    return selected, Q
end

I call this function:

for i = 0:2
    beta = i*pi/2
    name = string(i)
    selected, Q = relay_basis(pi/4, beta, name,2)
    println("beta:", beta)
    push!(prob,Q)
    df=DataFrame(selected=selected)

end

And I get this long error message:

TaskFailedException

    nested task error: MethodError: no method matching write(::Sockets.TCPSocket, ::Cstring)
    Closest candidates are:
      write(::IO, ::Any) at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/base/io.jl:637
      write(::IO, ::Any, ::Any...) at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/base/io.jl:638
      write(::FilePathsBase.AbstractPath, ::Any) at ~/.julia/packages/FilePathsBase/dVWLK/src/path.jl:771
      ...
    Stacktrace:
      [1] write(io::Sockets.TCPSocket, x::Cstring)
        @ Base ./io.jl:637
      [2] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:664
      [3] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
      [4] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
      [5] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
      [6] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
      [7] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
      [8] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
      [9] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
     [10] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
     [11] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
     [12] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
     [13] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
     [14] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
     [15] serialize
        @ /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653 [inlined]
     [16] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, a::Vector{JuMP.VariableRef})
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:277
     [17] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
     [18] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
     [19] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
     [20] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
     [21] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
     [22] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
     [23] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
     [24] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
     [25] serialize_any(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:674
     [26] serialize(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, x::Any)
        @ Serialization /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:653
     [27] serialize_msg(s::Distributed.ClusterSerializer{Sockets.TCPSocket}, o::Distributed.CallMsg{:call_fetch})
        @ Distributed /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Distributed/src/messages.jl:78
     [28] #invokelatest#2
        @ ./essentials.jl:716 [inlined]
     [29] invokelatest
        @ ./essentials.jl:714 [inlined]
     [30] send_msg_(w::Distributed.Worker, header::Distributed.MsgHeader, msg::Distributed.CallMsg{:call_fetch}, now::Bool)
        @ Distributed /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Distributed/src/messages.jl:181
     [31] send_msg
        @ /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Distributed/src/messages.jl:122 [inlined]
     [32] remotecall_fetch(::Function, ::Distributed.Worker, ::Function, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
        @ Distributed /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Distributed/src/remotecall.jl:464
     [33] remotecall_fetch(::Function, ::Distributed.Worker, ::Function, ::Vararg{Any})
        @ Distributed /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Distributed/src/remotecall.jl:461
     [34] #remotecall_fetch#158
        @ /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Distributed/src/remotecall.jl:496 [inlined]
     [35] remotecall_fetch
        @ /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Distributed/src/remotecall.jl:496 [inlined]
     [36] (::Distributed.var"#169#170"{typeof(+), var"#4#9"{Main.Quantum.var"#psetproposal#10"{Matrix{Float64}}, var"#target#8"{QRelaySampler, Vector{Int64}, Vector{Bool}}}, UnitRange{Int64}, Vector{UnitRange{Int64}}, Int64, Int64})()
        @ Distributed /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Distributed/src/macros.jl:270

Stacktrace:
 [1] wait
   @ ./task.jl:334 [inlined]
 [2] fetch
   @ ./task.jl:349 [inlined]
 [3] preduce(reducer::Function, f::Function, R::UnitRange{Int64})
   @ Distributed /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Distributed/src/macros.jl:274
 [4] macro expansion
   @ ./timing.jl:220 [inlined]
 [5] relay_basis(alpha::Float64, delta::Float64, name::String, n::Int64)
   @ Main ./In[3]:31
 [6] top-level scope
   @ ./In[4]:4
 [7] eval
   @ ./boot.jl:373 [inlined]
 [8] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base ./loading.jl:1196

I understood that the error might have occurred in the for loop, if it is how can I use the for loop for parallel computing.


问:
double tap in react native
How does react native's double tap function? I want the setliked state to be triggered if a user double taps the image. How can I accomplish this in RN? Is there a pre-built package in RN that allows me to accomplish that, like Instagram posts? I'm using rn 0.70.5 like onpress, but is there another method to accomplish this?

```<code>
    import { StyleSheet, Text, View, Image } from 'react-native'
    import React, { useState } from 'react'
    import { FontAwesome } from '@expo/vector-icons';
    import { icons1 } from '../CommonCss/PageCss';
    import { Feather } from '@expo/vector-icons';
    import styles from './styles';

    const PostCard = (
      {
        key,
        username,
        postimg,
        profileimg,
        likes,
        comments,
      }
    ) => {

      const [isliked, setIsliked] = useState(false)
      const [showcomments, setShowcomments] = useState(false)

      return (
        <View style={styles.container}>
          <View style={styles.content}>
            <Image source={{ uri: profileimg }} style={styles.profileImage} />
            <Text style={styles.Username}>{username}</Text>
          </View>
          <Image source={{ uri: postimg }} style={styles.posts} /> // This is the post img
          <View style={styles.section}>
            {
              isliked ?
                <View style={styles.likesection}>
                  <FontAwesome name="heart" size={24} color="black" style={styles.iconliked} onPress={() => {
                    setIsliked(false)
                  }} />
                  <Text style={styles.liked}>{likes.length + 1}</Text>
                </View>
                :
                <View style={styles.likesection}>
                  <Feather name="heart" size={24} color="black" style={icons1} onPress={() => {
                    setIsliked(true)
                  }} />
                  <Text style={styles.notliked}>{likes.length}</Text>
                </View>
            }
            <View style={styles.commentsection}>
              <FontAwesome name="comment" size={24} color="black" style={icons1}
                onPress={() => {
                  setShowcomments(!showcomments)
                }}
              />
            </View>
          </View>
          {
            showcomments == true &&
            <View style={styles.section2}>
              {
                comments.map((item, index) => {
                  return (
                    <View style={styles.section2s1} key={item.id}>
                      <Text style={styles.commentUser}>{item.username}</Text>
                      <Text style={styles.commentText}>{item.comments}</Text>
                    </View>
                  )
                })
              }
            </View>
          }
        </View>
      )
    }

    export default PostCard
</code>```

any suggestions from your part

Title: double tap in react native

Body:
How does react native's double tap function? I want the setliked state to be triggered if a user double taps the image. How can I accomplish this in RN? Is there a pre-built package in RN that allows me to accomplish that, like Instagram posts? I'm using rn 0.70.5 like onpress, but is there another method to accomplish this?

    import { StyleSheet, Text, View, Image } from 'react-native'
    import React, { useState } from 'react'
    import { FontAwesome } from '@expo/vector-icons';
    import { icons1 } from '../CommonCss/PageCss';
    import { Feather } from '@expo/vector-icons';
    import styles from './styles';

    const PostCard = (
      {
        key,
        username,
        postimg,
        profileimg,
        likes,
        comments,
      }
    ) => {

      const [isliked, setIsliked] = useState(false)
      const [showcomments, setShowcomments] = useState(false)

      return (
        <View style={styles.container}>
          <View style={styles.content}>
            <Image source={{ uri: profileimg }} style={styles.profileImage} />
            <Text style={styles.Username}>{username}</Text>
          </View>
          <Image source={{ uri: postimg }} style={styles.posts} /> // This is the post img
          <View style={styles.section}>
            {
              isliked ?
                <View style={styles.likesection}>
                  <FontAwesome name="heart" size={24} color="black" style={styles.iconliked} onPress={() => {
                    setIsliked(false)
                  }} />
                  <Text style={styles.liked}>{likes.length + 1}</Text>
                </View>
                :
                <View style={styles.likesection}>
                  <Feather name="heart" size={24} color="black" style={icons1} onPress={() => {
                    setIsliked(true)
                  }} />
                  <Text style={styles.notliked}>{likes.length}</Text>
                </View>
            }
            <View style={styles.commentsection}>
              <FontAwesome name="comment" size={24} color="black" style={icons1}
                onPress={() => {
                  setShowcomments(!showcomments)
                }}
              />
            </View>
          </View>
          {
            showcomments == true &&
            <View style={styles.section2}>
              {
                comments.map((item, index) => {
                  return (
                    <View style={styles.section2s1} key={item.id}>
                      <Text style={styles.commentUser}>{item.username}</Text>
                      <Text style={styles.commentText}>{item.comments}</Text>
                    </View>
                  )
                })
              }
            </View>
          }
        </View>
      )
    }

    export default PostCard

any suggestions from your part


问:
"Object not found" ERROR Message on Android AR Quicklook preview
I'm trying to put together an AR Demo and the file should be previewed using an Android phone that supports AR. The thing is that the object cannot load although I tried GLB and gItf with different mesh resolution. The object also loads fine using the model viewer from the ARCore documentation.

Any ideas what might be wrong and how to fix it?

I tried using different models w. different resolutions


问:
why is the last one always deleted from lazyColumn items in jetpack compose?
I made a dictionary application and the user can add their own dictionaries and enter their words and meanings into the dictionaries they add. The user can also delete these dictionaries, but for some reason when I want to delete a dictionary, it always deletes the last dictionary. What could be the reason for this? my codes are like this

CreateYourOwnDictionaryScreen

```<code>@Composable
fun CreateYourOwnDictionaryScreen(
    navController: NavController,
    viewModel: CreateYourOwnDictionaryViewModel = hiltViewModel()
) {

    val scaffoldState = rememberScaffoldState()
    val state = viewModel.state.value

    Scaffold(
        scaffoldState = scaffoldState,
        topBar = {
            TopAppBar(
                backgroundColor = bar,
                title = {

                    androidx.compose.material3.Text(
                        text = "your dictionaries",
                        modifier = Modifier.fillMaxWidth(),
                        color = Color.White,
                        fontSize = 22.sp
                    )

                },
                navigationIcon = {
                    IconButton(onClick = {
                        navController.navigate(Screen.MainScreen.route)
                    }) {
                        Icon(
                            imageVector = Icons.Filled.ArrowBack,
                            contentDescription = "Go Back"
                        )
                    }
                }

            )

        },

        floatingActionButtonPosition = FabPosition.Center,
        floatingActionButton = {
            FloatingActionButton(
                onClick = { navController.navigate(Screen.CreateDicScreen.route) },
                backgroundColor = bar,

                ) {
                Icon(Icons.Filled.Add, "fab")
            }
        }
    ) {

        Box(modifier = Modifier.background(MaterialTheme.colors.background)) {

            Column(
                modifier = Modifier
                    .fillMaxSize()
                    .padding(16.dp)
            ) {

                LazyColumn(
                    modifier = Modifier.fillMaxSize()
                ) {
                    items(state.dictionaries) { dictionary ->

                        CreateYourOwnDictionaryItem(
                            dictionary = dictionary,
                            modifier = Modifier
                                .fillMaxWidth()
                                .clickable {
                                    navController.navigate(Screen.MyWordsScreen.passDicId(dictionary.uid))
                                },

                            onAddClick = {
                                navController.navigate(
                                    Screen.MakeYourDictionaryScreen.passDicId(
                                        dictionary.uid
                                    )
                                )
                            },

                            onDeleteClick = {

                            },

                            onEditClick = {

                                navController.navigate(Screen.UpdateDictionaryScreen.passDicIdAndDicCreationTime(
                                    dictionary.uid,
                                    dictionary.creationTime
                                ))

                            }

                        )
                        Spacer(modifier = Modifier.height(16.dp))
                    }
                }

            }
        }

    }

}
</code>```

CreateYourOwnDictionaryItem

```<code>@Composable
fun CreateYourOwnDictionaryItem(
    dictionary: OwnDicEntity,
    modifier: Modifier = Modifier,
    cornerRadius: Dp = 10.dp,
    cutCornerSize: Dp = 30.dp,
    onAddClick: () -> Unit,
    onDeleteClick: () -> Unit,
    onEditClick: () -> Unit,
    viewModel: CreateYourOwnDictionaryViewModel = hiltViewModel()
) {

    Box(
        modifier = modifier
    ) {

        Canvas(modifier = Modifier.matchParentSize()) {

            val clipPath = Path().apply {
                lineTo(size.width - cutCornerSize.toPx(), 0f)
                lineTo(size.width, cutCornerSize.toPx())
                lineTo(size.width, size.height)
                lineTo(0f, size.height)
                close()
            }
            clipPath(clipPath) {

                drawRoundRect(
                    color = myColor4,
                    size = size,
                    cornerRadius = CornerRadius(cornerRadius.toPx())
                )

                val color1: Int = 0xFF0000FF.toInt()
                val color2: Int = 0xFF938F99.toInt()

                drawRoundRect(
                    color = Color(
                        ColorUtils.blendARGB(color1, color2, 0.2f)
                    ),
                    topLeft = Offset(size.width - cutCornerSize.toPx(), -100f),
                    size = Size(cutCornerSize.toPx() + 100f, cutCornerSize.toPx() + 100f),
                    cornerRadius = CornerRadius(cornerRadius.toPx())
                )

            }

        }

        Column(
            modifier = Modifier
                .padding(16.dp)
                .padding(end = 32.dp)
                .fillMaxSize(),
        ) {

            Text(
                text = dictionary.ownDicName,
                style = MaterialTheme.typography.h6,
                color = MaterialTheme.colors.onSurface,
                maxLines = 1,
                overflow = TextOverflow.Ellipsis
            )
            Spacer(modifier = Modifier.height(8.dp))
            Text(
                text = dictionary.creationTime,
                style = MaterialTheme.typography.body1,
                color = MaterialTheme.colors.onSurface,
            )
        }

        Row(modifier = Modifier.align(Alignment.BottomEnd)) {

            IconButton(
                onClick = onAddClick,

                ) {

                Icon(
                    imageVector = Icons.Default.Add,
                    contentDescription = "Add your own word to dictionary",
                    tint = MaterialTheme.colors.onSurface
                )
            }

            IconButton(
                onClick = {
                    viewModel.onConfirm()

                },
            ) {

                Icon(
                    imageVector = Icons.Default.Delete,
                    contentDescription = "Delete dictionary",
                    tint = MaterialTheme.colors.onSurface
                )
            }

            IconButton(
                onClick = onEditClick,
            ) {

                Icon(
                    imageVector = Icons.Default.Edit,
                    contentDescription = "edit dictionary",
                    tint = MaterialTheme.colors.onSurface
                )
            }
        }

    }

    if (viewModel.isDialogShown) {

        CustomDialog(

            onDismiss = {
                viewModel.onDismiss()
            },
            onConfirm = {
                println("dictionary $dictionary")
                //viewModel.onEvent(CreateYourOwnDictionaryEvents.DeleteDictionary(dictionary))
                viewModel.onDismiss()
            }

        )
    }

}

@Composable
fun CustomDialog(
    onDismiss: () -> Unit,
    onConfirm: () -> Unit,

    ) {

    Dialog(
        onDismissRequest = {
            onDismiss()
        }
    ) {
        Card(
            elevation = 5.dp,
            shape = RoundedCornerShape(15.dp),
            modifier = Modifier
                .fillMaxWidth(0.95f)
                .border(2.dp, color = md_theme_dark_error, shape = RoundedCornerShape(15.dp))
        ) {
            Column(
                modifier = Modifier
                    .fillMaxWidth()
                    .padding(15.dp),
                verticalArrangement = Arrangement.spacedBy(25.dp)
            ) {

                Text(
                    text = "Are You Sure You Want To Delete ?",
                    modifier = Modifier.padding(4.dp),
                    fontSize = 20.sp,
                    fontStyle = FontStyle.Normal,
                    textAlign = TextAlign.Center
                )

                Spacer(modifier = Modifier.padding(10.dp))

                Row(
                    modifier = Modifier
                        .fillMaxWidth(),
                    horizontalArrangement = Arrangement.spacedBy(30.dp),
                    verticalAlignment = Alignment.CenterVertically
                ) {
                    Button(
                        onClick = {
                            onDismiss()
                        },
                        colors = ButtonDefaults.buttonColors(
                            backgroundColor = md_theme_dark_error,
                            contentColor = md_theme_dark_onSurface
                        ),
                        modifier = Modifier
                            .fillMaxWidth()
                            .weight(1f),
                        shape = MaterialTheme.shapes.medium
                    ) {
                        Text(
                            text = "Cancel",
                            color = md_theme_dark_background,
                            fontWeight = FontWeight.Medium,
                            textAlign = TextAlign.Center,
                        )
                    }
                    Button(
                        onClick = {
                            onConfirm()

                        },
                        colors = ButtonDefaults.buttonColors(
                            backgroundColor = md_theme_dark_error,
                            contentColor = md_theme_dark_onSurface
                        ),
                        modifier = Modifier
                            .fillMaxWidth()
                            .weight(1f),
                        shape = MaterialTheme.shapes.medium
                    ) {
                        Text(
                            text = "Confirm",
                            color = md_theme_dark_background,
                            fontWeight = FontWeight.Medium,
                            textAlign = TextAlign.Center,
                        )
                    }
                }

            }
        }
    }
}
</code>```

viewModel

```<code>@HiltViewModel
class CreateYourOwnDictionaryViewModel @Inject constructor(
    private val getDicUseCase: GetDicUseCase,
    private val deleteDicUseCase: DeleteDicUseCase
) : ViewModel() {

    private val _state = mutableStateOf(CreateYourOwnDictionaryState())
    val state: State<CreateYourOwnDictionaryState> = _state

    private var getDicJob: Job? = null

    var isDialogShown by mutableStateOf(false)

    fun onConfirm(){
        isDialogShown = true
    }

    fun onDismiss(){
        isDialogShown = false
    }

    init {
        getDictionaries()
    }

    fun onEvent(event: CreateYourOwnDictionaryEvents) {

        when (event) {

            is CreateYourOwnDictionaryEvents.DeleteDictionary -> {

                viewModelScope.launch {
                    deleteDicUseCase.deleteDic(event.dictionary)
                    getDictionaries()
                }
            }

            is CreateYourOwnDictionaryEvents.UpdateDictionary -> {
                viewModelScope.launch {

                }
            }
        }

    }

     private fun getDictionaries() {

        getDicJob?.cancel()
        getDicJob = getDicUseCase.getDic().onEach { result ->

            when (result) {
                is Resource.Success -> {
                    _state.value = state.value.copy(
                        dictionaries = result.data ?: emptyList(),
                        isLoading = false
                    )
                }

                is Resource.Error -> {
                    _state.value = state.value.copy(
                        dictionaries = result.data ?: emptyList(),
                        isLoading = false
                    )
                }

                is Resource.Loading -> {
                    _state.value = state.value.copy(
                        dictionaries = result.data ?: emptyList(),
                        isLoading = true
                    )
                }
            }

        }.launchIn(viewModelScope)
    }

}
</code>```

CreateYourOwnDictionaryEvents

```<code>sealed class CreateYourOwnDictionaryEvents {

    data class DeleteDictionary(val dictionary:OwnDicEntity) : CreateYourOwnDictionaryEvents()
    data class UpdateDictionary(val dictionary:OwnDicEntity) : CreateYourOwnDictionaryEvents()

}
</code>```

Body:
I made a dictionary application and the user can add their own dictionaries and enter their words and meanings into the dictionaries they add. The user can also delete these dictionaries, but for some reason when I want to delete a dictionary, it always deletes the last dictionary. What could be the reason for this? my codes are like this

CreateYourOwnDictionaryScreen

@Composable
fun CreateYourOwnDictionaryScreen(
    navController: NavController,
    viewModel: CreateYourOwnDictionaryViewModel = hiltViewModel()
) {

    val scaffoldState = rememberScaffoldState()
    val state = viewModel.state.value

    Scaffold(
        scaffoldState = scaffoldState,
        topBar = {
            TopAppBar(
                backgroundColor = bar,
                title = {

                    androidx.compose.material3.Text(
                        text = "your dictionaries",
                        modifier = Modifier.fillMaxWidth(),
                        color = Color.White,
                        fontSize = 22.sp
                    )

                },
                navigationIcon = {
                    IconButton(onClick = {
                        navController.navigate(Screen.MainScreen.route)
                    }) {
                        Icon(
                            imageVector = Icons.Filled.ArrowBack,
                            contentDescription = "Go Back"
                        )
                    }
                }

            )

        },

        floatingActionButtonPosition = FabPosition.Center,
        floatingActionButton = {
            FloatingActionButton(
                onClick = { navController.navigate(Screen.CreateDicScreen.route) },
                backgroundColor = bar,

                ) {
                Icon(Icons.Filled.Add, "fab")
            }
        }
    ) {

        Box(modifier = Modifier.background(MaterialTheme.colors.background)) {

            Column(
                modifier = Modifier
                    .fillMaxSize()
                    .padding(16.dp)
            ) {

                LazyColumn(
                    modifier = Modifier.fillMaxSize()
                ) {
                    items(state.dictionaries) { dictionary ->

                        CreateYourOwnDictionaryItem(
                            dictionary = dictionary,
                            modifier = Modifier
                                .fillMaxWidth()
                                .clickable {
                                    navController.navigate(Screen.MyWordsScreen.passDicId(dictionary.uid))
                                },

                            onAddClick = {
                                navController.navigate(
                                    Screen.MakeYourDictionaryScreen.passDicId(
                                        dictionary.uid
                                    )
                                )
                            },

                            onDeleteClick = {

                            },

                            onEditClick = {

                                navController.navigate(Screen.UpdateDictionaryScreen.passDicIdAndDicCreationTime(
                                    dictionary.uid,
                                    dictionary.creationTime
                                ))

                            }

                        )
                        Spacer(modifier = Modifier.height(16.dp))
                    }
                }

            }
        }

    }

}

CreateYourOwnDictionaryItem

@Composable
fun CreateYourOwnDictionaryItem(
    dictionary: OwnDicEntity,
    modifier: Modifier = Modifier,
    cornerRadius: Dp = 10.dp,
    cutCornerSize: Dp = 30.dp,
    onAddClick: () -> Unit,
    onDeleteClick: () -> Unit,
    onEditClick: () -> Unit,
    viewModel: CreateYourOwnDictionaryViewModel = hiltViewModel()
) {

    Box(
        modifier = modifier
    ) {

        Canvas(modifier = Modifier.matchParentSize()) {

            val clipPath = Path().apply {
                lineTo(size.width - cutCornerSize.toPx(), 0f)
                lineTo(size.width, cutCornerSize.toPx())
                lineTo(size.width, size.height)
                lineTo(0f, size.height)
                close()
            }
            clipPath(clipPath) {

                drawRoundRect(
                    color = myColor4,
                    size = size,
                    cornerRadius = CornerRadius(cornerRadius.toPx())
                )

                val color1: Int = 0xFF0000FF.toInt()
                val color2: Int = 0xFF938F99.toInt()

                drawRoundRect(
                    color = Color(
                        ColorUtils.blendARGB(color1, color2, 0.2f)
                    ),
                    topLeft = Offset(size.width - cutCornerSize.toPx(), -100f),
                    size = Size(cutCornerSize.toPx() + 100f, cutCornerSize.toPx() + 100f),
                    cornerRadius = CornerRadius(cornerRadius.toPx())
                )

            }

        }

        Column(
            modifier = Modifier
                .padding(16.dp)
                .padding(end = 32.dp)
                .fillMaxSize(),
        ) {

            Text(
                text = dictionary.ownDicName,
                style = MaterialTheme.typography.h6,
                color = MaterialTheme.colors.onSurface,
                maxLines = 1,
                overflow = TextOverflow.Ellipsis
            )
            Spacer(modifier = Modifier.height(8.dp))
            Text(
                text = dictionary.creationTime,
                style = MaterialTheme.typography.body1,
                color = MaterialTheme.colors.onSurface,
            )
        }

        Row(modifier = Modifier.align(Alignment.BottomEnd)) {

            IconButton(
                onClick = onAddClick,

                ) {

                Icon(
                    imageVector = Icons.Default.Add,
                    contentDescription = "Add your own word to dictionary",
                    tint = MaterialTheme.colors.onSurface
                )
            }

            IconButton(
                onClick = {
                    viewModel.onConfirm()

                },
            ) {

                Icon(
                    imageVector = Icons.Default.Delete,
                    contentDescription = "Delete dictionary",
                    tint = MaterialTheme.colors.onSurface
                )
            }

            IconButton(
                onClick = onEditClick,
            ) {

                Icon(
                    imageVector = Icons.Default.Edit,
                    contentDescription = "edit dictionary",
                    tint = MaterialTheme.colors.onSurface
                )
            }
        }

    }

    if (viewModel.isDialogShown) {

        CustomDialog(

            onDismiss = {
                viewModel.onDismiss()
            },
            onConfirm = {
                println("dictionary $dictionary")
                //viewModel.onEvent(CreateYourOwnDictionaryEvents.DeleteDictionary(dictionary))
                viewModel.onDismiss()
            }

        )
    }

}

@Composable
fun CustomDialog(
    onDismiss: () -> Unit,
    onConfirm: () -> Unit,

    ) {

    Dialog(
        onDismissRequest = {
            onDismiss()
        }
    ) {
        Card(
            elevation = 5.dp,
            shape = RoundedCornerShape(15.dp),
            modifier = Modifier
                .fillMaxWidth(0.95f)
                .border(2.dp, color = md_theme_dark_error, shape = RoundedCornerShape(15.dp))
        ) {
            Column(
                modifier = Modifier
                    .fillMaxWidth()
                    .padding(15.dp),
                verticalArrangement = Arrangement.spacedBy(25.dp)
            ) {

                Text(
                    text = "Are You Sure You Want To Delete ?",
                    modifier = Modifier.padding(4.dp),
                    fontSize = 20.sp,
                    fontStyle = FontStyle.Normal,
                    textAlign = TextAlign.Center
                )

                Spacer(modifier = Modifier.padding(10.dp))

                Row(
                    modifier = Modifier
                        .fillMaxWidth(),
                    horizontalArrangement = Arrangement.spacedBy(30.dp),
                    verticalAlignment = Alignment.CenterVertically
                ) {
                    Button(
                        onClick = {
                            onDismiss()
                        },
                        colors = ButtonDefaults.buttonColors(
                            backgroundColor = md_theme_dark_error,
                            contentColor = md_theme_dark_onSurface
                        ),
                        modifier = Modifier
                            .fillMaxWidth()
                            .weight(1f),
                        shape = MaterialTheme.shapes.medium
                    ) {
                        Text(
                            text = "Cancel",
                            color = md_theme_dark_background,
                            fontWeight = FontWeight.Medium,
                            textAlign = TextAlign.Center,
                        )
                    }
                    Button(
                        onClick = {
                            onConfirm()

                        },
                        colors = ButtonDefaults.buttonColors(
                            backgroundColor = md_theme_dark_error,
                            contentColor = md_theme_dark_onSurface
                        ),
                        modifier = Modifier
                            .fillMaxWidth()
                            .weight(1f),
                        shape = MaterialTheme.shapes.medium
                    ) {
                        Text(
                            text = "Confirm",
                            color = md_theme_dark_background,
                            fontWeight = FontWeight.Medium,
                            textAlign = TextAlign.Center,
                        )
                    }
                }

            }
        }
    }
}

viewModel

@HiltViewModel
class CreateYourOwnDictionaryViewModel @Inject constructor(
    private val getDicUseCase: GetDicUseCase,
    private val deleteDicUseCase: DeleteDicUseCase
) : ViewModel() {

    private val _state = mutableStateOf(CreateYourOwnDictionaryState())
    val state: State<CreateYourOwnDictionaryState> = _state

    private var getDicJob: Job? = null

    var isDialogShown by mutableStateOf(false)

    fun onConfirm(){
        isDialogShown = true
    }

    fun onDismiss(){
        isDialogShown = false
    }

    init {
        getDictionaries()
    }

    fun onEvent(event: CreateYourOwnDictionaryEvents) {

        when (event) {

            is CreateYourOwnDictionaryEvents.DeleteDictionary -> {

                viewModelScope.launch {
                    deleteDicUseCase.deleteDic(event.dictionary)
                    getDictionaries()
                }
            }

            is CreateYourOwnDictionaryEvents.UpdateDictionary -> {
                viewModelScope.launch {

                }
            }
        }

    }

     private fun getDictionaries() {

        getDicJob?.cancel()
        getDicJob = getDicUseCase.getDic().onEach { result ->

            when (result) {
                is Resource.Success -> {
                    _state.value = state.value.copy(
                        dictionaries = result.data ?: emptyList(),
                        isLoading = false
                    )
                }

                is Resource.Error -> {
                    _state.value = state.value.copy(
                        dictionaries = result.data ?: emptyList(),
                        isLoading = false
                    )
                }

                is Resource.Loading -> {
                    _state.value = state.value.copy(
                        dictionaries = result.data ?: emptyList(),
                        isLoading = true
                    )
                }
            }

        }.launchIn(viewModelScope)
    }

}

CreateYourOwnDictionaryEvents

sealed class CreateYourOwnDictionaryEvents {

    data class DeleteDictionary(val dictionary:OwnDicEntity) : CreateYourOwnDictionaryEvents()
    data class UpdateDictionary(val dictionary:OwnDicEntity) : CreateYourOwnDictionaryEvents()

}


问:
Elasticsearch: mapper_parsing_exception: Get detailed error message
I am inserting a Pandas dataframe into Elasticsearch, using the elasticsearch Python package.

I have created an index specifying an explicit mapping:

```<code>mappings = {
    'properties': {
        'PLZ': {'type': 'integer'},
        'ORT': {'type': 'text'},
        'STRASSE': {'type': 'text'},
        ...
}

es.indices.create(index="test", mappings = mappings)
</code>```

When I try to insert a specific document into this index, I receive a mapper_parsing_exception:

```<code>res = es.index(index="test", id=1, document=df.iloc[0], error_trace = True)
</code>```

BadRequestError: BadRequestError(400, 'mapper_parsing_exception', 'failed to parse')

Is there any way to receive a more detailed error message describing which field exactly could not be parsed?

Body:
I am inserting a Pandas dataframe into Elasticsearch, using the elasticsearch Python package.

I have created an index specifying an explicit mapping:

mappings = {
    'properties': {
        'PLZ': {'type': 'integer'},
        'ORT': {'type': 'text'},
        'STRASSE': {'type': 'text'},
        ...
}

es.indices.create(index="test", mappings = mappings)

When I try to insert a specific document into this index, I receive a mapper_parsing_exception:

res = es.index(index="test", id=1, document=df.iloc[0], error_trace = True)

BadRequestError: BadRequestError(400, 'mapper_parsing_exception', 'failed to parse')

Is there any way to receive a more detailed error message describing which field exactly could not be parsed?


问:
How to allow user to login to all subdomains with Okta auth?
How can I allow an Okta auth app to be logged into two subdomains?

I have two applications under the same domain but different subdomains. I.e.

one.example.com

two.example.com

When a user logs into one.example.com, I want their authentication to persist across two.example.com without having to be prompted to log in again.

The flow would be

User clicks login from one.example.com

user is redirected to Okta auth hosted login screen

User enters their credentials

User is redirected back to one.example.com

User clicks link that takes them to two.example.com

User lands on two.example.com and access token persists and is accessable / included in subsequent API calls made from two.example.com

My Okta app is setup to use OIDC - OpenID Connect.

Authentication is working for one.example.com but when user navigates to two.example.com within the same browsing session, the accessToken is no longer accessible.

Should I set two.example.com up as a separate Okta app in the same Okta workspace or does it need to be the same Okta app considering their will be no new login prompt for the user?

I am using Okta auth SDK @okta/okta-auth-js to retrieve the access token:

```<code>oktaAuth.getAccessToken() // returns access token for one.example.com but returns undefined for `two.example.com`
</code>```

Body:
How can I allow an Okta auth app to be logged into two subdomains?

I have two applications under the same domain but different subdomains. I.e.

one.example.com

two.example.com

When a user logs into one.example.com, I want their authentication to persist across two.example.com without having to be prompted to log in again.

The flow would be

User clicks login from one.example.com

user is redirected to Okta auth hosted login screen

User enters their credentials

User is redirected back to one.example.com

User clicks link that takes them to two.example.com

User lands on two.example.com and access token persists and is accessable / included in subsequent API calls made from two.example.com

My Okta app is setup to use OIDC - OpenID Connect.

Authentication is working for one.example.com but when user navigates to two.example.com within the same browsing session, the accessToken is no longer accessible.

Should I set two.example.com up as a separate Okta app in the same Okta workspace or does it need to be the same Okta app considering their will be no new login prompt for the user?

I am using Okta auth SDK @okta/okta-auth-js to retrieve the access token:

oktaAuth.getAccessToken() // returns access token for one.example.com but returns undefined for `two.example.com`


问:
AWS Glue- s3fs throws FileNotFoundError
I am trying to read a parquet file from s3 using s3fs file system using pyarrow but getting NoSuchKey or FileNotFoundError.

```<code>def read_parquet_pd(path):
    s3 = s3fs.S3FileSystem()
    path = path.rstrip('/')
    logger.info(f"Path is: {path}")
    df = pq.ParquetDataset(f"{path}/", filesystem=s3).read_pandas().to_pandas()
    return df
</code>```

my s3 path looks like this- s3://bucket_name/folder/
if I remove path.rstrip('/') from my code, it give me the error-
s3://bucket_name/finance_outbound/folder//xyz.parquet does not exist.
If I keep path.rstrip('/') it gives me the error-
NoSucKey: s3://hvcp-sit-opdata-finance-s3://bucket_name/finance_outbound/folder
I am not sure from where the extra slash adding up or getting removed it respective cases. Any help will be extremely helpful.

Title: AWS Glue- s3fs throws FileNotFoundError

Body:
I am trying to read a parquet file from s3 using s3fs file system using pyarrow but getting NoSuchKey or FileNotFoundError.

def read_parquet_pd(path):
    s3 = s3fs.S3FileSystem()
    path = path.rstrip('/')
    logger.info(f"Path is: {path}")
    df = pq.ParquetDataset(f"{path}/", filesystem=s3).read_pandas().to_pandas()
    return df

my s3 path looks like this- s3://bucket_name/folder/
if I remove path.rstrip('/') from my code, it give me the error-
s3://bucket_name/finance_outbound/folder//xyz.parquet does not exist.
If I keep path.rstrip('/') it gives me the error-
NoSucKey: s3://hvcp-sit-opdata-finance-s3://bucket_name/finance_outbound/folder
I am not sure from where the extra slash adding up or getting removed it respective cases. Any help will be extremely helpful.


问:
In random forest modeling in R software, if the dependent variable is more than two levels, what command should be used instead of the Roc command?
I am facing the error "Error in prediction(pred1[, 2], mydata$Severity) :" in the code that you see when it is executed.

The error at the end of the code is shown in red

I suppose that the error is due to the presence of the roc function, because the dependent variable in my data has more than two levels, and roc is used for the dependent variable with two levels of 0 and 1. Thank you for your guidance on what command to use instead of the roc function? And what changes should I make in the code? Thanks


问:
.NET Core & Entity Framework - complex query
I have a problem with a database query from .NET Core, through Entity Framework; I think it can't be done.

I put you in situation: I have a table of employees and another of actions, with all the actions performed by the user.

Would it be possible, in a single query, to retrieve the entire list of employees, along with the actions they have performed "in the last 30 days"?

When I get the query, I make a query to all the employees that are enabled and I include them in the list of actions, but if I filter in it because the date is less than 30 days and there is no record, the employee does not appear, and I need it to appear with the empty list.

I need all employees with all actions in a period or anything actions if not have it.


问:
Spring Security Filters Authentication
I am relatively new to Srping Security Framework. During my learning period I have tried to implement a basic authentication security  feature for a private api endpoint /private/** . The application also contains a public api /public/** where not filters are applied and is accessible for everyone.
My code is presented below:

Employee.kt

```<code>data class Employee(val name: String, val age: Int)
</code>```

SpringConfig.kt

```<code>@Configuration
@EnableWebSecurity
class SecurityConfig {

    @Bean
    fun securityFilterChain(http: HttpSecurity) : SecurityFilterChain? {
        http
            .authorizeHttpRequests { authz ->
                authz
                    .antMatchers("/private/**").authenticated()
            }
            .formLogin(withDefaults())
        return http.build()
    }

    @Bean
    fun users(): InMemoryUserDetailsManager {
        return InMemoryUserDetailsManager(
            User.withUsername("john")
                .password("{noop}password")
                .authorities("read")
                .build()
        )
    }
}
</code>```

End points:
PublicEmployee.kt

```<code>@RestController
@RequestMapping("/public")
class PublicEmployeeResource {

    @GetMapping("/employee")
    fun getEmployee(): ResponseEntity<Employee> {
        val employee =  Employee(name="John", age=42)
        return ResponseEntity.ok(employee)
    }
}
</code>```

PrivateEmployee.kt

```<code>@RestController
@RequestMapping("/private")
class PrivateEmployeeResource {

    @GetMapping("/employee")
    fun getEmployee(principal: Principal): ResponseEntity<Employee> {
        val employee =  Employee(name="John", age=42)
        println("Principal is ${principal}")
        return ResponseEntity.ok(employee)
    }
</code>```

}

When I am using .formLogin(withDefaults()) for authentication, I get the below picture and I can pass the user and password as stated InMemoryUserDetailsManager.

However if I change the autnetication to  httpBasic() I do get the response from Employee object without any authentication.

Not sure what I am doing wrong.

Also I have read that WebConfigurerAdapter() is going to be deprectated. How I could setup multiple filters for specific url patterns in then ?

Title: Spring Security Filters Authentication

Body:
I am relatively new to Srping Security Framework. During my learning period I have tried to implement a basic authentication security  feature for a private api endpoint /private/** . The application also contains a public api /public/** where not filters are applied and is accessible for everyone.
My code is presented below:

Employee.kt

data class Employee(val name: String, val age: Int)

SpringConfig.kt

@Configuration
@EnableWebSecurity
class SecurityConfig {

    @Bean
    fun securityFilterChain(http: HttpSecurity) : SecurityFilterChain? {
        http
            .authorizeHttpRequests { authz ->
                authz
                    .antMatchers("/private/**").authenticated()
            }
            .formLogin(withDefaults())
        return http.build()
    }

    @Bean
    fun users(): InMemoryUserDetailsManager {
        return InMemoryUserDetailsManager(
            User.withUsername("john")
                .password("{noop}password")
                .authorities("read")
                .build()
        )
    }
}

End points:
PublicEmployee.kt

@RestController
@RequestMapping("/public")
class PublicEmployeeResource {

    @GetMapping("/employee")
    fun getEmployee(): ResponseEntity<Employee> {
        val employee =  Employee(name="John", age=42)
        return ResponseEntity.ok(employee)
    }
}

PrivateEmployee.kt

@RestController
@RequestMapping("/private")
class PrivateEmployeeResource {

    @GetMapping("/employee")
    fun getEmployee(principal: Principal): ResponseEntity<Employee> {
        val employee =  Employee(name="John", age=42)
        println("Principal is ${principal}")
        return ResponseEntity.ok(employee)
    }

}

When I am using .formLogin(withDefaults()) for authentication, I get the below picture and I can pass the user and password as stated InMemoryUserDetailsManager.

However if I change the autnetication to  httpBasic() I do get the response from Employee object without any authentication.

Not sure what I am doing wrong.

Also I have read that WebConfigurerAdapter() is going to be deprectated. How I could setup multiple filters for specific url patterns in then ?


问:
Can we aggregate two columns of covariance matrix into one such that if initial matrix 3x3 then final aggregated matrix is 2x2?
I have to aggregate two columns of cov into one

| 1.2  0.3  0.8 |
| 0.3  0.9  0.1 |
| 0.8  0.1  1.6 |

I would like 2x2 matrix by combining first two columns into one

I would like 2x2 matrix by combining first two columns into one


问:
Can't use variable inside @using{}
I have a foreach and inside it I have a using:

```<code>@foreach (var solution in solutions){
   //some code
   @solution.Id
   @using(Html.BeginForm("somemodel", "Admin", new { @viewName = "viewname" }, FormMethod.Post)){
     @solution.Id
   }
}
</code>```

The problem is that solution.Id has for example value 4 outside and inside the using it is always 1.

The button outside represents the value solution.Id have, the 1 inside the form is the value solution.Id have insiede the using

Can someone explain to me why?

Title: Can't use variable inside @using{}

Body:
I have a foreach and inside it I have a using:

@foreach (var solution in solutions){
   //some code
   @solution.Id
   @using(Html.BeginForm("somemodel", "Admin", new { @viewName = "viewname" }, FormMethod.Post)){
     @solution.Id
   }
}

The problem is that solution.Id has for example value 4 outside and inside the using it is always 1.

The button outside represents the value solution.Id have, the 1 inside the form is the value solution.Id have insiede the using

Can someone explain to me why?


问:
ESP-IDF on Eclipse IDE error with external Library
I am using esp-idf v4.1.1 with different compilers, I have used Visual Studio Code and Eclipse IDE with Espressif tool installed.

My intention is that I want to use an external library that, at the moment, only has a function that does a SHA256 hash for which the openssl sha library (<openssl/sha.h>) is used.

The problem is that I include the library as a component to my project and I call it from the main but I get the following error when building the project.

(https://i.stack.imgur.com/3EECj.png)

If I try it in the Eclipse IDE I get more information about the error and I get "undefined reference to SHA256_INIT()" as for the rest of the functions.

See main.c, dual.c and dual.h code:

main.c:

```<code>#include <stdio.h>
#include "dual.h"

void app_main(void)
{
   printf("Empezamos");

   char * data = "hola";
   char * e =  generateHashSHA256(data);
   printf("%s",e);
}
</code>```

Dual.c:

```<code>#include <stdio.h>
#include "dual.h"

#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
#include <limits.h>
#include <openssl/sha.h>

char * generateHashSHA256(char *data){
  SHA256_CTX ctx;
  u_int8_t results[SHA256_DIGEST_LENGTH];

  int n;

  n = strlen(data);
  SHA256_Init(&ctx);
  SHA256_Update(&ctx, (u_int8_t *)data, n);
  SHA256_Final(results, &ctx);

  char *newString;
  newString = malloc(sizeof(char)*SHA256_DIGEST_LENGTH*2);
  memset(newString, 0, sizeof(char)*SHA256_DIGEST_LENGTH*2);
  for(n=0;n<SHA256_DIGEST_LENGTH;n++)
  {
    printf(newString, "%s%02x", newString, results[n]);
  }

  return newString;
}
</code>```

And Dual.h:

```<code>char * generateHashSHA256(char *data);
</code>```

and CMake files:

CMake of component Dual:

```<code>idf_component_register(SRCS "dual.c"
                    INCLUDE_DIRS "include"
                    )
</code>```

CMake of main folder:

```<code>idf_component_register(SRCS "main.c"
                    INCLUDE_DIRS ".")
</code>```

CMake of project folder:

```<code>cmake_minimum_required(VERSION 3.5)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(template-app)
</code>```

I compiled the library from the terminal with "gcc -o name main.c -lssl -lcrypto" and it works correctly but when compiling it in an esp-idf project nothing...

Please HELP!

I have tried everything, I have included the openssl libraries in all the esp-idf directories, I have put the paths in the CMake... etc.

Body:
I am using esp-idf v4.1.1 with different compilers, I have used Visual Studio Code and Eclipse IDE with Espressif tool installed.

My intention is that I want to use an external library that, at the moment, only has a function that does a SHA256 hash for which the openssl sha library (<openssl/sha.h>) is used.

The problem is that I include the library as a component to my project and I call it from the main but I get the following error when building the project.

(https://i.stack.imgur.com/3EECj.png)

If I try it in the Eclipse IDE I get more information about the error and I get "undefined reference to SHA256_INIT()" as for the rest of the functions.

See main.c, dual.c and dual.h code:

main.c:

#include <stdio.h>
#include "dual.h"

void app_main(void)
{
   printf("Empezamos");

   char * data = "hola";
   char * e =  generateHashSHA256(data);
   printf("%s",e);
}

Dual.c:

#include <stdio.h>
#include "dual.h"

#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
#include <limits.h>
#include <openssl/sha.h>

char * generateHashSHA256(char *data){
  SHA256_CTX ctx;
  u_int8_t results[SHA256_DIGEST_LENGTH];

  int n;

  n = strlen(data);
  SHA256_Init(&ctx);
  SHA256_Update(&ctx, (u_int8_t *)data, n);
  SHA256_Final(results, &ctx);

  char *newString;
  newString = malloc(sizeof(char)*SHA256_DIGEST_LENGTH*2);
  memset(newString, 0, sizeof(char)*SHA256_DIGEST_LENGTH*2);
  for(n=0;n<SHA256_DIGEST_LENGTH;n++)
  {
    printf(newString, "%s%02x", newString, results[n]);
  }

  return newString;
}

And Dual.h:

char * generateHashSHA256(char *data);

and CMake files:

CMake of component Dual:

idf_component_register(SRCS "dual.c"
                    INCLUDE_DIRS "include"
                    )

CMake of main folder:

idf_component_register(SRCS "main.c"
                    INCLUDE_DIRS ".")

CMake of project folder:

cmake_minimum_required(VERSION 3.5)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(template-app)

I compiled the library from the terminal with "gcc -o name main.c -lssl -lcrypto" and it works correctly but when compiling it in an esp-idf project nothing...

Please HELP!

I have tried everything, I have included the openssl libraries in all the esp-idf directories, I have put the paths in the CMake... etc.


问:
Access and create pull request on external/different repository
I have a CMS software using Javascript that I use to manage data. I want to take the changed data, make transformations, and open a PR on a different repository either through GitHub API or something on that line that includes those changes on static files of that external repo. How would I go about the actual changes themselves? Is it possible to fork just the directory with the static files inside my CMS repo, make the changes and open the PR through the API? Could I change repos make the changes and then return to the CMS repo? Or is this not possible at all?

Apologies in advance if this was answered previously but I can't find a possible solution to my problem. Thank you


问:
Restrict connections from current user on TCP socket
I have the following Electron-ish usecase:

User creates a http daemon listening on connections from local host on port X

User launches web browser and goes to http://localhost:X

Since the http daemon was created by the current user, it shares its permissions (which for this application must be correct).

Problem: Any user may on current machine may connect to the server, which means that private data is shared among all users. Is it possible solve this on system level, like changing permissions on file descriptors, or is it necessary to use some kind of login scheme.


问:
Firebase Login with Google: Only let one pre existing email in
Its a admin panel and there only one email that need to be logged in to the admin panel. Right now every email gets logged in to the panel. I've manually added a user (email and password) to the 'Users' in Firebase. Now I want to only let that email in using Google Auth Provider. Is there a way to do this? There's a provider.setCustomParameters() but that's only for email domains, not for complete email. Right now my function looks like this;

```<code> const signInWithGoogle = async () => {
    const provider = new GoogleAuthProvider();
    try {
      auth.signInWithPopup(provider).then((result) => {
      });
    } catch (error) {}
  };
</code>```

I want something like this (this doesn't work)

```<code>provider.setCustomParameters({
   email: "example@gmail.com" //only let in this email user
})
</code>```

Body:
Its a admin panel and there only one email that need to be logged in to the admin panel. Right now every email gets logged in to the panel. I've manually added a user (email and password) to the 'Users' in Firebase. Now I want to only let that email in using Google Auth Provider. Is there a way to do this? There's a provider.setCustomParameters() but that's only for email domains, not for complete email. Right now my function looks like this;

 const signInWithGoogle = async () => {
    const provider = new GoogleAuthProvider();
    try {
      auth.signInWithPopup(provider).then((result) => {
      });
    } catch (error) {}
  };

I want something like this (this doesn't work)

provider.setCustomParameters({
   email: "example@gmail.com" //only let in this email user
})


问:
IOptions validation error occurs when trying to run a dotnet app
I have built a Discord bot app with C# and I'm trying to run it using dotnet app.dll, but I instantly encounter an error:
Microsoft.Extensions.Options.OptionsValidationException: A validation error has occurred.

This issue does not happen if I use the dotnet run command from the project directory. The bot itself is running on a Ubuntu VPS.

Here is how I register the options to services:

IHost host = Host.CreateDefaultBuilder(args)
        .UseSerilog()
        .ConfigureDiscordHost((context, config) => {
           // ...
        })
        .UseInteractionService((context, config) =>
        {
           // ...
        })
        .ConfigureAppConfiguration((context, config) =>
        {
            config.SetBasePath(context.HostingEnvironment.ContentRootPath);
            config.AddJsonFile("words_list.json");
        })
        .ConfigureServices((context, services) =>
        {
            // ...
            services.Configure<BotOptions>(options => context.Configuration.GetSection("BotOptions").Bind(options));
            services.AddOptions<WordSearchSettings>().Bind(context.Configuration);
            services.Configure<HostOptions>(
                    opts => opts.ShutdownTimeout = TimeSpan.FromSeconds(15));
        })
        .Build();

    await host.RunAsync(); // Error occurs here.
```
<p>And the WordSearchSettings class itself:</p>
<pre class="lang-cs prettyprint-override"><code>public struct WordSearchDifficulty
{
    public int StartTimestamp { get; set; }
    public int EndTimestamp { get; set; }
    public int WordsInGrid { get; set; }
    public int GridSize { get; set; }
    public string Message { get; set; }
    public List<string> Words { get; set; }
}

public class WordSearchSettings
{
    public Dictionary<string, WordSearchDifficulty> Difficulties { get; set; }
}
</code>```

I think the issue lies with WordSearchSettings, since I have created a very similar bot before without adding that class.

I have tried using ConfigureAndValidate<TOptions>() method from this package, but it did not fix the issue. There is also almost no information on this error on Google.

Body:
I have built a Discord bot app with C# and I'm trying to run it using dotnet app.dll, but I instantly encounter an error:
Microsoft.Extensions.Options.OptionsValidationException: A validation error has occurred.

This issue does not happen if I use the dotnet run command from the project directory. The bot itself is running on a Ubuntu VPS.

Here is how I register the options to services:

IHost host = Host.CreateDefaultBuilder(args)
        .UseSerilog()
        .ConfigureDiscordHost((context, config) => {
           // ...
        })
        .UseInteractionService((context, config) =>
        {
           // ...
        })
        .ConfigureAppConfiguration((context, config) =>
        {
            config.SetBasePath(context.HostingEnvironment.ContentRootPath);
            config.AddJsonFile("words_list.json");
        })
        .ConfigureServices((context, services) =>
        {
            // ...
            services.Configure<BotOptions>(options => context.Configuration.GetSection("BotOptions").Bind(options));
            services.AddOptions<WordSearchSettings>().Bind(context.Configuration);
            services.Configure<HostOptions>(
                    opts => opts.ShutdownTimeout = TimeSpan.FromSeconds(15));
        })
        .Build();

    await host.RunAsync(); // Error occurs here.

And the WordSearchSettings class itself:

public struct WordSearchDifficulty
{
    public int StartTimestamp { get; set; }
    public int EndTimestamp { get; set; }
    public int WordsInGrid { get; set; }
    public int GridSize { get; set; }
    public string Message { get; set; }
    public List<string> Words { get; set; }
}

public class WordSearchSettings
{
    public Dictionary<string, WordSearchDifficulty> Difficulties { get; set; }
}

I think the issue lies with WordSearchSettings, since I have created a very similar bot before without adding that class.

I have tried using ConfigureAndValidate<TOptions>() method from this package, but it did not fix the issue. There is also almost no information on this error on Google.


问:
the Index file of Categories was inserted with the _Layout interface above?
Can anyone tell me why I created Cate controllers after adding razor view mvc, the Index file of Categories was inserted with the _Layout interface above?
When i put RenderBody() at the top the _Layout is inserted at the end ?

here is img code of Index(Categories), _Layouu

```<code>@model IEnumerable<WebApplication1.Models.Category>

@{
    ViewData["Title"] = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h1>Categories</h1>

public IActionResult Index()
        {
            return View();
        }

        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}
</code>```

enter image description here

enter image description here

enter image description here

Body:
Can anyone tell me why I created Cate controllers after adding razor view mvc, the Index file of Categories was inserted with the _Layout interface above?
When i put RenderBody() at the top the _Layout is inserted at the end ?

here is img code of Index(Categories), _Layouu

@model IEnumerable<WebApplication1.Models.Category>

@{
    ViewData["Title"] = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

Categories

public IActionResult Index()
        {
            return View();
        }

        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}

enter image description here

enter image description here

enter image description here


问:
How to enable wininet cache in WRE
We have a program used httpwebrequest to download and cache, it works on windows, but when running the program in WRE (windows recovery environment), the download performs well, but there's never cache in INetCache folder. I know, the httpwebrequest http-cache control is provided by Wininet.  I wrote a simple code to download and cache via Wininet API, which execute as expected on windows.  But the CreateUrlCacheEntry failed in WRE(windows recovery environment) with errorcode 12004(ERROR_INTERNET_INTERNAL_ERROR).  I know there's should be quite a lot different between windows and WRE. Is there any way to enable http-cache feature in WRE via wininet? e.g., appending some DLL or registry items to WRE? hoping you could give us some guide, which great meaning for us.

I also try downloadurltocachefile, it returns Failed on WRE

Title: How to enable wininet cache in WRE