text:
Q: Spring-amqp: Exceptions when using anonymous, exclusive queues I've got a series of tomcat/spring applications for which messages need to be sent from single instances of several different servers to numerous clients, using a couple of different fanout exchanges. Each server instance has its own set of exchanges. The exchanges are declared by the server, and anonymous queues generated by each client and bound to those exchanges. I'm using anonymous queues because I don't know in advance how many consumers there will be, and of course I can't bind multiple consumers to a single named queue without undermining the nature of the fanout exchange. On the client side, I'm getting a ton of exceptions in my logs relating to attempts to re-declare or delete these anonymous queues.
To paint a clearer picture: Imagine I've got 2 services, Service A and Service B, each of which publishes to a pair of fanout exchanges - say ExchangeA1, ExchangeA2 for service A, and ExchangeB1, ExchangeB2 for service B. Now imagine I've got a single client establishing randomly-named queues bound to each of those 4 exchanges so it can monitor messages from both services.
Messages are sent successfully from the server-side to the exchanges without issue, so I'll leave off the server-side config, though I can provide that if it becomes relevant. Here's the client-side spring-config:
<rabbit:queue id="ClientQ1" />
<rabbit:queue id="ClientQ2" />

<!-- declare the exchanges so we can bind to them -->
<rabbit:fanout-exchange id="ExchangeA1.id" name="ExchangeA1">
    <rabbit:bindings>
        <rabbit:binding queue="ClientQ1"/>
    </rabbit:bindings>
</rabbit:fanout-exchange>

<rabbit:fanout-exchange id="ExchangeA2.id" name="ExchangeA2">
    <rabbit:bindings>
        <rabbit:binding queue="ClientQ2"/>
    </rabbit:bindings>
</rabbit:fanout-exchange>

<rabbit:connection-factory id="rabbitConnectionFactory"  <!-- this is a simple singleton bean that establishes an SSL connection to rabbitmq -->
                        connection-factory="rabbitMQConnectionFactoryBean"
                        publisher-confirms="true"
                        channel-cache-size="5" />

<rabbit:admin id="myRabbitAdmin" connection-factory="rabbitConnectionFactory"/>

<rabbit:listener-container id="rabbitListenerContainer"
                           acknowledge="auto"
                           prefetch="1000"
                           connection-factory="rabbitConnectionFactory"
                           message-converter="EventMessageConverterBean" >

    <rabbit:listener ref="Q1ListenerBean"
                     admin="myRabbitAdmin"
                     method="processEvent"
                     queue-names="#{ClientQ1.name}" />

    <rabbit:listener ref="Q2ListenerBean"
                     admin="myRabbitAdmin"
                     method="processEvent"
                     queue-names="#{ClientQ2.name}" />

</rabbit:listener-container>

Now, imagine that in some other dependency of this client, the same configuration is essentially repeated for bindings to ExchangeB(1,2).
Upon startup, I'm seeing loads of exceptions following this pattern:
ERROR - SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(1158) | Consumer received fatal exception on startup
org.springframework.amqp.rabbit.listener.QueuesNotAvailableException: Cannot prepare queue for listener. Either the queue doesn't exist or the broker will not allow us to use it.
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:481)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1083)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$DeclarationException: Failed to declare queue(s):[e4d2b49c-140f-4893-a764-4c84f945d482]
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:554)
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:453)
... 2 more
Caused by: java.io.IOException
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:106)
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:102)
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:124)
at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:801)
at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:61)
at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory$CachedChannelInvocationHandler.invoke(CachingConnectionFactory.java:666)
at com.sun.proxy.$Proxy114.queueDeclarePassive(Unknown Source)
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:533)
... 3 more
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=405, reply-text=RESOURCE_LOCKED - cannot obtain exclusive access to locked queue 'e4d2b49c-140f-4893-a764-4c84f945d482' in vhost '/', class-id=50, method-id=10)
at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:67)
at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:33)
at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:343)
at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:216)
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:118)
... 11 more

My debugging has lead me to the redeclareElementsIfNecessary() method in SimpleMessageListenerContainer(:954), which attempts to redeclare all queues/exhcnages/bindings if any are missing. This fails because rabbitmq will not allow exclusive queues to be redelcared. (or so I think)
Searching for similar issues lead me to this: Spring AMQP v1.4.2 - Rabbit reconnection issue on network failure , which is tangentially related, but the solution is not applicable to my problem. Since anonymous queues are by nature exclusive, and I must use anonymous queues, I seem to be stuck between a rock and a hard place. My questions are these:

*

*Am I doing something wrong w/r/t my listener configuration? Could I change my configuration in some way i'm missing that would alleviate this problem?

*Why is redeclareElementsIfNecessary being invoked? It seems to me that all of the queues in question should exist after the first declaration.

*Are these errors truly innocuous? If so, how can I go about intercepting them to avoid all the exceptions showing up in my logs?

Any information would be appreciated.
spring-amqp 1.4.6
rabbitmq 3.6.10
Update 1
Some relevant spring-debug log output related to rabbit:admin:
17:22:14,783 DEBUG RabbitAdmin:382 - Initializing declarations
17:22:14,784 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'serviceAExchange1'
17:22:14,784 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'serviceAExchange2'
17:22:14,784 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'serviceBExchange1'
17:22:14,784 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'serviceBExchange2'
17:22:14,784 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'org.springframework.amqp.core.TopicExchange#0'
17:22:14,784 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'org.springframework.amqp.core.TopicExchange#1'
17:22:14,784 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'org.springframework.amqp.core.TopicExchange#2'
17:22:14,784 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'ServiceAQueue1'
17:22:14,784 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'ServiceAQueue2'
17:22:14,784 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'ServiceBQueue1'
17:22:14,784 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'ServiceBQueue2'
17:22:14,784 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'consumer.index.amqp.consumerQueue'
17:22:14,785 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'org.springframework.amqp.rabbit.config.BindingFactoryBean#0'
17:22:14,785 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'org.springframework.amqp.rabbit.config.BindingFactoryBean#1'
17:22:14,786 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'org.springframework.amqp.rabbit.config.BindingFactoryBean#2'
17:22:14,786 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'org.springframework.amqp.rabbit.config.BindingFactoryBean#3'
17:22:14,786 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'org.springframework.amqp.rabbit.config.BindingFactoryBean#4'
17:22:14,786  INFO RabbitAdmin:399 - Auto-declaring a non-durable, auto-delete, or exclusive Queue (07475112-7be0-4c8d-b6e5-3279e81a1aff) durable:false, auto-delete:true, exclusive:true. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.
17:22:14,786  INFO RabbitAdmin:399 - Auto-declaring a non-durable, auto-delete, or exclusive Queue (e4825008-954f-4154-bd61-9b67e0ff582e) durable:false, auto-delete:true, exclusive:true. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.
17:22:14,786  INFO RabbitAdmin:399 - Auto-declaring a non-durable, auto-delete, or exclusive Queue (001bd357-6203-49a6-b573-7f1a998ff750) durable:false, auto-delete:true, exclusive:true. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.
17:22:14,786  INFO RabbitAdmin:399 - Auto-declaring a non-durable, auto-delete, or exclusive Queue (3880a65f-0104-4c99-96ac-1958ace7e2e0) durable:false, auto-delete:true, exclusive:true. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.
17:22:14,786  INFO RabbitAdmin:399 - Auto-declaring a non-durable, auto-delete, or exclusive Queue (3b1bc32a-872e-4fc3-ba2a-de200bc7b758) durable:false, auto-delete:true, exclusive:true. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.
17:22:14,791  INFO CachingConnectionFactory:213 - Created new connection: SimpleConnection@3158bf2b [delegate=amqp://admin@172.30.12.59:5671/]
17:22:14,791 DEBUG RabbitAdmin:382 - Initializing declarations
17:22:14,791 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'serviceAExchange1'
17:22:14,791 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'serviceAExchange2'
17:22:14,791 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'serviceBExchange1'
17:22:14,791 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'serviceBExchange2'
17:22:14,791 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'org.springframework.amqp.core.TopicExchange#0'
17:22:14,792 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'org.springframework.amqp.core.TopicExchange#1'
17:22:14,792 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'org.springframework.amqp.core.TopicExchange#2'
17:22:14,792 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'ServiceAQueue1'
17:22:14,792 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'ServiceAQueue2'
17:22:14,792 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'ServiceBQueue1'
17:22:14,792 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'ServiceBQueue2'
17:22:14,792 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'consumer.index.amqp.consumerQueue'
17:22:14,792 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'org.springframework.amqp.rabbit.config.BindingFactoryBean#0'
17:22:14,792 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'org.springframework.amqp.rabbit.config.BindingFactoryBean#1'
17:22:14,792 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'org.springframework.amqp.rabbit.config.BindingFactoryBean#2'
17:22:14,792 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'org.springframework.amqp.rabbit.config.BindingFactoryBean#3'
17:22:14,792 DEBUG DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'org.springframework.amqp.rabbit.config.BindingFactoryBean#4'
17:22:14,792  INFO RabbitAdmin:399 - Auto-declaring a non-durable, auto-delete, or exclusive Queue (07475112-7be0-4c8d-b6e5-3279e81a1aff) durable:false, auto-delete:true, exclusive:true. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.
17:22:14,792  INFO RabbitAdmin:399 - Auto-declaring a non-durable, auto-delete, or exclusive Queue (e4825008-954f-4154-bd61-9b67e0ff582e) durable:false, auto-delete:true, exclusive:true. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.
17:22:14,792  INFO RabbitAdmin:399 - Auto-declaring a non-durable, auto-delete, or exclusive Queue (001bd357-6203-49a6-b573-7f1a998ff750) durable:false, auto-delete:true, exclusive:true. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.
17:22:14,792  INFO RabbitAdmin:399 - Auto-declaring a non-durable, auto-delete, or exclusive Queue (3880a65f-0104-4c99-96ac-1958ace7e2e0) durable:false, auto-delete:true, exclusive:true. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.
17:22:14,792  INFO RabbitAdmin:399 - Auto-declaring a non-durable, auto-delete, or exclusive Queue (3b1bc32a-872e-4fc3-ba2a-de200bc7b758) durable:false, auto-delete:true, exclusive:true. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.
17:22:14,811 DEBUG CachingConnectionFactory:395 - Creating cached Rabbit Channel from PublisherCallbackChannelImpl: AMQChannel(amqp://admin@172.30.12.59:5671/,1)
17:22:14,811 DEBUG CachingConnectionFactory:395 - Creating cached Rabbit Channel from PublisherCallbackChannelImpl: AMQChannel(amqp://admin@172.30.12.59:5671/,1)
17:22:14,821 DEBUG RabbitTemplate:1045 - Executing callback on RabbitMQ Channel: Cached Rabbit Channel: PublisherCallbackChannelImpl: AMQChannel(amqp://admin@172.30.12.59:5671/,1)
17:22:14,821 DEBUG RabbitAdmin:444 - declaring Exchange 'serviceAExchange1'
17:22:14,822 DEBUG RabbitTemplate:1045 - Executing callback on RabbitMQ Channel: Cached Rabbit Channel: PublisherCallbackChannelImpl: AMQChannel(amqp://admin@172.30.12.59:5671/,1)
17:22:14,825 DEBUG RabbitAdmin:444 - declaring Exchange 'serviceAExchange1'
17:22:14,827 DEBUG RabbitAdmin:444 - declaring Exchange 'serviceAExchange2'
17:22:14,828 DEBUG RabbitAdmin:444 - declaring Exchange 'serviceAExchange2'
17:22:14,829 DEBUG RabbitAdmin:444 - declaring Exchange 'serviceBExchange1'
17:22:14,830 DEBUG RabbitAdmin:444 - declaring Exchange 'serviceBExchange1'
17:22:14,832 DEBUG RabbitAdmin:444 - declaring Exchange 'serviceBExchange2'
17:22:14,835 DEBUG RabbitAdmin:444 - declaring Exchange 'serviceBExchange2'
17:22:14,836 DEBUG RabbitAdmin:472 - declaring Queue '07475112-7be0-4c8d-b6e5-3279e81a1aff'
17:22:14,837 DEBUG RabbitAdmin:472 - declaring Queue '07475112-7be0-4c8d-b6e5-3279e81a1aff'
17:22:14,843 DEBUG RabbitAdmin:472 - declaring Queue 'e4825008-954f-4154-bd61-9b67e0ff582e'
17:22:14,845 DEBUG RabbitAdmin:472 - declaring Queue '001bd357-6203-49a6-b573-7f1a998ff750'
17:22:14,848 DEBUG RabbitAdmin:472 - declaring Queue '3880a65f-0104-4c99-96ac-1958ace7e2e0'
17:22:14,853 DEBUG RabbitAdmin:472 - declaring Queue '3b1bc32a-872e-4fc3-ba2a-de200bc7b758'
17:22:14,856 DEBUG PublisherCallbackChannelImpl:654 - PendingConfirms cleared
17:22:14,856 DEBUG RabbitAdmin:511 - Binding destination [07475112-7be0-4c8d-b6e5-3279e81a1aff (QUEUE)] to exchange [serviceAExchange1] with routing key []
17:22:14,858 ERROR CachingConnectionFactory:292 - Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=405, reply-text=RESOURCE_LOCKED - cannot obtain exclusive access to locked queue '07475112-7be0-4c8d-b6e5-3279e81a1aff' in vhost '/', class-id=50, method-id=10)
17:22:14,859 DEBUG CachingConnectionFactory:673 - Detected closed channel on exception.  Re-initializing: PublisherCallbackChannelImpl: AMQChannel(amqp://admin@172.30.12.59:5671/,1)
17:22:14,860 DEBUG RabbitAdmin:511 - Binding destination [e4825008-954f-4154-bd61-9b67e0ff582e (QUEUE)] to exchange [serviceAExchange2] with routing key []
17:22:14,862 DEBUG RabbitAdmin:511 - Binding destination [001bd357-6203-49a6-b573-7f1a998ff750 (QUEUE)] to exchange [serviceBExchange1] with routing key []
17:22:14,864  WARN RabbitAdmin:494 - Failed to declare queue:Queue [name=07475112-7be0-4c8d-b6e5-3279e81a1aff, durable=false, autoDelete=true, exclusive=true, arguments=null], continuing...
java.io.IOException
        at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:106)
        [...]
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=405, reply-text=RESOURCE_LOCKED - cannot obtain exclusive access to locked queue '07475112-7be0-4c8d-b6e5-3279e81a1aff' in vhost '/', class-id=50, method-id=10)
[ More declaration errors follow ]

A: 1.4.6 is nearly 2 years old; do you see the same behavior with the current version (1.7.4)?
The exception reply-code=405, reply-text=RESOURCE_LOCKED implies you have two consumers on the queue. A common mistake with Spring Apps on Tomcat (or any web container) is to load the application context twice - once in the root application context and again in the dispatcher servlet's context.
Turning on DEBUG logging for org.springframework and going over all the beans declarations should help.
I just loaded your config into a simple app (main) and I don't see any problems, even after force-closing the connection via the admin UI...
Auto-declaring a non-durable, auto-delete, or exclusive Queue (47c551b8-c290-4ff0-ae42-11f24d576399) durable:false, auto-delete:true, exclusive:true. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.
Auto-declaring a non-durable, auto-delete, or exclusive Queue (c494990e-9069-4561-8d64-1eb0373cf681) durable:false, auto-delete:true, exclusive:true. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.
Started So46496960Application in 1.454 seconds (JVM running for 1.879)
#method<connection.close>(reply-code=320, reply-text=CONNECTION_FORCED - Closed via management plugin, class-id=0, method-id=0)
#method<connection.close>(reply-code=320, reply-text=CONNECTION_FORCED - Closed via management plugin, class-id=0, method-id=0)
SimpleConnection@5fa6541 [delegate=amqp://guest@127.0.0.1:5672/, localPort= 58388], acknowledgeMode=AUTO local queue size=0
SimpleConnection@5fa6541 [delegate=amqp://guest@127.0.0.1:5672/, localPort= 58388], acknowledgeMode=AUTO local queue size=0
rabbitConnectionFactory#4015e40b:1/SimpleConnection@712becf3 [delegate=amqp://guest@127.0.0.1:5672/, localPort= 58404]
Auto-declaring a non-durable, auto-delete, or exclusive Queue (47c551b8-c290-4ff0-ae42-11f24d576399) durable:false, auto-delete:true, exclusive:true. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.
Auto-declaring a non-durable, auto-delete, or exclusive Queue (c494990e-9069-4561-8d64-1eb0373cf681) durable:false, auto-delete:true, exclusive:true. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.


text:
Q: Convert spark to pandas dataframe has Exception: arrow is not supported when using file-based collect I am trying to convert a spark dataframe to pandas dataframe on Azure databricks. But I get the following error:
Exception: arrow is not supported when using file-based collect
I have tried the reference code using the link: https://docs.databricks.com/spark/latest/spark-sql/spark-pandas.html
First I read csv file using the following line:
#read file
df1 = spark.read.csv('/mnt/test/sample.csv', header = True)

Next I try to convert this to pandas dataframe using this code below:
# Enable Arrow-based columnar data transfers
spark.conf.set("spark.sql.execution.arrow.enabled", "true")
# Convert the Spark DataFrame to a Pandas DataFrame
pandas_df = df1.select("*").toPandas()

But while doing this I get this error:
Exception: arrow is not supported when using file-based collect
Here is the full expansion of the error message:
Exception: arrow is not supported when using file-based collect
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<command-3700677352136413> in <module>()
      2 spark.conf.set("spark.sql.execution.arrow.enabled", "true")
      3 # Convert the Spark DataFrame to a Pandas DataFrame
----> 4 pandas_df = df1.select("*").toPandas()

/databricks/spark/python/pyspark/sql/dataframe.py in toPandas(self)
   2169                         _check_dataframe_localize_timestamps
   2170                     import pyarrow
-> 2171                     batches = self._collectAsArrow()
   2172                     if len(batches) > 0:
   2173                         table = pyarrow.Table.from_batches(batches)

/databricks/spark/python/pyspark/sql/dataframe.py in _collectAsArrow(self)
   2225         """
   2226         if self._sc._conf.get(self._sc._jvm.PythonSecurityUtils.USE_FILE_BASED_COLLECT()):
-> 2227             raise Exception("arrow is not supported when using file-based collect")
   2228         with SCCallSiteSync(self._sc) as css:
   2229             sock_info = self._jdf.collectAsArrowToPython()

Exception: arrow is not supported when using file-based collect

Can someone please help?

A: I finally figured out the solution. It was the Runtime version of the cluster that had to be changed. Created a new cluster and tested with it Runtime Version 5.5 and it seemed to run fine.

A: Why not directly read the csv file using pandas from the mount path of dbfs? Such as I did it as the code and figure below.
pdf = pd.read_csv('/dbfs/mnt/test/test.csv')

And I ran the code below successfully without any error on Azure Databricks.
pdf = pd.read_csv('/dbfs/mnt/test/test.csv')
spark.conf.set("spark.sql.execution.arrow.enabled", "true")
df1 = spark.createDataFrame(pdf)
pandas_df = df1.select("*").toPandas()

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to return a stored procedure as a string in C# code and ALTER it partially I want to change a part of a stored procedure in C# code. It would be great if someone can offer a solution how to do that with DataAdapter.
So, basically, I need to return the store procedure from database as a string so than I can replace a part of that string and finally execute it. Any suggestions? Thanks in advance!


text:
Q: How to add stroke/border to transparent png image in android? I have transparent images like shapes,letters which I'm fetch from gallery so I need to give them stroke/outline with black color, I can set border but It's set to whole bitmap like left,right,top and bottom.

Same thing we can do with photoshop is giving outerstroke to image but I want to achieve that in android.

I tried this and this It's give border, But what I want to do is like below
sample image
Original Image

I want like this -->

Does this possible in android?

A: I have an temporary solution like this
int strokeWidth = 8;
Bitmap originalBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.flower_icon);
Bitmap newStrokedBitmap = Bitmap.createBitmap(originalBitmap.getWidth() + 2 * strokeWidth, originalBitmap.getHeight() + 2 * strokeWidth, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(newStrokedBitmap);
float scaleX = newStrokedBitmap.getWidth() / originalBitmap.getWidth();
float scaleY = newStrokedBitmap.getHeight() / originalBitmap.getHeight();
Matrix matrix = new Matrix();
matrix.setScale(scaleX, scaleY);
canvas.drawBitmap(originalBitmap, matrix, null);
canvas.drawColor(Color.WHITE, PorterDuff.Mode.SRC_ATOP); //Color.WHITE is stroke color
canvas.drawBitmap(originalBitmap, strokeWidth, strokeWidth, null);

Firstly create a new bitmap with stroke size on left, right, bottom and top.
Secondly a little bit scale bitmap and draw scaled bitmap on newly created bitmap canvas.
Draw a color (your stroke color) with PorterDuff mode SRC_ATOP override original bitmap position with stroke color.
Finally draw your original bitmap on newly create bitmap canvas.


text:
Q: Defining an ordered pair as a set In mathematics we define mathematical objects in terms of other mathematical objects. For example, some textbooks define $(a,b)$ as a set. Such as,
$$(a,b):= \{\{a\},\{a,b\}\}$$
Now, the cardinality of $\{\{a\},\{a,b\}\} $ is $2$. Does this imply that the cardinality of $(a,b)$ is $2$?
I find it hard to speak of the cardinality of an ordered pair.
What I am asking here is why or why not can we speak of the cardinality of an ordered pair?
My question also applies to other objects such as relations as sets or ordered pairs, complex numbers as ordered pairs of real numbers... etc.
Why can we speak of a property of some objects and can't speak of the same property regarding another object that is defined in the terms of the first?
In summary, $$\left| {\left\{ {\left\{ a \right\},\left\{ {a,b} \right\}} \right\}} \right|=2$$
$$|(a,b)|=2?$$
Thanks in advance and sorry if my question is ambiguous.

A: You find it hard to talk about the cardinality of an ordered pair, because you don't think of an ordered pair as a set. You think about it as an ordered pair.
Similarly you will have a hard time talking about the cardinality of a real number. What is the cardinality of $\pi$? Well, of course it depends on how you construct the real numbers, and what exactly is $\pi$. But if you accept that $\pi$ is a particular set, then you can talk about its cardinality.
And the same principle applies to ordered pairs, or anything else really. If you accept that a particular object is represented by a particular set, then you can ask what are the elements of this set, and what is its cardinality, and so on.
As for whether or not $|(a,b)|=2$, this is true if and only if $a\neq b$. If $a=b$ then $(a,b)=(a,a)=\{\{a\}\}$ and its cardinality is $1$.


text:
Q: Poll success, but error: Operation now in progress (29). when Xdebug trying connect to PhpStorm from docker container I'm trying debug CLI script, and Xdebug can't connect to PhpStorm.
I see error Operation now in progress (29). in Xdebug remote log.
I'm sure Xdebug configured right, but I don't know how to debug PhpStorm.
Summary from phpinfo() generated by https://xdebug.org/wizard.php
Tailored Installation Instructions
Summary
Xdebug installed: 2.6.1
Server API: Command Line Interface
Windows: no
Zend Server: no
PHP Version: 7.1.24
Zend API nr: 320160303
PHP API nr: 20160303
Debug Build: no
Thread Safe Build: no
OPcache Loaded: no
Configuration File Path: /usr/local/etc/php
Configuration File: /usr/local/etc/php/php.ini
Extensions directory: /usr/local/lib/php/extensions/no-debug-non-zts-20160303
You're already running the latest Xdebug version

Xdebug log
Log opened at 2019-02-19 11:59:37
I: Connecting to configured address/port: 46.201.50.194:9000.
W: Creating socket for '46.201.50.194:9000', poll success, but error: Operation now in progress (29).
E: Could not connect to client. :-(
Log closed at 2019-02-19 11:59:37

Xdebug config
xdebug

xdebug support => enabled
Version => 2.6.1
IDE Key => PHPSTORM

Supported protocols
DBGp - Common DeBuGger Protocol

Directive => Local Value => Master Value
xdebug.auto_trace => Off => Off
xdebug.cli_color => 0 => 0
xdebug.collect_assignments => Off => Off
xdebug.collect_includes => On => On
xdebug.collect_params => 0 => 0
xdebug.collect_return => Off => Off
xdebug.collect_vars => Off => Off
xdebug.coverage_enable => On => On
xdebug.default_enable => On => On
xdebug.dump.COOKIE => no value => no value
xdebug.dump.ENV => no value => no value
xdebug.dump.FILES => no value => no value
xdebug.dump.GET => no value => no value
xdebug.dump.POST => no value => no value
xdebug.dump.REQUEST => no value => no value
xdebug.dump.SERVER => no value => no value
xdebug.dump.SESSION => no value => no value
xdebug.dump_globals => On => On
xdebug.dump_once => On => On
xdebug.dump_undefined => Off => Off
xdebug.extended_info => On => On
xdebug.file_link_format => no value => no value
xdebug.filename_format => no value => no value
xdebug.force_display_errors => Off => Off
xdebug.force_error_reporting => 0 => 0
xdebug.gc_stats_enable => Off => Off
xdebug.gc_stats_output_dir => /tmp => /tmp
xdebug.gc_stats_output_name => gcstats.%p => gcstats.%p
xdebug.halt_level => 0 => 0
xdebug.idekey => PHPSTORM => PHPSTORM
xdebug.max_nesting_level => 256 => 256
xdebug.max_stack_frames => -1 => -1
xdebug.overload_var_dump => 2 => 2
xdebug.profiler_aggregate => Off => Off
xdebug.profiler_append => Off => Off
xdebug.profiler_enable => Off => Off
xdebug.profiler_enable_trigger => Off => Off
xdebug.profiler_enable_trigger_value => no value => no value
xdebug.profiler_output_dir => /tmp => /tmp
xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p
xdebug.remote_addr_header => no value => no value
xdebug.remote_autostart => On => On
xdebug.remote_connect_back => Off => Off
xdebug.remote_cookie_expire_time => 3600 => 3600
xdebug.remote_enable => On => On
xdebug.remote_handler => dbgp => dbgp
xdebug.remote_host => 127.0.0.1 => localhost
xdebug.remote_log => /app/xdebug.log => no value
xdebug.remote_mode => req => req
xdebug.remote_port => 9000 => 9000
xdebug.remote_timeout => 200 => 200
xdebug.scream => Off => Off
xdebug.show_error_trace => Off => Off
xdebug.show_exception_trace => Off => Off
xdebug.show_local_vars => Off => Off
xdebug.show_mem_delta => Off => Off
xdebug.trace_enable_trigger => Off => Off
xdebug.trace_enable_trigger_value => no value => no value
xdebug.trace_format => 0 => 0
xdebug.trace_options => 0 => 0
xdebug.trace_output_dir => /tmp => /tmp
xdebug.trace_output_name => trace.%c => trace.%c
xdebug.var_display_max_children => 128 => 128
xdebug.var_display_max_data => 512 => 512
xdebug.var_display_max_depth => 3 => 3

A: Xdebug can't connect to PhpStorm because PhpStorm was not reachable by my external host ip.
How I debug it.
First I checked from docker container that PhpStorm listen port (9000 in my case)
nc -vz external_ip 9000

It got (tcp) failed: Connection refused
I try the same from the host and also got the error
Then I tried from host
nc -vz localhost 9000

And I got [tcp/*] succeeded!
So the problem in xdebug.remote_host not in PhpStorm probably
I found host ip in container
netstat -nr | grep '^0\.0\.0\.0' | awk '{print $2}'

Put it in xdebug.remote_host and now it works correctly
Thanks for @LazyOne

A: May be your xdebug.remote_port 9000 is using by php-fpm. You try changing other port. Example xdebug.remote_port=9001 and in launch.json file still port=9000

A: In my case I simply set the following xdebug conf:
xdebug.remote_connect_back=0
xdebug.remote_host=host.docker.internal

host.docker.internal should 'magically' find the host's IP (cf. documentation). Note that this requires Docker v18.03+ and currently only works on Mac and Windows hosts.

A: If someone doesn't want to hardcode or modify their docker, Dockerfile, or compose file (maybe someone is using a 2.x xdebug, it doesn't support environment variable). Adding the header X-Forwarded-For by using a header modifying extension on the browser so as to set $_SERVER['HTTP_X_FORWARDED_FOR'] is a very convenient approach. Don't forget the configuration xdebug.remote_connect_back=1.
Dockerfile
FROM  php:7.1-apache

RUN yes | pecl install xdebug-2.5.5 \
    && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_connect_back=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_log=/tmp/xdebug.log" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini

ModHeader extension

xdebug.log
Log opened at 2021-07-06 16:06:59
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to 172.17.0.1:9000.
W: Creating socket for '172.17.0.1:9000', poll success, but error: Operation now in progress (29).
E: Could not connect to client. :-(
Log closed at 2021-07-06 16:06:59

Log opened at 2021-07-06 16:07:40
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Remote address found, connecting to 172.30.112.1:9000.
I: Connected to client. :-)

A: For me the fix to this error was simply clicking the phone icon in PhpStorm twice to disable and then re-enable listening for debug connections.
It shouldn't change anything but it worked because before that I fixed a bunch of other issues, one of them being that port 9003 was blocked by something else. Apparently PhpStorm doesn't warn when it can't use the specified port, so after resolving other issues it might be necessary to re-initiate listening for debug connections.

A: Have you configured the mapping from phpstorm in PHP->Server, you have to map the project file to the absolute path of the server eg. src -> "/var/www/html/test/src"
Also the xdebug file from the server that contains the ip address

A: I have opened "Windows Defender Firewall with Advanced Security" (Windows firewall settings) and have found that I have two rules, which appeared not clear from where, that block the phpStorm.
I disabled them - and the xDebugger started working for me.


text:
Q: How do you get Gunicorn + Flask to serve static files over https? I am using Gunicorn + Flask + Python to develop a Heroku app, and I want to be able to run it locally with foreman. It works fine, but when I switch to use SSL for my site, it is no longer able to find javascript files under /static. How can I make these available under HTTPS?

A: Can you use nginx to front-end gunicorn? If so then you can serve static content like javascript via SSL by adding a location block like below to the nginx.conf:
server {
    listen 443 ssl;
    # other normal ssl stuff you seem to already have working

    location / {
        root /path/to/your/static/stuff;
        try_files $uri /index.html; # this will match your static content
    }
    location /api {
        # your normal proxy stuff to gunicorn
    }
}

And separately, you can serve static content separate from your API over http for efficiency, like below:
server { listen 80;  location / { try_files $uri /index.html; } }
server {
    listen 443 ssl;
    # other normal ssl stuff you seem to already have working
    location /api {
        # your normal proxy stuff to gunicorn
    }
}

A: The simplest way is to use Kenneth Reitz's Flask-SSLify library.


text:
Q: How to create treeview for multiple columns in sharepoint List with Context Menu of List Items? I created a SharePoint custom list with columns.(Column name col1 ,col2 ,col3 col4, col5)
I want to create a view with this columns to display the data as like Treeview structure.
Using groupby only two columns is possible to disply in treeview.
I want to configure 5 columns.

To achieve this how can i set the column data types
Col1 is single line of text. if I add any value in col2 it will come under Col1.
so for Col2 I have to create lookup or any other data type.
If i add other country to col1 it will not come under by India.
Each list items contains Context Menu add,delete,Edit..ect
without using Sharepoint Designer its possible to achieve this scenario using C#.
Can anyone help me on that.

A: I guess you better to use Manage Metadata Data type (Taxonomy Content Type) to achieve this else need to go for customisation.


text:
Q: CSS translate to the top left of the browser window I am trying to create an animation that takes a div and translates it to the top left of the browser window. Can this be done?
I have a block of vertical navigation links that look like the following, when the Expand link is clicked, I currently add the open class to the div with add-open-class. From there I want the div to slide to the top left of the screen.

let generes = document.querySelector('.expand')
generes.addEventListener('click', e => {
  let accordion = generes.closest('.add-open-class')
  accordion.classList.toggle('open')
})
a {
  display: block;
  padding: 10px;
  background: #fff;
}

.open {
  animation: openAnimation .2s both ease-in;
}

@keyframes openAnimation {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-100%);
  }
}
Nav Item
Nav Item
Nav Item
Nav Item
Nav Item
Nav Item

  Expand

    Sub Nav Item
    Sub Nav Item
    Sub Nav Item

A: Why not something like:

.open {
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: orange;
    animation: openAnimation 2s both ease-in;
}

@keyframes openAnimation {
  0% {
    transform: translate(calc(100vw - 50px), calc(100vh - 50px));
  }

  100% {
      transform:translate(0%,0%);
  }
}

Update: Animate (transform/translate) only inside wrap

.wrap {
    position: relative;
    left: 100px;
    top: 40px;
    border: solid 2px green;
    width: 300px;
    height: 150px;
}

.open {
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: orange;
    animation: openAnimation 2s both ease-in;
}

@keyframes openAnimation {
  0% {
    transform: translate(calc(300px - 20px), calc(150px - 20px));
  }

  100% {
      transform:translate(0, 0);
  }
}

With your code something like this:

let generes = document.querySelector('.expand')
generes.addEventListener('click', e => {
  let accordion = generes.closest('.add-open-class')
  accordion.classList.toggle('open')
})
.wrap {
    position: relative;
    border: solid 2px green;
}

.add-open-class {
    position: relative;
    border: solid 2px orange;
}

.add-open-class.open {
    position: absolute;
    top: 0;
    border: solid 2px fuchsia;
}

a {
  display: block;
  padding: 10px;
  background: #fff;
}

.open {
  animation: openAnimation .2s both ease-in;
}

@keyframes openAnimation {
  0% {
    transform: translateY(100%);
  }
  100% {
    transform: translateY(0);
  }
}

    Nav Item
    Nav Item
    Nav Item
    Nav Item
    Nav Item
    Nav Item

      Expand

        Sub Nav Item
        Sub Nav Item
        Sub Nav Item


text:
Q: Magento 1.9 cron scheduler change timezone i'm a magento newbie. I wrote a cron job code in my custom module's observer file and ran cron job from terminal. Scheduled jobs are entered into cron_schedule table. But the scheduled time is in UTC. Where should I change it to set scheduled time in Asia/Kolkata timezone.

Please help me to solve this. Thanks in advance.

A: Check the timeline settings within magento configs and on the server where it is being hosted. Make sure they all match.


text:
Q: How does Salesforce determine where to apply the "*** Skipped X bytes of detailed log" section in a log Firstly, this question isn't about how to access missing log content when a *** Skipped 53353122 bytes of detailed log style message is encountered. That is covered in another question and revolves around altering log levels.
I'd like to know when and how Salesforce applies this log content skipping functionality.

*

*What determines its location in the log?

*What log messages get kept and which get skipped over?

Anecdotally it seems to appear around the middle of the log for me, which always makes me think I'm missing a significant portion from the middle of the log file.

I did find the following in the Debug Log docs:

Each debug log must be 2 MB or smaller. Debug logs that are larger than 2 MB are reduced in size by removing older log lines, such as log lines for earlier System.debug statements. The log lines can be removed from any location, not just the start of the debug log.

It still seems a bit arbitrary about what will be removed once you reach the log file size limit. Why cull one log message over another? Why not just run until the MAXIMUM DEBUG LOG SIZE REACHED message and then stop logging?

In a discussion with Chris Peterson he indicated that in more recent API versions (post v24.0?) that lower severity events are evicted first. Some basic testing based on @sfdcfox's comments using large log messages can (kind of) show this.
Try changing the LoggingLevel on each debug statement. With no levels defined the d's got logged and everything else skipped. As it is below the b's get logged and everything else skipped. Where did the a's go? (Info > Debug > Fine)
System.debug(LoggingLevel.Info, 'a'.repeat(1500000));
System.debug(LoggingLevel.Debug, 'b'.repeat(1500000));
System.debug(LoggingLevel.Fine, 'c'.repeat(1500000));
System.debug(LoggingLevel.Finest, 'd'.repeat(1500000));

Update: It appears to be nondeterministic. Running the same anonymous Apex with the same logging levels results in differing log output. Sometimes only the b's messages appear along with a skipped message. Sometimes the a's appear. Sometimes I get a MAXIMUM DEBUG LOG SIZE REACHED.

A: Salesforce basically takes the first 2MB of your debug log text and prints it.  Anything past that 2MB cutoff is not output on the logs, but the size of the text if it were to show up is what is shown in the "Skipped * bytes".  What is shown in the Debug Logs is specified based on your Debug Profile Debug Levels for each Debug Type.  As a best practice, if debugging Apex code, I always put:
System.debug(LoggingLevel.ERROR, '<debug message>');

Then set the debug level to ERROR for Apex Code.  That way it filters out a lot of the junk that Apex will put in your logs by default. Make sure to turn off any types that you aren't interested in as well.  Salesforce is working on improving debugging (added a new trace feature), but definitely need to increase this log size as they often put a lot of junk that is hard to get rid of and eats up all the debug log space.


text:
Q: Read file without disk caching in Linux I have a C program that runs only weekly, and reads a large amount of files only once. Since Linux also caches everything that's read, they fill up the cache needlessly and this slows down the system a lot unless it has an SSD drive.
So how do I open and read from a file without filling up the disk cache?
Note:
By disk caching I mean that when you read a file twice, the second time it's read from RAM, not from disk. I.e. data once read from the disk is left in RAM, so subsequent reads of the same file will not need to reread the data from disk.

A: You can use posix_fadvise() with the POSIX_FADV_DONTNEED advice to request that the system free the pages you've already read.

A: I believe passing O_DIRECT to open() should help:

O_DIRECT (Since Linux 2.4.10)
Try to minimize cache effects of the I/O to and from this file. In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user space buffers. The O_DIRECT flag on its own makes at an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC that data and necessary metadata are transferred. To guarantee synchronous I/O the O_SYNC must be used in addition to O_DIRECT.

There are further detailed notes on O_DIRECT towards the bottom of the man page, including a fun quote from Linus.


text:
Q: Basis of multivariate polynomials with a specified set of roots I'm studying certain polynomials of 2 complex variables, say x and y. These polynomials have roots at the non-negative integers, that is both $x$ and $y$ have to be
$x,y \in \mathbb{N}$
simultaneously with the restriction that
$x+y \leq A$
for some non-negative integer A. I'd like to know the basis for these polynomials of minimal total degree (sum of degrees in $x$ and $y$), up to overal constants. I think this basis is:
$\left(x \atop n\right)\left(y \atop A+1-n\right)$
for integer $n$ with $0 \leq n \leq A+1$. The brackets are falling factorials:
$\left(x \atop n\right) = x (x-1)....(x-n-1)$
with
$\left(x \atop 0\right)\equiv 1$
At the moment I have only a proof-by-lack-of-imagination argument that this is the full set. Of course, I'd also like to know how to generalize to multiple complex variables :)


text:
Q: Web Services using Java on NetBeans Is this piece of code totally wrong? I am making a web service for a uni project. Is it possible to connect to a database while in a web service method.
The code of the connection works when in a standard SE project, but when in the web service the NetBeans will not let me deploy the project, it says it cannot create WSDL.
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.me.calculator;
 import com.mysql.jdbc.Statement;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
 import javax.jws.WebService;
 import javax.jws.WebMethod;
 import javax.jws.WebParam;
 import javax.ejb.Stateless;

 /**
 *
 * @author ericman
  */
  @WebService(serviceName = "CalculatorWS")
  @ Stateless()
  public class CalculatorWS {

/**
 * Web service operation
 */
@WebMethod(operationName = "UppDateBook")
public String UppDateBook(@WebParam(name = "name") String name) throws SQLException {
    //TODO write your implementation code here:
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost/bookcatalog","ericman","ericman");
    Statement stmt = (Statement) con.createStatement();
    String insert = "INSERT INTO `bookcatalog`.`books` (`name`, `isbn`, `price`, `publisher`, `img`) VALUES ('BookOne', '12456789', '45', 'publisher', 'httpfile');";
    int numUpdate = stmt.executeUpdate(insert);
    stmt.close();
    return null;
}

}
Error Message

SEVERE: Unable to find adpater for endpoint
  WARNING: MEX0008:Failed to parse metadata returned from server at http://localhost:8080/WebSercviceOne/WebSercviceOne?WSDL/mex using protocol SOAP_1_1. Continuing attempts.
  INFO: [ERROR] Server returned HTTP response code: 405 for URL: http://localhost:8080/WebSercviceOne/WebSercviceOne?WSDL
  Failed to read the WSDL document: http://localhost:8080/WebSercviceOne/WebSercviceOne?WSDL, because 1) could not find the document; /2) the document could not be read; 3) the root element of the document is not .
  INFO: [ERROR] failed.noservice=Could not find wsdl:service in the provided WSDL(s):
   At least one WSDL with at least one service definition needs to be provided.
  INFO:   Failed to parse the WSDL.
  INFO: Invoking wsimport with http://localhost:8080/WebSercviceOne/WebSercviceOne?WSDL
  SEVERE: wsimport failed
  INFO: Metro monitoring rootname successfully set to: amx:pp=/mon/server-mon[server],type=WSEndpoint,name=WebSercviceOne-WebSercviceOnePort
  WARNING: Container org.glassfish.webservices.JAXWSContainer@7339ea2c doesn't support class com.sun.xml.ws.api.server.Module
  INFO: WS00019: EJB Endpoint deployed
   ServiceOne  listening at address at http://ericman-PC:8080/WebSercviceOne/WebSercviceOne
  INFO: WEB0671: Loading application [ServiceOne] at [/ServiceOne]
  INFO: ServiceOne was successfully deployed in 511 milliseconds.
  INFO: parsing WSDL...

A: You can't throw an exception that way, you need to create your own exceptions respecting theses points:
1) Your custom exception is a class that extends Exception.
2) add the tag @WebFault(name="exception name") to your exception class
3) Create a bean that saves the exceptio message this bean has a String argument with all the constructors and a getter.
4) Your exception class needs to have an attribute of that bean.
5) must have two constructors one with a message and an instance of the bean, the other with a message, the instance of the bean and a Throwable object representig the issue.


text:
Q: generating HTML on server for conversion api I am looking into the converstion api to generate pdf documents from HTML.
I have lot of complex HTML that should be generated dynamically.  What is the best way to generate complex HTML on appengine server so that, I can use it in the conversion api.
Asset asset = new Asset(
    "text/html", "some data".getBytes(), "testfile.html");
In the above the second param is the HTML.  What if I have complex HTML? What is a good way to generate the HTML, so that it is maintainable and readable.
-Aswath

A: If you are looking for a way to generate some complex HTML and also going to inject some data into it, some templating engine (Velocity, FreeMarker or any other) would be useful here.
On the other side if you want to prepare some nice looking and readable template in a quick way, I suggest you using Google Docs for it. App Engine's Conversion API and Google Docs "Export as PDF" feature share the same backend, so you can easily edit the template in Google Docs, then use "Export as HTML" feature to get the HTML, using it with GAE conversion API you will get the same result as if you'd download it as PDF in Google Docs.


text:
Q: Default task outcome buttons won't show in SharePoint 2013 task Created a simple list workflow in SPD 2013 with 'Start task process' action.  Didn't change any default values.  Plan is to assign a task to multiple users to review a document, every time user adds one to document library. All works well. My list workflow sends an e-mail to user with the assign task.
My problem is, default task outcome ( Approved, Rejected) doesn't show up on the task form.  It only shows the 'close' button along with other task information.
How do I get my default options to show up on the task form ?

A: You need to press Edit Item button to see buttons you want to see - Approve, etc..

A: This happens, somehow, when you edit and add some code in the page or add code in content editor webpart, in any edit form of Task lists... If you have your edit form full default, it will show task outcome options as buttons again. It happens me when I tryed to hide the Content Type field from edit form, but I have the same issue that you.
Hope this helps you in some way.


text:
Q: Echoing HTML links If I am calling a list of links from a mysql table named categories I think I use a select statement like:
  $query = "SELECT cat_name, cat_description FROM categories";
  $result = mysqli_query($dbc, $query)
    or die('Error querying database.');

  while ($row = mysqli_fetch_array($result)){
    echo '$row';
  }

These categories have been joined with a business_info table in a mapping_table (they have a many to many relationship). I think that at the moment this will echo a string for each category name so I don't understand how I make my echoed results active links which will display the business info when clicked.
I know that once clicked they will issue a SELECT statement to the mapping_table which i'm cool with. the bit i'm struggling with is making them clickable to issue that statement. Any ideas, i'm lost!
EDIT: I edited out the AND clause. I was wrong.

A: Your SQL is invalid. It shoudd be
SELECT cat_name, cat_description FROM categories

Your die() clause should be
... or die (mysql_error())

so you can see exactly what the error was (a fixed string is useless for debugging purposes). And then your retrieval loop should be:
while($row = mysql_fetch_assoc($result)) {
    echo <<<EOL
{$row['cat_description']}

EOL;
}


text:
Q: Javascript play youtube API (+queue videos) Basically, i alrdy managed to create a website to search for videos using the youtube video api.
I would like now to add a youtubevideo player (iframe?), and possibly be able to queue videos (url) from a text input.
My next question, i found on the internet the required code for using an iframe,
but the script is all in html page, and i was wondering if it was possible to place the code in my JS page.. i tried it, but doesn't work... I thought that placing the syntaxes between  &  in my js file would do it...
Can someone explain how i can make it work while placing the code in my js file?
I know it's prboably a stupid question...
Thanks a lot!

A: i tried it the following way;
in html:

in js;
      // 2. This code loads the IFrame Player API code asynchronously.
      var tag = document.createElement('script');

..... etc
      }


text:
Q: string[] count is passed to ComboBox, but string[] value is not i've used a method,
public static string[] getMyStrings()

and passed it to a combobox like:
cmbMyBox.itemsSource  = getMyStrings(). //(more detail below)

the debugger  shows the strings have been added to the combobox, but when i look in the combobox the number of entries are there, but blank. anyone know what i'm doing wrong?
my list of devices:
public static string[] GetMIDIInDevices()
    {
        //get list of devices
        string[] returnDevices = new string[MidiIn.NumberOfDevices];

        // Get the product name for each device found
        for (int device = 0; device < MidiIn.NumberOfDevices; device++)
        {
            returnDevices[device] = MidiIn.DeviceInfo(device).ProductName;
        }
        return returnDevices;
    }

The simple code to display it on my main window in WPF:
public MainWindow()
    {
        InitializeComponent();
        cmbMidiDropdown.ItemsSource = NAudioMIDI.GetMIDIInDevices();
        //LoadMidiInDevicesIntoComboBox();
    }

here's the XAML:
<TabItem Header="MIDI Settings" Name="tabMidiSettings" Background="DarkGoldenrod">
            <Grid  Background="Honeydew">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="10" />
                    <ColumnDefinition Width="758" />
                </Grid.ColumnDefinitions>
                <ComboBox Grid.Column="1" Height="23" HorizontalAlignment="Right" Margin="0,141,146,0" Name="cmbMidiDropdown" VerticalAlignment="Top" Width="312"  ItemsSource="{Binding}" DisplayMemberPath="Name" />
                <Label Content="Select Midi Input device" Grid.Column="1" Height="28" HorizontalAlignment="Left" Margin="143,141,0,0" Name="label1" VerticalAlignment="Top" />
            </Grid>
        </TabItem>

DEBUGGER OUTPUT:
GetMIDIInDevices()
-       returnDevices   {string[3]} string[]
    [0] "MIDISPORT 2x2 In A"    string
    [1] "MIDISPORT 2x2 In B"    string
    [2] "Turtle Beach USB MIDI 1x1" string
    returnDevices[device]   "Turtle Beach USB MIDI 1x1" string

cmbMIDIDropdown
+       cmbMidiDropdown {System.Windows.Controls.ComboBox Items.Count:3}
-       cmbMidiDropdown.ItemsSource {string[3]}
-       [string[]]  {string[3]} string[]
    [0] "MIDISPORT 2x2 In A"    string
    [1] "MIDISPORT 2x2 In B"    string
    [2] "Turtle Beach USB MIDI 1x1" string

A: You are setting the ItemsSource in XAML, and the DisplayMemberPath as well.  When you set the ItemsSource in code, you are not changing the DisplayMemberPath, so the combobox is trying to call each object's .Name property.   String does not have a .Name, so you are getting blanks.  Remove the ItemsSource and DisplayMemberPath from your xaml, and you should see the values you expect.

A: Try this...
cmbMidiDropdown.DataContext = NAudioMIDI.GetMIDIInDevices();

You're setting your ItemsSource to inherit the DataContext by setting the {Binding} on the ItemsSource property. In doing this simply setting the DataContext of your ComboBox to the listing of strings will allow the ComboxBox to populate accordingly.
Also, setting your DisplayMemberPath is not needed since you are setting the ItemsSource as a listing of strings versus complex objects and a Name property does not exist on the string class.


text:
Q: Showing median value in grouped boxplot in R I have created boxplots using ggplot2 with this code.
plotgraph <- function(x, y, colour, min, max)
{
    plot1 <- ggplot(dims, aes(x = x, y = y, fill = Region)) +
        geom_boxplot()
    #plot1 <- plot1 + scale_x_discrete(name = "Blog Type")
    plot1 <- plot1 + labs(color='Region') + geom_hline(yintercept = 0, alpha = 0.4)
    plot1 <- plot1 + scale_y_continuous(breaks=c(seq(min,max,5)), limits = c(min, max))
    plot1 <- plot1 + labs(x="Blog Type", y="Dimension Score") + scale_fill_grey(start = 0.3, end = 0.7) + theme_grey()
    plot1 <- plot1 + theme(legend.justification = c(1, 1), legend.position = c(1, 1))
    return(plot1)
}
plot1 <- plotgraph (Blog, Dim1, Region, -30, 25)

A part of data I use is reproduced here.
Blog,Region,Dim1,Dim2,Dim3,Dim4
BlogsInd.,PK,-4.75,13.47,8.47,-1.29
BlogsInd.,PK,-5.69,6.08,1.51,-1.65
BlogsInd.,PK,-0.27,6.09,0.03,1.65
BlogsInd.,PK,-2.76,7.35,5.62,3.13
BlogsInd.,PK,-8.24,12.75,3.71,3.78
BlogsInd.,PK,-12.51,9.95,2.01,0.21
BlogsInd.,PK,-1.28,7.46,7.56,2.16
BlogsInd.,PK,0.95,13.63,3.01,3.35
BlogsNews,PK,-5.96,12.3,6.5,1.49
BlogsNews,PK,-8.81,7.47,4.76,1.98
BlogsNews,PK,-8.46,8.24,-1.07,5.09
BlogsNews,PK,-6.15,0.9,-3.09,4.94
BlogsNews,PK,-13.98,10.6,4.75,1.26
BlogsNews,PK,-16.43,14.49,4.08,9.91
BlogsNews,PK,-4.09,9.88,-2.79,5.58
BlogsNews,PK,-11.06,16.21,4.27,8.66
BlogsNews,PK,-9.04,6.63,-0.18,5.95
BlogsNews,PK,-8.56,7.7,0.71,4.69
BlogsNews,PK,-8.13,7.26,-1.13,0.26
BlogsNews,PK,-14.46,-1.34,-1.17,14.57
BlogsNews,PK,-4.21,2.18,3.79,1.26
BlogsNews,PK,-4.96,-2.99,3.39,2.47
BlogsNews,PK,-5.48,0.65,5.31,6.08
BlogsNews,PK,-4.53,-2.95,-7.79,-0.81
BlogsNews,PK,6.31,-9.89,-5.78,-5.13
BlogsTech,PK,-11.16,8.72,-5.53,8.86
BlogsTech,PK,-1.27,5.56,-3.92,-2.72
BlogsTech,PK,-11.49,0.26,-1.48,7.09
BlogsTech,PK,-0.9,-1.2,-2.03,-7.02
BlogsTech,PK,-12.27,-0.07,5.04,8.8
BlogsTech,PK,6.85,1.27,-11.95,-10.79
BlogsTech,PK,-5.21,-0.89,-6,-2.4
BlogsTech,PK,-1.06,-4.8,-8.62,-2.42
BlogsTech,PK,-2.6,-4.58,-2.07,-3.25
BlogsTech,PK,-0.95,2,-2.2,-3.46
BlogsTech,PK,-0.82,7.94,-4.95,-5.63
BlogsTech,PK,-7.65,-5.59,-3.28,-0.54
BlogsTech,PK,0.64,-1.65,-2.36,-2.68
BlogsTech,PK,-2.25,-3,-3.92,-4.87
BlogsTech,PK,-1.58,-1.42,-0.38,-5.15
Columns,PK,-5.73,3.26,0.81,-0.55
Columns,PK,0.37,-0.37,-0.28,-1.56
Columns,PK,-5.46,-4.28,2.61,1.29
Columns,PK,-3.48,2.38,12.87,3.73
Columns,PK,0.88,-2.24,-1.74,3.65
Columns,PK,-2.11,4.51,8.95,2.47
Columns,PK,-10.13,10.73,9.47,-0.47
Columns,PK,-2.08,1.04,0.11,0.6
Columns,PK,-4.33,5.65,2,-0.77
Columns,PK,1.09,-0.24,-0.92,-0.17
Columns,PK,-4.23,-4.01,-2.32,6.26
Columns,PK,-1.46,-1.53,9.83,5.73
Columns,PK,9.37,-1.32,1.27,-4.12
Columns,PK,5.84,-2.42,-5.21,1.07
Columns,PK,8.21,-9.36,-5.87,-3.21
Columns,PK,7.34,-7.3,-2.94,-5.86
Columns,PK,1.83,-2.77,1.47,-4.02
BlogsInd.,PK,14.39,-0.55,-5.42,-4.7
BlogsInd.,US,22.02,-1.39,2.5,-3.12
BlogsInd.,US,4.83,-3.58,5.34,9.22
BlogsInd.,US,-3.24,2.83,-5.3,-2.07
BlogsInd.,US,-5.69,15.17,-14.27,-1.62
BlogsInd.,US,-22.92,4.1,5.79,-3.88
BlogsNews,US,0.41,-2.03,-6.5,2.81
BlogsNews,US,-4.42,8.49,-8.04,2.04
BlogsNews,US,-10.72,-4.3,3.75,11.74
BlogsNews,US,-11.29,2.01,0.67,8.9
BlogsNews,US,-2.89,0.08,-1.59,7.06
BlogsNews,US,-7.59,8.51,3.02,12.33
BlogsNews,US,-7.45,23.51,2.79,0.48
BlogsNews,US,-12.49,15.79,-9.86,18.29
BlogsTech,US,-11.59,6.38,11.79,-7.28
BlogsTech,US,-4.6,4.12,7.46,3.36
BlogsTech,US,-22.83,2.54,10.7,5.09
BlogsTech,US,-4.83,3.37,-8.12,-0.9
BlogsTech,US,-14.76,29.21,6.23,9.33
Columns,US,-15.93,12.85,19.47,-0.88
Columns,US,-2.78,-1.52,8.16,0.24
Columns,US,-16.39,13.08,11.07,7.56

Even though I have tried to add detailed scale on y-axis, it is hard for me to pinpoint exact median score for each boxplot. So I need to print median value within each boxplot. There was another answer available (for faceted boxplot) which does not work for me as the printed values are not within the boxes but jammed together in the middle. It will be great to be able to print them within (middle and above the median line of) boxplots.
Thanks for your help.
Edit: I make a grouped graph as below.
Add

A: library(dplyr)
dims=dims%>%
  group_by(Blog,Region)%>%
  mutate(med=median(Dim1))
plotgraph <- function(x, y, colour, min, max)
{
  plot1 <- ggplot(dims, aes(x = x, y = y, fill = Region)) +
    geom_boxplot()+
    labs(color='Region') +
    geom_hline(yintercept = 0, alpha = 0.4)+
    scale_y_continuous(breaks=c(seq(min,max,5)), limits = c(min, max))+
    labs(x="Blog Type", y="Dimension Score") + scale_fill_grey(start = 0.3, end = 0.7) +
    theme_grey()+
    theme(legend.justification = c(1, 1), legend.position = c(1, 1))+
    geom_text(aes(y = med,x=x, label = round(med,2)),position=position_dodge(width = 0.8),size = 3, vjust = -0.5,colour="blue")
  return(plot1)
}
plot1 <- plotgraph (Blog, Dim1, Region, -30, 25)

Which gives (the text colour can be tweaked to something less tacky):

Note: You should consider using non-standard evaluation in your function rather than having it require the use of attach()
Edit:
One liner, not as clean I wanted it to be since I ran into problems with dplyr not properly aggregating the data even though it says the grouping was performed.
This function assume the dataframe is always called dims
library(ggplot2)
library(reshape2)
plotgraph <- function(x, y, colour, min, max)
{
  plot1 <- ggplot(dims, aes_string(x = x, y = y, fill = colour)) +
    geom_boxplot()+
    labs(color=colour) +
    geom_hline(yintercept = 0, alpha = 0.4)+
    scale_y_continuous(breaks=c(seq(min,max,5)), limits = c(min, max))+
    labs(x="Blog Type", y="Dimension Score") +
    scale_fill_grey(start = 0.3, end = 0.7) +
    theme_grey()+
    theme(legend.justification = c(1, 1), legend.position = c(1, 1))+
    geom_text(data= melt(with(dims, tapply(eval(parse(text=y)),list(eval(parse(text=x)),eval(parse(text=colour))), median)),varnames=c("Blog","Region"),value.name="med"),
              aes_string(y = "med",x=x, label = "med"),position=position_dodge(width = 0.8),size = 3, vjust = -0.5,colour="blue")
  return(plot1)
}
plot1 <- plotgraph ("Blog", "Dim1", "Region", -30, 25)

A: Assuming that Blog is your dataframe, the following should work:
min <- -30
max <- 25
meds <- aggregate(Dim1~Region, Blog, median)
plot1 <- ggplot(Blog, aes(x = Region, y = Dim1, fill = Region)) +
  geom_boxplot()
plot1 <- plot1 + labs(color='Region') + geom_hline(yintercept = 0, alpha = 0.4)
plot1 <- plot1 + scale_y_continuous(breaks=c(seq(min,max,5)), limits = c(min, max))
plot1 <- plot1 + labs(x="Blog Type", y="Dimension Score") + scale_fill_grey(start = 0.3, end = 0.7) + theme_grey()
plot1 + theme(legend.justification = c(1, 1), legend.position = c(1, 1)) +
  geom_text(data = meds, aes(y = Dim1, label = round(Dim1,2)),size = 5, vjust = -0.5, color='white')


text:
Q: How to add additional data column in EF using ASP.Net MVC 2 My Table:
[LocationId]
[Address]
[ZipCode]

When I show a list of Location's, I also want to show the distance from a given zip code.
In Asp.Net Web Forms I had a stored procedure that would return the distance and I would call this SP on ItemDataBound on my GridView.
Or, I also would have my SP that is returning the Location list add another column ([Distance]) which I could display in my GridView.
How would you do this using Entity Framework and Asp.Net Mvc 2?

A: Me?
LocationPresentation model = Repository.Locations
                                       .Where(l => l.Id == someId)
                                       .AsEnumerable()
                                       .Select(l => new LocationPresentation
                                                    {
                                                        Id = l.Id,
                                                        Address = l.Address,
                                                        ZipCode = l.ZipCode,
                                                        Distance = DistanceLib.ComputeDistance(someZIP, l.ZipCode)
                                                     });
return View(model);


text:
Q: How to make a deleted site collection disappear in search result? I have several deleted site collections which cannot be seen in active and deleted sites in new SharePoint admin center. Attempting to browse them in the browser would return 404 File Not Found. However, when I type the names in the search bar, they appear among the results.
I have seen something like full crawl or re-index. But those are mostly for SharePoint Servers not Online and I cannot access the setting page of those sites. Is there any way to make those sites disappear from the search result?
Thanks in advance.


text:
Q: how to work with WritableComparator Hadoop Below are my code snippet for using WritableComparator, but it does not work

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

public class MovieComparator extends WritableComparator{

    public MovieComparator(){
        super(Movie.class);
    }
    @Override
    public int compare(WritableComparable o,WritableComparable o2){
        System.out.println("in compare");
        Movie m = (Movie)o;
        Movie m2 = (Movie)o2;
        System.out.println(m.compareTo(m2));
        return m.movieId.compareTo(m2.movieId);
    }

}

public class Movie implements WritableComparable {

    Text movieId;
    Text movieTitle;

    public Movie(Text movieId, Text movieTitle) {

        this.movieId = movieId;
        this.movieTitle = movieTitle;
    }

    public Movie(){

    }

    public String getMovieId() {
        return movieId.toString();
    }

    public void setMovieId(String movieId) {
        this.movieId = new Text(movieId);
    }

    public String getMovieTitle() {
        return movieTitle.toString();
    }

    public void setMovieTitle(String movieTitle) {
        this.movieTitle = new Text(movieTitle);
    }

    @Override
    public void readFields(DataInput in) throws IOException {
        //movieId = in.read;
        movieId.readFields(in);
        movieTitle.readFields(in);
    }

    @Override
    public void write(DataOutput out) throws IOException {
        //out.writeUTF(movieId);
        //out.writeUTF(movieTitle);
        movieId.write(out);
        movieTitle.write(out);

    }

    @Override
    public int compareTo(Movie o) {

    //  System.out.println("in compareTo");
        int res=movieTitle.compareTo(o.movieTitle);
        return res;
    }

    @Override
    public int hashCode(){
        return movieId.hashCode();
    }

    @Override
    public boolean equals(Object o){
        Movie m=(Movie)o;
        return movieId.equals(m.movieId);
    }

    @Override
    public String toString(){
        return movieTitle.toString();
    }

}

In driver class I am setting the comparator by below line

job.setSortComparatorClass(MovieComparator.class);

Can any body tell me where I am wrong in this at it gives exception below

14/09/08 14:17:03 WARN mapred.LocalJobRunner: job_local_0001
java.io.IOException: Spill failed
    at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.collect(MapTask.java:1029)
    at org.apache.hadoop.mapred.MapTask$NewOutputCollector.write(MapTask.java:691)
    at org.apache.hadoop.mapreduce.TaskInputOutputContext.write(TaskInputOutputContext.java:80)
    at com.impetus.MovieMapper.map(MovieMapper.java:44)
    at com.impetus.MovieMapper.map(MovieMapper.java:1)
    at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:144)
    at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:370)
    at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:212)

A: I found the issue that Instead of using super(Movie.class), I will have to use super(Movie.class,true). As by sending true, WritableComparator will instantiate the object other wise it will pass null in compare method


text:
Q: Get the Values from the cells (ListView & ListViewItems) I have a ListView. My main goal is to be able, to copy the ListViewItems to the Clipboard and then to Excel. But I have troubles to read the ListView Cells.
To get the Columns I use:
var columnNames = new StringBuilder();

foreach (GridViewColumn column in ((GridView)(listViewSolution.View)).Columns)
{
       columnNames.Append(column.Header + "\t");
}

Now I want to add the rows, but I'm only able to access the first Cell in the first column, not the second or third..:
var stringBuilder = new StringBuilder();

for (int i = 0; i < listViewSolution.Items.Count; i++)
{
    stringBuilder.Append("\n");
    //foreach (GridViewColumn column in ((GridView)(listViewSolution.View)).Columns)
    //{
        //if (column.Header != null)
        //{
            ListViewItem myListBoxItem =
                (ListViewItem)(listViewSolution.ItemContainerGenerator.ContainerFromIndex(0)); //= Index 0 -> First Row, First Cell; Index 1 = Second Row, First Cell; But do we get: Second Column, First Row????
            stringBuilder.Append(myListBoxItem.Content.ToString() + "\t");
        //}
    //}
}
System.Windows.Clipboard.SetData(DataFormats.Text, columnNames.ToString() + stringBuilder.ToString());

Help would be much appreciated..

A: You're not changing the index in the .ContainerFromIndex call each iteration. Use your loop variable there and see what you get.


text:
Q: Materialize css and React js: Dropdown in Sidenav does not work I want to use React JS and Materialize to make an responsive Website. Therefore I created an Sidenav with Materialize. Unfortunately the Dropdown does not work. The dropdown is rendered as it should, and the corresponding items are displayed below it, without pressing anything. If I click on the dropdown button, nothing happens...
I would be extremely satisfied, if anyone could help me. I woud consider me as an beginner in React JS and in Materialize, so please be not too harsh with me. ;)
The React Class of my Sidenav:
var SideNav = React.createClass({
renderVoltageMenu: function () {
    return (

Bereiche

Dropdownarrow_drop_down

First

Second

Third

Fourth

    )
},

renderPowerMenu: function(){
    return (

Bereiche

Clickbox mean

clickbox actual

clickbox Pges, P1, P2, P3

    )
},

renderCemsMenu: function(){
    return (

Search...

Dropdown: Sortby ...

    )
},

renderGridoperatorContent: function(){
    return (
        <GridoperatorContent/>
    )
},

renderVoltageContent: function(){
    return (
        <VoltageContent/>
    )
},

renderPowerContent: function(){
    return (
        <PowerContent/>
    )
},

renderCemsContent: function(){
    return (
        <CemsContent/>
    )
},

getInitialState: function(){
    return({
        menu_name: 'gridoperator', //'gridoperator', 'voltage', 'power', 'cems'
    });
},

setMenuNameGridoperator: function(){
    this.setState({
        menu_name: 'gridoperator'
    });
},

setMenuNameVoltage: function(){
    this.setState({
        menu_name: 'voltage'
    });
},

setMenuNamePower: function(){
    this.setState({
        menu_name: 'power'
    });
},

setMenuNameCems: function(){
    this.setState({
        menu_name: 'cems'
    });
},

componentDidMount() {
    console.log("SideNav mounted");
    $(".dropdown").dropdown();
    $('.button-collapse').sideNav();
    // $('.button-collapse').sideNav({
    //         menuWidth: 300, // Default is 300
    //         closeOnClick: true, // Closes side-nav on  clicks, useful for Angular/Meteor
    //     }
    // );
    $('.collapsible').collapsible();
    $('.button-collapse').sideNav('show');
},

render() {
    return (

 {this.setMenuNameGridoperator()}}>Gridoperator

 {this.setMenuNameVoltage()}}>Spannung

 {this.setMenuNamePower()}}>Leistung

 {this.setMenuNameCems()}}>CEMS

                {(() => {
                    //Menu appearance depending on menu chosen
                    switch (this.state.menu_name) {
                        case "gridoperator":    return ;
                        case "voltage":         return this.renderVoltageMenu();
                        case "power":           return this.renderPowerMenu();
                        case "cems":            return this.renderCemsMenu();
                        default:                return ;
                    }
                })()}

            {(() => {
                //Content depending on menu chosen
                switch (this.state.menu_name) {
                    case "gridoperator":    return this.renderGridoperatorContent();
                    case "voltage":         return this.renderVoltageContent();
                    case "power":           return this.renderPowerContent();
                    case "cems":            return this.renderCemsContent();
                    default:                return this.renderGridoperatorContent();
                }
            })()}

    )
}

});


text:
Q: How do I get the menu program to restart after completing a selection? My program is stuck in an infinite loop after a selection is made and completed. It needs to restart and go through the menu options again. Any help would be greatly appreciated.
public static void main(String[] args) {
    // TODO Auto-generated method stub
    @SuppressWarnings("resource")
    Scanner input = new Scanner(System.in);

    System.out.println("Menu");
    System.out.println("1. Add");
    System.out.println("2. Subtract");
    System.out.println("3. Multiply");
    System.out.println("4. Divide");
    System.out.println("5. Generate a random number");
    System.out.println("6. Quit\n");

    System.out.print("What would you like to do? ");
    int choice = input.nextInt();
    int count = 0;

    while (choice < 1 || choice > 6){
        count ++;
        System.out.println("I'm sorry, " +choice+ " is not a valid option.\n");
        System.out.println("Menu");
        System.out.println("1. Add");
        System.out.println("2. Subtract");
        System.out.println("3. Multiply");
        System.out.println("4. Divide");
        System.out.println("5. Generate a random number");
        System.out.println("6. Quit\n");
        System.out.print("What would you like to do? ");
        choice = input.nextInt();
        if (choice >= 1 && choice <= 6){
            continue;
        }
        else if (count == 2){
            System.out.println("Please try again later.");
            System.exit(0);
            return;
        }
      }

    do
    {
        switch (choice)
        {
            case 1: choice = 1;

                System.out.print("What is the first number? ");
                int firstAdd = input.nextInt();
                System.out.print("What is the second number? ");
                int secondAdd = input.nextInt();
                System.out.println("Answer: " +(firstAdd + secondAdd));

                break;

            case 2: choice = 2;

                System.out.print("What is the first number? ");
                int firstSub = input.nextInt();
                System.out.print("What is the second nubmer? ");
                int secondSub = input.nextInt();
                System.out.println("Answer: " +(firstSub - secondSub));

                break;

            case 3: choice = 3;

                System.out.print("What is the first number?" );
                int firstMult = input.nextInt();
                System.out.print("What is the second number? ");
                int secondMult = input.nextInt();
                System.out.println("Answer: " +(firstMult * secondMult));

                break;

            case 4: choice = 4;

                System.out.print("What is the first number? ");
                double firstDiv = input.nextInt();
                System.out.print("What is the second number? ");
                double secondDiv = input.nextInt();

                    while (secondDiv == 0){
                        System.out.println("I'm sorry, you can't divide by zero.");
                        break;}
                    {

                    System.out.println("Answer: " +(firstDiv / secondDiv));
                    break;
                    }

            case 5: choice = 5;

                System.out.println(Math.random() * 10 + 1);

                break;

            case 6: choice = 6;

                System.out.println("Goodbye!");

                System.exit(0);
                return;
        }

    }while (choice >=1 && choice <= 6);

}

I've tried a few different options that I found in my book, but they seem to cause more errors in other areas. I don't know if there is a different statement than "break;" to use to restart the menu because this is my first time using cases.

A: Enclose everything after the scanner instantiation in a while loop.
Specifically,
while (true) {
    // your code
    if (choice == 6)
        break;
}

FIXED: Also remove the do {} while() loop. Your loop is infinite because "choice" does not change in the loop.


text:
Q: How do I highlight replaced words in PHP? I want to make it so that when I type in for example "hello i hope you have a good day bye" it will only highlight 'hello' and 'bye'. How would I go about doing this?
Because at the moment it currently highlights with yellow the whole line, which isn't what I want.
Here is my code below:
<?php
$words = $_POST['words'];
$words = preg_replace('/\bHello\b/i', 'Bonjour', $words);
$words = preg_replace('/\bbye\b/i', 'aurevoir', $words);
echo ''.$words.'';
?>

A:
<?php
$words = $_POST['words'];
$words = str_ireplace('Hello', 'Bonjour', $words);
$words = str_ireplace('bye', 'aurevoir', $words);
echo $words;
?>

A: Try something like this:
<?php
$words = $_POST['words'];
$words = str_replace("hello", "hello", $words);
$wirds = str_replace("bye", "bye", $words);

print($words);

?>

// CSS FILE
.highlight {
    background-color: yellow;
}

This would put a yellow background colour around "hello" and "bye" in the output.

A: Your problem
Your last line, the one that is echoing your result is wrong as you wrap your whole sentence in an highlighting context ( tag).
Solution

*

*You need to parse your original sentence ;

*wrap your keywords in an highlighting context.

You can do this in the preg_replace() function. I would also recommend the use of the  tag whom goal is to indicate relevance in context.
Code
<?php
$original_sentence = $_POST['words'];
$highlight_sentence = $original_sentence;
$word_to_highlight = array('Hello', 'Bye'); // list of words to highlight

foreach ($word_to_highlight as $word) {
  $pattern = printf('/\b%s\b/i', $word); // match a different word at each step
  $replace_by = printf('%s', $word); // replacement is updated at each step
  $highlight_sentence = preg_replace($pattern, $replace_by, $words);
}
?>

A: Yes, this approach is plausible, but font html tag IS obsolete, use span instead.


text:
Q: URL file access in php I am trying to include my header,footer and sidebar files like this,
include($str_url.'header.php');
include($str_url.'sidebar.php');
include($str_url.'footer.php');

i have defined $str_url = "http://www.example.com/"; in my constant file,
But is not working in my server.
how can i fix it?
Please help me.
Thanks.

A: You most probably don't want to include URLs into your main php file, but the local .php-files. include ('/path/to/a.php'); instead of include ('http://url/to/a.php');
(source: http://php.net/manual/en/function.include.php)

A: You probably need modify php.ini   allow_url_include = On.
But better never include files via http.

A: You should never include files via an absolut URL, because you will not be including the actual code, but the result of it.
Instead use relative paths or server paths (/home/user/public_html)
Easiest way would be via relative paths.
For example, if you have index.php and header.php in the same folder, you can just use:
    include('header.php');
If the files, are in another folder, for example you have header.php in an 'includes' folder, than you would use in your index.php:
    include('includes/header.php');


text:
Q: CSS vertical menu on two sides I'm trying to create a design with two vertical menus on each side of the main content part.
I tried various combinations of inline and relative and fixed positions but can't get it to work.
Fiddle: https://jsfiddle.net/g4vbampm/3/
The menus (red and blue blocks) should be right next to the middle green part (position:fixed put it at the edge of the screen to the left). They should also start at the top of the screen and never move. The height of the middle green part is going to change dynamically with js code.

.app {
  text-align: center;
}
.left {
  background: red;
  width: 150px;
  height: 300px;
  display: inline-block;
}
.center {
  background: green;
  width: 300px;
  height: auto;
  display: inline-block;
}
.right {
  background: blue;
  width: 150px;
  height: 300px;
  display: inline-block;
}

    menu1

menu2

menu3

    CONTENT

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

    menu1

menu2

menu3

A: Try It Once

.app{
    text-align:center;
}

.left{
  background:red;
  width:150px;
  height:300px;
  position:fixed;
  float:left;
  left:0px;
}

.center{
  background:green;
  width:calc(100% - 300px);
  width:-webkit-calc(100% - 300px);
  width:-moz-calc(100% - 300px);
  height:auto;
  float:left;
  margin-left:150px;

}

.right{
  background:blue;
  width:150px;
  height:300px;
  position:fixed;
 float:left;
 right:0px;
}

menu1

menu2

menu3

CONTENT

a

a

a

a

a
a

a

a

a

a

a

a

a

a

a
a

a

a

a

a

a

a

a

menu1

menu2

menu3

A: If you want to used fixed position for left and right divs even when u scroll than do like this.

* {
    margin: 0;
  }

.left,
.right {
  position: fixed;
  top: 0;
  width: 150px;
  height: 300px
}

.left {
  left: 0;
  background: red;
}

.right {
  right: 0;
  background: blue;
}

.center {
  width: calc(100% - 300px);
  margin: 0 auto;
  background: green;
}

    content

    content
    content
    contentcontent

    contetn

    content

Remember, use * { margin: 0 } only if you didn't reset your html.

A: The following should work for you:
.app{
        text-align:center;
    }

    .left{
      position:fixed;
      background:red;
      width:150px;
      height:300px;
      left:0;
      float: left;
    }

    .center{
      position: relative;
      background:green;
      width:300px;
      height:auto;
      left: 140px;
      float: left;
    }

    .right{
      position: fixed;
      background:blue;
      width:150px;
      height:300px;
      left: 445px;
      float: left;
    }

https://jsfiddle.net/9wnwL7rp/

A:
The menus (red and blue blocks) should be right next to the middle green part (position:fixed put it at the edge of the screen to the left). They should also start at the top of the screen and never move.

If they should "never move," then you want position:fixed (unless you want to constantly adapt the position via JavaScript, which is in most cases bad in terms of performance and visual outcome.)
Fixed positioning always takes the viewport as reference point. But you can still use it here, if you calculate the position dynamically.
Your middle element is 300px wide, so the other two elements need to be positioned at 50% + 150px, from the right resp. left (the opposite in each case.)
.left,
.right {
  position: fixed;
  top: 0;
}
.left{
  background:red;
  width:150px;
  height:300px;
  right: calc(50% + 150px);
}
.right{
  background:blue;
  width:150px;
  height:300px;
  left: calc(50% + 150px);
}

https://jsfiddle.net/g4vbampm/4/
Browser support for calc is pretty good, http://caniuse.com/#search=calc
If you need it to work in browsers that don't support calc, you can also use a negative margin to offset the elements from the middle,
.left{
  right: 50%;
  margin-right: 150px;
}

https://jsfiddle.net/g4vbampm/7/

A: Try to use css float property. http://www.w3schools.com/css/css_float.asp. But you have to split your main container into 3 columns. So .left class will have width 33.3% so on and so on. If you want some good html framework for grid system try to take a look on http://getbootstrap.com/ grid system


text:
Q: Does the sign "Take Free" make sense? The two-word sign "take free" in English is increasingly used in Japan to offer complimentary publications and other products. Is the phrase, which is considered kind of trendy in Japan, also used in English-speaking countries with the same meaning? Does it make sense to native English speakers? Is another phrase "take one free" a better choice of expression?

A: "Take free" is not a conventional expression in English and it's not grammatically correct either.
Here are some expressions which would be more commonly seen, on complimentary magazines and so on:
"Complimentary"
"Free"
"Free - take one"
"Please help yourself"
"Please take one"
Here's some real life examples:

A: I live in the U.S.  When people set a give-away out by the edge of the street for anyone to adopt, they usually write the following minimalist message, so they can write with really big, fat letters and use the whole space on their piece of cardboard:
FREE
This can also be used for free newspapers and advertising brochures, as one of J. Taylor's pictures showed.

A: As Japanese has no articles or concept of noun singular or plural, "Take Free" would  not burden the ears of a native Japanese speaker.
It does burden the English speaker. The imperative "take" is clearly a verb, but it has no grammatical object. "Free" , alone, is hard to compute in English as an object, and probably wouldn't be one in any event. "Free" is just too much an adjective.

Take one free

is better.

Please take one

is fine

Free

would work as well. While "free", alone,  has no article indicating a number, "free" alone creates no burden on the English speaker.

A: I would also add "free for the taking" to the list. But "take free" while sounding strange to native English speakers could be allowed for brevity.


text:
Q: Why Java provides two methods to remove element from Queue? The Queue implementation in Java has two methods to remove element, One is remove() which throws exception and other one is poll() which returns null for an empty queue. I have two doubts:

*

*Why Queue has different implementation to remove element?

*Which implementation to use When?

A: Remove() method differs from poll only in that it throws an exception if this queue is empty.

A: Looking at the answers, it wasn't clear to me which did what,hence:
Straight from the API :
The remove() and poll() methods differ only in their behavior when the queue is empty: the remove() method throws an exception, while the poll() method returns null

A: When you know how to react right now and/or expect elements to be absent then use poll.
Otherwise use remove.

A: In some situations it's expected that a queue will be empty, and in those cases having a method that doesn't throw an exception is appropriate. In other situations it's an exceptional circumstance that the queue is empty, and an exception is appropriate.
Throwing exceptions incurs a performance penalty, and if it's the case that you expect the queue to be empty from time to time you don't want to have to handle the queue-empty-logic as catching an exception -- it's both costly and difficult to read.
In the opposite case where you don't expect the queue to ever be empty it is a sign of a programming error, or some other exceptional circumstance that it is, and you don't want to write ugly error condition checking code (e.g. checking for null), because in this case that would be less readable than catching an exception (which you can do in another scope).

A: The abstract class AbstractQueue<E> implements Queue<E> and define the remove method.
You can take a look at source code:
public E remove() {
    E x = poll();
    if (x != null)
        return x;
    else
        throw new NoSuchElementException();
}

So, as you can see, the remove() method use poll() method.
You can use which one you prefer.

A: Sometimes you want a null value returned for an empty queue and sometimes you want it to treat an empty queue as a exception case.

A: The two methods are used differently in classic discussions about a Queue structure. I use poll() mostly to retrieve items, and remove() mostly if I need to modify the Queue outside of the normal loop.


text:
Q: Are there examples of how to use UIPopoverController on iOS? I've seen some demos where UIPopoverController is used and would like to use it in my apps.
So does anyone have any good tutorials that you could link me?
Is it possible to use it in relation to UISegmentedControl where different popover windows are summoned when different segments are selected as a type of a switch view function?

A: Here are some tutorials:

*

*iPad for iPhone Developers 101: UIPopoverController Tutorial

*[iPad App Video] iPad App Tutorial – UIPopoverController
Segmented Popover:

*

*Using a UISegmentedControl in the footer of UIPopoverController

*Buttons inside of a Pop Over Controller on the iPad, no UISegmentUISegmentedControl used but looks like one

A: *

*For popover in iPad we can use ActionSheetStringPicker, and for implementing it in your project you need to import ActionSheetStringPicker into your controller.
like - #imaport "ActionSheetStringPicker.h"

*After importing this you have to create an array which has only string type value.
e.g.
   NSArray *sourceArray=[[NSArray alloc]initWithObjects:@"Take Photo",@"Choose Photo", nil];

*And last you have to implement below method.
[ActionSheetStringPicker showPickerWithTitle:@"Any title"
                                            rows:sourceArray
                                initialSelection:yourInitialSelectionIntValue
                                       doneBlock:^(ActionSheetStringPicker *picker, NSInteger selectedIndex, id selectedValue) {

                                       NSLog(@" Index : %ld, value : %@",
                                             (long)selectedIndex, selectedValue);
                                       if ([selectedValue isEqualToString:@"Choose Photo"]) {

                                           // open photo lib
                                           [self youerMethdeOpenPhotoLib];

                                       }
                                       else
                                       {
                                           // open Camera
                                           [self yourMethodOpenCamera];
                                       }

                                   }
                                 cancelBlock:^(ActionSheetStringPicker *picker) {
                                     NSLog(@"Select photo Cancel");

                                 }origin:YourTapButtonObject];


text:
Q: Running Jobs in Kubernetes I'm trying to develop a scraping app in which I run a lot of different selenium scripts that are all dependent upon each other. I figured that using Kubernetes would be a good idea for this. In order for this to work, I need the scripts to be able to communicate with each other so I can trigger them to run after each other. How can I accomplish this?
This is an example of some logic that I'm want to perform:

*

*Fire of an container, X, that eventually creates a JSON file of some gathered data

*Give access to the JSON file to another container, Y.

*Trigger the Y container to run

I would appreciate any help that I can get!

A: The concept of Jobs sounds exactly like the stuff you'd like to achieve.

A Job creates one or more Pods and ensures that a specified number of them successfully terminate. As pods successfully complete, the Job tracks the successful completions. When a specified number of successful completions is reached, the task (ie, Job) is complete. Deleting a Job will clean up the Pods it created.
A simple case is to create one Job object in order to reliably run one Pod to completion. The Job object will start a new Pod if the first Pod fails or is deleted (for example due to a node hardware failure or a node reboot).
You can also use a Job to run multiple Pods in parallel.

Additionally, you might be interested in a concept of Init Containers.

Init containers are exactly like regular containers, except:
Init containers always run to completion.
     Each init container must complete successfully before the next one starts..
If a Pod's init container fails, Kubernetes repeatedly restarts the Pod until the init container succeeds.

And PV+PVC to store and share the data (JSON,etc)


text:
Q: Closure Capture Memory Leak issue with UITableView In willDisplay method, I get UIImage and IndexPath from a callback closure. I am using tableView inside that closure. Should I need to make that tableView weak to avoid possible memory leaks, or is it not an issue to use strong tableView?
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
    guard let cell = cell as? ArtistTableViewCell else { return }
    guard let imageUrl = cell.viewModel.artistImage() else { return }

    // Download image callback closure returns UIImage, IndexPath, and error
    ImageDownloadService.shared.downloadImage(imageUrl,indexPath:indexPath) { [weak tableView] (image, index, error) in
        DispatchQueue.main.async {
            guard let getIndexPath = index else { return }
            guard let getImage = image else { return }
            guard let getCell = tableView?.cellForRow(at: getIndexPath) as? ArtistTableViewCell else { return }

            getCell.setArtistImage(getImage)
        }
    }
}

A: It's not necessary to capture tableView explicitly because it's provided as local variable in the first parameter of the willDisplay method.
Therefore it will not cause a memory leak.
There is a simple rule: Don't capture anything which is locally accessible inside the method.
Feel free to prove it with Instruments.

A: Locale variables are not captured by closure as they are within the same scope, so you don't need to make tableview as weak reference.

A: weak is preferred. If you retain the tableView and dismiss the view controller while it downloads an image the table view object (and its cells) won't be deallocated until the call download finishes. (however no retain cycle will occur)


text:
Q: IIS 7 ssl port problem I am using ssl certificate for https://example.com/Pages/Membership/Registration.aspx and ı want to use ssl for subdomain https://host.example.com but IIS 7 error= port is using how can i bind sub domain 443 port

A: With SSL, you can only bind port 443 to one web site for that IP address.  To bind a second SSL certificate on port 443 you need to add another IP address to the NIC, then go into IIS Manager and edit the binding of the first web site and tell it to only use the first IP, and then you can bind the second (new) IP address to the subdomain website on it's port 443.
In short, for SSL, the combo of TCP port plus IP address has to be unique for each binding.


text:
Q: xamarin.ios mac build host version not compatible with local version I have installed on my visual studio and my mac . When I try to connect to my mac from visual studio I get this error :
http://i.stack.imgur.com/b63jF.jpg
What should I do ?Should i change version of my mac xamarin or VS?
Thanks

A: Make sure you do Check for Updates on both Mac and PC for Xamarin.

*

*Mac: "Xamarin Studio" -> Check for Updates

*PC: Tools -> Options ->
Xamarin -> Other -> Check for Updates

A: The most recent stable release of Xamarin.iOS is 9.0.1.29. The current alpha release is Xamarin.iOS 9.2.0.84, either way your versions of 8.x on VS and the OS-X build host are 'out of date'.

*

*https://releases.xamarin.com/stable-release-ios-9-support-service-release-1/
If you need to stay on 8.x, I would update your OS-X build host to 8.10 as it was the last stable service release of 8.x

*

*https://releases.xamarin.com/stable-release-cycle-5-service-release-4/

A: Just log in to your account on http://xamarin.com and then you can find the Downloads section in your account page, where you can click "View all versions" to see all versions, including 8.*. That should help you find a matching version.


text:
Q: Combining fields in a Couchbase Spring-Data Query I have a couchbase query that needs to search for a name, the object being searched stores firstName and lastName fields. My search query may be something like "Bob Smith", I have tried combining the fields in the query however this does not work ?
@Query("#{#n1ql.selectEntity} WHERE #{#n1ql.filter} AND LOWER(firstName) + ' ' + LOWER(lastName) LIKE $1 ")

A: I can't comment on the Java syntax, but as far as the N1QL query:
I believe you are trying to concatenate LOWER(firstName) and LOWER(lastName) with a space in between? In that case, use the concatenate operator of || instead of +.


text:
Q: findFragmentById(R.id.map) returns null in Android L While testing a location based app in Android 4.4 we were able to properly see and use map via Android maps v2
Since the time I upgraded to Android L it is not able to fetch MapFragment with the following code:

*

*In MainActivity there's a FrameLayout in which I load ShowMapFragment.

*In ShowMapFragment there is a MapFragment to  display map.

*Inside 'OnCreateView()' method
mapFragment = (MapFragment)getFragmentManager().findFragmentById(R.id.map);
map = mapFragment.getMap();
mapFragment is coming as null. Any help on this?

A: Got it. Posting this if anyone else faces the same issue. Basically we have to use getChildFragmentManager() instead of getFragmentManager() because the MapFragment is inside another fragemnt. See the answer by Rhisiart here.