instruction stringlengths 0 30k ⌀ |
|---|
I am using latest version of primeng i.e 17. While searching in autocomplete after selection of 2-3 items the size of suggestion panel reduced to almost 0. Still the items are present but they are not properly visible. Any particular solution for this ? |
Issue in p-autocomplete virtual scroll in primeng 17 |
|primefaces|primeng|angular17| |
I am very new with power BI and I need dynamically calculate with DAX the distinct count of client that have spend in the analyzed period more than zero.
In the example below if in the report I have the store I expect zero client for store A and 1 for store B. I am not able to have the total spend in the table because this changes depending on what I have in the report. Any recommendation?
|Client| USD|Store|
|------|-----|-----|
|50411542|1000|A|
|50411542|500|A|
|50411542|-2000|A|
|50411542|1000|B| |
|python|python-import|relative-path|python-packaging|relative-import| |
I have a time series with values every 5 minutes. I want to upsample it to have values every 10 seconds (the last known value is repeated) so that I can combine these values with values from another time series providing values every 10s.
How do I do that? Is that even possible? Would it be easier with PromQL in Prometheus? |
How to upsample a time series using Flux (or InfluxQL if easier)? |
I want to do this
[![Text with different colors][2]][2]
from this view model
public class MainWindowViewModel : ViewModelBase
{
public ObservableCollection<TextRun> RunList { get; set; }
public MainWindowViewModel()
{
RunList = new ObservableCollection<TextRun>(new List<TextRun>
{
new TextRun("th", "Red"),
new TextRun("is", "Green"),
new TextRun(" a", "Blue"),
new TextRun(" T", "Yellow"),
new TextRun("es", "Black"),
new TextRun("t!", "Orange"),
new TextRun("!!", "Violet")
});
}
}
public class TextRun
{
public string Text { get; set; }
public string Color { get; set; }
public TextRun(string title, string color)
{
Text = title;
Color = color;
}
}
exactly the same way this extract of the [accepted answer to this similar question][1] suggest:
> You may alternatively want to consider exposing an abstract model of
> text, font, etc. (i.e. a view model) and creating the actual Inline
> objects via a DataTemplate.
i.e. **no code, only axaml**. Sadly, the linked answer doesn't expand on this way of doing things and I need the details. I've spent the last two days trying out different combinations and I'm almost starting to hit my head against the wall. But in principle it should be easy. For instance, if the text were to be on different lines, this would be the axaml:
<ItemsControl ItemsSource="{Binding RunList}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Text}" Foreground="{Binding Color}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
but I need the text with different colors to be on the same line.
I know I must be using runs. This static axaml manages to do exactly that:
<TextBlock>
<Run Text="Th" Foreground="Red"/><Run Text="is" Foreground="Green"/><Run Text=" a" Foreground="Blue"/><Run Text=" t" Foreground="Yellow"/><Run Text="es" Foreground="Black"/><Run Text="t!" Foreground="Orange"/><Run Text="!!" Foreground="Violet"/>
</TextBlock>
But I need it to be "Modelview binded" (Dynamic) as the extract suggest.
I just started playing with Avalonia the day before yesterday, so I'm fumbling in the dark here, please bear with me. So far it feels intuitive. This is the first speed bump I hit.
Included WPF tag because the WPF's xaml solution to this problem should be very similar to Avalonia's axaml. Sadly, I have no WPF experience either.
[1]: https://stackoverflow.com/questions/1959856/data-binding-the-textblock-inlines
[2]: https://i.stack.imgur.com/vosi3.png |
I am developing website to navigate a sample Mastercard payment gateway and I want detect order id after the payment. In my code I set functions (callbacks) beforeRedirect , afterRedirect and completeCallback (Javascript functions) mentioned in documentation. I add js alerts for all functions to check they are working. But afterRedirect function is not working (other call backs are working) .The code seems to be correct. I have doubt that its because of security issues or running on localhost. Have you any idea why afterRidirect not working? Please help to solve this problem.
Here is the sample code.
This method is specifically for the full payment page option. Because we leave this page and return to it, we need to preserve the
state of successIndicator and orderId using the beforeRedirect/afterRedirect option
function afterRedirect(data) {
console.log("afterRedirect", data);
// Compare with the resultIndicator saved in the completeCallback() method
if(resultIndicator === "CANCELED"){
return;
}
else if (resultIndicator) {
var result = (resultIndicator === data.successIndicator) ? "SUCCESS" : "ERROR";
window.location.href = "/hostedCheckout/" + data.orderId + "/" + result;
}
else {
successIndicator = data.successIndicator;
orderId = data.orderId;
sessionId = data.sessionId;
sessionVersion = data.sessionVersion;
merchantId = data.merchantId;
window.location.href = "/hostedCheckout/" + data.orderId + "/" + data.successIndicator + "/" + data.sessionId;
}
This method preserves the current state of successIndicator and orderId, so they're not overwritten when we return to this page after redirect
function beforeRedirect() { console.log("beforeRedirect");
return {
successIndicator: successIndicator,
orderId: orderId
};
} |
Why some functions not working when navigate to the payment gateway? |
|javascript|php|html|payment-gateway|mastercard| |
I followed the readme of grpc-web [helloworld example][1] to setup a local Javascript client that talks to Greeter grpc service using the protoc generated JS client stub via envoy proxy. I switched out the nodejs grpc server with a grpc-java server implemented from the **Greeter.proto** and its working fine.
[![enter image description here][2]][2]
I would like to use nginx instead of envoy for all the communications happening from grpc-web JS client to grpc-java backend server. So, I replaced the envoy with nginx to listen on the same port as envoy ([envoy config][3])
I am using the following nginx configuration:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name _;
location / {
grpc_pass grpc://localhost:9090;
grpc_read_timeout 0s;
grpc_send_timeout 0s;
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, PUT, DELETE, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout' always;
add_header 'Access-Control-Max-Age' 1728000 always;
add_header 'Access-Control-Expose-Headers' 'custom-header-1,grpc-status,grpc-message' always;
add_header 'Content-Type' 'text/plain charset=UTF-8' always;
add_header 'Content-Length' 0 always;
return 204;
}
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, PUT, DELETE, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout' always;
add_header 'Access-Control-Expose-Headers' 'custom-header-1,grpc-status,grpc-message' always;
}
include servers/*;
}
Using this nginx configuration I am getting the following error:
**On browser:**
[![enter image description here][4]][4]
**nginx error_logs:**
2024/03/11 11:02:48 [error] 22103#0: *1 upstream timed out (60: Operation timed out) while reading response header from upstream, client: 127.0.0.1, server: _, request: "POST /helloworld.Greeter/SayHello HTTP/1.1", upstream: "grpc://[::1]:9090", host: "localhost:8080", referrer: "http://localhost:63342/"
2024/03/11 11:02:48 [error] 22103#0: *1 upstream timed out (60: Operation timed out) while reading response header from upstream, client: 127.0.0.1, server: _, request: "POST /helloworld.Greeter/SayRepeatHello HTTP/1.1", upstream: "grpc://127.0.0.1:9090", host: "localhost:8080", referrer: "http://localhost:63342/"
**grpc-java backend server logs:**
> Task :GreeterService.main()
Mar 11, 2024 11:02:12 AM org.example.server.GreeterService start
INFO: Server started...
Mar 11, 2024 11:02:48 AM io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler onDataRead
WARNING: Exception in onDataRead()
java.lang.NullPointerException
at io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler.onDataRead(NettyServerHandler.java:516)
at io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler.access$900(NettyServerHandler.java:111)
at io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler$FrameListener.onDataRead(NettyServerHandler.java:835)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$FrameReadListener.onDataRead(DefaultHttp2ConnectionDecoder.java:307)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$PrefaceFrameListener.onDataRead(DefaultHttp2ConnectionDecoder.java:691)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2InboundFrameLogger$1.onDataRead(Http2InboundFrameLogger.java:48)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2FrameReader.readDataFrame(DefaultHttp2FrameReader.java:415)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2FrameReader.processPayloadState(DefaultHttp2FrameReader.java:250)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2FrameReader.readFrame(DefaultHttp2FrameReader.java:159)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2InboundFrameLogger.readFrame(Http2InboundFrameLogger.java:41)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder.decodeFrame(DefaultHttp2ConnectionDecoder.java:173)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler$FrameDecoder.decode(Http2ConnectionHandler.java:393)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler$PrefaceDecoder.decode(Http2ConnectionHandler.java:250)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler.decode(Http2ConnectionHandler.java:453)
at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:529)
at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:468)
at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290)
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.grpc.netty.shaded.io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.grpc.netty.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.grpc.netty.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)
Mar 11, 2024 11:02:48 AM io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler onDataRead
WARNING: Exception in onDataRead()
java.lang.NullPointerException
at io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler.onDataRead(NettyServerHandler.java:516)
at io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler.access$900(NettyServerHandler.java:111)
at io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler$FrameListener.onDataRead(NettyServerHandler.java:835)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$FrameReadListener.onDataRead(DefaultHttp2ConnectionDecoder.java:307)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$PrefaceFrameListener.onDataRead(DefaultHttp2ConnectionDecoder.java:691)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2InboundFrameLogger$1.onDataRead(Http2InboundFrameLogger.java:48)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2FrameReader.readDataFrame(DefaultHttp2FrameReader.java:415)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2FrameReader.processPayloadState(DefaultHttp2FrameReader.java:250)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2FrameReader.readFrame(DefaultHttp2FrameReader.java:159)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2InboundFrameLogger.readFrame(Http2InboundFrameLogger.java:41)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder.decodeFrame(DefaultHttp2ConnectionDecoder.java:173)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler$FrameDecoder.decode(Http2ConnectionHandler.java:393)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler$PrefaceDecoder.decode(Http2ConnectionHandler.java:250)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler.decode(Http2ConnectionHandler.java:453)
at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:529)
at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:468)
at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290)
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.grpc.netty.shaded.io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.grpc.netty.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.grpc.netty.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)
Mar 11, 2024 11:02:48 AM io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler onStreamError
WARNING: Stream Error
io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2Exception$StreamException:
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2Exception.streamError(Http2Exception.java:173)
at io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler.newStreamException(NettyServerHandler.java:812)
at io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler.onDataRead(NettyServerHandler.java:522)
at io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler.access$900(NettyServerHandler.java:111)
at io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler$FrameListener.onDataRead(NettyServerHandler.java:835)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$FrameReadListener.onDataRead(DefaultHttp2ConnectionDecoder.java:307)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$PrefaceFrameListener.onDataRead(DefaultHttp2ConnectionDecoder.java:691)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2InboundFrameLogger$1.onDataRead(Http2InboundFrameLogger.java:48)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2FrameReader.readDataFrame(DefaultHttp2FrameReader.java:415)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2FrameReader.processPayloadState(DefaultHttp2FrameReader.java:250)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2FrameReader.readFrame(DefaultHttp2FrameReader.java:159)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2InboundFrameLogger.readFrame(Http2InboundFrameLogger.java:41)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder.decodeFrame(DefaultHttp2ConnectionDecoder.java:173)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler$FrameDecoder.decode(Http2ConnectionHandler.java:393)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler$PrefaceDecoder.decode(Http2ConnectionHandler.java:250)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler.decode(Http2ConnectionHandler.java:453)
at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:529)
at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:468)
at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290)
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.grpc.netty.shaded.io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.grpc.netty.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.grpc.netty.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.NullPointerException
at io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler.onDataRead(NettyServerHandler.java:516)
... 32 more
Mar 11, 2024 11:02:48 AM io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler onStreamError
WARNING: Stream Error
io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2Exception$StreamException:
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2Exception.streamError(Http2Exception.java:173)
at io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler.newStreamException(NettyServerHandler.java:812)
at io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler.onDataRead(NettyServerHandler.java:522)
at io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler.access$900(NettyServerHandler.java:111)
at io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler$FrameListener.onDataRead(NettyServerHandler.java:835)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$FrameReadListener.onDataRead(DefaultHttp2ConnectionDecoder.java:307)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$PrefaceFrameListener.onDataRead(DefaultHttp2ConnectionDecoder.java:691)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2InboundFrameLogger$1.onDataRead(Http2InboundFrameLogger.java:48)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2FrameReader.readDataFrame(DefaultHttp2FrameReader.java:415)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2FrameReader.processPayloadState(DefaultHttp2FrameReader.java:250)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2FrameReader.readFrame(DefaultHttp2FrameReader.java:159)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2InboundFrameLogger.readFrame(Http2InboundFrameLogger.java:41)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder.decodeFrame(DefaultHttp2ConnectionDecoder.java:173)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler$FrameDecoder.decode(Http2ConnectionHandler.java:393)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler$PrefaceDecoder.decode(Http2ConnectionHandler.java:250)
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler.decode(Http2ConnectionHandler.java:453)
at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:529)
at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:468)
at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290)
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.grpc.netty.shaded.io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.grpc.netty.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.grpc.netty.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.NullPointerException
at io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler.onDataRead(NettyServerHandler.java:516)
... 32 more
Can someone please help resolve this issue with nginx
[1]: https://github.com/grpc/grpc-web/tree/master/net/grpc/gateway/examples/helloworld
[2]: https://i.stack.imgur.com/IzPev.png
[3]: https://github.com/grpc/grpc-web/blob/master/net/grpc/gateway/examples/helloworld/envoy.yaml
[4]: https://i.stack.imgur.com/olbOo.png
|
grpc-web js client request to grpc-java backend server fails when using nginx instead of envoy |
|java|nginx|grpc|grpc-java|grpc-web| |
|python|python-3.x|pandas| |
Your question explicitly asks for an MVVM compliant way to handle attached UI events (or UI events in general) in the application view model. There is none. Per definition, the view model must not participate in UI logic. There is no reason for the view model to ever handle UI events. All the event handling must take place in the view.
The following UML diagram shows that the view model has to be view agnostic. That's a crucial requirement of the MVVM design pattern.
[![enter image description here][1]][1]
View agnostic of course means that the view model is not allowed to actively participate in UI logic.
While it is technically possible to handle UI events in the application view model, MVVM forbids that and requires that such events are handled in the application view. If you want to implement MVVM correctly because you don't want to allow the UI to bleed into the application, then you must handle such events in the view (in C# aka code-behind aka partial classes).
Copy & Paste are pure *view* operations:
1. They involve the user.
2. They exchange data between two UI elements
3. The event args of a UI event is a `RoutedEventArgs` object.
4. The `RoutedEventArgs` exposes the source **UI** elements (via the sender parameter of the delegate, via the `Source` and `OriginalSource` properties of the event args).
5. The `RoutedEventArgs` enables the handler to directly participate in UI logic (e.g. by marking an event as handled or by cancelling the ongoing UI operation etc.).
6. Routed events are always events that relate to UI interaction or UI behavior in context of UI logic.
7. In general, why would the view model be interested in UI events if there is nothing like a UI or a u ser from the point of view of the view model?
These are all hints that the event should not be handled in the view model. Routed events are *always* events that relate to UI interaction or UI behavior or render logic related - they are declared and raised by UI objects.
The view model must not care about any UI elements e.g. when and how they're changing their size. The `Button.Click` event is the only event that should trigger an operation on the view model. Such elements usually implement `ICommandSource` to eliminate the event subscription. However, there is nothing wrong with handling the `Click` event in code-behind and delegating the operation to the view model from there.
Passing all that UI objects to the view model (via the event args) is also a clear MVVM violation.
Participating in UI logic (copy & paste) is another MVVM violation. You must either handle the `Pasting` event in the code-behind of a control or implement property validation by letting your view model class implement `INotifyDataErrorInfo`.
From an UX point of view it is *never* a good idea to swallow a user action.
You must always give feedback so that the user can learn that his action is not supported. If you can't prevent it in the first place e.g. by disabling interaction which is usually visualized by grayed out elements, then you must provide error information that explains why the action is not allowed and how to fix it. Data validation is the best solution.
For example, when you fill in a registration form in a web application and enter/paste invalid data to the input field, your action is not silently swallowed.
Instead, you get a red box around the input field and an error message. `INotifyDataErrorInfo` does exactly the same. **And it does not violate MVVM**.
The recommended MVVM way to achieve your task is to implement `INotifyDataErrorInfo`. See [How to add validation to view model properties or how to implement INotifyDataErrorInfo][2].
A less elegant but still a valid MVVM solution is to implement the event handling of the `DataObject.Pasting` attached event in the view and cancelling the command from code-behind. Note that this solution can violate several UI design rules. You must at least provide proper error feedback to the user.
For your particular case, you should consider implementing a `NumericTextBox`. This is also an elegant solution where the input validation is completely handled by the input field. The control can provide data validation by implementing `Binding` validation e.g. defining a `ValidationRule`. You will get a convenient way to show a red box (customizable) and an error message to the user.
An example `NumericTextBox` that also handles pasted content:
**NumericValidationRule.cs**
The `ValidationRule` used by the `NumericTextBox` to validate the input. The rule is also passed to the binding engine in order to enable the visual validation error feedback that is built into the framework.
```c#
public class NumericValidationRule : ValidationRule
{
private readonly string nonNumericErrorMessage = "Only numeric input allowed.";
private readonly string malformedInputErrorMessage = "Input is malformed.";
private readonly string decimalSeperatorInputErrorMessage = "Only a single decimal seperator allowed.";
private TextBox Source { get; }
public NumericValidationRule(TextBox source) => this.Source = source;
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
ArgumentNullException.ThrowIfNull(cultureInfo, nameof(cultureInfo));
if (value is not string textValue
|| string.IsNullOrWhiteSpace(textValue))
{
return new ValidationResult(false, this.nonNumericErrorMessage);
}
if (IsInputNumeric(textValue, cultureInfo))
{
return ValidationResult.ValidResult;
}
// Input was can still be a valid special character
// like '-', '+' or the decimal seperator of the current culture
ValidationResult validationResult = HandleSpecialNonNumericCharacter(textValue, cultureInfo);
return validationResult;
}
private bool IsInputNumeric(string input, IFormatProvider culture) =>
double.TryParse(input, NumberStyles.Number, culture, out _);
private ValidationResult HandleSpecialNonNumericCharacter(string input, CultureInfo culture)
{
ValidationResult validationResult;
switch (input)
{
// Negative sign is not the first character
case var _ when input.LastIndexOf(culture.NumberFormat.NegativeSign, StringComparison.OrdinalIgnoreCase) != 0:
validationResult = new ValidationResult(false, this.malformedInputErrorMessage);
break;
// Positivre sign is not the first character
case var _ when input.LastIndexOf(culture.NumberFormat.PositiveSign, StringComparison.OrdinalIgnoreCase) != 0:
validationResult = new ValidationResult(false, this.malformedInputErrorMessage);
break;
// Allow single decimal separator
case var _ when input.Equals(culture.NumberFormat.NumberDecimalSeparator, StringComparison.OrdinalIgnoreCase):
{
bool isSingleSeperator = !this.Source.Text.Contains(culture.NumberFormat.NumberDecimalSeparator, StringComparison.CurrentCultureIgnoreCase);
validationResult = isSingleSeperator ? ValidationResult.ValidResult : new ValidationResult(false, this.decimalSeperatorInputErrorMessage);
break;
}
default:
validationResult = new ValidationResult(false, this.nonNumericErrorMessage);
break;
}
return validationResult;
}
}
```
**NumericTextBox.cs**
```c#
class NumericTextBox : TextBox
{
private ValidationRule NumericInputValidationRule { get; set; }
static NumericTextBox()
=> DefaultStyleKeyProperty.OverrideMetadata(typeof(NumericTextBox), new FrameworkPropertyMetadata(typeof(NumericTextBox)));
public NumericTextBox()
{
this.NumericInputValidationRule = new NumericValidationRule(this);
DataObject.AddPastingHandler(this, OnContentPasting);
}
private void OnContentPasting(object sender, DataObjectPastingEventArgs e)
{
if (!e.DataObject.GetDataPresent(DataFormats.Text))
{
e.CancelCommand();
ShowErrorFeedback("Only numeric content supported.");
return;
}
string pastedtext = (string)e.DataObject.GetData(DataFormats.Text);
CultureInfo culture = CultureInfo.CurrentCulture;
ValidationResult validationResult = ValidateText(pastedtext, culture);
if (!validationResult.IsValid)
{
e.CancelCommand();
}
}
#region Overrides of TextBoxBase
/// <inheritdoc />
protected override void OnTextInput(TextCompositionEventArgs e)
{
CultureInfo culture = CultureInfo.CurrentCulture;
string currentTextInput = e.Text;
// Remove any negative sign if '+' was pressed
// or prepend a negative sign if '-' was pressed
if (TryHandleNumericSign(currentTextInput, culture))
{
e.Handled = true;
return;
}
ValidationResult validationResult = ValidateText(currentTextInput, culture);
e.Handled = !validationResult.IsValid;
if (validationResult.IsValid)
{
base.OnTextInput(e);
}
}
#endregion Overrides of TextBoxBase
private ValidationResult ValidateText(string currentTextInput, CultureInfo culture)
{
ValidationResult validationResult = this.NumericInputValidationRule.Validate(currentTextInput, culture);
if (validationResult.IsValid)
{
HideErrorFeedback();
}
else
{
ShowErrorFeedback(validationResult.ErrorContent);
}
return validationResult;
}
private bool TryHandleNumericSign(string input, CultureInfo culture)
{
int oldCaretPosition = this.CaretIndex;
// Remove any negative sign if '+' pressed
if (input.Equals(culture.NumberFormat.PositiveSign, StringComparison.OrdinalIgnoreCase))
{
if (this.Text.StartsWith(culture.NumberFormat.NegativeSign, StringComparison.OrdinalIgnoreCase))
{
this.Text = this.Text.Remove(0, 1);
// Move the caret to the original input position
this.CaretIndex = oldCaretPosition - 1;
}
return true;
}
// Prepend the negative sign if '-' pressed
else if (input.Equals(culture.NumberFormat.NegativeSign, StringComparison.OrdinalIgnoreCase))
{
if (!this.Text.StartsWith(culture.NumberFormat.NegativeSign, StringComparison.OrdinalIgnoreCase))
{
this.Text = this.Text.Insert(0, culture.NumberFormat.NegativeSign);
// Move the caret to the original input position
this.CaretIndex = oldCaretPosition + 1;
}
return true;
}
return false;
}
private void HideErrorFeedback()
{
BindingExpression textPropertyBindingExpression = GetBindingExpression(TextProperty);
bool hasTextPropertyBinding = textPropertyBindingExpression is not null;
if (hasTextPropertyBinding)
{
Validation.ClearInvalid(textPropertyBindingExpression);
}
}
private void ShowErrorFeedback(object errorContent)
{
BindingExpression textPropertyBindingExpression = GetBindingExpression(TextProperty);
bool hasTextPropertyBinding = textPropertyBindingExpression is not null;
if (hasTextPropertyBinding)
{
// Show the error feedbck by triggering the binding engine
// to show the Validation.ErrorTemplate
Validation.MarkInvalid(
textPropertyBindingExpression,
new ValidationError(
this.NumericInputValidationRule,
textPropertyBindingExpression,
errorContent, // The error message
null));
}
}
}
```
**Generic.xaml**
```xaml
<Style TargetType="local:NumericTextBox">
<Style.Resources>
<!-- The visual error feedback -->
<ControlTemplate x:Key="ValidationErrorTemplate1">
<StackPanel>
<Border BorderBrush="Red"
BorderThickness="1"
HorizontalAlignment="Left">
<!-- Placeholder for the NumericTextBox itself -->
<AdornedElementPlaceholder x:Name="AdornedElement" />
</Border>
<Border Background="White"
BorderBrush="Red"
Padding="4"
BorderThickness="1"
HorizontalAlignment="Left">
<ItemsControl ItemsSource="{Binding}"
HorizontalAlignment="Left">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding ErrorContent}"
Foreground="Red" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Border>
</StackPanel>
</ControlTemplate>
</Style.Resources>
<Setter Property="Validation.ErrorTemplate"
Value="{StaticResource ValidationErrorTemplate1}" />
<Setter Property="BorderBrush"
Value="{x:Static SystemColors.ActiveBorderBrush}" />
<Setter Property="BorderThickness"
Value="1" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:NumericTextBox">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}">
<ScrollViewer Margin="0"
x:Name="PART_ContentHost" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled"
Value="False">
<Setter Property="Background"
Value="{x:Static SystemColors.ControlLightBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
```
[1]: https://i.stack.imgur.com/v71wU.png
[2]: https://stackoverflow.com/a/56608064/3141792 |
I keep coming up against this issue, so I would be grateful for shared insights from the resident experts. I can't be the only one who keeps encountering this.
I know I'm using old hardware, but I'm interested in the relevant issues for this sort of hardware and newer. I'm using a 3.2 GHz Ivy Bridge Xeon with 32 GB ECC RAM. It has only 8MB L3 Cache, but since I'm performing random reads and writes on multi-gigabyte buffers, I don't think the L3 cache size is very relevant to this question.
I've found it takes ~100 to read and update a 64 bit integer in a random position in a large buffer of the same. The buffer is aligned so it should only need to load one cache lane for each update. In a single threaded application, that means I get around 10-15 million updates per second. Supposing I had millions of independent such updates to perform, is there a faster way of getting that work done than processing them in sequence? I know I could multi-thread the application, but with only a few hundred cycles latency, does that mean it wouldn't be worth having more threads than cpu cores? I'm looking more for 10X+ speedup not just 2-4X. I have an OpenCL program which does this on an old Tesla GPU with GDDR5 RAM and I can get well over a billion updates per second, but efficient GPU programming is difficult and not friendly to branching code.
My Ivy Bridge CPU doesn't support AVX Gather/Scatter instructions. Would these instructions issue requests for all elements before necessarily receiving any of the responses from memory, or do they serialise the memory requests? The reported cycles per instruction are meaningless in this context because they would be mostly requesting data not in cache already. If they can be used to hide the latency and get multiple elements at once though, that could be really useful.
I don't think there is, but am I missing a trick here? Is there some way in c to use non-blocking memory reads/writes? Many Thanks. |
Custom FormRequest redirects to web route in Laravel 11 |
|php|laravel| |
In Flutter, is there a way to determine the user's skin color settings for their emojis? |
I am using Next.js 14 with App Router. This works both for `/@username` and nested paths like `/@username/about`:
```js
const nextConfig = {
async rewrites() {
return [
{
source: '/@:username/:path*',
destination: '/users/:username/:path*',
},
]
},
}
``` |
The Compose documentation e.g. [here][1] mentions, that `Modifier.drawBehind` only affects the drawing phase, other phases are not re-executed when this modifier changes. But how does Jetpack Compose know that e.g. `Modifier.drawBehind` only affects the drawing phase?
[1]: https://developer.android.com/develop/ui/compose/phases#phase3-drawing |
{"Voters":[{"Id":2675154,"DisplayName":"honk"},{"Id":9214357,"DisplayName":"Zephyr"},{"Id":14732669,"DisplayName":"ray"}],"SiteSpecificCloseReasonIds":[16]} |
Pre-compile the expression and its Jacobian to function objects, then pass them into `minimize`. Note that it attempts to be somewhat smarter than your intended gradient descent which may or may not be helpful; this defaults to Kraft's sequential least-squares programming method.
```python
import string
import numpy as np
import scipy.optimize
import sympy
expr_str = (
'0.2*a**3 - 0.1*a**2*b - 0.9*a**2*c + 0.5*a**2 - 0.1*a*b**2 - 0.4*a*b*c '
'+ 0.5*a*b - 0.6*a*c**2 - 0.5*a*c - 0.6*a - 0.1*b**3 + 0.4*b**2*c '
'- 0.4*b**2 + 0.7*b*c**2 - 0.4*b*c + 0.9*b + 0.09*c**3 - 0.6*c**2 + 0.4*c + 0.22'
)
symbols = {
c: sympy.Symbol(name=c, real=True, finite=True)
for c in string.ascii_lowercase
if c in expr_str
}
expr = sympy.parse_expr(s=expr_str, local_dict=symbols)
expr_callable = sympy.lambdify(
args=[symbols.values()], expr=expr,
)
jac = [
sympy.diff(expr, sym)
for sym in symbols.values()
]
jac_callable = sympy.lambdify(
args=[symbols.values()], expr=jac,
)
result = scipy.optimize.minimize(
fun=expr_callable,
jac=jac_callable,
x0=np.zeros(len(symbols)),
bounds=scipy.optimize.Bounds(lb=-1, ub=1),
)
assert result.success
print(result)
```
```none
CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL
message: CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL
success: True
status: 0
fun: -4.020346688237437
x: [ 5.139e-01 -1.000e+00 -1.000e+00]
nit: 5
jac: [-1.222e-08 3.839e+00 4.398e+00]
nfev: 7
njev: 7
hess_inv: <3x3 LbfgsInvHessProduct with dtype=float64>
```
If you really want a symbolic solution to `a` where `b` and `c` are equal to -1, you can then work backward, substituting `b` and `c` into the first Jacobian component and solving for `a`.
```python
jac_rhs = jac[0].subs({
symbols['b']: result.x[1],
symbols['c']: result.x[2],
})
print(jac_rhs)
soln = sympy.solve(jac_rhs, symbols['a'],
dict=True, numerical=False, simplify=False, rational=True)
pprint(soln)
```
```none
0.6*a**2 + 3.0*a - 1.7
[{a: -5/2 + sqrt(327)/6}, {a: -sqrt(327)/6 - 5/2}]
```
|
The default values of **BlockDeviceMappings** in json format is:
```json
BlockDeviceMappings: [{
DeviceName: '/dev/sda1',
Ebs: {
DeleteOnTermination: true,
SnapshotId: 'snap-06e838ce2a80337a4',
VolumeSize: 8,
VolumeType: 'gp2',
Encrypted: false,
},
}
```
Notes:
- SnapshotId change on every instance
- Full json request is here: https://gist.github.com/jrichardsz/f3ec44a044293b54af3dbff309fe5c83#file-aws-ec2-snippets-full-request-json
|
I need to write a function in JavaScript for calculating the in-tangents and out-tangents of a cubic Bézier curve, knowing the following: start control point (x1, y1), end control point (x2, y2) and end point (x, y). Please help! |
JS function for calculating tangents in a cubic Bézier curve |
|derivative|cubic-bezier| |
I am trying to make a PDF generator based on a html files using Google Apps Script. Unfortunately I am not able to apply custom font for this. I came up with the idea to load the font in base64 format, but it is not working for me. What am I missing?
I have tried to use `@font-face` with google fonts, but it seems that it is not fetched before conversion (works fine when getting `doGet(e)` from deployed script).
Here is the code:
Function:
```js
function htmlToPdf() {
var fileIdOfFontFile = "1xXWmKZ2wRzWq_4DWfeIK67QKFVkF_nVu";
var fontBlob = DriveApp.getFileById(fileIdOfFontFile).getBlob();
var htmlTemplate = HtmlService.createTemplateFromFile("site");
htmlTemplate.fontData = fontBlob.getContentType() + ';base64,' + Utilities.base64Encode(fontBlob.getBytes());
var pdf_html = htmlTemplate.evaluate().getContent();
var blob = Utilities.newBlob(pdf_html, MimeType.HTML).getAs(MimeType.PDF);
DriveApp.createFile(blob);
}
```
html:
```html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<style>
@font-face {
font-family: "Gloria Hallelujah";
src: url(<?= fontData ?>);
}
* {
font-family: "Gloria Hallelujah";
}
</style>
<body>
<p>test</p>
</body>
</html>
``` |
How to use custom font during html to pdf conversion? |
|html|css|google-apps-script|pdf|base64| |
null |
I have a dataframe from a CSV file with fields for latitude and longitude. I want to convert the df to a geodataframe of points with the lat and lon fields. When I map the points, the points show up in the wrong place (i.e., middle of the ocean).
I checked my gdf against another version of the gdf and confirmed that the lat/long fields and geometry fields are the same for observations with the same ID (this correct gdf is missing observations so I can't use it.) What am I missing? Thanks
Here is my code:
```
geometry = [Point(xy) for xy in zip(df['lon'], df['lat'])]
new_gdf = gpd.GeoDataFrame(df,crs='EPSG:4326',geometry=geometry)
new_gdf.to_crs('EPSG:2229',inplace=True) # convert to projection that I want to map in
new_gdf.plot()
``` |
Python Geopandas unable to convert latitude longitude to points |
|python|geopandas| |
null |
It looks like you use `push` to add children to `Data`, which means you can use this approach to get only the most recently added child node:
dbReference = db.getReference("Data");
Query query = dbReference.orderByKey().limitToLast(1);
query.addValueEventListener(new ValueEventListener() {
...
Also see the Firebase documentation on:
* [Adding an item to a list](https://firebase.google.com/docs/database/android/lists-of-data#append_to_a_list_of_data)
* [Sorting and filtering data](https://firebase.google.com/docs/database/android/lists-of-data#sorting_and_filtering_data) |
Data binding the TextBlock Runs in Avalonia |
|c#|wpf|data-binding|avaloniaui|avalonia| |
I want similar functionality of scrolling section to section using window.addEventListener('scroll', function); in my nextjs app similar to https://www.elsner.com/ . Please look into this while i am using scroll it conitnously scrolling to sections to sections.
My Code:
const options = {
root: null,
rootMargin: '0px',
threshold: 1.0,
};
const homeref = useRef(null);
const mainref = useRef(null);
const aboutref = useRef(null);
const servicesref = useRef(null);
const solutionsref = useRef(null);
const idoref = useRef(null);
const contactref = useRef(null);
const [mainactive, setmainactive] = useState('home');
const scrollto = (id) => {
scroller.scrollTo(id, {
duration: 1000,
delay: 0,
smooth: 'easeInOutQuart',
});
};
const itemset = (id, scroll) => {
setmainactive(id);
scrollto(scroll);
return;
};
const handleScroll = (direction) => {
const sections = ['home', 'about', 'services', 'ido', 'solutions', 'contact'];
const currentIndex = sections.indexOf(mainactive);
let newIndex = currentIndex;
if (direction === 'down') {
if (mainactive === 'about') {
const aboutBottom = aboutref.current.getBoundingClientRect().bottom;
if (aboutBottom <= window.innerHeight) {
newIndex = currentIndex < sections.length - 1 ? currentIndex + 1 : currentIndex;
}
} else {
newIndex = currentIndex < sections.length - 1 ? currentIndex + 1 : currentIndex;
}
} else if (direction === 'up') {
newIndex = currentIndex > 0 ? currentIndex - 1 : currentIndex;
}
const nextSection = sections[newIndex];
if (nextSection !== mainactive) {
setmainactive(nextSection);
scrollto(nextSection);
}
};
useEffect(() => {
const handleKeyDown = (event) => {
const wheeldown = event.wheelDeltaY < 0 || event.deltaY > 0;
const wheelup = event.wheelDeltaY > 0 || event.deltaY < 0;
if (event.key === 'ArrowDown' || wheeldown || event.key === 'ArrowRight') {
if ((mainactive === 'home' && window.scrollY > 0) || mainactive === 'about') {
setmainactive('about');
handleScroll('down');
} else if (mainactive === 'about') {
handleScroll('down');
} else if (mainactive === 'services') {
handleScroll('down');
} else if (mainactive === 'ido') {
handleScroll('down');
}
} else if (event.key === 'ArrowUp' || wheelup || 'ArrowLeft') {
if (mainactive === 'services' || mainactive === 'ido' || mainactive == 'solutions') {
handleScroll('up');
} else if (mainactive === 'about') {
setTimeout(() => {
setmainactive('home');
}, 1000);
scrollto('home');
}
}
};
window.addEventListener('keydown', handleKeyDown);
window.addEventListener('wheel', handleKeyDown);
window.addEventListener('touchmove', handleKeyDown, { passive: false });
return () => {
window.removeEventListener('keydown', handleKeyDown);
window.removeEventListener('wheel', handleKeyDown);
};
}, [mainactive]);
It is working fine on keys as same as i want using scroll. |
I am new to lasio so maybe I am missing some existing parameter.
All I want to do is read a LAS file , make some changes in well, curve , parameter and other section and write them back to LAS files.
But the issue is during writing operation all commented out lines are getting removed as they were not read by lasio at first place.
Suggest if there is some way in lasio to read commented out lines.
I read through documents but found nothing convincing. |
Using lasio.read() , read commented out lines(#) and preserve those lines while writing to Las |
|python-3.x|las| |
null |
I am a super beginner to programming so I have had ChatGPT help me build this toolbox. The one thing I cannot get to work right now is having a few buttons ping servers (localhost for testing) and display the response to the front end. Anything I am missing here?
```
<h2>Server Status:</h2>
<div class="button-container server-status">
<h3>DNS East:</h3>
<button class="server-button" data-location="DNS East" data server="localhost">Localhost</button>
<button class="server-button" data-location="DNS East" data-server="server1">server1</button>
<button class="server-button" data-location="DNS East" data-server="server2">server2</button>
</div>
```
```
// Add event listeners to server status buttons
document.querySelectorAll('.server-status button').forEach(button => {
button.addEventListener('click', () => {
const location = button.parentElement.querySelector('h3').textContent.trim();
const server = button.textContent.trim();
getServerStatus(location, server, button.parentElement); // Pass parent element as parameter
});
});
function getServerStatus(location, server, parentElement) {
// Make a GET request to the Flask route to get the server status
fetch(`/server_status/${location}/${server}`)
.then(response => response.text())
.then(data => {
// Display the server status on the screen
const statusDiv = document.createElement('div');
statusDiv.textContent = `${server}: ${data}`;
if (data.includes('1 packets received')) { // Check for the specific pattern indicating a successful ping response
statusDiv.style.color = 'green'; // Set text color to green
} else {
statusDiv.style.color = 'red'; // Set text color to red
}
parentElement.appendChild(statusDiv);
})
.catch(error => console.error('Error:', error));
}
```
```
# Server Status Dictionary
SERVER_STATUS = {
'DNS East': ['localhost', 'server1', 'server2']
}
# Ping Server Function
def ping_server(server):
"""Ping the specified server and return the result."""
command = ['ping', '-c', '1', server] # Linux command for pinging a server once
result = subprocess.run(command, capture_output=True, text=True)
return result.stdout # Return the ping result
```
I think it might be something on the frontend or JS side but I am not sure yet. |
You can use [`Series.str.extract`](https://pandas.pydata.org/docs/reference/api/pandas.Series.str.extract.html) like so:
```python
df["Alternative"] = df["Desc"].str.extract(r"(\d{8,12})")
```
This applies the regex `r"(\d{8,12})"` ([explained here](https://regex101.com/r/Hndt1Z/1)) over each row. The values in the resultant column will be strings unless you convert them to integers. |
Create a middleware.ts (or .js) in the root of your project. (https://nextjs.org/docs/app/building-your-application/routing/middleware)
import { NextResponse } from 'next/server';
export function middleware(request: Request) {
const requestHeaders = new Headers(request.headers);
requestHeaders.set('x-url', request.url);
return NextResponse.next({
request: {
headers: requestHeaders
}
});
}
then use headers in your layout or page. (https://nextjs.org/docs/app/api-reference/functions/headers#headers)
const requestUrl = headers().get('x-url') |
const imageUpdater = async (imagePublicId, imagePath) => {
try {
const result = await cloudinary.uploader.upload(imagePath, {
public_id: imagePublicId,
})
return result
} catch (error) {
throw new AppError(
StatusCodes.BAD_REQUEST,
"Cannot update image. Please try again."
)
}
} |
In know MySQL (MariaDB) functions and the case statement but how to combine the two?
I'm implementing a TO_STR translate function where I don't want to pollute the database with addtional tables. This is what I tried:
```SQL
CREATE FUNCTION CODE_TO_STR(CODE CHAR(4)) RETURN VARCHAR(50) AS
BEGIN
RETURN SELECT
CASE CODE
WHEN '1' THEN 'Code is one'
WHEN '2' THEN 'Code is two'
ELSE CODE
END;
END;
```
which gives an 1061 error. |
How to use a case statement in mysql function |
|mariadb|mysql-function| |
No, it's a division by zero error, which means that you at some point try to perform this pattern
```
a / b
```
where `b` is 0. In mathematics division by zero is a special problem.
Let's suppose that you divide a / 0 and let's suppose its result is r:
a / 0 = r
Now, let's multiply the equation with 0, so we get:
a = 0 * r
so, for which r is it true that a = 0 * r? The answer is that it's true for any r, as long as a is 0. But it's false for any r as long as a is not 0.
Therefore:
```
a / 0
```
makes no sense if a <> 0 and a / 0 could be anything if a = 0.
So, division by zero is a special case in mathematics and programming languages handle this issue.
Since your denominator do not depend on the values of `var1` or `var2`, the problem we discuss is completely independent on how you pass them and the problem is that you divide by zero. To solve your problem you will need to make sure you do not divide by zero, so you check whether the denominator is zero, put a default in there if so and do the division otherwise. Something like:
```
case
when denominator = 0 then 100
else numerator / denominator
end
``` |
[![enter image description here][1]][1]
i used the above code in selenium 4.16.0, chrome-120.0.6099.217
```python
from selenium.webdriver.edge.service import Service
service_obj = Service()
driver = webdriver.Chrome(service=service_obj)
driver.get("https://google.com")
```
[1]: https://i.stack.imgur.com/bMTRZ.png |
In accountsList.vue i call the following script where i commented a lot out because im doing a serious refactor and i wanted to isolate the problem. "balance" has a proper value and is set, i checked.
<script setup>
import Account from "@/Pages/Partials/AccountItem.vue";
import {UseAccountsStore} from "@/Stores/UseAccountsStore.js"
const props = defineProps({
editMode: Boolean,
balance: Object
})
const accountsStore = UseAccountsStore();
// console.log(props.balance)
accountsStore.balance = props.balance;
accountsStore.getAccounts()
// const balanceStore = UseBalanceStore()
// const balanceItemsStore = UseCategoryItemsStore()
function update() {
// accountsStore.getTotal()
// balanceStore.getGrandTotal()
}
This is my UseAccountsStore
import {defineStore} from "pinia";
import {ref} from "vue";
export const UseAccountsStore = defineStore('AccountStore', () => {
const balance = ref(null)
const accounts = ref([])
const total = ref(0)
function getAccounts() {
console.log(balance);
axios.get(route('accounts.index', {'id': balance.value.id}))
.then((response) => accounts.value = response.data)
}
function getTotal() {
axios.get(route('accounts.total'))
.then((response) => total.value = response.data)
}
function addAccount(account) {
accounts.value.push(account)
}
return {accounts, total, getAccounts, getTotal, addAccount}
})
What i don't get is that my "console.log(balance);" returns null. I tried to use a setter but that also results in a null value. Does anyone know why? What am i doing wrong? |
null |
null |
I'm trying to execute `kubectl` commands in python
```python
process = subprocess.run(["kubectl", "get", "pods", "-n", "argocd"])
```
which throws error:
```none
__main__ - INFO -
E0328 08:18:04.126243 25976 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused
E0328 08:18:04.126801 25976 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused
E0328 08:18:04.129854 25976 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused
E0328 08:18:04.130344 25976 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused
E0328 08:18:04.131804 25976 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused
The connection to the server localhost:8080 was refused - did you specify the right host or port?
__main__ - ERROR - Failed to get po.
NoneType: None
```
But when I execute the same command manually from the master node I see output without any issues.
Can someone help me figure out what's the issue here? |
|java|android|firebase|firebase-realtime-database| |
null |
null |
null |
null |
The answer is to use the following schedule: `0 0/3 * * *` in conjunction with an appropriate `start_date` and `end_date`.
I used [crontab.guru][1] to design the CRON expression. You can click on the `next` button to have examples of the following executions.
[1]: https://crontab.guru/#0_0/3_*_*_* |
I need the Birt.war that is compatible with JAVA 17 and Tomcat 10. We have a birt.war file but it worked with JAVA 8 and its ancient. I need a new one or preferably the project so I can build it myself. All the links I see for the birt war say file unavailable. Can some one please help me by posting a link to a birt war that will work with JAVA 17 or any any Java past 9. Thank you in advanced
I have been searching the internet for about a week. I tried using the old war and I got javax errors, because Java 17 doesn't have javax anymore. |
I need the BIRT.war that is compatible with Java 17 and Tomcat 10 |
|java|eclipse|birt|tomcat10| |
null |
Having prepared a snippet, I can see that it is working.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
// SET POPUP(TARGET) BEHAVIOUR WHEN CLICKING A MATCHING TRIGGER ID
$("[id^='trigger-']").on("click", function() {
var id = parseInt(this.id.replace("trigger-", ""), 10);
var thetarget = $("#target-" + id);
if ($(this).hasClass("active")) {
// Do something here if the trigger is already active
} else {
// Do something here if the trigger is not active
// Remove active classes from triggers in general
$('.trigger').removeClass("active");
// Remove active classes from targets in general
$('.target').removeClass("active");
// Add active class to this trigger
$(this).addClass("active");
// Add active class to this target
$(thetarget).addClass("active");
}
});
// Close Popup Event
$('.popupclose').on("click", function() {
console.log('Button test!');
$('.trigger').removeClass("active");
$('.target').removeClass("active");
});
<!-- language: lang-css -->
.team-popup {
display: none;
}
.active {
display: block;
}
<!-- language: lang-html -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<!-- The visible team item(s) -->
<div class="team-item anim-target bottomfade-fm-dm">
<a class="trigger" id="trigger-12">
<div class="team-image bg-image rounded-box"></div>
<h4>
The title
</h4>
<p>
team job title
</p>
</a>
</div>
<!-- The popup item(s) -->
<!-- popup start -->
<div class="team-popup target" id="target-12">
<div class="overlay"></div>
<div class="popup">
<div class="popupcontrols">
<span class="popupclose" style="cursor:pointer">X</span>
</div>
<div class="popupcontent">
<div class="g3">
<img src="https://picsum.photos/200" />
</div>
<div class="g7">
<h4>
the title
</h4>
<p>
team bio
</p>
</div>
</div>
</div>
</div>
<!-- popup end -->
<!-- end snippet -->
|
I have not been able to make it work with the 'username + password' overload of the `Credentials` class.
I did manage to get the intergration to work with a Github Personal Access Token.
1. Create a Personal Access Token (PAT) in Github (source: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token) Make sure it has the grant for Reading and Writing of contents, in order to be authorized to create Github Releases (as well as uploading files to that release).
2. Make sure you store the PAT somewhere safe, like a password safe.
3. Define a Parameter in the NukeBuild script for passing in the PAT. Ensure you decorate the property with `[Secret]` as you are dealing with secret data here. From the root of the repository, run `nuke` on the commandline to build the script and populate the `build.schema.json` file in the `.nuke` folder.
4. In the `.nuke` folder, create a parameters file to store the data, for example `parameters.secrets.json`, with file contents `{}` (an empty json object). Consider putting this file in gitignore, depending on your situation.
5. From your repository root, open command line and run `nuke :secrets secrets`. Provide a password (also save this somewhere, as you'll need it to decrypt the file again later!).
6. Navigate the menu and select the PAT parameter you've defined. Fill in the PAT. Then `<Save and Exit>`. This now saves the PAT in encrypted format in that secrets file.
7. Run the buildscript target, providing the `secrets` profile: `nuke --target MyTarget --profile secrets`. You'll be asked the password for decrypting the secrets file (from step 5). Provide it, and the script will now create the Release in Github. |
[enter image description here](https://i.stack.imgur.com/sojTu.png)
This is error i got( i have attach the image too)
App.jsx:14 [2024-03-30T14:08:58.599Z] @firebase/firestore: Firestore (10.10.0): Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: FirebaseError: [code=permission-denied]: Permission denied: Consumer 'project:undefined' has been suspended.
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
App.jsx:14
POST https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/chann…t8bfxc&SID=zC0Bn075IIsrG1YXDo5VTA&RID=59161&TYPE=terminate&zx=y5k0pfa69yem net::ERR_BLOCKED_BY_CLIENT
App.jsx:16 Uncaught (in promise) FirebaseError: Failed to get document because the client is offline.
App.jsx:16 Uncaught (in promise) FirebaseError: Failed to get document because the client is offline.
trying to solve the problem |
recently i have tried to connect vite and firebase but at end i got this error i dont know to solve this |
|reactjs|firebase|vite| |
null |
I want to create a form in contact form 7 that is able to change the response in a filled field to standard text in the output email.
The form is - for example - about buying/selling cars. In the label there's a question "are you looking for a car at the moment?. In the field there is a dropdown menu yes/no. The output in the e-mail should either be "this prospect is planning to buy a car" or "this person isn't interested in buying a car, but he filled in the form so this could be a buyer in the future". In other words, the answer in the filled field is converted to a different text.
Is there any way to do that? I fiddled around with CF7, but cannot get it to work properly. Unfortunately, Im not a programmer, just someone who wants to make a contact form. Can anyone help me here?
Help is appreciated!
Best regards, Max
I tried to fix this with Conditional Logic/conditional field, but this is obviously not a solution. |
You are looking for [`mapslices`](https://docs.julialang.org/en/v1/base/arrays/#Base.mapslices):
julia> mtx = [1.0 8.0;-Inf 5.0;5.0 -Inf;9.0 9.0]
4×2 Array{Float64,2}:
1.0 8.0
-Inf 5.0
5.0 -Inf
9.0 9.0
julia> mapslices(sortperm, mtx; dims=1) # apply sortperm to every column of mtx
4×2 Array{Int64,2}:
2 3
1 2
3 1
4 4
Taken from the documentation:
> Transform the given dimensions of array A using function f. f is called on each slice of A of the form A[...,:,...,:,...]. dims is an integer vector specifying where the colons go in this expression. The results are concatenated along the remaining dimensions. For example, if dims is [1,2] and A is 4-dimensional, f is called on A[:,:,i,j] for all i and j. |
null |
I have a Word VBA Macro in which I the requestbody of a httpRequest is a JSON string.:-
```
' Compose the request body
Dim requestBody As String
requestBody = {"message":{"subject":" & subject & ","body": {"content": " & body & ","contentType": "Text"},"toRecipients": {"emailAddress": {"address": " & recipient & "}}}}
```
When I compile I get a syntax error for the requestBody line.
No doubt I need to define it as a JSON string, but I cannot find out how!
It is a valid JSON string, I spent quite some time with JSON-Lint cleaning it up!
I have spent 2 days trying to find a solution.
Any pointers?
Thanking you |
VBA JSON String |
|json|vba| |
null |
I have been stuck on this all day and would really appreciate some help.
I have a table which I created in Power Query and have loaded this into an Excel worksheet named "Pay Com". To this table, I have added 2 slicers - one for Job and the other for Country. The filters work fine on the table.
I am trying to add VB code where I can change the slicer selections based on named ranges. So I want the Job slicer to be the value in my named range Filter_Job and the Country slicer to be the value in my named range 'Filter_Country'
I am not that proficient in VBA, but I have used code previously to change slicers in pivot tables. However, I cannot get this slicer to work and I don't know why. Is it something to do with the slicer being tied to a table rather than a pivot table? (The Report Connection option is greyed out if that has any implications).
Any guidance would be really appreciated.
I tried a couple of methods after googling this. I tried .SlicerCaches and it didn't like it. I tried .Shapes and it didn't work
I have passed the variables and set my variable values. It is the end part where I try to filter the slicer it does not work
This is my current code:
The first part of this code is dealing with double clicking within a pivot table, extracting values from the position of the double-clicked cell and pasting those into the named cells.
The second part of the code is what I need help with. I want to take the values from these named cells and use them to filter my slicers for a table that has been loaded from Power Query. It seems the table being from Power Query is the issue I am facing?
I have incorporated the code as per your answer @Taller but that still does not seem to work. It needs debugging at this line: countryValue = "|" & Join(Application.Transpose(Range("Filter_NH_Country")), "|") & "|"
```
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim pt As PivotTable
Dim wsHeatMap As Worksheet
Dim wsCom As Worksheet
Dim SI As SlicerItem
Dim jcValue As String
Dim countryValue As String
' Set references to the specific worksheets & Table
Set wsHeatMap = ThisWorkbook.Sheets("NH Map")
Set wsCom = ThisWorkbook.Sheets("Pay Com")
' Check if only one cell is selected in pivot table
If Target.Count = 1 Then
' Check if the double click happened in a PivotTable
On Error Resume Next
Set pt = Target.PivotTable
On Error GoTo 0
If Not pt Is Nothing And pt.Name = "pvt_Map" Then
' This is my specific pivot table
' Adjust the logic as needed, Example: Cancel the double click
Cancel = True
' Extract values from position of my selected cell
jcValue = Cells(Target.Row, "D").Value
countryValue = Cells(10, Target.Column - 1).Value
' Place the extracted values in the named ranges
Range("Filter_Job").Value = jcValue
Range("Filter_Country").Value = countryValue
' Reset error handling
On Error GoTo 0
jcValue = Range("Filter_Job").Value
countryValue = Range("Filter_Country").Value
' Apply filters to slicers in the "Pay Comp" worksheet
***countryValue = "|" & Join(Application.Transpose(Range("Filter_NH_Country")), "|") & "|"***
For Each SI In wsCom.SlicerCaches("Slicer_Country1").SlicerItems
SI.Selected = InStr(1, countryValue, "|" & SI.Name & "|")
Next
jobValue = "|" & Join(Application.Transpose(Range("Filter_NH_JC")), "|") & "|"
For Each SI In wsComp.SlicerCaches("Slicer_Job_Code").SlicerItems
SI.Selected = InStr(1, jobValue, "|" & SI.Name & "|")
Next
End If
End If
End Sub
``` |
Propertu in Pina returns null after setting the value |
|laravel|vue.js|pinia| |
found the solution: just dismiss keyboard to lose focus:
useEffect(() => {
const keyboardDidHideListener = Keyboard.addListener(
'keyboardDidHide',
Keyboard.dismiss,
);
return () => {
keyboardDidHideListener.remove();
};
}, []); |
Trying to make a short example with django 5 async signal. Here is the code:
View:
```python
async def confirm_email_async(request, code):
await user_registered_async.asend(
sender=User,
)
return JsonResponse({"status": "ok"})
```
Signal:
```python
user_registered_async = Signal()
@receiver(user_registered_async)
async def async_send_welcome_email(sender, **kwargs):
print("Sending welcome email...")
await asyncio.sleep(5)
print("Email sent")
```
The error trace is:
```
Traceback (most recent call last):
File "C:\Users\karonator\AppData\Roaming\Python\Python311\site-packages\asgiref\sync.py", line 534, in thread_handler
raise exc_info[1]
File "C:\Users\karonator\AppData\Roaming\Python\Python311\site-packages\django\core\handlers\exception.py", line 42, in inner
response = await get_response(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\karonator\AppData\Roaming\Python\Python311\site-packages\asgiref\sync.py", line 534, in thread_handler
raise exc_info[1]
File "C:\Users\karonator\AppData\Roaming\Python\Python311\site-packages\django\core\handlers\base.py", line 253, in _get_response_async
response = await wrapped_callback(
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\karonator\Desktop\signals\main\views.py", line 34, in confirm_email_async
await user_registered_async.asend(
File "C:\Users\karonator\AppData\Roaming\Python\Python311\site-packages\django\dispatch\dispatcher.py", line 250, in asend
responses, async_responses = await asyncio.gather(
^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\asyncio\tasks.py", line 819, in gather
if arg not in arg_to_fut:
^^^^^^^^^^^^^^^^^^^^^
TypeError: unhashable type: 'list'
```
Will be grateful for any help, already broken my head.
Thanks for your time. |
Django 5 signal asend: unhashable type list |
|python|django|python-asyncio|django-signals| |
Why do we need to add paranthesis when adding function as an expression to lambda?
def print_():
print('hello')
show = lambda: print_
show()
gives
```<function print_ at 0x0000019046503560>```
whereas
show1 = lambda: print_()
show1()
gives
```hello```
Why this behaviour? |
Why do we need to add brackets to lambda functions? |
|python|lambda| |
You are closing the plotter inside the loop.. Consider these options:
```python
from vedo import *
meshes = load("letter_*.vtk") # sort is done automatically
plotter = Plotter(axes=1)
for i, m in enumerate(meshes):
m.pos([i*2000, 0, 0]).color(i)
plotter.show(meshes).close()
```
[![enter image description here][1]][1]
Another option:
```python
import time
from vedo import *
meshes = load("letter_*.vtk")
plotter = Plotter(interactive=False)
plotter.show() # show the empty window
for i, m in enumerate(meshes):
m.color(i)
plotter.remove(meshes).add(m)
plotter.reset_camera().render()
time.sleep(0.5)
plotter.interactive().close()
```
will visualise your meshes one by one. Note that objects can also be removed by name e.g.:
`mesh.name = "jack"` then `plotter.remove("jack")` will remove it.
[1]: https://i.stack.imgur.com/fHRSH.png |
How to add default text in output to filled fields in Contact Form 7 |
|wordpress|forms|webforms|contact-form-7|contact-form| |
null |
How to solve this problem

```
[root@iZf8z8ooxm0rsr5hsejg0iZ config]# docker exec -it mosquitto sh
/ # mosquitto -v
1711804289: mosquitto version 2.0.14 starting
1711804289: Using default config.
1711804289: Starting in local only mode. Connections will only be possible from clients running on this machine.
1711804289: Create a configuration file which defines a listener to allow remote access.
1711804289: For more details see https://mosquitto.org/documentation/authentication-methods/
1711804289: Opening ipv4 listen socket on port 1883.
1711804289: Error: Address in use
1711804289: Opening ipv6 listen socket on port 1883.
1711804289: Error: Address not available
``` |
In React, with the React Pro Sidebar, using something like updating on `document.body.scrollHeight` worked for me:
```jsx
const [viewHeight, setViewHeight] = useState<
string | number
>("100vh")
useEffect(() => {
setViewHeight(document.body.scrollHeight)
}, [document.body.scrollHeight])
...
return <div style={{ height: viewHeight }}>...</div>
``` |
I have one NFSv4 server (Debian 11) and two client machines (Debian 11) which are mounting a NFS share exported by the server with `all_squash` option. I set the `all_squash` option because the two client machines have one user with same name but different UID. As addition to `all_squash` i set the `anonuid` and `anongid` option.
My Problem is that my setup works and i can write and read the files on the NFS share from clientside with the specific user, but other users on the clients have access with same rights to the files as well.
Is there a way to restrict the access to the share on clientside? |
Restrict user access on mounted NSFv4 share with all_squash option |
|debian|nfs|uid| |
I'm using the firestore emulator and exists isn't preventing calls when the document exists.
```
match /usernames/{username} {
allow update: if false;
allow create: if isUsernameAvailable(request.resource.data.username);
function isUsernameAvailable(rawName) {
let name = rawName.lower();
return isValidMessage() &&
isValidUsername(name) &&
!exists(/databases/$(database)/documents/users/$(request.auth.uid));
}
```
Here is the accepted [Request](https://i.stack.imgur.com/1daqL.png) and [Pre-Existing Document](https://i.stack.imgur.com/nOy1m.png)
The document clearly exists. I've compared my code to similar code, and I don't see syntactical errors, so I'm at a loss. |