qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,384,495
<p>Say I have two arrays X=[A,B,C] and Y=[D,E,F], where each element is a 3 by 3 matrix. I would like to make an array Z=[AD,BE,CF] without using for loop. What should I do?</p> <p>I have tried using np.tensordot(X,Y,axis=1) but it returns 9 products [[AD,AE,AF],[BD,BE,BF],[CD,CE,CF]]. the troublesome thing is that the matrix size for each element must be the same as the array length, say for 3 by 3 matrix, X and Y should have 3 elements each.</p>
[ { "answer_id": 74384538, "author": "hello world", "author_id": 11209333, "author_profile": "https://Stackoverflow.com/users/11209333", "pm_score": 3, "selected": true, "text": "=SUM((INDIRECT(\"A\" & ROW() - 1)),1)\n" }, { "answer_id": 74386343, "author": "player0", "author_id": 5632629, "author_profile": "https://Stackoverflow.com/users/5632629", "pm_score": 0, "selected": false, "text": "SEQUENCE" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20465232/" ]
74,384,508
<p>Can you tell me what is the difference of creating the image in these two codes?</p> <ol> <li><code>&lt;link href=&quot;img/favicon.ico&quot; rel=&quot;icon&quot; type=&quot;image/png&quot;&gt;</code></li> </ol> <p>versus</p> <ol start="2"> <li>initiating using the simple <code>&lt;img /&gt;</code> tag</li> </ol> <p>I'm just trying to understand what is the difference</p>
[ { "answer_id": 74384538, "author": "hello world", "author_id": 11209333, "author_profile": "https://Stackoverflow.com/users/11209333", "pm_score": 3, "selected": true, "text": "=SUM((INDIRECT(\"A\" & ROW() - 1)),1)\n" }, { "answer_id": 74386343, "author": "player0", "author_id": 5632629, "author_profile": "https://Stackoverflow.com/users/5632629", "pm_score": 0, "selected": false, "text": "SEQUENCE" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20465265/" ]
74,384,566
<p>I am trying to write a query that returns list of customer names that do not start or end with letter &quot;A&quot; (either in upper case or lower case). Following is my query,</p> <pre><code>SELECT * FROM Customers WHERE CustomerName IN (SELECT * FROM Customers WHERE CustomerName NOT LIKE 'A%') AND CustomerName IN (SELECT * FROM Customers WHERE CustomerName NOT LIKE '%a') </code></pre> <p>In the query result, I am getting an &quot;Error Code: 1241. Operand should contain 1 column(s)&quot;. Columns of Customers table is</p> <pre><code>`customers` ( `CustomerID` int(11) NOT NULL, `CustomerName` varchar(255) DEFAULT NULL, `ContactName` varchar(255) DEFAULT NULL, `Address` varchar(255) DEFAULT NULL, `City` varchar(255) DEFAULT NULL, `PostalCode` varchar(255) DEFAULT NULL, `Country` varchar(255) DEFAULT NULL </code></pre> <p>Can someone please correct my query?</p>
[ { "answer_id": 74384611, "author": "Sachin Shah", "author_id": 8612835, "author_profile": "https://Stackoverflow.com/users/8612835", "pm_score": -1, "selected": false, "text": "SELECT * FROM customers WHERE CustomerName NOT LIKE 'A%' AND CustomerName NOT LIKE '%A'\n" }, { "answer_id": 74384703, "author": "Yusuf Bulut", "author_id": 20147363, "author_profile": "https://Stackoverflow.com/users/20147363", "pm_score": 0, "selected": false, "text": "SELECT CustomerName FROM Customers \nWHERE \nCustomerName NOT LIKE 'A%'\nAND \nCustomerName NOT LIKE '%a'\n" }, { "answer_id": 74384721, "author": "Teja Goud Kandula", "author_id": 9087250, "author_profile": "https://Stackoverflow.com/users/9087250", "pm_score": 2, "selected": true, "text": "select\n *\nfrom\n Customers\nwhere\n upper(CustomerName) not like 'A%'\n and upper(CustomerName) not like '%A'\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384566", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5229604/" ]
74,384,584
<p>I expected every element to go through the for loop, then the duplicate ones to be removed through the if loop.</p> <pre><code>num = [5, 7, 21, 7, 5, 7, 7, 5, 7 , 7] for i in num: if num.count(i)!=1: num.remove(i) print(num) </code></pre> <p>What I get:</p> <pre><code>[21, 7, 5, 7, 7] </code></pre> <p>What I expect:</p> <pre><code>[21, 5, 7] </code></pre>
[ { "answer_id": 74384660, "author": "Chen Brestel", "author_id": 16355119, "author_profile": "https://Stackoverflow.com/users/16355119", "pm_score": -1, "selected": false, "text": "import numpy as np\nunique_num = np.unique(num)\n" }, { "answer_id": 74384669, "author": "Shivam Nagar", "author_id": 1909506, "author_profile": "https://Stackoverflow.com/users/1909506", "pm_score": 3, "selected": true, "text": "for i in num" }, { "answer_id": 74384698, "author": "Davinder Singh", "author_id": 14867730, "author_profile": "https://Stackoverflow.com/users/14867730", "pm_score": 1, "selected": false, "text": "set" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20465298/" ]
74,384,599
<p>I want the grid columns to be equal in width whether it will be one, two, or more columns, Also the column gap must be the same. I found one of the examples but when using <code>text-right</code> for columns the column width seems not equal. Anyone helps me to achieve this? <a href="https://i.stack.imgur.com/mmA14.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mmA14.png" alt="img" /></a> In the following example, column gap spacing and width are not equal. I want to achieve using CSS or JS.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.grid-equal-columns { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; } .grid-equal-columns &gt; * { overflow: hidden; text-align: right; margin: 10px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="grid-equal-columns"&gt; &lt;div&gt;Sample&lt;/div&gt; &lt;div&gt;12122&lt;/div&gt;&lt;div&gt;hello text&lt;/div&gt; &lt;div&gt;44444&lt;/div&gt; &lt;div&gt;5555&lt;/div&gt;&lt;div&gt;6666666666666666666666666&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74384693, "author": "MrPatel2021", "author_id": 19671394, "author_profile": "https://Stackoverflow.com/users/19671394", "pm_score": -1, "selected": false, "text": "grid-column" }, { "answer_id": 74384719, "author": "Stacks Queue", "author_id": 14820590, "author_profile": "https://Stackoverflow.com/users/14820590", "pm_score": 0, "selected": false, "text": "grid-auto-columns: 1fr;\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6060849/" ]
74,384,603
<p>I need a static mechanism to verify my sender knows a static token. That token is hard coded into the sending system.</p> <p>My API has an endpoint <code>/webhook</code> where I need to have that be verified.</p> <p>This <a href="https://quarkus.io/guides/security-customization#httpauthenticationmechanism-customization" rel="nofollow noreferrer">guides/security-customization</a> gives an example on how to implement a custom mechanism, so I implemented this:</p> <pre><code>@Singleton public class FixedTokenAuthenticationMechanism implements HttpAuthenticationMechanism { @Override public Uni&lt;SecurityIdentity&gt; authenticate(RoutingContext context, IdentityProviderManager identityProviderManager) { String authHeader = context.request().headers().get(&quot;magic_header&quot;); if (authHeader == &quot;magic_value&quot;) { return Uni.createFrom().optional(Optional.empty()); } else { return Uni.createFrom().optional(Optional.empty()); } } @Override public Uni&lt;ChallengeData&gt; getChallenge(RoutingContext context) { return null; } @Override public Set&lt;Class&lt;? extends AuthenticationRequest&gt;&gt; getCredentialTypes() { return Collections.singleton(AuthenticationRequest.class); } @Override public Uni&lt;Boolean&gt; sendChallenge(RoutingContext context) { return HttpAuthenticationMechanism.super.sendChallenge(context); } @Override public HttpCredentialTransport getCredentialTransport() { return HttpAuthenticationMechanism.super.getCredentialTransport(); } @Override public Uni&lt;HttpCredentialTransport&gt; getCredentialTransport(RoutingContext context) { return HttpAuthenticationMechanism.super.getCredentialTransport(context); } @Override public int getPriority() { return HttpAuthenticationMechanism.super.getPriority(); } } </code></pre> <p>I do not know how to configure this to be used in the application properties.</p> <p>There seems to be a configuration for <a href="https://quarkus.io/guides/security#path-specific-authentication-mechanisms" rel="nofollow noreferrer">path-specific-authentication-mechanisms</a> which I can not seem to make work.</p> <p>what would I need to configure in <code>aplication.properties</code> to use my not so secure security mechanism for the <code>/webhook</code> endpoint?</p>
[ { "answer_id": 74388037, "author": "Sergey Beryozkin", "author_id": 1133928, "author_profile": "https://Stackoverflow.com/users/1133928", "pm_score": 1, "selected": false, "text": "webhook" }, { "answer_id": 74437273, "author": "Johannes", "author_id": 536874, "author_profile": "https://Stackoverflow.com/users/536874", "pm_score": 0, "selected": false, "text": "Sergey Beryozkin" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/536874/" ]
74,384,635
<pre><code>import numpy as np import pandas as pd data = { 'ID': [112,113],'empDetails':[[{'key': 'score', 'value': 2},{'key': 'Name', 'value': 'Ajay'}, {'key': 'Department', 'value': 'HR'}],[ {'key': 'salary', 'value': 7.5},{'key': 'Name', 'value': 'Balu'}]]} dataDF = pd.DataFrame(data) #trails # dataDF['newColumns'] = dataDF['empDetails'].apply(lambda x: x[0].get('key')) # dataDF = dataDF['empDetails'].apply(pd.Series) # create dataframe # dataDF = pd.DataFrame(dataDF['empDetails'], columns=dataDF['empDetails'].keys()) # create the dataframe # df = pd.concat([pd.DataFrame(v, columns=[k]) for k, v in dataDF['empDetails'].items()], axis=1) # print(dataDF['empDetails'].items()) display(dataDF) </code></pre> <p><a href="https://i.stack.imgur.com/Dr0xJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Dr0xJ.png" alt="enter image description here" /></a> I am trying to iterate through <strong>empDetails</strong> column and fetch the value of <strong>Name</strong>,<strong>salary</strong> and <strong>Department</strong> into <strong>3</strong> different column</p> <p>Using pd.series I am able to split the dictionary into different columns, but not able to rename the columns as the column order may change.</p> <p>What will be the effective way to do this.</p> <p>Expected output <a href="https://i.stack.imgur.com/Kim2u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Kim2u.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74388037, "author": "Sergey Beryozkin", "author_id": 1133928, "author_profile": "https://Stackoverflow.com/users/1133928", "pm_score": 1, "selected": false, "text": "webhook" }, { "answer_id": 74437273, "author": "Johannes", "author_id": 536874, "author_profile": "https://Stackoverflow.com/users/536874", "pm_score": 0, "selected": false, "text": "Sergey Beryozkin" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2028043/" ]
74,384,651
<pre><code>if (Weight &lt;6) { Price = 5; System.out.println(&quot;The price of cleaning will be&quot; + Price); } else if(Weight &gt; 5 &lt; 10) { Price = 8; System.out.println(&quot;The price of cleaning will be&quot; + Price); } else if(Weight &gt;=10) { Price = 12; System.out.println(&quot;The price of cleaning will be&quot; + Price); } </code></pre> <p>on the else if (weight &gt; 5 &lt; 10). I'm getting a boolean error how do I fix that part?</p> <p>I expected it to know the difference. Please, I need help on this part, this work I'm doing is due in 3 hours</p>
[ { "answer_id": 74384677, "author": "Preston", "author_id": 11548316, "author_profile": "https://Stackoverflow.com/users/11548316", "pm_score": 2, "selected": false, "text": "Weight > 5 < 10" }, { "answer_id": 74384681, "author": "Ivan Krizsan", "author_id": 11868214, "author_profile": "https://Stackoverflow.com/users/11868214", "pm_score": 1, "selected": false, "text": "if (weight > 5 && weight < 10)\n" }, { "answer_id": 74392942, "author": "Vivek M Fauzdar", "author_id": 11915666, "author_profile": "https://Stackoverflow.com/users/11915666", "pm_score": 0, "selected": false, "text": "else if(weight > 5 && weight < 10)\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20058177/" ]
74,384,690
<p>I have a array of objects in PHP like:</p> <pre><code>[ { &quot;id&quot;: 99961, &quot;candidate&quot;: { &quot;data&quot;: { &quot;id&quot;: 125275, &quot;firstName&quot;: &quot;Jose&quot;, &quot;lastName&quot;: &quot;Zayas&quot; } }, &quot;dateAdded&quot;: 1667995574207 }, { &quot;id&quot;: 99960, &quot;candidate&quot;: { &quot;data&quot;: { &quot;id&quot;: 125274, &quot;firstName&quot;: &quot;CHRISTIAN&quot;, &quot;lastName&quot;: &quot;NEILS&quot; } }, &quot;dateAdded&quot;: 1667986477133 }, { &quot;id&quot;: 99959, &quot;candidate&quot;: { &quot;data&quot;: { &quot;id&quot;: 125273, &quot;firstName&quot;: &quot;Jose&quot;, &quot;lastName&quot;: &quot;Zayas&quot; } }, &quot;dateAdded&quot;: 1667985600420 }, { &quot;id&quot;: 99958, &quot;candidate&quot;: { &quot;data&quot;: { &quot;id&quot;: 125275, &quot;firstName&quot;: &quot;Jose&quot;, &quot;lastName&quot;: &quot;Zayas&quot; } }, &quot;dateAdded&quot;: 1667985600420 }, ] </code></pre> <p>I want to find duplicates based on same <code>candidate</code> firstName and lastName but different <code>candidate</code> id's. I have tried multiple methods like array_search, array_column, array_filter etc but nothing giving desired result. Output should be array of <code>candidate.data.id</code> that are different but with same <code>firstName</code> and <code>lastName</code>. Can anyone guide me in building the algorithm?</p>
[ { "answer_id": 74384677, "author": "Preston", "author_id": 11548316, "author_profile": "https://Stackoverflow.com/users/11548316", "pm_score": 2, "selected": false, "text": "Weight > 5 < 10" }, { "answer_id": 74384681, "author": "Ivan Krizsan", "author_id": 11868214, "author_profile": "https://Stackoverflow.com/users/11868214", "pm_score": 1, "selected": false, "text": "if (weight > 5 && weight < 10)\n" }, { "answer_id": 74392942, "author": "Vivek M Fauzdar", "author_id": 11915666, "author_profile": "https://Stackoverflow.com/users/11915666", "pm_score": 0, "selected": false, "text": "else if(weight > 5 && weight < 10)\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10140572/" ]
74,384,735
<p>What happens if h/w failure happens in time travel period ?? My assumption is that if a h/w failure happens during time travel we can on own restore the database while h/w failure during the fail-safe time can be handled only by SF</p>
[ { "answer_id": 74384677, "author": "Preston", "author_id": 11548316, "author_profile": "https://Stackoverflow.com/users/11548316", "pm_score": 2, "selected": false, "text": "Weight > 5 < 10" }, { "answer_id": 74384681, "author": "Ivan Krizsan", "author_id": 11868214, "author_profile": "https://Stackoverflow.com/users/11868214", "pm_score": 1, "selected": false, "text": "if (weight > 5 && weight < 10)\n" }, { "answer_id": 74392942, "author": "Vivek M Fauzdar", "author_id": 11915666, "author_profile": "https://Stackoverflow.com/users/11915666", "pm_score": 0, "selected": false, "text": "else if(weight > 5 && weight < 10)\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4861910/" ]
74,384,736
<p>I am trying to use type converters in Android (Kotlin) so i am using the type converters class but i am getting confused like inside of the clouds i am having a single variable so i have returned it but</p> <pre><code>@Entity(tableName = &quot;WeatherDb&quot;) data class WeatherDTO( val base: String, val clouds: Clouds, val cod: Int, val coord: Coord, val dt: Int, @PrimaryKey(autoGenerate = true) val id: Int, val main: Main, val name: String, val sys: Sys, val timezone: Int, val visibility: Int, val weather: List&lt;Weather&gt;, val wind: Wind ) class TypeConverters { @TypeConverter fun fromCloudsToDouble(clouds: Clouds): Int { return clouds.all } fun fromCoordToDouble(coord: Coord): Double { } } </code></pre> <p>In coord class here are multiple with different datatypes how to covert this?</p> <pre><code>data class Main( val feels_like: Double, val grnd_level: Int, val humidity: Int, val pressure: Int, val sea_level: Int, val temp: Double, val temp_max: Double, val temp_min: Double ) </code></pre> <p>Clouds.kt</p> <pre><code>data class Clouds( val all: Int ) </code></pre> <p>Coord.kt</p> <pre><code>data class Coord( val lat: Double, val lon: Double ) </code></pre> <p>Main.kt</p> <pre><code>data class Main( val feels_like: Double, val grnd_level: Int, val humidity: Int, val pressure: Int, val sea_level: Int, val temp: Double, val temp_max: Double, val temp_min: Double ) </code></pre> <p>Sys.kt</p> <pre><code>data class Sys( val country: String, val id: Int, val sunrise: Int, val sunset: Int, val type: Int ) </code></pre> <p>Weather.kt</p> <pre><code>data class Weather( val description: String, val icon: String, val id: Int, val main: String ) </code></pre> <p>Wind.kt</p> <pre><code>data class Wind( val deg: Int, val gust: Double, val speed: Double ) </code></pre> <p>WeatherViewModel.kt</p> <pre><code>@HiltViewModel class WeatherViewModel @Inject constructor( private val repo:WeatherRepository, private val application: Application, private val WeatherDb:WeatherDB, private val fusedLocationProviderClient: FusedLocationProviderClient ) :ViewModel(){ private val _resp = MutableLiveData&lt;WeatherDTO&gt;() val weatherResp:LiveData&lt;WeatherDTO&gt; get() = _resp private val _cord = MutableLiveData&lt;Coord&gt;() val cord:LiveData&lt;Coord&gt; get() = _cord var locality:String = &quot;&quot; fun getWeather(latitude:Double,longitude:Double) = viewModelScope.launch { repo.getWeather(latitude,longitude).let { response-&gt; if(response.isSuccessful){ Log.d(&quot;response&quot;,&quot;${response.body()}&quot;) WeatherDb.WeatherDao().insertWeather(response.body()!!) _resp.postValue(response.body()) }else{ Log.d(&quot;Weather Error&quot;,&quot;getWeather Error Response: ${response.message()}&quot;) } } } fun fetchLocation():Boolean{ val task = fusedLocationProviderClient.lastLocation if(ActivityCompat.checkSelfPermission(application,android.Manifest.permission.ACCESS_FINE_LOCATION) !=PackageManager.PERMISSION_GRANTED &amp;&amp; ActivityCompat.checkSelfPermission(application,android.Manifest.permission.ACCESS_COARSE_LOCATION) !=PackageManager.PERMISSION_GRANTED ){ return true } task.addOnSuccessListener { if(it!=null){ getWeather(it.latitude,it.longitude) getAddressName(it.latitude,it.longitude) Log.d(&quot;localityname&quot;, locality) } } return true } private fun fetchLocationDetails(){ } private fun getAddressName(lat:Double,long:Double):String{ var addressName = &quot; &quot; val geoCoder = Geocoder(application, Locale.getDefault()) val address = geoCoder.getFromLocation(lat,long,1) if (address != null) { addressName = address[0].adminArea } locality = addressName Log.d(&quot;subadmin&quot;,addressName.toString()) Log.d(&quot;Address&quot;, addressName) return addressName } fun getCoordinates(cord:String){ val geocoder = Geocoder(application,Locale.getDefault()) val address = geocoder.getFromLocationName(cord,2) val result = address?.get(0) if (result != null) { getWeather(result.latitude,result.longitude) getAddressName(result.latitude,result.longitude) } } } </code></pre>
[ { "answer_id": 74385579, "author": "Joe Dow", "author_id": 17410359, "author_profile": "https://Stackoverflow.com/users/17410359", "pm_score": 2, "selected": false, "text": "class Converters {\n\n @TypeConverter\n fun valueFromDomainToStorage(value: Value): String {\n return value.convertToJson()\n }\n\n @TypeConverter\n fun valueFromStorageToDomain(str: String): Value {\n // we can not create an empty instance of value as TypeDecoder.java should call non-empty constructor\n return Value(\n \"just a stub\",\n BigInteger.valueOf(0),\n BigInteger.valueOf(0),\n false,\n BigInteger.valueOf(0)\n )\n .fromJson(str)\n }\n}\n" }, { "answer_id": 74389315, "author": "MikeT", "author_id": 4744514, "author_profile": "https://Stackoverflow.com/users/4744514", "pm_score": 1, "selected": true, "text": "implementation 'com.google.code.gson:gson:2.10'" }, { "answer_id": 74397000, "author": "MikeT", "author_id": 4744514, "author_profile": "https://Stackoverflow.com/users/4744514", "pm_score": 0, "selected": false, "text": "[" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13644300/" ]
74,384,771
<p>For building web applications in Java, I have Tomcat as the integrated server in Eclipse for development. Some of the target systems are using JBoss while others are using WebLogic 12C.</p> <p>Application related settings are kept in app.properties file and loaded at runtime. Same as given <a href="https://stackoverflow.com/questions/13478477/how-to-modify-properties-file-in-a-web-app-at-runtime">here</a> .</p> <p>Where should I keep deployment specific properties? i.e. I want to keep items such as &quot;Site Title&quot;, &quot;Company Name&quot;, &quot;Database User&quot;, blah blah which would be different for each deployment. As an example, if I deploy the same app for two customers, I should be able to change the &quot;Company Name&quot;.</p> <p>When using .properties files, I'd have to keep separate branches of the same code and recompile for each deployment.</p> <p>What is the recommended pratice/method for doing so?</p>
[ { "answer_id": 74395960, "author": "httPants", "author_id": 740888, "author_profile": "https://Stackoverflow.com/users/740888", "pm_score": 2, "selected": true, "text": "<web-app xmlns=\"http://java.sun.com/xml/ns/javaee\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee\n http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd\" version=\"3.0\">\n\n <context-param>\n <param-name>spring.config.additional-location</param-name>\n <param-value>file:./config/sparq/dms-oncall-messaging.yml</param-value>\n </context-param>\n \n\n</web-app>\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7210927/" ]
74,384,773
<p>I've created a model to generate a calendar dimension which I only want to run when I explicitly specify to run it.</p> <p>I tried to use incremental materialisation with nothing in is_incremental() block hoping dbt would do nothing if there was no query to satisfy the temporary view. Unfortunately this didn't work.</p> <p>Any suggestion or thoughts for how I might achieve this greatly appreciated.</p> <p>Regards,</p> <p>Ashley</p>
[ { "answer_id": 74395960, "author": "httPants", "author_id": 740888, "author_profile": "https://Stackoverflow.com/users/740888", "pm_score": 2, "selected": true, "text": "<web-app xmlns=\"http://java.sun.com/xml/ns/javaee\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee\n http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd\" version=\"3.0\">\n\n <context-param>\n <param-name>spring.config.additional-location</param-name>\n <param-value>file:./config/sparq/dms-oncall-messaging.yml</param-value>\n </context-param>\n \n\n</web-app>\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19891453/" ]
74,384,793
<p>I am unable to read imaginary data from text file. Here is my .txt file</p> <blockquote> <p>abc.txt</p> </blockquote> <pre><code>0.2e-3+0.3*I 0.1+0.1*I 0.3+0.1*I 0.1+0.4*I </code></pre> <p>I want to read this data into a <em>matrix</em> and print it.</p> <p>I found the solutions using <em>C++</em> <a href="https://stackoverflow.com/questions/57967046/c-read-in-complex-numbers-from-a-txt-file-and-store-into-an-array-of-complex">here</a> and <a href="https://stackoverflow.com/questions/34622309/read-complex-numbers-abi-from-text-file-in-c">here</a>. I don't know how to do the same in C.</p> <p>I am able to read decimal and integer data in .txt and print them. I am also able to print imaginary data initialized at the declaration, using <code>complex.h</code> header. This is the program I have writtern</p> <pre><code>#include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; #include&lt;complex.h&gt; #include&lt;math.h&gt; int M,N,i,j,k,l,p,q; int b[2]; int main(void) { FILE* ptr = fopen(&quot;abc.txt&quot;, &quot;r&quot;); if (ptr == NULL) { printf(&quot;no such file.&quot;); return 0; } long double d=0.2e-3+0.3*I; long double c=0.0000000600415046630252; double matrixA[2][2]; for(i=0;i&lt;2; i++) for(j=0;j&lt;2; j++) fscanf(ptr,&quot;%lf+i%lf\n&quot;, creal(&amp;matrixA[i][j]), cimag(&amp;matrixA[i][j])); //fscanf(ptr, &quot;%lf&quot;, &amp;matrixA[i][j]) for reading non-imainary data, It worked. for(i=0;i&lt;2; i++) for(j=0;j&lt;2; j++) printf(&quot;%f+i%f\n&quot;, creal(matrixA[i][j]), cimag(matrixA[i][j])); //printf(&quot;%lf\n&quot;, matrixA[i][j]); for printing non-imainary data, It worked. printf(&quot;%f+i%f\n&quot;, creal(d), cimag(d)); printf(&quot;%Lg\n&quot;,c); fclose(ptr); return 0; } </code></pre> <p>But I want to read it from the text, because I have an array of larger size, which I can't initialize at declaration, because of it's size.</p>
[ { "answer_id": 74394540, "author": "the busybee", "author_id": 11294831, "author_profile": "https://Stackoverflow.com/users/11294831", "pm_score": 3, "selected": true, "text": "complex" }, { "answer_id": 74398737, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 1, "selected": false, "text": "scanf()" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19013072/" ]
74,384,797
<p>I have a dataset that is organized like this:</p> <p><strong>What I have</strong></p> <pre><code>data &lt;- tribble(~team_one, ~team_two, ~score_one, ~score_two, &quot;Australia&quot;, &quot;New Zealand&quot;, 214, 170, &quot;Australia&quot;, &quot;New Zealand&quot;, 214, 170, &quot;New Zealand&quot;, &quot;Australia&quot;, 214, 170, &quot;New Zealand&quot;, &quot;Australia&quot;, 214, 170) </code></pre> <pre><code>team_one team_two score_one score_two Australia New Zealand 214 170 Australia New Zealand 214 170 New Zealand Australia 214 170 New Zealand Australia 214 170 </code></pre> <p>I'd like to convert that to this:</p> <p><strong>Desired Output</strong></p> <pre><code>team score Australia 214 Australia 214 New Zealand 170 New Zealand 170 </code></pre> <p>I'm quite stuck on figuring out how to use what I have to get the desired output. Should I use <code>pivot_longer</code>? When I tried it, I get this, which isn't right:</p> <p><strong>What I tried</strong></p> <pre><code>data |&gt; pivot_longer(cols = c(&quot;score_one&quot;, &quot;score_two&quot;), names_to = &quot;name&quot;, values_to = &quot;value&quot;) </code></pre> <pre><code>team_one team_two name value Australia New Zealand score_one 214 Australia New Zealand score_two 170 Australia New Zealand score_one 214 Australia New Zealand score_two 170 New Zealand Australia score_one 214 New Zealand Australia score_two 170 New Zealand Australia score_one 214 New Zealand Australia score_two 170 </code></pre>
[ { "answer_id": 74385003, "author": "edvinsyk", "author_id": 16252296, "author_profile": "https://Stackoverflow.com/users/16252296", "pm_score": -1, "selected": false, "text": "data |> \n pivot_longer(cols = c(\"score_one\", \"score_two\"), names_to = \"name\", values_to = \"value\") |> \n pivot_longer(cols = c(\"team_one\", \"team_two\"), names_to = \"t\", values_to = \"team\") |> \n select(team, score = value)\n\n team score\n <chr> <dbl>\n 1 Australia 214\n 2 New Zealand 214\n 3 Australia 170\n 4 New Zealand 170\n 5 Australia 214\n 6 New Zealand 214\n 7 Australia 170\n 8 New Zealand 170\n 9 New Zealand 214\n10 Australia 214\n11 New Zealand 170\n12 Australia 170\n13 New Zealand 214\n14 Australia 214\n15 New Zealand 170\n16 Australia 170\n\n\n" }, { "answer_id": 74385351, "author": "Ssong", "author_id": 5567893, "author_profile": "https://Stackoverflow.com/users/5567893", "pm_score": 2, "selected": true, "text": "# I think that the values in your data have same meaning (team A:team B = team B:team A)\n# So I extracted the first two rows\n> data_c<-data[1:2,]\n\n#Change the data format\n> data_p<-pivot_longer(data_c, cols=everything(),\n names_to='.value',\n names_pattern='([A-Za-z]+)\\\\d?')\n\n#Sort the team column in ascending order as you required\n> arrange(data_p, team)\n\n# A tibble: 4 x 2\n# team score\n# <chr> <dbl>\n#1 Australia 214\n#2 Australia 214\n#3 New Zealand 170\n#4 New Zealand 170\n" }, { "answer_id": 74385711, "author": "MarBlo", "author_id": 4282026, "author_profile": "https://Stackoverflow.com/users/4282026", "pm_score": -1, "selected": false, "text": "library(tidyverse)\n\ndata %>% \n # one id per game\n rowid_to_column('id') %>%\n group_by(id) %>% \n pivot_longer(-c(id, score_one, score_two), names_to='Team', values_to='team') %>% \n # get the score from either the first or second team\n mutate(score = ifelse(str_detect(Team,'_one'), score_one, score_two)) %>% \n select(team, score)\n#> Adding missing grouping variables: `id`\n#> # A tibble: 8 × 3\n#> # Groups: id [4]\n#> id team score\n#> <int> <chr> <dbl>\n#> 1 1 Australia 214\n#> 2 1 New Zealand 170\n#> 3 2 Australia 214\n#> 4 2 New Zealand 170\n#> 5 3 New Zealand 214\n#> 6 3 Australia 170\n#> 7 4 New Zealand 214\n#> 8 4 Australia 170\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13874036/" ]
74,384,817
<pre class="lang-py prettyprint-override"><code>trainer = PyTorch( entry_point=&quot;train.py&quot;, source_dir= &quot;source_dir&quot;, # directory of your training script role=role, framework_version=&quot;1.5.0&quot;, py_version=&quot;py3&quot;, instance_type= &quot;local&quot;, instance_count=1, output_path=output_path, hyperparameters = hyperparameters ) </code></pre> <p>This code is running SageMaker NoteNook instance.</p> <p>Error</p> <pre><code>Creating dsd3faq5lq-algo-1-ouews ... Creating dsd3faq5lq-algo-1-ouews ... done Attaching to dsd3faq5lq-algo-1-ouews dsd3faq5lq-algo-1-ouews | 2022-11-10 05:39:26,444 sagemaker-training-toolkit INFO Imported framework sagemaker_pytorch_container.training dsd3faq5lq-algo-1-ouews | 2022-11-10 05:39:26,475 sagemaker-training-toolkit INFO No GPUs detected (normal if no gpus installed) dsd3faq5lq-algo-1-ouews | 2022-11-10 05:39:26,494 sagemaker_pytorch_container.training INFO Block until all host DNS lookups succeed. dsd3faq5lq-algo-1-ouews | 2022-11-10 05:39:26,507 sagemaker_pytorch_container.training INFO Invoking user training script. dsd3faq5lq-algo-1-ouews | 2022-11-10 05:39:26,673 sagemaker-training-toolkit ERROR Reporting training FAILURE dsd3faq5lq-algo-1-ouews | 2022-11-10 05:39:26,674 sagemaker-training-toolkit ERROR framework error: dsd3faq5lq-algo-1-ouews | Traceback (most recent call last): dsd3faq5lq-algo-1-ouews | File &quot;/opt/conda/lib/python3.6/site-packages/sagemaker_training/trainer.py&quot;, line 85, in train dsd3faq5lq-algo-1-ouews | entrypoint() dsd3faq5lq-algo-1-ouews | File &quot;/opt/conda/lib/python3.6/site-packages/sagemaker_pytorch_container/training.py&quot;, line 121, in main dsd3faq5lq-algo-1-ouews | train(environment.Environment()) dsd3faq5lq-algo-1-ouews | File &quot;/opt/conda/lib/python3.6/site-packages/sagemaker_pytorch_container/training.py&quot;, line 73, in train dsd3faq5lq-algo-1-ouews | runner_type=runner_type) dsd3faq5lq-algo-1-ouews | File &quot;/opt/conda/lib/python3.6/site-packages/sagemaker_training/entry_point.py&quot;, line 92, in run dsd3faq5lq-algo-1-ouews | files.download_and_extract(uri=uri, path=environment.code_dir) dsd3faq5lq-algo-1-ouews | File &quot;/opt/conda/lib/python3.6/site-packages/sagemaker_training/files.py&quot;, line 131, in download_and_extract dsd3faq5lq-algo-1-ouews | s3_download(uri, dst) dsd3faq5lq-algo-1-ouews | File &quot;/opt/conda/lib/python3.6/site-packages/sagemaker_training/files.py&quot;, line 167, in s3_download dsd3faq5lq-algo-1-ouews | s3.Bucket(bucket).download_file(key, dst) dsd3faq5lq-algo-1-ouews | File &quot;/opt/conda/lib/python3.6/site-packages/boto3/s3/inject.py&quot;, line 246, in bucket_download_file dsd3faq5lq-algo-1-ouews | ExtraArgs=ExtraArgs, Callback=Callback, Config=Config) dsd3faq5lq-algo-1-ouews | File &quot;/opt/conda/lib/python3.6/site-packages/boto3/s3/inject.py&quot;, line 172, in download_file dsd3faq5lq-algo-1-ouews | extra_args=ExtraArgs, callback=Callback) dsd3faq5lq-algo-1-ouews | File &quot;/opt/conda/lib/python3.6/site-packages/boto3/s3/transfer.py&quot;, line 307, in download_file dsd3faq5lq-algo-1-ouews | future.result() dsd3faq5lq-algo-1-ouews | File &quot;/opt/conda/lib/python3.6/site-packages/s3transfer/futures.py&quot;, line 106, in result dsd3faq5lq-algo-1-ouews | return self._coordinator.result() dsd3faq5lq-algo-1-ouews | File &quot;/opt/conda/lib/python3.6/site-packages/s3transfer/futures.py&quot;, line 265, in result dsd3faq5lq-algo-1-ouews | raise self._exception dsd3faq5lq-algo-1-ouews | File &quot;/opt/conda/lib/python3.6/site-packages/s3transfer/tasks.py&quot;, line 255, in _main dsd3faq5lq-algo-1-ouews | self._submit(transfer_future=transfer_future, **kwargs) dsd3faq5lq-algo-1-ouews | File &quot;/opt/conda/lib/python3.6/site-packages/s3transfer/download.py&quot;, line 343, in _submit dsd3faq5lq-algo-1-ouews | **transfer_future.meta.call_args.extra_args dsd3faq5lq-algo-1-ouews | File &quot;/opt/conda/lib/python3.6/site-packages/botocore/client.py&quot;, line 357, in _api_call dsd3faq5lq-algo-1-ouews | return self._make_api_call(operation_name, kwargs) dsd3faq5lq-algo-1-ouews | File &quot;/opt/conda/lib/python3.6/site-packages/botocore/client.py&quot;, line 676, in _make_api_call dsd3faq5lq-algo-1-ouews | raise error_class(parsed_response, operation_name) dsd3faq5lq-algo-1-ouews | botocore.exceptions.ClientError: An error occurred (403) when calling the HeadObject operation: Forbidden dsd3faq5lq-algo-1-ouews | dsd3faq5lq-algo-1-ouews | An error occurred (403) when calling the HeadObject operation: Forbidden dsd3faq5lq-algo-1-ouews exited with code 1 1 Aborting on container exit... </code></pre> <p>The same code worked a couple of days back but it is not working from yesterday onwards.</p> <pre><code>Sagemaker Version: 2.115.0 </code></pre> <p>I tried changing the SageMaker version to 2.0 but to no avail.</p> <p>I also uploaded training code on s3 and use s3_uri in &quot;source_dir&quot; but still got the same error.</p> <p>The problem only occurs while using <code>instance_type = &quot;local&quot;</code> It works perfectly fine if I use a remote instance such as <code>instance_type = &quot;ml.c4.xlarge&quot;</code></p> <p>I also tried uploading and downloading objects directly from S3 using boto3 and it worked perfectly fine. eg;</p> <pre class="lang-py prettyprint-override"><code>session = boto3.Session() s3 = session.resource('s3') s3_obj = s3.Object(bucket, data_key) s3_obj.put(Body=data) </code></pre> <pre class="lang-py prettyprint-override"><code>s3client = boto3.client('s3') response = s3client.get_object(Bucket= bucket, Key= data_key) body = response['Body'].read() </code></pre> <p>The above code works perfectly fine in same instance. I am not sure but if it was just an issue with permission, wouldn't the above code also not work.</p>
[ { "answer_id": 74385003, "author": "edvinsyk", "author_id": 16252296, "author_profile": "https://Stackoverflow.com/users/16252296", "pm_score": -1, "selected": false, "text": "data |> \n pivot_longer(cols = c(\"score_one\", \"score_two\"), names_to = \"name\", values_to = \"value\") |> \n pivot_longer(cols = c(\"team_one\", \"team_two\"), names_to = \"t\", values_to = \"team\") |> \n select(team, score = value)\n\n team score\n <chr> <dbl>\n 1 Australia 214\n 2 New Zealand 214\n 3 Australia 170\n 4 New Zealand 170\n 5 Australia 214\n 6 New Zealand 214\n 7 Australia 170\n 8 New Zealand 170\n 9 New Zealand 214\n10 Australia 214\n11 New Zealand 170\n12 Australia 170\n13 New Zealand 214\n14 Australia 214\n15 New Zealand 170\n16 Australia 170\n\n\n" }, { "answer_id": 74385351, "author": "Ssong", "author_id": 5567893, "author_profile": "https://Stackoverflow.com/users/5567893", "pm_score": 2, "selected": true, "text": "# I think that the values in your data have same meaning (team A:team B = team B:team A)\n# So I extracted the first two rows\n> data_c<-data[1:2,]\n\n#Change the data format\n> data_p<-pivot_longer(data_c, cols=everything(),\n names_to='.value',\n names_pattern='([A-Za-z]+)\\\\d?')\n\n#Sort the team column in ascending order as you required\n> arrange(data_p, team)\n\n# A tibble: 4 x 2\n# team score\n# <chr> <dbl>\n#1 Australia 214\n#2 Australia 214\n#3 New Zealand 170\n#4 New Zealand 170\n" }, { "answer_id": 74385711, "author": "MarBlo", "author_id": 4282026, "author_profile": "https://Stackoverflow.com/users/4282026", "pm_score": -1, "selected": false, "text": "library(tidyverse)\n\ndata %>% \n # one id per game\n rowid_to_column('id') %>%\n group_by(id) %>% \n pivot_longer(-c(id, score_one, score_two), names_to='Team', values_to='team') %>% \n # get the score from either the first or second team\n mutate(score = ifelse(str_detect(Team,'_one'), score_one, score_two)) %>% \n select(team, score)\n#> Adding missing grouping variables: `id`\n#> # A tibble: 8 × 3\n#> # Groups: id [4]\n#> id team score\n#> <int> <chr> <dbl>\n#> 1 1 Australia 214\n#> 2 1 New Zealand 170\n#> 3 2 Australia 214\n#> 4 2 New Zealand 170\n#> 5 3 New Zealand 214\n#> 6 3 Australia 170\n#> 7 4 New Zealand 214\n#> 8 4 Australia 170\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19655788/" ]
74,384,848
<p>I'm trying to show CircularProgress center of my webview inside stack but its showing bottom. I used expanded widget to use available space for webview.</p> <p>My code :</p> <pre><code>Widget build(BuildContext context) { return SafeArea( child: Scaffold( body: WillPopScope( onWillPop: () async { print(&quot;back pressed&quot;); return false; }, child: Column( children: [ webProgress &lt; 1 ? SizedBox( height: 5, child: LinearProgressIndicator( value: webProgress, color: Colors.blue, backgroundColor: Colors.white, ), ) : SizedBox(), Expanded( child: WebviewScaffold( url: &quot;https://google.com&quot;, mediaPlaybackRequiresUserGesture: false, withLocalStorage: true, ), ), isLoading ? Center( child: CircularProgressIndicator(), ) : Stack(), ], ), ), ), ); } } </code></pre>
[ { "answer_id": 74385003, "author": "edvinsyk", "author_id": 16252296, "author_profile": "https://Stackoverflow.com/users/16252296", "pm_score": -1, "selected": false, "text": "data |> \n pivot_longer(cols = c(\"score_one\", \"score_two\"), names_to = \"name\", values_to = \"value\") |> \n pivot_longer(cols = c(\"team_one\", \"team_two\"), names_to = \"t\", values_to = \"team\") |> \n select(team, score = value)\n\n team score\n <chr> <dbl>\n 1 Australia 214\n 2 New Zealand 214\n 3 Australia 170\n 4 New Zealand 170\n 5 Australia 214\n 6 New Zealand 214\n 7 Australia 170\n 8 New Zealand 170\n 9 New Zealand 214\n10 Australia 214\n11 New Zealand 170\n12 Australia 170\n13 New Zealand 214\n14 Australia 214\n15 New Zealand 170\n16 Australia 170\n\n\n" }, { "answer_id": 74385351, "author": "Ssong", "author_id": 5567893, "author_profile": "https://Stackoverflow.com/users/5567893", "pm_score": 2, "selected": true, "text": "# I think that the values in your data have same meaning (team A:team B = team B:team A)\n# So I extracted the first two rows\n> data_c<-data[1:2,]\n\n#Change the data format\n> data_p<-pivot_longer(data_c, cols=everything(),\n names_to='.value',\n names_pattern='([A-Za-z]+)\\\\d?')\n\n#Sort the team column in ascending order as you required\n> arrange(data_p, team)\n\n# A tibble: 4 x 2\n# team score\n# <chr> <dbl>\n#1 Australia 214\n#2 Australia 214\n#3 New Zealand 170\n#4 New Zealand 170\n" }, { "answer_id": 74385711, "author": "MarBlo", "author_id": 4282026, "author_profile": "https://Stackoverflow.com/users/4282026", "pm_score": -1, "selected": false, "text": "library(tidyverse)\n\ndata %>% \n # one id per game\n rowid_to_column('id') %>%\n group_by(id) %>% \n pivot_longer(-c(id, score_one, score_two), names_to='Team', values_to='team') %>% \n # get the score from either the first or second team\n mutate(score = ifelse(str_detect(Team,'_one'), score_one, score_two)) %>% \n select(team, score)\n#> Adding missing grouping variables: `id`\n#> # A tibble: 8 × 3\n#> # Groups: id [4]\n#> id team score\n#> <int> <chr> <dbl>\n#> 1 1 Australia 214\n#> 2 1 New Zealand 170\n#> 3 2 Australia 214\n#> 4 2 New Zealand 170\n#> 5 3 New Zealand 214\n#> 6 3 Australia 170\n#> 7 4 New Zealand 214\n#> 8 4 Australia 170\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20449361/" ]
74,384,885
<p>I need to get Thailand timezone in this format: <code>Thu Nov 10 2022 14:08:37 GMT+0800 (Malaysia Time)</code>. I have tried <code>new Date().toLocaleString(&quot;en-US&quot;, {timeZone: &quot;Asia/Bangkok&quot;})</code> but didn't get the correct format I want, probably because of the <code>.toLocaleString()</code>. Is there a simple way to do it?</p>
[ { "answer_id": 74385582, "author": "deceze", "author_id": 476, "author_profile": "https://Stackoverflow.com/users/476", "pm_score": 0, "selected": false, "text": "console.log(new Date().toLocaleString('en-US', {\n timeZone: 'Asia/Bangkok',\n weekday: 'short',\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n timeZoneName: 'short',\n hour12: false\n}));" }, { "answer_id": 74390047, "author": "RobG", "author_id": 257182, "author_profile": "https://Stackoverflow.com/users/257182", "pm_score": 2, "selected": true, "text": "// Return timestamp in same format as Date.prototype.toString\n// in designated timezone (IANA representative location)\nfunction toTimezone(tz, date = new Date()) {\n // Get parts except timezone name\n let opts = {\n year: 'numeric',\n month: 'short',\n day: '2-digit',\n weekday: 'short',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n timeZone: tz,\n timeZoneName: 'shortOffset',\n hour12: false\n }\n // To get full timezone name\n let opts2 = {\n hour: 'numeric',\n timeZone: tz,\n timeZoneName: 'long'\n }\n let toParts = opts => new Intl.DateTimeFormat('en', opts)\n .formatToParts(date)\n .reduce((acc, part) => {\n acc[part.type] = part.value;\n return acc;\n }, Object.create(null));\n \n let {year, month, day, weekday, hour, minute,\n second, timeZoneName} = toParts(opts);\n // Fix offset\n let sign = /\\+/.test(timeZoneName)? '+' : '-';\n let [oH, oM] = timeZoneName.substr(4).split(':');\n let offset = `GMT${sign}${oH.padStart(2, '0')}${oM || '00'}`;\n // Get timezone name\n timeZoneName = toParts(opts2).timeZoneName;\n\nreturn `${weekday} ${month} ${day} ${year} ${hour}:${minute}:${second} ${offset} (${timeZoneName})`;\n}\n\n// Examples\n['Australia/Adelaide',\n 'Asia/Bangkok',\n 'Asia/Kolkata',\n 'America/New_York',\n 'Pacific/Yap',\n 'Pacific/Pago_Pago'\n].forEach(tz => console.log(toTimezone(tz)));" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18036356/" ]
74,384,949
<p>I have an index used for bulk operations on collections that is experiencing throttling. To mitigate this am planning to shard the index so each pk is split over whatever number of partitions. At the moment there is a delete operation running on the base table using the index, so what happens is we query a set number of items against a pk in the index, delete them, then repeat until finished.</p> <p>The problem I see here is that if I do something similar with the sharded partition keys now I will just end up iterating through each partition and get the same issue with throttling on the base table when deleting. I was wondering if there is a way to issue a bulk query in dynamo so I can for example checks all shards and retrieve a set with an even distribution of items across them?</p>
[ { "answer_id": 74388569, "author": "Lee Hannigan", "author_id": 7909676, "author_profile": "https://Stackoverflow.com/users/7909676", "pm_score": 1, "selected": false, "text": "SELECT * FROM \"mytable\".\"index\" WHERE GSIPK IN [\"a-1\",\"a-2\",\"a-3\",\"a-4\"]" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11090037/" ]
74,384,975
<p>I have 3 Views, let say view1, view2 and view3.</p> <p>view1 is home screen.</p> <p>Now, I am presenting view2 with naviagationView.</p> <p>Now, on some event, I have pushed view 3 from view2.</p> <p>So in short, scene is <code>view1(home) -&gt; presented NavigationView(view2) -&gt; pushed view3</code></p> <p>Now, from view3, I want to dismiss navigation view and wanted to come back to view1(home).</p> <p>If I am taking <code>presentationMode</code> environment variable and make call as <code>presentationMode.wrappedValue.dismiss</code>, then it is popping up to view2, but I wanted to dismiss the whole navigationview.</p> <p>Here, I have just pushed one view. But there are chances that I might have pushed 7-8 views and wanted to dismiss the full navigation view from there.</p> <p>Is there any way to do this in swiftUI?</p>
[ { "answer_id": 74385273, "author": "Felix Uff", "author_id": 9375065, "author_profile": "https://Stackoverflow.com/users/9375065", "pm_score": 1, "selected": false, "text": "struct ContentView: View {\n var body: some View {\n NavigationView {\n NavigationLink(\"Go to second view\") {\n NavigationLink(\"Go to third view\") {\n NavigationLink(\"Go to forth view\"){\n Text(\"The end\")\n }.navigationTitle(\"Third View\").navigationBarTitleDisplayMode(.inline)\n }.navigationTitle(\"Second View\").navigationBarTitleDisplayMode(.inline)\n }.navigationTitle(\"Home View\").navigationBarTitleDisplayMode(.inline)\n }\n }\n}\n" }, { "answer_id": 74385503, "author": "Quang Hà", "author_id": 1615838, "author_profile": "https://Stackoverflow.com/users/1615838", "pm_score": 0, "selected": false, "text": "struct ContentView: View {\n @State var id = UUID()\n \n var body: some View {\n NavigationView {\n NavigationLink {\n NavigationLink {\n VStack {\n Text(\"Third\")\n Button {\n id = UUID()\n } label: {\n Text(\"Clear Stack\")\n }\n }.navigationTitle(\"Third\")\n } label: {\n Text(\"Go Third\")\n }.navigationTitle(\"Second\")\n } label: {\n Text(\"Go Second\")\n }.navigationTitle(\"First\")\n }.id(id)\n }\n}\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2160144/" ]
74,384,991
<p>I have two table with relation, defined in model and migration but when I delete the parent data the child do not delete automatically</p> <p><strong>User model</strong></p> <pre><code>class User extends Authenticatable implements MustVerifyEmail { use Notifiable; use Friendable; use HasApiTokens; public function userstatus() { return $this-&gt;hasOne(UserStatus::class); } } </code></pre> <p><strong>UserStatus model</strong></p> <pre><code>class UserStatus extends Model { public function user() { return $this-&gt;belongsToOne(User::class); } } </code></pre> <p><strong>User migration</strong>:</p> <pre><code>class CreateUsersTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('users', function (Blueprint $table) { $table-&gt;increments('id'); $table-&gt;string('first'); $table-&gt;string('last'); $table-&gt;string('description')-&gt;nullable(); $table-&gt;string('phone'); $table-&gt;string('question'); $table-&gt;string('answer'); $table-&gt;string('email')-&gt;unique(); $table-&gt;string('country'); $table-&gt;string('city'); $table-&gt;timestamp('email_verified_at')-&gt;nullable(); $table-&gt;timestamp('verified')-&gt;nullable(); $table-&gt;string('password'); $table-&gt;rememberToken(); $table-&gt;timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('users'); } } </code></pre> <p><strong>UserStatus migration</strong>:</p> <pre><code>class CreateUserStatusesTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('user_statuses', function (Blueprint $table) { $table-&gt;increments('id'); $table-&gt;foreignId('user_id')-&gt;constrained('users')-&gt;onDelete('cascade')-&gt;onUpdate('cascade'); $table-&gt;string('status')-&gt;default('InActive'); $table-&gt;timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('userstatuses'); } } </code></pre> <p>and I also tried using old ways on migration not working. There are a lot of relations in user and I can't delete them one by one each time so it needs to delete automatically.</p>
[ { "answer_id": 74385031, "author": "Semih SAHIN", "author_id": 10542740, "author_profile": "https://Stackoverflow.com/users/10542740", "pm_score": 2, "selected": true, "text": "$table->engine = 'InnoDB';\n" }, { "answer_id": 74388266, "author": "Shreya Desai", "author_id": 11439701, "author_profile": "https://Stackoverflow.com/users/11439701", "pm_score": 0, "selected": false, "text": "class CreateUserStatusesTable extends Migration\n{\n /**\n * Run the migrations.\n *\n * @return void\n */\n public function up()\n {\n Schema::create('user_statuses', function (Blueprint $table) {\n $table->increments('id');\n $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');\n $table->string('status')->default('InActive');\n $table->timestamps();\n });\n }\n\n /**\n * Reverse the migrations.\n *\n * @return void\n */\n public function down()\n {\n Schema::dropIfExists('userstatuses');\n }\n}\n" }, { "answer_id": 74388465, "author": "Engr Talha", "author_id": 12135529, "author_profile": "https://Stackoverflow.com/users/12135529", "pm_score": 0, "selected": false, "text": "public function up()\n {\n Schema::create('user_statuses', function (Blueprint $table) {\n $table->increments('id');\n $table->engine = \"InnoDB\";\n $table->interger('user_id')->unsigned(); \n $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');\n\n $table->string('status')->default('InActive');\n\n $table->timestamps();\n });\n }\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74384991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14081636/" ]
74,385,021
<p><a href="https://i.stack.imgur.com/MKRbS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MKRbS.png" alt="enter image description here" /></a></p> <p>how to query get day from this date on sql? September 29, 2000 is Saturday I just want to take the day</p> <p>i use query <code>SELECT DATENAME(WEEKDAY, '2022-09-24')</code></p> <p>result success : |Saturday|</p> <p>but if i use query <code>SELECT DATENAME(WEEKDAY, TGL_AKAD_MUR) from TABLE where FID_APLIKASI = 811213</code> this query error</p> <p>how to solved my problem ?</p>
[ { "answer_id": 74387582, "author": "RF1991", "author_id": 14799981, "author_profile": "https://Stackoverflow.com/users/14799981", "pm_score": 0, "selected": false, "text": "DECLARE @TGLAKADMUR NVARCHAR(100)= N'24092022'\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17962447/" ]
74,385,034
<p><a href="https://i.stack.imgur.com/Zymse.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Zymse.jpg" alt="enter image description here" /></a></p> <p>I want to open demo app using appium (in ios simulator using X code)</p>
[ { "answer_id": 74385109, "author": "vignesh", "author_id": 1350682, "author_profile": "https://Stackoverflow.com/users/1350682", "pm_score": 2, "selected": false, "text": ".swift" }, { "answer_id": 74388479, "author": "Montek", "author_id": 17737469, "author_profile": "https://Stackoverflow.com/users/17737469", "pm_score": 2, "selected": true, "text": ".swift" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20279204/" ]
74,385,051
<pre><code>for i in range(5): print(i,end=',') </code></pre> <p>O/P : 0,1,2,3,4,</p> <p>#I want to remove the comma after printing 4</p>
[ { "answer_id": 74385109, "author": "vignesh", "author_id": 1350682, "author_profile": "https://Stackoverflow.com/users/1350682", "pm_score": 2, "selected": false, "text": ".swift" }, { "answer_id": 74388479, "author": "Montek", "author_id": 17737469, "author_profile": "https://Stackoverflow.com/users/17737469", "pm_score": 2, "selected": true, "text": ".swift" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11364786/" ]
74,385,104
<p>I am sharing an image of button can some one help with the html css to achieve exact design. <a href="https://i.stack.imgur.com/nJhaL.jpg" rel="nofollow noreferrer">Normal state of radio button</a></p> <p><a href="https://i.stack.imgur.com/UfroS.jpg" rel="nofollow noreferrer">On hover style or Checked state</a></p>
[ { "answer_id": 74385109, "author": "vignesh", "author_id": 1350682, "author_profile": "https://Stackoverflow.com/users/1350682", "pm_score": 2, "selected": false, "text": ".swift" }, { "answer_id": 74388479, "author": "Montek", "author_id": 17737469, "author_profile": "https://Stackoverflow.com/users/17737469", "pm_score": 2, "selected": true, "text": ".swift" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19783908/" ]
74,385,136
<p>There is a global listener on specific input type:</p> <pre><code>$('input[type[&quot;radio&quot;]').on('change', function() { ... }); </code></pre> <p>But I have another more specific <code>radio</code> input with its own <code>unique_radio</code> class:</p> <pre><code>&lt;input type=&quot;radio&quot; class=&quot;unique_radio&quot; name=&quot;unique_radio&quot;&gt; </code></pre> <p>It also has its own click listener:</p> <pre><code>$('.unique_radio').on('click', function() { ... }); </code></pre> <p>When I click it, both listeners trigger the functions, but I need only the function with the unique_radio listener to be triggered.</p> <p>I have tried using <code>stopImmediatePropagation</code> and <code>off</code> as seen here:</p> <p><a href="https://stackoverflow.com/questions/209029/best-way-to-remove-an-event-handler-in-jquery">Best way to remove an event handler in jQuery?</a></p> <p>But that did not seem to work</p>
[ { "answer_id": 74387112, "author": "Cemil AKAN", "author_id": 13189540, "author_profile": "https://Stackoverflow.com/users/13189540", "pm_score": 1, "selected": false, "text": "$('input[type=\"radio\"]:not(.unique_radio)').on('change', function(){\n console.log(1);\n});\n$('.unique_radio').on('change', function() {\n console.log(2);\n});\n" }, { "answer_id": 74387350, "author": "Yves Kipondo", "author_id": 6108283, "author_profile": "https://Stackoverflow.com/users/6108283", "pm_score": 0, "selected": false, "text": "$('input[type=\"radio\"]').on('change', function() { \n console.log($(this).data('id'));\n});" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18178584/" ]
74,385,150
<p>I'm trying to receive response <code>order_token</code> from test API <code>https://sandbox.cashfree.com/pg/orders</code> which is used to create session of a payment gateway. Here is the code.</p> <pre><code> CFEnvironment environment = CFEnvironment.SANDBOX; Future&lt;dynamic&gt; createOrder() async { var response = await http.post( Uri.https('https://sandbox.cashfree.com/pg/orders'), headers: { 'Content-Type': 'application/json', 'x-client-id': 'your x-client-id', 'x-client-secret': 'your x-client-secret', 'x-api-version': '2022-01-01', 'x-request-id': 'developer_name', }, body: jsonEncode( { &quot;order_id&quot;: widget.cartId, &quot;order_amount&quot;: widget.grandTotal, &quot;order_currency&quot;: &quot;INR&quot;, &quot;order_note&quot;: &quot;Additional order info&quot;, &quot;customer_details&quot;: { &quot;customer_id&quot;: widget.address.id, &quot;customer_name&quot;: &quot;name&quot;, &quot;customer_email&quot;: widget.email, &quot;customer_phone&quot;: widget.address.phone, } }, ), ); if (response.statusCode == 200) { if (jsonDecode(response.body)['status'] == 'OK') { debugPrint(jsonDecode(response.body)['order_id']); debugPrint('log'); Logger.i(response.body); return jsonDecode(response.body)['order_id']; } } return ''; } createSession() { createOrder().then((value) { try { var session = CFSessionBuilder() .setEnvironment(environment) .setOrderId(widget.cartId!) .setOrderToken(value) .build(); return session; } on CFException catch (e) { debugPrint(e.message); } }); return null; } </code></pre> <p>But the response seems to null and payment gateway doesn't open. What might be going wrong with my code? I tried printing response but there in null value there,What might be going wrong? How do I get a response? I've done this in postman I get a response.</p>
[ { "answer_id": 74387112, "author": "Cemil AKAN", "author_id": 13189540, "author_profile": "https://Stackoverflow.com/users/13189540", "pm_score": 1, "selected": false, "text": "$('input[type=\"radio\"]:not(.unique_radio)').on('change', function(){\n console.log(1);\n});\n$('.unique_radio').on('change', function() {\n console.log(2);\n});\n" }, { "answer_id": 74387350, "author": "Yves Kipondo", "author_id": 6108283, "author_profile": "https://Stackoverflow.com/users/6108283", "pm_score": 0, "selected": false, "text": "$('input[type=\"radio\"]').on('change', function() { \n console.log($(this).data('id'));\n});" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12936850/" ]
74,385,153
<p>I'm struggling with getting the correct implementation of finding the nth number in the Fibonacci sequence. More accurately, how to optimize it with DP.</p> <p>I was able to correctly write it in the bottom-up approach:</p> <pre class="lang-cpp prettyprint-override"><code>int fib(int n) { int dp[n + 2]; dp[0] = 0; dp[1] = 1; for (int i = 2; i &lt;= n; i++) dp[i] = dp[i - 1] + dp[i - 2]; return dp[n]; } </code></pre> <p>But the top-down (memoized) approach is harder for me to grasp. This is what I put originally:</p> <pre class="lang-cpp prettyprint-override"><code>int fib(int n) { std::vector&lt;int&gt; dp(n + 1, -1); // Lambda Function auto recurse = [&amp;](int n) { if (dp[n] != -1) return dp[n]; if (n == 0) { dp[n] = 0; return 0; } if (n == 1){ dp[n] = 1; return 1; } dp[n] = fib(n - 2) + fib(n - 1); return dp[n]; }; recurse(n); return dp.back(); } </code></pre> <p>...This was my first time using a C++ lambda function, though, so I also tried:</p> <pre class="lang-cpp prettyprint-override"><code>int recurse(int n, std::vector&lt;int&gt;&amp; dp) { if (dp[n] != -1) return dp[n]; if (n == 0) { dp[n] = 0; return 0; } if (n == 1){ dp[n] = 1; return 1; } dp[n] = fib(n - 2) + fib(n - 1); return dp[n]; } int fib(int n) { std::vector&lt;int&gt; dp(n + 1, -1); recurse(n, dp); return dp.back(); } </code></pre> <p>...just to make sure. Both of these gave time limit exceeded errors on leetcode. This, obviously, seemed off, since DP/Memoization are optimization techniques. Is my top-down approach wrong? How do I fix it?</p>
[ { "answer_id": 74387112, "author": "Cemil AKAN", "author_id": 13189540, "author_profile": "https://Stackoverflow.com/users/13189540", "pm_score": 1, "selected": false, "text": "$('input[type=\"radio\"]:not(.unique_radio)').on('change', function(){\n console.log(1);\n});\n$('.unique_radio').on('change', function() {\n console.log(2);\n});\n" }, { "answer_id": 74387350, "author": "Yves Kipondo", "author_id": 6108283, "author_profile": "https://Stackoverflow.com/users/6108283", "pm_score": 0, "selected": false, "text": "$('input[type=\"radio\"]').on('change', function() { \n console.log($(this).data('id'));\n});" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16283824/" ]
74,385,156
<p>I have log file from a Vivado simulator, which i want to convert into simple JSON to visualize it ultimately. Please suggest me a python code to format the logs into JSON.</p> <p>I have tried to search for converting the logs into JSON, but most of them convert .csv (comma separated values) into JSON, while my log file contains colon separated values.</p> <p>This is line from my log file:</p> <blockquote> <p>OVL_ERROR : ASSERT_NO_OVERFLOW : Counter did not reset after reaching Threshold : Test expression changed value from allowed maximum value max to a value in the range max+1 to min : severity 1 : time 430000 : counter_tb.no_overflow.ovl_error_t</p> </blockquote> <p>I want the JSON to look like this:</p> <pre><code>{ &quot;Error&quot;:&quot;OVL_Error&quot;, &quot;Assertion&quot;:&quot;ASSERT_NO_OVERFLOW&quot;, &quot;Message&quot;:&quot;Counter_did_not_reset_after_reaching_Threshold&quot;, &quot;Coverage&quot;:&quot;Test expression changed value from allowed maximum value max to a value in the range max+1 to min&quot;, &quot;Severity&quot;:&quot;1&quot;, &quot;Time&quot;:&quot;430000&quot; } </code></pre> <p>Is it possible to do so.</p> <p>Thanks.</p>
[ { "answer_id": 74387112, "author": "Cemil AKAN", "author_id": 13189540, "author_profile": "https://Stackoverflow.com/users/13189540", "pm_score": 1, "selected": false, "text": "$('input[type=\"radio\"]:not(.unique_radio)').on('change', function(){\n console.log(1);\n});\n$('.unique_radio').on('change', function() {\n console.log(2);\n});\n" }, { "answer_id": 74387350, "author": "Yves Kipondo", "author_id": 6108283, "author_profile": "https://Stackoverflow.com/users/6108283", "pm_score": 0, "selected": false, "text": "$('input[type=\"radio\"]').on('change', function() { \n console.log($(this).data('id'));\n});" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20407976/" ]
74,385,165
<p>I am trying to implement a logger functionality using metaclasses. This is for learning purposes and may not be a good use case practically.</p> <pre><code>from functools import wraps def custom_logger(fn): @wraps(fn) def inner(*args,**kwargs): result=fn(*args,**kwargs) print(f'LOG: {fn.__qualname__} {args},{kwargs}, result={result}') return result return inner class custom_meta(type): def __new__(mcls,name,bases,namespace): new_obj=super().__new__(mcls,name,bases,namespace) for n,o in vars(new_obj).items(): if callable(o): decorated_=custom_logger(o) setattr(new_obj,n,decorated_) return new_obj class Person(metaclass=custom_meta): def __init__(self,name,age): self.name=name self.age=age def say_hello(self): print('hello') def __repr__(self): return 'hi' p=Person('naxi',29); p.say_hello() print(p) </code></pre> <p>All of the methods inside Person class are getting decorated perfectly. The only issue I am having is with <code>__repr__</code> method which is throwing below error.</p> <pre><code> File &quot;main.py&quot;, line 9, in inner print(f'LOG: {fn.__qualname__} {args},{kwargs}, result={result}') [Previous line repeated 247 more times] RecursionError: maximum recursion depth exceeded while getting the str of an object </code></pre> <p>Also, implementing the <code>__str__</code> works just fine. Can someone please let know why is <code>__repr__</code> behaving this way ?</p>
[ { "answer_id": 74387112, "author": "Cemil AKAN", "author_id": 13189540, "author_profile": "https://Stackoverflow.com/users/13189540", "pm_score": 1, "selected": false, "text": "$('input[type=\"radio\"]:not(.unique_radio)').on('change', function(){\n console.log(1);\n});\n$('.unique_radio').on('change', function() {\n console.log(2);\n});\n" }, { "answer_id": 74387350, "author": "Yves Kipondo", "author_id": 6108283, "author_profile": "https://Stackoverflow.com/users/6108283", "pm_score": 0, "selected": false, "text": "$('input[type=\"radio\"]').on('change', function() { \n console.log($(this).data('id'));\n});" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2092445/" ]
74,385,178
<p>how to run simple select query and get reusult in snowflakes procedure?</p> <pre><code>CREATE OR REPLACE PROCEDURE COARSDB0P_DB.COUNT_MISMATCH() RETURNS VARCHAR LANGUAGE JAVASCRIPT AS $$ var command =&quot;SELECT b.TABLE_CATALOG,b.TABLE_SCHEMA,b.TABLE_NAME,b.TABLE_TYPE,b.ROW_COUNT as Dev_COUNT,a.ROW_COUNT as UAT_COUNT FROM TABLE A ,information_schema.tables B where b.TABLE_NAME=a.TABLE_NAMES and b.TABLE_SCHEMA=a.TABLE_SCHEMA and b.TABLE_TYPE=a.TABLE_TYPE and TRY_CAST(b.ROW_COUNT as NUMBER) != TRY_CAST(a.ROW_COUNT as NUMBER);&quot; var cmd1_dict = {sqlText: command}; var stmt = snowflake.createStatement(cmd1_dict); var rs = stmt.execute(); rs.next(); var output = rs.getColumnValue(); return output; $$; </code></pre> <p>I need to return the actualy output of mentioned SLECT query.</p>
[ { "answer_id": 74390335, "author": "Dave Welden", "author_id": 95014, "author_profile": "https://Stackoverflow.com/users/95014", "pm_score": 1, "selected": false, "text": "create procedure ...\nreturns table (catalog varchar, schema varchar, ...)\ndeclare\n query varchar;\n res resultset;\nbegin\n -- build the dynamic SQL query\n query := 'select ...'\n res := (execute immediate :query);\n return table (res);\nend;\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20250071/" ]
74,385,203
<p>i have a api which generates random json details of image, i am trying to make a website which show different images every time u press a button.</p> <p>something like this one:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;zzz&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id=&quot;img_home&quot;&gt;&lt;/div&gt; &lt;button onclick=&quot;addimage()&quot;&gt;next&lt;/button&gt; &lt;script&gt; function addimage() { var img = new Image(); img.src = &quot;https://www.abcd.com/image-generator.json&quot; img_home.appendChild(img); } &lt;/script&gt; &lt;/body&gt; </code></pre>
[ { "answer_id": 74390335, "author": "Dave Welden", "author_id": 95014, "author_profile": "https://Stackoverflow.com/users/95014", "pm_score": 1, "selected": false, "text": "create procedure ...\nreturns table (catalog varchar, schema varchar, ...)\ndeclare\n query varchar;\n res resultset;\nbegin\n -- build the dynamic SQL query\n query := 'select ...'\n res := (execute immediate :query);\n return table (res);\nend;\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14937521/" ]
74,385,208
<p>I'm a little new to deploying/hosting Node apps and Puppeteer.</p> <p>But, I'm facing an issue though with my app on Heroku when trying to use Puppeteer.</p> <p>The full error is:</p> <pre><code> Error: Could not find Chromium (rev. 1056772). This can occur if either 2022-11-10T06:44:07.938983+00:00 app[web.1]: 1. you did not perform an installation before running the script (e.g. `npm install`) or 2022-11-10T06:44:07.938983+00:00 app[web.1]: 2. your cache path is incorrectly configured (which is: /app/.cache/puppeteer). 2022-11-10T06:44:07.938983+00:00 app[web.1]: For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration. 2022-11-10T06:44:07.938984+00:00 app[web.1]: at ChromeLauncher.resolveExecutablePath (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ProductLauncher.js:120:27) 2022-11-10T06:44:07.938984+00:00 app[web.1]: at ChromeLauncher.executablePath (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:166:25) 2022-11-10T06:44:07.938985+00:00 app[web.1]: at PuppeteerNode.executablePath (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/node/PuppeteerNode.js:162:105) 2022-11-10T06:44:07.938985+00:00 app[web.1]: at Object.&lt;anonymous&gt; (/app/index.js:29:145) 2022-11-10T06:44:07.938985+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1159:14) 2022-11-10T06:44:07.938986+00:00 app[web.1]: at Module._extensions..js (node:internal/modules/cjs/loader:1213:10) 2022-11-10T06:44:07.938986+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:1037:32) 2022-11-10T06:44:07.938986+00:00 app[web.1]: at Module._load (node:internal/modules/cjs/loader:878:12) 2022-11-10T06:44:07.938986+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) 2022-11-10T06:44:07.938987+00:00 app[web.1]: at node:internal/main/run_main_module:23:47 </code></pre> <p>My code for index.js is:</p> <pre><code> const puppeteer = require('puppeteer-extra') const RecaptchaPlugin = require('puppeteer-extra-plugin-recaptcha') const StealthPlugin = require('puppeteer-extra-plugin-stealth') const { executablePath } = require('puppeteer') const axios = require('axios') //pupeteer plugins puppeteer.use( RecaptchaPlugin({ provider: { id: '2captcha', token: 'XXX' }, visualFeedback: true //colorize reCAPTCHAs (violet = detected, green = solved) }) ) puppeteer.use(StealthPlugin()) //pupeteer crawl try { puppeteer.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox'], headless: true, executablePath: executablePath(), ignoreHTTPSErrors: true }).then(async browser =&gt; { console.log('Running tests..') const page = await browser.newPage() await page.goto('https://bot.sannysoft.com') await page.setViewport({ width: 1680, height: 857 }) await page.waitForTimeout(5000) await page.screenshot({ path: 'testresult.png', fullPage: true }) await browser.close() console.log(`All done, check the screenshot. ✨`) }) } catch (error) { console.error(error); } </code></pre> <p>And these are my build packs in Heroku:</p> <p><a href="https://i.stack.imgur.com/at6CC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/at6CC.png" alt="enter image description here" /></a></p> <p>I've been battling with these for a few days and tried everything :(</p> <p>Thank you!!</p> <p>I've tried adding the necessary flags:</p> <p><code>args: ['--no-sandbox', '--disable-setuid-sandbox']</code></p> <p>And also the build pack: <a href="https://github.com/jontewks/puppeteer-heroku-buildpack" rel="nofollow noreferrer">https://github.com/jontewks/puppeteer-heroku-buildpack</a></p> <p>These are the common solutions people have mentioned on other issue threads.</p>
[ { "answer_id": 74471504, "author": "Cowinch", "author_id": 20525484, "author_profile": "https://Stackoverflow.com/users/20525484", "pm_score": 1, "selected": false, "text": ".cache" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5401014/" ]
74,385,218
<p>I am writing R, and I want to add a new column WITHOUT using for loop.</p> <p>Here's the thing I want to do:</p> <p>I want to calculate the mean from the first value to the current value.</p> <p>If I use for loop, I will do in this way:</p> <pre><code>for (i in c(1:nrow(data))){ data$Xn_bar[i] = mean(data$Xn[1:i]) } </code></pre> <p>Is there other way(i.e. map?)</p> <p>Here's the data:</p> <pre><code>a = data.frame( n = c(1:10), Xn = c(-0.502,0.132,-0.079,0.887,0.117,0.319,-0.582,0.715,-0.825,-0.360) ) </code></pre>
[ { "answer_id": 74385693, "author": "islem", "author_id": 11952767, "author_profile": "https://Stackoverflow.com/users/11952767", "pm_score": 0, "selected": false, "text": "library(dplyr)\ndf=data.frame(n=c(1,2,3,4,5),\n Xn=c(-0.502,0.132,-0.079,0.887,0.117))\n\n# add column row_index which contain row_number of current row \ndf= df%>%\n mutate(row_index=row_number())\n\n# Add column Xxn \ndf$Xxn=mapply(function(x,y)return(\n round(\n mean(\n df$Xn[1:y]),3\n )\n ),\n df$Xn,\n df$row_index,\n USE.NAMES = F)\n \n #now remove row_index column\ndf= df%>%select(-row_index)\ndf\n# > df\n# n Xn Xxn\n# 1 1 -0.502 -0.502\n# 2 2 0.132 -0.185\n# 3 3 -0.079 -0.150\n# 4 4 0.887 0.110\n# 5 5 0.117 0.111\n" }, { "answer_id": 74386096, "author": "SamR", "author_id": 12545041, "author_profile": "https://Stackoverflow.com/users/12545041", "pm_score": 2, "selected": false, "text": "dplyr::cummean()" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16469595/" ]
74,385,225
<p>Okay so I have a Magento 2.4.5 project where I am facing some issues like images not loading up because they are being looked up inside <code>pub/media/wysiwyg</code> instead of <code>media/wysiwyg</code>. I have some wysiwyg images inside <code>pub/media/wysiwyg/&lt;some_image_directory&gt;</code>, however on the live site the directories and files are showing up as <code>media/wysiwyg</code>. How can I make sure that a separate <code>pub/media/wysiwyg</code> directory is created in the live site apart from the media directory that is already there such that the image loads up properly? We are using nginx which is opening up at 'pub' directory as the root where the media directory resides. Any help is appreciated.</p> <p>I tried checking for the piece of code where the image is coming from in an attempt to see if the path can be changed programmatically by removing the 'pub/' part from the pub/media/wysiwyg/ for the live site. However, that is not something that can be done as that will change things project-wide, which might break other things. Hence that is not being done.</p>
[ { "answer_id": 74385693, "author": "islem", "author_id": 11952767, "author_profile": "https://Stackoverflow.com/users/11952767", "pm_score": 0, "selected": false, "text": "library(dplyr)\ndf=data.frame(n=c(1,2,3,4,5),\n Xn=c(-0.502,0.132,-0.079,0.887,0.117))\n\n# add column row_index which contain row_number of current row \ndf= df%>%\n mutate(row_index=row_number())\n\n# Add column Xxn \ndf$Xxn=mapply(function(x,y)return(\n round(\n mean(\n df$Xn[1:y]),3\n )\n ),\n df$Xn,\n df$row_index,\n USE.NAMES = F)\n \n #now remove row_index column\ndf= df%>%select(-row_index)\ndf\n# > df\n# n Xn Xxn\n# 1 1 -0.502 -0.502\n# 2 2 0.132 -0.185\n# 3 3 -0.079 -0.150\n# 4 4 0.887 0.110\n# 5 5 0.117 0.111\n" }, { "answer_id": 74386096, "author": "SamR", "author_id": 12545041, "author_profile": "https://Stackoverflow.com/users/12545041", "pm_score": 2, "selected": false, "text": "dplyr::cummean()" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19969061/" ]
74,385,244
<p>Recently I'm using pac4j project for Oauth Twitter.Running on the local, everything works fine.But when I'm running on the remote server, unfortunately, the service doesn't work properly because there is no direct access to the external network.</p> <p>For example,in apache.httpcomponents:httpclient:</p> <p><code>HttpClients.custom().setSSLSocketFactory(sslsf).setProxy(new HttpHost(&quot;192.168.200.14&quot;, 8080)).build() </code></p> <p>How to use HTTP Proxy with Pac4j-oauth?</p>
[ { "answer_id": 74385693, "author": "islem", "author_id": 11952767, "author_profile": "https://Stackoverflow.com/users/11952767", "pm_score": 0, "selected": false, "text": "library(dplyr)\ndf=data.frame(n=c(1,2,3,4,5),\n Xn=c(-0.502,0.132,-0.079,0.887,0.117))\n\n# add column row_index which contain row_number of current row \ndf= df%>%\n mutate(row_index=row_number())\n\n# Add column Xxn \ndf$Xxn=mapply(function(x,y)return(\n round(\n mean(\n df$Xn[1:y]),3\n )\n ),\n df$Xn,\n df$row_index,\n USE.NAMES = F)\n \n #now remove row_index column\ndf= df%>%select(-row_index)\ndf\n# > df\n# n Xn Xxn\n# 1 1 -0.502 -0.502\n# 2 2 0.132 -0.185\n# 3 3 -0.079 -0.150\n# 4 4 0.887 0.110\n# 5 5 0.117 0.111\n" }, { "answer_id": 74386096, "author": "SamR", "author_id": 12545041, "author_profile": "https://Stackoverflow.com/users/12545041", "pm_score": 2, "selected": false, "text": "dplyr::cummean()" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385244", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20465694/" ]
74,385,270
<p>When I Run my code And take input of array in ascending order from user the function which i have made runs and if the i search the middle number from array to find its location the code runs perfectly fine. But when i search the number from array which is not middle the code does not give me any output please fix this issue.</p> <pre><code>#include&lt;iostream&gt; using namespace std; void input_array(int arr[], int n); int binary_search(int arr[], int n, int target); int main() { int limit; cout&lt;&lt;&quot;Enter The Limit For An Array:- &quot;; cin&gt;&gt;limit; int arr[limit]; input_array(arr, limit); int target; cout&lt;&lt;&quot;Enter The Number to find its position:- &quot;; cin&gt;&gt;target; binary_search(arr, limit, target); } void input_array(int arr[], int n) { cout&lt;&lt;&quot;Enter The Number in Increasing Order &quot;&lt;&lt;endl; for (int i = 0; i &lt; n; i++) { cout&lt;&lt;i+1&lt;&lt;&quot;. Enter Number :- &quot;; cin&gt;&gt;arr[i]; } } int binary_search(int arr[], int n, int target) { int low = 0; int high = n-1; int mid; for (int i = 0; i &lt; n; i++) { mid = (low+high) / 2; if (arr[mid] == target) { cout&lt;&lt;&quot;The Position of The Given Target is :- &quot;&lt;&lt;mid; return 0; } if (arr[mid] &gt; target) { low = mid + 1; } else { high = mid - 1; } } return -1; } </code></pre> <p>i have created a program which is not working i dont know the reason why its not working kindly please solve my issue so i can proceed further.</p>
[ { "answer_id": 74385693, "author": "islem", "author_id": 11952767, "author_profile": "https://Stackoverflow.com/users/11952767", "pm_score": 0, "selected": false, "text": "library(dplyr)\ndf=data.frame(n=c(1,2,3,4,5),\n Xn=c(-0.502,0.132,-0.079,0.887,0.117))\n\n# add column row_index which contain row_number of current row \ndf= df%>%\n mutate(row_index=row_number())\n\n# Add column Xxn \ndf$Xxn=mapply(function(x,y)return(\n round(\n mean(\n df$Xn[1:y]),3\n )\n ),\n df$Xn,\n df$row_index,\n USE.NAMES = F)\n \n #now remove row_index column\ndf= df%>%select(-row_index)\ndf\n# > df\n# n Xn Xxn\n# 1 1 -0.502 -0.502\n# 2 2 0.132 -0.185\n# 3 3 -0.079 -0.150\n# 4 4 0.887 0.110\n# 5 5 0.117 0.111\n" }, { "answer_id": 74386096, "author": "SamR", "author_id": 12545041, "author_profile": "https://Stackoverflow.com/users/12545041", "pm_score": 2, "selected": false, "text": "dplyr::cummean()" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20465707/" ]
74,385,286
<p>Here is my code:</p> <pre><code>string StringFromTheInput = TextBox1.Text; string source = StringFromTheInput.ToString(); var frequencies = new Dictionary&lt;string, int&gt;(); frequencies.Add(&quot;item&quot;, 0); string highestWord = null; var message = string.Join(&quot; &quot;, source); var splichar = new char[] { ' ', '.' }; var single = message.Split(splichar); int highestFreq = 0; foreach (var item in single) { if (item.Length &gt; 4) { int freq; frequencies.TryGetValue(item, out freq); freq += 1; if (freq&gt; highestFreq) { highestFreq = freq; highestWord = item.Trim(); } frequencies[item] = freq; Label1.Text = highestWord.ToString(); } } </code></pre> <p>This is successfully gets me the most frequent word from the text but I tried to increment highestFreq= freq+1 to get the second most frequent word but it doesn`t work!</p>
[ { "answer_id": 74385581, "author": "Siegfried.V", "author_id": 7310000, "author_profile": "https://Stackoverflow.com/users/7310000", "pm_score": 0, "selected": false, "text": "int indexYouNeed =2;\nint indexRead=1;\nstring textFound=\"\";\nforeach (KeyValuePair<string,int> entry in frequencies.Where(x=>x.Key.Length>4).OrderBy(x=>x.Value))\n{\n if(indexRead==indexYouNeed)\n {\n textFound=entry.Key;\n break;\n }\n indexRead++;\n}\n" }, { "answer_id": 74385659, "author": "LoLo2207", "author_id": 8800752, "author_profile": "https://Stackoverflow.com/users/8800752", "pm_score": 2, "selected": false, "text": "using System;\nusing System.Linq;\n\nstring StringFromTheInput = \"Her life in the confines of the house became her new normal. He wondered if she would appreciate his toenail collection. My secretary is the only person who truly understands my stamp-collecting obsession. This is the last random sentence I will be writing and I am going to stop mid-sent. She tilted her head back and let whip cream stream into her mouth while taking a bath.\";\n\nstring[] words = StringFromTheInput.Split(\" \");\nvar setsByFrequency = words\n .Where(x => x.Length > 4) // For words with more than 4 characters\n .GroupBy(x => x.ToLower()) // ToLower so 'House' and 'house' both gets placed into the same group\n .Select(g => new { Freq = g.Count(), Word = g.Key}) \n .OrderByDescending(g => g.Freq)\n .ToList();\n\nvar mostFrequent = setsByFrequency[0];\nvar secondMostFrequent = setsByFrequency[1];\n\nConsole.WriteLine(mostFrequent);\nConsole.WriteLine(secondMostFrequent);\n" }, { "answer_id": 74387900, "author": "Joaco Ferroni", "author_id": 8837876, "author_profile": "https://Stackoverflow.com/users/8837876", "pm_score": 0, "selected": false, "text": "string StringFromTheInput = \"\";\nvar wordsFreq = new Dictionary<string,int>(StringComparer.OrdinalIgnoreCase);\nforeach(var s in StringFromTheInput.Split(' ')){\n if(s.Length <=4) continue;\n if(wordsFreq.ContainsKey(s)){\n wordsFreq[s]++; \n }else{\n wordsFreq.Add(s,1);\n }\n}\nif(!wordsFreq.Any()) return;\nvar secondFreqWord = wordsFreq.OrderByDescending(x => x.Value).ToList()[1]; \n\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20465780/" ]
74,385,292
<p>I want to post forms data submitted on a wordpress gravity form to a third party erp software which accepts only soap envelopes. Gravity forms elitle package offers webhooks which has only two formats json and form data, is it possible to post the data as a form. Below is wsdl which i need to map with form fields. If not then what are my options,please help as it is a project to help a friend.</p> <p>WSDL that i would need to fill: `</p> <pre><code>&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:tem=&quot;http://tempuri.org/&quot; xmlns:v3=&quot;http://schemas.datacontract.org/2004/07/V3.WebServiceInterface.Models.V3&quot; xmlns:ser=&quot;http://schemas.microsoft.com/2003/10/Serialization/&quot;&gt; &lt;soapenv:Header/&gt; &lt;soapenv:Body&gt; &lt;tem:AddJobs&gt; &lt;!--Optional:--&gt; &lt;tem:jobs&gt; &lt;!--Zero or more repetitions:--&gt; &lt;v3:Job ser:Id=&quot;&quot; ser:Ref=&quot;&quot;&gt; &lt;!--Optional:--&gt; &lt;v3:Fields&gt; &lt;!--Zero or more repetitions:--&gt; &lt;v3:Field&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Name&gt;My_test_Jalal&lt;/v3:Name&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Value&gt;verrantque per auras&lt;/v3:Value&gt; &lt;/v3:Field&gt; &lt;/v3:Fields&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:FormName&gt;per auras&lt;/v3:FormName&gt; &lt;!--Optional:--&gt; &lt;v3:Asset ser:Id=&quot;circum claustra&quot; ser:Ref=&quot;nimborum in&quot;&gt; &lt;!--Optional:--&gt; &lt;v3:Fields&gt; &lt;!--Zero or more repetitions:--&gt; &lt;v3:Field&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Name&gt;foedere certo&lt;/v3:Name&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Value&gt;profundum quippe ferant&lt;/v3:Value&gt; &lt;/v3:Field&gt; &lt;/v3:Fields&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:FormName&gt;et carcere&lt;/v3:FormName&gt; &lt;!--Optional:--&gt; &lt;v3:Customer ser:Id=&quot;iovis rapidum iaculata&quot; ser:Ref=&quot;speluncis abdidit&quot;&gt; &lt;!--Optional:--&gt; &lt;v3:Fields&gt; &lt;!--Zero or more repetitions:--&gt; &lt;v3:Field&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Name&gt;bella gero et&lt;/v3:Name&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Value&gt;flammas turbine&lt;/v3:Value&gt; &lt;/v3:Field&gt; &lt;/v3:Fields&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:FormName&gt;hoc metuens&lt;/v3:FormName&gt; &lt;!--Optional:--&gt; &lt;v3:Contacts&gt; &lt;!--Zero or more repetitions:--&gt; &lt;v3:Contact ser:Id=&quot;ac vinclis&quot; ser:Ref=&quot;speluncis abdidit&quot;&gt; &lt;!--Optional:--&gt; &lt;v3:Fields&gt; &lt;!--Zero or more repetitions:--&gt; &lt;v3:Field&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Name&gt;aris imponet honorem&lt;/v3:Name&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Value&gt;praeterea aut&lt;/v3:Value&gt; &lt;/v3:Field&gt; &lt;/v3:Fields&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:FormName&gt;claustra fremunt&lt;/v3:FormName&gt; &lt;/v3:Contact&gt; &lt;/v3:Contacts&gt; &lt;!--Optional:--&gt; &lt;v3:Products&gt; &lt;!--Zero or more repetitions:--&gt; &lt;v3:Product ser:Id=&quot;imperio premit&quot; ser:Ref=&quot;quisquam numen&quot;&gt; &lt;!--Optional:--&gt; &lt;v3:Fields&gt; &lt;!--Zero or more repetitions:--&gt; &lt;v3:Field&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Name&gt;ac vinclis&lt;/v3:Name&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Value&gt;ac vinclis&lt;/v3:Value&gt; &lt;/v3:Field&gt; &lt;/v3:Fields&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:FormName&gt;pectore flammas&lt;/v3:FormName&gt; &lt;/v3:Product&gt; &lt;/v3:Products&gt; &lt;/v3:Customer&gt; &lt;!--Optional:--&gt; &lt;v3:Products&gt; &lt;!--Zero or more repetitions:--&gt; &lt;v3:Product ser:Id=&quot;pectore flammas&quot; ser:Ref=&quot;annos bella gero&quot;&gt; &lt;!--Optional:--&gt; &lt;v3:Fields&gt; &lt;!--Zero or more repetitions:--&gt; &lt;v3:Field&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Name&gt;certo et&lt;/v3:Name&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Value&gt;rates evertitque aequora&lt;/v3:Value&gt; &lt;/v3:Field&gt; &lt;/v3:Fields&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:FormName&gt;volutans nimborum in&lt;/v3:FormName&gt; &lt;/v3:Product&gt; &lt;/v3:Products&gt; &lt;/v3:Asset&gt; &lt;!--Optional:--&gt; &lt;v3:Contacts&gt; &lt;!--Zero or more repetitions:--&gt; &lt;v3:Contact ser:Id=&quot;faciat maria&quot; ser:Ref=&quot;et quisquam&quot;&gt; &lt;!--Optional:--&gt; &lt;v3:Fields&gt; &lt;!--Zero or more repetitions:--&gt; &lt;v3:Field&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Name&gt;et soror&lt;/v3:Name&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Value&gt;annos bella gero&lt;/v3:Value&gt; &lt;/v3:Field&gt; &lt;/v3:Fields&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:FormName&gt;ventos tempestatesque sonoras&lt;/v3:FormName&gt; &lt;/v3:Contact&gt; &lt;/v3:Contacts&gt; &lt;!--Optional:--&gt; &lt;v3:Customer ser:Id=&quot;regina iovisque&quot; ser:Ref=&quot;rapidum iaculata&quot;&gt; &lt;!--Optional:--&gt; &lt;v3:Fields&gt; &lt;!--Zero or more repetitions:--&gt; &lt;v3:Field&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Name&gt;insuper altos&lt;/v3:Name&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Value&gt;cum murmure&lt;/v3:Value&gt; &lt;/v3:Field&gt; &lt;/v3:Fields&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:FormName&gt;in patriam&lt;/v3:FormName&gt; &lt;!--Optional:--&gt; &lt;v3:Contacts&gt; &lt;!--Zero or more repetitions:--&gt; &lt;v3:Contact ser:Id=&quot;abdidit atris hoc&quot; ser:Ref=&quot;coniunx una cum&quot;&gt; &lt;!--Optional:--&gt; &lt;v3:Fields&gt; &lt;!--Zero or more repetitions:--&gt; &lt;v3:Field&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Name&gt;ipsa iovis&lt;/v3:Name&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Value&gt;frenat illi indignantes&lt;/v3:Value&gt; &lt;/v3:Field&gt; &lt;/v3:Fields&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:FormName&gt;nimborum in&lt;/v3:FormName&gt; &lt;/v3:Contact&gt; &lt;/v3:Contacts&gt; &lt;!--Optional:--&gt; &lt;v3:Products&gt; &lt;!--Zero or more repetitions:--&gt; &lt;v3:Product ser:Id=&quot;mollitque animos&quot; ser:Ref=&quot;montis insuper altos&quot;&gt; &lt;!--Optional:--&gt; &lt;v3:Fields&gt; &lt;!--Zero or more repetitions:--&gt; &lt;v3:Field&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Name&gt;molemque et montis&lt;/v3:Name&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Value&gt;gero et&lt;/v3:Value&gt; &lt;/v3:Field&gt; &lt;/v3:Fields&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:FormName&gt;circum claustra fremunt&lt;/v3:FormName&gt; &lt;/v3:Product&gt; &lt;/v3:Products&gt; &lt;/v3:Customer&gt; &lt;!--Optional:--&gt; &lt;v3:ProductRows&gt; &lt;!--Zero or more repetitions:--&gt; &lt;v3:ProductRow ser:Id=&quot;montis insuper&quot; ser:Ref=&quot;aris imponet&quot;&gt; &lt;!--Optional:--&gt; &lt;v3:Fields&gt; &lt;!--Zero or more repetitions:--&gt; &lt;v3:Field&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Name&gt;aris imponet&lt;/v3:Name&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:Value&gt;incedo regina&lt;/v3:Value&gt; &lt;/v3:Field&gt; &lt;/v3:Fields&gt; &lt;!--Optional:--&gt; &lt;!--type: string--&gt; &lt;v3:FormName&gt;ac vinclis&lt;/v3:FormName&gt; &lt;/v3:ProductRow&gt; &lt;/v3:ProductRows&gt; &lt;!--Optional:--&gt; &lt;v3:SubJobs/&gt; &lt;/v3:Job&gt; &lt;/tem:jobs&gt; &lt;/tem:AddJobs&gt; &lt;/soapenv:Body&gt; &lt;/soapenv:Envelope&gt; </code></pre> <p>`</p> <p>I am wondering if anyone here has ever tried this before since more than half of internet is running wordpress websites, plus i am pretty knew to wsdl soap. I tried submitting the above soap envelope to the endpoint but it failed so do not know what is wrong in my xml.</p>
[ { "answer_id": 74385581, "author": "Siegfried.V", "author_id": 7310000, "author_profile": "https://Stackoverflow.com/users/7310000", "pm_score": 0, "selected": false, "text": "int indexYouNeed =2;\nint indexRead=1;\nstring textFound=\"\";\nforeach (KeyValuePair<string,int> entry in frequencies.Where(x=>x.Key.Length>4).OrderBy(x=>x.Value))\n{\n if(indexRead==indexYouNeed)\n {\n textFound=entry.Key;\n break;\n }\n indexRead++;\n}\n" }, { "answer_id": 74385659, "author": "LoLo2207", "author_id": 8800752, "author_profile": "https://Stackoverflow.com/users/8800752", "pm_score": 2, "selected": false, "text": "using System;\nusing System.Linq;\n\nstring StringFromTheInput = \"Her life in the confines of the house became her new normal. He wondered if she would appreciate his toenail collection. My secretary is the only person who truly understands my stamp-collecting obsession. This is the last random sentence I will be writing and I am going to stop mid-sent. She tilted her head back and let whip cream stream into her mouth while taking a bath.\";\n\nstring[] words = StringFromTheInput.Split(\" \");\nvar setsByFrequency = words\n .Where(x => x.Length > 4) // For words with more than 4 characters\n .GroupBy(x => x.ToLower()) // ToLower so 'House' and 'house' both gets placed into the same group\n .Select(g => new { Freq = g.Count(), Word = g.Key}) \n .OrderByDescending(g => g.Freq)\n .ToList();\n\nvar mostFrequent = setsByFrequency[0];\nvar secondMostFrequent = setsByFrequency[1];\n\nConsole.WriteLine(mostFrequent);\nConsole.WriteLine(secondMostFrequent);\n" }, { "answer_id": 74387900, "author": "Joaco Ferroni", "author_id": 8837876, "author_profile": "https://Stackoverflow.com/users/8837876", "pm_score": 0, "selected": false, "text": "string StringFromTheInput = \"\";\nvar wordsFreq = new Dictionary<string,int>(StringComparer.OrdinalIgnoreCase);\nforeach(var s in StringFromTheInput.Split(' ')){\n if(s.Length <=4) continue;\n if(wordsFreq.ContainsKey(s)){\n wordsFreq[s]++; \n }else{\n wordsFreq.Add(s,1);\n }\n}\nif(!wordsFreq.Any()) return;\nvar secondFreqWord = wordsFreq.OrderByDescending(x => x.Value).ToList()[1]; \n\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13033678/" ]
74,385,324
<p>I am trying to show Activity indicator view on API call in my swiftUI application. I have created the Activity Indicator view and it's working fine but I want to disable the user interaction while it is being displayed. To achieve this I have also tried <strong>allowsHitTesting(false)</strong> modifier but of no use :( When I am clicking on the button is clickable.</p> <p><a href="https://i.stack.imgur.com/zqmd5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zqmd5.jpg" alt="enter image description here" /></a></p> <p>ContentView</p> <pre><code>import SwiftUI struct ContentView: View { var body: some View { return NavigationView { ZStack { VStack { Button { // print(&quot;Button tapped&quot;) } label: { Text(&quot;Tap me&quot;) } .frame(width: 200, height: 60) .background(.red) Spacer() } Loading() .edgesIgnoringSafeArea(.all) .allowsHitTesting(false) } } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } </code></pre> <p>IndicatorView</p> <pre><code>import SwiftUI struct Loading: View { var body: some View { ZStack { BlurView() VStack { Indicator() } }.frame(maxWidth: .infinity, maxHeight: .infinity) .allowsHitTesting(false) } } //struct ActivityIndicatorView_Previews: PreviewProvider { // static var previews: some View { // ActivityIndicatorView(show: .constant(true)) // } //} struct BlurView: UIViewRepresentable { func makeUIView(context: UIViewRepresentableContext&lt;BlurView&gt;) -&gt; UIVisualEffectView { let effect = UIBlurEffect(style: .systemMaterial) let view = UIVisualEffectView(effect: effect) return view } func updateUIView(_ uiView: UIVisualEffectView, context: UIViewRepresentableContext&lt;BlurView&gt;) { // } } struct Indicator: UIViewRepresentable { func makeUIView(context: UIViewRepresentableContext&lt;Indicator&gt;)-&gt; UIActivityIndicatorView { let ind = UIActivityIndicatorView(style: .medium) ind.startAnimating() return ind } func updateUIView(_ uiView: UIActivityIndicatorView, context: Context) { // } } </code></pre>
[ { "answer_id": 74385586, "author": "Quang Hà", "author_id": 1615838, "author_profile": "https://Stackoverflow.com/users/1615838", "pm_score": 1, "selected": false, "text": ".allowsHitTesting(false)" }, { "answer_id": 74386690, "author": "Cheezzhead", "author_id": 2542661, "author_profile": "https://Stackoverflow.com/users/2542661", "pm_score": 0, "selected": false, "text": "Button" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10469417/" ]
74,385,327
<p>how do i implement this in django-form?<br /> 2/3: 2 is current picked amount of item, 3 is maximum<br /> This form does not work with the model, it will send data after clicking to the redis server<br /> So, how can i hide form under - n/N +</p> <p><a href="https://i.stack.imgur.com/mw9W9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mw9W9.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74385586, "author": "Quang Hà", "author_id": 1615838, "author_profile": "https://Stackoverflow.com/users/1615838", "pm_score": 1, "selected": false, "text": ".allowsHitTesting(false)" }, { "answer_id": 74386690, "author": "Cheezzhead", "author_id": 2542661, "author_profile": "https://Stackoverflow.com/users/2542661", "pm_score": 0, "selected": false, "text": "Button" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17238976/" ]
74,385,336
<p>I have some data as below,</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: center;">AST_NAME</th> </tr> </thead> <tbody> <tr> <td style="text-align: center;">2F</td> </tr> <tr> <td style="text-align: center;">3F</td> </tr> <tr> <td style="text-align: center;">4F</td> </tr> <tr> <td style="text-align: center;">5F</td> </tr> <tr> <td style="text-align: center;">2-F-C</td> </tr> <tr> <td style="text-align: center;">3-F-A</td> </tr> <tr> <td style="text-align: center;">4-F-C</td> </tr> <tr> <td style="text-align: center;">4-F-D</td> </tr> <tr> <td style="text-align: center;">5-F-E</td> </tr> <tr> <td style="text-align: center;">5-F-F</td> </tr> <tr> <td style="text-align: center;">SwB</td> </tr> <tr> <td style="text-align: center;">6-F-G</td> </tr> <tr> <td style="text-align: center;">SwB</td> </tr> <tr> <td style="text-align: center;">7-F-A</td> </tr> </tbody> </table> </div> <p>I want to extract the number and letter F only from those values like 2-F-C or 3-F-D. My desired output is as below.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: center;">AST_NAME</th> </tr> </thead> <tbody> <tr> <td style="text-align: center;">2F</td> </tr> <tr> <td style="text-align: center;">3F</td> </tr> <tr> <td style="text-align: center;">4F</td> </tr> <tr> <td style="text-align: center;">5F</td> </tr> <tr> <td style="text-align: center;">2F</td> </tr> <tr> <td style="text-align: center;">3F</td> </tr> <tr> <td style="text-align: center;">4F</td> </tr> <tr> <td style="text-align: center;">4F</td> </tr> <tr> <td style="text-align: center;">5F</td> </tr> <tr> <td style="text-align: center;">5F</td> </tr> <tr> <td style="text-align: center;">SwB</td> </tr> <tr> <td style="text-align: center;">6F</td> </tr> <tr> <td style="text-align: center;">SwB</td> </tr> <tr> <td style="text-align: center;">7F</td> </tr> </tbody> </table> </div> <p>I tried using lstrip() and rstrip() but couldn't get a simple solution. I even tried extracting 1st 3 letters and then removing '-' but I failed to achieve the desired output. Kindly suggest. Thank you.</p>
[ { "answer_id": 74385499, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 3, "selected": true, "text": "str.replace" }, { "answer_id": 74385603, "author": "ziying35", "author_id": 16755671, "author_profile": "https://Stackoverflow.com/users/16755671", "pm_score": 1, "selected": false, "text": "tmp = (df.AST_NAME\n .str.extract(r'(\\d+-?[A-Z])', expand=False)\n .dropna()\n .str.replace('-', ''))\nres = tmp.combine_first(df.AST_NAME).to_frame()\nprint(res)\n>>>\n AST_NAME\n0 2F\n1 3F\n2 4F\n3 5F\n4 2F\n5 3F\n6 4F\n7 4F\n8 5F\n9 5F\n10 SwB\n11 6F\n12 SwB\n13 7F\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11230796/" ]
74,385,357
<p>i have a C header file with many defines for registers, and in my Python SWIG interface i only want to expose a few. My C header looks like this (just with many more defines):</p> <pre><code>#define REG_1 0x0001 #define REG_2 0x0002 #define REG_3 0x0003 </code></pre> <p>Let's say in my generated Python module if I want to have all defines accessible, I can just do:</p> <pre><code>%module myheader %{ #include myheader.h %} %include myheader.h </code></pre> <p>But what if I only want to have REG_1 accessible/wrapped? I tried something like:</p> <pre><code>%module myheader %{ #include myheader.h %} %constant REG_1; </code></pre> <p>But it didn't work. Checked the documentation, still clueless unfortunately. Any ideas?</p>
[ { "answer_id": 74385499, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 3, "selected": true, "text": "str.replace" }, { "answer_id": 74385603, "author": "ziying35", "author_id": 16755671, "author_profile": "https://Stackoverflow.com/users/16755671", "pm_score": 1, "selected": false, "text": "tmp = (df.AST_NAME\n .str.extract(r'(\\d+-?[A-Z])', expand=False)\n .dropna()\n .str.replace('-', ''))\nres = tmp.combine_first(df.AST_NAME).to_frame()\nprint(res)\n>>>\n AST_NAME\n0 2F\n1 3F\n2 4F\n3 5F\n4 2F\n5 3F\n6 4F\n7 4F\n8 5F\n9 5F\n10 SwB\n11 6F\n12 SwB\n13 7F\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17920971/" ]
74,385,406
<p>I'm still learning rust, to process data I find rust runs very fast, but when try to inserting data into mysql I haven't found a way to do it quickly (compared to me doing it in python in under 1 minutes, rust need 15+ minutes).</p> <p>I'm using rust library &quot;mysql&quot; to insert data into db with code:</p> <pre><code>use mysql::*; #[derive(Debug, PartialEq, Eq)] struct ListPhone { phone_no: String, } fn insert_mysql(data: Vec&lt;ListPhone&gt;) -&gt; () { let url = &quot;mysql://user:pass@xxx.xxx.xxx.xxx:3306/learn&quot;; let pool = mysql::Pool::new(url); let mut conn = pool.expect(&quot;error pool conn&quot;).get_conn(); let res = conn.expect(&quot;error running&quot;).exec_batch( r&quot;INSERT INTO listPhone (phone_no) VALUES (:phone_no)&quot;, data.into_iter().map(|p| { params! { &quot;phone_no&quot; =&gt; p.phone_no, } }), ); println!(&quot;done&quot;) } </code></pre> <p>Has anyone explored inserting large datasets into mysql using rust language quickly (batch, row), or is there any library that can help?</p> <p>Edit : when I log all the queries I can see the difference between the queries generated in python and my rust script. in python the script will be like this:</p> <blockquote> <p>insert into listPhone (phone_no) values (1),(2),(3)... all the data</p> </blockquote> <p>and then executing it one statement</p> <p>, but in rust it will generate :</p> <blockquote> <p>&quot;insert into listPhone (phone_no) values (1)&quot;,</p> </blockquote> <blockquote> <p>&quot;insert into listPhone (phone_no) values (2)&quot;,</p> </blockquote> <blockquote> <p>&quot;insert into listPhone (phone_no) values (3)&quot;, ... the rest of the data</p> </blockquote> <p>and execute for each statement.</p> <p>is there a way to convert the resulting statement into a single statement?</p> <p>edit 2:</p> <p>i tried this solution in idiomatic way, i don't know about efficiency but this solution can do it with faster time compared to the python script i have. but I still hope someone has a more elegant solution.</p> <pre><code>fn insert_mysql_batch_experiment(data: Vec&lt;ListPhone&gt;) -&gt; () { let mut vec = Vec::new(); let url = env::var(&quot;DATABASE_URL&quot;).expect(&quot;load env failed&quot;); let pool = mysql::Pool::new(&amp;*url).expect(&quot;error pool conn&quot;); let mut conn = pool.get_conn().expect(&quot;error conn&quot;); for x in data.iter() { vec.push(x.phone_no.clone()); } let hasil = vec.join(&quot;'),('&quot;); let final_str = [ &quot;INSERT INTO listPhone (phone_no) VALUES &quot;, &quot;('&quot;, &amp;hasil, &quot;')&quot;, ] .join(&quot;&quot;); { let query_result = conn.query_iter(final_str); query_result.expect(&quot;error inserting data&quot;); } } </code></pre>
[ { "answer_id": 74385499, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 3, "selected": true, "text": "str.replace" }, { "answer_id": 74385603, "author": "ziying35", "author_id": 16755671, "author_profile": "https://Stackoverflow.com/users/16755671", "pm_score": 1, "selected": false, "text": "tmp = (df.AST_NAME\n .str.extract(r'(\\d+-?[A-Z])', expand=False)\n .dropna()\n .str.replace('-', ''))\nres = tmp.combine_first(df.AST_NAME).to_frame()\nprint(res)\n>>>\n AST_NAME\n0 2F\n1 3F\n2 4F\n3 5F\n4 2F\n5 3F\n6 4F\n7 4F\n8 5F\n9 5F\n10 SwB\n11 6F\n12 SwB\n13 7F\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11277889/" ]
74,385,464
<p>I am converting string column into datetime column...</p> <p>Here is my input,</p> <pre><code>col 00000001011970 00000001011970 00000001011970 ... 00000001011970 </code></pre> <p>Here is my snippet,</p> <pre><code>df[col].with_column= df.with_column(pl.col(col).str.strptime(pl.Datetime, fmt='%Y-%m-%d %H:%M:%S',strict=False).alias('parsed EventTime') ) </code></pre> <p>this above snippet is not converting into DateTime... the output is same as input... there is no change in output.</p> <p>Please help me to convert string column to DateTime in polars.</p>
[ { "answer_id": 74385727, "author": "4pi", "author_id": 2450246, "author_profile": "https://Stackoverflow.com/users/2450246", "pm_score": 1, "selected": false, "text": "df = pl.DataFrame({\n\"col\": [\"00000001011970\", \"00000001011970\", \"00000001011970\"]\n})\nprint(df.with_column(\n pl.col('col')\n .str\n .strptime(pl.Datetime, fmt='%S%M%H%d%m%Y',strict=False)\n .alias('parsed EventTime')\n))\n\n" }, { "answer_id": 74392290, "author": "Dean MacGregor", "author_id": 1818713, "author_profile": "https://Stackoverflow.com/users/1818713", "pm_score": 0, "selected": false, "text": "df['col']=" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17423386/" ]
74,385,476
<p>I have a token that I sent to my backend where I verify it (jwt). Is there any difference in sending back the token itself or the userId I created on the backend to the client to store ?</p> <p>I need specificaly the userId in my client only once. The jwt /or userId I need otherwise to authenticate user (if I get back token user is authenticated). However for this it doesnt matter if I get back the token or userId as userId is only being created once a jwt is issued on backend.</p>
[ { "answer_id": 74385727, "author": "4pi", "author_id": 2450246, "author_profile": "https://Stackoverflow.com/users/2450246", "pm_score": 1, "selected": false, "text": "df = pl.DataFrame({\n\"col\": [\"00000001011970\", \"00000001011970\", \"00000001011970\"]\n})\nprint(df.with_column(\n pl.col('col')\n .str\n .strptime(pl.Datetime, fmt='%S%M%H%d%m%Y',strict=False)\n .alias('parsed EventTime')\n))\n\n" }, { "answer_id": 74392290, "author": "Dean MacGregor", "author_id": 1818713, "author_profile": "https://Stackoverflow.com/users/1818713", "pm_score": 0, "selected": false, "text": "df['col']=" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6377312/" ]
74,385,500
<p>I recently started learning .NET and am currently learning to build applications using .NET MAUI.</p> <p>At the moment, I am following <a href="https://learn.microsoft.com/en-us/training/paths/build-apps-with-dotnet-maui/" rel="nofollow noreferrer">Build mobile and desktop apps with .NET MAUI</a></p> <p>When running the .NET MAUI application that is created when creating a new project in Visual Studio, it is able to run and build fine for the windows machine. But when I try to run the android emulator, &quot;Pixel 5 - API 33 (Android 13.0 - API 33)&quot;, it starts the emulator but fails the build for the application.</p> <p>I tried deleting the emulator and redownloading it again to see if it would work but I got the same problem.</p> <p>Additionally, these are the logs when I try to build application and the target is the android emulator.</p> <p><code>Build started... 1&gt;------ Build started: Project: MauiApp1, Configuration: Debug Any CPU ------ Starting emulator pixel_5_-_api_33 ... 1&gt;C:\Program Files\dotnet\sdk\7.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(376,5): error NETSDK1127: The targeting pack Microsoft.Android is not installed. Please restore and try again. 1&gt;C:\Program Files\dotnet\sdk\7.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(376,5): error NETSDK1127: The targeting pack Microsoft.Maui.Core is not installed. Please restore and try again. 1&gt;C:\Program Files\dotnet\sdk\7.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(376,5): error NETSDK1127: The targeting pack Microsoft.Maui.Controls is not installed. Please restore and try again. 1&gt;C:\Program Files\dotnet\sdk\7.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(376,5): error NETSDK1127: The targeting pack Microsoft.Maui.Essentials is not installed. Please restore and try again. 1&gt;Done building project &quot;MauiApp1.csproj&quot; -- FAILED. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== ========== Elapsed 00:00.468 ========== ========== Deploy: 0 succeeded, 0 failed, 0 skipped ========== ========== Elapsed 00:00.468 ========== C:\Program Files (x86)\Android\android-sdk\emulator\emulator.EXE -netfast -accel on -avd pixel_5_-_api_33 -prop monodroid.avdname=pixel_5_-_api_33 Emulator pixel_5_-_api_33 is running.</code></p> <p><strong>Update:</strong> I decided to create a new project and it was able to run fine. I'm not sure why it didn't work previously but when I looked at the live visual tree the component of the app wouldn't show up so I think that might have something to do with it.</p>
[ { "answer_id": 74385727, "author": "4pi", "author_id": 2450246, "author_profile": "https://Stackoverflow.com/users/2450246", "pm_score": 1, "selected": false, "text": "df = pl.DataFrame({\n\"col\": [\"00000001011970\", \"00000001011970\", \"00000001011970\"]\n})\nprint(df.with_column(\n pl.col('col')\n .str\n .strptime(pl.Datetime, fmt='%S%M%H%d%m%Y',strict=False)\n .alias('parsed EventTime')\n))\n\n" }, { "answer_id": 74392290, "author": "Dean MacGregor", "author_id": 1818713, "author_profile": "https://Stackoverflow.com/users/1818713", "pm_score": 0, "selected": false, "text": "df['col']=" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,385,502
<p>I'm following the theming tutorial from <a href="https://developer.android.com/codelabs/basic-android-kotlin-compose-practice-superheroes?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-compose-unit-3-pathway-3%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-compose-practice-superheroes#4" rel="nofollow noreferrer">developer.google</a>. I'm trying to migrate the app to Mat. 3 and modify the status bar's color to match with the background color.</p> <ul> <li><p>After adding <code>android:statusBarColor</code> and <code>android:windowLightStatusBar</code>, nothing changes.</p> </li> <li><p>I noticed that at the very first moments the app loading, status bar is really as my expected, but a moment later it becomes wrong.</p> </li> </ul> <p>Before: <a href="https://i.stack.imgur.com/i43cL.png" rel="nofollow noreferrer">https://i.stack.imgur.com/i43cL.png</a></p> <p>After: <a href="https://i.stack.imgur.com/kMwaP.png" rel="nofollow noreferrer">https://i.stack.imgur.com/kMwaP.png</a></p> <p>What I've tried:</p> <pre><code>// res/values/themes.xml &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;resources&gt; &lt;style name=&quot;Theme.Superheroes&quot; parent=&quot;android:Theme.Material.Light.NoActionBar&quot;&gt; &lt;item name=&quot;android:statusBarColor&quot;&gt;@color/background_light&lt;/item&gt; &lt;item name=&quot;android:windowLightStatusBar&quot;&gt;true&lt;/item&gt; &lt;item name=&quot;android:windowBackground&quot;&gt;@color/background_light&lt;/item&gt; &lt;/style&gt; &lt;/resources&gt; </code></pre> <pre><code>// res/values-night/themes.xml &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;resources&gt; &lt;style name=&quot;Theme.Superheroes&quot; parent=&quot;android:Theme.Material.NoActionBar&quot;&gt; &lt;item name=&quot;android:statusBarColor&quot;&gt;@color/background_dark&lt;/item&gt; &lt;item name=&quot;android:windowLightStatusBar&quot;&gt;false&lt;/item&gt; &lt;item name=&quot;android:windowBackground&quot;&gt;@color/background_dark&lt;/item&gt; &lt;/style&gt; &lt;/resources&gt; </code></pre>
[ { "answer_id": 74386758, "author": "Code Poet", "author_id": 5513788, "author_profile": "https://Stackoverflow.com/users/5513788", "pm_score": 2, "selected": false, "text": "implementation \"com.google.accompanist:accompanist-systemuicontroller:0.27.0\"" }, { "answer_id": 74390372, "author": "VanSuTuyDuyen", "author_id": 14123115, "author_profile": "https://Stackoverflow.com/users/14123115", "pm_score": 0, "selected": false, "text": "ui.theme/Theme.kt" }, { "answer_id": 74390757, "author": "Chris", "author_id": 2199001, "author_profile": "https://Stackoverflow.com/users/2199001", "pm_score": 1, "selected": false, "text": "themes.xml" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14123115/" ]
74,385,525
<p>I have a file named <code>input.txt</code>.</p> <pre><code>name=&quot;XYZ_PP_0&quot; number=&quot;0x12&quot; bytesize=&quot;4&quot; info=&quot;0x00000012&quot; name=&quot;GK_LMP_2_0&quot; number=&quot;0xA5&quot; bytesize=&quot;8&quot; info=&quot;0x00000000bbae321f&quot; name=&quot;MP_LKO_1_0&quot; number=&quot;0x356&quot; bytesize=&quot;4&quot; info=&quot;0x00000234&quot; name=&quot;PNP_VXU_1_2_0&quot; number=&quot;0x48A&quot; bytesize=&quot;8&quot; info=&quot;0x00000000a18c3ba3&quot; name=&quot;AVU_W_2_3_1&quot; number=&quot;0x867&quot; bytesize=&quot;1&quot; info=&quot;0x0b&quot; </code></pre> <p>From this file i need to create another file <code>output.txt</code>. in this file if <code>bytesize=&quot;8&quot;</code> then <code>info</code> is split in to two.</p> <p>eg: <strong>number=&quot;0x48A&quot; bytesize=&quot;8&quot; info=&quot;0x00000000a18c3ba3&quot;</strong></p> <p>then output file will contain:</p> <pre><code>name=&quot;PNP_VXU_1_2_0_LOW&quot; number=&quot;0x48A&quot; info=&quot;0xa18c3ba3&quot; name=&quot;PNP_VXU_1_2_0_HIGH&quot; number=&quot;0x4BC&quot; info=&quot;0x00000000&quot; </code></pre> <p>where 0x4BC = 0x48A + 0x32</p> <p>this is current code:</p> <pre><code>import re infile_path = &quot;./input.txt&quot; outfile_path = &quot;./output.txt&quot; with open(infile_path, &quot;r&quot;) as infile, open(outfile_path, &quot;w&quot;) as outfile: for s in infile: r = re.match('number=&quot;(.*)&quot; bytesize=&quot;(.*)&quot; info=&quot;(.*)&quot;', s) if r: num, bs, info = map(lambda x: int(x, 0), r.groups()) l = len(r.group(3)) - 2 if bs == 8: l = 8 nums = (num, num + 0x32) infos = (info % (2**32), info // (2**32)) else: nums = (num, ) infos = (info, ) for num, info in zip(nums, infos): outfile.write(f'number=&quot;{num:#x}&quot; info=&quot;{info:#0{l+2}x}&quot;\n') </code></pre> <p><code>output.txt</code> for this code:</p> <pre><code>number=&quot;0x12&quot; info=&quot;0x00000012&quot; number=&quot;0xA5&quot; info=&quot;0xbbae321f&quot; number=&quot;0xD7&quot; info=&quot;0x00000000&quot; number=&quot;0x356&quot; info=&quot;0x00000234&quot; number=&quot;0x48A&quot; info=&quot;0xa18c3ba3&quot; number=&quot;0x4BC&quot; info=&quot;0x00000000&quot; number=&quot;0x867&quot; info=&quot;0x0b&quot; </code></pre> <p><strong>Expected Output:</strong></p> <pre><code>name=&quot;XYZ_PP_0&quot; number=&quot;0x12&quot; info=&quot;0x00000012&quot; name=&quot;GK_LMP_2_0_LOW&quot; number=&quot;0xA5&quot; info=&quot;0xbbae321f&quot; name=&quot;GK_LMP_2_0_HIGH&quot;number=&quot;0xD7&quot; info=&quot;0x00000000&quot; name=&quot;MP_LKO_1_0&quot; number=&quot;0x356&quot; info=&quot;0x00000234&quot; name=&quot;PNP_VXU_1_2_0_LOW&quot; number=&quot;0x48A&quot; info=&quot;0xa18c3ba3&quot; name=&quot;PNP_VXU_1_2_0_HIGH&quot; number=&quot;0x4BC&quot; info=&quot;0x00000000&quot; name=&quot;AVU_W_2_3_1&quot; number=&quot;0x867&quot; info=&quot;0x0b&quot; </code></pre> <p>How can i add the <strong>LOW</strong> and <strong>HIGH</strong> to the name if byte size is 8?</p>
[ { "answer_id": 74386758, "author": "Code Poet", "author_id": 5513788, "author_profile": "https://Stackoverflow.com/users/5513788", "pm_score": 2, "selected": false, "text": "implementation \"com.google.accompanist:accompanist-systemuicontroller:0.27.0\"" }, { "answer_id": 74390372, "author": "VanSuTuyDuyen", "author_id": 14123115, "author_profile": "https://Stackoverflow.com/users/14123115", "pm_score": 0, "selected": false, "text": "ui.theme/Theme.kt" }, { "answer_id": 74390757, "author": "Chris", "author_id": 2199001, "author_profile": "https://Stackoverflow.com/users/2199001", "pm_score": 1, "selected": false, "text": "themes.xml" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20273554/" ]
74,385,530
<p>I want to construct a 6X6 symmetric matrix A of rank 3 in MATLAB. any suggestions?</p> <p>tried different ways, couldn't end up with expected result</p>
[ { "answer_id": 74385870, "author": "flawr", "author_id": 2913106, "author_profile": "https://Stackoverflow.com/users/2913106", "pm_score": 1, "selected": false, "text": "diag" }, { "answer_id": 74385926, "author": "ThomasIsCoding", "author_id": 12158757, "author_profile": "https://Stackoverflow.com/users/12158757", "pm_score": 2, "selected": false, "text": "H" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20466096/" ]
74,385,545
<p>my scenario: I have an existing unit test framework with ~3000 individual test cases. They are made from TEST, TEST_F and TEST_P macros. Internally the tested modules make use of a logger library and now my goal is to create individual log files for each test case. To do so I would like to call a function as a SetUp for each test case. Is there a way to register such function at the framework and get it called automatically? The obvious solution for me would look like: do the work in a test fixture constructor or SetUp() but then I'd have to touch every single test case. I do like the idea of registering a global setup at the framework with AddGlobalTestEnvironment() but as I understand this is handled only once per executable.</p> <p>By the way: I have acceptance tests implemented in robot test and guess what? I want to repeat the task there...</p> <p>Thanks for any inspiration! Christoph</p>
[ { "answer_id": 74385870, "author": "flawr", "author_id": 2913106, "author_profile": "https://Stackoverflow.com/users/2913106", "pm_score": 1, "selected": false, "text": "diag" }, { "answer_id": 74385926, "author": "ThomasIsCoding", "author_id": 12158757, "author_profile": "https://Stackoverflow.com/users/12158757", "pm_score": 2, "selected": false, "text": "H" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385545", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11415117/" ]
74,385,548
<p>List Values</p> <pre><code>49 873 50 575 51 487 52 B000XPZCXW 53 B098LPQ5LM 54 B09W5S7GFK </code></pre> <p>All the values starting with 'B' need to converted into 1</p> <p>Output</p> <pre><code>49 873 50 575 51 487 52 1 53 1 54 1 </code></pre> <p>I was hoping to use 'startswith' lambda function</p>
[ { "answer_id": 74385870, "author": "flawr", "author_id": 2913106, "author_profile": "https://Stackoverflow.com/users/2913106", "pm_score": 1, "selected": false, "text": "diag" }, { "answer_id": 74385926, "author": "ThomasIsCoding", "author_id": 12158757, "author_profile": "https://Stackoverflow.com/users/12158757", "pm_score": 2, "selected": false, "text": "H" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20466110/" ]
74,385,594
<p>I am working on standard logic apps. In that I am not able to use the XSLT2.0 and XSLT 3.0. The Standard logic app will allows only XSLT1.0 . so what is the best approach to convert XSLT2.0 and XSLT3.0 in to XSLT 1.0</p> <p>I have XSLT3.0 and XSLT 2.0. How should I use those XSLT files in my standard logic app?</p>
[ { "answer_id": 74400701, "author": "pgfearo", "author_id": 63965, "author_profile": "https://Stackoverflow.com/users/63965", "pm_score": 0, "selected": false, "text": "Logic App (Standard) Note: Support for XSLT 2.0/3.0 is in private preview\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20465827/" ]
74,385,608
<p>This is my handleSearch function and i am checking if inputvalue is empty it shouldn't go further and hit my getSearch call, but sometimes if i backspace inputvalue quickly it console.logs(empty) as expected and instead of stopping it goes further n hits getSearch call below.</p> <p><strong>How to make it work correctly if inputvalue is empty.</strong></p> <pre><code> const handleSearch = async (value) =&gt; { setSearchTerm(value); if (value.length &lt;= 0 || value === &quot;&quot;) { console.log(&quot;empty&quot;); setSearchResult([]); return; } console.log(&quot;value&quot;, value); const searchRes = await getSearch(value, 0); console.log(&quot;searchRes&quot;, searchRes); setSearchResult(searchRes); }; </code></pre>
[ { "answer_id": 74400701, "author": "pgfearo", "author_id": 63965, "author_profile": "https://Stackoverflow.com/users/63965", "pm_score": 0, "selected": false, "text": "Logic App (Standard) Note: Support for XSLT 2.0/3.0 is in private preview\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16488075/" ]
74,385,638
<p>I am trying to make VBA to copy data and paste to matching worksheet name.</p> <ol> <li>&quot;Setting&quot; Worksheet will have all mixed data of item types.</li> <li>With VBA, copy &amp; paste values on A &amp; D columns to matching worksheet name.</li> <li>VBA code will go through entire A7 -&gt; lastrow</li> </ol> <p>worksheet name is based on the item types.</p> <p><a href="https://i.stack.imgur.com/2KM0S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2KM0S.png" alt="enter image description here" /></a></p> <hr /> <p><strong>Right now, I am stuck on this part - setting supplier as dynamic worksheet</strong></p> <p>Below is the issue area: &quot;out of range&quot;</p> <pre><code>For i = 7 To lastrow1 'setting spl as the value of the item type spl = Cells(i, &quot;A&quot;).Value 'setting supplier as the worksheet name Set supplier = Sheets(spl) </code></pre> <hr /> <p>Below is the entire VBA code: I have found an existing code, and had been tweaking to fit my usage.</p> <pre><code>Sub Copy_Data() Dim lastrow1 As Long, i As Long, auxRow As Long, offsetRow As Long Dim spl As String Dim supplier As Worksheet Set ws = Sheets(&quot;SETTING&quot;) lastrow1 = ws.Columns(&quot;A&quot;).Find(&quot;*&quot;, searchorder:=xlByRows, searchdirection:=xlPrevious).Row For i = 7 To lastrow1 'setting spl as the value of the item type spl = Cells(i, &quot;A&quot;).Value 'setting supplier as the worksheet name Set supplier = Sheets(spl) auxRow = supplier.Columns(&quot;A&quot;).Find(&quot;*&quot;, searchorder:=xlByRows, searchdirection:=xlPrevious).Row If auxRow &gt; 1 Then auxRow = auxRow + 1 If auxRow = 1 Then auxRow = offsetRow supplier.Cells(auxRow, &quot;A&quot;) = ws.Cells(i, &quot;A&quot;) supplier.Cells(auxRow, &quot;B&quot;) = ws.Cells(i, &quot;D&quot;) Next i End Sub </code></pre> <p>Thank you all in an advance.</p> <p>I have tried to define the worksheet to have dynamic value - based on item type on column A.</p> <p>But keep receiving 'out of range' when setting the worksheet.</p>
[ { "answer_id": 74386959, "author": "FaneDuru", "author_id": 2233308, "author_profile": "https://Stackoverflow.com/users/2233308", "pm_score": 0, "selected": false, "text": "Sub distributeIssues()\n Dim shS As Worksheet, lastR As Long, wb As Workbook, arr, arrIt, arrFin, i As Long\n Dim key, dict As Object\n \n Set wb = ThisWorkbooks\n Set shS = wb.Sheets(\"SETTING\")\n lastR = shS.Range(\"A\" & shS.rows.count).End(xlUp).row 'last row\n \n arr = shS.Range(\"A7:D\" & lastR).Value2 'place the range in an array for faster iteration/processing\n \n 'place the range to be processed in dictionary:\n Set dict = CreateObject(\"Scripting.Dictionary\")\n For i = 1 To UBound(arr) 'iterate between the array rows\n If Not dict.Exists(arr(i, 1)) Then 'if key does not exist\n dict.Add arr(i, 1), Array(arr(i, 4)) 'create it and place the value in D:D as array item\n Else\n arrIt = dict(arr(i, 1)) 'place the item content in an array\n ReDim Preserve arrIt(UBound(arrIt) + 1) 'extend the array with an element\n arrIt(UBound(arrIt)) = arr(i, 4) 'place value from D:D in the last element\n dict(arr(i, 1)) = arrIt 'place back the array as dictionary item\n End If\n Next i\n 'Stop\n 'drop the necessary value in the appropriate sheet:\n Application.ScreenUpdating = False: Application.Calculation = xlCalculationManual\n For Each key In dict\n With wb.Worksheets(key).Range(\"B9\").Resize(UBound(dict(key)) + 1, 1)\n .Value = Application.Transpose(dict(key))\n .Offset(, -1).Value = key\n End With\n Next key\n Application.ScreenUpdating = True: Application.Calculation = xlCalculationAutomatic\n \n MsgBox \"Ready...\"\nEnd Sub\n" }, { "answer_id": 74387755, "author": "cooogeee", "author_id": 3003395, "author_profile": "https://Stackoverflow.com/users/3003395", "pm_score": 2, "selected": true, "text": "ws.Columns(\"A\").Find(\"*\", searchorder:=xlByRows, earchdirection:=xlPrevious).Row\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13987475/" ]
74,385,639
<p><strong>Unable to covert Json to Dataframe, the following TypeError shows :</strong></p> <p>The following data is created</p> <pre><code>Test_data = {'archived': False, 'archived_at': None, 'associations': None, 'created_at': datetime.datetime(2020, 10, 30, 8, 3, 54, 190000, tzinfo=tzlocal()), 'id': '12345', 'properties': {'createdate': '[![2020-10-30T08:03:54.190Z][1]][1]', 'email': 'testmail@gmail.com', 'firstname': 'TestFirst', 'lastname': 'TestLast'}, 'properties_with_history': None, 'updated_at': datetime.datetime(2022, 11, 10, 6, 44, 14, 5000, tzinfo=tzlocal())} data = json.loads(test_data) </code></pre> <p><em>TypeError: the JSON object must be str, bytes or bytearray, not SimplePublicObjectWithAssociations</em></p> <p><strong>The following has been tried:</strong></p> <pre><code>s1 = json.dumps(test_data) d2 = json.loads(s1) </code></pre> <p><em>TypeError: Object of type SimplePublicObjectWithAssociations is not JSON serializable</em></p> <p><strong>Prefered Output :</strong></p> <p><img src="https://i.stack.imgur.com/vXYhf.png" alt="Text" /></p>
[ { "answer_id": 74385705, "author": "Bushmaster", "author_id": 15415267, "author_profile": "https://Stackoverflow.com/users/15415267", "pm_score": 2, "selected": false, "text": "df=pd.json_normalize(Test_data)\nprint(df)\n'''\n archived archived_at associations created_at id properties_with_history updated_at properties.createdate properties.email properties.firstname\n0 False None None 2020-10-30T08:03:54.190Z 12345 2022-11-10T06:44:14.500Z [![2020-10-30T08:03:54.190Z][1]][1] testmail@gmail.com TestFirst\n\n'''\n" }, { "answer_id": 74386481, "author": "Ljg", "author_id": 13603339, "author_profile": "https://Stackoverflow.com/users/13603339", "pm_score": 0, "selected": false, "text": "import pandas as pd \nimport datetime\nimport json\nimport jsonpickle\n\ntest_data ={'archived': False,\n'archived_at': None,\n'associations': None,\n'created_at': datetime.datetime(2020, 10, 30, 8, 3, 54, 190000),\n'id': '12345',\n'properties': {'createdate': '[![2020-10-30T08:03:54.190Z][1]][1]',\n 'email': 'testmail@gmail.com',\n 'firstname': 'TestFirst',\n 'lastname': 'TestLast'},\n'properties_with_history': None,\n'updated_at': datetime.datetime(2022, 11, 10, 6, 44, 14, 5000)}\n\n\ndata = jsonpickle.encode(test_data, unpicklable=False)\npd.read_json(data)\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15571878/" ]
74,385,642
<p>I would like to convert it to vector of vectors but I'm confused about the code above it's better to store it on stack rather than heap, that's why I want to change it to vector of vector</p> <pre><code>std::vector&lt;DPoint*&gt;* pixelSpacing; ///&lt; vector of slice pixel spacings pixelSpacing = new std::vector&lt;DPoint*&gt;(volume.pixelSpacing-&gt;size()); for (unsigned int i = 0; i &lt; pixelSpacing-&gt;size(); i++) { (*pixelSpacing)[i] = new DPoint(*(*volume.pixelSpacing)[i]); } </code></pre>
[ { "answer_id": 74385705, "author": "Bushmaster", "author_id": 15415267, "author_profile": "https://Stackoverflow.com/users/15415267", "pm_score": 2, "selected": false, "text": "df=pd.json_normalize(Test_data)\nprint(df)\n'''\n archived archived_at associations created_at id properties_with_history updated_at properties.createdate properties.email properties.firstname\n0 False None None 2020-10-30T08:03:54.190Z 12345 2022-11-10T06:44:14.500Z [![2020-10-30T08:03:54.190Z][1]][1] testmail@gmail.com TestFirst\n\n'''\n" }, { "answer_id": 74386481, "author": "Ljg", "author_id": 13603339, "author_profile": "https://Stackoverflow.com/users/13603339", "pm_score": 0, "selected": false, "text": "import pandas as pd \nimport datetime\nimport json\nimport jsonpickle\n\ntest_data ={'archived': False,\n'archived_at': None,\n'associations': None,\n'created_at': datetime.datetime(2020, 10, 30, 8, 3, 54, 190000),\n'id': '12345',\n'properties': {'createdate': '[![2020-10-30T08:03:54.190Z][1]][1]',\n 'email': 'testmail@gmail.com',\n 'firstname': 'TestFirst',\n 'lastname': 'TestLast'},\n'properties_with_history': None,\n'updated_at': datetime.datetime(2022, 11, 10, 6, 44, 14, 5000)}\n\n\ndata = jsonpickle.encode(test_data, unpicklable=False)\npd.read_json(data)\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/375666/" ]
74,385,643
<p>i am trying to update the state of the animated switcher in the middle area. i am trying to do this using a setstate in the lower area. but it does not work.</p> <ol> <li>the first thing i did is to create a variable with a boolean data type in the home class.</li> <li>then i passed the variable to both the middle area and the lower area</li> <li>the idea was that if the same variable is passed to the class whose state i am trying to update, and the class with the set state, it would work. but it seems i am wrong. i would appreciate some assistance. the boolean variable i am trying to make work is the _rep variable</li> </ol> <p>This is the Home widget</p> <pre><code>class HomePage extends StatefulWidget { const HomePage({Key? key}) : super(key: key); @override State&lt;HomePage&gt; createState() =&gt; _HomePageState(); } class _HomePageState extends State&lt;HomePage&gt; with TickerProviderStateMixin { late AnimationController _animationController; late AnimationController _controller; late Animation&lt;Offset&gt; _animation; late Animation&lt;Offset&gt; _anime; bool _rep = true; @override void initState() { _animationController = AnimationController( vsync: this, duration: Duration(seconds: 2) ); _animation = Tween&lt;Offset&gt;( begin:Offset (0.0, 0.0), end: Offset (0.0,3.0), ).animate(CurvedAnimation( parent: _animationController, curve: Curves.easeIn)); _anime = Tween&lt;Offset&gt;( begin:Offset (0.0, 0.0), end: Offset (0.0,-0.55), ).animate(CurvedAnimation( parent: _animationController, curve: Curves.easeIn)); super.initState(); } @override void dispose() { _animationController.dispose(); _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( body: SingleChildScrollView( scrollDirection: Axis.vertical, physics: const NeverScrollableScrollPhysics(), child: Padding( padding: EdgeInsets.only(top: 3.h), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ TopIcon(icons: Icons.arrow_back, color:Colors.grey.shade300 ,), SizedBox( height: 13.h, width: 13.w, child: Image.asset('assets/images/download.png') ), TopIcon(icons: Icons.shopping_bag_outlined, color: Colors.grey.shade300,), ], ), SizedBox( height: 3.h, ), Text('Frappuccino', style: TextStyle( fontSize: 27.sp, fontWeight: FontWeight.bold ), ), Padding( padding: const EdgeInsets.all(8.0), child: Text('White Chocolate', style: TextStyle( fontWeight: FontWeight.bold, color: Colors.grey.shade400 ), ), ), MiddleArea( controller: _animationController, animation: _animation, rep: _rep, ), LowerArea(controller: _animationController, anime: _anime, rep = _rep), ], ), ), ), ); } } </code></pre> <p>This is the middle area</p> <pre><code>class MiddleArea extends StatefulWidget { MiddleArea({Key? key, required this.controller, required this.animation, required this.rep}) : super(key: key); AnimationController controller; Animation&lt;Offset&gt; animation; final bool rep; @override State&lt;MiddleArea&gt; createState() =&gt; _MiddleAreaState(); } class _MiddleAreaState extends State&lt;MiddleArea&gt; { bool _flag = true; bool _favourite = true; @override Widget build(BuildContext context) { print(widget.rep); return SizedBox( height: 52.h, child: Stack( children: [ Column( children: [ Padding( padding: const EdgeInsets.only(top: 135.0), child: Text('STARBUCKS', style: TextStyle( fontFamily: 'Typette', color: Colors.brown.shade200, fontSize: 30.sp, fontWeight: FontWeight.w400 ), ), ), Text('STARBUCKS', style: TextStyle( fontFamily: 'Typette', color: Colors.brown.shade100, fontSize: 30.sp, fontWeight: FontWeight.w400 ), ), Text('STARBUCKS', style: TextStyle( fontFamily: 'Typette', color: Colors.brown.shade50, fontSize: 30.sp, fontWeight: FontWeight.w400 ), ), ], ), Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: const [ SizeAndFave(text: 'Preference'), SizeAndFave(text: 'Fave!') ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ GestureDetector( onTap: (){ setState(() { _flag = !_flag; }); }, child: AnimatedSwitcher( duration: const Duration(milliseconds: 500), transitionBuilder: (Widget child, Animation&lt;double&gt; animation){ return FadeTransition(opacity: animation, child: child,); }, child: widget.rep == true?Padding( padding: const EdgeInsets.all(14.0), key: const Key('1'), child: Container( height: 40, width: 40, decoration: BoxDecoration( border: Border.all( color: Colors.brown.shade300, width: 3 ), borderRadius: BorderRadius.circular(10) ), child: const Center( child: Icon( Icons.coffee_outlined, size: 20, ), ) ), ):null, ) ), GestureDetector( onTap: (){ setState(() { _favourite = !_favourite; }); }, child: _favourite? TopIcon(icons: Icons.favorite_border, color: Colors.brown.shade300) :TopIcon( icons: Icons.favorite, color: Colors.brown.shade300) ) ], ) ], ), AnimatedSwitcher( duration: Duration(seconds: 1), transitionBuilder: (Widget child, Animation&lt;double&gt; animation) { return FadeTransition( opacity: animation, child: child); }, child: _flag == true ? Center( key: const Key('1'), child: SlideTransition( position: widget.animation, child: SizedBox( height: 80.h, width: 80.w, child: Image.asset('assets/images/starcup.png'), ), ), ):Center( key: const Key('2'), child: SlideTransition( position: widget.animation, child: SizedBox( height: 80.h, width: 80.w, child: Image.asset('assets/images/greeen.png'), ), ), ), ), Positioned( child: Align( alignment: Alignment.bottomRight, child: Padding( padding: EdgeInsets.only(top: 30.h), child: TopIcon( icons: Icons.car_crash_outlined, color: Colors.brown.shade300), ), )), const Positioned( child: Align( alignment: Alignment.bottomLeft, child: Padding( padding: EdgeInsets.only(top: 330.0, left: 14), child: Text('\$ 5.99', style: TextStyle( fontSize: 27, fontWeight: FontWeight.bold ), ), ), )) ], ), ); } } </code></pre> <p>and lastly, the lower area</p> <pre><code>class LowerArea extends StatefulWidget { final AnimationController controller; final Animation&lt;Offset&gt; anime; bool rep; LowerArea({Key? key, required this.controller, required this.anime, required this.rep}) : super(key: key); @override State&lt;LowerArea&gt; createState() =&gt; _LowerAreaState(); } class _LowerAreaState extends State&lt;LowerArea&gt; { bool _bigger = true; bool _fade = true; void move(){ } @override Widget build(BuildContext context) { return Column( children: [ Container( child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: EdgeInsets.all(1.h), child: const Text('Tall Frappuccino', style: TextStyle( fontWeight: FontWeight.w500 ), ), ), Padding( padding: EdgeInsets.only(right: 5.h), child: const Text('Swipe Down', style: TextStyle( fontWeight: FontWeight.w500 ), ), ), Padding( padding: EdgeInsets.all(2.h), child: const Text('Pickup', style: TextStyle( fontWeight: FontWeight.w500 ), ), ) ], ), ), SlideTransition( position: widget.anime, child: AnimatedContainer( // height: 11.h, width: _bigger ? 35.h: 80.h, duration: const Duration(milliseconds: 500), child: Stack( fit: StackFit.loose, children: [ Center(child: Image.asset('assets/images/baggie.png')), Center( child: Padding( padding: EdgeInsets.only(bottom: 4.h), child: GestureDetector( onTap: (){ widget.controller.forward(); setState(() { _bigger = !_bigger; _fade = !_fade; widget.rep = !widget.rep; print('this is fade $_fade '); }); }, child: AnimatedSwitcher( duration: Duration(milliseconds: 300), transitionBuilder: (Widget child, Animation&lt;double&gt; animation){ return FadeTransition(opacity: animation, child: child,); }, child: _fade? Container( key: Key('1'), height: 8.h, width: 7.w, decoration: BoxDecoration( color: Colors.black, borderRadius: BorderRadius.circular(15) ), child: Column( children: [ Padding( padding: EdgeInsets.all(0.3.h), child: Icon( Icons.lock_outline, color: Colors.white54, size: 2.5.h, ), ), Icon( Icons.arrow_drop_down, color: Colors.white12, size: 3.h, ), ], ), ):null, ), ), ), ) ], ), ), ) ], ); } </code></pre>
[ { "answer_id": 74385705, "author": "Bushmaster", "author_id": 15415267, "author_profile": "https://Stackoverflow.com/users/15415267", "pm_score": 2, "selected": false, "text": "df=pd.json_normalize(Test_data)\nprint(df)\n'''\n archived archived_at associations created_at id properties_with_history updated_at properties.createdate properties.email properties.firstname\n0 False None None 2020-10-30T08:03:54.190Z 12345 2022-11-10T06:44:14.500Z [![2020-10-30T08:03:54.190Z][1]][1] testmail@gmail.com TestFirst\n\n'''\n" }, { "answer_id": 74386481, "author": "Ljg", "author_id": 13603339, "author_profile": "https://Stackoverflow.com/users/13603339", "pm_score": 0, "selected": false, "text": "import pandas as pd \nimport datetime\nimport json\nimport jsonpickle\n\ntest_data ={'archived': False,\n'archived_at': None,\n'associations': None,\n'created_at': datetime.datetime(2020, 10, 30, 8, 3, 54, 190000),\n'id': '12345',\n'properties': {'createdate': '[![2020-10-30T08:03:54.190Z][1]][1]',\n 'email': 'testmail@gmail.com',\n 'firstname': 'TestFirst',\n 'lastname': 'TestLast'},\n'properties_with_history': None,\n'updated_at': datetime.datetime(2022, 11, 10, 6, 44, 14, 5000)}\n\n\ndata = jsonpickle.encode(test_data, unpicklable=False)\npd.read_json(data)\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17905117/" ]
74,385,661
<p>How can I properly implement the use of git ignore to not commit .json files to my repository?</p> <p>I tried watching a youtube video for help, but after following his tips my json file is still being uploaded.</p>
[ { "answer_id": 74385704, "author": "ThisQRequiresASpecialist", "author_id": 19381612, "author_profile": "https://Stackoverflow.com/users/19381612", "pm_score": 2, "selected": false, "text": ".gitignore" }, { "answer_id": 74385796, "author": "Zita", "author_id": 16533015, "author_profile": "https://Stackoverflow.com/users/16533015", "pm_score": 1, "selected": false, "text": "*" }, { "answer_id": 74385905, "author": "kosist", "author_id": 6917446, "author_profile": "https://Stackoverflow.com/users/6917446", "pm_score": 1, "selected": false, "text": ".gitignore" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20466185/" ]
74,385,706
<p>I try to debug an app inside of the container and I need to run django to run tests I do that by:</p> <pre><code>docker-compose exec django bash </code></pre> <p>But as a result I get:</p> <pre><code>service &quot;django&quot; is not running container #1 </code></pre> <p>I don't really understand what this response means and I didn't find any information regarding that. This issue prevents me from being able to debug a code inside of the container with the database up and running.</p>
[ { "answer_id": 74385942, "author": "labs", "author_id": 20220951, "author_profile": "https://Stackoverflow.com/users/20220951", "pm_score": -1, "selected": false, "text": "ALLOWED_HOSTS = ['*']\n" }, { "answer_id": 74388207, "author": "Inopsek", "author_id": 20330613, "author_profile": "https://Stackoverflow.com/users/20330613", "pm_score": 0, "selected": false, "text": "docker exec -ti django bin/bash\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4307022/" ]
74,385,708
<p>I have to retuen the message &quot;Data Added&quot; in the api in ResponseBody Create a api while enters student data /newStudent</p> <p>Request Body:</p> <pre><code>{ &quot;name&quot;:&quot;Shubham&quot;, &quot;rollno&quot;:22, &quot;studentid&quot;:1 } </code></pre> <p>Response:</p> <pre><code>{ &quot;status&quot;:&quot;OK&quot;, &quot;message&quot;:&quot;Data Added&quot; } </code></pre> <hr /> <pre><code>@RequestMapping(&quot;/studentdata&quot;) @ResponseBody @ResponseStatus(HttpStatus.OK ) </code></pre>
[ { "answer_id": 74385763, "author": "YCF_L", "author_id": 5558072, "author_profile": "https://Stackoverflow.com/users/5558072", "pm_score": 2, "selected": false, "text": "class CustomResponse {\n private String status;\n private String message;\n // Constructor/Getters/Setters\n}\n" }, { "answer_id": 74385791, "author": "Ali Raza", "author_id": 10115166, "author_profile": "https://Stackoverflow.com/users/10115166", "pm_score": 0, "selected": false, "text": "router.post(\"/newStudent\", async (req, res) => {\n const { name, rollNo, studentId } = req.data;\n\n // POST data to DB\n const result = await AddStudentDataToDB({ name, rollNo, studentId });\n\n res.status(200).json({\n status: 'ok',\n message: 'Data Added'\n });\n});\n" }, { "answer_id": 74386002, "author": "Manir Mahamat", "author_id": 11185081, "author_profile": "https://Stackoverflow.com/users/11185081", "pm_score": 1, "selected": false, "text": "@Data\n@AllArgsConstructor\n@NoArgsConstructor\npublic class Response {\n private String statusCode;\n private String statusMsg;\n}\n" }, { "answer_id": 74392430, "author": "Banky Alani", "author_id": 10365095, "author_profile": "https://Stackoverflow.com/users/10365095", "pm_score": 0, "selected": false, "text": "import org.json.simple.JSONObject;\n\n@ResponseBody\n@RequestMapping(value = \"/studentdata\", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\npublic String message(@RequestBody String transaction) {\n String response = \"\";\n\n JSONObject obj = new JSONObject();\n obj.put(\"status\", \"OK\");\n obj.put(\"message\", \"Data Added\");\n response = obj.toJSONString();\n \n return response;\n}\n" }, { "answer_id": 74411638, "author": "SHUBHAM SHARMA", "author_id": 19901286, "author_profile": "https://Stackoverflow.com/users/19901286", "pm_score": 0, "selected": false, "text": "public class Response {\n private String statusCode;\n private String statusMsg;\n\n public String getStatusCode() {\n return statusCode;\n }\n\n public void setStatusCode(String statusCode) {\n this.statusCode = statusCode;\n }\n\n public String getStatusMsg() {\n return statusMsg;\n }\n\n public void setStatusMsg(String statusMsg) {\n this.statusMsg = statusMsg;\n }\n}\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19901286/" ]
74,385,709
<p>To debug my <code>C</code> code I compile it with the <code>-g</code> flag and use <code>lldb</code> to see where my <code>seg fault</code> is for example.<br> I use the <code>-g</code> flag so the output of <code>lldb</code> is in <code>C</code> not <code>Assembly</code>.<br> but now I have a multiple files project and <code>lldb</code> shows only <code>Assembly</code> even tho I'm using the <code>-g</code> flag, it's like the <code>-g</code> flag applies only to one file.<br> Example:</p> <pre class="lang-c prettyprint-override"><code>gcc -g example.c lldb a.out &gt;run I get c code here </code></pre> <pre class="lang-c prettyprint-override"><code>gcc -g example1.c example2.c main.c lldb a.out &gt;run I get assembly code here </code></pre> <p>Can anyone tell me what I'm I missing here?<br> and how can I get c code in <code>lldb</code>.</p> <p>Thanks in advance.</p>
[ { "answer_id": 74385774, "author": "Some programmer dude", "author_id": 440558, "author_profile": "https://Stackoverflow.com/users/440558", "pm_score": 3, "selected": true, "text": "run" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12246961/" ]
74,385,716
<p>I have database that looks like this</p> <pre><code>CREATE TABLE code ( id SERIAL, name VARCHAR(255) NOT NULL ); INSERT INTO code (name) VALUES ('random_value1_random'); INSERT INTO code (name) VALUES ('random_value123_random'); CREATE TABLE value ( id SERIAL, name VARCHAR(255) NOT NULL ); INSERT INTO value (name) VALUES ('value1'); INSERT INTO value (name) VALUES ('value123'); UPDATE code SET name = REPLACE(name, SELECT name from value , ''); </code></pre> <p>I want to update my table <code>code</code> to remove a portion of a code and that code is coming from another table. My goal is to update all values of <code>code</code> and remove the portion of the string that matches another value. My end goal is to make all <code>code.name</code> in the example look like: <code>random_random</code> removing the value from the <code>value</code> table.</p> <p>When tried using to replace with a query I get an error:</p> <blockquote> <p>[21000] ERROR: more than one row returned by a subquery used as an expression</p> </blockquote> <p>What is a cleaner better way to do this?</p>
[ { "answer_id": 74386104, "author": "Rik Bradley", "author_id": 10248941, "author_profile": "https://Stackoverflow.com/users/10248941", "pm_score": -1, "selected": false, "text": ";with l as (\n -- Match the longest value first\n select c.id c_id, v.id v_id, ROW_NUMBER () over (partition by c.id order by len(v.name) desc) r\n from code c\n join value v on charindex (v.name, c.name) > 0)\n, l1 as (\n -- Select the longest value first\n select c_id, v_id from l where r = 1\n )\nupdate c set name = REPLACE(c.name, v.name, '')\nfrom l1\njoin code c on c.id = l1.c_id\njoin value v on v.id = l1.v_id\n" }, { "answer_id": 74386120, "author": "Thorsten Kettner", "author_id": 2270762, "author_profile": "https://Stackoverflow.com/users/2270762", "pm_score": 2, "selected": true, "text": "REGEXP_REPLACE" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4452553/" ]
74,385,724
<pre><code>mydata = [{'ID' : '10', 'StartDate': '10/10/2016', 'EndDate': '15/10/2016'}, {'ID' : '20', 'StartDate': '10/10/2016', 'EndDate': '18/10/2016'}] df = pd.DataFrame(mydata) df['StartDate'] = pd.to_datetime(df['StartDate']).dt.date df['EndDate'] = pd.to_datetime(df['EndDate']).dt.date df = df.loc[df.index.repeat((df['EndDate'] - df['StartDate']).dt.days + 1)] df['Date'] = df['StartDate'] + pd.to_timedelta(df.groupby(level=0).cumcount(), unit='d') </code></pre> <p>I am getting Performance warning :</p> <blockquote> <p>PerformanceWarning: Adding/subtracting object-dtype array to TimedeltaArray not vectorized.</p> </blockquote> <p>What can I do to make it vectorized?</p>
[ { "answer_id": 74386104, "author": "Rik Bradley", "author_id": 10248941, "author_profile": "https://Stackoverflow.com/users/10248941", "pm_score": -1, "selected": false, "text": ";with l as (\n -- Match the longest value first\n select c.id c_id, v.id v_id, ROW_NUMBER () over (partition by c.id order by len(v.name) desc) r\n from code c\n join value v on charindex (v.name, c.name) > 0)\n, l1 as (\n -- Select the longest value first\n select c_id, v_id from l where r = 1\n )\nupdate c set name = REPLACE(c.name, v.name, '')\nfrom l1\njoin code c on c.id = l1.c_id\njoin value v on v.id = l1.v_id\n" }, { "answer_id": 74386120, "author": "Thorsten Kettner", "author_id": 2270762, "author_profile": "https://Stackoverflow.com/users/2270762", "pm_score": 2, "selected": true, "text": "REGEXP_REPLACE" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17900863/" ]
74,385,744
<p>having issues uploading file from NodeJs server side, found 100 posts and reasearches but nothing works, would appreciate any help.</p> <p><strong>Structure of the App</strong></p> <ol> <li><p>Front App - React Admin framework receving file and i encode in base64 the content of the image to send to API</p> </li> <li><p>Backend - NestJS App - receving base64 image in API</p> </li> <li><p>From my backend API need to send file to an external backend (Python API) to upload - here is the problem</p> </li> </ol> <p>Please see below my code, something wrong with the file from JS</p> <p>i have tried several methods and all of them ends in same error</p> <p><strong>1 solution</strong></p> <ul> <li>converting base64 image in buffer and send to external backend to upload the file</li> <li>have tried to pass as well cleanImageBuffer but no changes</li> </ul> <pre><code>import axios from 'axios'; import FormData from 'form-data'; export async function upload( fileBase64: string, filename: string ): Promise&lt;any&gt; { const buffer = Buffer.from(fileBase64, 'base64') const extension = fileBase64.substring(fileBase64.indexOf('/') + 1, fileBase64.indexOf(&quot;;base64&quot;)) const cleanBase64 = fileBase64.replace(/^data:image\/png;base64,/, '') const cleanImageBuffer = Buffer.from(cleanBase64, 'base64') const formData = new FormData(); // have tried to pass as well cleanImageBuffer but no changes formData.append('file', buffer); formData.append('fileName', filename + '.' + extension); formData.append('namespace', 'test'); return await axios .post('external_api_url', JSON.stringify(formData), { headers: { Authorization: `Bearer token`, ContentType: 'multipart/form-data' } }) .then((response) =&gt; { console.log('response = ' + JSON.stringify(response)) }) </code></pre> <p><strong>result 1 solution</strong></p> <pre><code>{ &quot;status&quot;: &quot;error&quot;, &quot;error&quot;: { &quot;code&quot;: &quot;bad_request&quot;, &quot;message&quot;: &quot;file Expected UploadFile, received: &lt;class 'str'&gt;&quot; } } </code></pre> <p><strong>2 solution</strong></p> <ul> <li>from base64 image received saving on my disk</li> <li>after creating a stream and sending the image</li> </ul> <pre><code>export async function upload ( fileBase64: string, filename: string ): Promise&lt;any&gt; { const extension = fileBase64.substring(fileBase64.indexOf('/') + 1, fileBase64.indexOf(&quot;;base64&quot;)) const cleanBase64 = fileBase64.replace(/^data:image\/png;base64,/, '') const TMP_UPLOAD_PATH = '/tmp' if (!fs.existsSync(TMP_UPLOAD_PATH)) { fs.mkdirSync(TMP_UPLOAD_PATH); } fs.writeFile(TMP_UPLOAD_PATH + '/' + filename + '.' + extension, cleanBase64, 'base64', function(err) { console.log(err); }) const fileStream = fs.createReadStream(TMP_UPLOAD_PATH + '/' + filename + '.' + extension) const formData = new FormData(); formData.append('file', fileStream, filename + '.' + extension); formData.append('fileName', filename + '.' + extension); formData.append('namespace', 'test'); return await axios .post('external_api_url', formData, { headers: { Authorization: `Bearer token`, ContentType: 'multipart/form-data' } }) .then((response) =&gt; { console.log('response = ' + JSON.stringify(response)) }) } </code></pre> <p><strong>result 2 solution</strong></p> <pre><code>{ &quot;status&quot;: &quot;error&quot;, &quot;error&quot;: { &quot;code&quot;: &quot;bad_request&quot;, &quot;message&quot;: &quot;file Expected UploadFile, received: &lt;class 'str'&gt;&quot; } } </code></pre> <p><strong>other solution that ended in same result</strong></p> <ul> <li>tried to use fetch from node-fetch - same result</li> <li>found out that some people had an outdated version of axios and having this issues, i have installed latest axios version 1.1.3 but same result</li> </ul> <p><strong>best scenario that i need</strong></p> <ul> <li>from base64 image received</li> <li>convert in buffer and send file to external Python API so to avoid saving the file on local disk</li> </ul> <p>would appreciate any help</p> <p><strong>below is a python example that works but not JS (JS nothing works)</strong></p> <pre><code>import requests url = &quot;http://127.0.0.1:8000/external_api&quot; payload={'namespace': 'test'} files=[ ('file',('lbl-pic.png',open('/local/path/lbl-pic.png','rb'),'image/png')) ] headers = { 'Authorization': 'Bearer token' } response = requests.request(&quot;POST&quot;, url, headers=headers, data=payload, files=files) print(response.text) </code></pre>
[ { "answer_id": 74498763, "author": "aaa", "author_id": 3620936, "author_profile": "https://Stackoverflow.com/users/3620936", "pm_score": 1, "selected": true, "text": "function upload (image: {imageBase64: string, fileName: string}) {\n const { imageBase64, fileName } = image;\n const cleanBase64 = imageBase64.substr(imageBase64.indexOf(',') + 1);\n // buffer should be clean base64\n const buffer = Buffer.from(cleanBase64, 'base64');\n\n const formData = new FormData();\n // filename as option is required, otherwise will not work, will say that received file is string and UploadFile\n formData.append('file', buffer, { filename: fileName });\n\n return client\n .post('url', formData, {\n headers: {\n ...formData.getHeaders(),\n },\n })\n .then((response) => response.data)\n .catch((error) => {\n return {\n status: 'error',\n error,\n };\n });\n}\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3620936/" ]
74,385,768
<p>i have a Array with Customer Objects. They have an ID, category and a date. In the list it can happen that there are different dates for the same categories.</p> <pre><code>Customer 1 | qualityCheck | 12.03.2022 Customer 1 | priceCheck | 05.07.2021 Customer 1 | customerCheck| 25.10.2022 Customer 1 | qualityCheck | 19.09.2020 Customer 1 | priceCheck | 15.05.2022 </code></pre> <p>Now i need for every Category the latest date. For the example above it would be like this.</p> <pre><code>Customer 1 | qualityCheck | 12.03.2022 Customer 1 | customerCheck| 25.10.2022 Customer 1 | priceCheck | 15.05.2022 </code></pre> <p>It can be that the list has 100 entries or also only 1. how can i solve this? it would be easiest if i had a new list with this items</p>
[ { "answer_id": 74386100, "author": "Razvan", "author_id": 7611661, "author_profile": "https://Stackoverflow.com/users/7611661", "pm_score": 0, "selected": false, "text": " Map<String, Optional<Customer>> result = list.stream()\n .sorted(Comparator.comparing(Customer::getDate))\n .collect(Collectors.groupingBy(Customer::getCategory,\n LinkedHashMap::new, Collectors.maxBy(Comparator.comparing(Customer::getDate))));\n" }, { "answer_id": 74387804, "author": "Serdar Sarıtaş", "author_id": 15755741, "author_profile": "https://Stackoverflow.com/users/15755741", "pm_score": 1, "selected": false, "text": "let sorted = arr.sort((a,b) => {\nreturn a.cat.localeCompare(b.cat) || new Date(b.date) - new Date(a.date)})\n\n\nlet result = []\nfor(let i = 0 ; i < sorted.length; i++) {\n let existed = result.find(eel => eel.cat === sorted[i].cat )\n if(!existed) {\n result.push(sorted[i])\n }\n}\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385768", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8865176/" ]
74,385,784
<p>My Electron app needs to store into and retrieve from a sqlite db, objects like this: </p> <pre><code>{&quot;name&quot;:&quot;my regexp&quot;,&quot;regexp&quot;:/some\spattern/i} </code></pre> <p>(real objects are much larger and much more complex.)</p> <p>I started by storing stringified object in a field, but since JSON.stringify() does not handle regular expressions and converts them to {}, I had to convert all regexps to strings, which stringify() then escapes. I end up with very convoluted code in many functions.</p> <p>If anyone has solved this problem elegantly either with JSON or XML, I would love a good solution.</p>
[ { "answer_id": 74386100, "author": "Razvan", "author_id": 7611661, "author_profile": "https://Stackoverflow.com/users/7611661", "pm_score": 0, "selected": false, "text": " Map<String, Optional<Customer>> result = list.stream()\n .sorted(Comparator.comparing(Customer::getDate))\n .collect(Collectors.groupingBy(Customer::getCategory,\n LinkedHashMap::new, Collectors.maxBy(Comparator.comparing(Customer::getDate))));\n" }, { "answer_id": 74387804, "author": "Serdar Sarıtaş", "author_id": 15755741, "author_profile": "https://Stackoverflow.com/users/15755741", "pm_score": 1, "selected": false, "text": "let sorted = arr.sort((a,b) => {\nreturn a.cat.localeCompare(b.cat) || new Date(b.date) - new Date(a.date)})\n\n\nlet result = []\nfor(let i = 0 ; i < sorted.length; i++) {\n let existed = result.find(eel => eel.cat === sorted[i].cat )\n if(!existed) {\n result.push(sorted[i])\n }\n}\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11373232/" ]
74,385,812
<p>Lets say i have df like this</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ID</th> <th>name_x</th> <th>st</th> <th>string</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>xx</td> <td>us</td> <td>Being unacquainted with the chief raccoon was harming his prospects for promotion</td> </tr> <tr> <td>2</td> <td>xy</td> <td>us1</td> <td>The overpass went under the highway and into a secret world</td> </tr> <tr> <td>3</td> <td>xz</td> <td>us</td> <td>He was 100% into fasting with her until he understood that meant he couldn't eat</td> </tr> <tr> <td>4</td> <td>xu</td> <td>us2</td> <td>Random words in front of other random words create a random sentence</td> </tr> <tr> <td>5</td> <td>xi</td> <td>us1</td> <td>All you need to do is pick up the pen and begin</td> </tr> </tbody> </table> </div> <p>Using python and pandas for column <strong>st</strong> I want count <strong>name_x</strong> values and then extract top 3 key words from string.</p> <p>For example like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>st</th> <th>name_x_count</th> <th>top1_word</th> <th>top2_word</th> <th>top3_word</th> </tr> </thead> <tbody> <tr> <td>us</td> <td>2</td> <td>word1</td> <td>word2</td> <td>word3</td> </tr> <tr> <td>us1</td> <td>2</td> <td>word1</td> <td>word2</td> <td>word3</td> </tr> <tr> <td>us2</td> <td>1</td> <td>word1</td> <td>word2</td> <td>word3</td> </tr> </tbody> </table> </div> <p>Is there any way to solve this task?</p>
[ { "answer_id": 74385998, "author": "Celius Stingher", "author_id": 11897007, "author_profile": "https://Stackoverflow.com/users/11897007", "pm_score": 2, "selected": false, "text": "Counter" }, { "answer_id": 74386205, "author": "Bushmaster", "author_id": 15415267, "author_profile": "https://Stackoverflow.com/users/15415267", "pm_score": 1, "selected": false, "text": "df['string']=df['string'] + ' ' # we will use sum function. When combining sentences, there should be spaces in between.\n\ndfx=df.groupby('st').agg({'st':'count','string':'sum'}) #groupby st and combine strings\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15276787/" ]
74,385,833
<pre><code> &lt;td id=&quot;gender3&quot; name =&quot;gender&quot;&gt;Male &lt;input id = &quot;gender_input3&quot; type=&quot;text&quot; style=&quot;border:ridge;width:90px; display: none&quot; name=&quot;gender&quot; &gt; &lt;/td&gt; </code></pre> <p>A <strong>td</strong> contains text and another dom called input. When certain action is triggered, I only want to clear the text.</p> <pre><code>td = document.getElementById(&quot;gender3&quot;) td.innerText = &quot;&quot; </code></pre> <p>This will also eliminate input tag.</p> <p>How can I do? Thanks.</p>
[ { "answer_id": 74385998, "author": "Celius Stingher", "author_id": 11897007, "author_profile": "https://Stackoverflow.com/users/11897007", "pm_score": 2, "selected": false, "text": "Counter" }, { "answer_id": 74386205, "author": "Bushmaster", "author_id": 15415267, "author_profile": "https://Stackoverflow.com/users/15415267", "pm_score": 1, "selected": false, "text": "df['string']=df['string'] + ' ' # we will use sum function. When combining sentences, there should be spaces in between.\n\ndfx=df.groupby('st').agg({'st':'count','string':'sum'}) #groupby st and combine strings\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1033591/" ]
74,385,836
<p>I have a table like</p> <p>sales(product_number, assortment, date)</p> <p>Here 1 assortment contains multiple products. For example 1 assortment i.e. chocolates contains product_number cadbury, 5 star, kitkat etc. Each and every product has date. I'm trying to check that all products in the same assortment have the same date. I'm trying to write a query which will return data where every product_number in every assortment has same date. For example, below is the sample data</p> <pre><code>product_number assortment date cadbury chocolate 2021-09-09 cadbury chocolate 2021-09-09 kitkat chocolate 2021-09-09 5 star chocolate 2021-09-09 lays chips 2022-01-02 chips chips 2022-02-05 bingo chips 2022-01-02 bingo chips 2022-01-02 </code></pre> <p>In the above table there are 2 assortments, chocolate and chips. chocolate assortment has multiple products which has same date where as chips assortment has different dates. The output must be</p> <pre><code>product_number assortment date cadbury chocolate 2021-09-09 cadbury chocolate 2021-09-09 kitkat chocolate 2021-09-09 5 star chocolate 2021-09-09 </code></pre> <p>I wrote a SQL query which is below</p> <pre><code>SELECT * FROM sales WHERE date IN (SELECT date FROM sales GROUP BY assortment, date HAVING COUNT(DISTINCT product_number) = 1) ORDER BY assortment, product_number, date </code></pre>
[ { "answer_id": 74385998, "author": "Celius Stingher", "author_id": 11897007, "author_profile": "https://Stackoverflow.com/users/11897007", "pm_score": 2, "selected": false, "text": "Counter" }, { "answer_id": 74386205, "author": "Bushmaster", "author_id": 15415267, "author_profile": "https://Stackoverflow.com/users/15415267", "pm_score": 1, "selected": false, "text": "df['string']=df['string'] + ' ' # we will use sum function. When combining sentences, there should be spaces in between.\n\ndfx=df.groupby('st').agg({'st':'count','string':'sum'}) #groupby st and combine strings\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18158837/" ]
74,385,856
<p>Implementing ordered and unordered list using tiptap react. I want functionality like when user currently in any list or any list is active in text-area of tiptap then by hit the enter key message should send with a single ordered list. The problem is when I need to add another line in same list, using shift+enter key for jumping in new line with updated number of list for example:</p> <pre><code>&quot;1. currently writing in text-area&quot; `hitting shift-enter key` the expected output is &quot;1. currently writing in text-area&quot; &quot;2. some other line&quot; </code></pre> <p>but I got</p> <pre><code>&quot;1. currently writing in text-area&quot; &quot;2. &quot; &quot; &quot; `cursor is in next line` . </code></pre> <p>I found out the problem is with every shift + enter hit tiptap adds <br> tag and add a simple break line in between any working node.</p> <p>I tried with adding</p> <pre><code>const removeBlankSpace = () =&gt; { const abc = editor?.getHTML().replace(&quot;&lt;br&gt;&quot;, &quot; &quot;) || &quot;&quot;; editor?.commands.setContent(abc); }; </code></pre> <p>removing blank space or <br> tag explicitly and setting up inside editor.commands.setContent</p> <pre><code>const editor = useEditor({ extensions: [ Document.extend({ // @ts-ignore addCommands() { return { setNewParagraph: () =&gt; // @ts-ignore ({ commands, editor }) =&gt; { const { state } = editor; const { selection } = state; const { $head } = selection; const position = $head.after(); return commands.insertContentAt( { from: position, to: position }, { type: Paragraph.name } // Note this is adding a paragraph ); }, }; }, addKeyboardShortcuts() { return { Enter: () =&gt; { emitCustomEvent(&quot;enter-key-tiptap&quot;); return true; }, }; }, }), StarterKit.configure({ document: false, heading: { levels: [1, 2, 3, 4], }, }), Strike, Highlight.configure({ multicolor: true }), Link.configure({ openOnClick: true, }), Emoji.configure({ emojis: [...gitHubEmojis], enableEmoticons: true, forceFallbackImages: true, }), Placeholder.configure({ showOnlyWhenEditable: false, showOnlyCurrent: true, includeChildren: true, placeholder: () =&gt; &quot;Send a message&quot;, }), Link.configure({ openOnClick: false, }), MentionExtension, MentionTipTap.configure(), ], editorProps: { attributes: { class: `prose prose-sm custom-note sm:prose-sm lg:prose-lg xl:prose-2xl mx-auto focus:outline-none`, }, handleKeyDown(view, event) { // For the purpose of detect key inside ordered and unordered list. if (keyPressCheck.key === &quot;Shift&quot; &amp;&amp; event.key === &quot;Enter&quot;) { console.log(&quot;emit new list&quot;); emitCustomEvent(&quot;new-line-list&quot;); } keyPressCheck.key = event.key; if (keyPressCheck.key !== &quot;Shift&quot; &amp;&amp; event.key === &quot;Enter&quot;) { emitCustomEvent(&quot;enter-for-list&quot;); } }, }, autofocus: &quot;end&quot;, onUpdate({ editor, transaction }) { onChange(editor as Editor); }, content: ``, }); const handleEnterKeyForList = () =&gt; { if (editor?.can().splitListItem(&quot;listItem&quot;)) { console.log(&quot;enter key submit here&quot;); onMessageSend(); } }; // editor?.commands.setContent(&quot;&lt;ul&gt;&lt;li&gt;&lt;p&gt;jg&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&quot;); const removeBlankSpace = () =&gt; { console.log( &quot;changes donw ------------------------------&quot;, editor?.getHTML() ); // const abc = editor?.getHTML().replace(&quot;&lt;br&gt;&quot;, &quot; &quot;) || &quot;&quot;; // console.log(&quot;abc: &quot;, abc); // editor?.commands.setContent(abc); }; const handleNewLineUpdate = () =&gt; { if ( editor?.isActive(&quot;orderedList&quot;) || (editor?.isActive(&quot;bulletList&quot;) &amp;&amp; editor.can().splitListItem(&quot;listItem&quot;)) ) { editor?.chain().focus().splitListItem(&quot;listItem&quot;).run(); removeBlankSpace(); } }; useCustomEventListener(&quot;enter-key-tiptap&quot;, handleEnterKey); useCustomEventListener(&quot;enter-for-list&quot;, handleEnterKeyForList); useCustomEventListener(&quot;new-line-list&quot;, handleNewLineUpdate); </code></pre>
[ { "answer_id": 74385998, "author": "Celius Stingher", "author_id": 11897007, "author_profile": "https://Stackoverflow.com/users/11897007", "pm_score": 2, "selected": false, "text": "Counter" }, { "answer_id": 74386205, "author": "Bushmaster", "author_id": 15415267, "author_profile": "https://Stackoverflow.com/users/15415267", "pm_score": 1, "selected": false, "text": "df['string']=df['string'] + ' ' # we will use sum function. When combining sentences, there should be spaces in between.\n\ndfx=df.groupby('st').agg({'st':'count','string':'sum'}) #groupby st and combine strings\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18744198/" ]
74,385,871
<p>I'm trying out OpenPDF in Clojure. I manage to make a simple document, but there are font problems.</p> <p>Here's some failing code:</p> <pre><code>(ns invoice.download.pdf (:require [clojure.java.io :as io]) (:import [com.lowagie.text Font FontFactory Paragraph] [com.lowagie.text.pdf BaseFont])) (defn- add-invoice [document] (let [font (-&gt; (io/resource &quot;fonts/Helvetica.ttf&quot;) (.toString) (BaseFont/createFont BaseFont/IDENTITY_H BaseFont/NOT_EMBEDDED) (Font. 12))] (.add document (Paragraph. &quot;Invoice&quot; font)))) </code></pre> <p>Something crashes when setting font size, but no exception is thrown. It seems no font is created, even though that part of the code executes fine apart from setting font size.</p>
[ { "answer_id": 74401514, "author": "a.k", "author_id": 8162407, "author_profile": "https://Stackoverflow.com/users/8162407", "pm_score": 2, "selected": true, "text": "(:use clj-pdf.core)\n(pdf\n [{:font {:encoding :unicode\n :ttf-name \"fonts/proxima_nova_extrabold.ttf\"}}\n [:phrase \"Testing 123\"]\n [:phrase \"some text\"]\n [:phrase \"some more text\"]\n [:paragraph \"yet more text\"]]\n \"doc.pdf\")\n" }, { "answer_id": 74402213, "author": "Lars Melander", "author_id": 11601044, "author_profile": "https://Stackoverflow.com/users/11601044", "pm_score": 0, "selected": false, "text": "clj-pdf" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11601044/" ]
74,385,880
<p>i need to run a Excel VBA Macro from Java. I've already exported the module as a vbs file: module1.vbs</p> <p>And now i just need to run it from the java code.</p> <p>I tried to run it from Java like this:</p> <pre><code>Runtime.getRuntime().exec(&quot;C://Users//pk//OneDrive - pk//Documents//Module1.vbs&quot;); </code></pre> <p>This is the Error i get from it:</p> <blockquote> <p>java.io.IOException: Cannot run program &quot;C:\Users\pk\OneDrive - pk\Documents\Modul1e.vbs&quot;: CreateProcess error=193, %1 is not a valid Win32 application</p> </blockquote>
[ { "answer_id": 74401514, "author": "a.k", "author_id": 8162407, "author_profile": "https://Stackoverflow.com/users/8162407", "pm_score": 2, "selected": true, "text": "(:use clj-pdf.core)\n(pdf\n [{:font {:encoding :unicode\n :ttf-name \"fonts/proxima_nova_extrabold.ttf\"}}\n [:phrase \"Testing 123\"]\n [:phrase \"some text\"]\n [:phrase \"some more text\"]\n [:paragraph \"yet more text\"]]\n \"doc.pdf\")\n" }, { "answer_id": 74402213, "author": "Lars Melander", "author_id": 11601044, "author_profile": "https://Stackoverflow.com/users/11601044", "pm_score": 0, "selected": false, "text": "clj-pdf" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20395564/" ]
74,385,924
<p>I have a csv files with a table of info, I need to plot a hist with the information available, the table has dates and numbers, I want the dates to be on the x axis and the numbers on the y axis, but it is plotting the other way around, below are the details:</p> <p>The below table is on a csv file (called Results.csv in the below code) that I am reading from, so it has 3 columns, index, Date, and Incidents</p> <pre><code> Date Incidents 0 14-06-17 637 1 15-06-17 549 2 16-06-17 510 3 17-06-17 460 4 18-06-17 431 5 19-06-17 332 6 20-06-17 220 </code></pre> <pre><code>import numpy as np import pandas as pd import matplotlib.pyplot as plt Results_Hist = pd.read_csv (&quot;/content/drive/MyDrive/Colab Notebooks/Results.csv&quot;) hist = Results_Hist['Incidents'].hist() </code></pre> <p><a href="https://i.stack.imgur.com/p3g3K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p3g3K.png" alt="And here is the plot I am getting" /></a></p> <p>Please keep in mind that I still want to have it vertical, so again, the dates on the bottom, and the values on the y axis</p> <p>Also, I don't know why the dates are changing to numbers from 0 to 2 Thanks</p>
[ { "answer_id": 74386283, "author": "Vojta F", "author_id": 9528643, "author_profile": "https://Stackoverflow.com/users/9528643", "pm_score": 2, "selected": true, "text": "Results_Hist.plot(x='Date', y='AIncidents', kind='bar')\n" }, { "answer_id": 74386345, "author": "AlexWach", "author_id": 14569281, "author_profile": "https://Stackoverflow.com/users/14569281", "pm_score": 0, "selected": false, "text": "import pandas as pd\nimport numpy as np\nfrom matplotlib import pyplot as plt\n\n# build sample data\ndates = pd.date_range(start='01-01-1990', end='01-07-1990')\nincidents = np.random.normal(loc=100, scale=10, size=len(dates))\ndf = pd.DataFrame(zip(dates, incidents), columns=['Dates', 'Incidents'])\nprint(df)\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20410984/" ]
74,385,943
<p>I have 2 terraform scripts. One of them creates an Azure VM with a network and 1 subnet. The second TF script creates databricks and 2 additional subnets in the Azure VM network to connect both Databricks and VM.</p> <p>The problem is that after the first apply everything works well. But after the second the terraform is want to delete 2 additional subnets.</p> <p>My question is how to prevent the deletion of 2 additional subnets?</p> <p>VM part of the creation network and one subnet:</p> <pre><code>resource &quot;azurerm_virtual_network&quot; &quot;neo4j_virt_network&quot; { name = &quot;neo4j-virtnetwork-${var.env}-${var.location}-001&quot; address_space = [&quot;10.0.0.0/16&quot;] location = var.location resource_group_name = var.resource_group subnet { name = &quot;neo4j-virtnetwork-subnet-${var.env}-${var.location}-001&quot; address_prefix = &quot;10.0.1.0/24&quot; security_group = azurerm_network_security_group.neo4j_sg.id } tags = local.tags } </code></pre> <p>Databricks part of creating 2 additional subnets:</p> <pre><code>resource &quot;azurerm_subnet&quot; &quot;private&quot; { name = &quot;databricks-dev-northeurope-001-private&quot; resource_group_name = var.resource_group virtual_network_name = azurerm_virtual_network.neo4j_virt_network.name address_prefixes = [&quot;10.0.3.0/24&quot;] delegation { name = &quot;databricks-delegation&quot; service_delegation { name = &quot;Microsoft.Databricks/workspaces&quot; actions = [ &quot;Microsoft.Network/virtualNetworks/subnets/join/action&quot;, &quot;Microsoft.Network/virtualNetworks/subnets/prepareNetworkPolicies/action&quot;, &quot;Microsoft.Network/virtualNetworks/subnets/unprepareNetworkPolicies/action&quot;, ] } } } resource &quot;azurerm_network_security_group&quot; &quot;private&quot; { name = &quot;databricks-dev-northeurope-001-private-sg&quot; resource_group_name = var.resource_group location = var.location } resource &quot;azurerm_subnet_network_security_group_association&quot; &quot;private&quot; { subnet_id = azurerm_subnet.private.id network_security_group_id = azurerm_network_security_group.private.id } resource &quot;azurerm_subnet&quot; &quot;public&quot; { name = &quot;databricks-dev-northeurope-001-public&quot; resource_group_name = var.resource_group virtual_network_name = azurerm_virtual_network.neo4j_virt_network.name address_prefixes = [&quot;10.0.5.0/24&quot;] delegation { name = &quot;databricks-delegation&quot; service_delegation { name = &quot;Microsoft.Databricks/workspaces&quot; actions = [ &quot;Microsoft.Network/virtualNetworks/subnets/join/action&quot;, &quot;Microsoft.Network/virtualNetworks/subnets/prepareNetworkPolicies/action&quot;, &quot;Microsoft.Network/virtualNetworks/subnets/unprepareNetworkPolicies/action&quot;, ] } } } resource &quot;azurerm_network_security_group&quot; &quot;public&quot; { name = &quot;databricks-dev-northeurope-001-public-sg&quot; resource_group_name = var.resource_group location = var.location } resource &quot;azurerm_subnet_network_security_group_association&quot; &quot;public&quot; { subnet_id = azurerm_subnet.public.id network_security_group_id = azurerm_network_security_group.public.id } resource &quot;azurerm_databricks_workspace&quot; &quot;databricks&quot; { name = &quot;databricks-${var.env}-${var.location}-001&quot; resource_group_name = var.resource_group location = var.location sku = &quot;standard&quot; managed_resource_group_name = &quot;${var.company_name}-rg-databricks-workspace-${var.env}-${var.location}-001&quot; custom_parameters { machine_learning_workspace_id = azurerm_machine_learning_workspace.ml_workspace.id storage_account_name = &quot;databrick${var.env}${random_string.db_code.result}&quot; virtual_network_id = azurerm_virtual_network.neo4j_virt_network.id public_subnet_name = azurerm_subnet.public.name public_subnet_network_security_group_association_id = azurerm_subnet_network_security_group_association.public.id private_subnet_name = azurerm_subnet.private.name private_subnet_network_security_group_association_id = azurerm_subnet_network_security_group_association.private.id } depends_on = [ azurerm_subnet_network_security_group_association.public, azurerm_subnet_network_security_group_association.private, ] tags = local.tags } </code></pre> <p>Message from debug about that quantity of subnets changed in network object:</p> <pre><code>2022-11-10T09:28:12.050+0200 [WARN] Provider &quot;registry.terraform.io/hashicorp/azurerm&quot; produced an unexpected new value for module.dev.azurerm_virtual_network.neo4j_virt_network during refresh. - .subnet: actual set element cty.ObjectVal(map[string]cty.Value{&quot;address_prefix&quot;:cty.StringVal(&quot;10.0.3.0/24&quot;), &quot;id&quot;:cty.StringVal(&quot;[...]&quot;), &quot;name&quot;:cty.StringVal(&quot;databricks-dev-northeurope-001-private&quot;), &quot;security_group&quot;:cty.StringVal(&quot;[...]&quot;)}) does not correlate with any element in plan - .subnet: actual set element cty.ObjectVal(map[string]cty.Value{&quot;address_prefix&quot;:cty.StringVal(&quot;10.0.5.0/24&quot;), &quot;id&quot;:cty.StringVal(&quot;[...]&quot;), &quot;name&quot;:cty.StringVal(&quot;databricks-dev-northeurope-001-public&quot;), &quot;security_group&quot;:cty.StringVal(&quot;[...]&quot;)}) does not correlate with any element in plan - .subnet: length changed from 1 to 3 </code></pre>
[ { "answer_id": 74386633, "author": "Kombajn zbożowy", "author_id": 2890093, "author_profile": "https://Stackoverflow.com/users/2890093", "pm_score": 3, "selected": true, "text": "subnet { ... }" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385943", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6691914/" ]
74,385,944
<p><a href="https://i.stack.imgur.com/gymuL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gymuL.png" alt="My attempt:" /></a> <a href="https://i.stack.imgur.com/N8QiC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N8QiC.png" alt="Example page:" /></a></p> <p>Scenario: I am currently working through a CSS/HTML project and have to recreate an example web-page using flexbox.</p> <p>Problem: I seem to be unable to mimic the margin/indenting that the example page is using on either side of the page.</p> <p><a href="https://i.stack.imgur.com/IQsnl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IQsnl.png" alt="enter image description here" /></a> When I attempt to copy this in various ways, I end up indenting the entire header block, and I'm left with whatever colour the body is behind.</p>
[ { "answer_id": 74386633, "author": "Kombajn zbożowy", "author_id": 2890093, "author_profile": "https://Stackoverflow.com/users/2890093", "pm_score": 3, "selected": true, "text": "subnet { ... }" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19884722/" ]
74,385,973
<p>Help needed. I am trying to save a file with python but this error appears. [Errno 13] Permission denied : &quot;C:\Users\33769\Desktop\Reviewin&quot; Firstly, I don't understand why it adds anti-slashes to the path ! Here is my code :</p> <pre><code>file_path = r'C:\Users\33769\Desktop\Reviewin' with open(file_path) as f: f.write(file) </code></pre> <p>Don't worry the (file), I mentionned it in my code, The problem that occured is with the path and I don't know how to fix it. Thanks for answring !</p>
[ { "answer_id": 74386012, "author": "sitWolf", "author_id": 7422392, "author_profile": "https://Stackoverflow.com/users/7422392", "pm_score": 0, "selected": false, "text": "with open(file_path, \"w\") as f:\n ...\n" }, { "answer_id": 74386176, "author": "Nazmul Hasan", "author_id": 20173161, "author_profile": "https://Stackoverflow.com/users/20173161", "pm_score": 0, "selected": false, "text": "import os\nfile_path = 'C:\\Users\\33769\\Desktop\\Reviewin'\nsave_path = os.path.join(file_path, \"reviewin.txt\") \nwith open(save_path, \"w\") as f:\n f.write(file_path)\n" }, { "answer_id": 74386549, "author": "9Limes", "author_id": 19980443, "author_profile": "https://Stackoverflow.com/users/19980443", "pm_score": -1, "selected": false, "text": "file_path = r'C:\\Users\\33769\\Desktop\\Reviewin.fileextentionhere'#ex png, gif\nwith open(file_path) as f: \n f.write(file) \n" }, { "answer_id": 74394037, "author": "9Limes", "author_id": 19980443, "author_profile": "https://Stackoverflow.com/users/19980443", "pm_score": -1, "selected": false, "text": "from PIL import Image\n\nfile = \"C://Users/ABC/YourImageFile\" #the image you want to save\nimg = Image.open(file) #open the image file for use\n\nimg.save(C:\\Users\\33769\\Desktop\\Reviewin) #save your image to the desired \n #directory\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18862346/" ]
74,385,980
<p>I want to create a method in a class object (depending on some condition). This works when I create the lambda in the class (m2) and when I assign an existing method to a class attribute (m3), but NOT when I assign a lambda to a class attribute (m1). In that case the lambda does not get the self parameter.</p> <pre><code>class c: def __init__( self ): self.m1 = lambda self: 1 self.m3 = self._m3 m2 = lambda self: 1 def _m3( self ): pass c().m2() # works c().m3() # works c().m1() # error: missing 1 required positional argument: 'self' </code></pre> <p>What must I do to be able to call the m1 lambda with the c().m1() syntax?</p>
[ { "answer_id": 74386046, "author": "Jasper Rou", "author_id": 20173271, "author_profile": "https://Stackoverflow.com/users/20173271", "pm_score": -1, "selected": false, "text": "self.m1 = lambda self: 1\n" }, { "answer_id": 74386157, "author": "blhsing", "author_id": 6890912, "author_profile": "https://Stackoverflow.com/users/6890912", "pm_score": 1, "selected": true, "text": "types.MethodType" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20248075/" ]
74,385,983
<p>I have a script that updates a configuration file with current year, but for some reason the copyright symbol is not being inserted correctly. The PowerShell script is UTF-8 with BOM and the JSON file is UTF-8.</p> <p>The workflow is that I read from a JSON file, update the copyright date, and then save to a JSON file again.</p> <p>The JSON file <code>info.json</code>:</p> <pre><code>{ &quot;CopyrightInfo&quot;: &quot;Copyright © CompanyName 1992&quot; } </code></pre> <p>Reproducible excerpt of the PowerShell script:</p> <pre><code>$path = &quot;./info.json&quot; $a = Get-Content $path| ConvertFrom-Json $a.'CopyrightInfo' = &quot;Copyright $([char]::ConvertFromUtf32(0x000000A9)) CompanyName $((Get-Date).Year)&quot; $a | ConvertTo-Json | set-content $path </code></pre> <p>I've tried a bunch of ways, above is the latest attempt. It looks fine when printed in PowerShell or opened in Notepad, but any other editor (Visual Studio Code, SourceTree, Azure DevOps file viewer, etc) they always result in the following:</p> <pre><code>&quot;CopyrightInfo&quot;: &quot;Copyright � CompanyName 2022&quot; </code></pre> <p>If anyone can explain what I'm doing wrong that would great and even greater if they could also add a way to make it work properly.</p> <p>I'm using PowerShell version 5.1.19041.1682</p> <p>EDIT: Updated issue with reproducible code excerpts and used PowerShell version.</p>
[ { "answer_id": 74387239, "author": "iRon", "author_id": 1701026, "author_profile": "https://Stackoverflow.com/users/1701026", "pm_score": 0, "selected": false, "text": "$Data = @{ CopyrightInfo = \"Copyright $([char]::ConvertFromUtf32(0x000000A9)) CompanyName $((Get-Date).Year)\" }\n$Json = ConvertTo-Json $Data\n$Json |Set-Content .\\Test.json\n$Json = Get-Content -Raw .\\Test.json\n$Data = ConvertFrom-Json $Json\n$Data\n" }, { "answer_id": 74389785, "author": "mklement0", "author_id": 45375, "author_profile": "https://Stackoverflow.com/users/45375", "pm_score": 2, "selected": true, "text": "Set-Content -Encoding utf8" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3010546/" ]
74,385,991
<p>The problem is as follows.</p> <p>I have a pandas dataFrame looking something like</p> <pre><code> row_idx clm_idx value 0 0 1 a1 1 0 2 b1 2 1 3 c1 3 2 3 d1 </code></pre> <p>This dataFrame can have up to m lines (probably quite a lot).</p> <p>Secondly I have a nxn numpy array A where I need to add those values to depending on the columns 'row_idx' and 'clm_idx' which describe the row and column index in the numpy array. The mathematical function can even be more complex than simply adding. But I set that aside for now.</p> <pre><code>A = [[a b c d], [e f g h], [i k l m], [n o p q]] </code></pre> <p>Here as an example its a 4x4 matrix. So I would like to get the following in the end:</p> <pre><code>A_new = [[a b+a1 c+b1 d], [e f g h+c1], [i k l m+d1], [n o p q]] </code></pre> <p>I assume I can iterate over all rows of the dataframe somehow extract the indices and then add the values at the corresponding index to the nxn array. But that seems somewhat inefficient.</p> <p>I tried as well:</p> <pre><code>df.apply(lambda x: A[x['row_idx'], x['clm_idx']] += x['value']) </code></pre> <p>But this throws a SyntaxError that one cannot contain an assignment in this context.</p> <p>Is there an efficient way to solve the problem, assuming that there m and n are quite big?</p> <p>As a basic code block this should do. The problem is the last line:</p> <pre><code>import numpy as np import pandas as pd data = {'row_idx': [0, 0, 1, 2], 'clm_idx': [1,2,3,3], 'value': [1,2,3,4]} df = pd.DataFrame(data) A = np.zeros((4,4)) df.apply(lambda x: A[x['row_idx'], x['clm_idx']] += x['value'], axis=1) </code></pre>
[ { "answer_id": 74387239, "author": "iRon", "author_id": 1701026, "author_profile": "https://Stackoverflow.com/users/1701026", "pm_score": 0, "selected": false, "text": "$Data = @{ CopyrightInfo = \"Copyright $([char]::ConvertFromUtf32(0x000000A9)) CompanyName $((Get-Date).Year)\" }\n$Json = ConvertTo-Json $Data\n$Json |Set-Content .\\Test.json\n$Json = Get-Content -Raw .\\Test.json\n$Data = ConvertFrom-Json $Json\n$Data\n" }, { "answer_id": 74389785, "author": "mklement0", "author_id": 45375, "author_profile": "https://Stackoverflow.com/users/45375", "pm_score": 2, "selected": true, "text": "Set-Content -Encoding utf8" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74385991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17926094/" ]
74,386,010
<p>I've got a new project(spring boot 2.4.13) and I want to add swagger to that project</p> <pre><code> &lt;parent&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt; &lt;version&gt;2.4.13&lt;/version&gt; &lt;relativePath/&gt; &lt;/parent&gt; </code></pre> <p>I've just added 2 dependencies:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;io.springfox&lt;/groupId&gt; &lt;artifactId&gt;springfox-boot-starter&lt;/artifactId&gt; &lt;version&gt;3.0.0&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;io.springfox&lt;/groupId&gt; &lt;artifactId&gt;springfox-swagger-ui&lt;/artifactId&gt; &lt;version&gt;3.0.0&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>And when I start my application I see following error in log:</p> <pre><code>2022-11-10 11:14:37.459 ERROR 30060 --- [ scheduling-1] o.s.integration.handler.LoggingHandler : org.springframework.messaging.MessageDeliveryException: Dispatcher has no subscribers for channel 'application-1.inMemorySwaggerResourcesProvider-out-0'.; nested exception is org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers, failedMessage=GenericMessage [payload=byte[90], headers={messageConsumed=true, X-B3-SpanId=febbbdee76288c09, io.opentracing.contrib.spring.integration.messaging.OpenTracingChannelInterceptor.SCOPE=io.opentracing.util.ThreadLocalScope@6ea2e38a, X-B3-ParentSpanId=cf083cc53199901c, X-B3-Sampled=1, X-B3-TraceId=cf083cc53199901c, messageSent=true, id=13817867-f785-2eee-2522-c98a9d95be36, contentType=application/json, timestamp=1668068077459}], failedMessage=GenericMessage [payload=byte[90], headers={messageConsumed=true, X-B3-SpanId=febbbdee76288c09, io.opentracing.contrib.spring.integration.messaging.OpenTracingChannelInterceptor.SCOPE=io.opentracing.util.ThreadLocalScope@6ea2e38a, X-B3-ParentSpanId=cf083cc53199901c, X-B3-Sampled=1, X-B3-TraceId=cf083cc53199901c, messageSent=true, id=13817867-f785-2eee-2522-c98a9d95be36, contentType=application/json, timestamp=1668068077459}] at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:76) at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:317) at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:272) at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:187) at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:166) at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:47) at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:109) at org.springframework.integration.router.AbstractMessageRouter.doSend(AbstractMessageRouter.java:213) at org.springframework.integration.router.AbstractMessageRouter.handleMessageInternal(AbstractMessageRouter.java:195) at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:56) at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:115) at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:133) at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:106) at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:72) at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:317) at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:272) at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:187) at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:166) at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:47) at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:109) at org.springframework.integration.endpoint.SourcePollingChannelAdapter.handleMessage(SourcePollingChannelAdapter.java:196) at org.springframework.integration.endpoint.AbstractPollingEndpoint.messageReceived(AbstractPollingEndpoint.java:450) at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:436) at org.springframework.integration.endpoint.AbstractPollingEndpoint.pollForMessage(AbstractPollingEndpoint.java:388) at org.springframework.integration.endpoint.AbstractPollingEndpoint.lambda$null$4(AbstractPollingEndpoint.java:331) at org.springframework.integration.util.ErrorHandlingTaskExecutor.lambda$execute$0(ErrorHandlingTaskExecutor.java:57) at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50) at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:55) at org.springframework.integration.endpoint.AbstractPollingEndpoint.lambda$createPoller$5(AbstractPollingEndpoint.java:328) at io.opentracing.contrib.concurrent.TracedRunnable.run(TracedRunnable.java:30) at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:95) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java) at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833) Caused by: org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers, failedMessage=GenericMessage [payload=byte[90], headers={messageConsumed=true, X-B3-SpanId=febbbdee76288c09, io.opentracing.contrib.spring.integration.messaging.OpenTracingChannelInterceptor.SCOPE=io.opentracing.util.ThreadLocalScope@6ea2e38a, X-B3-ParentSpanId=cf083cc53199901c, X-B3-Sampled=1, X-B3-TraceId=cf083cc53199901c, messageSent=true, id=13817867-f785-2eee-2522-c98a9d95be36, contentType=application/json, timestamp=1668068077459}] at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:139) at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:106) at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:72) ... 38 more </code></pre> <p>What is the root cause? how can I fix it ?</p> <p><strong>P.S.</strong> Without mentioned changes there are no the error</p>
[ { "answer_id": 74387239, "author": "iRon", "author_id": 1701026, "author_profile": "https://Stackoverflow.com/users/1701026", "pm_score": 0, "selected": false, "text": "$Data = @{ CopyrightInfo = \"Copyright $([char]::ConvertFromUtf32(0x000000A9)) CompanyName $((Get-Date).Year)\" }\n$Json = ConvertTo-Json $Data\n$Json |Set-Content .\\Test.json\n$Json = Get-Content -Raw .\\Test.json\n$Data = ConvertFrom-Json $Json\n$Data\n" }, { "answer_id": 74389785, "author": "mklement0", "author_id": 45375, "author_profile": "https://Stackoverflow.com/users/45375", "pm_score": 2, "selected": true, "text": "Set-Content -Encoding utf8" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74386010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2674303/" ]
74,386,011
<p>I have a flink job written in scala and I am creating one custom metric to count the nmber of events in a stream. The job is deployed on kubernetes and I see system metrics of job-manager and task-managers in the prometheus. However, we don't see the custom metrics in prometheus though we see that in Flink UI. Below is the custom metrics code:</p> <pre><code> val sampleProcessFunction = new ProcessFunction[String, String] { @transient private var counter: Counter = _ override def open(parameters: Configuration): Unit = counter = getRuntimeContext.getMetricGroup.addGroup(&quot;abc&quot;).counter(&quot;streamcounter&quot;) override def processElement( value: String, ctx: ProcessFunction[String, String]#Context, out: Collector[String]): Unit = { val result = value.parseJson.toString counter.inc() out.collect(result) } } </code></pre> <p>flink-config.yaml has these entries related to prometheus:</p> <pre><code> taskmanager.network.detailed-metrics: true metrics.reporter.prom.class:org.apache.flink.metrics.prometheus.PrometheusReporter metrics.reporter.prom.port: 8080 </code></pre> <p>Not only custom metrics, any taskmanager metrics that follows the path <strong>taskmanager.job.</strong>* are not exposed in the metrics endpoint. When I am getting into a taskmanager pod and doing a curl to the metrics endpoint like this:</p> <pre><code>kubectl exec -it flink-taskmanager-app-7448cdb787-9c48j -- /bin/bash curl http://localhost:8080/metrics </code></pre> <p>I am only getting the status metrics related to taskmanager:</p> <pre><code># HELP flink_taskmanager_Status_JVM_Memory_Mapped_MemoryUsed MemoryUsed (scope: taskmanager_Status_JVM_Memory_Mapped) # TYPE flink_taskmanager_Status_JVM_Memory_Mapped_MemoryUsed gauge flink_taskmanager_Status_JVM_Memory_Mapped_MemoryUsed{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 0.0 # HELP flink_taskmanager_Status_Flink_Memory_Managed_Used Used (scope: taskmanager_Status_Flink_Memory_Managed) # TYPE flink_taskmanager_Status_Flink_Memory_Managed_Used gauge flink_taskmanager_Status_Flink_Memory_Managed_Used{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 0.0 # HELP flink_taskmanager_Status_Shuffle_Netty_UsedMemorySegments UsedMemorySegments (scope: taskmanager_Status_Shuffle_Netty) # TYPE flink_taskmanager_Status_Shuffle_Netty_UsedMemorySegments gauge flink_taskmanager_Status_Shuffle_Netty_UsedMemorySegments{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 0.0 # HELP flink_taskmanager_Status_Network_TotalMemorySegments TotalMemorySegments (scope: taskmanager_Status_Network) # TYPE flink_taskmanager_Status_Network_TotalMemorySegments gauge flink_taskmanager_Status_Network_TotalMemorySegments{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 30037.0 # HELP flink_taskmanager_Status_Shuffle_Netty_AvailableMemory AvailableMemory (scope: taskmanager_Status_Shuffle_Netty) # TYPE flink_taskmanager_Status_Shuffle_Netty_AvailableMemory gauge flink_taskmanager_Status_Shuffle_Netty_AvailableMemory{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 9.84252416E8 # HELP flink_taskmanager_Status_JVM_ClassLoader_ClassesLoaded ClassesLoaded (scope: taskmanager_Status_JVM_ClassLoader) # TYPE flink_taskmanager_Status_JVM_ClassLoader_ClassesLoaded gauge flink_taskmanager_Status_JVM_ClassLoader_ClassesLoaded{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 11075.0 # HELP flink_taskmanager_Status_JVM_Memory_Metaspace_Max Max (scope: taskmanager_Status_JVM_Memory_Metaspace) # TYPE flink_taskmanager_Status_JVM_Memory_Metaspace_Max gauge flink_taskmanager_Status_JVM_Memory_Metaspace_Max{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 2.68435456E8 # HELP flink_taskmanager_Status_Shuffle_Netty_RequestedMemoryUsage RequestedMemoryUsage (scope: taskmanager_Status_Shuffle_Netty) # TYPE flink_taskmanager_Status_Shuffle_Netty_RequestedMemoryUsage gauge flink_taskmanager_Status_Shuffle_Netty_RequestedMemoryUsage{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 0.0 # HELP flink_taskmanager_Status_Shuffle_Netty_AvailableMemorySegments AvailableMemorySegments (scope: taskmanager_Status_Shuffle_Netty) # TYPE flink_taskmanager_Status_Shuffle_Netty_AvailableMemorySegments gauge flink_taskmanager_Status_Shuffle_Netty_AvailableMemorySegments{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 30037.0 # HELP flink_taskmanager_Status_JVM_Memory_Metaspace_Used Used (scope: taskmanager_Status_JVM_Memory_Metaspace) # TYPE flink_taskmanager_Status_JVM_Memory_Metaspace_Used gauge flink_taskmanager_Status_JVM_Memory_Metaspace_Used{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 6.5252976E7 # HELP flink_taskmanager_Status_JVM_Memory_NonHeap_Max Max (scope: taskmanager_Status_JVM_Memory_NonHeap) # TYPE flink_taskmanager_Status_JVM_Memory_NonHeap_Max gauge flink_taskmanager_Status_JVM_Memory_NonHeap_Max{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 7.80140544E8 # HELP flink_taskmanager_Status_JVM_Memory_Direct_Count Count (scope: taskmanager_Status_JVM_Memory_Direct) # TYPE flink_taskmanager_Status_JVM_Memory_Direct_Count gauge flink_taskmanager_Status_JVM_Memory_Direct_Count{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 30065.0 # HELP flink_taskmanager_Status_JVM_Memory_Direct_TotalCapacity TotalCapacity (scope: taskmanager_Status_JVM_Memory_Direct) # TYPE flink_taskmanager_Status_JVM_Memory_Direct_TotalCapacity gauge flink_taskmanager_Status_JVM_Memory_Direct_TotalCapacity{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 9.85225216E8 # HELP flink_taskmanager_Status_JVM_GarbageCollector_G1_Old_Generation_Time Time (scope: taskmanager_Status_JVM_GarbageCollector_G1_Old_Generation) # TYPE flink_taskmanager_Status_JVM_GarbageCollector_G1_Old_Generation_Time gauge flink_taskmanager_Status_JVM_GarbageCollector_G1_Old_Generation_Time{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 0.0 # HELP flink_taskmanager_Status_JVM_Threads_Count Count (scope: taskmanager_Status_JVM_Threads) # TYPE flink_taskmanager_Status_JVM_Threads_Count gauge flink_taskmanager_Status_JVM_Threads_Count{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 51.0 # HELP flink_taskmanager_Status_Shuffle_Netty_TotalMemory TotalMemory (scope: taskmanager_Status_Shuffle_Netty) # TYPE flink_taskmanager_Status_Shuffle_Netty_TotalMemory gauge flink_taskmanager_Status_Shuffle_Netty_TotalMemory{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 9.84252416E8 # HELP flink_taskmanager_Status_JVM_GarbageCollector_G1_Young_Generation_Time Time (scope: taskmanager_Status_JVM_GarbageCollector_G1_Young_Generation) # TYPE flink_taskmanager_Status_JVM_GarbageCollector_G1_Young_Generation_Time gauge flink_taskmanager_Status_JVM_GarbageCollector_G1_Young_Generation_Time{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 55.0 # HELP flink_taskmanager_Status_JVM_ClassLoader_ClassesUnloaded ClassesUnloaded (scope: taskmanager_Status_JVM_ClassLoader) # TYPE flink_taskmanager_Status_JVM_ClassLoader_ClassesUnloaded gauge flink_taskmanager_Status_JVM_ClassLoader_ClassesUnloaded{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 0.0 # HELP flink_taskmanager_Status_JVM_Memory_Heap_Used Used (scope: taskmanager_Status_JVM_Memory_Heap) # TYPE flink_taskmanager_Status_JVM_Memory_Heap_Used gauge flink_taskmanager_Status_JVM_Memory_Heap_Used{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 1.56297264E8 # HELP flink_taskmanager_Status_JVM_CPU_Time Time (scope: taskmanager_Status_JVM_CPU) # TYPE flink_taskmanager_Status_JVM_CPU_Time gauge flink_taskmanager_Status_JVM_CPU_Time{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 4.001E10 # HELP flink_taskmanager_Status_JVM_Memory_Direct_MemoryUsed MemoryUsed (scope: taskmanager_Status_JVM_Memory_Direct) # TYPE flink_taskmanager_Status_JVM_Memory_Direct_MemoryUsed gauge flink_taskmanager_Status_JVM_Memory_Direct_MemoryUsed{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 9.85225217E8 # HELP flink_taskmanager_Status_Shuffle_Netty_UsedMemory UsedMemory (scope: taskmanager_Status_Shuffle_Netty) # TYPE flink_taskmanager_Status_Shuffle_Netty_UsedMemory gauge flink_taskmanager_Status_Shuffle_Netty_UsedMemory{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 0.0 # HELP flink_taskmanager_Status_JVM_GarbageCollector_G1_Young_Generation_Count Count (scope: taskmanager_Status_JVM_GarbageCollector_G1_Young_Generation) # TYPE flink_taskmanager_Status_JVM_GarbageCollector_G1_Young_Generation_Count gauge flink_taskmanager_Status_JVM_GarbageCollector_G1_Young_Generation_Count{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 3.0 # HELP flink_taskmanager_Status_JVM_Memory_Metaspace_Committed Committed (scope: taskmanager_Status_JVM_Memory_Metaspace) # TYPE flink_taskmanager_Status_JVM_Memory_Metaspace_Committed gauge flink_taskmanager_Status_JVM_Memory_Metaspace_Committed{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 6.7375104E7 # HELP flink_taskmanager_Status_JVM_Memory_Heap_Max Max (scope: taskmanager_Status_JVM_Memory_Heap) # TYPE flink_taskmanager_Status_JVM_Memory_Heap_Max gauge flink_taskmanager_Status_JVM_Memory_Heap_Max{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 4.429185024E9 # HELP flink_taskmanager_Status_JVM_Memory_NonHeap_Committed Committed (scope: taskmanager_Status_JVM_Memory_NonHeap) # TYPE flink_taskmanager_Status_JVM_Memory_NonHeap_Committed gauge flink_taskmanager_Status_JVM_Memory_NonHeap_Committed{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 9.8787328E7 # HELP flink_taskmanager_Status_JVM_Memory_NonHeap_Used Used (scope: taskmanager_Status_JVM_Memory_NonHeap) # TYPE flink_taskmanager_Status_JVM_Memory_NonHeap_Used gauge flink_taskmanager_Status_JVM_Memory_NonHeap_Used{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 9.4597576E7 # HELP flink_taskmanager_Status_Shuffle_Netty_TotalMemorySegments TotalMemorySegments (scope: taskmanager_Status_Shuffle_Netty) # TYPE flink_taskmanager_Status_Shuffle_Netty_TotalMemorySegments gauge flink_taskmanager_Status_Shuffle_Netty_TotalMemorySegments{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 30037.0 # HELP flink_taskmanager_Status_Flink_Memory_Managed_Total Total (scope: taskmanager_Status_Flink_Memory_Managed) # TYPE flink_taskmanager_Status_Flink_Memory_Managed_Total gauge flink_taskmanager_Status_Flink_Memory_Managed_Total{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 4.294967296E9 # HELP flink_taskmanager_Status_JVM_CPU_Load Load (scope: taskmanager_Status_JVM_CPU) # TYPE flink_taskmanager_Status_JVM_CPU_Load gauge flink_taskmanager_Status_JVM_CPU_Load{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 0.002796347271376764 # HELP flink_taskmanager_Status_JVM_Memory_Mapped_Count Count (scope: taskmanager_Status_JVM_Memory_Mapped) # TYPE flink_taskmanager_Status_JVM_Memory_Mapped_Count gauge flink_taskmanager_Status_JVM_Memory_Mapped_Count{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 0.0 # HELP flink_taskmanager_Status_JVM_Memory_Heap_Committed Committed (scope: taskmanager_Status_JVM_Memory_Heap) # TYPE flink_taskmanager_Status_JVM_Memory_Heap_Committed gauge flink_taskmanager_Status_JVM_Memory_Heap_Committed{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 4.429185024E9 # HELP flink_taskmanager_Status_Network_AvailableMemorySegments AvailableMemorySegments (scope: taskmanager_Status_Network) # TYPE flink_taskmanager_Status_Network_AvailableMemorySegments gauge flink_taskmanager_Status_Network_AvailableMemorySegments{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 30037.0 # HELP flink_taskmanager_Status_JVM_Memory_Mapped_TotalCapacity TotalCapacity (scope: taskmanager_Status_JVM_Memory_Mapped) # TYPE flink_taskmanager_Status_JVM_Memory_Mapped_TotalCapacity gauge flink_taskmanager_Status_JVM_Memory_Mapped_TotalCapacity{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 0.0 # HELP flink_taskmanager_Status_JVM_GarbageCollector_G1_Old_Generation_Count Count (scope: taskmanager_Status_JVM_GarbageCollector_G1_Old_Generation) # TYPE flink_taskmanager_Status_JVM_GarbageCollector_G1_Old_Generation_Count gauge flink_taskmanager_Status_JVM_GarbageCollector_G1_Old_Generation_Count{host=&quot;172_26_129_190&quot;,tm_id=&quot;172_26_129_190:6122_3b582c&quot;,} 0.0 </code></pre> <p><strong>Note:</strong> No explicit filter/exclusion configured in the config file.<br /> Can anybody please help how can we get the <strong>taskmanager.job.</strong>* metrics including custom metrics?</p>
[ { "answer_id": 74387239, "author": "iRon", "author_id": 1701026, "author_profile": "https://Stackoverflow.com/users/1701026", "pm_score": 0, "selected": false, "text": "$Data = @{ CopyrightInfo = \"Copyright $([char]::ConvertFromUtf32(0x000000A9)) CompanyName $((Get-Date).Year)\" }\n$Json = ConvertTo-Json $Data\n$Json |Set-Content .\\Test.json\n$Json = Get-Content -Raw .\\Test.json\n$Data = ConvertFrom-Json $Json\n$Data\n" }, { "answer_id": 74389785, "author": "mklement0", "author_id": 45375, "author_profile": "https://Stackoverflow.com/users/45375", "pm_score": 2, "selected": true, "text": "Set-Content -Encoding utf8" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74386011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3336596/" ]
74,386,033
<p><a href="https://i.stack.imgur.com/IgWQd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IgWQd.png" alt="enter image description here" /></a></p> <p>I am not sure I can ask about just excel problems on stackoverflow.com. Just let me know gently If I am making mistakes.</p> <p>I need to concat vertical cells in col3.<br /> Their ranges depend on column 'num' which has numbers like 1(A2), 2(A7), 3(A9).<br /> So the result would be like 'aaa,bbb,ddd,eee', then 'ff', 'gg,abc'.<br /> I tried to use CONCATENATE or TEXTJOIN but I realized it wasn't that simple to do it.</p> <p>Is there any way to do it? Or do I need to learn VBA? Hope someone knows can guide to do it...</p>
[ { "answer_id": 74386532, "author": "5202456", "author_id": 5202456, "author_profile": "https://Stackoverflow.com/users/5202456", "pm_score": 2, "selected": true, "text": "=IF(A3=\"\",D2&CHAR(44)&D3,D3)" }, { "answer_id": 74386804, "author": "Robert Mearns", "author_id": 5050, "author_profile": "https://Stackoverflow.com/users/5050", "pm_score": 0, "selected": false, "text": "=TEXTJOIN(\",\",TRUE,D2:D11)\n" }, { "answer_id": 74387139, "author": "Tom Sharpe", "author_id": 3894917, "author_profile": "https://Stackoverflow.com/users/3894917", "pm_score": 1, "selected": false, "text": "=LET(freq,DROP(FREQUENCY(IF(A2:A15=\"\",ROW(A2:A15)),IF(A2:A15<>\"\",ROW(A2:A15))),1)+1,cols,MAX(freq),rows,ROWS(freq),\narray,SEQUENCE(rows,cols,0),start,XMATCH(QUOTIENT(array,cols)+1,A2:A15),strings,IF(MOD(array,cols)+1>freq,\"\",IF(INDEX(D2:D15,start+MOD(array,cols))=\"\",\"\",INDEX(D2:D15,start+MOD(array,cols)))),\nBYROW(strings,LAMBDA(s,TEXTJOIN(\",\",TRUE,s))))\n" }, { "answer_id": 74387453, "author": "zipa", "author_id": 5811078, "author_profile": "https://Stackoverflow.com/users/5811078", "pm_score": 0, "selected": false, "text": "E" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74386033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9062770/" ]
74,386,043
<p>I want to search for Windows paths on complete HTML document and save them in a array. The paths can be completely different. Except for the drive letter, everything that comes after it is uncertain.</p> <p>For example my HTML:</p> <pre><code>&lt;p&gt;Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. &lt;br&gt; &lt;br&gt; C:\Users\max\Documents&lt;br&gt; S:\Data\Customer&lt;br&gt; &lt;br&gt; Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.&lt;/p&gt; </code></pre>
[ { "answer_id": 74386532, "author": "5202456", "author_id": 5202456, "author_profile": "https://Stackoverflow.com/users/5202456", "pm_score": 2, "selected": true, "text": "=IF(A3=\"\",D2&CHAR(44)&D3,D3)" }, { "answer_id": 74386804, "author": "Robert Mearns", "author_id": 5050, "author_profile": "https://Stackoverflow.com/users/5050", "pm_score": 0, "selected": false, "text": "=TEXTJOIN(\",\",TRUE,D2:D11)\n" }, { "answer_id": 74387139, "author": "Tom Sharpe", "author_id": 3894917, "author_profile": "https://Stackoverflow.com/users/3894917", "pm_score": 1, "selected": false, "text": "=LET(freq,DROP(FREQUENCY(IF(A2:A15=\"\",ROW(A2:A15)),IF(A2:A15<>\"\",ROW(A2:A15))),1)+1,cols,MAX(freq),rows,ROWS(freq),\narray,SEQUENCE(rows,cols,0),start,XMATCH(QUOTIENT(array,cols)+1,A2:A15),strings,IF(MOD(array,cols)+1>freq,\"\",IF(INDEX(D2:D15,start+MOD(array,cols))=\"\",\"\",INDEX(D2:D15,start+MOD(array,cols)))),\nBYROW(strings,LAMBDA(s,TEXTJOIN(\",\",TRUE,s))))\n" }, { "answer_id": 74387453, "author": "zipa", "author_id": 5811078, "author_profile": "https://Stackoverflow.com/users/5811078", "pm_score": 0, "selected": false, "text": "E" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74386043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20466418/" ]
74,386,045
<p>&quot;WorkerProcessRestarting. Initialization timed out and host is shutting down&quot; Azure function app run time error for Isolated function, can someone please help.</p> <p>I created isolated function app in framework 4.8, not able to debug it locally or run it locally. Visual studio doesn't show any error when i try to debug the function app. It keeps processing without hitting the function and not returning any error. Then I tried to deploy it Azure, deployment went fine, when i Try to Run it, get below error in 10 secs &quot;WorkerProcessRestarting. Initialization timed out and host is shutting down&quot;</p>
[ { "answer_id": 74386532, "author": "5202456", "author_id": 5202456, "author_profile": "https://Stackoverflow.com/users/5202456", "pm_score": 2, "selected": true, "text": "=IF(A3=\"\",D2&CHAR(44)&D3,D3)" }, { "answer_id": 74386804, "author": "Robert Mearns", "author_id": 5050, "author_profile": "https://Stackoverflow.com/users/5050", "pm_score": 0, "selected": false, "text": "=TEXTJOIN(\",\",TRUE,D2:D11)\n" }, { "answer_id": 74387139, "author": "Tom Sharpe", "author_id": 3894917, "author_profile": "https://Stackoverflow.com/users/3894917", "pm_score": 1, "selected": false, "text": "=LET(freq,DROP(FREQUENCY(IF(A2:A15=\"\",ROW(A2:A15)),IF(A2:A15<>\"\",ROW(A2:A15))),1)+1,cols,MAX(freq),rows,ROWS(freq),\narray,SEQUENCE(rows,cols,0),start,XMATCH(QUOTIENT(array,cols)+1,A2:A15),strings,IF(MOD(array,cols)+1>freq,\"\",IF(INDEX(D2:D15,start+MOD(array,cols))=\"\",\"\",INDEX(D2:D15,start+MOD(array,cols)))),\nBYROW(strings,LAMBDA(s,TEXTJOIN(\",\",TRUE,s))))\n" }, { "answer_id": 74387453, "author": "zipa", "author_id": 5811078, "author_profile": "https://Stackoverflow.com/users/5811078", "pm_score": 0, "selected": false, "text": "E" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74386045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20466408/" ]
74,386,093
<p>Hello I have a <code>List&lt;Tuple&lt;int, int&gt;&gt;</code> and I want to check if there are repeated elements no matter the order. So, for example, if my list contains</p> <pre><code>List&lt;Tuple&lt;int, int&gt;&gt; tuple = new List&lt;Tuple&lt;int, int&gt;&gt;() { new Tuple&lt;int, int&gt;(1, 2), new Tuple&lt;int, int&gt;(2, 1), new Tuple&lt;int, int&gt;(3, 2) }; </code></pre> <p>I want to remove the the second item because it contains the same elements that the first but in reverse order (1,2) and (2,1).</p> <p>What would be the most efficient way to do it?</p>
[ { "answer_id": 74386239, "author": "Firo", "author_id": 671619, "author_profile": "https://Stackoverflow.com/users/671619", "pm_score": 2, "selected": false, "text": "var set = new HashSet<long>();\nvar unique = tuple.Where(t => set.Add((long)Math.Max(t.Item1, t.Item2) << 32 | Math.Min(t.Item1, t.Item2)))\n" }, { "answer_id": 74386449, "author": "Peter Csala", "author_id": 13268855, "author_profile": "https://Stackoverflow.com/users/13268855", "pm_score": 0, "selected": false, "text": "IEqualityComparer" }, { "answer_id": 74386525, "author": "Svyatoslav Danyliv", "author_id": 10646316, "author_profile": "https://Stackoverflow.com/users/10646316", "pm_score": 1, "selected": false, "text": "DistinctBy" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74386093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14366150/" ]
74,386,133
<p>I want to decrypt AES encrypted data with openssl command.</p> <ul> <li>Encrypted data: <code>GD5YV2naJZ/x3mQnfictWQ==</code> (base64 encoded)</li> <li>Key: <code>uHe2MCmggLlugpGBiMVuXTck7OT8Nk8g</code></li> <li>Cipher: AES-256-CBC</li> <li>IV: <code>LNP8U7pc6GjxzxAtgw4s3A==</code> (base64 encoded)</li> </ul>
[ { "answer_id": 74386539, "author": "Dawlatzai Ghousi", "author_id": 4217232, "author_profile": "https://Stackoverflow.com/users/4217232", "pm_score": 0, "selected": false, "text": "Illuminate\\Contracts\\Encryption\\DecryptException;\nuse Illuminate\\Support\\Facades\\Crypt;\n \ntry {\n $decrypted = Crypt::decryptString($encryptedValue);\n} catch (DecryptException $e) {\n //\n}\n" }, { "answer_id": 74386884, "author": "pynexj", "author_id": 900078, "author_profile": "https://Stackoverflow.com/users/900078", "pm_score": 2, "selected": true, "text": "$ echo GD5YV2naJZ/x3mQnfictWQ== | openssl base64 -d > data.enc\n$ iv=$( echo LNP8U7pc6GjxzxAtgw4s3A== | openssl base64 -d | xxd -p | tr -d '\\n' )\n$ echo $iv\n2cd3fc53ba5ce868f1cf102d830e2cdc\n$ key=$( echo uHe2MCmggLlugpGBiMVuXTck7OT8Nk8g | xxd -p | tr -d '\\n' )\n$ echo $key\n754865324d436d67674c6c7567704742694d56755854636b374f54384e6b38670a\n$ openssl aes-256-cbc -d -in data.enc -K $key -iv $iv\ns:4:\"Test\";\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74386133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8063455/" ]
74,386,140
<p>I am working with Reactjs using html, css, and javascript. I want to style active navigator item in the navbar with white border. That is mean the border will stay in the item while the page of this item is open.</p> <pre><code>import React, { useState } from &quot;react&quot;; import { Link } from &quot;react-router-dom&quot;; import &quot;./Navbar.css&quot;; import { navItems } from &quot;./NavItems&quot;; import Dropdown from &quot;./Dropdown&quot;; function Navbar() { const [dropdown, setDropdown] = useState(false); return ( &lt;&gt; &lt;nav className=&quot;navbar&quot;&gt; &lt;ul className=&quot;nav-items&quot;&gt; {navItems.map((item) =&gt; { if (item.id === &quot;C3&quot;) { return ( &lt;li key={item.id} className={item.cName} id={window.location.pathname === item.path? &quot;C10&quot;:&quot;&quot;} onMouseClick={() =&gt; setDropdown(true)} onMouseEnter={() =&gt; setDropdown(true)} onMouseLeave={() =&gt; setDropdown(false)} &gt; &lt;Link to={item.title}&gt;{item.title}&lt;/Link&gt; {dropdown &amp;&amp; &lt;Dropdown /&gt;} &lt;/li&gt; ); } return ( &lt;li key={item.id} className={item.cName} id={window.location.pathname === item.path? &quot;C10&quot;:&quot;&quot;} &gt; &lt;Link to={item.path}&gt;{item.title}&lt;/Link&gt; &lt;/li&gt; ); })} &lt;/ul&gt; &lt;/nav&gt; &lt;/&gt; ); } export default Navbar; </code></pre> <p>This is the CSS file</p> <pre><code> .nav-item a:hover { border: solid 2px white; } #C10{ border: solid 2px white; } </code></pre> <p>I try to use this method in CSS file.</p> <pre><code>.nav-item a:active { border: solid 2px white; } </code></pre> <p>and I use this method in CSS file and JS file also but it does not work!</p> <pre><code>id={window.location.pathname === item.path? &quot;C10&quot;:&quot;&quot;} #C10{ border: solid 2px white; } </code></pre>
[ { "answer_id": 74386539, "author": "Dawlatzai Ghousi", "author_id": 4217232, "author_profile": "https://Stackoverflow.com/users/4217232", "pm_score": 0, "selected": false, "text": "Illuminate\\Contracts\\Encryption\\DecryptException;\nuse Illuminate\\Support\\Facades\\Crypt;\n \ntry {\n $decrypted = Crypt::decryptString($encryptedValue);\n} catch (DecryptException $e) {\n //\n}\n" }, { "answer_id": 74386884, "author": "pynexj", "author_id": 900078, "author_profile": "https://Stackoverflow.com/users/900078", "pm_score": 2, "selected": true, "text": "$ echo GD5YV2naJZ/x3mQnfictWQ== | openssl base64 -d > data.enc\n$ iv=$( echo LNP8U7pc6GjxzxAtgw4s3A== | openssl base64 -d | xxd -p | tr -d '\\n' )\n$ echo $iv\n2cd3fc53ba5ce868f1cf102d830e2cdc\n$ key=$( echo uHe2MCmggLlugpGBiMVuXTck7OT8Nk8g | xxd -p | tr -d '\\n' )\n$ echo $key\n754865324d436d67674c6c7567704742694d56755854636b374f54384e6b38670a\n$ openssl aes-256-cbc -d -in data.enc -K $key -iv $iv\ns:4:\"Test\";\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74386140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19187485/" ]
74,386,141
<p>I need to get all values that are numbers from:</p> <pre><code>lst = [7, 18, 3, 'a', True, (2,3)] </code></pre> <p>So I need to get 7,8 and 3. How can I get that?</p> <p>I tried using function <code>isnumeric</code> and <code>isdigit</code>. It returns error -&gt;</p> <pre><code>AttributeError: 'int' object has no attribute 'isnumeric' </code></pre>
[ { "answer_id": 74386179, "author": "KillerRebooted", "author_id": 18554284, "author_profile": "https://Stackoverflow.com/users/18554284", "pm_score": 1, "selected": false, "text": "type()" }, { "answer_id": 74386245, "author": "ML-1994", "author_id": 17385629, "author_profile": "https://Stackoverflow.com/users/17385629", "pm_score": -1, "selected": false, "text": "lst = [7, 18, 3, 'a', True, (2,3)]\n[x for x in lst if isinstance(x, int)]\n\n==> [7, 18, 3, True]\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74386141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19801339/" ]
74,386,191
<p>I am getting response as</p> <p>{ &quot;statusCode&quot;: 219, &quot;body&quot;: &quot;{&quot;message&quot;: &quot;otp sent to user&quot;, &quot;session&quot;: &quot;f603ee03-4906-4451-b4e5-b19f0ccf84d0&quot;, &quot;otp&quot;: &quot;123456&quot;}&quot; }</p> <p>I want to get the Session number from this response. Do we have any suggestions</p> <p>I tried post processors however couldn't as the response is in string</p>
[ { "answer_id": 74386179, "author": "KillerRebooted", "author_id": 18554284, "author_profile": "https://Stackoverflow.com/users/18554284", "pm_score": 1, "selected": false, "text": "type()" }, { "answer_id": 74386245, "author": "ML-1994", "author_id": 17385629, "author_profile": "https://Stackoverflow.com/users/17385629", "pm_score": -1, "selected": false, "text": "lst = [7, 18, 3, 'a', True, (2,3)]\n[x for x in lst if isinstance(x, int)]\n\n==> [7, 18, 3, True]\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74386191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9228859/" ]
74,386,202
<p>I'm sure I'm missing something obvious here but I've had a really good look over this, combing for typos and such but I can't see what the problem is. I want this to be a simple form that requires a username/password combination to validate. The usernames/passwords having to match hasn't been implemented yet because my initial testing can't get over this first hurdle of the form always validating!</p> <p>I've definitely made a solid go at it and I feel bad I'm getting stuck here, even looking over tons of references and comparing them to my own. I'm not even sure if the event listener itself is the problem or if the problem comes from poor coding in the function. Opening console in browser shows me no errors either. Could anybody point out where my issue is? Thanks.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>"use strict"; let loginform = document.forms.login; loginform.addEventListener("submit", checkLogin); let users = []; let pwords = []; users = ["Administrator", "Manager", "Cleric", "Scribe"]; pwords = ["Password01", "Password", "Admin", "P@ssword"]; //*** NOTE: the password for each username is specific. Use the the alignment of the data in the table above (i.e. the password for the Administrator account is Password01, etc.). *** function checkLogin() { var usernameInput = loginform.getElementById("Username").value; var pwInput = loginform.getElementById("Password").value; //.includes is what we need for the array checking if statements //For Loop 1 for (usernameInput in users) { if (!users.includes(usernameInput)) { window.event.preventDefault(); alert("Your username is incorrect. Please try again.") loginform.user.focus(); return false; } else { //For Loop 2 for (pwInput in pwords) { if (!pwords.includes(pwInput)) { window.event.preventDefault(); alert("Your password is incorrect. Please try again.") loginform.pword.focus(); return false; } } } } }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;h1 id="main"&gt;Login to Umbrella Corporation&lt;/h1&gt; &lt;div id="container"&gt; &lt;form name="login" action="success.html" method="POST"&gt; &lt;input type="text" name="user" id="Username"&gt; &lt;br&gt; &lt;br&gt; &lt;input type="password" name="pword" id="Password"&gt; &lt;br&gt; &lt;br&gt; &lt;input type="submit" value="Submit"&gt; &lt;input type="reset" value="Reset"&gt; &lt;/form&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74386368, "author": "mplungjan", "author_id": 295783, "author_profile": "https://Stackoverflow.com/users/295783", "pm_score": 1, "selected": true, "text": "var usernameInput = loginform.user.value;\nvar pwInput = loginform.pword.value;\n\n\nvar usernameInput = loginform.querySelector(\"#Username\").value;\nvar pwInput = loginform.querySelector(\"#Password\").value;\n\n\nvar usernameInput = document.getElementById(\"Username\").value;\nvar pwInput = document.getElementById(\"Password\").value;\n" }, { "answer_id": 74386386, "author": "Sudhanva M", "author_id": 13221168, "author_profile": "https://Stackoverflow.com/users/13221168", "pm_score": -1, "selected": false, "text": "var usernameInput = loginform.getElementById(\"Username\").value;\n\nfor (usernameInput in users) {...}\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74386202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19372608/" ]
74,386,216
<pre><code> Dim connect As String = &quot;Data Source=DESKTOP-D32ONKB;Initial Catalog=Attendance;Integrated Security=True&quot; Using conn As New SqlConnection(connect) Dim dt As DataTable = New DataTable() Dim sql As String = &quot;SELECT ID,Name,Class,Date FROM stuattrecordAMPM&quot; Using command As New SqlCommand(sql, conn) Using adapter As New SqlDataAdapter(command) Dim i As Integer = 0 For i = 0 To dt.Rows.Count - 1 Dim sy As String = dt.Rows(i).Item(0).ToString Next 'command.Parameters.Add(&quot;@ID&quot;, SqlDbType.Int).Value = Convert.ToInt32(TextBox1.Text) adapter.Fill(dt) TextBox1.Text = dt(0)(0) End Using End Using End Using </code></pre> <p>This code working properly asper my expectation. When I use &quot;where ID=@ID&quot; in sqlcommand It's showing error: 'Input string was not in a correct format.'</p> <pre><code> Dim connect As String = &quot;Data Source=DESKTOP-D32ONKB;Initial Catalog=Attendance;Integrated Security=True&quot; Using conn As New SqlConnection(connect) Dim dt As DataTable = New DataTable() Dim sql As String = &quot;SELECT ID,Name,Class,Date FROM stuattrecordAMPM where ID=@ID&quot; Using command As New SqlCommand(sql, conn) Using adapter As New SqlDataAdapter(command) Dim i As Integer = 0 For i = 0 To dt.Rows.Count - 1 Dim sy As String = dt.Rows(i).Item(0).ToString Next command.Parameters.Add(&quot;@ID&quot;, SqlDbType.Int).Value = Convert.ToInt32(TextBox1.Text) adapter.Fill(dt) TextBox1.Text = dt(0)(0) End Using End Using End Using </code></pre> <p>In this code I'm getting error. Could someone help me how to declare &quot;@ID&quot;. Thank you.. Please check the error description. <a href="https://i.stack.imgur.com/HEBAW.jpg" rel="nofollow noreferrer">enter image description here</a></p>
[ { "answer_id": 74386566, "author": "Devrim Mert Yöyen", "author_id": 20466471, "author_profile": "https://Stackoverflow.com/users/20466471", "pm_score": 1, "selected": false, "text": "Dim idValue As Int = Convert.ToInt32(TextBox1.Text)\nDim dt As DataTable = New DataTable() \nDim connect As String = \"Data Source=DESKTOP-D32ONKB;Initial Catalog=Attendance;Integrated Security=True\"\nUsing conn As New SqlConnection(connect) \n Dim sql As String = \"SELECT ID,Name,Class,Date FROM stuattrecordAMPM where ID=@ID\"\n Using command As New SqlCommand(sql, conn)\n command.Parameters.Add(\"@ID\", SqlDbType.Int).Value = idValue\n Using adapter As New SqlDataAdapter(command) \n adapter.Fill(dt) \n End Using \n End Using\nEnd Using\nDim i As Integer = 0\nFor i = 0 To dt.Rows.Count - 1\n Dim sy As String = dt.Rows(i).Item(0).ToString\nNext\nTextBox1.Text = dt(0)(0)\n" }, { "answer_id": 74392353, "author": "Albert D. Kallal", "author_id": 10527, "author_profile": "https://Stackoverflow.com/users/10527", "pm_score": 0, "selected": false, "text": " dim strSQL as string = \"SELECT * FROM MyTable\"\n dim strWhere as string = \"\"\n\n dim cmdSQL as New Sqlcommand(\"\", new Sqlconneciton(\"con string here\")\n\n ' add first @id\n strWhere = \"@ID1\"\n cmd.SQL.Paramters.Add(\"@ID1\", SqlDbType.Int).Value = 124\n\n ' add 2nd @!id\n strWhere &= \",@ID2\"\n cmd.SQL.Paramaters.Add(\"@ID2\", SqlDbType.Int).Value = 456\n\n ' and so on and so on\n cmdSQL.CommandText = strSQL & \" WHERE ID IN (\" & strWhere & \")\"\n dim rstData as new DataTable()\n cmdSQL.conneciton.Open()\n rstData.Load(cmdSQL.ExectuteReader())\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74386216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20369318/" ]
74,386,250
<p>I am trying to remove last character from a string in react</p> <p><code>val = &quot;string&quot;</code></p> <p><code>const newVal = value.split(&quot;&quot;);</code></p> <p>i tried this but this didn't helped.</p>
[ { "answer_id": 74386267, "author": "UNRIVALLEDKING", "author_id": 17525745, "author_profile": "https://Stackoverflow.com/users/17525745", "pm_score": 2, "selected": true, "text": "const newVal = value.slice(0, -1);\n" }, { "answer_id": 74386414, "author": "Uri Loya", "author_id": 6447529, "author_profile": "https://Stackoverflow.com/users/6447529", "pm_score": 0, "selected": false, "text": "const newVal = val.substring(0, val.length - 1);\n" }, { "answer_id": 74386643, "author": "HappyKoala", "author_id": 13658665, "author_profile": "https://Stackoverflow.com/users/13658665", "pm_score": 0, "selected": false, "text": "val = \"string\";\n// const newVal = value.split(\"\");\nconst newVal = val.substring(0, val.length-1);\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74386250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18804413/" ]
74,386,274
<p>I am importing a library and I get this error when compiling:</p> <pre><code>go.cu(61): error: calling a __host__ function(&quot;TinyJS::Interpreter::Interpreter()&quot;) from a __global__ function(&quot;capnduk_kernel&quot;) is not allowed </code></pre> <p>...is there a way to port an entire file (<a href="https://github.com/gfwilliams/tiny-js/blob/master/TinyJS.cpp" rel="nofollow noreferrer">TinyJS</a>) to run on the device?</p> <p>I've checked the compiler documentation, and it doesn't look like there's a way to do this. I'm guessing the only way is to rewrite the file by hand, which is a can of worms.</p>
[ { "answer_id": 74391883, "author": "Robert Crovella", "author_id": 1695960, "author_profile": "https://Stackoverflow.com/users/1695960", "pm_score": 2, "selected": false, "text": "nvcc" }, { "answer_id": 74404074, "author": "einpoklum", "author_id": 1593077, "author_profile": "https://Stackoverflow.com/users/1593077", "pm_score": 0, "selected": false, "text": "--device-as-default-execution-space" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74386274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970175/" ]
74,386,285
<p>I am at loss on how to generate a new column with <code>dplyr</code> when using a conditional statement across multiple columns.</p> <p>Given some data</p> <pre><code>library(dplyr) a &lt;- data.frame(var1 = c(&quot;one&quot;, &quot;two&quot;, &quot;three&quot;), var2 = c(&quot;three&quot;, &quot;one&quot;, &quot;three&quot;), var3 = c(&quot;three&quot;, &quot;two&quot;, NA)) </code></pre> <pre><code>&gt; a var1 var2 var3 1 one three three 2 two one two 3 three three &lt;NA&gt; </code></pre> <p>I would like to compute a new column matching a set of conditions (whether <code>&quot;one&quot;</code>, <code>&quot;two&quot;</code>, or <code>&quot;three&quot;</code> are present or not; if so, return an arbitrary value <code>1</code>, <code>2</code>, or <code>3</code>), in order of priority where <code>&quot;one&quot;</code> would have the highest priority and <code>&quot;three&quot;</code> the lowest (i.e., the returned vector should be <code>1 1 3</code>).</p> <p>My way of approaching it would be</p> <pre><code>a %&gt;% mutate(new_variable = case_when( &quot;one&quot; %in% across(starts_with(&quot;var&quot;)) ~ 1, &quot;two&quot; %in% across(starts_with(&quot;var&quot;)) ~ 2, &quot;three&quot; %in% across(starts_with(&quot;var&quot;)) ~ 3, TRUE ~ NA)) </code></pre> <p>This obviously doesn't work and I suspect it would search for a match the full three columns, if it did. Is there a way in <code>tidyverse</code> to do it? Thanks!</p>
[ { "answer_id": 74386749, "author": "Aron Strandberg", "author_id": 4885169, "author_profile": "https://Stackoverflow.com/users/4885169", "pm_score": 3, "selected": true, "text": "mapping <- c(\"one\" = 1, \"two\" = 2, \"three\" = 3)\n\napply(a, 1, \\(x) min(mapping[x], na.rm = TRUE))\n\n#> [1] 1 1 3\n" }, { "answer_id": 74387514, "author": "Chris Ruehlemann", "author_id": 8039978, "author_profile": "https://Stackoverflow.com/users/8039978", "pm_score": 1, "selected": false, "text": "tidyverse" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74386285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10798015/" ]
74,386,325
<p>Given the following input</p> <pre><code>{ &quot;environment&quot;: [ { &quot;name&quot;: &quot;AAA&quot;, &quot;value&quot;: &quot;1111&quot; }, { &quot;name&quot;: &quot;BBB&quot;, &quot;value&quot;: &quot;2222&quot; }, { &quot;name&quot;: &quot;CCC&quot;, &quot;value&quot;: &quot;3333&quot; }, { &quot;name&quot;: &quot;DDD&quot;, &quot;value&quot;: &quot;4444&quot; } ] } </code></pre> <p>If CCC exists, then write out on a single line of certain values 1111, 2222, 4444 Else Write Nothing</p> <p>jq -r '.environment[] | select (.name == &quot;CCC&quot;) | [.name, .value] | @csv'</p> <p>Don't know how to write the other values.</p> <p>Would like to see the values 1111, 2222, 3333</p>
[ { "answer_id": 74386749, "author": "Aron Strandberg", "author_id": 4885169, "author_profile": "https://Stackoverflow.com/users/4885169", "pm_score": 3, "selected": true, "text": "mapping <- c(\"one\" = 1, \"two\" = 2, \"three\" = 3)\n\napply(a, 1, \\(x) min(mapping[x], na.rm = TRUE))\n\n#> [1] 1 1 3\n" }, { "answer_id": 74387514, "author": "Chris Ruehlemann", "author_id": 8039978, "author_profile": "https://Stackoverflow.com/users/8039978", "pm_score": 1, "selected": false, "text": "tidyverse" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74386325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20466574/" ]
74,386,327
<p>I have a problem where my code tries to call <code>pthread_mutex_destory()</code> twice. I need to check whether the lock have been destroyed before or not.</p> <p>How can I do this? Will this work:</p> <pre><code>void deinit() { if(1 == pthread_mutex_trylock(&amp;this-&gt;m_lock)) { (void) pthread_mutex_destroy(&amp;this-&gt;m_lock); } } </code></pre> <p>Will <code>trylock</code> only check weather the mutex is locked or not or will it also show me weather it is deleted or not?</p>
[ { "answer_id": 74386611, "author": "David van rijn", "author_id": 4313775, "author_profile": "https://Stackoverflow.com/users/4313775", "pm_score": 3, "selected": true, "text": "pthread_mutex_destroy" }, { "answer_id": 74393040, "author": "John Bollinger", "author_id": 2402272, "author_profile": "https://Stackoverflow.com/users/2402272", "pm_score": 1, "selected": false, "text": "pthread_mutex_t" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74386327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19574336/" ]
74,386,350
<p>There is a dataframe with hourly data, e.g.:</p> <pre><code> DATE TIME Amount 2022-11-07 21:00:00 10 2022-11-07 22:00:00 11 2022-11-08 07:00:00 10 2022-11-08 08:00:00 13 2022-11-08 09:00:00 12 2022-11-08 10:00:00 11 2022-11-08 11:00:00 13 2022-11-08 12:00:00 12 2022-11-08 13:00:00 10 2022-11-08 14:00:00 9 ... </code></pre> <p>I would like to add a new column sum_morning where I calculate the sum of &quot;Amount&quot; for the morning hours only (07:00 - 12:00):</p> <pre><code> DATE TIME Amount sum_morning 2022-11-07 21:00:00 10 NaN 2022-11-07 22:00:00 11 NaN 2022-11-08 07:00:00 10 NaN 2022-11-08 08:00:00 13 NaN 2022-11-08 09:00:00 12 NaN 2022-11-08 10:00:00 11 NaN 2022-11-08 11:00:00 13 NaN 2022-11-08 12:00:00 12 71 2022-11-08 13:00:00 10 NaN 2022-11-08 14:00:00 9 NaN ... </code></pre> <p>There can be gaps in the dataframe (e.g. from 22:00 - 07:00), so shift is probably not working here.</p> <p>I thought about</p> <ul> <li>creating a new dataframe where I filter all time slices from 07:00 - 12:00 for all dates</li> <li>do a group by and calculate the sum for each day</li> <li>and then merge this back to the original df.</li> </ul> <p>But maybe there is a more effective solution?</p> <p>I really enjoy working with Python / pandas, but hourly data still makes my head spin.</p>
[ { "answer_id": 74386428, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 2, "selected": false, "text": "DatetimeIndex" }, { "answer_id": 74386513, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 2, "selected": false, "text": "# get values between 7 and 12h\nm = pd.to_timedelta(df['TIME']).between('7h', '12h')\n\n# find last True per day\nidx = m&m.groupby(df['DATE']).shift(-1).ne(True)\n\n# assign the sum of the 7-12h values on the last True per day\ndf.loc[idx, 'sum_morning'] = df['Amount'].where(m).groupby(df['DATE']).transform('sum')\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74386350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8518582/" ]
74,386,372
<p>I want to create a function that will take an object of student exam scores and calculate the total scores for all subjects for each student, then sort the students in the object based on their total_score.</p> <p>Below is the before mapping and sorting, and the expected result.</p> <pre><code>const studentsExamScore = [ { name: &quot;Patty Colon&quot;, roll: &quot;1001&quot;, subjects: [ { name: &quot;Match&quot;, score: 76, }, { name: &quot;Physics&quot;, score: 84, }, { name: &quot;Chemistry&quot;, score: 82, }, ], }, { name: &quot;Fredrick Hubbard&quot;, roll: &quot;1002&quot;, subjects: [ { name: &quot;Match&quot;, score: 86, }, { name: &quot;Physics&quot;, score: 88, }, { name: &quot;Chemistry&quot;, score: 67, }, ], }, { name: &quot;Deanna Hogan&quot;, roll: &quot;1003&quot;, subjects: [ { name: &quot;Match&quot;, score: 77, }, { name: &quot;Physics&quot;, score: 75, }, { name: &quot;Chemistry&quot;, score: 94, }, ], }, ]; </code></pre> <p><strong>Expected Output</strong></p> <p>The total_score is added to each student and they are sorted by their total score.</p> <pre><code>const ExpectedStudentListOutput = [ { name: &quot;Patty Colon&quot;, roll: &quot;1001&quot;, total_score: 242, subjects: [ { name: &quot;Match&quot;, score: 76, }, { name: &quot;Physics&quot;, score: 84, }, { name: &quot;Chemistry&quot;, score: 82, }, ], }, { name: &quot;Fredrick Hubbard&quot;, roll: &quot;1002&quot;, total_score: 241, subjects: [ { name: &quot;Match&quot;, score: 86, }, { name: &quot;Physics&quot;, score: 88, }, { name: &quot;Chemistry&quot;, score: 67, }, ], }, { name: &quot;Carrie Schneider&quot;, roll: &quot;1004&quot;, total_score: 236, subjects: [ { name: &quot;Match&quot;, score: 88, }, { name: &quot;Physics&quot;, score: 83, }, { name: &quot;Chemistry&quot;, score: 65, }, ], }, ]; </code></pre>
[ { "answer_id": 74386428, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 2, "selected": false, "text": "DatetimeIndex" }, { "answer_id": 74386513, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 2, "selected": false, "text": "# get values between 7 and 12h\nm = pd.to_timedelta(df['TIME']).between('7h', '12h')\n\n# find last True per day\nidx = m&m.groupby(df['DATE']).shift(-1).ne(True)\n\n# assign the sum of the 7-12h values on the last True per day\ndf.loc[idx, 'sum_morning'] = df['Amount'].where(m).groupby(df['DATE']).transform('sum')\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74386372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19571681/" ]
74,386,383
<p>I have an Ansible job that run on 2 or more urls. Each url returns the same variables with different values. Here is the JSON data registry of the job:</p> <pre><code>{ &quot;msg&quot;: { &quot;results&quot;: [ { &quot;url&quot;: &quot;http://0.0.0.1:xxx1&quot;, &quot;othervar&quot;: &quot;othervar&quot;, &quot;othervar2&quot;: &quot;othervar2&quot;, &quot;json&quot;: { &quot;messages&quot;: [ { &quot;message&quot;: &quot;This is message number 1&quot;, &quot;message2&quot;: &quot;This is message2 number 1&quot; }, { &quot;message&quot;: &quot;This is message number 2&quot;, &quot;message2&quot;: &quot;This is message2 number 2&quot; }, { &quot;message&quot;: &quot;This is message number 3&quot;, &quot;message2&quot;: &quot;This is message2 number 3&quot; } ] } }, { &quot;url&quot;: &quot;http://0.0.0.2:xxx2&quot;, &quot;othervar&quot;: &quot;othervar&quot;, &quot;othervar2&quot;: &quot;othervar2&quot;, &quot;json&quot;: { &quot;messages&quot;: [ { &quot;message&quot;: &quot;This is message number 1&quot;, &quot;message2&quot;: &quot;This is message2 number 1&quot; }, { &quot;message&quot;: &quot;This is message number 2&quot;, &quot;message2&quot;: &quot;This is message2 number 2&quot; }, { &quot;message&quot;: &quot;This is message number 3&quot;, &quot;message2&quot;: &quot;This is message2 number 3&quot; } ] } } ] } } </code></pre> <p>I want to make a specific dict containing only the <code>url</code> variable and also <code>message</code> and <code>message2</code> variables. I have 2 options for my expected results:</p> <p>option 1:</p> <pre><code>&quot;message&quot;: [ { &quot;url&quot;: &quot;http://0.0.0.1:xxx1&quot;, &quot;content&quot;: [ { &quot;message&quot;: &quot;This is message number 1&quot;, &quot;message2&quot;: &quot;This is message2 number 1&quot; }, { &quot;message&quot;: &quot;This is message number 2&quot;, &quot;message2&quot;: &quot;This is message2 number 2&quot; }, { &quot;message&quot;: &quot;This is message number 3&quot;, &quot;message2&quot;: &quot;This is message2 number 3&quot; } ] }, { &quot;url&quot;: &quot;http://0.0.0.2:xxx2&quot;, &quot;content&quot;: [ { &quot;message&quot;: &quot;This is message number 1&quot;, &quot;message2&quot;: &quot;This is message2 number 1&quot; }, { &quot;message&quot;: &quot;This is message number 2&quot;, &quot;message2&quot;: &quot;This is message2 number 2&quot; }, { &quot;message&quot;: &quot;This is message number 3&quot;, &quot;message2&quot;: &quot;This is message2 number 3&quot; } ] } </code></pre> <p>option 2:</p> <pre><code>&quot;message&quot;: [ { &quot;url&quot;: &quot;http://0.0.0.0:xxx1&quot;, &quot;message&quot;: &quot;This is message number 1&quot;, &quot;message2&quot;: &quot;This is message2 number 1&quot; }, { &quot;url&quot;: &quot;http://0.0.0.0:xxx1&quot;, &quot;message&quot;: &quot;This is message number 2&quot;, &quot;message2&quot;: &quot;This is message2 number 2&quot; }, { &quot;url&quot;: &quot;http://0.0.0.0:xxx1&quot;, &quot;message&quot;: &quot;This is message number 2&quot;, &quot;message2&quot;: &quot;This is message2 number 2&quot; }, { &quot;url&quot;: &quot;http://0.0.0.0:xxx2&quot;, &quot;message&quot;: &quot;This is message number 1&quot;, &quot;message2&quot;: &quot;This is message2 number 1&quot; }, { &quot;url&quot;: &quot;http://0.0.0.0:xxx2&quot;, &quot;message&quot;: &quot;This is message number 2&quot;, &quot;message2&quot;: &quot;This is message2 number 2&quot; }, { &quot;url&quot;: &quot;http://0.0.0.0:xxx2&quot;, &quot;message&quot;: &quot;This is message number 2&quot;, &quot;message2&quot;: &quot;This is message2 number 2&quot; } ] </code></pre> <p>I am able to get each variable (url only, message only, message2 only) but how can i merge them into a dict like option 1 or option 2?</p>
[ { "answer_id": 74388094, "author": "guido", "author_id": 389099, "author_profile": "https://Stackoverflow.com/users/389099", "pm_score": 0, "selected": false, "text": "---\n- name: Playbook for infinispan Hosts\n hosts: localhost\n tasks:\n - name: load json from file\n shell: cat test.json\n register: result\n - name: save the input json data to a variable\n set_fact:\n jsondata: \"{{ result.stdout | from_json }}\"\n - name: display the input dict\n debug:\n var: jsondata\n - name: parse the json into new array\n set_fact:\n message: \"{{ message|default([]) + [ { 'url': item.url, 'content': item.json.messages } ] }}\"\n loop: \"{{ jsondata.msg.results }}\"\n - name: display the resulting data structure\n debug:\n var: message\n" }, { "answer_id": 74389248, "author": "Zeitounator", "author_id": 9401096, "author_profile": "https://Stackoverflow.com/users/9401096", "pm_score": 3, "selected": true, "text": " my_results: \"{{ results | json_query('[].{\\\"url\\\": url, \\\"content\\\": json.messages}') }}\"\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74386383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17504121/" ]