问:
How to use DataStore in jetpack compose while key is saved when loged in and validate it at Splash Screen?
I need help for this case, i want to save a token from login response using datastore. and get the  token and validate it in splash screen. if it was logged in, the screen will be move to dashboard. and if not logged in, the screen move to login screen. please help me

SplashScreen

```<code>@Composable
fun SplashScreen(navController: NavController) {
    var startAnimation by remember { mutableStateOf(false) }

    val context = LocalContext.current
    val appDatastore = AppDatastore.getInstance(context)!!
    val lifecycleOwner = LocalLifecycleOwner.current

    val alphaAnim = animateFloatAsState(
        targetValue = if (startAnimation) 0.8f else 0f,
        animationSpec = tween(
            durationMillis = 800,
            easing = {
                OvershootInterpolator(4f).getInterpolation(it)
            })
    )
    LaunchedEffect(key1 = true) {
        startAnimation = true
        delay(3000)
        navController.popBackStack()

        appDatastore.getUserToken.collect {
            if (it.isNotBlank()) {
                navController.navigate("home_screen")
            }else{
                navController.navigate("onboarding_screen")
            }
        }

        appDatastore.getOnboardStatus.collect{
            if (it) {
                navController.navigate("login_screen")
            }else{
                navController.navigate("onboarding_screen")
            }
        }
    }
    Splash(scale = alphaAnim.value)
}
</code>```

DataStore Class

```<code>class AppDatastore(private val context: Context) {

    private val Context.datastore: DataStore<Preferences> by preferencesDataStore(name = "app_datastore")

    private val TOKEN = stringPreferencesKey(name = "user_name")
    private val ONBOARD = booleanPreferencesKey("completed")

    companion object {
        @SuppressLint("StaticFieldLeak")
        var INSTANCE: AppDatastore? = null
        fun getInstance(base: Context): AppDatastore? {
            if (INSTANCE == null) {
                synchronized(AppDatastore::class.java) {
                    INSTANCE = AppDatastore(base.applicationContext)
                }
            }

            return INSTANCE
        }
    }

    suspend fun saveOnBoardStatus(isCompleted : Boolean) {
        context.datastore.edit { key ->
            key[ONBOARD] = isCompleted
        }
    }

    suspend fun saveUserToken(token: String) {
        context.datastore.edit { key ->
            key[TOKEN] = token
        }
    }

    val getUserToken: Flow<String> = context.datastore.data.map { preferences ->
        preferences[TOKEN] ?: ""
    }

    val getOnboardStatus: Flow<Boolean> = context.datastore.data.map { preferences ->
        preferences[ONBOARD] ?: false
    }

}
</code>```

Login Screen

```<code> Button(
                        onClick = {
                            viewModel.login(username, password)
                            lifecycleOwner.lifecycleScope.launch {
                                state.login?.token?.let { appDatastore.saveUserToken(it) }
                            }
                        },
                        modifier = Modifier
                            .fillMaxWidth()
                            .height(50.dp),
                        enabled = isFormValid,
                        shape = RoundedCornerShape(8.dp),
                        colors = ButtonDefaults.buttonColors(backgroundColor = Blue500)
                    ) {
                        Text(
                            text = "Login",
                            fontFamily = Poppins,
                            fontWeight = FontWeight.Bold,
                            color = Color.White,
                            fontSize = 16.sp
                        )
                    }
</code>```

Body:
I need help for this case, i want to save a token from login response using datastore. and get the  token and validate it in splash screen. if it was logged in, the screen will be move to dashboard. and if not logged in, the screen move to login screen. please help me

SplashScreen

@Composable
fun SplashScreen(navController: NavController) {
    var startAnimation by remember { mutableStateOf(false) }

    val context = LocalContext.current
    val appDatastore = AppDatastore.getInstance(context)!!
    val lifecycleOwner = LocalLifecycleOwner.current

    val alphaAnim = animateFloatAsState(
        targetValue = if (startAnimation) 0.8f else 0f,
        animationSpec = tween(
            durationMillis = 800,
            easing = {
                OvershootInterpolator(4f).getInterpolation(it)
            })
    )
    LaunchedEffect(key1 = true) {
        startAnimation = true
        delay(3000)
        navController.popBackStack()

        appDatastore.getUserToken.collect {
            if (it.isNotBlank()) {
                navController.navigate("home_screen")
            }else{
                navController.navigate("onboarding_screen")
            }
        }

        appDatastore.getOnboardStatus.collect{
            if (it) {
                navController.navigate("login_screen")
            }else{
                navController.navigate("onboarding_screen")
            }
        }
    }
    Splash(scale = alphaAnim.value)
}

DataStore Class

class AppDatastore(private val context: Context) {

    private val Context.datastore: DataStore<Preferences> by preferencesDataStore(name = "app_datastore")

    private val TOKEN = stringPreferencesKey(name = "user_name")
    private val ONBOARD = booleanPreferencesKey("completed")

    companion object {
        @SuppressLint("StaticFieldLeak")
        var INSTANCE: AppDatastore? = null
        fun getInstance(base: Context): AppDatastore? {
            if (INSTANCE == null) {
                synchronized(AppDatastore::class.java) {
                    INSTANCE = AppDatastore(base.applicationContext)
                }
            }

            return INSTANCE
        }
    }

    suspend fun saveOnBoardStatus(isCompleted : Boolean) {
        context.datastore.edit { key ->
            key[ONBOARD] = isCompleted
        }
    }

    suspend fun saveUserToken(token: String) {
        context.datastore.edit { key ->
            key[TOKEN] = token
        }
    }

    val getUserToken: Flow<String> = context.datastore.data.map { preferences ->
        preferences[TOKEN] ?: ""
    }

    val getOnboardStatus: Flow<Boolean> = context.datastore.data.map { preferences ->
        preferences[ONBOARD] ?: false
    }

}

Login Screen

 Button(
                        onClick = {
                            viewModel.login(username, password)
                            lifecycleOwner.lifecycleScope.launch {
                                state.login?.token?.let { appDatastore.saveUserToken(it) }
                            }
                        },
                        modifier = Modifier
                            .fillMaxWidth()
                            .height(50.dp),
                        enabled = isFormValid,
                        shape = RoundedCornerShape(8.dp),
                        colors = ButtonDefaults.buttonColors(backgroundColor = Blue500)
                    ) {
                        Text(
                            text = "Login",
                            fontFamily = Poppins,
                            fontWeight = FontWeight.Bold,
                            color = Color.White,
                            fontSize = 16.sp
                        )
                    }


来源: stackexchange

问:
Coloring on Folium Heatmap with Gradient
I have a dataframe called responses of this form:

```<code>| phrase_resp | lat       | lng        | color            |
|-------------|-----------|------------|------------------|
| 0.0         | 33.748992 | -84.390264 | rgb(155, 55, 0)  |
| 0.0         | 35.960395 | -83.921026 | rgb(155, 55, 0)  |
| 0.5         | 39.952724 | -75.163526 | rgb(0, 150, 250) |
| 0.5         | 41.355619 | -72.099780 | rgb(0, 150, 250) |
| 0.5         | 41.650020 | -72.734216 | rgb(0, 150, 250) |
</code>```

I'm feeding it into a Folium heatmap as follows, but all the datapoints are coming up as blue (i.e., rgb(0, 150, 250)). I've seen some of the posts here about using gradients, so that is what I did, but it isn’t working, of course. I believe it is something in this line:
HeatMap(responses[['lat', 'lng', 'phrase_resp']],gradient=gradient, radius=10).add_to(map_osm) # Add heat map to the previously created map

However, this is the broader context

```<code>gradient={0:'rgb(155, 55, 0)', 0.5:'rgb(0, 150, 250)',1:'rgb(0, 100, 0)'}
responses['color'] = responses['phrase_resp'].apply(lambda x: gradient[x])

colormap.add_to(map_osm) # add color bar at the top of the map
gradient={0:'rgb(155, 55, 0)', 0.5:'rgb(0, 150, 250)',1:'rgb(0, 100, 0)'}
HeatMap(responses[['lat', 'lng', 'phrase_resp']],gradient=gradient, radius=10).add_to(map_osm) # Add heat map to the previously created map

map_osm.save('newone.html') # Save as html file
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I have a dataframe called responses of this form:

| phrase_resp | lat       | lng        | color            |
|-------------|-----------|------------|------------------|
| 0.0         | 33.748992 | -84.390264 | rgb(155, 55, 0)  |
| 0.0         | 35.960395 | -83.921026 | rgb(155, 55, 0)  |
| 0.5         | 39.952724 | -75.163526 | rgb(0, 150, 250) |
| 0.5         | 41.355619 | -72.099780 | rgb(0, 150, 250) |
| 0.5         | 41.650020 | -72.734216 | rgb(0, 150, 250) |

I'm feeding it into a Folium heatmap as follows, but all the datapoints are coming up as blue (i.e., rgb(0, 150, 250)). I've seen some of the posts here about using gradients, so that is what I did, but it isn’t working, of course. I believe it is something in this line:
HeatMap(responses[['lat', 'lng', 'phrase_resp']],gradient=gradient, radius=10).add_to(map_osm) # Add heat map to the previously created map

However, this is the broader context

gradient={0:'rgb(155, 55, 0)', 0.5:'rgb(0, 150, 250)',1:'rgb(0, 100, 0)'}
responses['color'] = responses['phrase_resp'].apply(lambda x: gradient[x])

colormap.add_to(map_osm) # add color bar at the top of the map
gradient={0:'rgb(155, 55, 0)', 0.5:'rgb(0, 150, 250)',1:'rgb(0, 100, 0)'}
HeatMap(responses[['lat', 'lng', 'phrase_resp']],gradient=gradient, radius=10).add_to(map_osm) # Add heat map to the previously created map

map_osm.save('newone.html') # Save as html file


问:
Can't import h5py together with geopandas and rasterio
I am trying to extract data from .h5 files (SMAP L4 NEE) for buffer around study sites (points in a .geojson files) and save the data as .tiff files.  I have h5py, geopandas, and rasterio installed in a conda environment "geo-env".

Each package functions fine on its own and geopandas and rasterio work together fine.  However, if I import both h5py, I cannot import geopandas and/or rasterio.

For geopandas:

```<code>import h5py
import geopandas
</code>```

I get this traceback:

```<code>---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_28052/3630653928.py in <module>
      1 import os
      2 import h5py
----> 3 import geopandas
      4 import shutil
      5 import zipfile

~\.conda\envs\geo-env\lib\site-packages\geopandas\__init__.py in <module>
      5 from geopandas.array import points_from_xy  # noqa
      6
----> 7 from geopandas.io.file import _read_file as read_file  # noqa
      8 from geopandas.io.arrow import _read_parquet as read_parquet  # noqa
      9 from geopandas.io.arrow import _read_feather as read_feather  # noqa

~\.conda\envs\geo-env\lib\site-packages\geopandas\io\file.py in <module>
     18
     19 try:
---> 20     from fiona import Env as fiona_env
     21 except ImportError:
     22     try:

~\.conda\envs\geo-env\lib\site-packages\fiona\__init__.py in <module>
     83
     84 import fiona._loading
---> 85 with fiona._loading.add_gdal_dll_directories():
     86     from fiona.collection import BytesCollection, Collection
     87     from fiona.drvsupport import supported_drivers

AttributeError: partially initialized module 'fiona' has no attribute '_loading' (most likely due to a circular import)
</code>```

For rasterio:

```<code>import h5py
import rasterio
</code>```

I get this traceback:

```<code>---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_28052/2444724308.py in <module>
      1 import os
      2 import h5py
----> 3 import rasterio
      4 import shutil
      5 import zipfile

~\.conda\envs\geo-env\lib\site-packages\rasterio\__init__.py in <module>
      7 from pathlib import Path
      8
----> 9 from rasterio._base import gdal_version
     10 from rasterio.drivers import driver_from_extension, is_blacklisted
     11 from rasterio.dtypes import (

ImportError: DLL load failed while importing _base: The specified procedure could not be found.
</code>```

It looks to be related to fiona and/or gdal, but not sure what to do to fix it.  I installed geopandas and rasterio first - h5py was done later.

Is there a way to get these packages to play nicely together?

Body:
I am trying to extract data from .h5 files (SMAP L4 NEE) for buffer around study sites (points in a .geojson files) and save the data as .tiff files.  I have h5py, geopandas, and rasterio installed in a conda environment "geo-env".

Each package functions fine on its own and geopandas and rasterio work together fine.  However, if I import both h5py, I cannot import geopandas and/or rasterio.

For geopandas:

import h5py
import geopandas

I get this traceback:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_28052/3630653928.py in <module>
      1 import os
      2 import h5py
----> 3 import geopandas
      4 import shutil
      5 import zipfile

~\.conda\envs\geo-env\lib\site-packages\geopandas\__init__.py in <module>
      5 from geopandas.array import points_from_xy  # noqa
      6
----> 7 from geopandas.io.file import _read_file as read_file  # noqa
      8 from geopandas.io.arrow import _read_parquet as read_parquet  # noqa
      9 from geopandas.io.arrow import _read_feather as read_feather  # noqa

~\.conda\envs\geo-env\lib\site-packages\geopandas\io\file.py in <module>
     18
     19 try:
---> 20     from fiona import Env as fiona_env
     21 except ImportError:
     22     try:

~\.conda\envs\geo-env\lib\site-packages\fiona\__init__.py in <module>
     83
     84 import fiona._loading
---> 85 with fiona._loading.add_gdal_dll_directories():
     86     from fiona.collection import BytesCollection, Collection
     87     from fiona.drvsupport import supported_drivers

AttributeError: partially initialized module 'fiona' has no attribute '_loading' (most likely due to a circular import)

For rasterio:

import h5py
import rasterio

I get this traceback:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_28052/2444724308.py in <module>
      1 import os
      2 import h5py
----> 3 import rasterio
      4 import shutil
      5 import zipfile

~\.conda\envs\geo-env\lib\site-packages\rasterio\__init__.py in <module>
      7 from pathlib import Path
      8
----> 9 from rasterio._base import gdal_version
     10 from rasterio.drivers import driver_from_extension, is_blacklisted
     11 from rasterio.dtypes import (

ImportError: DLL load failed while importing _base: The specified procedure could not be found.

It looks to be related to fiona and/or gdal, but not sure what to do to fix it.  I installed geopandas and rasterio first - h5py was done later.

Is there a way to get these packages to play nicely together?


问:
Kotlin - @AliasFor not overriding attribute from @DisplayName
I'm trying to create an annotation for tests with a few meta-annotations. I'd like to pass a name parameter and use it for @DisplayName's value, by using @AliasFor. The code looks like this:

```<code>@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
@Nested
@DisplayName("")
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
internal annotation class EndpointTest(
    @get:AliasFor(annotation = DisplayName::class, attribute = "value")
    val name: String
)
</code>```

The value of @DisplayName is not being overriden, which is unexpected. It seems to be completely ignored. I used "" here because value does not have a default value

Body:
I'm trying to create an annotation for tests with a few meta-annotations. I'd like to pass a name parameter and use it for @DisplayName's value, by using @AliasFor. The code looks like this:

@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
@Nested
@DisplayName("")
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
internal annotation class EndpointTest(
    @get:AliasFor(annotation = DisplayName::class, attribute = "value")
    val name: String
)

The value of @DisplayName is not being overriden, which is unexpected. It seems to be completely ignored. I used "" here because value does not have a default value


问:
How to keep inserted text in textarea
I'm quite new to coding, so my code might be the hard way to get from point a to b.
I'm trying to start easy with a calendar where I can write down things on my schedule, but the problem is that the inserted text won't save when the page is refreshed, or I edit the code, and I can't seem to find any solutions that works.

I've seen someone mention echo, and I've tried

```<code><td>11<br><textarea rows="5" cols="3" class="Info"><php echo $_POST['textareaContent']; ?></textarea></td>
</code>```

But it just comes up as an error.

This is the current code:

```<code><td>1<br><textarea rows="5" cols="3" class="Info"></textarea></td>
</code>```

and I just wonder what I'm supposed to change or add in order to save text. Hopefully there's a solution out there where I don't need to start Javascript, cause my knowledge there is = 0...

Title: How to keep inserted text in textarea

Body:
I'm quite new to coding, so my code might be the hard way to get from point a to b.
I'm trying to start easy with a calendar where I can write down things on my schedule, but the problem is that the inserted text won't save when the page is refreshed, or I edit the code, and I can't seem to find any solutions that works.

I've seen someone mention echo, and I've tried

11
<textarea rows="5" cols="3" class="Info"><php echo $_POST['textareaContent']; ?></textarea>

But it just comes up as an error.

This is the current code:

1
<textarea rows="5" cols="3" class="Info"></textarea>

and I just wonder what I'm supposed to change or add in order to save text. Hopefully there's a solution out there where I don't need to start Javascript, cause my knowledge there is = 0...


问:
Fetch time(s) from database table to array for disable particular/selected time pickers
I have table from database here, where I want to fetch the times only (fld_booking_pickup, fld_booking_start, fld_booking_end in tbl_bookings database here), in order to disable particular time here that have been selected in database via timepicker.

This is the coding that I set for the times :

```<code><div class="form-group">
 <label for="Pickup">Pickup Time</label>
 <input type="time" class="form-control timepicker" name="fld_booking_pickuptime" id="fld_booking_pickuptime" placeholder="hh:mm A" value="" required>
</div>
</code>```
```<code><div class="form-group">
 <label for="StartTime">Program Time (Start)</label>
 <input type="time" class="form-control timepicker" name="fld_booking_start" id="fld_booking_start" placeholder="hh:mm A" value="" required>
</div>
</code>```
```<code><div class="form-group">
 <label for="EndTime">Program Time (End)</label>
 <input type="time" class="form-control timepicker" name="fld_booking_end" id="fld_booking_end" placeholder="hh:mm A" value="" required>
</div>
</code>```

This is the script that I use to disable time selection (I thought of replacing date with time in script, but I could be wrong since I really don't know any other ways for time, since I'm totally new in this) :

```<code><?php
$times = array();

$time_query = "SELECT `tbl_bookings`.`fld_booking_pickuptime`, `tbl_bookings`.`fld_booking_start`, `tbl_bookings`.`fld_booking_end` FROM `tbl_bookings` WHERE status_delete=1";
$time_result = mysqli_query($link, $time_query);
  if (mysqli_num_rows($time_result ) > 0) {
    while ($row = mysqli_fetch_assoc($time_result )) {
       $times [] = $row['fld_booking_pickuptime'], $row['fld_booking_pickuptime'], $row['fld_booking_pickuptime'];
    }
  }
?>

  var array = <?= json_encode($times)?>;

$('input.timepicker').timepicker({
    beforeShowDay: function(time){
        var string = jQuery.timepicker.formatTime('hh:mm A', date);
        return [ array.indexOf(string) == -1 ]
    }
});
</code>```

I want to fetch the respective times from database as the array, so that the times can be disabled for selection (using times that already in database). I am totally new in this, so I hope anyone can somewhat help me to fetch the times from database for the time selection disable. Thank you so much, totally appreciated ~

Body:
I have table from database here, where I want to fetch the times only (fld_booking_pickup, fld_booking_start, fld_booking_end in tbl_bookings database here), in order to disable particular time here that have been selected in database via timepicker.

This is the coding that I set for the times :

 Pickup Time
 <input type="time" class="form-control timepicker" name="fld_booking_pickuptime" id="fld_booking_pickuptime" placeholder="hh:mm A" value="" required>

 Program Time (Start)
 <input type="time" class="form-control timepicker" name="fld_booking_start" id="fld_booking_start" placeholder="hh:mm A" value="" required>

 Program Time (End)
 <input type="time" class="form-control timepicker" name="fld_booking_end" id="fld_booking_end" placeholder="hh:mm A" value="" required>

This is the script that I use to disable time selection (I thought of replacing date with time in script, but I could be wrong since I really don't know any other ways for time, since I'm totally new in this) :

<?php
$times = array();

$time_query = "SELECT `tbl_bookings`.`fld_booking_pickuptime`, `tbl_bookings`.`fld_booking_start`, `tbl_bookings`.`fld_booking_end` FROM `tbl_bookings` WHERE status_delete=1";
$time_result = mysqli_query($link, $time_query);
  if (mysqli_num_rows($time_result ) > 0) {
    while ($row = mysqli_fetch_assoc($time_result )) {
       $times [] = $row['fld_booking_pickuptime'], $row['fld_booking_pickuptime'], $row['fld_booking_pickuptime'];
    }
  }
?>

  var array = <?= json_encode($times)?>;

$('input.timepicker').timepicker({
    beforeShowDay: function(time){
        var string = jQuery.timepicker.formatTime('hh:mm A', date);
        return [ array.indexOf(string) == -1 ]
    }
});

I want to fetch the respective times from database as the array, so that the times can be disabled for selection (using times that already in database). I am totally new in this, so I hope anyone can somewhat help me to fetch the times from database for the time selection disable. Thank you so much, totally appreciated ~


问:
How to use Apache Camel to read data from ClickHouse
I am new to Apache Camel.

I use Camel SQL component to read data from ClickHouse. Below is my route.

```<code>from("timer://foofixedRate=true&period=60m").routeId("initCKSource").startupOrder(1).log([ckSource]querying...").to("sql:select datetime,date,id,idNumber from test_base;?dataSource=ckDS")
</code>```

And this error occurred:

```<code>Caused by: java.sql.SQLFeatureNotSupportedException: null
at ru.yandex.clickhouse.ClickHousePreparedStatementImpl.getParameterMetaData(ClickHousePreparedStatementImpl.java:442) \~\[clickhouse-jdbc-0.2.4.jar:na\]
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.getParameterMetaData(HikariProxyPreparedStatement.java) \~\[HikariCP-2.7.8.jar:na\]
at org.apache.camel.component.sql.SqlProducer$2.doInPreparedStatement(SqlProducer.java:120) \~\[camel-sql-2.23.0.jar:2.23.0\]
at org.apache.camel.component.sql.SqlProducer$2.doInPreparedStatement(SqlProducer.java:116) \~\[camel-sql-2.23.0.jar:2.23.0\]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:605) \~\[spring-jdbc-5.0.5.RELEASE.jar:5.0.5.RELEASE\]
... 12 common frames omitted
</code>```

Body:
I am new to Apache Camel.

I use Camel SQL component to read data from ClickHouse. Below is my route.

from("timer://foofixedRate=true&period=60m").routeId("initCKSource").startupOrder(1).log([ckSource]querying...").to("sql:select datetime,date,id,idNumber from test_base;?dataSource=ckDS")

And this error occurred:

Caused by: java.sql.SQLFeatureNotSupportedException: null
at ru.yandex.clickhouse.ClickHousePreparedStatementImpl.getParameterMetaData(ClickHousePreparedStatementImpl.java:442) \~\[clickhouse-jdbc-0.2.4.jar:na\]
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.getParameterMetaData(HikariProxyPreparedStatement.java) \~\[HikariCP-2.7.8.jar:na\]
at org.apache.camel.component.sql.SqlProducer$2.doInPreparedStatement(SqlProducer.java:120) \~\[camel-sql-2.23.0.jar:2.23.0\]
at org.apache.camel.component.sql.SqlProducer$2.doInPreparedStatement(SqlProducer.java:116) \~\[camel-sql-2.23.0.jar:2.23.0\]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:605) \~\[spring-jdbc-5.0.5.RELEASE.jar:5.0.5.RELEASE\]
... 12 common frames omitted


问:
How to write markdown in home page (index.html) in github pages jekyll-theme-chirpy?
I'm new to github pages and jekyll theme, while trying to use jekyll-theme-chirpy to write my own github pages.

I have learned that, in _tabs, each markdown file is a tab for the site.

But I don't know, how to edit home page using markdown ? There's only index.html file but I don't want to edit the html file, I want to write markdown file for home page.


问:
Calculating forward returns of an XTS object
I have a standard XTS stock price object.   I would like to add a column that consists of the forward one year return. So, if the row I’m evaluating is 2019-03-01, I would like the return of 2019-03-01 to 2020-03-01 to be added.  I have experimented with some ugly for loops, but I figure there has to be an elegant solution to this problem.   Thanks!

I created a subset using stockxts[“2019-03-01/2020-03-01”] and then used first and last.


问:
ERROR while running PDI transformation on Carte Cluster
I am working with PDI and Carte Cluster. My goal is to successfully run a transformation/ job on a Carte cluster. I already have deployed each Carte server running as a docker container.

From PDI Client, I connected to Pentaho Repository, opened up a .ktr file (transformation) and set it to run on the configurated Carte Cluster. However while executing the trans, I got:

ERROR: Socket is not connected

when a slave is trying to connect to the master. Then the transformation stopped and produced no results.

What should I do to fix this socket connection problem?

P/s: I am working on servers in a private LAN, so if you need any more details, leave a comment below and I will add them to the question.


Title: How to apply weights from function svydesign into function coxph?

Body:
How to use coxph to embed weights?

In the following codes, I wish I could use coxph to produce the same output as svycoxph.

Thank you!

Data

demo <- structure(list(SEP = c(142L, 112L, 104L, 119L, 102L, NA, 125L,
 110L, 112L, 127L, 115L, 122L, NA, 95L, 137L, 124L, NA, 147L,
 113L, 130L, 113L, 113L, 116L, NA, 114L, 128L, 108L, 115L, NA,
 NA, 126L, 117L, 152L, 122L, 123L, 104L, 120L, 118L, NA, 111L,
 137L, 96L, 141L, NA, 112L, NA, 141L, 124L, 131L, NA, 129L, 128L,
 107L, 127L, 114L, 111L, 133L, 129L, NA, 112L, 114L, NA, NA, 118L,
 115L, NA, 108L, 139L, 110L, 107L, 122L, 120L, 139L, 140L, 103L,
 NA, 95L, 120L, 139L, 124L, 130L, 133L, 114L, 104L, 125L, 117L,
 122L, 100L, 107L, 130L, 128L, 167L, 130L, 132L, 112L, NA, NA,
 NA, 111L, 129L, 119L, 144L, NA, 118L, 125L, 115L, 123L, 120L,
 120L, 115L, 123L, 117L, NA, NA, 102L, 108L, 109L, 107L, 146L,
 126L, 143L, 126L, 105L, NA, 145L, 140L, 118L, NA, 112L, 124L,
 114L, 112L, 109L, 130L, 102L, 128L, 138L, 139L, 108L, 111L, 127L,
 113L, 146L, 131L, 129L, 133L, 102L, 135L, 100L, 133L, 117L, 101L,
 NA, 123L, 134L, 85L, NA, 123L, 88L, 109L, 145L, 136L, 126L, 111L,
 106L, 111L, NA, 114L, 124L, 119L, 144L, NA, 139L, 148L, 133L,
 NA, 82L, NA, 97L, 132L, 108L, NA, NA, 115L, 127L, 119L, 144L,
 149L, 138L, 113L, 124L, 109L, 139L, NA, 139L, 144L, 102L, 129L,
 139L, 173L, 127L, NA, 138L, 205L, 124L, 125L, 123L, 126L, 115L,
 160L, 128L, 113L, 130L, 108L, NA, 133L, NA, 124L, 108L, NA, 114L,
 103L, NA, 122L, 112L, NA, 114L, 102L, 127L, 103L, 149L, 125L,
 138L, 145L, 127L, 114L, 134L, 112L, 127L, NA, 124L, 101L, 98L,
 150L, NA, 128L, 159L, 93L, NA, 132L, 107L, NA, 113L, 104L, 139L,
 110L, 119L, NA, 127L, NA, 135L, NA, NA, 153L, 94L, 128L, 130L,
 152L, 114L, 114L, NA, 123L, NA, 165L, 108L, 132L, 120L, 90L,
 101L, 108L, 96L, 94L, 119L, 143L, 120L, 142L, 136L, NA, 100L,
 121L, 117L, 119L, 129L, 116L, 129L, 123L, 126L, NA, 145L, 114L
), D_CVD = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 1L,
 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L,
 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 0L,
 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 1L, 1L,
 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L,
 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L,
 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L,
 0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L,
 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L,
 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L,
 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L,
 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 1L
), syear = c(28.75, 28.666666667, 28.583333333, 7.8333333333,
 26.166666667, 30.416666667, 27, 27, 27, 28.083333333, 17.333333333,
 25.75, 28.666666667, 21.75, 30.25, 21.833333333, 1.4166666667,
 20.666666667, 12.333333333, 30.916666667, 26.75, 30.166666667,
 25.25, 27.333333333, 14.666666667, 12.25, 28.75, 7.9166666667,
 30.916666667, 0.1666666667, 26.916666667, 29.583333333, 26.916666667,
 26.416666667, 5.9166666667, 29.333333333, 29.75, 25.5, 22.75,
 31, 3.5833333333, 5.8333333333, 26.666666667, 8.8333333333, 25.166666667,
 24.583333333, 29.833333333, 0.8333333333, 18.083333333, 30.083333333,
 29.833333333, 28.416666667, 26, 30.666666667, 16, 30.166666667,
 27.083333333, 15.583333333, 16.833333333, 30.333333333, 4.5,
 28.833333333, 28.416666667, 10.666666667, 28, 14.583333333, 27.333333333,
 28.166666667, 6.3333333333, 26.25, 27, 26.916666667, 30.916666667,
 14.25, 13.75, 28.333333333, 1.1666666667, 26.333333333, 30.083333333,
 11.583333333, 15.666666667, 27.166666667, 15.916666667, 26.25,
 25.75, 7.8333333333, 12.083333333, 2.5, 25.75, 14.916666667,
 10.333333333, 25.75, 27.833333333, 25.583333333, 0.9166666667,
 2.25, 22, 7.0833333333, 26.416666667, 30.75, 29.5, 28.583333333,
 4.8333333333, 27.333333333, 15.916666667, 25.5, 14.166666667,
 13.833333333, 19.166666667, 27, 27, 3.4166666667, 26.5, 19.25,
 30.166666667, 18.583333333, 28.416666667, 29.25, 29.75, 27.083333333,
 29.166666667, 2.3333333333, 18.583333333, 1, 13.916666667, 15.166666667,
 30.833333333, 27.333333333, 26.666666667, 6.75, 22.333333333,
 11.583333333, 27.583333333, 14.083333333, 30.916666667, 27.166666667,
 27.916666667, 29.166666667, 30.666666667, 29.166666667, 5.6666666667,
 26.25, 27.833333333, 29.416666667, 26.583333333, 26.75, 13.666666667,
 22.416666667, 26.666666667, 25.583333333, 25.416666667, 29.5,
 27.333333333, 27, 26.666666667, 26.5, 1, 24.333333333, 20, 28.75,
 8.75, 13.916666667, 25.916666667, 27.333333333, 26.75, 25.75,
 0.9166666667, 26, 13, 30.833333333, 4.5, 2.5833333333, 26, 18.083333333,
 30.333333333, 14.583333333, 30.416666667, 14.833333333, 30.583333333,
 6.6666666667, 29.333333333, 0.1666666667, 8.4166666667, 24.833333333,
 19.583333333, 29.083333333, 25.833333333, 27.083333333, 28.25,
 2.0833333333, 14.5, 26.583333333, 28, 19.583333333, 1.5, 25.833333333,
 31, 3.6666666667, 26.333333333, 7.9166666667, 28, 26.25, 28,
 27.583333333, 29.916666667, 30.25, 4.9166666667, 25.333333333,
 25.416666667, 28.916666667, 28.083333333, 26.166666667, 11.5,
 11.083333333, 23.916666667, 23.833333333, 27.166666667, 28.333333333,
 27.416666667, 28.5, 2.0833333333, 30.833333333, 17.166666667,
 11.75, 25.25, 7.5833333333, 30.333333333, 11.666666667, 18.666666667,
 27.25, 14.583333333, 27.833333333, 29.75, 25.166666667, 26, 29.5,
 20.25, 3.1666666667, 27, 1.1666666667, 25.75, 22.666666667, 12.75,
 7.0833333333, 26.833333333, 23.083333333, 18.833333333, 27, 8.1666666667,
 23.5, 28.5, 8.75, 9.75, 25.416666667, 11.083333333, 7.4166666667,
 25.833333333, 26.5, 28.333333333, 28.5, 14.583333333, 19.833333333,
 27.666666667, 0.0833333333, 30.25, 28.916666667, 28, 20.583333333,
 26.333333333, 22.416666667, 6.5833333333, 30.083333333, 14.166666667,
 26.583333333, 12.083333333, 26.25, 25.75, 26.666666667, 2.5,
 26.333333333, 30.75, 25.666666667, 30.25, 9.8333333333, 30.25,
 28.333333333, 28.333333333, 29.166666667, 5.75, 29.833333333,
 25.666666667, 7.3333333333, 6.3333333333, 28.083333333, 31, 30.833333333,
 28.083333333, 26.416666667, 19.25, 4.6666666667), SDPSTRA6 = c(33L,
23L, 23L, 34L, 11L, 1L, 2L, 17L, 31L, 3L, 47L, 41L, 31L, 33L,
1L, 29L, 40L, 19L, 8L, 14L, 42L, 30L, 27L, 21L, 44L, 32L, 31L,
25L, 49L, 28L, 31L, 8L, 7L, 32L, 27L, 17L, 40L, 13L, 8L, 12L,
10L, 24L, 14L, 14L, 45L, 19L, 7L, 3L, 19L, 24L, 7L, 8L, 6L, 5L,
17L, 30L, 31L, 30L, 49L, 34L, 43L, 31L, 2L, 8L, 33L, 14L, 23L,
46L, 22L, 26L, 2L, 36L, 49L, 21L, 38L, 2L, 22L, 20L, 9L, 18L,
12L, 17L, 40L, 20L, 8L, 13L, 12L, 2L, 38L, 36L, 32L, 41L, 19L,
28L, 18L, 6L, 3L, 13L, 38L, 21L, 43L, 27L, 7L, 22L, 26L, 25L,
23L, 28L, 12L, 31L, 1L, 16L, 22L, 23L, 9L, 36L, 43L, 17L, 40L,
31L, 35L, 27L, 8L, 4L, 28L, 39L, 49L, 23L, 45L, 8L, 26L, 17L,
22L, 21L, 3L, 18L, 43L, 35L, 4L, 32L, 49L, 26L, 4L, 44L, 34L,
30L, 5L, 33L, 30L, 28L, 28L, 28L, 29L, 7L, 34L, 39L, 2L, 20L,
24L, 31L, 5L, 33L, 47L, 21L, 15L, 8L, 40L, 47L, 30L, 21L, 32L,
20L, 47L, 34L, 34L, 6L, 22L, 17L, 48L, 5L, 46L, 20L, 3L, 16L,
34L, 32L, 9L, 31L, 10L, 8L, 10L, 32L, 19L, 20L, 8L, 41L, 12L,
11L, 47L, 2L, 3L, 29L, 43L, 48L, 25L, 34L, 30L, 27L, 16L, 33L,
33L, 11L, 29L, 19L, 12L, 33L, 31L, 26L, 21L, 6L, 22L, 3L, 7L,
43L, 29L, 37L, 34L, 12L, 18L, 5L, 7L, 19L, 18L, 29L, 49L, 45L,
8L, 14L, 7L, 6L, 13L, 8L, 15L, 27L, 42L, 31L, 18L, 4L, 15L, 2L,
6L, 26L, 48L, 27L, 45L, 39L, 47L, 38L, 10L, 27L, 7L, 8L, 34L,
31L, 9L, 29L, 44L, 47L, 20L, 28L, 6L, 24L, 37L, 12L, 22L, 22L,
41L, 15L, 22L, 20L, 21L, 9L, 1L, 49L, 11L, 10L, 26L, 20L, 41L,
39L, 8L, 40L, 1L, 3L, 12L, 3L, 3L, 38L, 10L, 20L), SDPPSU6 = c(1L,
 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 1L,
 1L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 2L,
 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L,
 1L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
 2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L,
 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 2L,
 1L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 2L,
 1L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 1L,
 1L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L,
 2L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 2L,
 1L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 1L,
 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 2L,
 2L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 2L,
 1L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L,
 2L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 2L,
 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 1L,
 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L,
 2L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 2L,
 1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 1L), WTPFEX6 = c(70305.12,
26679.42, 2392.94, 1, 20418.58, 34632.97, 9170.88, 9065.17, 1898.6,
3385.47, 48497.36, 1071.86, 71804, 1836.87, 20281.17, 4292.7,
1, 8235.62, 8576.61, 2568.94, 10018.47, 13817.29, 1496.91, 9961.41,
21211.54, 26056.15, 2182.63, 1388.16, 5133.71, 1, 1532.26, 2534.9,
3903.85, 4166.76, 11640.77, 36030.38, 15193.64, 3242.98, 2588.14,
30773, 2664.96, 1, 10534.91, 1511.47, 448.77, 1, 16470.85, 1,
2350.66, 1, 18470.06, 13400.55, 3136.18, 45311.92, 8305.63, 18901.18,
1898.6, 1683.18, 1, 1820.01, 561.36, 1, 1, 7500.18, 27127.77,
1, 2661.3, 2227.7, 2435.81, 32110.52, 61257.88, 2594.27, 1550.47,
21145.56, 2631.77, 1, 5569.31, 3894.58, 3689.18, 1559.86, 9186.91,
8428.62, 10957.64, 3894.58, 27327.4, 1220.33, 35432.29, 11618.4,
10799.48, 8662.42, 17790.83, 1438.94, 59012.42, 1246.2, 2600.09,
1, 3274.35, 5781.14, 10799.48, 4716.12, 9442.2, 19845.66, 1,
2742.66, 1466.43, 858.56, 15748.05, 399.24, 2643.2, 19468.16,
38622.86, 1629.12, 1, 1, 3077.67, 2473.32, 1814.24, 9953.44,
1401.84, 4726.59, 3611.62, 4362.71, 15016.25, 1, 544.53, 511.16,
2132.95, 2993.76, 3533.34, 7500.18, 2990.94, 8772.44, 3704.02,
24069.73, 4397.87, 1682.75, 36060.87, 3941.6, 3630.22, 7126.87,
1947.65, 1326.43, 54646.15, 1275.45, 22828.25, 19627.39, 23796.23,
1, 4494, 1068.12, 1589.53, 1915.72, 1, 39353.42, 22828.25, 1122.5,
13147.49, 5342.93, 2408.39, 4592.06, 11022.59, 31529.06, 37841.46,
24883.34, 33771.31, 2883.48, 12193.27, 49085.22, 1390.43, 20740.41,
4722.67, 1, 2448.05, 11763.34, 1583.02, 1, 5808.52, 1, 2104.03,
11771.04, 1749.21, 1, 5626.76, 8160.31, 6857.48, 3351.51, 4505.82,
4411.05, 19063.88, 23577.03, 13043.05, 44167.93, 10635.15, 3832.6,
2855.58, 1438.94, 3690.31, 5445.54, 1906.9, 3648.03, 13601.59,
3812.9, 2263.26, 30582.5, 2801.9, 1915.69, 917.02, 14590.25,
24765.25, 59661.84, 2236.43, 3424.55, 15998.15, 6982.24, 1, 951.83,
1, 4200.6, 5177.99, 7718.35, 8319.23, 7082.91, 1, 1824.88, 54463.42,
25085.12, 7746.23, 4491.25, 5856.82, 5114.27, 9043.98, 2278.74,
49639.31, 3422.93, 6296.11, 1334.39, 589.08, 2134.13, 30255.34,
1, 4698.28, 23572.91, 8520.58, 10193.14, 1, 14869.29, 4843.95,
21110.42, 1, 18366.32, 23390.25, 1, 3486.36, 1436.43, 443.71,
563.86, 2280.91, 1, 22098.83, 19845.66, 10745.24, 1, 1, 1959.98,
3617.72, 2471.76, 41588.8, 1877.66, 45992.91, 2197.45, 1, 24780.76,
1, 35139.21, 1, 4029.27, 492.95, 3242.55, 10250.8, 29930.07,
7742.58, 48058.22, 25040.37, 4795.47, 13525.29, 4418.72, 3731.79,
7691.44, 367.45, 2207.73, 31226.75, 2276.24, 10989.21, 3385.47,
23638.87, 4397.87, 5682.27, 2869, 1, 3868.25)), row.names = c(3015L,
8586L, 8677L, 11466L, 9224L, 8701L, 15210L, 11787L, 4196L, 9629L,
12854L, 13543L, 8607L, 10722L, 7847L, 9800L, 19320L, 11658L,
19045L, 1907L, 12858L, 14351L, 1425L, 11314L, 15872L, 19384L,
47L, 16412L, 2951L, 17309L, 10719L, 338L, 18070L, 7007L, 15689L,
7960L, 10131L, 11287L, 13905L, 8726L, 16943L, 18068L, 6271L,
12688L, 15704L, 12533L, 4918L, 16987L, 14398L, 63L, 9846L, 14585L,
6852L, 795L, 17084L, 4777L, 4475L, 10430L, 11073L, 419L, 13784L,
4971L, 166L, 14622L, 1053L, 10786L, 7006L, 3271L, 6605L, 3389L,
9249L, 6162L, 5077L, 9030L, 4254L, 2868L, 16125L, 9704L, 8603L,
12914L, 18659L, 6359L, 19103L, 6346L, 8872L, 16100L, 2322L, 17860L,
6095L, 15568L, 19431L, 4113L, 3682L, 1383L, 17507L, 16967L, 9388L,
18137L, 6820L, 2871L, 528L, 5998L, 19079L, 7009L, 6366L, 6465L,
13991L, 14350L, 17575L, 1221L, 10818L, 14928L, 10728L, 11507L,
5505L, 14502L, 753L, 10189L, 1890L, 1217L, 9825L, 17021L, 13383L,
18730L, 19022L, 14665L, 2911L, 6481L, 1842L, 17006L, 13185L,
13531L, 3780L, 4203L, 160L, 14290L, 9972L, 8023L, 5368L, 11690L,
6677L, 7168L, 717L, 5881L, 7323L, 11406L, 12297L, 14789L, 6488L,
1207L, 1184L, 5252L, 4137L, 3571L, 9602L, 10987L, 15538L, 845L,
14941L, 4719L, 15463L, 16384L, 6756L, 11407L, 4259L, 10625L,
13911L, 4119L, 15984L, 2508L, 16942L, 16534L, 1336L, 19111L,
8313L, 14066L, 10201L, 15739L, 4734L, 19185L, 5513L, 18325L,
17606L, 11306L, 11374L, 2369L, 3426L, 3712L, 7965L, 11576L, 13642L,
12913L, 16004L, 9428L, 17179L, 3472L, 5339L, 17733L, 13554L,
12906L, 15944L, 3730L, 1838L, 1319L, 11489L, 2444L, 17064L, 4070L,
11754L, 136L, 11430L, 11310L, 19144L, 13038L, 16795L, 14323L,
1584L, 82L, 10504L, 4583L, 14630L, 11007L, 16316L, 17896L, 3745L,
8245L, 8704L, 2631L, 19203L, 10628L, 18407L, 7553L, 5562L, 3844L,
12800L, 2205L, 12532L, 18704L, 9093L, 15312L, 9988L, 13853L,
18211L, 16439L, 11880L, 18987L, 16152L, 12548L, 14740L, 15928L,
2358L, 16281L, 16657L, 6778L, 18241L, 16539L, 1410L, 3715L, 5323L,
8688L, 16090L, 16232L, 11252L, 12299L, 10850L, 5372L, 4006L,
12204L, 3601L, 13315L, 18820L, 10309L, 18283L, 1455L, 9905L,
1313L, 19513L, 1566L, 13958L, 14219L, 5849L, 1087L, 10136L, 16983L,
14660L, 240L, 2989L, 8617L, 13102L, 896L, 9243L, 17620L, 18866L,
9520L, 804L, 249L, 9983L, 1555L, 16694L, 12630L), class = "data.frame")

Code

library(survey)
demoDesign <- svydesign(data = demo, strata = ~SDPSTRA6, id = ~SDPPSU6, nest = TRUE, weights = ~WTPFEX6)
svycoxph(Surv(syear,D_CVD) ~ SEP, design=demoDesign)

library(survival)
coxph(Surv(syear,D_CVD) ~ SEP, data=demo)


问:
Why are props not being passed from component to page?
I'm trying to move some API fetch code out of a main page in my Next.js app and into a component file. Mostly in order to keep things organised and reduce the amount of code in the main page.

On the main page the API fetching is done inside getInitialProps as it uses async functions. This all works fine. I've now moved the code into a component file but the props aren't returning anything to the main page.

Component file:

```<code>// Link removed for security.
const sheet = 'GOOGLE_SHEETS_API_LINK';

// Function to fetch cell data from a Google Sheet.
async function getCellData(url,array1,array2) {
  let doTheFetch = await fetch(url);
  let jsonify = await doTheFetch.json();
  let getValue = jsonify.values[array1][array2];
  return getValue;
}

export async function getServerSideProps() {
  const testDataReturn = () => {
    // Sheet API link & position of data in the nested array that's returned.
    return getCellData(sheet,0,0)
  }
  const testDataReturnOutput = await testDataReturn();

  return {
    props: {
        message: 'Hello world!',
        testDataReturnOutput: testDataReturnOutput
    }
  }
}

function Page({ message, testDataReturnOutput }) {
  return (
      <>
          <h1>Example page</h1>
          <h2>{message}</h2>
          <div>Cell data: {testDataReturnOutput}</div>
      </>
  )
}

export default Page
</code>```

Relevant code on my main index page:

```<code>import Page from '../components/Page';

function Dashboard(props) {
  return (
    <Page />
  );
}

export default Dashboard
</code>```

I can import this component file normally in the main page. The issue is that the HTML is rendered but the props: {message} and {testDataReturnOutput} are not. Do I need to pass down the props in a different way?

Body:
I'm trying to move some API fetch code out of a main page in my Next.js app and into a component file. Mostly in order to keep things organised and reduce the amount of code in the main page.

On the main page the API fetching is done inside getInitialProps as it uses async functions. This all works fine. I've now moved the code into a component file but the props aren't returning anything to the main page.

Component file:

// Link removed for security.
const sheet = 'GOOGLE_SHEETS_API_LINK';

// Function to fetch cell data from a Google Sheet.
async function getCellData(url,array1,array2) {
  let doTheFetch = await fetch(url);
  let jsonify = await doTheFetch.json();
  let getValue = jsonify.values[array1][array2];
  return getValue;
}

export async function getServerSideProps() {
  const testDataReturn = () => {
    // Sheet API link & position of data in the nested array that's returned.
    return getCellData(sheet,0,0)
  }
  const testDataReturnOutput = await testDataReturn();

  return {
    props: {
        message: 'Hello world!',
        testDataReturnOutput: testDataReturnOutput
    }
  }
}

function Page({ message, testDataReturnOutput }) {
  return (
      <>

Example page

{message}

Cell data: {testDataReturnOutput}

      </>
  )
}

export default Page

Relevant code on my main index page:

import Page from '../components/Page';

function Dashboard(props) {
  return (
    <Page />
  );
}

export default Dashboard

I can import this component file normally in the main page. The issue is that the HTML is rendered but the props: {message} and {testDataReturnOutput} are not. Do I need to pass down the props in a different way?


问:
Uncaught TypeError: Cannot read properties of undefined (reading 'appendChild') in Odoo 14
I want to show dialog when click tree-record, i used js to write code below, but odoo show error message like question title

```<code>notificationDialogPopup: function(data){
   if(data){
      const container = document.createElement('div');
      container.setAttribute("id","container");

      const title = document.createElement('h1');
      title.setAttribute("id", "title");
      title.innerText = "Title Testing";

      const content = document.createElement('p');
      content.setAttribute("id","content");
      content.innerText = "Content Testing";

      const date = document.createElement('h6');
      date.setAttribute("id","date");
      date.innerText = "11-11-1999";

      const author = document.createElement('h6');
      author.setAttribute("id","author");
      author.inertText = "Admin";

      const btnClose = document.createElement('button');
      btnClose.setAttribute("id","button");

      const style = document.createElement('style');
      style.innerHTML = "#notification-container {}"
            + "#title {color:red}"
            + "#content {color:blue}"
            + "#date {color:red}"
            + "#author {color:red}"
            + "#button {color:red}"

      document.container.appendChild(title);
      document.container.appendChild(content);
      document.container.appendChild(date);
      document.container.appendChild(author);
      document.container.appendChild(btnClose);
      document.head.appendChild(style);
      document.body.appendChild(container);
   }
}
</code>```

});

i tried change position appendChild but not working

Body:
I want to show dialog when click tree-record, i used js to write code below, but odoo show error message like question title

notificationDialogPopup: function(data){
   if(data){
      const container = document.createElement('div');
      container.setAttribute("id","container");

      const title = document.createElement('h1');
      title.setAttribute("id", "title");
      title.innerText = "Title Testing";

      const content = document.createElement('p');
      content.setAttribute("id","content");
      content.innerText = "Content Testing";

      const date = document.createElement('h6');
      date.setAttribute("id","date");
      date.innerText = "11-11-1999";

      const author = document.createElement('h6');
      author.setAttribute("id","author");
      author.inertText = "Admin";

      const btnClose = document.createElement('button');
      btnClose.setAttribute("id","button");

      const style = document.createElement('style');
      style.innerHTML = "#notification-container {}"
            + "#title {color:red}"
            + "#content {color:blue}"
            + "#date {color:red}"
            + "#author {color:red}"
            + "#button {color:red}"

      document.container.appendChild(title);
      document.container.appendChild(content);
      document.container.appendChild(date);
      document.container.appendChild(author);
      document.container.appendChild(btnClose);
      document.head.appendChild(style);
      document.body.appendChild(container);
   }
}

});

i tried change position appendChild but not working


问:
Laravel command fails on cPanel only
I have a command where I find some models and send emails. I'm not gonna post the whole code but simply it looks like this.

` Log::info('Daily Late  Requests Check Executed!');
$newRequests=ModelsRequest::where("status","pending")->get();

```<code>    foreach ($newRequests as $request){

     Http::get('url', [
     //parameters//
     ]);

     Mail::to($request->donorEmail)->send(new donorLateReq([
     //parameters//
     ]));
 } `
</code>```

I have added this command on Kernal.php and this works fine when I run php artisan schedule:run on my localhost.

But on my cpanel it only executes this line.

Log::info('Daily Late Requests Check Executed!');

I guess this line can't be executed on cpanel.

ModelsRequest::where("status","pending")->get();

All models are working fine on every controller. The whole app works fine on cpanel except this scheduled command.

I tried sending an email, sending an sms using this scheduled command and those worked fine.

Anyone knows how to fix this on cPanel?

Thanks!

Tried running a scheduled laravel command on cpanel

Title: Laravel command fails on cPanel only

Body:
I have a command where I find some models and send emails. I'm not gonna post the whole code but simply it looks like this.

` Log::info('Daily Late  Requests Check Executed!');
$newRequests=ModelsRequest::where("status","pending")->get();

    foreach ($newRequests as $request){

     Http::get('url', [
     //parameters//
     ]);

     Mail::to($request->donorEmail)->send(new donorLateReq([
     //parameters//
     ]));
 } `

I have added this command on Kernal.php and this works fine when I run php artisan schedule:run on my localhost.

But on my cpanel it only executes this line.

Log::info('Daily Late Requests Check Executed!');

I guess this line can't be executed on cpanel.

ModelsRequest::where("status","pending")->get();

All models are working fine on every controller. The whole app works fine on cpanel except this scheduled command.

I tried sending an email, sending an sms using this scheduled command and those worked fine.

Anyone knows how to fix this on cPanel?

Thanks!

Tried running a scheduled laravel command on cpanel


问:
(linux python) mysql.connector downloading and extract issue
I follow the tutorial  installing mysql-connector

https://pynative.com/install-mysql-connector-python/

environment:
linux redhat version: CentOS Linux 7 (Core), x86-64

python 2.7.5

that I download "mysql-connector-python3-8.0.31-1.el7.x86_64.rpm" package  to extract

but I used $ tar xzf mysql-connector-python-2.7.tar.gz wasn't work, what the problem

additional equiment info: if someone needed

```<code>[root@localhost bin]# hostnamectl
   Static hostname: localhost.localdomain
         Icon name: computer-desktop
           Chassis: desktop
        Machine ID: d09237002da04b0295253727d227eb9a
           Boot ID: b18995e3345343249830026bd06b92a0
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-957.el7.x86_64
      Architecture: x86-64
</code>```

the website screenshot

the main problem is from this, my classmate's discussion

(Pyscript) website showing No module named 'mysql'

but after pip3 installed, is not working

Body:
I follow the tutorial  installing mysql-connector

https://pynative.com/install-mysql-connector-python/

environment:
linux redhat version: CentOS Linux 7 (Core), x86-64

python 2.7.5

that I download "mysql-connector-python3-8.0.31-1.el7.x86_64.rpm" package  to extract

but I used $ tar xzf mysql-connector-python-2.7.tar.gz wasn't work, what the problem

additional equiment info: if someone needed

[root@localhost bin]# hostnamectl
   Static hostname: localhost.localdomain
         Icon name: computer-desktop
           Chassis: desktop
        Machine ID: d09237002da04b0295253727d227eb9a
           Boot ID: b18995e3345343249830026bd06b92a0
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-957.el7.x86_64
      Architecture: x86-64

the website screenshot

the main problem is from this, my classmate's discussion

(Pyscript) website showing No module named 'mysql'

but after pip3 installed, is not working


问:
Accessing CDK generated ARNs from SAM launch.json debug config
I'm using the CDK to generate Node Lambdas.
I need to pass in the ARN of a created topic to the lambda. This is easy enough using environment variables and accessing topicArn from the CDK library.

I'm also using SAM to debug locally. To do this, I'm populating enviornment variables in launch.json.

The issue is that I don't know at write time the ARN of the topic. I guess that I could enter it manually, but that wouldn't scale and would be fragile when I tear down and rebuild the stack. Another idea might be to use the topic name, then at runtime do an SNS query to find that topic and pull its ARN. That seems messy too though.

Are there any tricks for referencing a CDK generated ARN in launch.json?

cdk definition code

```<code>// SNS
    const {SNSTopic} =  new CreateSNSTopicConstruct(this)

// Lambda
const handler = new aws_lambda_nodejs.NodejsFunction(
    this,
    "MyLamda",
    {
        entry: "resources/source.ts",
        handler: "handler",
        environment:{
            SNS_TOPIC_ARN : SNSTopic.topicArn // This works fine for deployed code.

     }...
</code>```

launch.json

```<code>"configurations": [
    {
        "type": "aws-sam",
        "request": "direct-invoke",
        "aws": {
            "credentials": "profile:personal",
            "region": "ap-southeast-2"
        },
        "name": "_:resources/geotabFeedAccess.handler (nodejs14.x)",
        "invokeTarget": {
            "target": "code",
            "projectRoot": "${workspaceFolder}/",
            "lambdaHandler": "resources/source.handler"
        },
        "lambda": {
            "runtime": "nodejs14.x",

            "environmentVariables": {
                "SNS_TOPIC_ARN":"", // .... but how do I reference it here?

            },
        },
    }
</code>```

Body:
I'm using the CDK to generate Node Lambdas.
I need to pass in the ARN of a created topic to the lambda. This is easy enough using environment variables and accessing topicArn from the CDK library.

I'm also using SAM to debug locally. To do this, I'm populating enviornment variables in launch.json.

The issue is that I don't know at write time the ARN of the topic. I guess that I could enter it manually, but that wouldn't scale and would be fragile when I tear down and rebuild the stack. Another idea might be to use the topic name, then at runtime do an SNS query to find that topic and pull its ARN. That seems messy too though.

Are there any tricks for referencing a CDK generated ARN in launch.json?

cdk definition code

// SNS
    const {SNSTopic} =  new CreateSNSTopicConstruct(this)

// Lambda
const handler = new aws_lambda_nodejs.NodejsFunction(
    this,
    "MyLamda",
    {
        entry: "resources/source.ts",
        handler: "handler",
        environment:{
            SNS_TOPIC_ARN : SNSTopic.topicArn // This works fine for deployed code.

     }...

launch.json

"configurations": [
    {
        "type": "aws-sam",
        "request": "direct-invoke",
        "aws": {
            "credentials": "profile:personal",
            "region": "ap-southeast-2"
        },
        "name": "_:resources/geotabFeedAccess.handler (nodejs14.x)",
        "invokeTarget": {
            "target": "code",
            "projectRoot": "${workspaceFolder}/",
            "lambdaHandler": "resources/source.handler"
        },
        "lambda": {
            "runtime": "nodejs14.x",

            "environmentVariables": {
                "SNS_TOPIC_ARN":"", // .... but how do I reference it here?

            },
        },
    }


问:
How do you use multiple NavigationLinks in a single list row in SwiftUI?
I want to navigate to HelloWorldView when "Hello" is clicked. However, if the text "Bye" is clicked, then I want to navigate to the ByeWorldView. In the past, I was able to use isActive on the multiple NavigationLinks to get this to work, but Apple has deprecated this in iOS 16.2, so now I am back to the drawing board.

```<code>import SwiftUI

struct ContentView: View {
    var body: some View {
        NavigationStack {
            ListView()
        }
    }
}

struct ListView: View {
    var body: some View {
        List {
            RowView()
            RowView()
            RowView()
        }
    }
}

struct RowView: View {
    @State var text: String = ""
    var body: some View {
        HStack{
            Button("Bye") {
                text = "bye"
            }
            Button("Hello") {
                text = "hello"
            }
            NavigationLink("", value: text).opacity(0)
        }
        .navigationDestination(for: String.self) { string in
            if(string == "hello") {
                HelloWorldView()
            } else {
                ByeWorldView()
            }
        }
    }
}

struct HelloWorldView: View {
    var body: some View {
        Text("Hello, World!")
    }
}

struct ByeWorldView: View {
    var body: some View {
        Text("Bye, World!")
    }
}
</code>```

Body:
I want to navigate to HelloWorldView when "Hello" is clicked. However, if the text "Bye" is clicked, then I want to navigate to the ByeWorldView. In the past, I was able to use isActive on the multiple NavigationLinks to get this to work, but Apple has deprecated this in iOS 16.2, so now I am back to the drawing board.

import SwiftUI

struct ContentView: View {
    var body: some View {
        NavigationStack {
            ListView()
        }
    }
}

struct ListView: View {
    var body: some View {
        List {
            RowView()
            RowView()
            RowView()
        }
    }
}

struct RowView: View {
    @State var text: String = ""
    var body: some View {
        HStack{
            Button("Bye") {
                text = "bye"
            }
            Button("Hello") {
                text = "hello"
            }
            NavigationLink("", value: text).opacity(0)
        }
        .navigationDestination(for: String.self) { string in
            if(string == "hello") {
                HelloWorldView()
            } else {
                ByeWorldView()
            }
        }
    }
}

struct HelloWorldView: View {
    var body: some View {
        Text("Hello, World!")
    }
}

struct ByeWorldView: View {
    var body: some View {
        Text("Bye, World!")
    }
}


问:
phpmyadmin "Not Found: The requested URL was not found on this server."
Good day. I installed phpmyadmin on Centos 9 machine that I opened via Digitalocean. When I entered nano /etc/httpd/conf.d/phpMyAdmin.conf after installation, I encountered something different from other people. I used the settings they shared in my own file, but it didn't work. I don't understand what to do here. There are no places like Require ip and Allow from. I couldn't find where to write my ip address. This is my first time doing this kind of work, so I'm sorry. Thanks in advance. Good day.

```<code># phpMyAdmin - Web based MySQL browser written in php
#
# Allows only localhost by default
#
# But allowing phpMyAdmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL

Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   Require local
</Directory>

<Directory /usr/share/phpMyAdmin/setup/>
   Require local
</Directory>

# These directories do not require access over HTTP - taken from the original
# phpMyAdmin upstream tarball
#
<Directory /usr/share/phpMyAdmin/libraries/>
    Require all denied
</Directory>

<Directory /usr/share/phpMyAdmin/templates/>
    Require all denied
</Directory>

<Directory /usr/share/phpMyAdmin/setup/lib/>
    Require all denied
</Directory>

<Directory /usr/share/phpMyAdmin/setup/frames/>
    Require all denied
</Directory>

# This configuration prevents mod_security at phpMyAdmin directories from
# filtering SQL etc.  This may break your mod_security implementation.
#
#<IfModule mod_security.c>
#    <Directory /usr/share/phpMyAdmin/>
#        SecRuleInheritance Off
#    </Directory>
#</IfModule>
</code>```

I deleted Require all denied and replaced it with Require ip your_workstation_IP_address and Allow from your_workstation_IP_address. But it didn't work. After that I tried these settings but it still didn't work.(I had my own ip address where it says 127.0.0.1)

```<code><Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       #ADD following line:
       Require all granted
       Require ip 127.0.0.1
       Require ip ::1
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     #CHANGE following 2 lines:
     Order Allow,Deny
     Allow from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>
</code>```

Body:
Good day. I installed phpmyadmin on Centos 9 machine that I opened via Digitalocean. When I entered nano /etc/httpd/conf.d/phpMyAdmin.conf after installation, I encountered something different from other people. I used the settings they shared in my own file, but it didn't work. I don't understand what to do here. There are no places like Require ip and Allow from. I couldn't find where to write my ip address. This is my first time doing this kind of work, so I'm sorry. Thanks in advance. Good day.

# phpMyAdmin - Web based MySQL browser written in php
#
# Allows only localhost by default
#
# But allowing phpMyAdmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL

Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   Require local
</Directory>

<Directory /usr/share/phpMyAdmin/setup/>
   Require local
</Directory>

# These directories do not require access over HTTP - taken from the original
# phpMyAdmin upstream tarball
#
<Directory /usr/share/phpMyAdmin/libraries/>
    Require all denied
</Directory>

<Directory /usr/share/phpMyAdmin/templates/>
    Require all denied
</Directory>

<Directory /usr/share/phpMyAdmin/setup/lib/>
    Require all denied
</Directory>

<Directory /usr/share/phpMyAdmin/setup/frames/>
    Require all denied
</Directory>

# This configuration prevents mod_security at phpMyAdmin directories from
# filtering SQL etc.  This may break your mod_security implementation.
#
#<IfModule mod_security.c>
#    <Directory /usr/share/phpMyAdmin/>
#        SecRuleInheritance Off
#    </Directory>
#</IfModule>

I deleted Require all denied and replaced it with Require ip your_workstation_IP_address and Allow from your_workstation_IP_address. But it didn't work. After that I tried these settings but it still didn't work.(I had my own ip address where it says 127.0.0.1)

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       #ADD following line:
       Require all granted
       Require ip 127.0.0.1
       Require ip ::1
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     #CHANGE following 2 lines:
     Order Allow,Deny
     Allow from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>


问:
Microsoft Graph API Problem Accessing OneDrive Items Shared by External User
I am writing a .NET desktop app that uses the Microsoft Graph API to access the contents of my OneDrive for Business storage.  I am logging in to Graph using my Microsoft work/school account U1, in my organization O1.  Another Microsoft work/school account, U2, in a different organization, O2, has shared a folder with me.  The folder shows up in "Shared With You" when I browse my OneDrive interactively in a browser, and I can make changes to the folder there.  It also shows up as a DriveItem in the returned list when my app uses the "sharedWithMe" API call documented here (with allowexternal set to true).

All good so far.  The problem is when I try to actually retrieve the shared folder using the returned DriveItem.  I am following the guidance in the doc page to use a call like

```<code>GET /drives/{remoteItem-driveId}/items/{remoteItem-id}
</code>```

to retrieve the folder, and I have the "Files.ReadWrite.All" permission.  I believe I am doing this correctly in my code, because it works fine on other items shared with me by users in my organization.  However, with the folder shared by U2, this call fails with an "itemNotFound" error.  I don't understand why this fails.  Is this a problem with my code, or some configuration that needs to be done in my organization O1, or in their organization O2, or a combination?  Or is what I'm trying to do just not possible across organizations?

I have found a couple other folks who have had similar problems, but the resolutions are inconclusive: see here, here, and here.  These links have suggested a couple directions:

could this be a problem with some sharing setting on the part of organization O2?  Unfortunately I don't have any control over this org.  But if I can give them a clear request, preferably with some Microsoft docs to back it up, I think they would be receptive.  For example, does organization O2 need to add/invite my account U1 as an external/guest user to their Azure AD?  I don't know for sure if they've done that.

one of the comments suggested that my app would need to be a multi-tenant app for it to access resources in another tenant.  I do not want my app to be multi-tenant in the sense of allowing people in other tenants to login to it, but I do want my account to be able to access resources in other tenants that have been shared with me.  I tried changing the app registration for my app to multi-tenant, and that didn't make any difference.

in the multi-tenant vein, I found this Microsoft doc, which states "In the code of your multi-tenant app, get the authentication token for other tenants and store them in the auxiliary headers. The user or application must have been invited as a guest to the other tenants."  In my code I am using Microsoft.Identity.Client.PublicClientApplicationBuilder to sign my account in and get an access token, using the authority for my tenant.  It sounds like my access token is only valid for resources in my tenant - how do I get a token for another tenant in my code?

Thanks very much for any suggestions, be they pointers to docs, code suggestions, etc!

Body:
I am writing a .NET desktop app that uses the Microsoft Graph API to access the contents of my OneDrive for Business storage.  I am logging in to Graph using my Microsoft work/school account U1, in my organization O1.  Another Microsoft work/school account, U2, in a different organization, O2, has shared a folder with me.  The folder shows up in "Shared With You" when I browse my OneDrive interactively in a browser, and I can make changes to the folder there.  It also shows up as a DriveItem in the returned list when my app uses the "sharedWithMe" API call documented here (with allowexternal set to true).

All good so far.  The problem is when I try to actually retrieve the shared folder using the returned DriveItem.  I am following the guidance in the doc page to use a call like

GET /drives/{remoteItem-driveId}/items/{remoteItem-id}

to retrieve the folder, and I have the "Files.ReadWrite.All" permission.  I believe I am doing this correctly in my code, because it works fine on other items shared with me by users in my organization.  However, with the folder shared by U2, this call fails with an "itemNotFound" error.  I don't understand why this fails.  Is this a problem with my code, or some configuration that needs to be done in my organization O1, or in their organization O2, or a combination?  Or is what I'm trying to do just not possible across organizations?

I have found a couple other folks who have had similar problems, but the resolutions are inconclusive: see here, here, and here.  These links have suggested a couple directions:

could this be a problem with some sharing setting on the part of organization O2?  Unfortunately I don't have any control over this org.  But if I can give them a clear request, preferably with some Microsoft docs to back it up, I think they would be receptive.  For example, does organization O2 need to add/invite my account U1 as an external/guest user to their Azure AD?  I don't know for sure if they've done that.

one of the comments suggested that my app would need to be a multi-tenant app for it to access resources in another tenant.  I do not want my app to be multi-tenant in the sense of allowing people in other tenants to login to it, but I do want my account to be able to access resources in other tenants that have been shared with me.  I tried changing the app registration for my app to multi-tenant, and that didn't make any difference.

in the multi-tenant vein, I found this Microsoft doc, which states "In the code of your multi-tenant app, get the authentication token for other tenants and store them in the auxiliary headers. The user or application must have been invited as a guest to the other tenants."  In my code I am using Microsoft.Identity.Client.PublicClientApplicationBuilder to sign my account in and get an access token, using the authority for my tenant.  It sounds like my access token is only valid for resources in my tenant - how do I get a token for another tenant in my code?

Thanks very much for any suggestions, be they pointers to docs, code suggestions, etc!


问:
The command 'cmake -G "Visual Studio 16 2019" -T v140,host=x64' doesn't work, how to make cmake recognize vc140?
My cmake version is 3.20.6. I have installed Visual Studio 2019 Professional edition. I need to use cmake to generate a vs solution. For the historical reason, I can't use the lateset MSVC tooset. So I installed v140 by Visual Studio installer. As you can see below.

However, when I execute the command

```<code>cmake -G "Visual Studio 16 2019" -T v140,host=x64 ..
</code>```

It turns out Cmake somehow can't find the real path of the v140 toolset.

```<code>-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19044.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:42 (project):
  No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:42 (project):
  No CMAKE_CXX_COMPILER could be found.

-- Configuring incomplete, errors occurred!
</code>```

Can someone tell me how to fix this issue?

Body:
My cmake version is 3.20.6. I have installed Visual Studio 2019 Professional edition. I need to use cmake to generate a vs solution. For the historical reason, I can't use the lateset MSVC tooset. So I installed v140 by Visual Studio installer. As you can see below.

However, when I execute the command

cmake -G "Visual Studio 16 2019" -T v140,host=x64 ..

It turns out Cmake somehow can't find the real path of the v140 toolset.

-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19044.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:42 (project):
  No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:42 (project):
  No CMAKE_CXX_COMPILER could be found.

-- Configuring incomplete, errors occurred!

Can someone tell me how to fix this issue?


问:
Remove Sub Folders & file names in URL of a GitHub Pages Site
I want to remove the endings after my domain, for example:

https://customdomain.com/src/loading-page/loading.html -> https://customcustomdomain.com/

Here is my file tree for GitHub Pages:

```<code>dist
│   CNAME
│   poster.png
│
└───assets
│   │   css/images/js files
│
└───src
│   │
│   └───loading-page
│       │   loading.html
│   └───main-page
│       │   main.html
</code>```

Is there a specific file I can incorporate in this tree to rewrite the URL on the GitHub Pages to look like the root (no folders or files following the domain? Or some setting I can change in GitHub Pages itself?

Body:
I want to remove the endings after my domain, for example:

https://customdomain.com/src/loading-page/loading.html -> https://customcustomdomain.com/

Here is my file tree for GitHub Pages:

dist
│   CNAME
│   poster.png
│
└───assets
│   │   css/images/js files
│
└───src
│   │
│   └───loading-page
│       │   loading.html
│   └───main-page
│       │   main.html

Is there a specific file I can incorporate in this tree to rewrite the URL on the GitHub Pages to look like the root (no folders or files following the domain? Or some setting I can change in GitHub Pages itself?


问:
django make query related name through anther related name
i have models

```<code>class Payee(models.Model):
    name = models.CharField(unique=True,max_length=30,default='',verbose_name="اسم المستفيد")

class expenses(models.Model):  # المصروفات

    name = models.CharField(unique=True,max_length=40,default='',verbose_name="اسم البند")

    default_value = models.IntegerField(help_text="القيمة الأفتراضية ",blank=True,null=True,verbose_name="القيمة المفروضة")  # سعر متوقع للبند

    payee_name = models.ForeignKey ( Payee, to_field='id', on_delete=models.CASCADE , blank=True, null=True, verbose_name="المستفيد", related_name='expenses_payee_name' )
    expenses_type = models.ForeignKey ( expenses_types, to_field='id', on_delete=models.CASCADE , blank=True, null=True, verbose_name="نوع المعاملة", related_name='expenses_expenses_type' )

    description = models.TextField (blank=True, null=True, max_length=300,  default='',  verbose_name="ملاحظات")

    active= models.BooleanField(default=True,)

class monthly(models.Model):  # الشهور

    month_date = models.DateField(
        help_text="إضافة شهر جديد", unique=True, verbose_name="شهر/ سنة")
    month_salary = models.IntegerField(
        blank=True, null=True, verbose_name="راتب الشهر ")
    description = models.TextField(
        blank=True, null=True, max_length=400, default='', verbose_name="ملاحظات")
    expenses = models.ManyToManyField(expenses ,related_name='monthly_expenses')
    # changeable_expenses = models.ManyToManyField(changeable_expenses)
    remaining_value = models.IntegerField(
        default="0", blank=True, null=True, verbose_name="المتبقي يتم حسابه تلقائي ")
    active= models.BooleanField(default=True,)

class month_expenses(models.Model):
    month = models.ForeignKey ( monthly, to_field='id', on_delete=models.CASCADE , blank=True, null=True, verbose_name="الشهر", related_name='month_real_value' )
    exp_name = models.ForeignKey ( expenses, to_field='id' , on_delete=models.CASCADE , blank=True, null=True, verbose_name="المعاملة", related_name='exp_real_value' )
    real_value = models.IntegerField(default=0 ,blank=True, null=True, verbose_name="القيمة الفعلية ")
    active= models.BooleanField(default=True,)

</code>```

i wont to do query like this

```<code>class monthly(models.Model):  # الشهور
......

def total_real (self , type , payee_name, active=True) :

        total_real _value = self.month_real_value.filter(expenses_type__in=type , payee_name__in=payee_name, active=active ).values_list('real_value' ,  flat=True)

        return sum (total_real _value)

</code>```

the issue for me ( payee_name , active , expenses_type ) are in expenses model not in same model(monthly)
in month_expenses model we have ForeignKey with  expenses  with related name " exp_real_value "

Body:
i have models

class Payee(models.Model):
    name = models.CharField(unique=True,max_length=30,default='',verbose_name="اسم المستفيد")

class expenses(models.Model):  # المصروفات

    name = models.CharField(unique=True,max_length=40,default='',verbose_name="اسم البند")

    default_value = models.IntegerField(help_text="القيمة الأفتراضية ",blank=True,null=True,verbose_name="القيمة المفروضة")  # سعر متوقع للبند

    payee_name = models.ForeignKey ( Payee, to_field='id', on_delete=models.CASCADE , blank=True, null=True, verbose_name="المستفيد", related_name='expenses_payee_name' )
    expenses_type = models.ForeignKey ( expenses_types, to_field='id', on_delete=models.CASCADE , blank=True, null=True, verbose_name="نوع المعاملة", related_name='expenses_expenses_type' )

    description = models.TextField (blank=True, null=True, max_length=300,  default='',  verbose_name="ملاحظات")

    active= models.BooleanField(default=True,)

class monthly(models.Model):  # الشهور

    month_date = models.DateField(
        help_text="إضافة شهر جديد", unique=True, verbose_name="شهر/ سنة")
    month_salary = models.IntegerField(
        blank=True, null=True, verbose_name="راتب الشهر ")
    description = models.TextField(
        blank=True, null=True, max_length=400, default='', verbose_name="ملاحظات")
    expenses = models.ManyToManyField(expenses ,related_name='monthly_expenses')
    # changeable_expenses = models.ManyToManyField(changeable_expenses)
    remaining_value = models.IntegerField(
        default="0", blank=True, null=True, verbose_name="المتبقي يتم حسابه تلقائي ")
    active= models.BooleanField(default=True,)

class month_expenses(models.Model):
    month = models.ForeignKey ( monthly, to_field='id', on_delete=models.CASCADE , blank=True, null=True, verbose_name="الشهر", related_name='month_real_value' )
    exp_name = models.ForeignKey ( expenses, to_field='id' , on_delete=models.CASCADE , blank=True, null=True, verbose_name="المعاملة", related_name='exp_real_value' )
    real_value = models.IntegerField(default=0 ,blank=True, null=True, verbose_name="القيمة الفعلية ")
    active= models.BooleanField(default=True,)

i wont to do query like this

class monthly(models.Model):  # الشهور
......

def total_real (self , type , payee_name, active=True) :

        total_real _value = self.month_real_value.filter(expenses_type__in=type , payee_name__in=payee_name, active=active ).values_list('real_value' ,  flat=True)

        return sum (total_real _value)

the issue for me ( payee_name , active , expenses_type ) are in expenses model not in same model(monthly)
in month_expenses model we have ForeignKey with  expenses  with related name " exp_real_value "


问:
What is the API 29 (Q) version of this line of windowManager.currentWindowMetrics.bounds.height()?
I'm trying to create a Bitmap for a paint Canvas that uses the entire screen. Currently I have the following code that kind of works:

```<code>override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    val displayMetrics = DisplayMetrics()
    windowManager.defaultDisplay.getMetrics(displayMetrics)

    val dw = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
        windowManager.currentWindowMetrics.bounds.width()
    } else {
        displayMetrics.widthPixels
    }
    val dh = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
        windowManager.currentWindowMetrics.bounds.height()
    } else {
        displayMetrics.heightPixels
    }

    bitmap = Bitmap.createBitmap(dw, dh, Bitmap.Config.ARGB_8888)
    canvas = Canvas(bitmap)
    paint = Paint()
    paint.color = Color.YELLOW
    paint.strokeWidth = 15f
    drawWireCanvas.setImageBitmap(bitmap)

}
</code>```

Think connect-the-dots, I have the following code in a MotionEvent.ACTION_MOVE listener to create a line when a point is touched and follow the touch:

```<code>    if (point1Touched == 1) {
        canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR)
        canvas.drawLine(point1.x, point1.y, motionEvent.rawX, motionEvent.rawY, paint)
        drawWireCanvas.invalidate()
    }
</code>```

Everything works perfectly for the >R API targets, but when I test on an Android 10 device (Q API) the start point of drawLine is off on the y axis by a bit. This problem replicates across all the different points. This issue also replicates if I use displayMetics.widthPixels on >= R API targets.

I'm pretty sure the issue lies in that displayMetics line of code but I can't find any sources online as to what the fix would be.

Thanks in advance!

Body:
I'm trying to create a Bitmap for a paint Canvas that uses the entire screen. Currently I have the following code that kind of works:

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    val displayMetrics = DisplayMetrics()
    windowManager.defaultDisplay.getMetrics(displayMetrics)

    val dw = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
        windowManager.currentWindowMetrics.bounds.width()
    } else {
        displayMetrics.widthPixels
    }
    val dh = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
        windowManager.currentWindowMetrics.bounds.height()
    } else {
        displayMetrics.heightPixels
    }

    bitmap = Bitmap.createBitmap(dw, dh, Bitmap.Config.ARGB_8888)
    canvas = Canvas(bitmap)
    paint = Paint()
    paint.color = Color.YELLOW
    paint.strokeWidth = 15f
    drawWireCanvas.setImageBitmap(bitmap)

}

Think connect-the-dots, I have the following code in a MotionEvent.ACTION_MOVE listener to create a line when a point is touched and follow the touch:

    if (point1Touched == 1) {
        canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR)
        canvas.drawLine(point1.x, point1.y, motionEvent.rawX, motionEvent.rawY, paint)
        drawWireCanvas.invalidate()
    }

Everything works perfectly for the >R API targets, but when I test on an Android 10 device (Q API) the start point of drawLine is off on the y axis by a bit. This problem replicates across all the different points. This issue also replicates if I use displayMetics.widthPixels on >= R API targets.

I'm pretty sure the issue lies in that displayMetics line of code but I can't find any sources online as to what the fix would be.

Thanks in advance!


问:
Communication Refused between 2 Docker Express Microservices
I am trying to deploy a full stack application with docker containers, currently I have various express microservice images, and a react nginx image that are all being proxied by nginx, when react makes a call to one of my microservices it has to make a synchronous request to another but I am getting connection refused and not sure why, i have tried to do this with both relative and absolute urls to no avail.

Here is my docker compose:

```<code>networks:
  my_network:
    driver: bridge

services:
  nginx-service:
    image: sahilhakimi/topshelf-nginx:latest
    ports:
      - 80:80
    depends_on:
      - identity-service
      - client-service
      - product-service
      - cart-service
    networks:
      - my_network
  client-service:
    image: sahilhakimi/topshelf-frontend:latest
    networks:
      - my_network
  identity-service:
    image: sahilhakimi/topshelf-identity:latest
    environment:
      TOKEN_KEY: 7e44d0deaa035296b0cb10b3ea46ac627707e51c277908b609c0739d1adafc22e7e543faf9d43028ae64cccdf506e7994a1b0075880aae61a6cdb87d087bc082759a12c398d7e3291fd54539f1b260c7a5f6c79e2c4d586a180ed42b93866583c8da85acf261939d2171ef4b18765a205ee35f8cd1b989a8473589642176f6d1
      REFRESH_TOKEN_KEY: b7fb9c5209f55dc4b50d0faef5b4a0b3bdaa81db1e813779ef6c064de0a934e0c2e027fe5e2a9ab7b6d6c06a5d7099ccd837f7698ba9b5a8bee5e1acd86823c0eb29945d4965fe0db59d95c2defb60dbebb1b034dd22132115f14a50e175bd44bc919a91b7b6731e25908fc3b8800d06e90c6b1288b42c8b2378c2a619931e33
      AWS_ACCESS_KEY_ID: AKIATQAAJCDKIHEBIK5B
      AWS_SECRET_ACCESS_KEY: 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
      MONGO_URI: mongodb://root:rootpassword@mongodb_container:27017/Users?authSource=admin
      REDIS_PASSWORD: eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81
      REDIS_HOST: cache
      REDIS_PORT: 6379
      clientUrl: http://client-service:5173
    depends_on:
      - mongodb_container
      - cache
    networks:
      - my_network
  product-service:
    image: sahilhakimi/topshelf-product:latest
    environment:
      TOKEN_KEY: 7e44d0deaa035296b0cb10b3ea46ac627707e51c277908b609c0739d1adafc22e7e543faf9d43028ae64cccdf506e7994a1b0075880aae61a6cdb87d087bc082759a12c398d7e3291fd54539f1b260c7a5f6c79e2c4d586a180ed42b93866583c8da85acf261939d2171ef4b18765a205ee35f8cd1b989a8473589642176f6d1
      REFRESH_TOKEN_KEY: b7fb9c5209f55dc4b50d0faef5b4a0b3bdaa81db1e813779ef6c064de0a934e0c2e027fe5e2a9ab7b6d6c06a5d7099ccd837f7698ba9b5a8bee5e1acd86823c0eb29945d4965fe0db59d95c2defb60dbebb1b034dd22132115f14a50e175bd44bc919a91b7b6731e25908fc3b8800d06e90c6b1288b42c8b2378c2a619931e33
      AWS_ACCESS_KEY_ID: AKIATQAAJCDKIHEBIK5B
      AWS_SECRET_ACCESS_KEY: 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
      MONGO_URI: mongodb://root:rootpassword@mongodb_container:27017/Products?authSource=admin
      KAFKA_HOST: kafka:9092
    depends_on:
      - mongodb_container
      - kafka
    networks:
      - my_network
  cart-service:
    image: sahilhakimi/topshelf-cart:latest
    environment:
      TOKEN_KEY: 7e44d0deaa035296b0cb10b3ea46ac627707e51c277908b609c0739d1adafc22e7e543faf9d43028ae64cccdf506e7994a1b0075880aae61a6cdb87d087bc082759a12c398d7e3291fd54539f1b260c7a5f6c79e2c4d586a180ed42b93866583c8da85acf261939d2171ef4b18765a205ee35f8cd1b989a8473589642176f6d1
      REFRESH_TOKEN_KEY: b7fb9c5209f55dc4b50d0faef5b4a0b3bdaa81db1e813779ef6c064de0a934e0c2e027fe5e2a9ab7b6d6c06a5d7099ccd837f7698ba9b5a8bee5e1acd86823c0eb29945d4965fe0db59d95c2defb60dbebb1b034dd22132115f14a50e175bd44bc919a91b7b6731e25908fc3b8800d06e90c6b1288b42c8b2378c2a619931e33
      REDIS_PASSWORD: eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81
      REDIS_HOST: cache
      REDIS_PORT: 6379
      KAFKA_HOST: kafka:9092
    depends_on:
      - cache
      - kafka
    networks:
      - my_network
  mongodb_container:
    image: mongo:latest
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: rootpassword
    ports:
      - 27017:27017
    volumes:
      - mongodb_data_container:/data/db
    networks:
      - my_network
  cache:
    image: redis:6.2-alpine
    restart: always
    ports:
      - "6379:6379"
    command: redis-server --save 20 1 --loglevel warning --requirepass eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81
    volumes:
      - cache:/data
    networks:
      - my_network

  zookeeper:
    image: zookeeper:latest
    networks:
      - my_network
  kafka:
    image: wurstmeister/kafka:latest
    networks:
      - my_network
    ports:
      - 29092:29092
    environment:
      KAFKA_LISTENERS: EXTERNAL_SAME_HOST://:29092,INTERNAL://:9092
      KAFKA_ADVERTISED_LISTENERS: INTERNAL://kafka:9092,EXTERNAL_SAME_HOST://localhost:29092
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT,EXTERNAL_SAME_HOST:PLAINTEXT
      KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL
      KAFKA_CREATE_TOPICS: "addToCart:1:1,invalidCartProduct:1:1"
      KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
      KAFKA_HEAP_OPTS: "-Xmx256M -Xms128M"
      KAFKA_JVM_PERFORMANCE_OPTS: " -Xmx256m -Xms256m"
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
    depends_on:
      - zookeeper

volumes:
  mongodb_data_container:
  cache:
    driver: local
</code>```

The request that is giving me trouble is in the cart service and currently looks like this:

```<code>  const response = await axios.post(
      "http://product-service:3001/api/product/checkout",
      {
        cart: JSON.parse(cart),
        token: req.body.token,
      },
      {
        headers: {
          "Content-Type": "application/json",
          Cookie: `accessToken=${cookies.accessToken}; refreshToken=${cookies.refreshToken}`,
        },
      }
    );
</code>```

and here is my nginx configuration as well,

```<code>upstream client{
    server client-service;
}
upstream identity{
    server identity-service:3000;
}
upstream product{
    server product-service:3001;
}
upstream cart{
    server cart-service:3002;
}
server {
    listen 80;

    location / {
        client_max_body_size 100M;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_pass http://client;

    }

    location /api/user/ {
        client_max_body_size 100M;
        proxy_pass http://identity;
    }
    location /api/product/{
        client_max_body_size 100M;
        proxy_pass http://product;
    }
    location /api/cart/{
        client_max_body_size 100M;
        proxy_pass http://cart;
    }

}
</code>```

The error log in my docker container is :

```<code>  cause: Error: connect ECONNREFUSED 127.0.0.1:3001
      at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16) {
    errno: -111,
    code: 'ECONNREFUSED',
    syscall: 'connect',
    address: '127.0.0.1',
    port: 3001
  }
}
</code>```

I tried the above and was expecting my request to properly be made to product service without connection refused, i know that the request is initially being proxied to cart service as wanted by nginx

Body:
I am trying to deploy a full stack application with docker containers, currently I have various express microservice images, and a react nginx image that are all being proxied by nginx, when react makes a call to one of my microservices it has to make a synchronous request to another but I am getting connection refused and not sure why, i have tried to do this with both relative and absolute urls to no avail.

Here is my docker compose:

networks:
  my_network:
    driver: bridge

services:
  nginx-service:
    image: sahilhakimi/topshelf-nginx:latest
    ports:
      - 80:80
    depends_on:
      - identity-service
      - client-service
      - product-service
      - cart-service
    networks:
      - my_network
  client-service:
    image: sahilhakimi/topshelf-frontend:latest
    networks:
      - my_network
  identity-service:
    image: sahilhakimi/topshelf-identity:latest
    environment:
      TOKEN_KEY: 7e44d0deaa035296b0cb10b3ea46ac627707e51c277908b609c0739d1adafc22e7e543faf9d43028ae64cccdf506e7994a1b0075880aae61a6cdb87d087bc082759a12c398d7e3291fd54539f1b260c7a5f6c79e2c4d586a180ed42b93866583c8da85acf261939d2171ef4b18765a205ee35f8cd1b989a8473589642176f6d1
      REFRESH_TOKEN_KEY: b7fb9c5209f55dc4b50d0faef5b4a0b3bdaa81db1e813779ef6c064de0a934e0c2e027fe5e2a9ab7b6d6c06a5d7099ccd837f7698ba9b5a8bee5e1acd86823c0eb29945d4965fe0db59d95c2defb60dbebb1b034dd22132115f14a50e175bd44bc919a91b7b6731e25908fc3b8800d06e90c6b1288b42c8b2378c2a619931e33
      AWS_ACCESS_KEY_ID: AKIATQAAJCDKIHEBIK5B
      AWS_SECRET_ACCESS_KEY: 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
      MONGO_URI: mongodb://root:rootpassword@mongodb_container:27017/Users?authSource=admin
      REDIS_PASSWORD: eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81
      REDIS_HOST: cache
      REDIS_PORT: 6379
      clientUrl: http://client-service:5173
    depends_on:
      - mongodb_container
      - cache
    networks:
      - my_network
  product-service:
    image: sahilhakimi/topshelf-product:latest
    environment:
      TOKEN_KEY: 7e44d0deaa035296b0cb10b3ea46ac627707e51c277908b609c0739d1adafc22e7e543faf9d43028ae64cccdf506e7994a1b0075880aae61a6cdb87d087bc082759a12c398d7e3291fd54539f1b260c7a5f6c79e2c4d586a180ed42b93866583c8da85acf261939d2171ef4b18765a205ee35f8cd1b989a8473589642176f6d1
      REFRESH_TOKEN_KEY: b7fb9c5209f55dc4b50d0faef5b4a0b3bdaa81db1e813779ef6c064de0a934e0c2e027fe5e2a9ab7b6d6c06a5d7099ccd837f7698ba9b5a8bee5e1acd86823c0eb29945d4965fe0db59d95c2defb60dbebb1b034dd22132115f14a50e175bd44bc919a91b7b6731e25908fc3b8800d06e90c6b1288b42c8b2378c2a619931e33
      AWS_ACCESS_KEY_ID: AKIATQAAJCDKIHEBIK5B
      AWS_SECRET_ACCESS_KEY: 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
      MONGO_URI: mongodb://root:rootpassword@mongodb_container:27017/Products?authSource=admin
      KAFKA_HOST: kafka:9092
    depends_on:
      - mongodb_container
      - kafka
    networks:
      - my_network
  cart-service:
    image: sahilhakimi/topshelf-cart:latest
    environment:
      TOKEN_KEY: 7e44d0deaa035296b0cb10b3ea46ac627707e51c277908b609c0739d1adafc22e7e543faf9d43028ae64cccdf506e7994a1b0075880aae61a6cdb87d087bc082759a12c398d7e3291fd54539f1b260c7a5f6c79e2c4d586a180ed42b93866583c8da85acf261939d2171ef4b18765a205ee35f8cd1b989a8473589642176f6d1
      REFRESH_TOKEN_KEY: b7fb9c5209f55dc4b50d0faef5b4a0b3bdaa81db1e813779ef6c064de0a934e0c2e027fe5e2a9ab7b6d6c06a5d7099ccd837f7698ba9b5a8bee5e1acd86823c0eb29945d4965fe0db59d95c2defb60dbebb1b034dd22132115f14a50e175bd44bc919a91b7b6731e25908fc3b8800d06e90c6b1288b42c8b2378c2a619931e33
      REDIS_PASSWORD: eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81
      REDIS_HOST: cache
      REDIS_PORT: 6379
      KAFKA_HOST: kafka:9092
    depends_on:
      - cache
      - kafka
    networks:
      - my_network
  mongodb_container:
    image: mongo:latest
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: rootpassword
    ports:
      - 27017:27017
    volumes:
      - mongodb_data_container:/data/db
    networks:
      - my_network
  cache:
    image: redis:6.2-alpine
    restart: always
    ports:
      - "6379:6379"
    command: redis-server --save 20 1 --loglevel warning --requirepass eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81
    volumes:
      - cache:/data
    networks:
      - my_network

  zookeeper:
    image: zookeeper:latest
    networks:
      - my_network
  kafka:
    image: wurstmeister/kafka:latest
    networks:
      - my_network
    ports:
      - 29092:29092
    environment:
      KAFKA_LISTENERS: EXTERNAL_SAME_HOST://:29092,INTERNAL://:9092
      KAFKA_ADVERTISED_LISTENERS: INTERNAL://kafka:9092,EXTERNAL_SAME_HOST://localhost:29092
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT,EXTERNAL_SAME_HOST:PLAINTEXT
      KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL
      KAFKA_CREATE_TOPICS: "addToCart:1:1,invalidCartProduct:1:1"
      KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
      KAFKA_HEAP_OPTS: "-Xmx256M -Xms128M"
      KAFKA_JVM_PERFORMANCE_OPTS: " -Xmx256m -Xms256m"
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
    depends_on:
      - zookeeper

volumes:
  mongodb_data_container:
  cache:
    driver: local

The request that is giving me trouble is in the cart service and currently looks like this:

  const response = await axios.post(
      "http://product-service:3001/api/product/checkout",
      {
        cart: JSON.parse(cart),
        token: req.body.token,
      },
      {
        headers: {
          "Content-Type": "application/json",
          Cookie: `accessToken=${cookies.accessToken}; refreshToken=${cookies.refreshToken}`,
        },
      }
    );

and here is my nginx configuration as well,

upstream client{
    server client-service;
}
upstream identity{
    server identity-service:3000;
}
upstream product{
    server product-service:3001;
}
upstream cart{
    server cart-service:3002;
}
server {
    listen 80;

    location / {
        client_max_body_size 100M;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_pass http://client;

    }

    location /api/user/ {
        client_max_body_size 100M;
        proxy_pass http://identity;
    }
    location /api/product/{
        client_max_body_size 100M;
        proxy_pass http://product;
    }
    location /api/cart/{
        client_max_body_size 100M;
        proxy_pass http://cart;
    }

}

The error log in my docker container is :

  cause: Error: connect ECONNREFUSED 127.0.0.1:3001
      at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16) {
    errno: -111,
    code: 'ECONNREFUSED',
    syscall: 'connect',
    address: '127.0.0.1',
    port: 3001
  }
}

I tried the above and was expecting my request to properly be made to product service without connection refused, i know that the request is initially being proxied to cart service as wanted by nginx


问:
How can I put assume role on itself in CDK
I have a role created by aws cdk like below code.

```<code>const role = new iam.Role(scope, name, {
    assumedBy: new iam.CompositePrincipal(
      new iam.ServicePrincipal('codebuild.amazonaws.com'),
      new iam.ServicePrincipal('codepipeline.amazonaws.com'),
    ),
  });
role.grantAssumeRole(new iam.ArnPrincipal(role.roleArn));
</code>```

I'd like it to be able to assume by itself. The use case is that the role will used by codebuild and inside the codebuild it needs to assume the role in order to pass credential to a docker container.

but after deploy, the principal of this role is:

```<code>{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "codebuild.amazonaws.com"
            },
            "Action": "sts:AssumeRole"
        },
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "codepipeline.amazonaws.com"
            },
            "Action": "sts:AssumeRole"
        }
    ]
}
</code>```

It doesn't include the roleArn in the principle. How can I make the arn appear in the principal policy?

I don't pass the role name into this code since I'd like to use auto generated role name. That's why I can't assemble the role arn.

Body:
I have a role created by aws cdk like below code.

const role = new iam.Role(scope, name, {
    assumedBy: new iam.CompositePrincipal(
      new iam.ServicePrincipal('codebuild.amazonaws.com'),
      new iam.ServicePrincipal('codepipeline.amazonaws.com'),
    ),
  });
role.grantAssumeRole(new iam.ArnPrincipal(role.roleArn));

I'd like it to be able to assume by itself. The use case is that the role will used by codebuild and inside the codebuild it needs to assume the role in order to pass credential to a docker container.

but after deploy, the principal of this role is:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "codebuild.amazonaws.com"
            },
            "Action": "sts:AssumeRole"
        },
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "codepipeline.amazonaws.com"
            },
            "Action": "sts:AssumeRole"
        }
    ]
}

It doesn't include the roleArn in the principle. How can I make the arn appear in the principal policy?

I don't pass the role name into this code since I'd like to use auto generated role name. That's why I can't assemble the role arn.