问:
Unable to run docker-compose up command
I am inside organization infrastructure. And using Windows 7 machine. I have Hyper-V enabled and Docker toolbox installed. Due to firewall blocking while Docker, host machine cannot access, Oracle VM box machine, So, I have adopted an work around of port-forwarding and this helps me to pull image and start container as usual.

But whenever, I am trying to use docker-compose up, the command fails with error, docker-compose: not found

Version Details

```<code>Boot2Docker version 18.03.0-ce, build HEAD : 404ee40 - Thu Mar 22 17:12:23 UTC 2018
Docker version 18.03.0-ce, build 0520e24
</code>```

Step-1:

```<code>λ ssh docker@127.0.0.1 -p 51712
docker@127.0.0.1's password:
</code>```

Step-2: Navigating to folder where docker-compose.yml file is there and making it up.

```<code>docker@default:~$ cd /c/Users/pranaygupta/Docker/Images/artillery-tests/
docker@default:/c/Users/pranaygupta/Docker/Images/artillery-tests$ ls
artillery/          docker-compose.yml  grafana/
docker@default:/c/Users/pranaygupta/Docker/Images/artillery-tests$ docker-compose up
-sh: docker-compose: not found
</code>```

Any help to solve this issue, will be great help to me.

答: I was able to solve this issue by opening the internal proxy and setting to dedicated internal repository for installing docker-compose.</p>

Title: Unable to run docker-compose up command

Body:
I am inside organization infrastructure. And using Windows 7 machine. I have Hyper-V enabled and Docker toolbox installed. Due to firewall blocking while Docker, host machine cannot access, Oracle VM box machine, So, I have adopted an work around of port-forwarding and this helps me to pull image and start container as usual.

But whenever, I am trying to use docker-compose up, the command fails with error, docker-compose: not found

Version Details

Boot2Docker version 18.03.0-ce, build HEAD : 404ee40 - Thu Mar 22 17:12:23 UTC 2018
Docker version 18.03.0-ce, build 0520e24

Step-1:

λ ssh docker@127.0.0.1 -p 51712
docker@127.0.0.1's password:

Step-2: Navigating to folder where docker-compose.yml file is there and making it up.

docker@default:~$ cd /c/Users/pranaygupta/Docker/Images/artillery-tests/
docker@default:/c/Users/pranaygupta/Docker/Images/artillery-tests$ ls
artillery/          docker-compose.yml  grafana/
docker@default:/c/Users/pranaygupta/Docker/Images/artillery-tests$ docker-compose up
-sh: docker-compose: not found

Any help to solve this issue, will be great help to me.


来源: stackexchange

问:
Sort multiple sublists of list to create new list, Dart
I'm trying to sort an entire list according to one property. Afterwards I'd like to sort this list according to a second property, but in groups of 4. So, after sorting the list once, I want to look at the first 4 positions and sort only these 4 according to the second property - then move on to the next 4 positions and sort these again, and so on...

This is what I have so far:

```<code>class myElements {
  int Position;
  String text;
  int Top;
  int Left;

  myElements(int Position, String text, int Top, int Left){
    this.Position = Position;
    this.text = text;
    this.Top = Top;
    this.Left = Left;
  }
}
</code>```

```<code>var FirstList = new List<myElements>();
var newList = new List<myElements>();
</code>```

Adding Elements to my first list:

```<code>myElements Test = myElements(ElementNumber, text, Top, Left);
              FirstList.add(Test);
</code>```

Then sorting for the first time according to 'Top':

```<code> Comparator<myElements> TextComparator = (a, b) => a.Top.compareTo(b.Top);
      FirstList.sort(TextComparator);
</code>```

Here is where I'm stuck. I'm trying to sort the list again, but only in groups of 4 - this time according to 'Left':

```<code>   for (int i = 0; i < FirstList.length; i += 4) {
          Comparator<myElements> TextComparator2 = (a, b) =>
              a.Left.compareTo(b.Left);

          newList.addAll(FirstList.sublist(i, i + 3).sort(TextComparator2)); //this line does not work
        }
</code>```

I think I am stuck trying to access my sorted sublist: (FirstList.sublist(i, i + 4).sort(TextComparator2) . If I could add these to a new list, it should work.
However any other suggestions are more than welcome.

Thanks so much!

答:
newList.addAll(FirstList.sublist(i, i + 3).sort(TextComparator2)); //this line does not work
```
</blockquote>

<p>Your code is almost correct.  You have the right idea, but you ended up trying to do too much in one line of code.</p>

<p>Breaking it down a bit, your code is equivalent to:</p>

<pre class="lang-dart prettyprint-override"><code>var sublist = FirstList.sublist(i, i + 3);
newList.addAll(sublist.sort(...)); // Does not work
</code>```

And that doesn't work because List.sort does not return a value.  It mutates the list instead of returning a new list.

It would work if you instead did:

var sublist = FirstList.sublist(i, i + 3);
sublist.sort();
newList.addAll(sublist);
```

Also, List.sublist uses an exclusive end index.  If you want to create sublists with 4 elements, you would need to use sublist(i, i + 4).

ContentLicense: CC BY-SA 4.0

Body:
I'm trying to sort an entire list according to one property. Afterwards I'd like to sort this list according to a second property, but in groups of 4. So, after sorting the list once, I want to look at the first 4 positions and sort only these 4 according to the second property - then move on to the next 4 positions and sort these again, and so on...

This is what I have so far:

class myElements {
  int Position;
  String text;
  int Top;
  int Left;

  myElements(int Position, String text, int Top, int Left){
    this.Position = Position;
    this.text = text;
    this.Top = Top;
    this.Left = Left;
  }
}

var FirstList = new List<myElements>();
var newList = new List<myElements>();

Adding Elements to my first list:

myElements Test = myElements(ElementNumber, text, Top, Left);
              FirstList.add(Test);

Then sorting for the first time according to 'Top':

 Comparator<myElements> TextComparator = (a, b) => a.Top.compareTo(b.Top);
      FirstList.sort(TextComparator);

Here is where I'm stuck. I'm trying to sort the list again, but only in groups of 4 - this time according to 'Left':

   for (int i = 0; i < FirstList.length; i += 4) {
          Comparator<myElements> TextComparator2 = (a, b) =>
              a.Left.compareTo(b.Left);

          newList.addAll(FirstList.sublist(i, i + 3).sort(TextComparator2)); //this line does not work
        }

I think I am stuck trying to access my sorted sublist: (FirstList.sublist(i, i + 4).sort(TextComparator2) . If I could add these to a new list, it should work.
However any other suggestions are more than welcome.

Thanks so much!

Body:
newList.addAll(FirstList.sublist(i, i + 3).sort(TextComparator2)); //this line does not work

Your code is almost correct.  You have the right idea, but you ended up trying to do too much in one line of code.

Breaking it down a bit, your code is equivalent to:

var sublist = FirstList.sublist(i, i + 3);
newList.addAll(sublist.sort(...)); // Does not work

And that doesn't work because List.sort does not return a value.  It mutates the list instead of returning a new list.

It would work if you instead did:

var sublist = FirstList.sublist(i, i + 3);
sublist.sort();
newList.addAll(sublist);

Also, List.sublist uses an exclusive end index.  If you want to create sublists with 4 elements, you would need to use sublist(i, i + 4).


问:
Deleting documents from Cosmos Db collection during incremental load using Azure Data factory
I am trying to copy data from Azure SQL to Azure Cosmos Db Collection (Mongo API). I am using upsert to insert/update the documents on Cosmos Db. However, if any data from source is deleted, how do I delete that document from Cosmos Db.</p>

答:
As far as I am aware,it is impossible to deleting documents from Cosmos Db collection during incremental load.

Because,incremental load is comparing LastModifytime.If you delete rows in azure sql,them  don't exist in source and copy data only supports insert and update.

If you want to synchronized your data,please delete them in cosmos db manually.
You can run the delete sql in cosmos db or add a column DeleteStatus.When you want to delete data,update DeleteStatus and LastModifytimethen incremental load.Finally,run the sql both in cosmos db and azure sql:

delete from xxxx where DeleteStatus = 1

Hope these can help you.


问:
javascript Cannot pass variables between 2 functions
I am wondering how to pass a variable between 2 functions.

I have looked on Stackoverflow but all examples I tried did not work for me.

I have function, which calculates an array: arrR.

Now, I would like to call this variable somewhere else:

```<code>function my_function(arrR) {
    return(arrR[1]);
}

function onRefresh(chart) {
    chart.config.data.datasets.forEach(function(dataset) {
        dataset.data.push({
            x: Date.now(),
            y: myfunction(arrR)
        });
    });
}
</code>```

But y: myfunction(arrR) gives notting. I have checked that if I put some number say y: 1 this works.

Any clue ?

Many thanks

答:
Try this instead. Also check if arrR is exist or not by using console.log()

```<code>function onRefresh(chart) {
    chart.config.data.datasets.forEach(function(dataset) {
        arrR.length > 0 && dataset.data.push({
            x: Date.now(),
            y: myfunction(arrR)
        });
    });
}
</code>```

Body:
I am wondering how to pass a variable between 2 functions.

I have looked on Stackoverflow but all examples I tried did not work for me.

I have function, which calculates an array: arrR.

Now, I would like to call this variable somewhere else:

function my_function(arrR) {
    return(arrR[1]);
}

function onRefresh(chart) {
    chart.config.data.datasets.forEach(function(dataset) {
        dataset.data.push({
            x: Date.now(),
            y: myfunction(arrR)
        });
    });
}

But y: myfunction(arrR) gives notting. I have checked that if I put some number say y: 1 this works.

Any clue ?

Many thanks

Body:
Try this instead. Also check if arrR is exist or not by using console.log()

function onRefresh(chart) {
    chart.config.data.datasets.forEach(function(dataset) {
        arrR.length > 0 && dataset.data.push({
            x: Date.now(),
            y: myfunction(arrR)
        });
    });
}


问:
How do I create a reverse proxy that runs in Azure?
We have a static WordPress website that we would like to be able to scale ad-hoc.

In the long term we will move the site to eg. Umbraco CMS, but right now we would like to put in an Reverse Proxy frontend that takes the load of the current site.

We have tried writing out own HttpHandler (like this http://www.codeproject.com/KB/web-security/HTTPReverseProxy.aspx), but we want a more robust solutions that handles caching out of the box,  HTTP redirects (301, 302) etc.

We would like to be able to host this in a standard Azure WebRole, so we can spin up as many roles as needed.... that is, it should be configurable in web.config or by using a small simple startup task (*.cmd file).

Does anyone know of a solution for this?

答:
You can use Application Request Routing (ARR).  Take a look here:

http://things.smarx.com/#Install Application Request Routing

Also watch how Steve configured it as a reverse proxy in his talk from MIX:

http://channel9.msdn.com/events/MIX/MIX11/SVC04

ContentLicense: CC BY-SA 3.0


问:
How to delete table rows in word using Qt
I want to delete some table rows in a doc file by using QAxobject,like this:

```<code>QAxObject* range_delete = table->querySubObject("Rows(int)", 6);
if (range_delete) {
    range_delete->dynamicCall("Delete()");
}
</code>```

but it doesn't work,the range_delete always get Null.
So, How can i do this in a correct way ?
And then what if the number of rows is greater than 1?

答:
I find a way to solve this problem.
I found that, when there are vertically merged cells in the table, individual rows cannot be selected,So, the range_delete always get null.And then, I choose the oher way to select the row that I want to delete.
the code:

```<code>//step one ,select the cell that the row contains
QAxObject* cells = table_object->querySubObject("Cell(int,int)", i, 1);
//step two, get the row
QAxObject* range = cells->querySubObject("Range");
QAxObject* row = range_a->querySubObject("Rows");
//step three, delete it
row->dynamiCall("Delete()");
</code>```

Finally, it worked.
PS:All of this is about the tables in the Doc file.

Body:
I want to delete some table rows in a doc file by using QAxobject,like this:

QAxObject* range_delete = table->querySubObject("Rows(int)", 6);
if (range_delete) {
    range_delete->dynamicCall("Delete()");
}

but it doesn't work,the range_delete always get Null.
So, How can i do this in a correct way ?
And then what if the number of rows is greater than 1?

Body:
I find a way to solve this problem.
I found that, when there are vertically merged cells in the table, individual rows cannot be selected,So, the range_delete always get null.And then, I choose the oher way to select the row that I want to delete.
the code:

//step one ,select the cell that the row contains
QAxObject* cells = table_object->querySubObject("Cell(int,int)", i, 1);
//step two, get the row
QAxObject* range = cells->querySubObject("Range");
QAxObject* row = range_a->querySubObject("Rows");
//step three, delete it
row->dynamiCall("Delete()");

Finally, it worked.
PS:All of this is about the tables in the Doc file.


问:
Show only discontinuous points in Highcharts line graph
I am using a Highcharts line graph to show data that is sometimes discontinuous.  I have markers turned off because that was the display preference of our design team.  Isolated data points disappear, though, and are visible only on hover.

Is there a way to turn markers on, but only for isolated data points? (i.e. I do NOT want to set markers: {enabled: true}, but I do want the solitary point on the far right of the series to be displayed).

fiddle with example (note the isolated data point on the far right of the series - it is invisible unless you hover over the single point):

```<code>Highcharts.chart('container', {
    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },

    plotOptions: {
        series: {
            marker: {
                enabled: false
            }
        }
    },

    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, NaN, 54.4]
    }]
});
</code>```

default:

on hover:

EDIT:

I tried

```<code>...
       series: {
           marker: {
               enabled: true,
               radius: 1
           }
       }
...
</code>```

but the lone point is nearly invisible.

答:
You can enable markers for individual data points:

```<code>    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, NaN, {
            y: 54.4,
            marker: {
                enabled: true
            }
        }]
    }]
</code>```

Live demo: https://jsfiddle.net/BlackLabel/2prxc63m/

API Reference: https://api.highcharts.com/highcharts/series.line.data.marker.enabled

Body:
I am using a Highcharts line graph to show data that is sometimes discontinuous.  I have markers turned off because that was the display preference of our design team.  Isolated data points disappear, though, and are visible only on hover.

Is there a way to turn markers on, but only for isolated data points? (i.e. I do NOT want to set markers: {enabled: true}, but I do want the solitary point on the far right of the series to be displayed).

fiddle with example (note the isolated data point on the far right of the series - it is invisible unless you hover over the single point):

Highcharts.chart('container', {
    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },

    plotOptions: {
        series: {
            marker: {
                enabled: false
            }
        }
    },

    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, NaN, 54.4]
    }]
});

default:

on hover:

EDIT:

I tried

...
       series: {
           marker: {
               enabled: true,
               radius: 1
           }
       }
...

but the lone point is nearly invisible.

Body:
You can enable markers for individual data points:

    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, NaN, {
            y: 54.4,
            marker: {
                enabled: true
            }
        }]
    }]

Live demo: https://jsfiddle.net/BlackLabel/2prxc63m/

API Reference: https://api.highcharts.com/highcharts/series.line.data.marker.enabled


问:
Scarlet websocket in Android application with coroutine
I'm trying to implement application, which will work with websocket. So I choose scarlet. I can see in logs a response from a server, but I cant consume a data in my viewModel. How to do that? I am using Koin + viewModel + coroutine

Module for Koin

```<code>val networkModule = module {
    single { createScarlet() }
    single <ChatSocketRepository> {
        ChatSocketRepositoryImpl(get())
    }
}

private fun createScarlet(): ChatSocketApi {
    val client = OkHttpClient.Builder()
        .readTimeout(DataProviderImplementation.TIMEOUT, TimeUnit.SECONDS)
        .writeTimeout(DataProviderImplementation.TIMEOUT, TimeUnit.SECONDS)
        .connectTimeout(DataProviderImplementation.TIMEOUT, TimeUnit.SECONDS)
        .addInterceptor(HttpLoggingInterceptor().apply {
            level = HttpLoggingInterceptor.Level.BODY
        })
        .build()

    return Scarlet.Builder()
        .webSocketFactory(client.newWebSocketFactory("wss://demos.kaazing.com/echo"))
        .addMessageAdapterFactory(GsonMessageAdapter.Factory())
        .addStreamAdapterFactory(CoroutinesStreamAdapterFactory())
        .build()
        .create()
}
</code>```

ChatSocketApi

```<code>interface ChatSocketApi {
    @Receive
    fun observeText(): ReceiveChannel<String>
}
</code>```

ChatSocketRepository

```<code>interface ChatSocketRepository {
    fun observeTest(): ReceiveChannel<String>
}
</code>```

ChatSocketRepositoryImpl:

```<code>class ChatSocketRepositoryImpl(private val api: ChatSocketApi) : ChatSocketRepository {
    override fun observeTest(): ReceiveChannel<String> {
        return api.observeText()
    }
}
</code>```

ViewModel

```<code>class MyViewModel(private val chatSocketRepository: ChatSocketRepository) : BaseViewModel() {
    init {
        viewModelScope.launch {
            val text = chatSocketRepository.observeTest().consumeEach {
                Log.d("SOCKET", it.toString())
            }
        }
    }
</code>```

答: you already get the data, and your data is String because you declare ReceiveChannel<String> you can use the received data and put it in a LiveData. change the value of livedata in the .consumeEach{}  method instead.

Body:
I'm trying to implement application, which will work with websocket. So I choose scarlet. I can see in logs a response from a server, but I cant consume a data in my viewModel. How to do that? I am using Koin + viewModel + coroutine

Module for Koin

val networkModule = module {
    single { createScarlet() }
    single <ChatSocketRepository> {
        ChatSocketRepositoryImpl(get())
    }
}

private fun createScarlet(): ChatSocketApi {
    val client = OkHttpClient.Builder()
        .readTimeout(DataProviderImplementation.TIMEOUT, TimeUnit.SECONDS)
        .writeTimeout(DataProviderImplementation.TIMEOUT, TimeUnit.SECONDS)
        .connectTimeout(DataProviderImplementation.TIMEOUT, TimeUnit.SECONDS)
        .addInterceptor(HttpLoggingInterceptor().apply {
            level = HttpLoggingInterceptor.Level.BODY
        })
        .build()

    return Scarlet.Builder()
        .webSocketFactory(client.newWebSocketFactory("wss://demos.kaazing.com/echo"))
        .addMessageAdapterFactory(GsonMessageAdapter.Factory())
        .addStreamAdapterFactory(CoroutinesStreamAdapterFactory())
        .build()
        .create()
}

ChatSocketApi

interface ChatSocketApi {
    @Receive
    fun observeText(): ReceiveChannel<String>
}

ChatSocketRepository

interface ChatSocketRepository {
    fun observeTest(): ReceiveChannel<String>
}

ChatSocketRepositoryImpl:

class ChatSocketRepositoryImpl(private val api: ChatSocketApi) : ChatSocketRepository {
    override fun observeTest(): ReceiveChannel<String> {
        return api.observeText()
    }
}

ViewModel

class MyViewModel(private val chatSocketRepository: ChatSocketRepository) : BaseViewModel() {
    init {
        viewModelScope.launch {
            val text = chatSocketRepository.observeTest().consumeEach {
                Log.d("SOCKET", it.toString())
            }
        }
    }


问:
mirrors.jenkins-ci.org does not respond
Jenkins plugins updates portal does not work:
https://updates.jenkins.io/download/plugins/job-dsl/1.77/job-dsl.hpi

It looks that some mirrors.jenkinsci.org stopped working:

```<code>wget https://updates.jenkins.io/download/plugins/job-dsl/1.77/job-dsl.hpi
--2020-06-03 06:17:55--  https://updates.jenkins.io/download/plugins/job-dsl/1.77/job-dsl.hpi
Resolving updates.jenkins.io (updates.jenkins.io)... 52.202.51.185
Connecting to updates.jenkins.io (updates.jenkins.io)|52.202.51.185|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://mirrors.jenkins-ci.org/plugins/job-dsl/1.77/job-dsl.hpi [following]
--2020-06-03 06:17:56--  http://mirrors.jenkins-ci.org/plugins/job-dsl/1.77/job-dsl.hpi
Resolving mirrors.jenkins-ci.org (mirrors.jenkins-ci.org)... 52.202.51.185
Connecting to mirrors.jenkins-ci.org (mirrors.jenkins-ci.org)|52.202.51.185|:80... connected.
HTTP request sent, awaiting response...
</code>```

and

```<code>wget http://mirrors.jenkins-ci.org
--2020-06-03 06:21:37--  http://mirrors.jenkins-ci.org/
Resolving mirrors.jenkins-ci.org (mirrors.jenkins-ci.org)... 52.202.51.185
Connecting to mirrors.jenkins-ci.org (mirrors.jenkins-ci.org)|52.202.51.185|:80... connected.
HTTP request sent, awaiting response...
</code>```

jenkins

答:
The Jenkins project infrastructure is mainly maintained by a group of contributors, you can have more information here, when you experience issues with one of the services it's usually better to send a message on the Jenkins infra mailing list link.

More specifically with the update center, you can use this dashboard to see the current response time, most of the time that service is just overloaded, they are plans to work on the mirroring infrastructure as you can see in the Jenkins roadmap

Title: mirrors.jenkins-ci.org does not respond

Body:
Jenkins plugins updates portal does not work:
https://updates.jenkins.io/download/plugins/job-dsl/1.77/job-dsl.hpi

It looks that some mirrors.jenkinsci.org stopped working:

wget https://updates.jenkins.io/download/plugins/job-dsl/1.77/job-dsl.hpi
--2020-06-03 06:17:55--  https://updates.jenkins.io/download/plugins/job-dsl/1.77/job-dsl.hpi
Resolving updates.jenkins.io (updates.jenkins.io)... 52.202.51.185
Connecting to updates.jenkins.io (updates.jenkins.io)|52.202.51.185|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://mirrors.jenkins-ci.org/plugins/job-dsl/1.77/job-dsl.hpi [following]
--2020-06-03 06:17:56--  http://mirrors.jenkins-ci.org/plugins/job-dsl/1.77/job-dsl.hpi
Resolving mirrors.jenkins-ci.org (mirrors.jenkins-ci.org)... 52.202.51.185
Connecting to mirrors.jenkins-ci.org (mirrors.jenkins-ci.org)|52.202.51.185|:80... connected.
HTTP request sent, awaiting response...

and

wget http://mirrors.jenkins-ci.org
--2020-06-03 06:21:37--  http://mirrors.jenkins-ci.org/
Resolving mirrors.jenkins-ci.org (mirrors.jenkins-ci.org)... 52.202.51.185
Connecting to mirrors.jenkins-ci.org (mirrors.jenkins-ci.org)|52.202.51.185|:80... connected.
HTTP request sent, awaiting response...

jenkins


问:
How can I create a vbs file by batch without losing those lines?
Everytime I tries to create a vbs file by batch , some lines are missing in the vbs file

```<code>@echo off
echo Function RunAsAdmin() >> 2.vbs
echo If WScript.Arguments.length = 0 Then >> 2.vbs
echo CreateObject("Shell.Application").ShellExecute "wscript.exe", """" & _ >> 2.vbs
echo WScript.ScriptFullName & """" & "RunAsAdministrator""",,"runas", 1 >> 2.vbs
echo WScript.Quit >> 2.vbs
echo End If >> test.vbs
</code>```

What do i need to keep these 2 lines when making a vbs file by batch?

```<code>echo CreateObject("Shell.Application").ShellExecute "wscript.exe", """" & _ >> 2.vbs
echo WScript.ScriptFullName & """" & "RunAsAdministrator""",,"runas", 1 >> 2.vbs`
</code>```

答:
Refer to this How to Escape Characters in batch file.

@echo off
Title Generate VBS File from batch script
Set "VBSFile=%~dpn0.vbs"
Call :Generate_VBS_File
Pause & Exit
REM -----------------------------------------------------------------------------
:Generate_VBS_File
>"%VBSFile%" (
    echo    Function RunAsAdmin(^)
    echo    If WScript.Arguments.length = 0 Then
    echo        CreateObject("Shell.Application"^).ShellExecute "wscript.exe", """" ^& _
    echo        WScript.ScriptFullName ^& """" ^& "RunAsAdministrator""",,"runas", 1
    echo        WScript.Quit
    echo    End If
    echo    End Function
)
Exit /B
REM -----------------------------------------------------------------------------
```

Body:
Everytime I tries to create a vbs file by batch , some lines are missing in the vbs file

@echo off
echo Function RunAsAdmin() >> 2.vbs
echo If WScript.Arguments.length = 0 Then >> 2.vbs
echo CreateObject("Shell.Application").ShellExecute "wscript.exe", """" & _ >> 2.vbs
echo WScript.ScriptFullName & """" & "RunAsAdministrator""",,"runas", 1 >> 2.vbs
echo WScript.Quit >> 2.vbs
echo End If >> test.vbs

What do i need to keep these 2 lines when making a vbs file by batch?

echo CreateObject("Shell.Application").ShellExecute "wscript.exe", """" & _ >> 2.vbs
echo WScript.ScriptFullName & """" & "RunAsAdministrator""",,"runas", 1 >> 2.vbs`


问:
TextFormField displaying error message even after the values are inserted (using Form Flutter)
I am experimenting with flutter and I am stucked with a silly problem. I have defined two TextInputField in a screen, and I am validating using Form. Everything is working fine, my only problem, error is not going away even after values which is inserted are fine.

Below is the screenshot before entering the value. Error is showing at the start of the screen as well.

Below is the screen after entering the value. When i click on signup button, error is still showing.

You can see, value is getting printed in logs when i click on Sign Up button.

Widget Class

```<code>class SignUpForm extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return SignUpState();
  }
}
</code>```

State Class

```<code>class SignUpState extends State<SignUpForm> {
  final _fbKey = GlobalKey<FormState>();
  final UserDetails userDetails = UserDetails();
  bool _autoValidate = true;

  @override
  Widget build(BuildContext context) {
    return CustomScreenBg(
      AppString.additional_information,
      CustomCard(_getSignUpForm(context)),
    );
  }

  _getSignUpForm(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(12),
      child: Form(
        key: _fbKey,
        autovalidate: _autoValidate,
        child: Column(
          mainAxisSize: MainAxisSize.min,
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.start,
              children: [
                RichText(
                  text: TextSpan(
                    text: AppString.welcome_to,
                    style: TextStyle(
                      color: AppColor.BLACK.toColor,
                      fontSize: 18,
                    ),
                    children: <TextSpan>[
                      TextSpan(
                        text: '${AppString.app_name}',
                        style: TextStyle(
                          fontSize: 24,
                          color: AppColor.PRIMARY_COLOR.toColor,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
            SizedBox(height: 4),
            Row(
              mainAxisAlignment: MainAxisAlignment.start,
              children: [
                SubTitleText(AppString.lets_get_started),
              ],
            ),
            SizedBox(height: 16),
            Column(
              mainAxisSize: MainAxisSize.min,
              mainAxisAlignment: MainAxisAlignment.start,
              children: <Widget>[
                TextFormField(
                  decoration: InputDecoration(
                    labelText: AppString.enter_name,
                    errorText: AppString.error_name,
                  ),
                  keyboardType: TextInputType.text,
                  validator: (value) {
                    if (value.length < 4) {
                      return AppString.error_name;
                    }
                    return null;
                  },
                  onSaved: (name) {
                    userDetails.name = name;
                  },
                ),
                SizedBox(height: 16),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: AppString.enter_email,
                    errorText: AppString.error_email,
                  ),
                  keyboardType: TextInputType.text,
                  validator: (value) {
                    if (value.length < 5 || !value.contains('@')) {
                      return AppString.error_email;
                    }
                    return null;
                  },
                  onSaved: (email) {
                    userDetails.email = email;
                  },
                ),
              ],
            ),
            SizedBox(height: 24),
            Row(
              mainAxisSize: MainAxisSize.max,
              mainAxisAlignment: MainAxisAlignment.end,
              children: <Widget>[
                CustomButton(
                  AppString.sign_up,
                  () {
                    _onSubmit();
                  },
                  textColor: AppColor.WHITE.toColor,
                  bgColor: AppColor.PRIMARY_COLOR.toColor,
                ),
              ],
            ),
            SizedBox(height: 12)
          ],
        ),
      ),
    );
  }

  _onSubmit() {
    if (_fbKey.currentState.validate()) {
      _fbKey.currentState.save();
      print(userDetails.name);
      print(userDetails.email);
    } else {
      setState(() {
        _autoValidate = true;
      });
    }
  }
}

</code>```

This method is getting called when clicking on Sign Up Button.

```<code>_onSubmit() {
    if (_fbKey.currentState.validate()) {
      _fbKey.currentState.save();
      print(userDetails.name);
      print(userDetails.email);
    } else {
      setState(() {
        _autoValidate = true;
      });
    }
  }

</code>```

Can someone help me in figuring it out, what i am doing wrong?

答: You don't have to set the errorText property, when validation fails it will show the message returned by the validator callback. So for fixing the issue, all you want is to remove errorText from your TextFormField.

Body:
I am experimenting with flutter and I am stucked with a silly problem. I have defined two TextInputField in a screen, and I am validating using Form. Everything is working fine, my only problem, error is not going away even after values which is inserted are fine.

Below is the screenshot before entering the value. Error is showing at the start of the screen as well.

Below is the screen after entering the value. When i click on signup button, error is still showing.

You can see, value is getting printed in logs when i click on Sign Up button.

Widget Class

class SignUpForm extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return SignUpState();
  }
}

State Class

class SignUpState extends State<SignUpForm> {
  final _fbKey = GlobalKey<FormState>();
  final UserDetails userDetails = UserDetails();
  bool _autoValidate = true;

  @override
  Widget build(BuildContext context) {
    return CustomScreenBg(
      AppString.additional_information,
      CustomCard(_getSignUpForm(context)),
    );
  }

  _getSignUpForm(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(12),
      child: Form(
        key: _fbKey,
        autovalidate: _autoValidate,
        child: Column(
          mainAxisSize: MainAxisSize.min,
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.start,
              children: [
                RichText(
                  text: TextSpan(
                    text: AppString.welcome_to,
                    style: TextStyle(
                      color: AppColor.BLACK.toColor,
                      fontSize: 18,
                    ),
                    children: <TextSpan>[
                      TextSpan(
                        text: '${AppString.app_name}',
                        style: TextStyle(
                          fontSize: 24,
                          color: AppColor.PRIMARY_COLOR.toColor,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
            SizedBox(height: 4),
            Row(
              mainAxisAlignment: MainAxisAlignment.start,
              children: [
                SubTitleText(AppString.lets_get_started),
              ],
            ),
            SizedBox(height: 16),
            Column(
              mainAxisSize: MainAxisSize.min,
              mainAxisAlignment: MainAxisAlignment.start,
              children: <Widget>[
                TextFormField(
                  decoration: InputDecoration(
                    labelText: AppString.enter_name,
                    errorText: AppString.error_name,
                  ),
                  keyboardType: TextInputType.text,
                  validator: (value) {
                    if (value.length < 4) {
                      return AppString.error_name;
                    }
                    return null;
                  },
                  onSaved: (name) {
                    userDetails.name = name;
                  },
                ),
                SizedBox(height: 16),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: AppString.enter_email,
                    errorText: AppString.error_email,
                  ),
                  keyboardType: TextInputType.text,
                  validator: (value) {
                    if (value.length < 5 || !value.contains('@')) {
                      return AppString.error_email;
                    }
                    return null;
                  },
                  onSaved: (email) {
                    userDetails.email = email;
                  },
                ),
              ],
            ),
            SizedBox(height: 24),
            Row(
              mainAxisSize: MainAxisSize.max,
              mainAxisAlignment: MainAxisAlignment.end,
              children: <Widget>[
                CustomButton(
                  AppString.sign_up,
                  () {
                    _onSubmit();
                  },
                  textColor: AppColor.WHITE.toColor,
                  bgColor: AppColor.PRIMARY_COLOR.toColor,
                ),
              ],
            ),
            SizedBox(height: 12)
          ],
        ),
      ),
    );
  }

  _onSubmit() {
    if (_fbKey.currentState.validate()) {
      _fbKey.currentState.save();
      print(userDetails.name);
      print(userDetails.email);
    } else {
      setState(() {
        _autoValidate = true;
      });
    }
  }
}

This method is getting called when clicking on Sign Up Button.

_onSubmit() {
    if (_fbKey.currentState.validate()) {
      _fbKey.currentState.save();
      print(userDetails.name);
      print(userDetails.email);
    } else {
      setState(() {
        _autoValidate = true;
      });
    }
  }

Can someone help me in figuring it out, what i am doing wrong?


问:
SDL#: Why initialize IntPtr to null?
The few tutorials I have found for SDL# recommend initializing variables before use, like so:

```<code>IntPtr surface = IntPtr.Zero;
surface = SDL.SDL_GetWindowSurface(window);
</code>```

Is there any practical difference between that code and the following?

```<code>IntPtr surface = SDL.SDL_GetWindowSurface(window);
</code>```

According to this post, in SDL C/C++ this code style is used for backwards compatibility reasons. Is the same true for SDL#?

答:
Theoretically difference exists. Here is sample:

```<code>void some_method()
{
    IntPtr surface2 = IntPtr.Zero;
    surface2 = MainWindow.foo();    //  Foo's signature: IntPtr foo();
    //...
}

IL code:
{
    .maxstack 1
    .locals init (
        [0] native int
    )

    // IntPtr surface2 = IntPtr.Zero;
    IL_0000: ldsfld native int [mscorlib]System.IntPtr::Zero
    IL_0005: stloc.0
    // surface2 = MainWindow.foo();
    IL_0006: call native int WPFTest.MainWindow::foo()
    IL_000b: stloc.0
    //  ......
}

void some_method()
{
    IntPtr surface2 = MainWindow.foo();    //  Foo's signature: IntPtr foo();
    //...
}

IL code:
{
    .locals init (
        [0] native int
    )

    // IntPtr surface = MainWindow.foo();
    IL_0000: call native int WPFTest.MainWindow::foo()
    IL_0005: stloc.0
}
</code>```

Second code constains less instructions. But I don't think that you should really care about that (JIT does its job very well). In your concrete case with IntPtr class semantics is the same (internally IntPtr is always 0). My summary - you should care about general architecture of your app instead of such micro optimizations

Title: SDL#: Why initialize IntPtr to null?

Body:
The few tutorials I have found for SDL# recommend initializing variables before use, like so:

IntPtr surface = IntPtr.Zero;
surface = SDL.SDL_GetWindowSurface(window);

Is there any practical difference between that code and the following?

IntPtr surface = SDL.SDL_GetWindowSurface(window);

According to this post, in SDL C/C++ this code style is used for backwards compatibility reasons. Is the same true for SDL#?

Body:
Theoretically difference exists. Here is sample:

void some_method()
{
    IntPtr surface2 = IntPtr.Zero;
    surface2 = MainWindow.foo();    //  Foo's signature: IntPtr foo();
    //...
}

IL code:
{
    .maxstack 1
    .locals init (
        [0] native int
    )

    // IntPtr surface2 = IntPtr.Zero;
    IL_0000: ldsfld native int [mscorlib]System.IntPtr::Zero
    IL_0005: stloc.0
    // surface2 = MainWindow.foo();
    IL_0006: call native int WPFTest.MainWindow::foo()
    IL_000b: stloc.0
    //  ......
}

void some_method()
{
    IntPtr surface2 = MainWindow.foo();    //  Foo's signature: IntPtr foo();
    //...
}

IL code:
{
    .locals init (
        [0] native int
    )

    // IntPtr surface = MainWindow.foo();
    IL_0000: call native int WPFTest.MainWindow::foo()
    IL_0005: stloc.0
}

Second code constains less instructions. But I don't think that you should really care about that (JIT does its job very well). In your concrete case with IntPtr class semantics is the same (internally IntPtr is always 0). My summary - you should care about general architecture of your app instead of such micro optimizations


问:
MinGW/MSYS shell colors
I'd like for my makefile output to be color-coded.

But I can't get the ANSI color codes to work on this terminal. It should be possible though, ls --color gives me colorful output, and my shell prompt is also colored:

```<code>$ echo $PS1
\[\033]0;$MSYSTEM:\w\007 \033[32m\]\u@\h \[\033[33m\w\033[0m\] $
</code>```

I suspect maybe the first section puts the terminal in a special mode so that it will accept color codes. Can somebody explain?

答:
I solved it.

The command to use is echo -e.

So, in the makefile:

```<code>foo.o: foo.c
    @echo -e "\033[32mCompiling foo.c\033[0m"
    $(CC) $(CFLAGS) -c -o $@ $<
</code>```

I would imagine this works just fine in bash as well.

Title: MinGW/MSYS shell colors

Body:
I'd like for my makefile output to be color-coded.

But I can't get the ANSI color codes to work on this terminal. It should be possible though, ls --color gives me colorful output, and my shell prompt is also colored:

$ echo $PS1
\[\033]0;$MSYSTEM:\w\007 \033[32m\]\u@\h \[\033[33m\w\033[0m\] $

I suspect maybe the first section puts the terminal in a special mode so that it will accept color codes. Can somebody explain?

Body:
I solved it.

The command to use is echo -e.

So, in the makefile:

foo.o: foo.c
    @echo -e "\033[32mCompiling foo.c\033[0m"
    $(CC) $(CFLAGS) -c -o $@ $<

I would imagine this works just fine in bash as well.


问:
Linq group by with multiple columns
net core projects. I am trying to retrieve unique rows for example, my table looks like below

```<code>Country_id  Country Reegion
----------  ------- -------
1           Germany Europe
2           UK      Europe
3           UK      Europe
</code>```

In result, I am trying to get like this.

```<code>Country_id  Country   Reegion
----------  -------   -------
    1       Germany   Europe
    2       UK        Europe
</code>```

In the above example, Countryid with value 2 and 3 has same value UK so I want to retrieve only one row. I tried using below code

```<code>var listOfGeographies = await GeographyRepository.GetAsync(x=>x.IsActive == true).ConfigureAwait(false);
var listOfUniqueGeographies = listOfGeographies.GroupBy(x => x.Country).Select(y => y.First());
IEnumerable<GeographyEntity> result = from o in listOfUniqueGeographies
                                      select new GeographyEntity
                                      {
                                          Id = o.CountryId,
                                          Country = o.Country,
                                          Region = o.Region,
                                          SubRegion = o.SubRegion
                                      };
</code>```

Above code will return all the rows without grouping. May I know any changes I have to do in above linq query. Can someone help me on this. Any help would be appreciated. Thanks

答:
It seems like you need grouping on Country name as it is repeating in the data but with different id (which is strange) in that case you need to group and select the first one :

```<code>var result1 = myRepoOutput.GroupBy(x => x.Country)
                          .Select(b => b.First());
</code>```

Title: Linq group by with multiple columns

Body:
net core projects. I am trying to retrieve unique rows for example, my table looks like below

Country_id  Country Reegion
----------  ------- -------
1           Germany Europe
2           UK      Europe
3           UK      Europe

In result, I am trying to get like this.

Country_id  Country   Reegion
----------  -------   -------
    1       Germany   Europe
    2       UK        Europe

In the above example, Countryid with value 2 and 3 has same value UK so I want to retrieve only one row. I tried using below code

var listOfGeographies = await GeographyRepository.GetAsync(x=>x.IsActive == true).ConfigureAwait(false);
var listOfUniqueGeographies = listOfGeographies.GroupBy(x => x.Country).Select(y => y.First());
IEnumerable<GeographyEntity> result = from o in listOfUniqueGeographies
                                      select new GeographyEntity
                                      {
                                          Id = o.CountryId,
                                          Country = o.Country,
                                          Region = o.Region,
                                          SubRegion = o.SubRegion
                                      };

Above code will return all the rows without grouping. May I know any changes I have to do in above linq query. Can someone help me on this. Any help would be appreciated. Thanks

Body:
It seems like you need grouping on Country name as it is repeating in the data but with different id (which is strange) in that case you need to group and select the first one :

var result1 = myRepoOutput.GroupBy(x => x.Country)
                          .Select(b => b.First());


问:
How to make group assignments for azure active directory roles?
I want to assign Azure Active Directory groups to an Azure Active Directory role. But if I open e.g. the role "Directory Readers" and click on "Add Assignment" I can only choose Azure Active Directory users but no groups.

How can I assign an Azure Active Directory group to an Azure Active Directory role?

Thank you in forward!

Best regards
Matthias

答:
I'm afraid that you could not assign an Azure Active Directory group to an Azure Active Directory role both in the portal and Powershell.

Here is a workaround. You could get members in the group first, then loop the members and assign members to the role.

```<code>$members = Get-AzureADGroupMember -ObjectId {object id of group}

Foreach($member in $members){
    Add-AzureADDirectoryRoleMember -ObjectId {object id of directory reader role} -RefObjectId $member.ObjectId
}
</code>```

If there is still a group in this group, then It will fail when assigning the role to the internal group.

Body:
I'm afraid that you could not assign an Azure Active Directory group to an Azure Active Directory role both in the portal and Powershell.

Here is a workaround. You could get members in the group first, then loop the members and assign members to the role.

$members = Get-AzureADGroupMember -ObjectId {object id of group}

Foreach($member in $members){
    Add-AzureADDirectoryRoleMember -ObjectId {object id of directory reader role} -RefObjectId $member.ObjectId
}

If there is still a group in this group, then It will fail when assigning the role to the internal group.


问:
How to write a custom-attribute (directive) in React 16.9?
Is it possible to use React just for writing a custom-attribute for existing HTML tags?

for example, I want to add float-label to an input HTML tag like the following code:

  <input type="text" id="lname" name="lname" float-label="LastName">

```

and call float-labels.js behind the scene. I want to just extend the regular HTML input tag no more.

Is it possible to use React to extend current HTML tags without writing a new component/tag (like float-input)?

答:
You should use a data attribute instead:

```<code>  <input type="text" id="lname" name="lname" data-float-label="LastName">
</code>```

This is supported, otherwise hyphen attributes will not be rendered.

Body:
Is it possible to use React just for writing a custom-attribute for existing HTML tags?

for example, I want to add float-label to an input HTML tag like the following code:

  <input type="text" id="lname" name="lname" float-label="LastName">

and call float-labels.js behind the scene. I want to just extend the regular HTML input tag no more.

Is it possible to use React to extend current HTML tags without writing a new component/tag (like float-input)?

Body:
You should use a data attribute instead:

  <input type="text" id="lname" name="lname" data-float-label="LastName">

This is supported, otherwise hyphen attributes will not be rendered.


问:
Unity3d Unable to generate Uri link to start dwonload assetbundle
Greeting,

Recently, I been experimenting Unity3d and Firebase for some projects. I managed to download images from Firebase Storage and tried to do the same for assetbundle.

But when I start download, it just stop at Debug.Log("download link generated");
Usually it will give me the Uri link after that.
I tested the code again at my image download scene, it still work.

Did anyone experience this before? Or I missing out something that need to prepare for assetbundle download?

Forgot to mention, it's still in the same project. But different scene.

```<code>public void DownloadStarted()
    {
        StorageReference asset_ref = storage.GetReferenceFromUrl("gs://dummy_link.appspot.com/test_folder/Test_Asset/testbox");

        asset_ref.GetDownloadUrlAsync().ContinueWith((Task<Uri> task) =>
        {
            if (task.IsFaulted && task.IsCanceled)
            {
                Debug.Log(task.Exception.ToString());
            }
            else
            {
                Debug.Log("download link generated");
                Debug.Log("Download URL: " + task.Result);
                downloadLink = task.Result;
                _isDownload = true;

                StartCoroutine(DownloadAsset(task.Result));
            }
        });
    }

    IEnumerator DownloadAsset(Uri uri)
    {
        Debug.Log("Start Download");

        using (UnityWebRequest uwr = UnityWebRequestAssetBundle.GetAssetBundle(uri))
        {
            yield return uwr.SendWebRequest();

            if (uwr.isNetworkError || uwr.isHttpError)
            {
                Debug.Log(uwr.error);
            }
            else
            {

                AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(uwr);

                GameObject instance = Instantiate(bundle.LoadAsset("cube", typeof(GameObject)), gameObj.transform) as GameObject;
            }
        }
    }

</code>```

答:
ContinueWith might be executed on a thread different to the Unity main thread.

Most of Unity's API only works in the main thread.

In your case StartCoroutine will probably silently(?) fail in a thread.

specifically for Unity there is an extension in Firebase  ContinueWithOnMainThread you should use in Unity

Note that your if condition should also be a || instead of && so

public void DownloadStarted()
{
    StorageReference asset_ref = storage.GetReferenceFromUrl("gs://dummy_link.appspot.com/test_folder/Test_Asset/testbox");

    asset_ref.GetDownloadUrlAsync().ContinueWithOnMainThread((Task<Uri> task) =>
    {
        // I think here it should be || instead of &&
        if (task.IsFaulted || task.IsCanceled)
        {
            Debug.Log(task.Exception.ToString());
        }
        else
        {
            Debug.Log("download link generated");
            Debug.Log("Download URL: " + task.Result);
            downloadLink = task.Result;
            _isDownload = true;

            StartCoroutine(DownloadAsset(task.Result));
        }
    });
}
```

Body:
Greeting,

Recently, I been experimenting Unity3d and Firebase for some projects. I managed to download images from Firebase Storage and tried to do the same for assetbundle.

But when I start download, it just stop at Debug.Log("download link generated");
Usually it will give me the Uri link after that.
I tested the code again at my image download scene, it still work.

Did anyone experience this before? Or I missing out something that need to prepare for assetbundle download?

Forgot to mention, it's still in the same project. But different scene.

public void DownloadStarted()
    {
        StorageReference asset_ref = storage.GetReferenceFromUrl("gs://dummy_link.appspot.com/test_folder/Test_Asset/testbox");

        asset_ref.GetDownloadUrlAsync().ContinueWith((Task<Uri> task) =>
        {
            if (task.IsFaulted && task.IsCanceled)
            {
                Debug.Log(task.Exception.ToString());
            }
            else
            {
                Debug.Log("download link generated");
                Debug.Log("Download URL: " + task.Result);
                downloadLink = task.Result;
                _isDownload = true;

                StartCoroutine(DownloadAsset(task.Result));
            }
        });
    }

    IEnumerator DownloadAsset(Uri uri)
    {
        Debug.Log("Start Download");

        using (UnityWebRequest uwr = UnityWebRequestAssetBundle.GetAssetBundle(uri))
        {
            yield return uwr.SendWebRequest();

            if (uwr.isNetworkError || uwr.isHttpError)
            {
                Debug.Log(uwr.error);
            }
            else
            {

                AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(uwr);

                GameObject instance = Instantiate(bundle.LoadAsset("cube", typeof(GameObject)), gameObj.transform) as GameObject;
            }
        }
    }


问:
Redux Thunk vs Redux custom Middleware
I am new to redux. So after reading lots of tutorials.I understood that, redux need redux thunk to dispatch async actions by returning another function.But if  I call http request inside custom middle-ware then

is it required redux thunk ?

is Redux custom middleware no side effects ? I mean no need to return another function.

If  i use redux thunk then my action creator looks like this. This I understood

```<code>function incrementAsync() {
  return (dispatch) => {
    setTimeout(() => {
      // Yay! Can invoke sync or async actions with `dispatch`
      dispatch(increment());
    }, 1000);
  };
}
</code>```

I have confusion in custom middle-ware.

https://blog.logrocket.com/managing-asynchronous-actions-in-redux-1bc7d28a00c6/

as per this blog

```<code>const httpMiddleware = store => next => action => {
  if (action[HTTP_ACTION]) {
    const actionInfo = action[HTTP_ACTION];
    const fetchOptions = {
      method: actionInfo.verb,
      headers: actionInfo.headers,
      body: actionInfo.payload || null
    };

    next({
      type: actionInfo.type + "_REQUESTED"
    });

    fetch(actionInfo.endpoint, fetchOptions)
      .then(response => response.json())
      .then(data => next({
        type: actionInfo.type + "_RECEIVED",
        payload: data
      }))
      .catch(error => next({
        type: actionInfo.type + "_FAILED",
        payload: error
     }));
  } else {
    return next(action);
  }
}
</code>```

they are not returning any dispatch function inside action. I know that store,next,action are the inner functions.

can any one help me to understand about this?

Thank you.

答:
All redux-thunk is is a simple redux middleware that checks if your action is a function and acts accordingly. You can build it yourself in 5 minutes.

You can see that it deconstructs dispatch and getState from the store object, and then calls your action with them as parameters.

Have a look at it's source code.

So, your example code can look like this:

```<code>const httpMiddleware = store => next => action => {
  if (action[HTTP_ACTION]) {
    const actionInfo = action[HTTP_ACTION];
    const fetchOptions = {
      method: actionInfo.verb,
      headers: actionInfo.headers,
      body: actionInfo.payload || null
    };

    store.dispatch({
      type: actionInfo.type + "_REQUESTED"
    });

    fetch(actionInfo.endpoint, fetchOptions)
      .then(response => response.json())
      .then(data => store.dispatch({
        type: actionInfo.type + "_RECEIVED",
        payload: data
      }))
      .catch(error => store.dispatch({
        type: actionInfo.type + "_FAILED",
        payload: error
     }));
  } else {
    return next(action);
  }
}
</code>```

Title: Redux Thunk vs Redux custom Middleware

Body:
I am new to redux. So after reading lots of tutorials.I understood that, redux need redux thunk to dispatch async actions by returning another function.But if  I call http request inside custom middle-ware then

is it required redux thunk ?

is Redux custom middleware no side effects ? I mean no need to return another function.

If  i use redux thunk then my action creator looks like this. This I understood

function incrementAsync() {
  return (dispatch) => {
    setTimeout(() => {
      // Yay! Can invoke sync or async actions with `dispatch`
      dispatch(increment());
    }, 1000);
  };
}

I have confusion in custom middle-ware.

https://blog.logrocket.com/managing-asynchronous-actions-in-redux-1bc7d28a00c6/

as per this blog

const httpMiddleware = store => next => action => {
  if (action[HTTP_ACTION]) {
    const actionInfo = action[HTTP_ACTION];
    const fetchOptions = {
      method: actionInfo.verb,
      headers: actionInfo.headers,
      body: actionInfo.payload || null
    };

    next({
      type: actionInfo.type + "_REQUESTED"
    });

    fetch(actionInfo.endpoint, fetchOptions)
      .then(response => response.json())
      .then(data => next({
        type: actionInfo.type + "_RECEIVED",
        payload: data
      }))
      .catch(error => next({
        type: actionInfo.type + "_FAILED",
        payload: error
     }));
  } else {
    return next(action);
  }
}

they are not returning any dispatch function inside action. I know that store,next,action are the inner functions.

can any one help me to understand about this?

Thank you.

Body:
All redux-thunk is is a simple redux middleware that checks if your action is a function and acts accordingly. You can build it yourself in 5 minutes.

You can see that it deconstructs dispatch and getState from the store object, and then calls your action with them as parameters.

Have a look at it's source code.

So, your example code can look like this:

const httpMiddleware = store => next => action => {
  if (action[HTTP_ACTION]) {
    const actionInfo = action[HTTP_ACTION];
    const fetchOptions = {
      method: actionInfo.verb,
      headers: actionInfo.headers,
      body: actionInfo.payload || null
    };

    store.dispatch({
      type: actionInfo.type + "_REQUESTED"
    });

    fetch(actionInfo.endpoint, fetchOptions)
      .then(response => response.json())
      .then(data => store.dispatch({
        type: actionInfo.type + "_RECEIVED",
        payload: data
      }))
      .catch(error => store.dispatch({
        type: actionInfo.type + "_FAILED",
        payload: error
     }));
  } else {
    return next(action);
  }
}


问:
java spark logging level issue with spring boot
I am using spark with java spring boot, want to set log level ERROR to console and file, but it's not working, tried the following solution

1).set("spark.executor.extraJavaOptions","-Dlog4jspark.root.logger=ERROR,console")
2).set("spark.driver.extraJavaOptions", "-Dorg.slf4j.simpleLogger.defaultLogLevel=ERROR,console")

spark.sparkContext.setLogLevel('ERROR')

but not working :(

spark configuration:

pom.xml Dependancy:

```<code>    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-library</artifactId>
        <version>${scala.version}</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-compiler</artifactId>
        <version>${scala.version}</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-reflect</artifactId>
        <version>${scala.version}</version>
        <scope>compile</scope>
    </dependency>

        <!-- For spring MVC -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
            <exclusions>
           <exclusion>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-classic</artifactId>
                </exclusion>
        </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-classic</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- For Spring Integration -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-integration</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-mllib_2.10</artifactId>
            <version>2.0.0</version>
            <exclusions>
                <exclusion>
                    <artifactId>slf4j-api</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-core_2.10</artifactId>
            <version>2.0.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-streaming_2.10</artifactId>
            <version>2.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-sql_2.10</artifactId>
            <version>2.0.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.slf4j/log4j-over-slf4j -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.6.4</version>
    </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>compile</scope>
        </dependency>

        <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.1</version>
        <exclusions>
            <exclusion>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
            </exclusion>
            <exclusion>
                <groupId>commons-beanutils</groupId>
                <artifactId>commons-beanutils-core</artifactId>
            </exclusion>
        </exclusions>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.39</version>
    </dependency>

    <dependency>
        <groupId>org.freemarker</groupId>
        <artifactId>freemarker</artifactId>
        <version>2.3.24-incubating</version>
    </dependency>

    <dependency>
        <groupId>com.jayway.jsonpath</groupId>
        <artifactId>json-path</artifactId>
        <version>2.1.0</version>
        <exclusions>
            <exclusion>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>log4j-over-slf4j</artifactId>
            </exclusion>
            <exclusion>
                <groupId>commons-beanutils</groupId>
                <artifactId>commons-beanutils-core</artifactId>
            </exclusion>
            <exclusion>
                <groupId>commons-collections</groupId>
                <artifactId>commons-collections</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-yarn-common</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.4.189</version>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>log4j-over-slf4j</artifactId>
            </exclusion>
            <exclusion>
                <groupId>commons-beanutils</groupId>
                <artifactId>commons-beanutils-core</artifactId>
            </exclusion>
            <exclusion>
                <groupId>commons-collections</groupId>
                <artifactId>commons-collections</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-yarn-common</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>*</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.17</version>
    </dependency>
    <dependency>
        <groupId>com.opencsv</groupId>
        <artifactId>opencsv</artifactId>
        <version>4.1</version>
    </dependency>

    <!--Test-->
    <dependency>
        <groupId>org.scalatest</groupId>
        <artifactId>scalatest_${scala.libversion}</artifactId>
        <version>3.0.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.3.2</version>
    </dependency>
            <!-- https://mvnrepository.com/artifact/com.healthmarketscience.sqlbuilder/sqlbuilder -->
    <dependency>
        <groupId>com.healthmarketscience.sqlbuilder</groupId>
        <artifactId>sqlbuilder</artifactId>
        <version>2.1.7</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
    <dependency>
        <groupId>com.googlecode.json-simple</groupId>
        <artifactId>json-simple</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
      <groupId>ca.krasnay</groupId>
      <artifactId>sqlbuilder</artifactId>
      <version>1.2</version>
    </dependency>

    <dependency>
      <groupId>com.crealytics</groupId>
      <artifactId>spark-excel_2.10</artifactId>
      <version>0.8.3</version>
    </dependency>
    <dependency>
      <groupId>com.eclipsesource.minimal-json</groupId>
      <artifactId>minimal-json</artifactId>
      <version>0.9.5</version>
    </dependency>
            <!-- https://mvnrepository.com/artifact/joda-time/joda-time -->
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.3</version>
    </dependency>
    </dependencies>
</code>```

答:
In the application.properties that you should have in the src/main/resources, add:

logging.level.org.apache=WARN

Hope it works

Body:
I am using spark with java spring boot, want to set log level ERROR to console and file, but it's not working, tried the following solution

1).set("spark.executor.extraJavaOptions","-Dlog4jspark.root.logger=ERROR,console")
2).set("spark.driver.extraJavaOptions", "-Dorg.slf4j.simpleLogger.defaultLogLevel=ERROR,console")

spark.sparkContext.setLogLevel('ERROR')

but not working :(

spark configuration:

pom.xml Dependancy:

    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-library</artifactId>
        <version>${scala.version}</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-compiler</artifactId>
        <version>${scala.version}</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-reflect</artifactId>
        <version>${scala.version}</version>
        <scope>compile</scope>
    </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
            <exclusions>
           <exclusion>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-classic</artifactId>
                </exclusion>
        </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-classic</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-integration</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-mllib_2.10</artifactId>
            <version>2.0.0</version>
            <exclusions>
                <exclusion>
                    <artifactId>slf4j-api</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-core_2.10</artifactId>
            <version>2.0.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-streaming_2.10</artifactId>
            <version>2.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-sql_2.10</artifactId>
            <version>2.0.0</version>
        </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.6.4</version>
    </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>compile</scope>
        </dependency>

        <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.1</version>
        <exclusions>
            <exclusion>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
            </exclusion>
            <exclusion>
                <groupId>commons-beanutils</groupId>
                <artifactId>commons-beanutils-core</artifactId>
            </exclusion>
        </exclusions>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.39</version>
    </dependency>

    <dependency>
        <groupId>org.freemarker</groupId>
        <artifactId>freemarker</artifactId>
        <version>2.3.24-incubating</version>
    </dependency>

    <dependency>
        <groupId>com.jayway.jsonpath</groupId>
        <artifactId>json-path</artifactId>
        <version>2.1.0</version>
        <exclusions>
            <exclusion>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>log4j-over-slf4j</artifactId>
            </exclusion>
            <exclusion>
                <groupId>commons-beanutils</groupId>
                <artifactId>commons-beanutils-core</artifactId>
            </exclusion>
            <exclusion>
                <groupId>commons-collections</groupId>
                <artifactId>commons-collections</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-yarn-common</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.4.189</version>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>log4j-over-slf4j</artifactId>
            </exclusion>
            <exclusion>
                <groupId>commons-beanutils</groupId>
                <artifactId>commons-beanutils-core</artifactId>
            </exclusion>
            <exclusion>
                <groupId>commons-collections</groupId>
                <artifactId>commons-collections</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-yarn-common</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>*</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.17</version>
    </dependency>
    <dependency>
        <groupId>com.opencsv</groupId>
        <artifactId>opencsv</artifactId>
        <version>4.1</version>
    </dependency>

    <dependency>
        <groupId>org.scalatest</groupId>
        <artifactId>scalatest_${scala.libversion}</artifactId>
        <version>3.0.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.3.2</version>
    </dependency>

    <dependency>
        <groupId>com.healthmarketscience.sqlbuilder</groupId>
        <artifactId>sqlbuilder</artifactId>
        <version>2.1.7</version>
    </dependency>

    <dependency>
        <groupId>com.googlecode.json-simple</groupId>
        <artifactId>json-simple</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
      <groupId>ca.krasnay</groupId>
      <artifactId>sqlbuilder</artifactId>
      <version>1.2</version>
    </dependency>

    <dependency>
      <groupId>com.crealytics</groupId>
      <artifactId>spark-excel_2.10</artifactId>
      <version>0.8.3</version>
    </dependency>
    <dependency>
      <groupId>com.eclipsesource.minimal-json</groupId>
      <artifactId>minimal-json</artifactId>
      <version>0.9.5</version>
    </dependency>

    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.3</version>
    </dependency>
    </dependencies>


问:
How to run Django and Spark application
I am working on a Spark Application and I want to create a rest API in Django, below is my code

```<code>from django.shortcuts import render
from django.http import Http404
from rest_framework.views import APIView
from rest_framework.decorators import api_view
from rest_framework.response import Response
from rest_framework import status
from django.http import JsonResponse
from django.core import serializers
from django.conf import settings
import json
from pyspark import SparkContext, SparkConf, SQLContext

sc = SparkContext()
sql = SQLContext(sc)

df = Sql.read.format("jdbc").options(
        url = "jdbc:mysql://127.0.0.1:3306/demo",
        driver = "com.mysql.cj.jdbc.Driver",
        dbtable = "tablename",
        user = "xyz",
        password = "abc"
).load()

totalrecords = df.count()

# Create your views here.
@api_view(["GET"])
def Demo(self):
    try:
        a = str(totalrecords)
        return JsonResponse(a,safe=False)
    except ValueError as e:
        return Response(e.args[0],status.HTTP_400_BAD_REQUEST)
</code>```

I want to know how will I run this code, as I have directly tried "python manage.py runserver" which is not working, so how to run this spark and django with django api and spark-submit with all required spark jar file?

答:
To run this code you have to use spark submit only,

```<code>spark-submit --jars mysql.jar manage.py runserver 0.0.0.0:8000
</code>```

or

```<code>spark-submit manage.py runserver
</code>```

Title: How to run Django and Spark application

Body:
I am working on a Spark Application and I want to create a rest API in Django, below is my code

from django.shortcuts import render
from django.http import Http404
from rest_framework.views import APIView
from rest_framework.decorators import api_view
from rest_framework.response import Response
from rest_framework import status
from django.http import JsonResponse
from django.core import serializers
from django.conf import settings
import json
from pyspark import SparkContext, SparkConf, SQLContext

sc = SparkContext()
sql = SQLContext(sc)

df = Sql.read.format("jdbc").options(
        url = "jdbc:mysql://127.0.0.1:3306/demo",
        driver = "com.mysql.cj.jdbc.Driver",
        dbtable = "tablename",
        user = "xyz",
        password = "abc"
).load()

totalrecords = df.count()

# Create your views here.
@api_view(["GET"])
def Demo(self):
    try:
        a = str(totalrecords)
        return JsonResponse(a,safe=False)
    except ValueError as e:
        return Response(e.args[0],status.HTTP_400_BAD_REQUEST)

I want to know how will I run this code, as I have directly tried "python manage.py runserver" which is not working, so how to run this spark and django with django api and spark-submit with all required spark jar file?

Body:
To run this code you have to use spark submit only,

spark-submit --jars mysql.jar manage.py runserver 0.0.0.0:8000

or

spark-submit manage.py runserver


问:
menu popup, when hover, on css
I have a sidebar on the site, on the left, with certain menu items. There are also subclauses. I can’t make it so that when you hover, a pop-up block with sub-items is displayed on the main menu item. The main sidebar has position: sticky. What you need to display in the popup block in the main_menu_content_list_submenu tag. Please help sort it out. Thank you so much!

.main {
  font-family: PT Sans;
  position: relative;
  display: flex;
  flex-direction: row;
  min-height: 100%;
}

.main_menu {
  display: flex;
  flex-direction: column;
  width: auto;
  background-color: #38618C;
  padding: 50px 50px 0 50px;
}

.main_menu_content {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 50px;
  width: 100%;
}
.main_menu_content_list {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  height: 700px;
}

.main_menu_content_list li {
  list-style-type: none;
}

.main_menu_content_list a {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-style: normal;
  font-weight: normal;
  font-size: 18px;
  line-height: 23px;
  color: #D7DFE8;
  text-decoration: none;
}

.main_content {
  display: flex;
  align-items: center;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  height: 100%;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="main">
<div class="main_menu">
            <div class="main_menu_content">
                <ul class="main_menu_content_list">
                    <li>
                            <div class="main_menu_content_list_int"></div>Text1
                        </li>

                        <ul class="main_menu_content_list_submenu">
                            <li>Text1.1</li>
                            <li>Text1.2</li>
                        </ul>

                    <li>
                            <div class="main_menu_content_list_tv"></div>Text2
                        </li>
                    <li>
                            <div class="main_menu_content_list_video"></div>Text3
                        </li>
                </ul>
            </div>
</div>
<div class="main_content">
</div>
</div></code>```

答:
  * {
            padding: 0;
            margin: 0;
        }

        .main {
            font-family: PT Sans;
            position: relative;
            display: flex;
            flex-direction: row;
            min-height: 100%;
        }

        .main_menu {
            display: flex;
            flex-direction: column;
            width: auto;
            background-color: #38618C;
            /* padding: 50px 50px 0 50px; */
        }

        .main_menu_content {
            display: flex;
            flex-direction: column;
            position: sticky;
            top: 50px;
            width: 100%;
        }

        .main_menu_content_list {
            display: flex;
            position: relative;
            flex-direction: column;
            justify-content: space-between;
            text-align: center;
            height: 700px;
        }

        .main_menu_content_list li {
            padding: 50px;

            list-style-type: none;
        }

        .main_menu_content_list li a {
            position: relative;
        }

        .main_menu_content_list li a:hover .main_menu_content_list_int {
            display: block;
        }

        .main_menu_content_list li a:hover~.main_menu_content_list_submenu {
            display: block;
        }

        .main_menu_content_list_int {
            display: none;
            position: absolute;
            right: -135%;
            bottom: 40%;
            width: 10px;
            height: 10px;
            background-color: violet;
            transform: rotate(45deg)
        }

        .main_menu_content_list a {
            display: flex;
            flex-direction: column;
            align-items: center;
            font-style: normal;
            font-weight: normal;
            font-size: 18px;
            line-height: 23px;
            color: #D7DFE8;
            text-decoration: none;
        }

        .main_content {
            display: flex;
            align-items: center;
            flex-direction: column;
            width: 100%;
            max-width: 100%;
            height: 100%;
        }

        .main_menu_content_list_submenu {
            display: none;
            position: absolute;
            left: 100%;
            top: -50px;
            width: 200px;
            height: 700px;
            padding: 50px 50px 0 50px;
            background-color: violet;
        }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="main">
        <div class="main_menu">
            <div class="main_menu_content">
                <ul class="main_menu_content_list">
                    <li>
                            <div class="main_menu_content_list_int"></div>Text1

                        <ul class="main_menu_content_list_submenu">
                            <li>Text1.1</li>
                            <li>Text1.2</li>
                        </ul>
                    </li>

                    <li>
                            <div class="main_menu_content_list_int"></div>Text2

                        <ul class="main_menu_content_list_submenu">
                            <li>Text2.1</li>
                            <li>Text2.2</li>
                        </ul>
                    </li>
                    <li>
                            <div class="main_menu_content_list_video"></div>Text3
                        </li>
                </ul>
            </div>
        </div>
        <div class="main_content">
        </div>
    </div></code>```

slightly changed your orginal css  for better effect.

Title: menu popup, when hover, on css

Body:
I have a sidebar on the site, on the left, with certain menu items. There are also subclauses. I can’t make it so that when you hover, a pop-up block with sub-items is displayed on the main menu item. The main sidebar has position: sticky. What you need to display in the popup block in the main_menu_content_list_submenu tag. Please help sort it out. Thank you so much!

.main {
  font-family: PT Sans;
  position: relative;
  display: flex;
  flex-direction: row;
  min-height: 100%;
}

.main_menu {
  display: flex;
  flex-direction: column;
  width: auto;
  background-color: #38618C;
  padding: 50px 50px 0 50px;
}

.main_menu_content {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 50px;
  width: 100%;
}
.main_menu_content_list {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  height: 700px;
}

.main_menu_content_list li {
  list-style-type: none;
}

.main_menu_content_list a {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-style: normal;
  font-weight: normal;
  font-size: 18px;
  line-height: 23px;
  color: #D7DFE8;
  text-decoration: none;
}

.main_content {
  display: flex;
  align-items: center;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  height: 100%;
}

Text1

Text1.1

Text1.2

Text2

Text3

Body:
  * {
            padding: 0;
            margin: 0;
        }

        .main {
            font-family: PT Sans;
            position: relative;
            display: flex;
            flex-direction: row;
            min-height: 100%;
        }

        .main_menu {
            display: flex;
            flex-direction: column;
            width: auto;
            background-color: #38618C;
            /* padding: 50px 50px 0 50px; */
        }

        .main_menu_content {
            display: flex;
            flex-direction: column;
            position: sticky;
            top: 50px;
            width: 100%;
        }

        .main_menu_content_list {
            display: flex;
            position: relative;
            flex-direction: column;
            justify-content: space-between;
            text-align: center;
            height: 700px;
        }

        .main_menu_content_list li {
            padding: 50px;

            list-style-type: none;
        }

        .main_menu_content_list li a {
            position: relative;
        }

        .main_menu_content_list li a:hover .main_menu_content_list_int {
            display: block;
        }

        .main_menu_content_list li a:hover~.main_menu_content_list_submenu {
            display: block;
        }

        .main_menu_content_list_int {
            display: none;
            position: absolute;
            right: -135%;
            bottom: 40%;
            width: 10px;
            height: 10px;
            background-color: violet;
            transform: rotate(45deg)
        }

        .main_menu_content_list a {
            display: flex;
            flex-direction: column;
            align-items: center;
            font-style: normal;
            font-weight: normal;
            font-size: 18px;
            line-height: 23px;
            color: #D7DFE8;
            text-decoration: none;
        }

        .main_content {
            display: flex;
            align-items: center;
            flex-direction: column;
            width: 100%;
            max-width: 100%;
            height: 100%;
        }

        .main_menu_content_list_submenu {
            display: none;
            position: absolute;
            left: 100%;
            top: -50px;
            width: 200px;
            height: 700px;
            padding: 50px 50px 0 50px;
            background-color: violet;
        }

<div class="main">
        <div class="main_menu">
            <div class="main_menu_content">
                <ul class="main_menu_content_list">
                    <li><a href="">
                            <div class="main_menu_content_list_int"></div>Text1
                        </a>
                        <ul class="main_menu_content_list_submenu">
                            <li><a href="">Text1.1</a></li>
                            <li><a href="">Text1.2</a></li>
                        </ul>
                    </li>

                    <li><a href="">
                            <div class="main_menu_content_list_int"></div>Text2
                        </a>
                        <ul class="main_menu_content_list_submenu">
                            <li><a href="">Text2.1</a></li>
                            <li><a href="">Text2.2</a></li>
                        </ul>
                    </li>
                    <li><a href="">
                            <div class="main_menu_content_list_video"></div>Text3
                        </a></li>
                </ul>
            </div>
        </div>
        <div class="main_content">
        </div>
    </div>

slightly changed your orginal css  for better effect.


问:
Spring Batch Partition Slave JDBCItemWriter StepScope or Default Bean Scope
Please advise about the Spring batch partition Slave "JdbcBatchItemWriter" scope . Currently we have defined as default Bean scope with 30 partitions. As per the documentation says JdbcBatchItemWriter is thread-safe. Please note Our Reader is "STEPSCOPE"

Code snippets below for writer

        @Bean
        public JdbcBatchItemWriter<UnifiedInvoiceDTO> summaryWriter() {
            JdbcBatchItemWriter<UnifiedInvoiceDTO> databaseItemWriter = new JdbcBatchItemWriter<>();
            databaseItemWriter.setDataSource(dataSource);
            databaseItemWriter.setSql(BSCSUtils.QUERY_INSERT_UBI_SUMMARY);
            ItemPreparedStatementSetter<UnifiedInvoiceDTO> invoicePreparedStatementSetter = new InvoiceSummarySetter();
            databaseItemWriter.setItemPreparedStatementSetter(invoicePreparedStatementSetter);
            return databaseItemWriter;
        }
```

<p>Code snippets below for Composite writer as we have multiple tables</p>

<pre class="lang-java prettyprint-override"><code>        @Bean
        public CompositeItemWriter compositeWriter() throws Exception {
            CompositeItemWriter compositeItemWriter = new CompositeItemWriter();
            List<ItemWriter> writers = new ArrayList<ItemWriter>();
            logger.info("Composite Writer Started");
            writers.add(summaryWriter());
            writers.add(detailsWriter());
            writers.add(chartWriter());
            compositeItemWriter.setDelegates(writers);
            return compositeItemWriter;
        }
</code>```

Our Questions

Do we need to make Composite writer and JDBCwriter "StepScope" to avoid any concurrency issues. As per the documentation says JdbcBatchItemWriter is thread-safe.

Do we get any delay while insert(Batch commit) because of default Bean scope .

Please advise

答:
If a writer is documented to be thread safe, then you can use it in a multi-threaded step. I would configure each worker step with its own instances of reader/writer to make sure there is no concurrency issues.

I see no relation between the two. The idea of partitioning is that workers are executed in parallel, so you will have parallel transactions. Now using a shared writer in multiple parallel transactions vs using multiple writers is something you need to experiment and benchmark.

Body:
Please advise about the Spring batch partition Slave "JdbcBatchItemWriter" scope . Currently we have defined as default Bean scope with 30 partitions. As per the documentation says JdbcBatchItemWriter is thread-safe. Please note Our Reader is "STEPSCOPE"

Code snippets below for writer

        @Bean
        public JdbcBatchItemWriter<UnifiedInvoiceDTO> summaryWriter() {
            JdbcBatchItemWriter<UnifiedInvoiceDTO> databaseItemWriter = new JdbcBatchItemWriter<>();
            databaseItemWriter.setDataSource(dataSource);
            databaseItemWriter.setSql(BSCSUtils.QUERY_INSERT_UBI_SUMMARY);
            ItemPreparedStatementSetter<UnifiedInvoiceDTO> invoicePreparedStatementSetter = new InvoiceSummarySetter();
            databaseItemWriter.setItemPreparedStatementSetter(invoicePreparedStatementSetter);
            return databaseItemWriter;
        }

Code snippets below for Composite writer as we have multiple tables

        @Bean
        public CompositeItemWriter compositeWriter() throws Exception {
            CompositeItemWriter compositeItemWriter = new CompositeItemWriter();
            List<ItemWriter> writers = new ArrayList<ItemWriter>();
            logger.info("Composite Writer Started");
            writers.add(summaryWriter());
            writers.add(detailsWriter());
            writers.add(chartWriter());
            compositeItemWriter.setDelegates(writers);
            return compositeItemWriter;
        }

Our Questions

Do we need to make Composite writer and JDBCwriter "StepScope" to avoid any concurrency issues. As per the documentation says JdbcBatchItemWriter is thread-safe.

Do we get any delay while insert(Batch commit) because of default Bean scope .

Please advise