qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,472,892
<p>I have a script that fetches weather api then should output the data into a file, my problem is that in the last loop it outputs the results into a file that has the variable value instead of the name. Is there a way to use the variable name instead?</p> <pre><code>#city tromso=&quot;lat=69.6492&amp;lon=18.9553&quot; gjovik=&quot;lat=60.8941&amp;lon=10.5001&quot; oslo=&quot;lat=59.9139&amp;lon=10.7522&quot; trondheim=&quot;lat=63.4305&amp;lon=10.39.51&quot; bergen=&quot;lat=60.3913&amp;lon=5.3221&quot; echo &quot;a&quot; #Creates a directory #mkdir scraped-weather #Loops through the cities and puts the name in for CITY in tromso gjovik oslo trondheim bergen; do echo ${CITY} &gt; ${CITY}.txt done echo &quot;b&quot; #I get the data for each city and puts it in the city file for CITY in $tromso $gjovik $oslo $trondheim $bergen; do curl -s &quot;$API$CITY&quot; | grep -A5 -E '[0-9]{2}-[0-9]{2}-[0-9]{2}' &gt;&gt; ${CITY}.txt done </code></pre>
[ { "answer_id": 74473042, "author": "Prafull Ladha", "author_id": 6843187, "author_profile": "https://Stackoverflow.com/users/6843187", "pm_score": 1, "selected": false, "text": "kubectl delete pod $(kubectl get pod | grep apisix | awk '{print $1}')\n" }, { "answer_id": 74473187, "author": "Michail Alexakis", "author_id": 1943126, "author_profile": "https://Stackoverflow.com/users/1943126", "pm_score": 0, "selected": false, "text": "selector" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74472892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20400773/" ]
74,472,942
<p>I am using MutableStateFlow in my jetpack compose. Like below</p> <pre><code>val isBluetoothEnabled = MutableStateFlow(false) </code></pre> <p>whenever I tried to use the value of variable like this <code>.value</code> i.e. <code>isBluetoothEnabled.value</code>. So I am trying to use delegate property to avoid using <code>.value</code></p> <pre><code>val isBluetoothEnabled by MutableStateFlow(false) </code></pre> <p>but I am getting weird error</p> <pre><code>Type 'MutableStateFlow&lt;TypeVariable(T)&gt;' has no method 'getValue(PairViewModel, KProperty&lt;*&gt;)' and thus it cannot serve as a delegate </code></pre>
[ { "answer_id": 74473042, "author": "Prafull Ladha", "author_id": 6843187, "author_profile": "https://Stackoverflow.com/users/6843187", "pm_score": 1, "selected": false, "text": "kubectl delete pod $(kubectl get pod | grep apisix | awk '{print $1}')\n" }, { "answer_id": 74473187, "author": "Michail Alexakis", "author_id": 1943126, "author_profile": "https://Stackoverflow.com/users/1943126", "pm_score": 0, "selected": false, "text": "selector" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74472942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11560810/" ]
74,472,967
<p>I'm trying to get the parent of some deeply nested element like below</p> <pre><code>&lt;div class='content id='cart-content'&gt; &lt;div class='child1'&gt; &lt;div class='child1-1'&gt; &lt;div class='child1-1-1'&gt; &lt;input type=&quot;checkbox&quot; class='selectAllItem' name='selectAllItem' /&gt; Select All &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class='child2'&gt; &lt;div class='child2-2'&gt; &lt;div class='child2-2-2'&gt; &lt;input type=&quot;checkbox&quot; class='selectOneItem' name='selectOneItem' /&gt; Select One &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>when i check <code>Select All</code> box I want to get the node of the root parent which have <code>id='cart-content'</code></p> <p>my approach 1.</p> <pre><code>let rootNode = event.target.closest('#cart-content') </code></pre> <p>but the problem is clicking on <code>select one checkbox</code> would also return same result because they both have same root parent and are on same level</p> <p>approach 2.</p> <pre><code>let rootNode = event.target.parentNode.parentNode.parentNode.parentNode; </code></pre> <p>the problem with this approach is the same if i click on <code>select one</code> checkbox would also return the root parent because the distance between the element and the root parent is also 4 parents</p> <p>Now in <code>jquery</code> i would do the below to get desire result</p> <p><code>let rootNode = $(this).parent('.child1-1-1').parents('#');</code></p> <p>and when select one is clicked it won't return the rootNode because it doesn't have a direct parent with the class name <code>child1-1-1</code></p> <p>How can I achieve this same result using pure javascript vanilla js</p> <p>Thanks for any help</p>
[ { "answer_id": 74474334, "author": "gustavo catala sverdrup", "author_id": 15339988, "author_profile": "https://Stackoverflow.com/users/15339988", "pm_score": 0, "selected": false, "text": "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\" />\n <title>Static Template</title>\n </head>\n <body>\n <h1>\n This is a static template, there is no bundler or bundling involved!\n </h1>\n <div class=\"content\" id=\"cart-content\">\n <div class=\"child1\">\n <div class=\"child1-1\">\n <div class=\"child1-1-1\">\n <input\n id=\"input1\"\n type=\"checkbox\"\n class=\"selectAllItem selectinput\"\n name=\"selectAllItem\"\n />\n Select All\n </div>\n </div>\n </div>\n\n <div class=\"child2\">\n <div class=\"child2-2\">\n <div class=\"child2-2-2\">\n <input\n id=\"input2\"\n type=\"checkbox\"\n class=\"selectOneItem selectinput\"\n name=\"selectOneItem\"\n />\n Select One\n </div>\n </div>\n </div>\n </div>\n </body>\n <script>\n let allInputs = document.getElementsByClassName(\"selectinput\");\n\n allInputs = [...allInputs];\n allInputs.forEach((input) => {\n input.addEventListener('change', (e) => {\n let parentNode;\n if (e.target.id == \"input1\") {\n parentNode = e.target.parentNode.parentNode.parentNode.parentNode;\n // Do something with parentNode\n console.log(parentNode)\n }\n else{\n // Do something else\n }\n });\n });\n </script>\n</html>" }, { "answer_id": 74474696, "author": "sam", "author_id": 1977250, "author_profile": "https://Stackoverflow.com/users/1977250", "pm_score": 1, "selected": false, "text": "var rootParentNode = e.target.parentNode.classList.contains('child1-1-1') ? e.target.closest('#cart-content') : null;" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74472967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1977250/" ]
74,473,008
<p>To make a concept checking if a type can be converted without narrowing to another, it is proposed <a href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0870r4.html" rel="nofollow noreferrer">here</a> to make it using std::forward and std::type_identity_t like this:</p> <pre><code>template&lt;class T, class U&gt; concept __construct_without_narrowing = requires (U&amp;&amp; x) { { std::type_identity_t&lt;T[]&gt;{std::forward&lt;U&gt;(x)} } -&gt; T[1]; }; </code></pre> <p>I understand from it why something like this:</p> <pre><code>To{std::declval&lt;From&gt;()} </code></pre> <p>gives incorrect results, but when i try to simplify it using another idea in the paper, writing just</p> <pre><code>template &lt;typename From, typename To&gt; concept WithoutNarrowing = requires (From x) { {(To[1]){x}} -&gt;std::same_as&lt;To[1]&gt;; }; </code></pre> <p>It seems to give the same results. What circumstances have to occur for it to give different result? Or is it equivalent? For what reason is std::forward used here?</p>
[ { "answer_id": 74473145, "author": "Oleh Kostiv", "author_id": 9334760, "author_profile": "https://Stackoverflow.com/users/9334760", "pm_score": 0, "selected": false, "text": "(U u)" }, { "answer_id": 74474292, "author": "user17732522", "author_id": 17732522, "author_profile": "https://Stackoverflow.com/users/17732522", "pm_score": 2, "selected": true, "text": "U" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10570107/" ]
74,473,023
<p>I'd like images to scale to appropriately fit the screen size. I've tried a few of the expected things, but they've all scaled based on width, and I need something that can scale based on height.</p> <p>If I use max-width, it works as planned. While if I use max-height, it doesn't seem to do anything.</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-html lang-html prettyprint-override"><code>&lt;img src="https://i.imgur.com/9OPnZNk.png" style="max-width:20%;height:auto;"&gt; &lt;p&gt;The above scales as intended, and is using the max-width property.&lt;/p&gt; &lt;img src="https://i.imgur.com/9OPnZNk.png" style="width:auto;max-height:20%;"&gt; &lt;p&gt;The above doesn't scale as intended, and is using the max-height property.&lt;/p&gt;</code></pre> </div> </div> </p> <p>How can I fix this?</p>
[ { "answer_id": 74473145, "author": "Oleh Kostiv", "author_id": 9334760, "author_profile": "https://Stackoverflow.com/users/9334760", "pm_score": 0, "selected": false, "text": "(U u)" }, { "answer_id": 74474292, "author": "user17732522", "author_id": 17732522, "author_profile": "https://Stackoverflow.com/users/17732522", "pm_score": 2, "selected": true, "text": "U" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20528324/" ]
74,473,037
<p>I need to create a button to change my li's to black.</p> <p>html</p> <pre><code> &lt;h2&gt;Sonnenfarben&lt;/h2&gt; &lt;div class=&quot;box&quot;&gt; &lt;ul type=&quot;circle&quot; class=&quot;liste2&quot;&gt; &lt;li class=&quot;farbeRot&quot;&gt;rot&lt;/li&gt; &lt;li class=&quot;farbeOrange&quot;&gt;orange&lt;/li&gt; &lt;li class=&quot;farbeGelb&quot;&gt;gelb&lt;/li&gt; &lt;/ul&gt; &lt;button onclick=&quot;changeColor()&quot;&gt;Lights out&lt;/button&gt; &lt;ol class=&quot;liste3&quot; start=&quot;3&quot;&gt; &lt;li class=&quot;farbeBraun&quot;&gt;braun&lt;/li&gt; &lt;li class=&quot;farbeGrau&quot;&gt;grau&lt;/li&gt; &lt;/ol&gt; </code></pre> <p>css</p> <pre><code>.farbeRot{ color: ; font-weight: bold; } .farbeOrange{ color: orange; font-style: italic; } .farbeGelb{ color: yellow; } .farbeBraun{ color: brown; font-style: italic; } .farbeGrau{ color: grey; font-weight: bold; } .box{ color: black; } </code></pre> <p>JS</p> <pre><code>function changeColor(){ document.querySelector('.box').style.color = &quot;black&quot;; } </code></pre> <p>Tried to connect everything but didn´t work out.</p> <p>edit: put in all colors I defined already. Tried deleting them etc. but it still did not work.</p>
[ { "answer_id": 74473100, "author": "flyingfox", "author_id": 3176419, "author_profile": "https://Stackoverflow.com/users/3176419", "pm_score": 2, "selected": false, "text": ".box" }, { "answer_id": 74473793, "author": "Pratik Dev", "author_id": 15908339, "author_profile": "https://Stackoverflow.com/users/15908339", "pm_score": 1, "selected": true, "text": "function changeColor() {\n const liste2 = document.querySelector(\".liste2\");\n liste2.classList.toggle(\"black-ul\")\n \n /*\n if you just want the lights off and not toggle, replace above \"toggle\" with \"add\"\n simple javascript my boy\n */\n \n}" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20524007/" ]
74,473,043
<p>I am working on an application where I bind the list of data into DOM using Vue.js. But it is not working I have used v-for, v-list, and v-repeat but don't get it working. Here is my code both for the template and the script.</p> <pre><code> &lt;div class=&quot;weather-info&quot; v-if=&quot;weather!=undefined&quot;&gt; &lt;div v-repeat=&quot;item in weather&quot;&gt; &lt;div class=&quot;location-box&quot;&gt; &lt;div class=&quot;location&quot;&gt;{{item.day}} &lt;/div&gt; &lt;!-- &lt;div class=&quot;date&quot;&gt;{{ todaysDate() }}&lt;/div&gt; --&gt; &lt;/div&gt; &lt;div class=&quot;weather-box&quot;&gt; &lt;div class=&quot;temp&quot;&gt;{{ Math.round(item.temprature) }}°c&lt;/div&gt; &lt;div class=&quot;weather&quot;&gt;{{Math.round(item.windSpeed)}}&lt;/div&gt; &lt;div class=&quot;icon&quot;&gt; &lt;img src=&quot;{{iconUrl}}.png&quot;/&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Here is the code of the Script</p> <pre><code>export default { data() { return { url_base: &quot;https://localhost:7197/api/weather/&quot;, weather: undefined, }; }, methods : { async fetchWeather(e) { if (e.key == &quot;Enter&quot;) { let response = await axios.get(`${this.url_base}forecast?city=${this.query}`); this.setResults(response.data); } }, setResults(res) { console.log(res) if(res.isSuccessful === true){ this.weather = res.response; }else{ // error message } }, }, }; </code></pre> <p>The JSON i received in <strong>res</strong> is show below.</p> <p><a href="https://i.stack.imgur.com/RE53I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RE53I.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74473100, "author": "flyingfox", "author_id": 3176419, "author_profile": "https://Stackoverflow.com/users/3176419", "pm_score": 2, "selected": false, "text": ".box" }, { "answer_id": 74473793, "author": "Pratik Dev", "author_id": 15908339, "author_profile": "https://Stackoverflow.com/users/15908339", "pm_score": 1, "selected": true, "text": "function changeColor() {\n const liste2 = document.querySelector(\".liste2\");\n liste2.classList.toggle(\"black-ul\")\n \n /*\n if you just want the lights off and not toggle, replace above \"toggle\" with \"add\"\n simple javascript my boy\n */\n \n}" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4963996/" ]
74,473,044
<p>I Have a data frame of several water quality measures. For each measure I have a calculated mean and SD. I have a value for 6 sites and 4 seasons. Currently my dataframe has the means in a column for examples 'Temp_1' and then a column for the standard deviation as 'Temp_2'. I want to export the file with one column for each water quality measure with the format mean (SD).</p> <h3>current output</h3> <p>This is an example for the first water measure, but I'd like to code it so it is also done to remaining factors as well.</p> <p><a href="https://i.stack.imgur.com/ttYYf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ttYYf.png" alt="enter image description here" /></a></p> <h3>desired output</h3> <p><a href="https://i.stack.imgur.com/UQ8tv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UQ8tv.png" alt="enter image description here" /></a></p> <h3>Head of dataframe</h3> <pre><code>structure(list(season = structure(c(1L, 1L, 1L, 1L, 1L, 1L), levels = c(&quot;Winter&quot;, &quot;Spring&quot;, &quot;Summer&quot;, &quot;Autumn&quot;), class = &quot;factor&quot;), Site = structure(1:6, levels = c(&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;, &quot;5&quot;, &quot;6&quot;), class = &quot;factor&quot;), Temp_1 = c(7.2, 7.05, 6.3, 6.25, 6.2, 5.4), Temp_2 = c(1.55563491861041, 1.90918830920368, 1.69705627484771, 2.33345237791561, 2.40416305603426, 2.40416305603426 ), pH_1 = c(7.435, 7.38, 7.52, 7.525, 7.38, 7.565), pH_2 = c(0.289913780286484, 0.282842712474619, 0.0989949493661164, 0.120208152801713, 0.0565685424949239, 0.261629509039023), DO_1 = c(9, 9.1, 8.25, 8.85, 9.25, 9), DO_2 = c(0, 0.424264068711928, 0.0707106781186558, 0.494974746830583, 0.636396103067892, 0.42426406871193), EC_1 = c(337.5, 333, 321.5, 322, 309, 300.5 ), EC_2 = c(55.8614357137373, 41.0121933088198, 51.618795026618, 32.5269119345812, 25.4558441227157, 30.4055915910215), SS_1 = c(5.945, 3.65, 5.025, 2.535, 10.22, 4.595), SS_2 = c(0.728319984622144, 1.06066017177982, 2.93449314192417, 0.473761543394987, 8.23072293301141, 0.67175144212722), TP_1 = c(73.5, 75, 61.5, 66.5, 83, 87), TP_2 = c(3.53553390593274, 12.7279220613579, 9.19238815542512, 6.36396103067893, 26.8700576850888, 24.0416305603426), SRP_1 = c(19, 19, 10, 14, 13.5, 23.5), SRP_2 = c(2.82842712474619, 1.4142135623731, 2.82842712474619, 0, 0.707106781186548, 3.53553390593274 ), PP_1 = c(54.5, 56, 51.5, 52.5, 69.5, 63.5), PP_2 = c(6.36396103067893, 11.3137084989848, 6.36396103067893, 6.36396103067893, 26.1629509039023, 20.5060966544099), DA_1 = c(0.083, 0.0775, 0.0775, 0.044, 0.059, 0.051), DA_2 = c(0.00282842712474619, 0.0120208152801713, 0.00919238815542513, 0.0014142135623731, 0.0127279220613579, 0.00848528137423857), DNI_1 = c(0.048739437, 0.041015562, 0.0617723365, 0.0337441755, 0.041480944, 0.0143461675), DNI_2 = c(0.0345079125942686, 0.0223312453226695, 0.0187360224120165, 0.0162032493604065, 0.0258169069873252, 0.0202885446465761), DNA_1 = c(20.43507986, 20.438919615, 14.98692746, 19.953408625, 17.03060377, 8.5767502525 ), DNA_2 = c(1.80288106961836, 1.2687128010491, 2.28839365291436, 1.03116172040732, 0.396528484042397, 1.72350828181138), DF_1 = c(0.0992379715, 0.0947268395, 0.094323125, 0.098064875, 0.0980304675, 0.085783911 ), DF_2 = c(0.00372072305060515, 0.00724914346231915, 0.0142932471712976, 0.0116895470668939, 0.00255671780854136, 0.00830519117656529 ), DC_1 = c(12.18685357, 12.73924378, 13.09550326, 13.417557825, 15.140975265, 21.429763715), DC_2 = c(0.57615880774946, 0.0430071960969884, 0.702539578486863, 0.134642528587041, 0.66786605299916, 0.17012889453292 ), DS_1 = c(15.834380095, 15.69623116, 14.37636388, 15.444235935, 14.647596185, 11.9877372), DS_2 = c(1.67153135346354, 1.69978765863781, 2.47560570280853, 1.03831263471691, 1.24488755930594, 0.975483163720397 ), DOC_1 = c(19.74, 20.08, 21.24, 20.34, 21.88, 24.92), DOC_2 = c(2.7435743110038, 1.69705627484772, 2.60215295476649, 1.04651803615609, 0.226274169979695, 0.452548339959388)), row.names = c(NA, 6L), class = &quot;data.frame&quot;) </code></pre>
[ { "answer_id": 74473123, "author": "Aron Strandberg", "author_id": 4885169, "author_profile": "https://Stackoverflow.com/users/4885169", "pm_score": 0, "selected": false, "text": "df$Temp <- paste0(df$Temp_1, ' (', df$Temp_2, ')')\n" }, { "answer_id": 74473147, "author": "Tom Hoel", "author_id": 17213355, "author_profile": "https://Stackoverflow.com/users/17213355", "pm_score": 0, "selected": false, "text": "library(tidyverse)\n\ndf %>% \n pivot_longer(-c(season, Site)) %>% \n mutate(name = name %>% str_remove_all(\"[^a-zA-Z]\")) %>% \n group_by(season, Site, name) %>%\n summarise(value = str_c(round(value, 2), collapse = \", \")) %>% \n pivot_wider(names_from = name, \n values_from = value) \n\n# A tibble: 6 x 17\n# Groups: season, Site [6]\n season Site DA DC DF DNA DNI DO DOC DS EC pH PP SRP SS Temp TP \n <fct> <fct> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>\n1 Winter 1 0.08, 0 12.19, 0.58 0.1, 0 20.44, 1.8 0.05, 0.03 9, 0 19.7~ 15.8~ 337.~ 7.43~ 54.5~ 19, ~ 5.94~ 7.2,~ 73.5~\n2 Winter 2 0.08, 0.01 12.74, 0.04 0.09, 0.01 20.44, 1.27 0.04, 0.02 9.1, 0.~ 20.0~ 15.7~ 333,~ 7.38~ 56, ~ 19, ~ 3.65~ 7.05~ 75, ~\n3 Winter 3 0.08, 0.01 13.1, 0.7 0.09, 0.01 14.99, 2.29 0.06, 0.02 8.25, 0~ 21.2~ 14.3~ 321.~ 7.52~ 51.5~ 10, ~ 5.03~ 6.3,~ 61.5~\n4 Winter 4 0.04, 0 13.42, 0.13 0.1, 0.01 19.95, 1.03 0.03, 0.02 8.85, 0~ 20.3~ 15.4~ 322,~ 7.53~ 52.5~ 14, 0 2.54~ 6.25~ 66.5~\n5 Winter 5 0.06, 0.01 15.14, 0.67 0.1, 0 17.03, 0.4 0.04, 0.03 9.25, 0~ 21.8~ 14.6~ 309,~ 7.38~ 69.5~ 13.5~ 10.2~ 6.2,~ 83, ~\n6 Winter 6 0.05, 0.01 21.43, 0.17 0.09, 0.01 8.58, 1.72 0.01, 0.02 9, 0.42 24.9~ 11.9~ 300.~ 7.57~ 63.5~ 23.5~ 4.6,~ 5.4,~ 87, ~\n" }, { "answer_id": 74473281, "author": "TarJae", "author_id": 13321647, "author_profile": "https://Stackoverflow.com/users/13321647", "pm_score": 2, "selected": true, "text": "transmute" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18143306/" ]
74,473,055
<p>Say I have the following structure:</p> <pre class="lang-html prettyprint-override"><code>&lt;p&gt;lorem ipsum&lt;/p&gt; &lt;span&gt;dolor&lt;/span&gt; &lt;p&gt;sit amen&lt;/p&gt; </code></pre> <p>What is the best way to programmatically get the following in JS?</p> <pre class="lang-html prettyprint-override"><code>&lt;p&gt;lorem ipsum &lt;span&gt;dolor&lt;/span&gt; sit amen&lt;/p&gt; </code></pre> <p>Is it possible also to do this with differents tags like</p> <pre class="lang-html prettyprint-override"><code>&lt;h1&gt;lorem ipsum&lt;/h1&gt; &lt;span&gt;dolor&lt;/span&gt; &lt;h1&gt;sit amen&lt;/h1&gt; </code></pre> <p>That should result in</p> <pre class="lang-html prettyprint-override"><code>&lt;h1&gt;lorem ipsum &lt;span&gt;dolor&lt;/span&gt; sit amen&lt;/h1&gt; </code></pre> <p>I'm not talking just of three elements: could be also something like:</p> <pre><code>p span p span p </code></pre>
[ { "answer_id": 74473322, "author": "Mina", "author_id": 11887902, "author_profile": "https://Stackoverflow.com/users/11887902", "pm_score": 1, "selected": false, "text": "tag" }, { "answer_id": 74473334, "author": "Dream Bold", "author_id": 12743692, "author_profile": "https://Stackoverflow.com/users/12743692", "pm_score": 1, "selected": false, "text": "const h1tag = document.createElement(\"h1\");\nconst node = document.createTextNode( \n document.querySelectorAll(\"h1\")[0].innerHTML + \" \" + \n document.querySelector(\"span\").outerHTML + \" \" + \n document.querySelectorAll(\"h1\")[1].innerHTML \n );\nh1tag.appendChild(node);\n" }, { "answer_id": 74473465, "author": "soupy-norman", "author_id": 4299304, "author_profile": "https://Stackoverflow.com/users/4299304", "pm_score": 0, "selected": false, "text": "const inPnl = document.getElementById('input');\nconst elems = inPnl.querySelectorAll('p, span');\nconst outPnl = document.getElementById('output');\n\nelems[0]\n .appendChild(elems[1])\n .appendChild(document.createTextNode(elems[2].innerText));\n\noutPnl.appendChild(elems[0]);" }, { "answer_id": 74474130, "author": "T-S", "author_id": 17907084, "author_profile": "https://Stackoverflow.com/users/17907084", "pm_score": 0, "selected": false, "text": "<p>" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10503039/" ]
74,473,056
<p>Android project Code base is full java and dagger 2 is implemented in java as well. I am integrating kotlin in the code and each time I rebuild, Dagger gives errors. (Added below)</p> <h1>code:</h1> <p><strong>build.gradle (project)</strong></p> <pre><code>buildscript { ext { kotlin_version = &quot;1.7.10&quot; } repositories { google() mavenCentral() } dependencies { classpath 'com.google.gms:google-services:4.3.10' classpath 'com.android.tools.build:gradle:7.2.1' classpath &quot;org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version&quot; } } allprojects { repositories { google() mavenCentral() } } } task clean(type: Delete) { delete rootProject.buildDir } </code></pre> <p><strong>build.gradle (app)</strong></p> <pre><code> apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' android { compileSdkVersion 32 defaultConfig { applicationId &quot;co.xyz.abc&quot; minSdkVersion 21 targetSdkVersion 32 versionCode 15 versionName &quot;1.1.1&quot; multiDexEnabled true renderscriptTargetApi 19 renderscriptSupportModeEnabled true vectorDrawables.useSupportLibrary = true } buildTypes { // ... } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' } buildFeatures { viewBinding true } } dependencies { // AndroidX // .... //kotlin implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.7.10' implementation 'androidx.core:core-ktx:1.9.0' // ViewModel def lifecycle_version = &quot;2.4.1&quot; implementation &quot;androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version&quot; // Dagger2 def daggerVersion = &quot;2.35.1&quot; api &quot;com.google.dagger:dagger:$daggerVersion&quot; annotationProcessor &quot;com.google.dagger:dagger-compiler:$daggerVersion&quot; // Dagger Android api &quot;com.google.dagger:dagger-android-support:$daggerVersion&quot; api &quot;com.google.dagger:dagger-android:$daggerVersion&quot; annotationProcessor &quot;com.google.dagger:dagger-android-processor:$daggerVersion&quot; // AssistedInject def assistedInject = '0.6.0' compileOnly &quot;com.squareup.inject:assisted-inject-annotations-dagger2:$assistedInject&quot; annotationProcessor &quot;com.squareup.inject:assisted-inject-processor-dagger2:$assistedInject&quot; androidTestImplementation 'junit:junit:4.13.2' } </code></pre> <p><strong>gradle.properties</strong></p> <pre><code> android.enableJetifier=true android.useAndroidX=true org.gradle.jvmargs=-Xmx1536m kotlin.code.style=official </code></pre> <p><strong>gradle-wrapper.properties</strong></p> <pre><code>distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip </code></pre> <p><strong>Errors after Rebuild:</strong></p> <blockquote> <p>FAILURE: Build failed with an exception.</p> <ul> <li>What went wrong: Execution failed for task ':app:checkStagingLocalDevAarMetadata'. A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction 3 issues were found when checking AAR metadata:</li> </ul> <ol> <li><p>Dependency 'androidx.core:core-ktx:1.9.0' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs.</p> <p>:app is currently compiled against android-32.</p> <p>Also, the maximum recommended compile SDK version for Android Gradle plugin 7.2.1 is 32.</p> <p>Recommended action: Update this project's version of the Android Gradle plugin to one that supports 33, then update this project to use compileSdkVerion of at least 33.</p> <p>Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on).</p> </li> <li><p>Dependency 'androidx.core:core:1.9.0' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs.</p> <p>:app is currently compiled against android-32.</p> <p>Also, the maximum recommended compile SDK version for Android Gradle plugin 7.2.1 is 32.</p> <p>Recommended action: Update this project's version of the Android Gradle plugin to one that supports 33, then update this project to use compileSdkVerion of at least 33.</p> <p>Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on).</p> </li> <li><p>Dependency 'androidx.annotation:annotation-experimental:1.3.0' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs.</p> <p>:app is currently compiled against android-32.</p> <p>Also, the maximum recommended compile SDK version for Android Gradle plugin 7.2.1 is 32.</p> <p>Recommended action: Update this project's version of the Android Gradle plugin to one that supports 33, then update this project to use compileSdkVerion of at least 33.</p> <p>Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on).</p> </li> </ol> </blockquote> <p><strong>When I change compileSdk to 33 :</strong></p> <blockquote> <p>Task :app:compileStagingLocalDevJavaWithJavac</p> <p>error: cannot find symbol import co.abc.client.di.components.DaggerABCApplicationComponent; ^ symbol: class DaggerABCApplicationComponent location: package co.abc.client.di.components</p> </blockquote> <p><strong>Now, if I downgrade the core-ktx version to 1.8.0 and change annotationProcessor to kapt :</strong></p> <blockquote> <p>Task :app:kaptStagingLocalDevKotlin /StudioProjects/project/app/src/main/java/co/abc/client/di/modules/account/AssistedModule.java:8: error: cannot find symbol @Module(includes = AssistedInject_AssistedModule.class) ^ symbol: class AssistedInject_AssistedModule /StudioProjects/project/app/src/main/java/co/abc/client/di/modules/account/AssistedModule.java:9: error: [ComponentProcessor:MiscError] dagger.internal.codegen.ComponentProcessor was unable to process this interface because not all of its dependencies could be resolved. Check for compilation errors or a circular dependency with generated code. public interface AssistedModule {} ^ /StudioProjects/project/app/src/main/java/co/abc/client/di/components/ABCApplicationComponent.java:40: error: [ComponentProcessor:MiscError] dagger.internal.codegen.ComponentProcessor was unable to process this interface because not all of its dependencies could be resolved. Check for compilation errors or a circular dependency with generated code. public interface ABCApplicationComponent extends AndroidInjector { ^</p> <p>Task :app:kaptStagingLocalDevKotlin FAILED</p> <p>FAILURE: Build failed with an exception.</p> <ul> <li>What went wrong: Execution failed for task ':app:kaptStagingLocalDevKotlin'. A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction java.lang.reflect.InvocationTargetException (no error message)</li> </ul> </blockquote> <p>What could be the issue here? Should the Dagger-related code be written in Kotlin? Is there a source I could refer to for kotlin integration in java code base for android when dagger is there?</p> <p>So far, I have tried these which didn't work:</p> <ol> <li>upgrading and downgrading versions for kotlin and dagger.</li> <li>changing all annotationProcessors to kapt</li> <li>adding this to gradle - -Pandroid.incrementalJavaCompile=false</li> <li>android { compileOptions.incremental = false }</li> <li>restart ide</li> </ol> <p>Also, I have another project(java code base and kotlin integration setup) which is working with these versions so the issue doesn't seem to be with that. only difference is, dagger is not in my other project and everything runs fine there.</p>
[ { "answer_id": 74473322, "author": "Mina", "author_id": 11887902, "author_profile": "https://Stackoverflow.com/users/11887902", "pm_score": 1, "selected": false, "text": "tag" }, { "answer_id": 74473334, "author": "Dream Bold", "author_id": 12743692, "author_profile": "https://Stackoverflow.com/users/12743692", "pm_score": 1, "selected": false, "text": "const h1tag = document.createElement(\"h1\");\nconst node = document.createTextNode( \n document.querySelectorAll(\"h1\")[0].innerHTML + \" \" + \n document.querySelector(\"span\").outerHTML + \" \" + \n document.querySelectorAll(\"h1\")[1].innerHTML \n );\nh1tag.appendChild(node);\n" }, { "answer_id": 74473465, "author": "soupy-norman", "author_id": 4299304, "author_profile": "https://Stackoverflow.com/users/4299304", "pm_score": 0, "selected": false, "text": "const inPnl = document.getElementById('input');\nconst elems = inPnl.querySelectorAll('p, span');\nconst outPnl = document.getElementById('output');\n\nelems[0]\n .appendChild(elems[1])\n .appendChild(document.createTextNode(elems[2].innerText));\n\noutPnl.appendChild(elems[0]);" }, { "answer_id": 74474130, "author": "T-S", "author_id": 17907084, "author_profile": "https://Stackoverflow.com/users/17907084", "pm_score": 0, "selected": false, "text": "<p>" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10076942/" ]
74,473,133
<p>I'm trying to solve this problem since some days now but it seems I have reached a dead end. Maybe someone would be able to help me.</p> <p>I have two sheets. The first one contains the list of my clients and their delivery number depending of the weekday.</p> <p><img src="https://i.stack.imgur.com/VYQ5A.png" alt="Caption 1" /></p> <p>In my second sheet I would like to get the delivery number of the client (red cells) depending of the weekday I select (yellow cells).</p> <p><img src="https://i.stack.imgur.com/sBTjK.png" alt="Caption 2" /></p> <p>I tried VLOOKUP formula, INDEX/MATCH, QUERY but I wasn't able to find a way to get the delivery number depending of the client's name and the weekday. I think the main issue is that in the first sheet the weekday is a column title.</p> <p>Maybe the solution is simply to build my tables differently...</p> <p>Thank you for your help</p>
[ { "answer_id": 74473335, "author": "Martín", "author_id": 20363318, "author_profile": "https://Stackoverflow.com/users/20363318", "pm_score": 1, "selected": false, "text": "=INDEX(Sheet1!$1:$1000,MATCH(A2,Sheet1!$A:$A,0),MATCH(B2,Sheet1!$1:$1,0))\n" }, { "answer_id": 74473737, "author": "The God of Biscuits", "author_id": 18645332, "author_profile": "https://Stackoverflow.com/users/18645332", "pm_score": 1, "selected": false, "text": "=map(A2:A,B2:B,lambda(name,day,ifna(filter(filter(Sheet1!B2:D4,Sheet1!A2:A4=name),Sheet1!B1:D1=day))))\n" }, { "answer_id": 74475961, "author": "player0", "author_id": 5632629, "author_profile": "https://Stackoverflow.com/users/5632629", "pm_score": 1, "selected": true, "text": "=INDEX(IFNA(VLOOKUP(A9:A11&B9:B11, \n SPLIT(FLATTEN(A2:A4&B1:D1&\"​​\"&B2:D4), \"​​\"), 2, )))\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16378556/" ]
74,473,141
<p>I have a dataset of this type:</p> <pre><code> id 1 2 3 4 5 A 10 40 80 12 50 B 20 60 70 77 60 C 30 15 50 20 60 C 30 15 20 45 43 B 50 100 70 77 32 C 30 15 20 80 21 A 50 100 10 12 50 </code></pre> <p>Is there a way to group it somehow to show which columns are specific for which id? For example, we can see that all of the values corresponding to the id 'C' in the first column equal to 30; similarly, column 3 is pretty 'B' id specific - all of the values are the same for 'B' in column 3 etc. Same for column 5 and id 'A'.</p> <p>So, there are columns specific for each id; is there a way to group them somehow and for each id visualise/list columns specific to each of them?</p>
[ { "answer_id": 74473324, "author": "Panda Kim", "author_id": 20430449, "author_profile": "https://Stackoverflow.com/users/20430449", "pm_score": 3, "selected": true, "text": "(df.melt('id')\n .groupby(['id', 'variable'])\n .agg(lambda x: x.max() if x.max() == x.min() else None)\n .unstack())\n" }, { "answer_id": 74473691, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 0, "selected": false, "text": "thresh = 1\n\n(df.melt('id', var_name='col')\n .groupby(['col', 'id'], as_index=False)['value']\n .agg(frozenset)\n .loc[lambda d: d['value'].str.len().le(thresh)]\n .groupby(['value', 'col'])['id']\n .agg(set)\n .loc[lambda s: s.str.len().eq(1)]\n)\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18134832/" ]
74,473,159
<p>I made a JavaScript quote generator but wanted to add something to it. So I decided to figure out how to swap male verbiage for female. The API is an array with 1.5k quotes as objects. As a new coder how would you approach this problem? full project is here <a href="https://keller-johnson.github.io/quote-generator/" rel="nofollow noreferrer">https://keller-johnson.github.io/quote-generator/</a></p> <pre><code>//Show new quote function newQuote() { loading(); //Pick a random from apiQuotes array const quote = apiQuotes[Math.floor(Math.random() * apiQuotes.length)]; //Searching for male terms and making them female //turn quote.text into an array this will make it easier to match the male terms and make them //because if we tried to do .replace or .replaceAll it would replace parts of substrings as well let quoteArray = quote.text.split(&quot; &quot;); // now we are making a if statement to turn these generic terms into women specific terms let newArrayQuote = quoteArray.map((index) =&gt; { if (index === &quot;he&quot;) { return &quot;she&quot;; } if (index === &quot;he.&quot;) { return &quot;she.&quot;; } if (index === &quot;He&quot;) { return &quot;She&quot;; } if (index === &quot;his&quot;) { return &quot;hers&quot;; } if (index === &quot;His&quot;) { return &quot;Hers&quot;; } if (index === &quot;him&quot;) { return &quot;her&quot;; } if (index === &quot;him.&quot;) { return &quot;her.&quot;; } if (index === &quot;Him&quot;) { return &quot;Her&quot;; } if (index === &quot;men&quot;) { return &quot;women&quot;; } if (index === &quot;men,&quot;) { return &quot;women,&quot;; } if (index === &quot;Men&quot;) { return &quot;Women&quot;; } if (index === &quot;man&quot;) { return &quot;woman&quot;; } if (index === &quot;man.&quot;) { return &quot;woman.&quot;; } if (index === &quot;Man&quot;) { return &quot;Woman&quot;; } if (index === &quot;himself&quot;) { return &quot;herself&quot;; } if (index === &quot;himself.&quot;) { return &quot;herself.&quot;; } else { return index; } }); //turning the newArrayQuote back into string let stringQuote = newArrayQuote.join(&quot; &quot;); //Check if Author field is blank and replace it with unknown if (!quote.author) { authorText.textContent = &quot;Unknown&quot;; } else { authorText.textContent = quote.author; } // Check quote length to determine the styling if (stringQuote.length &gt; 120) { quoteText.classList.add(&quot;long-quote&quot;); } else { quoteText.classList.remove(&quot;long-quote&quot;); } //Set Quote, Hide Loader complete(); quoteText.textContent = stringQuote; } </code></pre> <p>I have a working model but it's not very DRY and it's killing me because I know there has to be a better way.</p>
[ { "answer_id": 74473290, "author": "Jankapunkt", "author_id": 3098783, "author_profile": "https://Stackoverflow.com/users/3098783", "pm_score": 2, "selected": false, "text": "const mapping = {\n 'he': 'she',\n ...\n 'himself.': 'herself.'\n}\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19609236/" ]
74,473,165
<p>I'm using Oracle SQL-developer and I got the following output-table, which shows the monthly sales value of our customers. The customers have several locations.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>month</th> <th>year</th> <th>customer_name</th> <th>sales_volume</th> </tr> </thead> <tbody> <tr> <td>01</td> <td>2022</td> <td>Farming company Berlin</td> <td>150</td> </tr> <tr> <td>01</td> <td>2022</td> <td>Farming company London</td> <td>200</td> </tr> <tr> <td>01</td> <td>2022</td> <td>Farming company Amsterdam</td> <td>350</td> </tr> <tr> <td>01</td> <td>2022</td> <td>XY Company Berlin</td> <td>200</td> </tr> <tr> <td>01</td> <td>2022</td> <td>customer 5</td> <td>7</td> </tr> <tr> <td>01</td> <td>2022</td> <td>customer 7</td> <td>7</td> </tr> <tr> <td>01</td> <td>2022</td> <td>X_Person</td> <td>2</td> </tr> <tr> <td>02</td> <td>2022</td> <td>XY Company London</td> <td>100</td> </tr> <tr> <td>02</td> <td>2022</td> <td>Hello Company Berlin</td> <td>150</td> </tr> <tr> <td>02</td> <td>2022</td> <td>Hello Company Amsterdam</td> <td>150</td> </tr> <tr> <td>02</td> <td>2022</td> <td>customer 1</td> <td>20</td> </tr> <tr> <td>02</td> <td>2022</td> <td>customer 2</td> <td>10</td> </tr> <tr> <td>02</td> <td>2022</td> <td>customer 3</td> <td>5</td> </tr> <tr> <td>02</td> <td>2022</td> <td>Y-Person</td> <td>1</td> </tr> </tbody> </table> </div> <p>Now I'd like to get the sales_volume per customer_name for month/year. I want to add the sales_volume per month/year for all the different locations of the Farming company, the XY Company and the Hello Company. The rest (customer 1-7, X-Person, Y-Person) should be summed up in an own row named &quot;Other&quot;</p> <p>The new output table would be the following:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>month</th> <th>year</th> <th>customer_name</th> <th>sum_Sales_volume</th> </tr> </thead> <tbody> <tr> <td>01</td> <td>2022</td> <td>Farming Company</td> <td>700</td> </tr> <tr> <td>01</td> <td>2022</td> <td>XY Company</td> <td>300</td> </tr> <tr> <td>01</td> <td>2022</td> <td>Other</td> <td>16</td> </tr> <tr> <td>02</td> <td>2022</td> <td>XY Company</td> <td>100</td> </tr> <tr> <td>02</td> <td>2022</td> <td>Hello Company</td> <td>300</td> </tr> <tr> <td>02</td> <td>2022</td> <td>Other</td> <td>36</td> </tr> </tbody> </table> </div> <p>So far I tried to sum the customer_name with LIKE function but I don't understand how the &quot;when then&quot; works in this case.</p> <p>My code:</p> <pre><code>Select month, year, sum(sales_volume) CASE WHEN customer_name LIKE '%Farming%' Then 'Farming Company' WHEN customer_name LIKE '%XY%' Then 'XY Company' WHEN customer_name LIKE '%Hello%' Then 'Hello Company' ELSE THEN 'Standard' END AS &quot;sum_Sales_volume&quot; </code></pre>
[ { "answer_id": 74473290, "author": "Jankapunkt", "author_id": 3098783, "author_profile": "https://Stackoverflow.com/users/3098783", "pm_score": 2, "selected": false, "text": "const mapping = {\n 'he': 'she',\n ...\n 'himself.': 'herself.'\n}\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20410882/" ]
74,473,190
<p>In some occasions, specially when copy-pasting, we end up having some text fields with a character 0 (nul) at the end of a string.</p> <p>It doesn't show in any way when you display the data, but you do detect it when you export it.</p> <p><a href="https://i.stack.imgur.com/QpkbA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QpkbA.png" alt="Exported text with null char" /></a></p> <p>We've tried to (at least) detect it by using the &quot;Position&quot; function.</p> <p>However Position(text_field, char(0), 1, 1) won't find this char (it does return 0, even if the character is there).</p> <p>I guess this is some kind of bug from FileMaker, but I'd like to know if anyone has found a way to circumvent it...</p> <p>More info and a database sample at: <a href="https://community.claris.com/en/s/question/0D53w00005wrUMMCA2/character-0-0x0-in-text-fields" rel="nofollow noreferrer">https://community.claris.com/en/s/question/0D53w00005wrUMMCA2/character-0-0x0-in-text-fields</a></p>
[ { "answer_id": 74473767, "author": "michael.hor257k", "author_id": 3016153, "author_profile": "https://Stackoverflow.com/users/3016153", "pm_score": 2, "selected": false, "text": "Char(0)" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3719667/" ]
74,473,195
<p>I want to have <code>ListTile</code> widget that sometimes has <code>title</code> as null, e.g.:</p> <pre><code>ListTile( title: item.title.isNotEmpty ? Text( item.title, maxLines: 1, ) : null, subtitle: Text( task.text, maxLines: 3, overflow: TextOverflow.fade, ), } </code></pre> <p>If the <code>title</code> is null, it stays there as an empty space, which causes entire widget to look ugly.</p> <p>On the other hand, if the subtitle is null, it nicely collapse.</p> <p><a href="https://i.stack.imgur.com/KAQek.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KAQek.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74473404, "author": "Gringo", "author_id": 20528563, "author_profile": "https://Stackoverflow.com/users/20528563", "pm_score": -1, "selected": false, "text": "ListTile(\n title: item.title.isNotEmpty\n ? Text(\n item.title,\n maxLines: 1,\n )\n : null,\n subtitle: Text(\n task.text,\n maxLines: 3,\n overflow: TextOverflow.fade,\n ),\n)\n" }, { "answer_id": 74473917, "author": "Yeasin Sheikh", "author_id": 10157127, "author_profile": "https://Stackoverflow.com/users/10157127", "pm_score": 3, "selected": true, "text": "subtitle" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1448545/" ]
74,473,236
<p><a href="https://i.stack.imgur.com/MKFYV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MKFYV.png" alt="enter image description here" /></a></p> <p>Tried float:right but the image will only show half...<br /> What I want is to move <strong>123</strong> move to the red circle</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>#ImgControl{ width: 25px; height: 25px; background-color: #ffd7c2; position: absolute; bottom: 20px; right: 30px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="ImgControl"&gt; &lt;img src="assets\icon\cart.png" @click="Test"/&gt; &lt;span&gt;123&lt;/span&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74473358, "author": "MAYUR SANCHETI", "author_id": 12238257, "author_profile": "https://Stackoverflow.com/users/12238257", "pm_score": 0, "selected": false, "text": "#ImgControl{\nwidth: 25px;\nheight: 25px;\nbackground-color: #ffd7c2;\nposition: absolute;\ntop: 11px;\nright: 20px;\ndisplay: flex;\n}" }, { "answer_id": 74473518, "author": "Fabrizio Calderan", "author_id": 1098851, "author_profile": "https://Stackoverflow.com/users/1098851", "pm_score": 2, "selected": true, "text": "width" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20181506/" ]
74,473,263
<p>I created the following snippet:</p> <pre><code>snippet setttwd setwd(dirname(rstudioapi::getActiveDocumentContext()$path)) </code></pre> <p><a href="https://i.stack.imgur.com/moFhS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/moFhS.png" alt="enter image description here" /></a></p> <p>But when I type <code>setttwd</code> and press enter, I get the following piece of code:</p> <p><a href="https://i.stack.imgur.com/zBpWn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zBpWn.png" alt="enter image description here" /></a></p> <p>Note that <code>$path</code> has disappeared.</p> <p>Why?</p>
[ { "answer_id": 74475934, "author": "Julien", "author_id": 8806649, "author_profile": "https://Stackoverflow.com/users/8806649", "pm_score": 0, "selected": false, "text": "$" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8806649/" ]
74,473,269
<p>`Good day, colleagues!</p> <p>I cannot find a way to get Response and/or custom Response Header in Angular.</p> <p>Angular is embedded into JSP page. Angular sends post request to Spring Boot app with multi part file. If the size of the file exceeds 10 MB Spring Boot app throws MaxFileSizeExceededException, which is handled in it and wrapped into EsignError as follows:</p> <pre><code>@ControllerAdvice @Slf4j public class EsignExceptionHandler extends ResponseEntityExceptionHandler { @ExceptionHandler(value = {EsignException.class}) public ResponseEntity&lt;Object&gt; scannerException(Exception ex, WebRequest request) { log.error(ex.getMessage()); log.info(&quot;Inside first handler&quot;); String bodyOfResponse = ex.getMessage(); return handleExceptionInternal(ex, bodyOfResponse, HTTPUtil.getCommonHeaders(), HttpStatus.INTERNAL_SERVER_ERROR, request); } @ExceptionHandler(MaxUploadSizeExceededException.class) public @ResponseBody ResponseEntity&lt;?&gt; handleMaxUploadSizeExceededException(MaxUploadSizeExceededException ex) { log.error(ex.getMessage()); log.info(&quot;Inside second handler&quot;); EsignError error = new EsignError(HttpStatus.BAD_REQUEST.value(), ex.getMessage()); HttpHeaders headers = new HttpHeaders(HTTPUtil.getCommonHeaders()); headers.setAccessControlAllowOrigin(&quot;*&quot;); headers.setContentType(MediaType.APPLICATION_JSON); headers.add(&quot;msgHeader&quot;, ex.getMessage()); return new ResponseEntity&lt;&gt;(error, headers, HttpStatus.BAD_REQUEST); } } </code></pre> <p>EsignError class is as follows:</p> <pre><code>@Data public class EsignError { private int status; private String message; private Date timestamp; public EsignError(int status, String message) { this.status = status; this.message = message; this.timestamp = new Date(); } } </code></pre> <p>Spring Boot app returns the following JSON as an example:</p> <p><code>{ &quot;status&quot;: 400, &quot;message&quot;: &quot;Maximum upload size exceeded; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException: the request was rejected because its size (31238283) exceeds the configured maximum (10485760)&quot;, &quot;timestamp&quot;: &quot;2022-11-17T08:41:45.580+00:00&quot; }</code></p> <p>In browser (Network tab) I see the following custom header among Response Headers: Maximum upload size exceeded; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException: the request was rejected because its size (31238845) exceeds the configured maximum (10485760)</p> <p>I also see the following in Response in browser: <code>{&quot;status&quot;:400,&quot;message&quot;:&quot;Maximum upload size exceeded; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException: the request was rejected because its size (31238845) exceeds the configured maximum (10485760)&quot;,&quot;timestamp&quot;:&quot;2022-11-17T08:45:38.705+00:00&quot;} </code></p> <p>I tried to catch and see the custom header value or response in Angular as follows:</p> <p>First, I tried it in the postFile() method of angular component, that sends the post request to the Spring Boot app:</p> <pre><code>postFile() { this.uploadState = 'отправка файла...'; var certHolders: string = ''; this.corresp.approvals.forEach(a =&gt; { certHolders = certHolders + a.logname + ';'; }); const formData: FormData = new FormData(); formData.append('file', this.file, 'file.pdf'); formData.append('idappli', String(this.corresp.idappli)); formData.append('odcorresp', String(this.corresp.odcorresp)); formData.append('idletter', String(this.corresp.idletter)); formData.append('certHolders', certHolders); formData.append('fpage', String(this.stampStart)); formData.append('lpage', String(this.stampEnd)); const headers = new HttpHeaders().append(&quot;Access-Control-Allow-Origin&quot;, &quot;*&quot;) .append(&quot;Access-Control-Allow-Origin&quot;, &quot;*&quot;) .append(&quot;Access-Control-Allow-Methods&quot;, &quot;POST&quot;) .append(&quot;Access-Control-Allow-Headers&quot;, &quot;Origin, Accept, Authorization, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers&quot;) const o: Observable&lt;any&gt; = this.http.post(this.corresp.url, formData, {headers, responseType: &quot;blob&quot;}); o.subscribe(blob =&gt; { this.addHistory(&quot;insert&quot;); this.getFileWithSign(); this.corresp.exists = true; console.log('blob.error: ' + blob.error); console.log('blob.message: ' + blob.message); }, error =&gt; { this.uploadState = 'ошибка отправки файла на подпись!'; console.log('console.log error.status: ' + error.status); // console.log('console.log error.error(): ' + error.error()); // console.log('console.log error.errorDetails: ' + error.errorDetails); console.log('console.log error: ' + error); console.log('console.log error.error: ' + error.error); // The following line results in error in browser console: ERROR TypeError: Cannot read properties of undefined (reading 'status') // console.log('console.log error.error.status: ' + error.error.status); if (error.status === 400) { const msg2 = error.headers.get('msgHeader'); alert('msg2: ' + msg2); } } ); } </code></pre> <p>It does not show anything out of the custom header or response.</p> <p>Also I tried to do it via three kinds of Interceptors as follows:</p> <ol> <li>ErrorInterceptor:</li> </ol> <pre><code>import {Injectable} from '@angular/core'; import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor, HttpErrorResponse, HttpResponse } from '@angular/common/http'; import {Observable, throwError} from 'rxjs'; import {catchError, retry, tap} from &quot;rxjs/operators&quot;; @Injectable() export class ErrorInterceptor implements HttpInterceptor { constructor() { } intercept(request: HttpRequest&lt;any&gt;, next: HttpHandler): Observable&lt;HttpEvent&lt;any&gt;&gt; { return next.handle(request).pipe( catchError((errorResponse: HttpErrorResponse) =&gt; { if (errorResponse.status === 400) { console.log('!!! Размер файла не может быть больше 10 Мб !!!'); console.log('errorResponse.error: ' + errorResponse.error); console.log('errorResponse.error.message: ' + errorResponse.error.message); console.log('errorResponse.error.status: ' + errorResponse.error.status); console.log('errorResponse.error.timestamp: ' + errorResponse.error.timestamp); alert('!!! Размер файла не может быть больше 10 Мб !!!'); alert(errorResponse.status); alert(errorResponse.message); alert(errorResponse.error); const msg = errorResponse.headers.getAll('msgHeader'); console.log(msg); alert(msg); } return throwError(() =&gt; new Error('test error 400')); })); } } </code></pre> <p>ErrorIterseptor allows to get status of 400, but not the message or timestamp.</p> <ol start="2"> <li>EventInterceptor</li> </ol> <pre><code>import { Injectable } from '@angular/core'; import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor, HttpResponse, HttpErrorResponse } from '@angular/common/http'; import { Observable } from 'rxjs'; import {retry, tap} from &quot;rxjs/operators&quot;; @Injectable() export class EventInterceptor implements HttpInterceptor { constructor() {} intercept(request: HttpRequest&lt;any&gt;, next: HttpHandler): Observable&lt;HttpEvent&lt;any&gt;&gt; { return next.handle(request).pipe( tap(event =&gt; { if (event instanceof HttpResponse) { console.log('Response'); console.log(event); alert(event); console.log(event.body); console.log(event.status); console.log(event.headers); } if (event instanceof HttpErrorResponse) { console.log('Error') console.log(event); alert(event); console.log(event.error); console.log(event.status); console.log(event.headers); } } )); } } </code></pre> <p>EventInterceptor looks useless.</p> <ol start="3"> <li>ResponseHeaderInterceptor</li> </ol> <pre><code>import {Injectable} from '@angular/core'; import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor, HttpResponse } from '@angular/common/http'; import {Observable, throwError} from 'rxjs'; import {catchError, filter, retry} from &quot;rxjs/operators&quot;; @Injectable() export class ResponseHeaderInterceptor implements HttpInterceptor { constructor() { } intercept(request: HttpRequest&lt;any&gt;, next: HttpHandler): Observable&lt;HttpEvent&lt;any&gt;&gt; { return next.handle(request).pipe( filter(event =&gt; event instanceof HttpResponse), catchError(error =&gt; { if (error.status === 400) { const msg = error.headers.get('msgHeader'); console.log(msg); alert(msg); } return throwError(error); }) ); } } </code></pre> <p>This interceptor does not help either.</p> <p>Can you please help me to figure out how I can get either custom header value or response value in either component from which post is sen<code>your text</code>t or in any interceptor?</p>
[ { "answer_id": 74475934, "author": "Julien", "author_id": 8806649, "author_profile": "https://Stackoverflow.com/users/8806649", "pm_score": 0, "selected": false, "text": "$" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12436979/" ]
74,473,327
<p>I'm trying to get all posts that has at least 2 comments in the last 48 hours. I'm using the following code:</p> <pre><code> $posts= Post::has( 'comments', '&gt;', 1 )-&gt;whereHas( 'comments', function( $comments ) { return $comments-&gt;where( 'created_at', '&gt;', Carbon::now()-&gt;subDays(2) ); })-&gt;get()-&gt;toArray(); </code></pre> <ol> <li>has at least 2 comments is working fine.</li> <li>in the last 48 hours isn't working.</li> </ol>
[ { "answer_id": 74528877, "author": "xenooooo", "author_id": 20283630, "author_profile": "https://Stackoverflow.com/users/20283630", "pm_score": 4, "selected": true, "text": "has()" }, { "answer_id": 74542793, "author": "discussion", "author_id": 19432371, "author_profile": "https://Stackoverflow.com/users/19432371", "pm_score": -1, "selected": false, "text": "'created_at', '>', Carbon::now()->subDays(2)" }, { "answer_id": 74546746, "author": "benkov", "author_id": 2769031, "author_profile": "https://Stackoverflow.com/users/2769031", "pm_score": -1, "selected": false, "text": "$posts= Post::where( 'comments', '>', 1 )\n ->where( 'comments', function( $comments ) {\n return $comments->where( 'created_at', '>', Carbon::now()->subDays(2) );\n })\n ->get()->toArray();\n" }, { "answer_id": 74546923, "author": "Erhan URGUN", "author_id": 9476192, "author_profile": "https://Stackoverflow.com/users/9476192", "pm_score": 1, "selected": false, "text": "<?php\n\nnamespace App\\Http\\Controllers;\n\nuse Illuminate\\Http\\Request;\nuse App\\Post;\nuse App\\Comment;\n\nclass DemoController extends Controller\n{\n public function index()\n {\n $posts = Post::whereHas('comments', function($q) {\n $q->where('created_at', '>=', date('Y-m-d H:i:s', strtotime('-48 hours')));\n })->withCount('comments')->having('comments_count', '>=', 2)->get();\n\n return view('demo', compact('posts'));\n }\n}\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5844795/" ]
74,473,372
<p>I have a file like this:</p> <pre><code>reference 25038 A G 39134 1 TPPH54 TPPH49 TPPH50 TPPHL51 TPPH52 TPPH53 TPPH55 p.Thr10198Thr reference 77940 T C 5131 1 TPPH54 TPPH49 p.Asn898Asp reference 77940 T C 5131 1 TPPH29 TPPH30 TPPH32 p.Gly48Gly </code></pre> <p>and I would like to get:</p> <pre><code>reference 25038 A G 39134 1 TPPH54 p.Thr10198Thr reference 77940 T C 5131 1 TPPH54 p.Asn898Asp reference 77940 T C 5131 1 TPPH29 p.Gly48Gly </code></pre> <p>How to remove in awk/sed/grep patterns after the first one (always $7) all those having the same beggining??</p> <p>I was thinking something like:</p> <ul> <li><p>only print the 7 first columns and the last one</p> <p>paste &lt;(awk '{print $1, $2, $3, $4, $5, $6, $7}' file) &lt;(awk '{print ????}' file-tmp) &gt; file-final</p> </li> </ul> <p>but I don't know how to get the last one because the number can be different at each raw</p> <ul> <li>or 'scan' the file until having 'TPPH' beginning expression, keep the first one and remove the other ones for each raw. I'm not sure how to do it</li> </ul> <p>Thank you very much in advance for your help!</p>
[ { "answer_id": 74473441, "author": "RavinderSingh13", "author_id": 5866580, "author_profile": "https://Stackoverflow.com/users/5866580", "pm_score": 2, "selected": false, "text": "awk" }, { "answer_id": 74473587, "author": "HatLess", "author_id": 16372109, "author_profile": "https://Stackoverflow.com/users/16372109", "pm_score": 3, "selected": true, "text": "sed" }, { "answer_id": 74473725, "author": "anubhava", "author_id": 548225, "author_profile": "https://Stackoverflow.com/users/548225", "pm_score": 3, "selected": false, "text": "awk '{print $1, $2, $3, $4, $5, $6, $7, $NF}' file | column -t\nreference 25038 A G 39134 1 TPPH54 p.Thr10198Thr\nreference 77940 T C 5131 1 TPPH54 p.Asn898Asp\nreference 77940 T C 5131 1 TPPH29 p.Gly48Gly\n" }, { "answer_id": 74474830, "author": "potong", "author_id": 967492, "author_profile": "https://Stackoverflow.com/users/967492", "pm_score": 2, "selected": false, "text": "sed -E 's/\\S+/\\n&/8g;s/\\n.*\\n//;s/\\n//' file\n" }, { "answer_id": 74500378, "author": "The fourth bird", "author_id": 5424988, "author_profile": "https://Stackoverflow.com/users/5424988", "pm_score": 2, "selected": false, "text": "awk" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8830342/" ]
74,473,377
<p>I currently have two files: <code>anotherFile</code> and <code>myFile</code>, which is being merged together to a <code>result</code> file, which is sorted. All this is 3 steps, however I want to be able to make it to a so called &quot;one-liner&quot;</p> <p>Currently</p> <pre class="lang-bash prettyprint-override"><code>#(script which creates 'anotherFile') anotherFile &gt; result cat ./myFile | cut -f 1,2 &gt;&gt; result sort -o result{,} </code></pre> <p>I want to be able to &quot;one-liner&quot; this, so I don't have to refer to <code>result</code> file 3 times!</p> <pre><code>cat ./myFile | cut -f 1,2 | xargs -I sort -m anotherFile {} &gt; finalFile </code></pre> <p>I know the following above will not work since the <code>{}</code> is not an existing file.</p>
[ { "answer_id": 74473409, "author": "Thomas", "author_id": 14637, "author_profile": "https://Stackoverflow.com/users/14637", "pm_score": 3, "selected": true, "text": "{}" }, { "answer_id": 74473470, "author": "M. Nejat Aydin", "author_id": 13809001, "author_profile": "https://Stackoverflow.com/users/13809001", "pm_score": 2, "selected": false, "text": "{ ./anotherFileScript; cut -f1,2 myfile; } | sort > result\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17487397/" ]
74,473,382
<p>i saw this expression in one of the Pipeine , in the filter activity condition. can anyone help me understad this expresson used( you can refrase inorder to make it understandable). looks difficult to understand.</p> <pre><code>@if(equals(pipeline().parameters.FileName,'default'),endswith(toUpper(item().name),'.PDF'), and(startswith(item().name,replace(string(pipeline().parameters.Filemane),'*.txt','')), endswith(toUpper(item().name),'.PGP'))) </code></pre> <p>Thanks</p> <p>I dont have blocker , but i cannot understand the Expression. Just wanted to get some clarity what is the purpose of that code , what are they trying to achieve in that particualar filter condition in the ADF</p>
[ { "answer_id": 74473740, "author": "ibda", "author_id": 7981885, "author_profile": "https://Stackoverflow.com/users/7981885", "pm_score": 0, "selected": false, "text": "\nif(pipeline().parameters.FileName == 'default')\n{\n // if the name of item ends with .pdf then return true, else return false\n return endswith(toUpper(item().name),'.PDF'), \n}\nelse\n{\n // replace the *.txt with an empty string. \n // I think it means if the file ends with .txt then replace it with an empty string\n string replacedText = replace(pipeline().parameters.Filemane,'*.txt','')\n // check if the itemName is ends with .txt (in this case this condition will fail)\n boolean cond1 = startswith(item().name, replacedText)\n \n // if the name of item ends with .PGP then cond2 = true\n boolean cond2 = endswith(toUpper(item().name),'.PGP')\n \n return cond1 && cond2 \n}\n" }, { "answer_id": 74475958, "author": "Rakesh Govindula", "author_id": 18836744, "author_profile": "https://Stackoverflow.com/users/18836744", "pm_score": 2, "selected": true, "text": "FileName" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17852467/" ]
74,473,447
<p>for your understanding i attached w3school screenshot. <a href="https://i.stack.imgur.com/Ecim3.png" rel="nofollow noreferrer">enter image description here</a></p> <p>if u have ever visited w3school website u will understand my requirement easily. i want to create these html sidebar dynamic from my admin dashboard. first i will create one sidebar title name then insert content according to title name and so on..... for best understanding you can assume that i want to create w3school clone dynamic from where i can dynamic create sidebar and content. i read about react router dom and many more but not able to create like this.</p>
[ { "answer_id": 74473740, "author": "ibda", "author_id": 7981885, "author_profile": "https://Stackoverflow.com/users/7981885", "pm_score": 0, "selected": false, "text": "\nif(pipeline().parameters.FileName == 'default')\n{\n // if the name of item ends with .pdf then return true, else return false\n return endswith(toUpper(item().name),'.PDF'), \n}\nelse\n{\n // replace the *.txt with an empty string. \n // I think it means if the file ends with .txt then replace it with an empty string\n string replacedText = replace(pipeline().parameters.Filemane,'*.txt','')\n // check if the itemName is ends with .txt (in this case this condition will fail)\n boolean cond1 = startswith(item().name, replacedText)\n \n // if the name of item ends with .PGP then cond2 = true\n boolean cond2 = endswith(toUpper(item().name),'.PGP')\n \n return cond1 && cond2 \n}\n" }, { "answer_id": 74475958, "author": "Rakesh Govindula", "author_id": 18836744, "author_profile": "https://Stackoverflow.com/users/18836744", "pm_score": 2, "selected": true, "text": "FileName" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20528717/" ]
74,473,452
<p>I want to have an edit mode to each field in a div that is mapped out from an array that I fetch from firbase. I succeeded doing that by conditioning the rendered field to the value of a boolean (editField) which I then manipulate using useState, like so:</p> <p><a href="https://i.stack.imgur.com/bZOrj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bZOrj.png" alt="enter image description here" /></a></p> <p>in the functions seen up there I can manipulate the value of editTitle, so as to switch between the two functions by double clicking or clicking a button, and also update the field value in Firebase. as such:</p> <p><a href="https://i.stack.imgur.com/0lScH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0lScH.png" alt="enter image description here" /></a> this all works fine. HOWEVER, if there are more that one divs rendered from the tasks[], then thay are obviously all effected to the flipping of editTitle's value from false to true, and by double clicking one field, all fields of same name in all divs swithc to edit mode. as such:</p> <p><a href="https://i.stack.imgur.com/iJqTs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iJqTs.png" alt="enter image description here" /></a></p> <p>what can I do to target only the field in the task I want to edit? I've tried using the elemnt.id and index in some way bat can't seem to come up with the correct method...</p> <pre><code> const ifEditTitleIsTrue = (element, index) =&gt; { return ( &lt;div&gt; &lt;input type=&quot;text&quot; defaultValue={element.Title} onChange={(e) =&gt; setUpdatedTitle(e.target.value)} /&gt; &lt;button className=&quot;exit__editmode-btn btn&quot; onClick={exitEditMode}&gt; X &lt;/button&gt; &lt;button className=&quot;update__edit-btn btn&quot; id=&quot;updateTitle&quot; onClick={(e) =&gt; updateField(e, element.id)} &gt; ok &lt;/button&gt; &lt;/div&gt; ); }; // if editTitle = false (default): const ifEditTitleIsFalse = (element, index) =&gt; { return ( &lt;h3 id={index} className=&quot;task-title&quot; onDoubleClick={() =&gt; setEditTitle(true)} &gt; {element.Title} &lt;/h3&gt; ); }; // edit mode for inCharge field const ifEditInChargeIsTrue = (element, index) =&gt; { return ( &lt;div&gt; { &lt;GetCollaboratorsForEditMode catchValueInCharge={catchValueInCharge} /&gt; } &lt;button className=&quot;exit__editmode-btn btn&quot; onClick={exitEditMode}&gt; X &lt;/button&gt; &lt;button className=&quot;update__edit-btn btn&quot; id=&quot;updateInCharge&quot; onClick={(e) =&gt; updateField(e, element.id)} &gt; ok &lt;/button&gt; &lt;/div&gt; ); }; </code></pre> <pre><code> {tasks[0] &amp;&amp; tasks.map((element, index) =&gt; ( &lt;div id={element.id} className=&quot;task&quot; key={element.id}&gt; {editTitle ? ifEditTitleIsTrue(element, index) : ifEditTitleIsFalse(element, index)} </code></pre>
[ { "answer_id": 74473740, "author": "ibda", "author_id": 7981885, "author_profile": "https://Stackoverflow.com/users/7981885", "pm_score": 0, "selected": false, "text": "\nif(pipeline().parameters.FileName == 'default')\n{\n // if the name of item ends with .pdf then return true, else return false\n return endswith(toUpper(item().name),'.PDF'), \n}\nelse\n{\n // replace the *.txt with an empty string. \n // I think it means if the file ends with .txt then replace it with an empty string\n string replacedText = replace(pipeline().parameters.Filemane,'*.txt','')\n // check if the itemName is ends with .txt (in this case this condition will fail)\n boolean cond1 = startswith(item().name, replacedText)\n \n // if the name of item ends with .PGP then cond2 = true\n boolean cond2 = endswith(toUpper(item().name),'.PGP')\n \n return cond1 && cond2 \n}\n" }, { "answer_id": 74475958, "author": "Rakesh Govindula", "author_id": 18836744, "author_profile": "https://Stackoverflow.com/users/18836744", "pm_score": 2, "selected": true, "text": "FileName" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19676780/" ]
74,473,461
<pre><code>class Solution { List&lt;List&lt;int&gt;&gt; ans = new List&lt;List&lt;int&gt;&gt;(); public List&lt;List&lt;int&gt;&gt; subsets(List&lt;int&gt; A) { var currList = new List&lt;int&gt;(); A.Sort(); GenerateSubSets(A, 0, currList); ans.Sort(new ListComparer()); return ans; } public void GenerateSubSets(List&lt;int&gt; A, int position, List&lt;int&gt; currList) { if(position &gt; A.Count-1) { ans.Add(currList); return; } GenerateSubSets(A, position+1, new List&lt;int&gt;(currList)); currList.Add(A[position]); GenerateSubSets(A, position+1, new List&lt;int&gt;(currList)); return; } } public class ListComparer : IComparer&lt;List&lt;int&gt;&gt; { public int Compare(List&lt;int&gt; list1, List&lt;int&gt; list2) { var list1Index = 0; var list2Index = 0; while((list1Index &lt; list1.Count) &amp;&amp; (list2Index &lt; list2.Count)) { if(list1[list1Index].CompareTo(list2[list2Index]) == 0) { list1Index++; list2Index++; continue; } return list1[list1Index].CompareTo(list2[list2Index]); } return list1.Count &gt; list2.Count ? 1 : -1; } } </code></pre> <p>The above code when run for test case</p> <blockquote> <p>[ 8, 5, 19, 11, 10, 7, 18, 16, 13, 17 ]</p> </blockquote> <p>gives me incorrect answer.</p> <p>Instead of getting</p> <blockquote> <p>... [5 10 16 17 ] [5 10 16 17 18 ] ...</p> </blockquote> <p>I get</p> <blockquote> <p>... [5 10 16 17 18 ] [5 10 16 17 ] ...</p> </blockquote> <p>Except for this line all other comparisons seems to be working fine. Also, if I call the sort function twice,</p> <blockquote> <p>ans.Sort(new ListComparer())</p> </blockquote> <p>this issue goes away. What am I missing? I am running this code in a leetcode style editor.</p>
[ { "answer_id": 74473986, "author": "jdweng", "author_id": 5015238, "author_profile": "https://Stackoverflow.com/users/5015238", "pm_score": 0, "selected": false, "text": " public class ListComparer : IComparer<List<int>>\n {\n public int Compare(List<int> list1, List<int> list2)\n {\n int min = Math.Min(list1.Count(), list2.Count());\n\n for (int i = 0; i < min; i++)\n {\n if(list1[i] != list2[i])\n return list1[i].CompareTo(list2[i]);\n }\n return list1.Count().CompareTo(list2.Count());\n }\n }\n" }, { "answer_id": 74475264, "author": "Dmitry Bychenko", "author_id": 2319407, "author_profile": "https://Stackoverflow.com/users/2319407", "pm_score": 2, "selected": true, "text": "public class ListComparer : IComparer<List<int>> {\n public int Compare(List<int> left, List<int> right) {\n // Compare with itself is always 0\n if (ReferenceEquals(left, right)) \n return 0; \n\n // Let null be less than any list\n if (left == null)\n return -1;\n if (right == null)\n return 1;\n\n // Compare corresponding items\n for (int i = 0; i < Math.Min(left.Count, right.Count); ++i) {\n int result = left[i].CompareTo(right[i]);\n\n // items are not equal; we can return the result here\n if (result != 0)\n return result;\n }\n \n // All corresponding items are equal\n // Let longer list be greater\n return left.Count.CompareTo(right.Count); \n }\n}\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8143322/" ]
74,473,463
<p>I have multiple elements that are seperatet in two divs. The first div contains a Text and the second div a color. When I click on one element the text and color should change and if I click it again it should change back. The problem is that no matter which one I click, its always the last one which changes.</p> <p>The HTML part:</p> <pre><code>&lt;style&gt; .colorGreen { background-color: green; } .colorRed { background-color: red; } &lt;/style&gt; &lt;div class=&quot;box2&quot;&gt;Text1&lt;/div&gt; &lt;div class=&quot;box1 colorGreen&quot;&gt;O&lt;/div&gt; &lt;div class=&quot;box2&quot;&gt;Text1&lt;/div&gt; &lt;div class=&quot;box1 colorGreen&quot;&gt;O&lt;/div&gt; &lt;div class=&quot;box2&quot;&gt;Text1&lt;/div&gt; &lt;div class=&quot;box1 colorGreen&quot;&gt;O&lt;/div&gt; </code></pre> <p>The JavaScript part:</p> <pre><code>&lt;script type='text/javascript'&gt; var box1Temp = document.querySelectorAll(&quot;.box1&quot;); var box2Temp = document.querySelectorAll(&quot;.box2&quot;); for (var i = 0; i &lt; box1Temp.length; i++) { var box1 = box1Temp[i]; var box2 = box2Temp[i]; box2.onclick = box1.onclick = function() { if (box1.classList.contains(&quot;colorGreen&quot;)) { box1.classList.add(&quot;colorRed&quot;); box1.classList.remove(&quot;colorGreen&quot;); box2.innerHTML = &quot;Text2&quot;; } else { box1.classList.add(&quot;colorGreen&quot;); box1.classList.remove(&quot;colorRed&quot;); box2.innerHTML = &quot;Text1&quot;; } } } &lt;/script&gt; </code></pre> <p>It works, when I use only one div. Then I can use 'this', instead of the 'box1' variable, to addres the right element. But if I replace 'box1' with 'this' its still the text div that changes. (I know it's obvious that this is happening, but I'm lost)</p>
[ { "answer_id": 74473605, "author": "Abbas Shaikh", "author_id": 12667283, "author_profile": "https://Stackoverflow.com/users/12667283", "pm_score": -1, "selected": false, "text": "let box1 = document.querySelectorAll(\".box1\");\nlet box2 = document.querySelectorAll(\".box2\");\n\nbox1.forEach((b1,i) => {\n b1.addEventListener(\"click\",(ev) => {\n ev.target.classList.toggle(\"colorGreen\");\n ev.target.classList.toggle(\"colorRed\");\n console.log(box2[i]);\n if(ev.target.classList.contains(\"colorGreen\")){\n box2[i].textContent = \"Text1\";\n }else{\n box2[i].textContent = \"Text2\"\n }\n })\n})\n\n" }, { "answer_id": 74473655, "author": "rrr63", "author_id": 20059789, "author_profile": "https://Stackoverflow.com/users/20059789", "pm_score": 0, "selected": false, "text": "this" }, { "answer_id": 74473932, "author": "James Hill", "author_id": 763246, "author_profile": "https://Stackoverflow.com/users/763246", "pm_score": 1, "selected": true, "text": "// Capture click event for parent container, .toggle-set\nfor (const ele of document.querySelectorAll(\".toggle-set\")) {\n ele.addEventListener(\"click\", function() {\n // Grab text and color elements\n const textToggle = ele.querySelector(\".toggle-text\"); \n const colorToggle = ele.querySelector(\".toggle-color\");\n \n // Toggle text\n // NOTE: This could use further refinement with regex or something similar to strip whitespace before comparison\n textToggle.textContent = textToggle.textContent == \"Text1\" ? \"Text2\" : \"Text1\";\n \n // Toggle css classes\n colorToggle.classList.toggle(\"colorGreen\");\n colorToggle.classList.toggle(\"colorRed\");\n });\n}" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11287137/" ]
74,473,490
<p>Im trying to Make a login from an angular Frontend to an ASP.net API backend, But when I try to give the data model with the email and password within the request it doesnt reach the backend while the naming is exactly the same.</p> <p>Here is my Endpoint in ASP:</p> <pre><code>[Route(&quot;/[controller]/Login&quot;)] [HttpPost] public async Task&lt;IActionResult&gt; Login(LoginForm loginForm) </code></pre> <p>Here is my class LoginForm in ASP:</p> <pre><code>public class LoginForm { [Required] public string Email { get; set; } [Required] public string Password { get; set; } } </code></pre> <p>Here is my request code in Angular:</p> <pre><code>login(model: LoginForm) { console.log(model); return this.http.post(this.authUrl + &quot;Login&quot; , model, {}).pipe( map((response: any) =&gt; { const user = response; if (user.result.accountID &gt; 0) { localStorage.setItem(&quot;token&quot;, user.token); this.decodedToken = this.helper.decodeToken(user.token); } }) ); } </code></pre> <p>Here is my LoginForm Class in Angular:</p> <pre><code>export interface LoginForm { Email: string; Password: string; } </code></pre> <p>And here is the console log when I try it out:</p> <pre><code>{Email: 'test', Password: 'test'} </code></pre> <p>And here is the Request Payload from network when i try it out:</p> <pre><code>{Email: &quot;test&quot;, Password: &quot;test&quot;} Email : &quot;test&quot; Password : &quot;test&quot; </code></pre> <p>It does reach the backend but the model is just not filled in see picture below: <a href="https://i.stack.imgur.com/vBDBN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vBDBN.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74473605, "author": "Abbas Shaikh", "author_id": 12667283, "author_profile": "https://Stackoverflow.com/users/12667283", "pm_score": -1, "selected": false, "text": "let box1 = document.querySelectorAll(\".box1\");\nlet box2 = document.querySelectorAll(\".box2\");\n\nbox1.forEach((b1,i) => {\n b1.addEventListener(\"click\",(ev) => {\n ev.target.classList.toggle(\"colorGreen\");\n ev.target.classList.toggle(\"colorRed\");\n console.log(box2[i]);\n if(ev.target.classList.contains(\"colorGreen\")){\n box2[i].textContent = \"Text1\";\n }else{\n box2[i].textContent = \"Text2\"\n }\n })\n})\n\n" }, { "answer_id": 74473655, "author": "rrr63", "author_id": 20059789, "author_profile": "https://Stackoverflow.com/users/20059789", "pm_score": 0, "selected": false, "text": "this" }, { "answer_id": 74473932, "author": "James Hill", "author_id": 763246, "author_profile": "https://Stackoverflow.com/users/763246", "pm_score": 1, "selected": true, "text": "// Capture click event for parent container, .toggle-set\nfor (const ele of document.querySelectorAll(\".toggle-set\")) {\n ele.addEventListener(\"click\", function() {\n // Grab text and color elements\n const textToggle = ele.querySelector(\".toggle-text\"); \n const colorToggle = ele.querySelector(\".toggle-color\");\n \n // Toggle text\n // NOTE: This could use further refinement with regex or something similar to strip whitespace before comparison\n textToggle.textContent = textToggle.textContent == \"Text1\" ? \"Text2\" : \"Text1\";\n \n // Toggle css classes\n colorToggle.classList.toggle(\"colorGreen\");\n colorToggle.classList.toggle(\"colorRed\");\n });\n}" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15409620/" ]
74,473,509
<p>I want to create a program that gives you the position of the string in a list.</p> <pre><code>a = [1,3,4,5,6,7,8,9,2,&quot;rick&quot;,56,&quot;open&quot;] </code></pre>
[ { "answer_id": 74473551, "author": "Adam Jaamour", "author_id": 5609328, "author_profile": "https://Stackoverflow.com/users/5609328", "pm_score": 1, "selected": false, "text": "index()" }, { "answer_id": 74473661, "author": "ruslanway", "author_id": 19767441, "author_profile": "https://Stackoverflow.com/users/19767441", "pm_score": 0, "selected": false, "text": "a=[1,3,4,5,6,7,8,9,2,\"rick\",56,\"open\"]\n\ndef find_str(arr):\n res = {}\n for index, value in enumerate(arr):\n if isinstance(value, str):\n res[value] = index\n return res\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20410960/" ]
74,473,588
<p>prompt - c++</p> <p>Write a program that removes all spaces from the given input.</p> <p>Ex: If the input is: &quot;Hello my name is John.&quot; the output is:</p> <p>HellomynameisJohn. Your program must define and call the following function. The function should return a string representing the input string without spaces. void RemoveSpaces(string &amp;userString)</p> <p>issue - i believe my code is correct; i'm just not very clear on the concept of pass by reference so my code is wrong in terms of my assignment. that's why my output still shows up as string with spaces in my submission.</p> <p>how would i write this using pass by reference?</p> <p>my code -</p> <pre><code>#include &lt;iostream&gt; using namespace std; void RemoveSpaces ( string &amp;userString ) { unsigned int i ; for ( i = 0 ; i &lt; userString.size() ; i ++ ) { if ( userString.at(i) != ' ' ) { cout &lt;&lt; userString.at(i) ; } } } int main() { string userInputString ; getline ( cin, userInputString ); RemoveSpaces ( userInputString ) ; cout &lt;&lt; userInputString ; return 0; } </code></pre> <p>for pass by reference i had thought that userString would be &quot;updated&quot; in the function and output as the updated version?</p>
[ { "answer_id": 74473718, "author": "john", "author_id": 882003, "author_profile": "https://Stackoverflow.com/users/882003", "pm_score": 3, "selected": true, "text": "void RemoveSpaces ( string &userString )\n{\n string temp;\n for (size_t i = 0 ; i < userString.size() ; i ++ )\n {\n if (userString.at(i) != ' ' )\n temp.push_back(userString.at(i));\n }\n userString = temp;\n}\n" }, { "answer_id": 74473916, "author": "Serge Ballesta", "author_id": 3545273, "author_profile": "https://Stackoverflow.com/users/3545273", "pm_score": 0, "selected": false, "text": "using namespace std" }, { "answer_id": 74474001, "author": "compli", "author_id": 16006373, "author_profile": "https://Stackoverflow.com/users/16006373", "pm_score": 2, "selected": false, "text": "void RemoveSpaces ( string &userString )\n{\n unsigned int i ; \n int count = 0;\n for ( i = 0 ; i < userString.size() ; i ++ )\n {\n if ( userString.at(i) != ' ' )\n {\n userString.at(count++) = userString.at(i);\n cout << userString.at(i) ;\n }\n }\n userString.resize(count);\n}\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473588", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20528802/" ]
74,473,596
<p>This should be easy, but I am struggling with type managing trying to send a list as property to a component. Specifically, I am creating the following component:</p> <pre><code>const [list, setList] = useState&lt;Array&lt;ToastProps&gt;&gt;([]); ... &lt;Toast toastlist={list}&gt;&lt;/Toast&gt; </code></pre> <p>This component is set as:</p> <pre><code>export interface ToastProps { id: number; title: string; description: string; backgroundColor: string; } export default function Toast(props: ToastProps[]) { return ( &lt;div&gt; {props.map((toast, i) =&gt; ( &lt;div key={i} style={{ backgroundColor: toast.backgroundColor }}&gt; &lt;button&gt;X&lt;/button&gt; &lt;div&gt; &lt;p&gt;{toast.title}&lt;/p&gt; &lt;p&gt;{toast.description}&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; ))} &lt;/div&gt; ); } </code></pre> <p>I have the following error:</p> <blockquote> <p>Type '{ toastlist: ToastProps[]; }' is not assignable to type 'IntrinsicAttributes &amp; ToastProps[]'.</p> </blockquote> <p>How can I fix this problem? Thanks in advance for any help you can provide.</p>
[ { "answer_id": 74473626, "author": "Sachila Ranawaka", "author_id": 6428638, "author_profile": "https://Stackoverflow.com/users/6428638", "pm_score": 3, "selected": true, "text": "export default function Toast({toastlist}: {toastlist:ToastProps[]}) {\n return (\n <div>\n {toastlist.map((toast, i) => (\n <div key={i} style={{ backgroundColor: toast.backgroundColor }}>\n <button>X</button>\n <div>\n <p>{toast.title}</p>\n <p>{toast.description}</p>\n </div>\n </div>\n ))}\n </div>\n );\n}\n" }, { "answer_id": 74473792, "author": "Ivan Popov", "author_id": 15999141, "author_profile": "https://Stackoverflow.com/users/15999141", "pm_score": 1, "selected": false, "text": "export interface ToastList {\n id: number;\n title: string;\n description: string;\n backgroundColor: string;\n}\n\nexport interface ToastProps {\n toastlist: ToastList[];\n}\n\n/////\nconst [list, setList] = useState<ToastList[]>([]);\n...\n<Toast toastlist={list}></Toast>\n/////\n\n\nexport default function Toast(props: ToastProps) {\n return (\n <div>\n {props.map((toast, i) => (\n <div key={i} style={{ backgroundColor: toast.backgroundColor }}>\n <button>X</button>\n <div>\n <p>{toast.title}</p>\n <p>{toast.description}</p>\n </div>\n </div>\n ))}\n </div>\n );\n}\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14729041/" ]
74,473,615
<p>I want to make my design more responsive. But whenever I make those background circles, it stops being responsive, and the image of the person and the yellow circle stop sticking to the center. Any tips on how I can do it better and more efficiently?</p> <p>I'm having difficulties making it responsive cause all the elements have <code>position: absolute</code>. I am currently doing it like this:</p> <pre><code>&lt;div className=&quot;background&quot;&gt; &lt;div className='outer-circle'&gt;&lt;/div&gt; // Gray circles &lt;img src={landingPersonImage} alt=&quot;&quot;&gt; // Image of the person &lt;div className='section1-img-bg'&gt;&lt;/div&gt; // Yellow circle &lt;/div&gt; </code></pre> <p><a href="https://i.stack.imgur.com/AKx19.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AKx19.png" alt="Sample design" /></a></p> <p>My main issue is that the yellow circle is not sticking to the center of those background circles. Here is a video of what I mean: <a href="https://drive.google.com/file/d/1ZA_skdNAyt2L9pewoTIuIF4CKJLCsqIR/view?usp=share_link" rel="nofollow noreferrer">https://drive.google.com/file/d/1ZA_skdNAyt2L9pewoTIuIF4CKJLCsqIR/view?usp=share_link</a></p> <p>Codepen - <a href="https://codepen.io/c0mpli-the-scripter/pen/OJExaLR" rel="nofollow noreferrer">https://codepen.io/c0mpli-the-scripter/pen/OJExaLR</a> Grey is replaced with green for better visibilty.</p>
[ { "answer_id": 74473626, "author": "Sachila Ranawaka", "author_id": 6428638, "author_profile": "https://Stackoverflow.com/users/6428638", "pm_score": 3, "selected": true, "text": "export default function Toast({toastlist}: {toastlist:ToastProps[]}) {\n return (\n <div>\n {toastlist.map((toast, i) => (\n <div key={i} style={{ backgroundColor: toast.backgroundColor }}>\n <button>X</button>\n <div>\n <p>{toast.title}</p>\n <p>{toast.description}</p>\n </div>\n </div>\n ))}\n </div>\n );\n}\n" }, { "answer_id": 74473792, "author": "Ivan Popov", "author_id": 15999141, "author_profile": "https://Stackoverflow.com/users/15999141", "pm_score": 1, "selected": false, "text": "export interface ToastList {\n id: number;\n title: string;\n description: string;\n backgroundColor: string;\n}\n\nexport interface ToastProps {\n toastlist: ToastList[];\n}\n\n/////\nconst [list, setList] = useState<ToastList[]>([]);\n...\n<Toast toastlist={list}></Toast>\n/////\n\n\nexport default function Toast(props: ToastProps) {\n return (\n <div>\n {props.map((toast, i) => (\n <div key={i} style={{ backgroundColor: toast.backgroundColor }}>\n <button>X</button>\n <div>\n <p>{toast.title}</p>\n <p>{toast.description}</p>\n </div>\n </div>\n ))}\n </div>\n );\n}\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16006373/" ]
74,473,632
<p>I want to calculate the bounding rect of a shape after I scale or rotate it.</p> <p>First of all, I want to get the width and height.</p> <p><a href="https://i.stack.imgur.com/axISa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/axISa.png" alt="enter image description here" /></a></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const ctx = document.body.appendChild(document.createElement('canvas')).getContext('2d') let rotation = 45 let p1 = new Path2D() p1.rect(0, 0, 75, 75) let p2 = new Path2D() p2.addPath(p1, new DOMMatrix().translate(80, 10).scale(1, 1.2).rotate(45)) ctx.fillStyle = 'red' ctx.fill(p2) //how get bounding rect from p2 or ctx { width , height ,...}</code></pre> </div> </div> </p>
[ { "answer_id": 74476952, "author": "Kaiido", "author_id": 3702797, "author_profile": "https://Stackoverflow.com/users/3702797", "pm_score": 1, "selected": false, "text": "Path2D" }, { "answer_id": 74493464, "author": "Meysam Ghorbani", "author_id": 18642505, "author_profile": "https://Stackoverflow.com/users/18642505", "pm_score": 0, "selected": false, "text": "const ctx = document.body.appendChild(document.createElement('canvas')).getContext('2d')\nctx.canvas.width = innerWidth, ctx.canvas.height = innerHeight\n\nlet p1 = new Path2D()\n\np1.rect(0, 0, 100, 100)\nlet p2 = new Path2D()\n\np2.addPath(p1, new DOMMatrix().rotate(10).translate(80, 10))\n\nctx.fillStyle = 'red'\n\nctx.fill(p2)\n\np1 = new Path2D()\n\np1.arc(0, 0, 40, 0,100)\np2 = new Path2D()\n\np2.addPath(p1, new DOMMatrix().rotate(10).translate(80, 40))\n\nctx.fillStyle = 'blue'\n\nctx.fill(p2)\n\nconst bbox = getBoundingBox(ctx, 0, 0, innerWidth, innerHeight)\n\nctx.strokeStyle = \"green\";\n\nctx.strokeRect(bbox.left, bbox.top, bbox.width, bbox.height);\n\n\nfunction getBoundingBox(ctx, left, top, width, height) {\nvar ret = {}, data = ctx.getImageData(left, top, width, height).data, first = false, last = false, right = false, left = false, r = height, w = 0, c = 0, d = 0;\n\n// 1. get bottom\nwhile (!last && r) {\n r--;\n for (c = 0; c < width; c++) {\n if (data[r * width * 4 + c * 4 + 3]) {\n last = r + 1;\n ret.bottom = r + 1;\n break;\n }\n }\n}\n\n// 2. get top\nr = 0;\nvar checks = [];\nwhile (!first && r < last) {\n for (c = 0; c < width; c++) {\n if (data[r * width * 4 + c * 4 + 3]) {\n first = r - 1;\n ret.top = r - 1;\n ret.height = last - first - 1;\n break;\n }\n }\n r++;\n}\n\n// 3. get right\nc = width;\nwhile (!right && c) {\n c--;\n for (r = 0; r < height; r++) {\n if (data[r * width * 4 + c * 4 + 3]) {\n right = c + 1;\n ret.right = c + 1;\n break;\n }\n }\n}\n\n// 4. get left\nc = 0;\nwhile (!left && c < right) {\n for (r = 0; r < height; r++)\n if (data[r * width * 4 + c * 4 + 3]) {\n left = c;\n ret.left = c;\n ret.width = right - left - 1;\n break;\n }\n c++;\n if (left) return ret;\n}\n}" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18642505/" ]
74,473,698
<p>i have a data frame with dates and values :</p> <pre><code> n = 1000 date = seq(as.Date(&quot;2022/1/1&quot;), by = &quot;day&quot;, length.out = n) value = rnorm(n,0,1) df = tibble(date,value);df </code></pre> <p>how can i ggplot this data frame and to plot in the geom_line or geom_point two arrows pointing the maximum value and the minimum value of the value variable ?</p> <pre><code>ggplot(data =df, aes(x = date,y=value)) + geom_point() ggplot(data =df, aes(x = date,y=value)) + geom_line() </code></pre> <p>Any help ?</p>
[ { "answer_id": 74474031, "author": "Tech Commodities", "author_id": 9541415, "author_profile": "https://Stackoverflow.com/users/9541415", "pm_score": 2, "selected": true, "text": "geom_segment()" }, { "answer_id": 74474365, "author": "TarJae", "author_id": 13321647, "author_profile": "https://Stackoverflow.com/users/13321647", "pm_score": 2, "selected": false, "text": "or" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16346449/" ]
74,473,702
<pre><code>protected void DropDownMainProduct_SelectedIndexChanged(object sender, EventArgs e) { string mainProductCode = DropDownMainProduct.SelectedValue; if (mainProductCode == &quot;0&quot;) { DropDownSubProduct.SelectedValue = &quot;0&quot;; DropDownSubProduct.Attributes.Add(&quot;disabled&quot;, &quot;true&quot;); } else { DropDownSubProduct.Attributes.Remove(&quot;disabled&quot;); } } </code></pre> <p>Can I use the <code>DropDownMainProduct_SelectedIndexChanged</code> function in different ASP.NET pages without re-writing the dropdown's <code>IndexChanged</code> method?</p>
[ { "answer_id": 74478058, "author": "Albert D. Kallal", "author_id": 10527, "author_profile": "https://Stackoverflow.com/users/10527", "pm_score": 1, "selected": false, "text": " protected void DropDownMainProduct_SelectedIndexChanged(object sender, EventArgs e)\n {\n MyCode.MyDropDown(sender);\n }\n" }, { "answer_id": 74495443, "author": "Scott Hannen", "author_id": 5101046, "author_profile": "https://Stackoverflow.com/users/5101046", "pm_score": 3, "selected": true, "text": "DropDownMainProduct_SelectedIndexChanged" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20507126/" ]
74,473,739
<p>Suppose i have following id</p> <pre><code>74876593476 74877777777 74884784633 74822228765 74878645421 74820201111 </code></pre> <p>i want to ignore any number contain more than 3 repeated numbers respectively, then the expected result is:</p> <pre><code>74876593476 74884784633 74878645421 74876593476 </code></pre>
[ { "answer_id": 74473890, "author": "Ronak Shah", "author_id": 3962914, "author_profile": "https://Stackoverflow.com/users/3962914", "pm_score": 2, "selected": false, "text": "grep" }, { "answer_id": 74473946, "author": "George Savva", "author_id": 12176280, "author_profile": "https://Stackoverflow.com/users/12176280", "pm_score": 1, "selected": false, "text": "strsplit" }, { "answer_id": 74474035, "author": "ThomasIsCoding", "author_id": 12158757, "author_profile": "https://Stackoverflow.com/users/12158757", "pm_score": 2, "selected": false, "text": "grepl" }, { "answer_id": 74474111, "author": "Nathan", "author_id": 17133994, "author_profile": "https://Stackoverflow.com/users/17133994", "pm_score": 0, "selected": false, "text": "library(tidyverse)\nlibrary(rlang)\n\ndata <- tibble(id=as.character(c(74876593476,74877777777,11111,74884784633,74822228765,74878645421,74820201111)))\n\n\noutput <- data %>% mutate(triple=grepl(x=id,pattern=\"111|222|777\")) %>%\n filter(triple==FALSE)\n" }, { "answer_id": 74476734, "author": "jblood94", "author_id": 9463489, "author_profile": "https://Stackoverflow.com/users/9463489", "pm_score": 2, "selected": false, "text": "fNoRep <- function(x, k = 3L) {\n n <- ceiling(log10(x)) + 1L\n # get the digits as integers, plus an extra digit for each value\n i <- as.integer((rep.int(x, n)/10^sequence(n, 0))%%10)\n # set the extra digit to 10 in order to separate the values\n i[cs <- cumsum(n)] <- 10L\n # use rle to find runs longer than k\n lens <- rle(i)$lengths\n x[-unique(findInterval(cumsum(lens)[which(lens > k)], cs)) - 1L]\n}\n\nx <- c(74876593476, 74877777777, 74884784633, 74822228765, 74878645421, 74820201111, 91526000000)\nfNoRep(x)\n#> [1] 74876593476 74884784633 74878645421\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12121095/" ]
74,473,747
<p>It is actually working in my purpose for example like it has to be show my Minutes in screen. However when I executed the code console show up always error. I really want to know why they showed me Error and really want to fix it.</p> <p>So my code is basically like this:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;body&gt; &lt;div id=&quot;root&quot;&gt;&lt;/div&gt; &lt;/body&gt; &lt;script src=&quot;https://unpkg.com/react@17.0.2/umd/react.development.js&quot;&gt;&lt;/script&gt; &lt;script src=&quot;https://unpkg.com/react-dom@17.0.2/umd/react-dom.development.js&quot;&gt;&lt;/script&gt; &lt;script src=&quot;https://unpkg.com/@babel/standalone/babel.min.js&quot;&gt;&lt;/script&gt; &lt;script type=&quot;text/babel&quot;&gt; function App() { const [minutes, setMinutes] = React.useState(); const onChange = (event) =&gt; { setMinutes(event.target.value); }; return ( &lt;div&gt; &lt;h1 className=&quot;hi&quot;&gt;Super Converter&lt;/h1&gt; &lt;label htmlFor=&quot;minutes&quot;&gt;Minutes&lt;/label&gt; &lt;input value={minutes} id=&quot;minutes&quot; placeholder=&quot;Minutes&quot; type=&quot;number&quot; onChange={onChange} /&gt; &lt;h4&gt;You want to convert {minutes}&lt;/h4&gt; &lt;label htmlFor=&quot;hours&quot;&gt;Hours&lt;/label&gt; &lt;input id=&quot;hours&quot; placeholder=&quot;Hours&quot; type=&quot;number&quot; /&gt; &lt;/div&gt; ); } const root = document.getElementById(&quot;root&quot;); ReactDOM.render(&lt;App /&gt;, root); &lt;/script&gt; &lt;/html&gt; </code></pre> <p>and always Error code like</p> <pre><code>react-dom.development.js:61 Warning: A component is changing an uncontrolled input to be controlled. This is likely caused by the value changing from undefined to a defined value, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components at input at div at App (&lt;anonymous&gt;:10:31) </code></pre> <p>I'd like to know why it happened to me and what I have to do for figuring out.</p>
[ { "answer_id": 74473880, "author": "Ankit", "author_id": 19757319, "author_profile": "https://Stackoverflow.com/users/19757319", "pm_score": 1, "selected": false, "text": "0" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17384919/" ]
74,473,765
<p>I'm trying to scrape the webpage ted.europa.eu using Python with Selenium to retrieve information from the tenders. The script is supposed to be executed once a day with the new publications. The problem I have is that navigating to the new tenders I need Selenium to apply a filter to get only the ones from the same day the script it's executed. I already have the script for this and works perfectly, the problem is that when I activate the headless mode I get the following error <code>selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable: [object HTMLInputElement] has no size and location</code></p> <p>This is the code I have that applies the filter I need:</p> <pre><code>import sys import time import re from datetime import datetime from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.action_chains import ActionChains from dotenv import load_dotenv load_dotenv(&quot;../../../../.env&quot;) sys.path.append(&quot;../src&quot;) sys.path.append(&quot;../../../../utils&quot;) from driver import * from lted import LTED from runnable import * # start print('start...') counter = 0 start = datetime.now() # get driver driver = get_driver_from_url(&quot;https://ted.europa.eu/TED/browse/browseByMap.do%22) actions = ActionChains(driver) # change language to spanish WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, &quot;lgId&quot;))) driver.find_element(By.ID, &quot;lgId&quot;).click() driver.find_element(By.XPATH, &quot;//select[@id='lgId']/option[text()='español (es)']&quot;).click() # click on &quot;Busqueda avanzada&quot; WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, &quot;goToSearch&quot;))) driver.find_element(By.ID, &quot;goToSearch&quot;).click() # accept cookies and close tab WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, &quot;cookie-consent-banner&quot;))) driver.find_element(By.XPATH, &quot;//div[@id='cookie-consent-banner']/div[1]/div[1]/div[2]/a[1]&quot;).click() driver.find_element(By.XPATH, &quot;//div[@id='cookie-consent-banner']/div[1]/div[1]/div[2]/a[1]&quot;).click() # click on specific date and set to today WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, &quot;publicationDateSpecific&quot;))) element = driver.find_element(By.ID, &quot;publicationDateSpecific&quot;) actions.move_to_element(element).perform() driver.find_element(By.ID, &quot;publicationDateSpecific&quot;).click() driver.find_element(By.CLASS_NAME, &quot;ui-state-highlight&quot;).click() # click on search driver.find_element(By.ID, &quot;search&quot;).click() </code></pre> <p>From the imports the only think I need to explain is that from the line <code>from dirver import *</code> comes the method <code>get_driver_from_url()</code> that is used later in the code. This method looks like this:</p> <pre><code>def get_driver_from_url(url): options = webdriver.ChromeOptions() options.add_argument(&quot;--no-sandbox&quot;) options.add_argument(&quot;--disable-dev-shm-usage&quot;) options.add_argument(&quot;--start-maximized&quot;) options.add_argument(&quot;--headless&quot;) driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options) driver.get(url) return driver </code></pre> <p>As I said this code works perfectly without the headless mode, but when activated I get the error.</p> <p>At first got another error and searching on the Internet found out that it could be because the element is not on screen, so I added the argument <code>&quot;--start-maximized&quot;</code> to make sure the Chrome tab is as big as possible and added the ActionChains to use <code>actions.move_to_element(element).perform()</code>, but I get this error on this exact code line.</p> <p>Also tried changing the line <code>WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, &quot;publicationDateSpecific&quot;)))</code> to <code>WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, &quot;publicationDateSpecific&quot;)))</code> but it just didn't work.</p> <p>Update: Also tried changing to <code>EC.visibility_of_element_located</code> as mentioned in <a href="https://stackoverflow.com/questions/68806577/python3-with-selenium-elementnotinteractable-object-has-no-size-and-location">this</a> post but didn't work either</p> <p>What am I doing wrong?</p>
[ { "answer_id": 74473880, "author": "Ankit", "author_id": 19757319, "author_profile": "https://Stackoverflow.com/users/19757319", "pm_score": 1, "selected": false, "text": "0" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20477176/" ]
74,473,795
<p>I want to loop over this array of objects to render them in a component in react, why the mapping is not working?</p> <p>fruits:[{&quot;value&quot;:&quot;Apple&quot;,&quot;status&quot;:&quot;Green&quot;},{&quot;value&quot;:&quot;Orange &quot;,&quot;status&quot;:&quot;Yellow&quot;},{&quot;value&quot;:&quot;Banana&quot;,&quot;status&quot;:&quot;Green&quot;}]</p> <pre><code>export interface FruitsStatus { fruits: Record&lt;string, string&gt;; } const Fruits: (props: FruitsStatus) =&gt; JSX.Element = props =&gt; { return ( {props.fruits.map((fruit, index) =&gt; { return ( &lt;tr key={index}&gt; &lt;td&gt; {fruit.value} &lt;/td&gt; &lt;td &gt; {fruit.status} &lt;/td&gt; &lt;/tr&gt; ); })} ) } </code></pre>
[ { "answer_id": 74473857, "author": "Shawn", "author_id": 14361465, "author_profile": "https://Stackoverflow.com/users/14361465", "pm_score": 1, "selected": false, "text": "export interface FruitsStatus { \n fruits: Record<string, string>[];\n}\nconst Fruits: (props: FruitsStatus) => JSX.Element = props => {\nreturn (\n{props.fruits.map((fruit, index) => {\n return (\n <tr key={index}>\n <td>\n {fruit.value}\n </td>\n <td > {fruit.status} </td>\n </tr>\n );\n })}\n)\n}\n" }, { "answer_id": 74473860, "author": "Ali Sattarzadeh", "author_id": 11434567, "author_profile": "https://Stackoverflow.com/users/11434567", "pm_score": 3, "selected": true, "text": "return (\n <>\n {props.fruits.map((fruit, index) => {\n return (\n <tr key={index}>\n <td>\n {fruit.value}\n </td>\n <td > {fruit.status} </td>\n </tr>\n );\n })}\n </>\n)\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18892774/" ]
74,473,811
<p>I’ve got a very simple scenario. I have an api response that simply returns an array of strings.</p> <pre><code>[‘test’,’test2’,’test3’] </code></pre> <p>I need to deserialise into an object to integrate with some current code.</p> <p>I’ve tried using a straight class with a single property of type List but no dice.</p> <p>How to deserialise into single object?</p>
[ { "answer_id": 74473857, "author": "Shawn", "author_id": 14361465, "author_profile": "https://Stackoverflow.com/users/14361465", "pm_score": 1, "selected": false, "text": "export interface FruitsStatus { \n fruits: Record<string, string>[];\n}\nconst Fruits: (props: FruitsStatus) => JSX.Element = props => {\nreturn (\n{props.fruits.map((fruit, index) => {\n return (\n <tr key={index}>\n <td>\n {fruit.value}\n </td>\n <td > {fruit.status} </td>\n </tr>\n );\n })}\n)\n}\n" }, { "answer_id": 74473860, "author": "Ali Sattarzadeh", "author_id": 11434567, "author_profile": "https://Stackoverflow.com/users/11434567", "pm_score": 3, "selected": true, "text": "return (\n <>\n {props.fruits.map((fruit, index) => {\n return (\n <tr key={index}>\n <td>\n {fruit.value}\n </td>\n <td > {fruit.status} </td>\n </tr>\n );\n })}\n </>\n)\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2951437/" ]
74,473,820
<p>I am new to MySQL and learning about trigger. I have 2 tables that I want : when a table (detail_transaction) has been inserted, a 'stock' field of another table (item) change.</p> <ul> <li>'item' Table</li> </ul> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>id</th> <th>name</th> <th>price</th> <th>stock</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Item_A</td> <td>15</td> <td>900</td> </tr> <tr> <td>2</td> <td>Item_B</td> <td>9</td> <td>500</td> </tr> </tbody> </table> </div> <ul> <li>'detail_transaction' Table</li> </ul> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>id</th> <th>id_item</th> <th>count</th> <th>total_price</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1</td> <td>5</td> <td>75</td> </tr> </tbody> </table> </div> <p>If I insert new row in 'detail_transaction' table, I WANT my 'stock' field in 'item' table with the same 'id' to decrease and adjust to the 'count' of the 'detail_transaction'. For example : I insert new row in 'detail_transaction' table :</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>id</th> <th>id_item</th> <th>count</th> <th>total_price</th> </tr> </thead> <tbody> <tr> <td>2</td> <td>1</td> <td><strong>10</strong></td> <td>150</td> </tr> </tbody> </table> </div> <p>I WANT the 'item' table updated to :</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>id</th> <th>name</th> <th>price</th> <th>stock</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Item_A</td> <td>15</td> <td><strong>890</strong></td> </tr> <tr> <td>2</td> <td>Item_B</td> <td>9</td> <td>500</td> </tr> </tbody> </table> </div> <p>I created a trigger to try achieve my purpose, but when I tried to insert new row in 'detail_transaction' I got this error : <em>Can't update 'item' table in stored function/trigger because it is already used by statement which invoked this stored function/trigger</em>.</p> <p>My trigger :</p> <pre><code>DELIMITER $$ CREATE TRIGGER update_stock AFTER INSERT ON detail_transaction FOR EACH ROW BEGIN UPDATE item JOIN detail_transaction ON detail_transaction.id_item = item.id SET stock = stock - NEW.count WHERE item.id = NEW.id_item; END$$ DELIMITER ; </code></pre> <p>Then, I inserted row to detail_transaction table :</p> <pre><code>INSERT INTO detail_transaction (id, id_item, count, total_price) VALUES (2, 1, 10, (SELECT price FROM item WHERE item.ID = 1) * 10); </code></pre> <p>But I got the error. What can I do to solve this? Is it because of the SELECT part when I try to INSERT? Thanks for your answer.</p>
[ { "answer_id": 74474016, "author": "Neville Kuyt", "author_id": 626692, "author_profile": "https://Stackoverflow.com/users/626692", "pm_score": 2, "selected": true, "text": "Item" }, { "answer_id": 74475098, "author": "P.Salmon", "author_id": 6152400, "author_profile": "https://Stackoverflow.com/users/6152400", "pm_score": 0, "selected": false, "text": "INSERT INTO detail_transaction (id, id_item, count, total_price)\n select 2, 1, 10, price * 10 \n FROM item \nWHERE item.ID = 1;\n" }, { "answer_id": 74475261, "author": "Akina", "author_id": 10138734, "author_profile": "https://Stackoverflow.com/users/10138734", "pm_score": 0, "selected": false, "text": "CREATE TABLE item (\n `id` INTEGER AUTO_INCREMENT PRIMARY KEY,\n `name` VARCHAR(255),\n `price` INTEGER,\n `stock` INTEGER\n);\nINSERT INTO item VALUES\n ('1', 'Item_A', '15', '900'),\n ('2', 'Item_B', '9', '500');\nSELECT * FROM item;\n\nCREATE TABLE detail_transaction (\n `id` INTEGER AUTO_INCREMENT PRIMARY KEY,\n `id_item` INTEGER,\n `count` INTEGER,\n `total_price` INTEGER,\n FOREIGN KEY (`id_item`) REFERENCES `item` (`id`)\n);\nINSERT INTO detail_transaction VALUES\n ('1', '1', '5', '75');\nSELECT * FROM detail_transaction;\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20528649/" ]
74,473,909
<p>I have a Javascript regex like this:</p> <pre><code>/^[a-zA-Z0-9 !@#$%^&amp;*()-_-~.+,/\&quot; ]+$/ </code></pre> <p>which allows following conditions:</p> <ol> <li><p>only alphabets allowed</p> </li> <li><p>only numeric allowed</p> </li> <li><p>combination of alphabets and numeric allowed</p> </li> <li><p>combination of alphabets, numeric and special characters are allowed</p> </li> </ol> <p>I want to modify above regex to cover two more cases as below:</p> <blockquote> <p>only special characters are not allowed</p> </blockquote> <blockquote> <p>string should not start with special characters</p> </blockquote> <p>so basicaly my requirement is:</p> <pre><code>string = 'abc' -&gt; Correct string = '123' -&gt; Correct string = 'abc123' -&gt;Correct string = 'abc123!@#' -&gt;Correct string = 'abc!@#123' -&gt; Correct string = '123!@#abc' -&gt; Correct string = '!@#' -&gt; Wrong string = '!@#abc' -&gt; Wrong string = '!@#123' -&gt; Wrong string = '!@#abc123' -&gt; Wrong </code></pre> <p>can someone please help me with this?</p>
[ { "answer_id": 74473958, "author": "Wiktor Stribiżew", "author_id": 3832970, "author_profile": "https://Stackoverflow.com/users/3832970", "pm_score": 2, "selected": true, "text": "/^(?=[^a-zA-Z0-9]*[a-zA-Z0-9])[a-zA-Z0-9 !@#$%^&*()_~.+,/\\\" -]+$/\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" }, { "answer_id": 74477030, "author": "zer00ne", "author_id": 2813224, "author_profile": "https://Stackoverflow.com/users/2813224", "pm_score": 0, "selected": false, "text": "[a-zA-Z0-9]" }, { "answer_id": 74493739, "author": "Van Minh Nhon TRUONG", "author_id": 4970104, "author_profile": "https://Stackoverflow.com/users/4970104", "pm_score": 0, "selected": false, "text": "_" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7036867/" ]
74,473,955
<p>What I'm trying to do is to detect the type of logged-in user and then setting a <code>.profile</code> parameter to <code>request.user</code>, so I can use it by calling <code>request.user.profile</code> in my views.</p> <p>To do this, I've wrote a <code>Middleware</code> as follows:</p> <pre class="lang-py prettyprint-override"><code>class SetProfileMiddleware: def __init__(self, get_response): self.get_response = get_response def __call__(self, request): user, token = JWTAuthentication().authenticate(request) profile_type = token.payload.get(&quot;profile_type&quot;, None) request.user.profile = User.get_profile(profile_type, request.user) request.user.profile_type = profile_type # Works Here print(&quot;-&quot; * 20) print(type(request.user)) # &lt;class 'django.utils.functional.SimpleLazyObject'&gt; print('Process Request -&gt;', request.user.profile) response = self.get_response(request) # Does not work here print(&quot;-&quot; * 20) print(type(request.user)) # &lt;class 'users.models.User'&gt; print('Process Response -&gt;', request.user.profile) return response def process_view(self, request, view_func, view_args, view_kwargs): # Works here print(&quot;-&quot; * 20) print(type(request.user)) # &lt;class 'django.utils.functional.SimpleLazyObject'&gt; print('Process View -&gt;', request.user.profile) </code></pre> <p>Now I can access <code>request.user.profile</code> in <code>process_view</code> however it does not exists in my views and is causing an <code>AttributeError</code> stating that <code>'User' object has no attribute 'profile'</code>.</p> <p>Seems my <code>request.user</code> is being overwritten somewhere before hitting the view.</p> <hr /> <p>Note that I'm using Django Rest Framework, here is my view:</p> <pre class="lang-py prettyprint-override"><code>class ProfileAPIView(generics.RetrieveUpdateAPIView): serializer_class = ProfileSerializer def get_object(self): obj = self.request.user.profile # Raise the `AttributeError` self.check_object_permissions(self.request, obj) return obj </code></pre> <p>Here is my <code>settings.py</code>:</p> <pre class="lang-py prettyprint-override"><code>MIDDLEWARE = [ &quot;django.middleware.security.SecurityMiddleware&quot;, &quot;django.contrib.sessions.middleware.SessionMiddleware&quot;, &quot;django.middleware.common.CommonMiddleware&quot;, &quot;django.middleware.csrf.CsrfViewMiddleware&quot;, &quot;django.contrib.auth.middleware.AuthenticationMiddleware&quot;, &quot;django.contrib.messages.middleware.MessageMiddleware&quot;, &quot;django.middleware.clickjacking.XFrameOptionsMiddleware&quot;, ] LOCAL_MIDDLEWARE = [ &quot;users.middleware.SetProfileMiddleware&quot;, ] MIDDLEWARE = MIDDLEWARE + LOCAL_MIDDLEWARE REST_FRAMEWORK = { &quot;DEFAULT_PERMISSION_CLASSES&quot;: (&quot;rest_framework.permissions.IsAuthenticated&quot;,), &quot;DEFAULT_RENDERER_CLASSES&quot;: ( &quot;rest_framework.renderers.JSONRenderer&quot;, &quot;rest_framework.renderers.BrowsableAPIRenderer&quot;, ), &quot;DEFAULT_AUTHENTICATION_CLASSES&quot;: [ &quot;rest_framework_simplejwt.authentication.JWTAuthentication&quot;, ], } SIMPLE_JWT = { &quot;SLIDING_TOKEN_REFRESH_LIFETIME&quot;: timedelta(minutes=45), &quot;AUTH_TOKEN_CLASSES&quot;: (&quot;rest_framework_simplejwt.tokens.SlidingToken&quot;,), } DEFAULT_AUTO_FIELD = &quot;django.db.models.BigAutoField&quot; AUTH_USER_MODEL = &quot;users.User&quot; LOGIN_REDIRECT_URL = &quot;admin/&quot; </code></pre>
[ { "answer_id": 74473958, "author": "Wiktor Stribiżew", "author_id": 3832970, "author_profile": "https://Stackoverflow.com/users/3832970", "pm_score": 2, "selected": true, "text": "/^(?=[^a-zA-Z0-9]*[a-zA-Z0-9])[a-zA-Z0-9 !@#$%^&*()_~.+,/\\\" -]+$/\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" }, { "answer_id": 74477030, "author": "zer00ne", "author_id": 2813224, "author_profile": "https://Stackoverflow.com/users/2813224", "pm_score": 0, "selected": false, "text": "[a-zA-Z0-9]" }, { "answer_id": 74493739, "author": "Van Minh Nhon TRUONG", "author_id": 4970104, "author_profile": "https://Stackoverflow.com/users/4970104", "pm_score": 0, "selected": false, "text": "_" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3423768/" ]
74,473,962
<p>I have implemented a &quot;super app&quot; for Android &amp; iOS that opens various web apps in a WebView, allowing users to access standard services without having to leave the app.</p> <h2>The Flow</h2> <p>The user opens the Mobile App</p> <p>The user selects a web app from the list of common apps like Facebook, Twitter, Deliveroo, Uber, and other shopping, food delivery, and ride-hailing apps.</p> <h2>The Problem</h2> <p>The web apps work fine for everything, however, the push notifications are not received by the WebView.</p> <h2>What I have tried</h2> <p>I have tried using Google Chrome Push Notifications for this. However, it only supports Chrome and it is not possible to receive these notifications in iframe or WebView.</p> <h2>What I Expect</h2> <p>I expect to be able to receive notifications from these web apps of various services I have integrated, as it is not 100% usable if my users are not able to get notifications for these web apps.</p>
[ { "answer_id": 74473958, "author": "Wiktor Stribiżew", "author_id": 3832970, "author_profile": "https://Stackoverflow.com/users/3832970", "pm_score": 2, "selected": true, "text": "/^(?=[^a-zA-Z0-9]*[a-zA-Z0-9])[a-zA-Z0-9 !@#$%^&*()_~.+,/\\\" -]+$/\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" }, { "answer_id": 74477030, "author": "zer00ne", "author_id": 2813224, "author_profile": "https://Stackoverflow.com/users/2813224", "pm_score": 0, "selected": false, "text": "[a-zA-Z0-9]" }, { "answer_id": 74493739, "author": "Van Minh Nhon TRUONG", "author_id": 4970104, "author_profile": "https://Stackoverflow.com/users/4970104", "pm_score": 0, "selected": false, "text": "_" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11208942/" ]
74,473,985
<p>I need to call my sign method in my Livewire controller. So far I haven't been able to get it to work because nothing happens</p> <pre><code> function handleValidButtonClick(event) { event.preventDefault(); console.log(canvas.toDataURL()); const dataURL = canvas.toDataURL('image/png'); const data = dataURL.replace(/^data:image\/(png|jpg);base64,/, &quot;&quot;); const id = {{ $id }}; try { Livewire.emit('sign', data, id); } catch (error) { console.log(error); } } </code></pre> <p>I'm trying to convert a canvas to an image with javascript and after save in mu public storage with livewire.</p>
[ { "answer_id": 74473958, "author": "Wiktor Stribiżew", "author_id": 3832970, "author_profile": "https://Stackoverflow.com/users/3832970", "pm_score": 2, "selected": true, "text": "/^(?=[^a-zA-Z0-9]*[a-zA-Z0-9])[a-zA-Z0-9 !@#$%^&*()_~.+,/\\\" -]+$/\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" }, { "answer_id": 74477030, "author": "zer00ne", "author_id": 2813224, "author_profile": "https://Stackoverflow.com/users/2813224", "pm_score": 0, "selected": false, "text": "[a-zA-Z0-9]" }, { "answer_id": 74493739, "author": "Van Minh Nhon TRUONG", "author_id": 4970104, "author_profile": "https://Stackoverflow.com/users/4970104", "pm_score": 0, "selected": false, "text": "_" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74473985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15151656/" ]
74,474,006
<p>We have many old selects like this:</p> <pre><code>SELECT tm.&quot;ID&quot;,tm.&quot;R_PERSONES&quot;,tm.&quot;R_DATASOURCE&quot;, ,tm.&quot;MATCHCODE&quot;, d.NAME AS DATASOURCE, p.PDID FROM TABLE_MAPPINGS tm, PERSONES p, DATASOURCES d, (select ID from TABLE_MAPPINGS where (R_PERSONES, MATCHCODE) in (select R_PERSONES, MATCHCODE from TABLE_MAPPINGS where id in (select max(id) from TABLE_MAPPINGS group by MATCHCODE) ) ) tm2 WHERE tm.R_PERSONES = p.ID AND tm.R_DATASOURCE=d.ID and tm2.id = tm.id; </code></pre> <p>These are large tables, and queries take a long time. How to rebuild them?</p> <p>Thank you</p>
[ { "answer_id": 74474177, "author": "Littlefoot", "author_id": 9097906, "author_profile": "https://Stackoverflow.com/users/9097906", "pm_score": 1, "selected": false, "text": "table_mappings" }, { "answer_id": 74474550, "author": "MT0", "author_id": 1509264, "author_profile": "https://Stackoverflow.com/users/1509264", "pm_score": 3, "selected": true, "text": "SELECT *\nFROM (\n SELECT m.*,\n COUNT(CASE WHEN rnk = 1 THEN 1 END)\n OVER (PARTITION BY r_persones, matchcode) AS has_max_id\n FROM (\n SELECT tm.ID,\n tm.R_PERSONES,\n tm.R_DATASOURCE,\n tm.MATCHCODE,\n d.NAME AS DATASOURCE,\n p.PDID,\n RANK() OVER (PARTITION BY tm.matchcode ORDER BY tm.id DESC) As rnk\n FROM TABLE_MAPPINGS tm\n INNER JOIN PERSONES p ON tm.R_PERSONES = p.ID\n INNER JOIN DATASOURCES d ON tm.R_DATASOURCE = d.ID\n ) m\n)\nWHERE has_max_id > 0;\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7422619/" ]
74,474,014
<p>I'm creating an e-commerce website where I show 3 options &quot;body lotion&quot;, &quot;body wash&quot; and &quot;body scrub&quot; the customer can click on any of these options, and the respective product shows up.</p> <p>I have the products stored in the &quot;U20Arr&quot; and a &quot;type&quot; object key specifying whether it's of type body lotion or body wash or a body scrub</p> <p>can somebody please help me on how do I filter out the products based on the category /type</p> <p>the code of the same where at present I'm displaying all the products</p> <pre><code>import React from 'react' import u20bg from &quot;../assets/u20bg.png&quot;; import &quot;../styles/Under20.css&quot;; import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbSeparator, } from '@chakra-ui/react' import { ChevronRightIcon } from '@chakra-ui/icons'; import { Link } from 'react-router-dom'; import filterBtn from &quot;../assets/filterBtn.png&quot;; import sortBtn from &quot;../assets/sortBtn.png&quot; import { useState } from 'react'; const Under20 = () =&gt; { const [filter, SetFilter] = useState(false); const [sort, SetSort] = useState(false); const filterShowHandler = () =&gt; { SetFilter(!filter) } const toggleSortHandler = () =&gt; { SetSort(!sort) } var u20arr = [ // body wash { id: &quot;43&quot;, name: &quot;NATURAL LEMON BODY WASH&quot;, price: 18, type: &quot;bodywash&quot;, primaryImage: &quot;https://cdn.shopify.com/s/files/1/0081/7374/8305/products/NB_ScalpScrub200mlTube_200mL_02_large.jpg?v=1654006879&quot;, hoverImg: &quot;https://cdn.shopify.com/s/files/1/0081/7374/8305/products/NO_Lists_for_Site-SIG_3ec6e6c0-aee5-483d-a6c9-e4abab736fd7_large.png?v=1654006879&quot;, stars: 4, descr: &quot;Our Scalp Scrub removes product build up and impurities with a refreshing blend of Peppermint &amp; Ginger Extract. &quot; }, { id: &quot;44&quot;, name: &quot;NATURAL STRAWBERRY BODY WASH&quot;, price: 15, type: &quot;bodywash&quot;, primaryImage: &quot;https://cdn.shopify.com/s/files/1/0081/7374/8305/products/NB_Leave-InConditioner_250ml_02_large.jpg?v=1654006878&quot;, hoverImg: &quot;https://cdn.shopify.com/s/files/1/0081/7374/8305/products/NaturalBalance_7be6d9d2-0387-44f2-9949-b03a344fc044_large.jpg?v=1654006878&quot;, stars: 5, descr: &quot;Our Scalp Scrub removes product build up and impurities with a refreshing blend of Peppermint &amp; Ginger Extract. &quot; }, { id: &quot;45&quot;, name: &quot;NATURAL STRAWBERRY BODY WASH&quot;, price: 11, type: &quot;bodywash&quot;, primaryImage: &quot;https://cdn.shopify.com/s/files/1/0081/7374/8305/products/TravelPack2019_large.jpg?v=1652797301&quot;, hoverImg: &quot;https://cdn.shopify.com/s/files/1/0081/7374/8305/products/TravelPack2019_large.jpg?v=1652797301&quot;, stars: 5, descr: &quot;Our Scalp Scrub removes product build up and impurities with a refreshing blend of Peppermint &amp; Ginger Extract. &quot; }, // body loption { id: &quot;46&quot;, name: &quot;NATURAL BLUEBERRY BODY LOTION&quot;, price: 15, type: &quot;bodyLotion&quot;, primaryImage: &quot;https://cdn.shopify.com/s/files/1/0081/7374/8305/products/CreamyBodyWash500ml_large.jpg?v=1649168513&quot;, hoverImg: &quot;https://cdn.shopify.com/s/files/1/0081/7374/8305/products/CreamyBodyFinal_large.jpg?v=1649168513&quot;, stars: 5, descr: &quot;Our Scalp Scrub removes product build up and impurities with a refreshing blend of Peppermint &amp; Ginger Extract. &quot; }, { id: &quot;47&quot;, name: &quot;NATURAL KIWI BODY LOTION&quot;, price: 19, type: &quot;bodyLotion&quot;, primaryImage: &quot;https://cdn.shopify.com/s/files/1/0081/7374/8305/products/Biomarine_Facial_Serum_02_FOR_WEB_large.jpg?v=1646144556&quot;, hoverImg: &quot;https://cdn.shopify.com/s/files/1/0081/7374/8305/products/MicrosoftTeams-image_5_-SMALL_large.jpg?v=1646144556&quot;, stars: 5, descr: &quot;Our Scalp Scrub removes product build up and impurities with a refreshing blend of Peppermint &amp; Ginger Extract. &quot; }, { id: &quot;48&quot;, name: &quot;NATURAL AVACODA BODY LOTION&quot;, price: 14, type: &quot;bodyLotion&quot;, primaryImage: &quot;https://cdn.shopify.com/s/files/1/0081/7374/8305/products/Hydra_Eye_Gel_15ml_Tube_02_FOR_WEB_large.jpg?v=1646144555&quot;, hoverImg: &quot;https://cdn.shopify.com/s/files/1/0081/7374/8305/products/MicrosoftTeams-image_5_-SMALL_533a775e-6e81-48de-bafa-6250300a0219_large.jpg?v=1646144555&quot;, stars: 5, descr: &quot;Our Scalp Scrub removes product build up and impurities with a refreshing blend of Peppermint &amp; Ginger Extract. &quot; }, //// bodyScrub { id: &quot;49&quot;, name: &quot;EXFOLIATING JELLY SCRUB&quot;, price: 19, type: &quot;bodyScrub&quot;, primaryImage: &quot;https://cdn.shopify.com/s/files/1/0081/7374/8305/products/Brightening_JellyExfoliator125ml_02_large.jpg?v=1629210220&quot;, hoverImg: &quot;https://cdn.shopify.com/s/files/1/0081/7374/8305/products/NO_Lists_for_Site_BRIGHTENING_451cbd3f-1e8b-446a-a45e-61cc31826f69_large.jpg?v=1629210220&quot;, stars: 5, descr: &quot;Our Scalp Scrub removes product build up and impurities with a refreshing blend of Peppermint &amp; Ginger Extract. &quot; }, { id: &quot;50&quot;, name: &quot;EXFOLIATING APPPLE SCRUB&quot;, price: 9, type: &quot;bodyScrub&quot;, primaryImage: &quot;https://cdn.shopify.com/s/files/1/0081/7374/8305/products/Brightening_IlluminatingMoisturiser60ml_02_large.jpg?v=1629210218&quot;, hoverImg: &quot;https://cdn.shopify.com/s/files/1/0081/7374/8305/products/NO_Lists_for_Site_BRIGHTENING_cf1ff5a7-5a32-4bb0-a7ce-be69ccc9fcf0_large.jpg?v=1629210219&quot;, stars: 5, descr: &quot;Our Scalp Scrub removes product build up and impurities with a refreshing blend of Peppermint &amp; Ginger Extract. &quot; }, { id: &quot;51&quot;, name: &quot;EXFOLIATING KIWI SCRUB&quot;, price: 16, type: &quot;bodyScrub&quot;, primaryImage: &quot;https://cdn.shopify.com/s/files/1/0081/7374/8305/products/Bergamot_PachouliBodyWash500mL1000x1000x144_large.jpg?v=1637072534&quot;, hoverImg: &quot;https://cdn.shopify.com/s/files/1/0081/7374/8305/products/Bergamot_PachouliBodyWashpumpLifestyle1000x1000x144_large.jpg?v=1637072534&quot;, stars: 5, descr: &quot;Our Scalp Scrub removes product build up and impurities with a refreshing blend of Peppermint &amp; Ginger Extract. &quot; }, ] return ( &lt;div className='u20MainParent'&gt; &lt;p className=' bg-white z-50 relative w100vw'&gt; &lt;/p&gt; &lt;div className='u20Hold'&gt; &lt;img src={u20bg} className=&quot;u20Pic&quot; /&gt; &lt;/div&gt; &lt;div className='u20HeadingHold gap-20 justify-center relative flex flex-col'&gt; &lt;p className='u20Heading'&gt; Under $20 &lt;/p&gt; &lt;p className='u20Desc'&gt; Shop Sukin natural and vegan collection of skincare and hair care gifts under $20.&lt;/p&gt; &lt;/div&gt; &lt;div className='u20BreadCrumbHold absolute text-sm'&gt; &lt;Breadcrumb spacing='8px' separator={&lt;ChevronRightIcon /&gt;}&gt; &lt;BreadcrumbItem&gt; &lt;Link to={`/`}&gt;Home&lt;/Link&gt; &lt;/BreadcrumbItem&gt; &lt;BreadcrumbItem&gt; &lt;Link to={`/`}&gt;Under 20&lt;/Link&gt; &lt;/BreadcrumbItem&gt; &lt;/Breadcrumb&gt; &lt;/div&gt; &lt;div className='filterSortHold flex flex-row gap-8 absolute text-left'&gt; &lt;img src={filterBtn} className=&quot; w-36 cursor-pointer scale&quot; onClick={filterShowHandler} /&gt; &lt;img src={sortBtn} className=&quot; w-36 cursor-pointer scale&quot; onClick={toggleSortHandler} /&gt; &lt;/div&gt; &lt;div className='filterOptionsHold relative'&gt; {filter &amp;&amp; &lt;div className='flex rounded-xl gap-8 flex-col boxSh fof absolute '&gt; &lt;p className='ml-10 cursor-pointer'&gt; Body Lotion&lt;/p&gt; &lt;p className='ml-10 cursor-pointer'&gt; Body Scrub &lt;/p&gt; &lt;p className='ml-10 cursor-pointer text-white' &gt; Body Wash &lt;/p&gt; &lt;/div&gt;} &lt;/div&gt; &lt;div&gt; &lt;div className='sortOptionsHold relative'&gt; {sort &amp;&amp; &lt;div className='flex rounded-xl flex-col gap-7 boxSh2 fof absolute'&gt; &lt;p className='ml-20 cursor-pointer'&gt; A - Z &lt;/p&gt; &lt;p className='ml-20 cursor-pointer'&gt; Z - A &lt;/p&gt; &lt;p className='ml-10 cursor-pointer'&gt; LOW TO HIGH &lt;/p&gt; &lt;p className='ml-10 cursor-pointer text-white'&gt; HIGH TO LOW &lt;/p&gt; &lt;/div&gt;} &lt;/div&gt; &lt;/div&gt; &lt;div className='flex gap-20 flex-wrap relative top-96 justify-center text-center'&gt; {u20arr.map((item) =&gt; { return (&lt;div key={item.id}&gt; &lt;img src={item.primaryImage} className=&quot;w-32&quot; /&gt; &lt;p&gt; ${item.price} &lt;/p&gt; &lt;/div&gt;) })} &lt;/div&gt; &lt;/div &gt; ) } export default Under20 </code></pre>
[ { "answer_id": 74474065, "author": "owenizedd", "author_id": 7146064, "author_profile": "https://Stackoverflow.com/users/7146064", "pm_score": 2, "selected": true, "text": "filter" }, { "answer_id": 74474175, "author": "Pompedup", "author_id": 12239272, "author_profile": "https://Stackoverflow.com/users/12239272", "pm_score": 0, "selected": false, "text": "// useMemo will avoid filtering it several times\nconst u20GroupedByType = useMemo(() => u20arr\n .reduce((acc, current) => {\n // ||= set the value only if acc[current.type] is not defined\n acc[current.type] ||= []\n acc[current.type].push(current)\n return acc\n }, {}), [u20arr])\n" }, { "answer_id": 74474439, "author": "Redemption Jonathan", "author_id": 18009477, "author_profile": "https://Stackoverflow.com/users/18009477", "pm_score": 1, "selected": false, "text": "useMemo" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19768549/" ]
74,474,022
<p>I have a data frame that looks like this:</p> <pre><code> Vendor GRDate Pass/Fail 0 204177 2022-22 1.0 1 204177 2022-22 0.0 2 204177 2022-22 0.0 3 204177 2022-22 1.0 4 204177 2022-22 1.0 5 204177 2022-22 1.0 7 201645 2022-22 0.0 8 201645 2022-22 0.0 9 201645 2022-22 1.0 10 201645 2022-22 1.0 </code></pre> <p>I am trying to work out the percentage of where Pass/Fail equals 1 for each week for each vendor and put it in a new df (Number of pass = 1 / total number of lines per vendor &amp; week)</p> <p>which would look like this:</p> <pre><code> Vendor GRDate Performance 0 204177 2022-22 0.6 1 201645 2022-22 0.5 </code></pre> <p>I'm trying to do this with <code>.groupby()</code> and <code>.count()</code> but i can't work out how to get this into a new df along with the Vendor and GRDate columns. The code I have here returns the percentage of pass fail but drops the other two columns.</p> <pre><code>sdp_percent = sdp.groupby(['GRDate','Vendor'])['Pass/Fail'].apply(lambda x: x[x == 1].count()) / sdp.groupby(['GRDate','Vendor'])['Pass/Fail'].count() </code></pre> <p>But then if I add <code>.reset_index()</code> to keep them I get this error: unsupported operand type(s) for /: 'str' and 'str'</p> <p>Please can someone explain what i'm doing wrong?</p>
[ { "answer_id": 74474065, "author": "owenizedd", "author_id": 7146064, "author_profile": "https://Stackoverflow.com/users/7146064", "pm_score": 2, "selected": true, "text": "filter" }, { "answer_id": 74474175, "author": "Pompedup", "author_id": 12239272, "author_profile": "https://Stackoverflow.com/users/12239272", "pm_score": 0, "selected": false, "text": "// useMemo will avoid filtering it several times\nconst u20GroupedByType = useMemo(() => u20arr\n .reduce((acc, current) => {\n // ||= set the value only if acc[current.type] is not defined\n acc[current.type] ||= []\n acc[current.type].push(current)\n return acc\n }, {}), [u20arr])\n" }, { "answer_id": 74474439, "author": "Redemption Jonathan", "author_id": 18009477, "author_profile": "https://Stackoverflow.com/users/18009477", "pm_score": 1, "selected": false, "text": "useMemo" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13123654/" ]
74,474,023
<p>But I am wondering how to initialize char *** in c.<br /> initialize char* :</p> <pre><code>char *test = &quot;hello&quot;; printf(&quot;tets[0]=%s\n&quot;,test); </code></pre> <p>The following is initialize char **.</p> <pre><code>char **test = (char *[]) {&quot;hello&quot;, &quot;world&quot;}; printf(&quot;tets[1]=%s\n&quot;,test[1]); </code></pre> <p>So far I tried to initialize char ***:</p> <pre><code>// char ***test = (*(char *[])) {{&quot;hello&quot;}, {&quot;world&quot;}}; //char ***test = ((char **)[]) {{&quot;hello&quot;}, {&quot;world&quot;}}; </code></pre> <p>Intended to achieve, initialize a char*** using text string literal. Then i can use <code>printf(&quot;tets[1]=%s\n&quot;,(*test)[1])</code> to print out <code>world</code>.</p>
[ { "answer_id": 74474644, "author": "Andreas Wenzel", "author_id": 12149471, "author_profile": "https://Stackoverflow.com/users/12149471", "pm_score": 3, "selected": true, "text": "char**" }, { "answer_id": 74475277, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 1, "selected": false, "text": "char *test = \"hello\";\nprintf(\"tets[0]=%s\\n\",test);\n\nchar **test1 = (char *[]) {\"hello\", \"world\"};\n printf(\"tets[1]=%s\\n\",test1[1]);\n\nchar ***test2 = (char **[]){(char *[]) {\"hello\", \"world\"}, (char *[]) {\"something\", \"else\"}};\n printf(\"tets[1]=%s\\n\",test2[1][1]);\n\nchar **elem1 = (char *[]) {\"hello\", \"world\"};\nchar **elem2 = (char *[]) {\"something\", \"else\"};\n\nchar ***test3 = (char **[]){elem1, elem2};\n printf(\"tets[1]=%s\\n\",test2[1][0]);\n\n/* --- or **** */\n\nchar ****test4 = (char ***[]){ (char **[]){(char *[]) {\"hello\", \"world\"}, (char *[]) {\"something\", \"else\"}}, \n (char **[]){(char *[]) {\"four\", \"pointer\"}, (char *[]) {\"programmer\", \"king\"}}};\n printf(\"tets[1]=%s\\n\",test4[1][1][0]);\n\n" }, { "answer_id": 74475678, "author": "Lundin", "author_id": 584518, "author_profile": "https://Stackoverflow.com/users/584518", "pm_score": 1, "selected": false, "text": "char***" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15603477/" ]
74,474,030
<p>may someone help me on this? I want to transpose the following data but in my trasnpose code exist errors;</p> <p>my code is ;</p> <pre><code>proc transpose data=a out=b delimeter=_; by k m; id variable3 variable4 var variable 5; run; </code></pre> <p>my dataset is;</p> <pre><code>variable1 variable2 variable3 variable4 variable5 k m eye eye1 weak not related 1 1 1 eye eye1 weak not related subj1 2 1 inf inf1 weak not related 2 1 2 inf inf1 weak not related subj2 2 2 inf inf1 weak not related subj1 2 2 inf inf2 mod not related 1 2 2 inf inf2 mod not related subj1 3 2 </code></pre> <p>and I want to be</p> <pre><code>variable1 variable2 weak_not_related mod_not_related eye eye1 1 eye eye1 subj1 inf inf1 2 inf inf1 subj2 inf inf1 subj1 inf inf2 1 inf inf2 subj1 </code></pre> <p>Many thanks,</p>
[ { "answer_id": 74474644, "author": "Andreas Wenzel", "author_id": 12149471, "author_profile": "https://Stackoverflow.com/users/12149471", "pm_score": 3, "selected": true, "text": "char**" }, { "answer_id": 74475277, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 1, "selected": false, "text": "char *test = \"hello\";\nprintf(\"tets[0]=%s\\n\",test);\n\nchar **test1 = (char *[]) {\"hello\", \"world\"};\n printf(\"tets[1]=%s\\n\",test1[1]);\n\nchar ***test2 = (char **[]){(char *[]) {\"hello\", \"world\"}, (char *[]) {\"something\", \"else\"}};\n printf(\"tets[1]=%s\\n\",test2[1][1]);\n\nchar **elem1 = (char *[]) {\"hello\", \"world\"};\nchar **elem2 = (char *[]) {\"something\", \"else\"};\n\nchar ***test3 = (char **[]){elem1, elem2};\n printf(\"tets[1]=%s\\n\",test2[1][0]);\n\n/* --- or **** */\n\nchar ****test4 = (char ***[]){ (char **[]){(char *[]) {\"hello\", \"world\"}, (char *[]) {\"something\", \"else\"}}, \n (char **[]){(char *[]) {\"four\", \"pointer\"}, (char *[]) {\"programmer\", \"king\"}}};\n printf(\"tets[1]=%s\\n\",test4[1][1][0]);\n\n" }, { "answer_id": 74475678, "author": "Lundin", "author_id": 584518, "author_profile": "https://Stackoverflow.com/users/584518", "pm_score": 1, "selected": false, "text": "char***" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20238328/" ]
74,474,036
<pre><code>TextFormField( inputFormatters: [ FilteringTextInputFormatter.deny(RegExp('[a-zA-Z]')), FilteringTextInputFormatter.allow(RegExp('[0-9]')), ], maxLength: 2, controller: controller, ), ), </code></pre> <p>I want to prevent the user from entering a number greater than 12 in the TextFormField. It can only write numbers between 1-12(including 12).</p>
[ { "answer_id": 74474460, "author": "Ivo", "author_id": 1514861, "author_profile": "https://Stackoverflow.com/users/1514861", "pm_score": 2, "selected": true, "text": "TextFormField(\n inputFormatters: [\n TextInputFormatter.withFunction((oldValue, newValue) {\n if (newValue.text == '') return newValue;\n final i = int.tryParse(newValue.text);\n if (i == null) return oldValue;\n if (i > 12) return newValue.copyWith(text: '12', selection: const TextSelection.collapsed(offset: 2));\n return newValue;\n })\n ],\n maxLength: 2,\n)\n" }, { "answer_id": 74474541, "author": "Zhar", "author_id": 2326640, "author_profile": "https://Stackoverflow.com/users/2326640", "pm_score": 1, "selected": false, "text": " class LimitRangeTextInputFormatter extends TextInputFormatter {\n LimitRangeTextInputFormatter(this.min, this.max, {this.defaultIfEmpty = false}) : assert(min < max);\n\n final int min;\n final int max;\n final bool defaultIfEmpty;\n\n @override\n TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {\n int? value = int.tryParse(newValue.text);\n String? enforceValue;\n if(value != null) {\n if (value < min) {\n enforceValue = min.toString();\n } else if (value > max) {\n enforceValue = max.toString();\n }\n }\n else{\n if(defaultIfEmpty) {\n enforceValue = min.toString();\n }\n }\n // filtered interval result\n if(enforceValue != null){\n return TextEditingValue(text: enforceValue, selection: TextSelection.collapsed(offset: enforceValue.length));\n }\n // value that fit requirements\n return newValue;\n }\n}\n" }, { "answer_id": 74474608, "author": "Hemali Vekariya", "author_id": 15863739, "author_profile": "https://Stackoverflow.com/users/15863739", "pm_score": 1, "selected": false, "text": " TextField(\n controller: textEditingEventController,\n inputFormatters: [\n FilteringTextInputFormatter.deny(RegExp('[a-zA-Z]')),\n FilteringTextInputFormatter.allow(RegExp('[0-9]')),\n ],\n onChanged: (val) {\n if (int.parse(((val.isEmpty) ? '00' : (val))) > 60) {\n textEditingEventController.text = '12';\n }\n textEditingEventController.value = TextEditingValue(\n text: textEditingEventController.text,\n selection: TextSelection.fromPosition(\n TextPosition(\n offset: textEditingEventController\n .value.selection.baseOffset),\n ),\n );\n textEditingEventController.selection =\n TextSelection.fromPosition(TextPosition(\n offset:\n textEditingEventController.text.length));\n },\n ),\n" }, { "answer_id": 74474614, "author": "noxgood", "author_id": 20003715, "author_profile": "https://Stackoverflow.com/users/20003715", "pm_score": 0, "selected": false, "text": "FilteringTextInputFormatter.allow(RegExp(r'^([1][0-2]?|[1-9])$'))" }, { "answer_id": 74474915, "author": "Parth Gupta", "author_id": 13101257, "author_profile": "https://Stackoverflow.com/users/13101257", "pm_score": 0, "selected": false, "text": "TextFormField(\n decoration: const InputDecoration(\n counterText: \"\",\n ),\n controller: textEditingController,\n maxLength: 2,\n )\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17906689/" ]
74,474,058
<p>I'm trying to create a nested dictionary from a list of strings. Each index of the strings corresponds to a key, while each character a value.</p> <p>I have a list:</p> <pre><code>list = ['game', 'club', 'party', 'play'] </code></pre> <p>I would like to create a (nested) dictionary:</p> <pre><code>dict = {0: {'g', 'c', 'p', 'p'}, 1: {'a', 'l', 'a', 'l'}, 2: {'m', 'u', 'r', 'a'}, etc.} </code></pre> <p>I was thinking something along the lines of:</p> <pre><code>res = {} for item in range(len(list)): for i in list[item]: if i not in res: # create a key (index - ex. '0') and a value (character - ex. 'g' of 'game') else: # put the value in the corresponding key (ex. 'c' of 'club') print(res) </code></pre>
[ { "answer_id": 74474136, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 3, "selected": true, "text": "from itertools import zip_longest\n\nlst = [\"game\", \"club\", \"party\", \"play\"]\n\nout = {\n i: [v for v in t if not v is None] for i, t in enumerate(zip_longest(*lst))\n}\n\nprint(out)\n" }, { "answer_id": 74474185, "author": "tobifasc", "author_id": 2633917, "author_profile": "https://Stackoverflow.com/users/2633917", "pm_score": 1, "selected": false, "text": "items = ['game', 'club', 'party', 'play']\nresult = {}\nfor item in items:\n for (idx, char) in enumerate(list(item)):\n if idx not in result:\n result[idx] = [char]\n else:\n result[idx].append(char)\nprint(result)\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3892557/" ]
74,474,067
<p>I am trying to understand closures, and I have this example below</p> <pre><code>function outerFunction(outerVariable) { return function innerFunction(innerVariable) { console.log('outer variable: ' + outerVariable) console.log('inner variable: ' + innerVariable) } } const newFunction = outerFunction('outside') newFunction('inside') </code></pre> <p>the part that I don't understand is when we assign the outerFunction function to a variable (the last two lines), then call the variable as a function passing another argument. I have no idea what happened in there.</p>
[ { "answer_id": 74474136, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 3, "selected": true, "text": "from itertools import zip_longest\n\nlst = [\"game\", \"club\", \"party\", \"play\"]\n\nout = {\n i: [v for v in t if not v is None] for i, t in enumerate(zip_longest(*lst))\n}\n\nprint(out)\n" }, { "answer_id": 74474185, "author": "tobifasc", "author_id": 2633917, "author_profile": "https://Stackoverflow.com/users/2633917", "pm_score": 1, "selected": false, "text": "items = ['game', 'club', 'party', 'play']\nresult = {}\nfor item in items:\n for (idx, char) in enumerate(list(item)):\n if idx not in result:\n result[idx] = [char]\n else:\n result[idx].append(char)\nprint(result)\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13521326/" ]
74,474,085
<p>I'm using The entity framework for creating a database with some products. Product Has a entity Named Price, i want to save all prices with two decimal places even if it's a round number.</p> <p>Like:<br /> 2 = 2.00</p> <p>5.9 = 5.90</p> <p>17.99 = 17.99</p> <p><strong>I can't use Decimal</strong></p> <p>Here is my Product:</p> <pre><code>namespace CashRegister.Models { public class Produkt { [Key] public int Id { get; set; } public string Name { get; set; } public double Preis { get; set; } public bool Preisart { get; set; } public bool Deaktiviert { get; set; } = false; public List&lt;EinkaufsPosition&gt; EinkaufsPositionen { get; set; } public int KategorieId { get; set; } public Kategorie Kategorie { get; set; } } } </code></pre> <p>Is it possible to Save it in the Database Like I Showed and How?</p>
[ { "answer_id": 74474136, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 3, "selected": true, "text": "from itertools import zip_longest\n\nlst = [\"game\", \"club\", \"party\", \"play\"]\n\nout = {\n i: [v for v in t if not v is None] for i, t in enumerate(zip_longest(*lst))\n}\n\nprint(out)\n" }, { "answer_id": 74474185, "author": "tobifasc", "author_id": 2633917, "author_profile": "https://Stackoverflow.com/users/2633917", "pm_score": 1, "selected": false, "text": "items = ['game', 'club', 'party', 'play']\nresult = {}\nfor item in items:\n for (idx, char) in enumerate(list(item)):\n if idx not in result:\n result[idx] = [char]\n else:\n result[idx].append(char)\nprint(result)\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12373301/" ]
74,474,090
<p>This YouTube <a href="https://www.youtube.com/watch?v=McZIQhZpvew" rel="nofollow noreferrer">video</a> @27:20 talks about populating the cache with routing info to avoid latency during a cold start. You can either try to get a document you know doesn't exist, or you can use <code>CosmosClient.CreateAndInitializeAsync()</code>.</p> <p>I already have this code set up:</p> <pre><code>private async Task&lt;Container&gt; CreateContainerAsync(string endpoint, string authKey) { var cosmosClientBuilder = new CosmosClientBuilder( accountEndpoint: endpoint, authKeyOrResourceToken: authKey) .WithConnectionModeDirect(portReuseMode: PortReuseMode.PrivatePortPool, idleTcpConnectionTimeout: TimeSpan.FromHours(1)) .WithApplicationName(UserAgentSuffix) .WithConsistencyLevel(ConsistencyLevel.Session) .WithApplicationRegion(Regions.AustraliaEast) .WithRequestTimeout(TimeSpan.FromSeconds(DatabaseRequestTimeoutInSeconds)) .WithThrottlingRetryOptions(TimeSpan.FromSeconds(DatabaseMaxRetryWaitTimeInSeconds), DatabaseMaxRetryAttemptsOnThrottledRequests); var client = cosmosClientBuilder.Build(); var databaseResponse = await CreateDatabaseIfNotExistsAsync(client).ConfigureAwait(false); var containerResponse = await CreateContainerIfNotExistsAsync(databaseResponse.Database).ConfigureAwait(false); return containerResponse; } </code></pre> <p>Is there any way to incorporate <code>CosmosClient.CreateAndInitializeAsync()</code> with it to populate the cache?</p> <p>If not, is it ok to do this to populate the cache?</p> <pre><code>public class CosmosClientWrapper { public CosmosClientWrapper(IKeyVaultFacade keyVaultFacade) { var container = CreateContainerAsync(endpoint, authenticationKey).GetAwaiter().GetResult(); // Get a document that doesn't exist to populate the routing info: container.ReadItemAsync&lt;object&gt;(Guid.NewGuid().ToString(), PartitionKey.None).GetAwaiter().GetResult(); } } </code></pre>
[ { "answer_id": 74474243, "author": "Gaurav Mantri", "author_id": 188096, "author_profile": "https://Stackoverflow.com/users/188096", "pm_score": 0, "selected": false, "text": "CosmosClientBuilder.BuildAndInitializeAsync" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2063755/" ]
74,474,093
<p>I want to <strong>save my console output in a text file</strong>, but I want it to be <strong>as it happens</strong> so that if the programm crashes, logs will be saved. Do you have some ideas ?</p> <p>I can't just specify file in logger because I have a lot of different loggers that are printing into the console.</p>
[ { "answer_id": 74516445, "author": "Ziur Olpa", "author_id": 10416012, "author_profile": "https://Stackoverflow.com/users/10416012", "pm_score": 2, "selected": false, "text": "import logging\nfrom pathlib import Path\n\nroot_path = <YOUR PATH>\n\nlog_level = logging.DEBUG\n\n# Print to the terminal\nlogging.root.setLevel(log_level)\nformatter = logging.Formatter(\"%(asctime)s | %(levelname)s | %(message)s\", \"%Y-%m-%d %H:%M:%S\")\nstream = logging.StreamHandler()\nstream.setLevel(log_level)\nstream.setFormatter(formatter)\nlog = logging.getLogger(\"pythonConfig\")\nif not log.hasHandlers():\n log.setLevel(log_level)\n log.addHandler(stream)\n\n# file handler:\nfile_handler = logging.FileHandler(Path(root_path / \"process.log\"), mode=\"w\")\nfile_handler.setLevel(log_level)\nfile_handler.setFormatter(formatter)\nlog.addHandler(file_handler)\n\nlog.info(\"test\")\n" }, { "answer_id": 74520966, "author": "Jib", "author_id": 20124358, "author_profile": "https://Stackoverflow.com/users/20124358", "pm_score": 2, "selected": false, "text": "python3 -u ./myscript.py 2>&1 outputfile.txt" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11147691/" ]
74,474,098
<p>I have this list:</p> <pre><code> DI bpg01001:PGE00 3:1 ------ 1 1 (No fault) DI bpg01001:VOL00 2:13 ------ 1 1 (Normal) DI dca06001:HPR00 3:12 ------ 1 1 (Normal) DI dca06001:HUH00 3:15 ------ 1 1 (Normal) DI dca06001:PWS00 3:14 ------ 1 1 (Normal) DI dca06001:UOL00 3:13 ------ 1 1 (Normal) DI rcf10001:ACO00 2:0 ------ 1 1 (Present) DI rcf10001:BDC00 2:4 ------ 1 1 (Normal) DI rcf10001:ERR00 2:2 ------ 1 1 (Normal) DI rcf10001:ERS00 2:3 ------ 1 1 (Normal) DO bpg01001:PGS00 1:4 ------ 0 0 (Stop) </code></pre> <p>My goal is to sort everything from <code>1:4</code> to <code>3:15</code> but <code>|sort -k3</code> seems to fail in terms of human readings. Any ideas?</p>
[ { "answer_id": 74516445, "author": "Ziur Olpa", "author_id": 10416012, "author_profile": "https://Stackoverflow.com/users/10416012", "pm_score": 2, "selected": false, "text": "import logging\nfrom pathlib import Path\n\nroot_path = <YOUR PATH>\n\nlog_level = logging.DEBUG\n\n# Print to the terminal\nlogging.root.setLevel(log_level)\nformatter = logging.Formatter(\"%(asctime)s | %(levelname)s | %(message)s\", \"%Y-%m-%d %H:%M:%S\")\nstream = logging.StreamHandler()\nstream.setLevel(log_level)\nstream.setFormatter(formatter)\nlog = logging.getLogger(\"pythonConfig\")\nif not log.hasHandlers():\n log.setLevel(log_level)\n log.addHandler(stream)\n\n# file handler:\nfile_handler = logging.FileHandler(Path(root_path / \"process.log\"), mode=\"w\")\nfile_handler.setLevel(log_level)\nfile_handler.setFormatter(formatter)\nlog.addHandler(file_handler)\n\nlog.info(\"test\")\n" }, { "answer_id": 74520966, "author": "Jib", "author_id": 20124358, "author_profile": "https://Stackoverflow.com/users/20124358", "pm_score": 2, "selected": false, "text": "python3 -u ./myscript.py 2>&1 outputfile.txt" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1948548/" ]
74,474,103
<p>I have two array:</p> <p>for example:</p> <pre><code>arraySelectedItems = [{id: 1, name: &quot;item1&quot;}, {id: 2, name: &quot;item2&quot;}] arraySavedItems = [{id: 1, name: &quot;item1&quot;}, {id: 2, name: &quot;item2&quot;}] </code></pre> <p>now I need to check if there is some item in arraySavedItems that is not present in arraySelectedItems, and in this case I'll go to populate another array called arrayDeletedItems.</p> <p>If the two arrays have the same items I don't need to populate the arrayDeletedItems.</p> <p>So I have tried with this code:</p> <pre><code>arraySavedItems.filter((itemSaved) =&gt; !arraySelectedItems.find((itemSel) =&gt; { if (itemSaved.id !== itemSel.id) { arrayDeletedItems.push(itemSaved) } } )) </code></pre> <p>So with this data:</p> <pre><code> arraySelectedItems = [{id: 1, name: &quot;item1&quot;}, {id: 2, name: &quot;item2&quot;}] arraySavedItems = [{id: 1, name: &quot;item1&quot;}, {id: 2, name: &quot;item2&quot;}] </code></pre> <p>I'll expect that arrayDeletedItems will be:</p> <pre><code> arrayDeletedItems = [] </code></pre> <p>Instead whit this data for example:</p> <pre><code> arraySelectedItems = [{id: 1, name: &quot;item1&quot;}] arraySavedItems = [{id: 1, name: &quot;item1&quot;}, {id: 2, name: &quot;item2&quot;}] </code></pre> <p>I'll expect that arrayDeletedItems will be:</p> <pre><code>arrayDeletedItems = [{id: 2, name: &quot;item2&quot;}] </code></pre> <p>With my code I receive and arrayDeletedItems that has the all values:</p> <pre><code>arrayDeletedItems = [{id: 1, name: &quot;item1&quot;}, {id: 2, name: &quot;item2&quot;}] </code></pre>
[ { "answer_id": 74474181, "author": "Dakeyras", "author_id": 1857909, "author_profile": "https://Stackoverflow.com/users/1857909", "pm_score": 1, "selected": false, "text": ".includes()" }, { "answer_id": 74474245, "author": "gog", "author_id": 3494774, "author_profile": "https://Stackoverflow.com/users/3494774", "pm_score": 3, "selected": true, "text": "function difference(a, b, keyFn) {\n let keys = new Set(a.map(keyFn))\n return b.filter(obj => !keys.has(keyFn(obj)))\n}\n\n\n//\n\n\nselectedItems = [{id: 1, name: \"item1\"}, {id:4}]\n\nsavedItems = [{id: 1, name: \"item1\"}, {id: 2, name: \"item2\"}, {id:3}, {id:4}]\n\nresult = difference(selectedItems, savedItems, obj => obj.id)\n\nconsole.log(result)" }, { "answer_id": 74474452, "author": "owenizedd", "author_id": 7146064, "author_profile": "https://Stackoverflow.com/users/7146064", "pm_score": 0, "selected": false, "text": "id" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11604252/" ]
74,474,115
<p>We have a web application written in React that integrates with Stripe to take payments.</p> <p>When the user accesses the Apply Pay option, the popup immediately closes before they can complete the transaction.</p> <ul> <li>The domain has been added to the Apple Pay settings on Stripe</li> <li>There are no errors or logs in the javascript console to indicate an issue.</li> <li>This is using Stripe Connect</li> <li>The same page works perfectly on Google Pay</li> </ul> <p>The page in question is publicly accessible here: <a href="https://whitecobalt.rendr.co.uk/pay?key=0tRvBe7q4E10230" rel="nofollow noreferrer">https://whitecobalt.rendr.co.uk/pay?key=0tRvBe7q4E10230</a></p> <p>I have recorded a screen-share video of the issue, which can be viewed here:</p> <p>Has anyone else experienced this or is able to point us in the right direction, we've tried everything, and we're a bit stumped!</p> <p>Thanks in advance!</p>
[ { "answer_id": 74474388, "author": "karllekko", "author_id": 9769731, "author_profile": "https://Stackoverflow.com/users/9769731", "pm_score": 2, "selected": true, "text": "acct_1M1B1IQ0dY0splyg" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1849662/" ]
74,474,119
<p>I have multiple GitHub checks. One of them is <a href="https://mergify.com" rel="nofollow noreferrer">mergify</a>. It merges the PR is all defined checks are successful. However in my case there is a different check that only starts after a minute or so, which is why mergify always misses it.</p> <p>How can I make sure that mergify starts with some delay or better that it starts as the last GitHub app</p>
[ { "answer_id": 74474388, "author": "karllekko", "author_id": 9769731, "author_profile": "https://Stackoverflow.com/users/9769731", "pm_score": 2, "selected": true, "text": "acct_1M1B1IQ0dY0splyg" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5345715/" ]
74,474,149
<p>I need the job to continue when one of the steps fails. Steps are dynamically generated and are independent.</p> <pre><code> public Step step(Long id) { return stepBuilderFactory.get(&quot;STEP_&quot; + id) .tasklet((contribution, chunkContext) -&gt; { service.action(id); return RepeatStatus.FINISHED; }).build(); } </code></pre> <p>I want to save the FAILED state if it fails but not terminate the execution. Is there a way to do it? Thanks</p>
[ { "answer_id": 74476109, "author": "Mahmoud Ben Hassine", "author_id": 5019386, "author_profile": "https://Stackoverflow.com/users/5019386", "pm_score": 1, "selected": false, "text": "@Bean\npublic Job job() {\n return jobBuilderFactory.get(\"job\")\n .start(stepA())\n .on(\"*\").to(stepB())\n .from(stepA()).on(\"FAILED\").to(stepC())\n .end()\n .build();\n}\n" }, { "answer_id": 74476826, "author": "daniel_ip", "author_id": 19939028, "author_profile": "https://Stackoverflow.com/users/19939028", "pm_score": 0, "selected": false, "text": "SimpleJobBuilder jobBuilder = this.jobBuilderFactory.get(\"JOB\").start(steps.remove(0));\n for(Step step : steps) {\n jobBuilder.next(step);\n }\nreturn jobBuilder.build();\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19939028/" ]
74,474,176
<p>In our github repository, we have a github action that calls a reusable workflow in an environment.</p> <pre><code>name: Pull Request Merged concurrency: group: ${{ github.ref }} on: pull_request: types: [closed] jobs: deploy_to_stage: if: | github.event.pull_request.merged == true &amp;&amp; contains(github.event.pull_request.labels.*.name, 'Stage') name: Deploy to Stage uses: ./.github/workflows/deploy.yml with: environment: Stage secrets: inherit </code></pre> <p>The reusable workflow is roughly as follows:</p> <pre><code>name: deploy on: workflow_call: secrets: AWS_ACCESS_KEY_ID: required: true AWS_SECRET_ACCESS_KEY: required: true jobs: deployment: runs-on: ubuntu-latest steps: [...] </code></pre> <p>How can I access the value of the environment name (here: &quot;Stage&quot;) in a step of the reusable workflow?</p>
[ { "answer_id": 74476109, "author": "Mahmoud Ben Hassine", "author_id": 5019386, "author_profile": "https://Stackoverflow.com/users/5019386", "pm_score": 1, "selected": false, "text": "@Bean\npublic Job job() {\n return jobBuilderFactory.get(\"job\")\n .start(stepA())\n .on(\"*\").to(stepB())\n .from(stepA()).on(\"FAILED\").to(stepC())\n .end()\n .build();\n}\n" }, { "answer_id": 74476826, "author": "daniel_ip", "author_id": 19939028, "author_profile": "https://Stackoverflow.com/users/19939028", "pm_score": 0, "selected": false, "text": "SimpleJobBuilder jobBuilder = this.jobBuilderFactory.get(\"JOB\").start(steps.remove(0));\n for(Step step : steps) {\n jobBuilder.next(step);\n }\nreturn jobBuilder.build();\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2792414/" ]
74,474,184
<p>I'm creating an app that sends both a refresher and access tokens; also, in this app, there are a ModelViewSet called Users (returns all users in the database) where permission_classes for the IsAuthenticated only, everything seems to work perfectly.</p> <p>But when the access token expires and sets the header for the Authentication = 'Bearer ${access_token},' the ModelView returns the data despite the expiration of the access_token, and checks the same token with the TokenVerifyView, its returns:</p> <pre class="lang-json prettyprint-override"><code>{ &quot;detail&quot;: &quot;Token is invalid or expired&quot;, &quot;code&quot;: &quot;token_not_valid&quot; } </code></pre> <p>I'm using rest_framework and rest_framework_simplejwt the ACCESS_TOKEN_LIFETIME equal to 10sec and the DEFAULT_AUTHENTICATION_CLASSES are the default from the lib itself</p> <pre class="lang-py prettyprint-override"><code>class UserViewSet(ModelViewSet): permission_classes = [permissions.IsAuthenticated,] queryset = User.objects.all() serializer_class = UserSerializer </code></pre> <pre class="lang-py prettyprint-override"><code>REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework_simplejwt.authentication.JWTAuthentication', ) } SIMPLE_JWT = { 'ACCESS_TOKEN_LIFETIME': timedelta(seconds=10), 'REFRESH_TOKEN_LIFETIME': timedelta(days=1), 'ROTATE_REFRESH_TOKENS': False, 'BLACKLIST_AFTER_ROTATION': False, 'UPDATE_LAST_LOGIN': False, 'ALGORITHM': 'HS256', 'SIGNING_KEY': SECRET_KEY, 'VERIFYING_KEY': None, 'AUDIENCE': None, 'ISSUER': None, 'JWK_URL': None, 'LEEWAY': 0, 'AUTH_HEADER_TYPES': ('Bearer',), 'AUTH_HEADER_NAME': 'HTTP_AUTHORIZATION', 'USER_ID_FIELD': 'id', 'USER_ID_CLAIM': 'user_id', 'USER_AUTHENTICATION_RULE': 'rest_framework_simplejwt.authentication.default_user_authentication_rule', 'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',), 'TOKEN_TYPE_CLAIM': 'token_type', 'TOKEN_USER_CLASS': 'rest_framework_simplejwt.models.TokenUser', 'JTI_CLAIM': 'jti', 'SLIDING_TOKEN_REFRESH_EXP_CLAIM': 'refresh_exp', 'SLIDING_TOKEN_LIFETIME': timedelta(minutes=5), 'SLIDING_TOKEN_REFRESH_LIFETIME': timedelta(days=1), } </code></pre> <p>Should I create an authentication class and add it to the DEFAULT_AUTHENTICATION_CLASSES, or is there a predefined way to handle this problem, so if the token is expired, return status with 403</p>
[ { "answer_id": 74474829, "author": "atf98", "author_id": 9807497, "author_profile": "https://Stackoverflow.com/users/9807497", "pm_score": 0, "selected": false, "text": "DEFAULT_AUTHENTICATION_CLASSES" }, { "answer_id": 74557930, "author": "Mahammadhusain kadiwala", "author_id": 19205926, "author_profile": "https://Stackoverflow.com/users/19205926", "pm_score": 0, "selected": false, "text": "DEFAULT_AUTHENTICATION_CLASSES" }, { "answer_id": 74572866, "author": "NeX'T'iME", "author_id": 8327421, "author_profile": "https://Stackoverflow.com/users/8327421", "pm_score": 2, "selected": true, "text": "djangorestframework-simplejwt" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8327421/" ]
74,474,194
<p>I have the next component in my react application:</p> <pre><code>import &quot;./styles.css&quot;; type InpuType = &quot;input&quot; | &quot;textarea&quot;; interface IContainer { name: string; placeholder: string; as: InpuType; } const Container = ({ name, placeholder, as, ...rest }: IContainer &amp; ( | React.TextareaHTMLAttributes&lt;HTMLTextAreaElement&gt; | React.InputHTMLAttributes&lt;HTMLInputElement&gt; )) =&gt; { const Comp = as || &quot;input&quot;; return &lt;Comp name={name} placeholder={placeholder} {...rest} /&gt;; }; export default function App() { return ( &lt;div className=&quot;App&quot;&gt; &lt;Container name=&quot;hi&quot; as=&quot;textarea&quot; placeholder=&quot;start&quot; /&gt; &lt;/div&gt; ); } </code></pre> <p>The <code>...rest</code> are all the default props that could be added for a <code>textarea</code> or <code>input</code>.<br> I have a typescript issue here <code>&lt;Comp name={name} ...</code>, hovering over the component i get this message:</p> <pre><code>Type '{ autoComplete?: string | undefined; autoFocus?: boolean | undefined; cols?: number | undefined; dirName?: string | undefined; disabled?: boolean | undefined; form?: string | undefined; ... 261 more ...; placeholder: string; } | { ...; }' is not assignable to type 'IntrinsicAttributes &amp; ClassAttributes&lt;HTMLInputElement&gt; &amp; InputHTMLAttributes&lt;HTMLInputElement&gt; &amp; ClassAttributes&lt;...&gt; &amp; TextareaHTMLAttributes&lt;...&gt;'. </code></pre> <p>and i am not sure how to get rid of that. <br> Question: Why the issue appear and how to solve it? <br> demo:<a href="https://codesandbox.io/s/react-typescript-forked-z6dk4i?file=/src/App.tsx:379-396" rel="nofollow noreferrer">https://codesandbox.io/s/react-typescript-forked-z6dk4i?file=/src/App.tsx:379-396</a></p>
[ { "answer_id": 74474829, "author": "atf98", "author_id": 9807497, "author_profile": "https://Stackoverflow.com/users/9807497", "pm_score": 0, "selected": false, "text": "DEFAULT_AUTHENTICATION_CLASSES" }, { "answer_id": 74557930, "author": "Mahammadhusain kadiwala", "author_id": 19205926, "author_profile": "https://Stackoverflow.com/users/19205926", "pm_score": 0, "selected": false, "text": "DEFAULT_AUTHENTICATION_CLASSES" }, { "answer_id": 74572866, "author": "NeX'T'iME", "author_id": 8327421, "author_profile": "https://Stackoverflow.com/users/8327421", "pm_score": 2, "selected": true, "text": "djangorestframework-simplejwt" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12540500/" ]
74,474,205
<p>I want to compare two list (one is nested) for mutual exclusivity. Problem is that this code is printing false even if they have only one element in common. I need it to print false if they have both elements in common.</p> <p>output I'm getting: <code>false true false</code></p> <p>Desired output: <code>true true false</code></p> <pre><code>... ArrayList&lt;String&gt; properties = new ArrayList&lt;&gt;(Arrays.asList(&quot;A&quot;, &quot;B&quot;)); ArrayList&lt;ArrayList&lt;String&gt; &gt; pairs = new ArrayList&lt;ArrayList&lt;String&gt; &gt;(); pairs.add(new ArrayList&lt;&gt;(Arrays.asList(&quot;A&quot;, &quot;C&quot;))); pairs.add(new ArrayList&lt;&gt;(Arrays.asList(&quot;D&quot;, &quot;C&quot;))); pairs.add(new ArrayList&lt;&gt;(Arrays.asList(&quot;A&quot;, &quot;B&quot;))); for(int i = 0; i&lt; pairs.size(); i++) { System.out.println(Collections.disjoint(properties, pairs.get(i))); } </code></pre>
[ { "answer_id": 74474562, "author": "maloomeister", "author_id": 11441011, "author_profile": "https://Stackoverflow.com/users/11441011", "pm_score": 2, "selected": true, "text": "Collections.disjoint()" }, { "answer_id": 74495182, "author": "Alexander Ivanchenko", "author_id": 17949945, "author_profile": "https://Stackoverflow.com/users/17949945", "pm_score": 0, "selected": false, "text": "Collection.containsAll()" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10482658/" ]
74,474,220
<p>I've got this DataFrame in Python using pandas:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Column 1</th> <th>Column 2</th> <th>Column 3</th> </tr> </thead> <tbody> <tr> <td>hello</td> <td>a,b,c</td> <td>1,2,3</td> </tr> <tr> <td>hi</td> <td>b,c,a</td> <td>4,5,6</td> </tr> </tbody> </table> </div> <p>The values in column 3 belong to the categories in column 2. Is there a way to combine columns 2 and 3 that I get this output?</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Column 1</th> <th>a</th> <th>b</th> <th>c</th> </tr> </thead> <tbody> <tr> <td>hello</td> <td>1</td> <td>2</td> <td>3</td> </tr> <tr> <td>hi</td> <td>6</td> <td>4</td> <td>5</td> </tr> </tbody> </table> </div> <p>Any advise will be very helpful! Thank you!</p>
[ { "answer_id": 74474367, "author": "Nuri Taş", "author_id": 19255749, "author_profile": "https://Stackoverflow.com/users/19255749", "pm_score": 2, "selected": false, "text": "pd.crosstab" }, { "answer_id": 74474509, "author": "Panda Kim", "author_id": 20430449, "author_profile": "https://Stackoverflow.com/users/20430449", "pm_score": 3, "selected": true, "text": "df.apply(lambda x: pd.Series(x['Column 3'].split(','), index=x['Column2'].split(',')), axis=1) \n" }, { "answer_id": 74475126, "author": "sammywemmy", "author_id": 7175713, "author_profile": "https://Stackoverflow.com/users/7175713", "pm_score": 1, "selected": false, "text": "from collections import defaultdict\noutcome = defaultdict(list)\nfor column, row in zip(df['Column 2'], df['Column 3']):\n column = column.split(',')\n row = row.split(',')\n for first, last in zip(column, row):\n outcome[first].append(last)\npd.DataFrame(outcome).assign(Column = df['Column 1'])\n a b c Column\n0 1 2 3 hello\n1 6 4 5 hi\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15265431/" ]
74,474,227
<p>A rather primitive question, but I can't find how to solve it:</p> <p>I have an array initiated and in this scope and I need to push an object from a JSON (which got transformed from a XML) into a data array, which collects the data in a loop and I need to only then return the response out of scope, because in the scope it is not full yet.</p> <p>How do I solve this rather primitive problem?</p> <p>My minimal example looks like this:</p> <pre><code>{ ... dataarr.push(jsonObj['soap:Envelope']['soap:Body']['ns:Response']['return']['items']); } // scope 1 ends here res.status(200).send(dataarr); // out of scope in this scope 2 the response has to be sent back to the client </code></pre> <p>I get the error because the variable is out of scope, how do I fix this though?</p> <p><strong>UPDATE 1</strong></p> <p>More code:</p> <pre><code>let dataarr = []; let payloadarr = []; ... axios(config) .then(function (response) { logger.log('info', 'POST /getdata successful from ' + req.ip); var options = { attributeNamePrefix : &quot;@_&quot;, attrNodeName: &quot;attr&quot;, //default is 'false' textNodeName : &quot;#text&quot;, ignoreAttributes : true, ignoreNameSpace : false, allowBooleanAttributes : false, parseNodeValue : true, parseAttributeValue : false, trimValues: true, cdataTagName: &quot;__cdata&quot;, //default is 'false' cdataPositionChar: &quot;\\c&quot;, parseTrueNumberOnly: false, arrayMode: false, //&quot;strict&quot; attrValueProcessor: (val, attrName) =&gt; he.decode(val, {isAttributeValue: true}),//default is a=&gt;a tagValueProcessor : (val, tagName) =&gt; he.decode(val), //default is a=&gt;a stopNodes: [&quot;parse-me-as-string&quot;] }; console.log(&quot;response.data:&quot;); console.log(response.data); if( parser.validate(response.data) === true) { //optional (it'll return an object in case it's not valid) var jsonObj = parser.parse(response.data,options); } var tObj = parser.getTraversalObj(response.data,options); var jsonObj = parser.convertToJson(tObj,options); console.log(&quot;jsonObj in parsing:&quot;); console.log(jsonObj); console.log(jsonObj['soap:Envelope']['soap:Body']['ns:getResponse']['return']['items']); dataarr.push(jsonObj['soap:Envelope']['soap:Body']['ns:getResponse']['return']['items']); console.log(&quot;dataarr getting filled:&quot;); console.log(j); console.log(dataarr); }) .catch(function (error) { logger.warn('[/getdocumentmetadata]: ', new Error(error)); //console.log(error); }); } }) .catch(function (error) { logger.warn('[GET /getdocuments]: ', new Error(error)); }); res.status(200).send(dataarr); }); </code></pre>
[ { "answer_id": 74474363, "author": "Pompedup", "author_id": 12239272, "author_profile": "https://Stackoverflow.com/users/12239272", "pm_score": 1, "selected": false, "text": "let dataarr = [] // at the top of you function\n\n...\nawait new Promise((resolve, reject) => axios(config)\n .then(function (response) {\n ...\n resolve()\n })\n .catch(function (error) {\n ...\n" }, { "answer_id": 74475384, "author": "Weedoze", "author_id": 4245446, "author_profile": "https://Stackoverflow.com/users/4245446", "pm_score": 2, "selected": true, "text": "await" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474227", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12360035/" ]
74,474,247
<p>I have a <strong>user table</strong></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>USER_ID</th> <th>FIRSTNAME</th> <th>LASTNAME</th> </tr> </thead> <tbody> <tr> <td>1000</td> <td>Tom</td> <td>Doe</td> </tr> <tr> <td>2000</td> <td>Tina</td> <td>Doe</td> </tr> <tr> <td>3000</td> <td>Michael</td> <td>Doe</td> </tr> <tr> <td>4000</td> <td>Robert</td> <td>Doe</td> </tr> </tbody> </table> </div> <p>and a table with <strong>values</strong></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>USER_ID</th> <th>VALUE</th> </tr> </thead> <tbody> <tr> <td>1000</td> <td>10</td> </tr> <tr> <td>2000</td> <td>20</td> </tr> <tr> <td>3000</td> <td>40</td> </tr> <tr> <td>4000</td> <td>20</td> </tr> <tr> <td>1000</td> <td>20</td> </tr> <tr> <td>3000</td> <td>10</td> </tr> <tr> <td>4000</td> <td>30</td> </tr> </tbody> </table> </div> <p>Now I would like to write an SQL-statement that lists all users with the <strong>value 10</strong> and if the value is not 10 or there is none in the table, it should return a <strong>null</strong>.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>USER_ID</th> <th>FIRSTNAME</th> <th>LASTNAME</th> <th>VALUE</th> </tr> </thead> <tbody> <tr> <td>1000</td> <td>Tom</td> <td>Doe</td> <td>10</td> </tr> <tr> <td>2000</td> <td>Tina</td> <td>Doe</td> <td>null</td> </tr> <tr> <td>3000</td> <td>Michael</td> <td>Doe</td> <td>10</td> </tr> <tr> <td>4000</td> <td>Robert</td> <td>Doe</td> <td>null</td> </tr> </tbody> </table> </div> <p>How can I realize this?</p>
[ { "answer_id": 74474348, "author": "Littlefoot", "author_id": 9097906, "author_profile": "https://Stackoverflow.com/users/9097906", "pm_score": 1, "selected": false, "text": "SQL> with\n 2 tuser (user_id, firstname) as\n 3 (select 1000, 'Tom' from dual union all\n 4 select 2000, 'Tina' from dual union all\n 5 select 3000, 'Michael'from dual union all\n 6 select 4000, 'Robert' from dual\n 7 ),\n 8 tvalues (user_id, value) as\n 9 (select 1000, 10 from dual union all\n 10 select 2000, 20 from dual union all\n 11 select 3000, 40 from dual union all\n 12 select 4000, 20 from dual union all\n 13 select 1000, 20 from dual union all\n 14 select 3000, 10 from dual union all\n 15 select 4000, 30 from dual\n 16 )\n" }, { "answer_id": 74474357, "author": "Ankit Bajpai", "author_id": 3627756, "author_profile": "https://Stackoverflow.com/users/3627756", "pm_score": 1, "selected": false, "text": "SELECT U.USER_ID, U.FIRSTNAME, U.LASTNAME, V.VALUE\n FROM users U\n LEFT JOIN (SELECT USER_ID, VALUE\n FROM values\n WHERE values = 10) V ON U.USER_ID = V.USER_ID\n" }, { "answer_id": 74474443, "author": "VvdL", "author_id": 15589010, "author_profile": "https://Stackoverflow.com/users/15589010", "pm_score": 3, "selected": true, "text": "LEFT JOIN" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17634846/" ]
74,474,270
<p>I understood that std::numeric_limits::espsilon() and DBL_EPSILON should deliver the same value but are defined in different headers, limits, and cfloat. Which makes std::numeric_limits::espsilon() a c++ style way of writing and DBL_EPSILON the c style.</p> <p>My question is if there is any benefit in using std::numeric_limits::espsilon() over DBL_EPSILON in c++ project? Aside from a clean c++ coding style. Or did I understand this completely wrong?</p>
[ { "answer_id": 74474364, "author": "463035818_is_not_a_number", "author_id": 4117728, "author_profile": "https://Stackoverflow.com/users/4117728", "pm_score": 3, "selected": true, "text": "std::numeric_limits" }, { "answer_id": 74474480, "author": "Ranoiaetep", "author_id": 12861639, "author_profile": "https://Stackoverflow.com/users/12861639", "pm_score": 0, "selected": false, "text": "std::numeric_limits<T>::epsilon" }, { "answer_id": 74474622, "author": "Marek R", "author_id": 1387438, "author_profile": "https://Stackoverflow.com/users/1387438", "pm_score": 0, "selected": false, "text": "DBL_EPSILON" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2509663/" ]
74,474,271
<p>I have a log source which has the following format:</p> <pre><code>//file1.png is the filename, the parenthesis hold the filesize in bytes. // Each item is separated by a semicolon. file1.png (445b); file2.pdf (2345b); file3.jpg (343b); file4.docx (3243b); </code></pre> <p>I have this regex to split the items into a list of lists, with 0 being the filename, 1 the extension and 2 the size in bytes. This can be copied as a test:</p> <pre><code>datatable (item:string ) [ 'file1.png (445b); file2.pdf (2345b); file3.jpg (343b); file4.docx (3243b);', 'file1.src (3243b); file2.ps2 (24b); file3.jpg (300b); file4.jpg (326b);' ] | extend list = extract_all(@'([^&lt;&gt;:&quot;\/\\\|\?\*;]+)\.([a-zA-z0-9]+) \((\d+)b\);', item) </code></pre> <p>This outputs as the following:</p> <p><code>[[&quot;file1&quot;, &quot;.png&quot;, &quot;343&quot;], [&quot;file2&quot;, &quot;.pdf&quot;, &quot;232&quot;],...]</code></p> <p><strong>I want to remove items from the list if the sublist contains certain filetypes (such as .png). How would I go about doing this? KQL has no iteration features as far as I know.</strong></p> <p>I have tried using regex to exclude the queries I do not want to match. It was the following: <code>(?:^|; =?)([^&lt;&gt;:&quot;\/\\\|\?\*;]+\.(?!jpg\b|png\b)\w+ \(\d+b\))(?=;|$)</code>. Unfortunately, KQL does not support negative lookaheads.</p>
[ { "answer_id": 74474834, "author": "David דודו Markovitz", "author_id": 6336479, "author_profile": "https://Stackoverflow.com/users/6336479", "pm_score": 1, "selected": false, "text": "datatable (item:string ) [\n'file1.png (445b); file2.pdf (2345b); file3.jpg (343b); file4.docx (3243b);',\n'file1.src (3243b); file2.ps2 (24b); file3.jpg (300b); file4.jpg (326b);'\n]\n| mv-apply f = extract_all(@'([^<>:\"\\/\\\\\\|\\?\\*;]+)\\.([a-zA-z0-9]+) \\((\\d+)b\\);', item) on\n ( \n where f[1] !in~ (\"png\", \"jpg\")\n | summarize make_list(pack_array(f))\n )\n" }, { "answer_id": 74475005, "author": "David דודו Markovitz", "author_id": 6336479, "author_profile": "https://Stackoverflow.com/users/6336479", "pm_score": 1, "selected": false, "text": "datatable (item:string ) [\n'file1.png (445b); file2.pdf (2345b); file3.jpg (343b); file4.docx (3243b);',\n'file1.src (3243b); file2.ps2 (24b); file3.jpg (300b); file4.jpg (326b);'\n]\n| extend clean_item = replace_regex(item, @'([^<>:\"\\/\\\\\\|\\?\\*;]+)\\.(?i:png|jpg) \\((\\d+)b\\);', \"\")\n| extend extract_all(@'([^<>:\"\\/\\\\\\|\\?\\*;]+)\\.([a-zA-z0-9]+) \\((\\d+)b\\);', clean_item)\n" }, { "answer_id": 74483331, "author": "ChrisWue", "author_id": 220986, "author_profile": "https://Stackoverflow.com/users/220986", "pm_score": 0, "selected": false, "text": "datatable (item:string ) [\n'file1.png (445b); file2.pdf (2345b); file3.jpg (343b); file4.docx (3243b);',\n'file1.src (3243b); file2.ps2 (24b); file3.jpg (300b); file4.jpg (326b);'\n]\n| extend s=split(item, \"; \")\n| mv-expand s\n| parse s with fileName \".\" extension \" (\" fileSize \"b)\" rest\n| where extension !in (\"png\", \"jpg\")\n| extend image = bag_pack(\"fileName\", fileName, \"extension\", extension, \"fileSizeBytes\", fileSize)\n| summarize make_list(image) by item\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3901102/" ]
74,474,273
<p>I am trying to run a function which is using a featured image as my header image on my webpage I want to include the options to also allow my end user to select between using the featured image or to select a slider instead if they wish to use that page depending here is the code I have for the featured image development.</p> <pre><code>add_action('neve_before_primary', 'getPageFeaturedImage', 5); function getPageFeaturedImage() { // These two variables will only be used if set $pageTitle = get_field('page-title'); $pageSecondTitle = get_field('page_second_title'); if (has_post_thumbnail($post -&gt; ID) ) { $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post -&gt; ID ), 'single-post-thumbnail'); &lt;div class=&quot;featured-image-container&quot;&gt; &lt;img src=&quot;&lt;?php echo $image[0]; ?&gt;&quot; class=&quot;featured-image&quot;&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>This code when run is making the feadured image the main image on the page with a title container on top of it with some css which doesnt matter for this question below you will find the code I have for the slider.</p> <pre><code>function smartsliderheader() { echo '&lt;div class=&quot;smart-slider-header&quot;&gt;'; $slider = get_field(&quot;smart_slider_header&quot;); echo do_shortcode($slider); } </code></pre> <p>This on its own does what I need it to do the featured image code works and so does the slider but getting them both to run toghether and have only one of them run if the other has no options used is where I could used some help.</p> <p>Any help with this will be much apprechiated. I look forward to your questions if I have missed something out.</p>
[ { "answer_id": 74474834, "author": "David דודו Markovitz", "author_id": 6336479, "author_profile": "https://Stackoverflow.com/users/6336479", "pm_score": 1, "selected": false, "text": "datatable (item:string ) [\n'file1.png (445b); file2.pdf (2345b); file3.jpg (343b); file4.docx (3243b);',\n'file1.src (3243b); file2.ps2 (24b); file3.jpg (300b); file4.jpg (326b);'\n]\n| mv-apply f = extract_all(@'([^<>:\"\\/\\\\\\|\\?\\*;]+)\\.([a-zA-z0-9]+) \\((\\d+)b\\);', item) on\n ( \n where f[1] !in~ (\"png\", \"jpg\")\n | summarize make_list(pack_array(f))\n )\n" }, { "answer_id": 74475005, "author": "David דודו Markovitz", "author_id": 6336479, "author_profile": "https://Stackoverflow.com/users/6336479", "pm_score": 1, "selected": false, "text": "datatable (item:string ) [\n'file1.png (445b); file2.pdf (2345b); file3.jpg (343b); file4.docx (3243b);',\n'file1.src (3243b); file2.ps2 (24b); file3.jpg (300b); file4.jpg (326b);'\n]\n| extend clean_item = replace_regex(item, @'([^<>:\"\\/\\\\\\|\\?\\*;]+)\\.(?i:png|jpg) \\((\\d+)b\\);', \"\")\n| extend extract_all(@'([^<>:\"\\/\\\\\\|\\?\\*;]+)\\.([a-zA-z0-9]+) \\((\\d+)b\\);', clean_item)\n" }, { "answer_id": 74483331, "author": "ChrisWue", "author_id": 220986, "author_profile": "https://Stackoverflow.com/users/220986", "pm_score": 0, "selected": false, "text": "datatable (item:string ) [\n'file1.png (445b); file2.pdf (2345b); file3.jpg (343b); file4.docx (3243b);',\n'file1.src (3243b); file2.ps2 (24b); file3.jpg (300b); file4.jpg (326b);'\n]\n| extend s=split(item, \"; \")\n| mv-expand s\n| parse s with fileName \".\" extension \" (\" fileSize \"b)\" rest\n| where extension !in (\"png\", \"jpg\")\n| extend image = bag_pack(\"fileName\", fileName, \"extension\", extension, \"fileSizeBytes\", fileSize)\n| summarize make_list(image) by item\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18440788/" ]
74,474,308
<p>Hello ı created tableData() 2d array in named &quot;list&quot; module by getlist() function. I want to copy tableData() array to main sub. I think firstly ı have to call and run function in main sub afterwards copy. But ıdk how to do it could you help me? I hope problem is clear.</p> <pre><code>'list module Public Function getlist() Dim tableData() As String End Function 'Main Module Sub Main() Dim partlist() As String partlist() = list.tableData() ' ıdk :) End Sub </code></pre>
[ { "answer_id": 74474629, "author": "IvanSTV", "author_id": 19198860, "author_profile": "https://Stackoverflow.com/users/19198860", "pm_score": 0, "selected": false, "text": "Public tableData() As String\nPublic Function getlist()\n'any operations with array tableData() \nEnd Function\n\nSub Main()\nDim partlist() As String\npartlist() = list.tableData() ' ıdk :)\nEnd Sub\n" }, { "answer_id": 74474786, "author": "FunThomas", "author_id": 7599798, "author_profile": "https://Stackoverflow.com/users/7599798", "pm_score": 1, "selected": false, "text": "Public Function getlist() As String()\n 'any operations with array tableData() \n Dim tableData() As String\n (...)\n getlist = tableData\nEnd Function\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16704510/" ]
74,474,328
<p>I have a form where I want the user to enter their first name, last name and age</p> <p>But before anything, I want the user to not be able to leave the text boxes empty The problem I have is to get the age, my data must be of type int, but I don't know how the age text box is empty and gives an error to the user.</p> <pre><code>string firstName = tbxName.Text; string lastName = tbxFamily.Text; int age = Convert.ToInt32(tbxAge.Text); if (string.IsNullOrEmpty(tbxName.Text)) { MessageBox.Show(&quot;لطفا نام کاربری خود را وارد کنید&quot;); }else if (string.IsNullOrEmpty(tbxFamily.Text)) { MessageBox.Show(&quot;لطفا نام خانوادگی خود را وارد کنید&quot;); }else if (!string.IsNullOrEmpty(tbxAge.Text)) { MessageBox.Show(&quot;لطفا سن خود را بررسی کنید&quot;); }else { MessageBox.Show(&quot; نام کاربری &quot; + firstName + &quot; نام خانوادگی &quot; + lastName + &quot; با سن &quot; + age + &quot; با موفقیت ثبت شد &quot;); } </code></pre>
[ { "answer_id": 74474629, "author": "IvanSTV", "author_id": 19198860, "author_profile": "https://Stackoverflow.com/users/19198860", "pm_score": 0, "selected": false, "text": "Public tableData() As String\nPublic Function getlist()\n'any operations with array tableData() \nEnd Function\n\nSub Main()\nDim partlist() As String\npartlist() = list.tableData() ' ıdk :)\nEnd Sub\n" }, { "answer_id": 74474786, "author": "FunThomas", "author_id": 7599798, "author_profile": "https://Stackoverflow.com/users/7599798", "pm_score": 1, "selected": false, "text": "Public Function getlist() As String()\n 'any operations with array tableData() \n Dim tableData() As String\n (...)\n getlist = tableData\nEnd Function\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14348692/" ]
74,474,329
<p>I've got a column which I am trying to clean, the data is like this:</p> <p><a href="https://i.stack.imgur.com/cPk9h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cPk9h.png" alt="enter image description here" /></a></p> <p>Wherever the pattern is of x-y year, I want to extract only the 'x' value and leave it in the string. For any other value, I want to keep it as is.</p> <p>Using str.extract('(.{,2}(-))') is returning a NaN value for all the other rows.</p>
[ { "answer_id": 74474629, "author": "IvanSTV", "author_id": 19198860, "author_profile": "https://Stackoverflow.com/users/19198860", "pm_score": 0, "selected": false, "text": "Public tableData() As String\nPublic Function getlist()\n'any operations with array tableData() \nEnd Function\n\nSub Main()\nDim partlist() As String\npartlist() = list.tableData() ' ıdk :)\nEnd Sub\n" }, { "answer_id": 74474786, "author": "FunThomas", "author_id": 7599798, "author_profile": "https://Stackoverflow.com/users/7599798", "pm_score": 1, "selected": false, "text": "Public Function getlist() As String()\n 'any operations with array tableData() \n Dim tableData() As String\n (...)\n getlist = tableData\nEnd Function\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9056381/" ]
74,474,346
<p>Can anyone help to capture the both int and float vaules using reg expression</p> <p>I have below reg exp which will capture only int values but need to modify this for foot value also</p> <pre><code>'^[[:space:]]*([[:digit:]]+)[[:space:]]*([kmg])b?[[:space:]]*$' </code></pre> <p>This works if the value is eg <code>23 MB</code> but failing for <code>23.789 MB</code>.</p> <pre><code>'^[[:space:]]*([[:digit:].]+)[[:space:]]*([kmg])b?[[:space:]]*$' </code></pre>
[ { "answer_id": 74474629, "author": "IvanSTV", "author_id": 19198860, "author_profile": "https://Stackoverflow.com/users/19198860", "pm_score": 0, "selected": false, "text": "Public tableData() As String\nPublic Function getlist()\n'any operations with array tableData() \nEnd Function\n\nSub Main()\nDim partlist() As String\npartlist() = list.tableData() ' ıdk :)\nEnd Sub\n" }, { "answer_id": 74474786, "author": "FunThomas", "author_id": 7599798, "author_profile": "https://Stackoverflow.com/users/7599798", "pm_score": 1, "selected": false, "text": "Public Function getlist() As String()\n 'any operations with array tableData() \n Dim tableData() As String\n (...)\n getlist = tableData\nEnd Function\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20471367/" ]
74,474,381
<p>I have a HTML setup:</p> <pre class="lang-html prettyprint-override"><code>&lt;div id=&quot;wrapper&quot;&gt; &lt;div id=&quot;content&quot;&gt; Lorem ipsum, dolor sit amet consectetur adipisicing elit. Ex corporis perferendis in fugiat cumque. Ipsam modi quia doloremque, animi quisquam quo exercitationem nihil debitis ea corrupti, provident placeat officiis nam. &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I would like the height of the div with id <code>wrapper</code> to be equal to the height of the div with id <code>content</code>, minus X px (say 4px).</p> <p>The div with id <code>wrapper</code> must be positioned according to the normal flow of the document. I.e. not <code>absolute</code> or <code>fixed</code>.</p> <p>Is this possible?</p> <hr /> <p>I am asking because I would like to remove the top and bottom spacing of the text, (not padding, border, margin), but keep spacing between the text in case of wrapping.</p> <p>Essentially; If the text would never wrap, (which it can), it would be equal to setting the <code>line-height</code> to 1 (or the font size).</p> <p>EDIT: Asked another way, can i set <code>line-height</code> to 1 for only the top half of the first line, and the bottom half of the last line?</p> <p>If there are any other ways of accomplishing this, I.e css properties like <code>paragraph-height</code> or similar, this is very welcome.</p>
[ { "answer_id": 74474540, "author": "erecodes", "author_id": 18703252, "author_profile": "https://Stackoverflow.com/users/18703252", "pm_score": 0, "selected": false, "text": "calc()" }, { "answer_id": 74474640, "author": "dantheman", "author_id": 13929140, "author_profile": "https://Stackoverflow.com/users/13929140", "pm_score": 2, "selected": true, "text": "#wrapper{\n background: red;\n display: inline-block;\n}\n\n#content {\n margin-bottom: -4px;\n margin-top: -4px;\n}" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5279274/" ]
74,474,391
<p>Basically I am trying to find a way how the fetch data works. I have created a method that returns a simple list and the response of the body is as follow:</p> <pre><code>[ { &quot;Name&quot;: &quot;ApooBG&quot;, &quot;Password&quot;: &quot;e062f192A&quot;, &quot;Email&quot;: &quot;idk@abv.bg&quot; }, { &quot;Name&quot;: &quot;VenszBG&quot;, &quot;Password&quot;: &quot;12645&quot;, &quot;Email&quot;: &quot;idkk2@abv.bg&quot; }, { &quot;Name&quot;: &quot;PetarGH&quot;, &quot;Password&quot;: &quot;1245&quot;, &quot;Email&quot;: &quot;idkk3@abv.bg&quot; } ] </code></pre> <p>then I have in react a button that calls a method, where it should get this list.</p> <pre><code>&lt;div&gt; &lt;button onClick={Testing}&gt;Edit Info&lt;/button&gt;&lt;/div&gt; </code></pre> <pre><code> const Testing = () =&gt; { fetch(&quot;https://localhost:7101/GetUsers&quot;) .then((response) =&gt; response.json()) .then((data) =&gt; { console.log(data); }) }; </code></pre> <p>When I try to click on the button I need to get the users in the console.log but instead I get <a href="https://i.stack.imgur.com/Rpl2F.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Rpl2F.png" alt="this error" /></a></p> <p>Could you guys tell me what I am doing wrong as I really don't get the idea. The url should be okay as this is what the request URL is. Therefore, the problem should be somewhere else.</p>
[ { "answer_id": 74474540, "author": "erecodes", "author_id": 18703252, "author_profile": "https://Stackoverflow.com/users/18703252", "pm_score": 0, "selected": false, "text": "calc()" }, { "answer_id": 74474640, "author": "dantheman", "author_id": 13929140, "author_profile": "https://Stackoverflow.com/users/13929140", "pm_score": 2, "selected": true, "text": "#wrapper{\n background: red;\n display: inline-block;\n}\n\n#content {\n margin-bottom: -4px;\n margin-top: -4px;\n}" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20045530/" ]
74,474,402
<p>I am not sure whether this is an <code>amt</code> or a <code>tidyr</code> issue, but there is no <code>amt</code> tag yet, so here we are.</p> <p>When working with nested tracks, any calculation (e.g. <code>step_lengths</code>) done in the nested tracks creates a new &quot;list-like&quot; column outside the &quot;data&quot; column, with the same number of rows. I am not sure that is the desired outcome, I'd rather have it added to the nested dataset inside the &quot;data&quot; column, but that's fine, it can be easily solved by unnesting and nesting again (in theory). However, unnest produces this weird list-like object of class NULL, and although I have managed to find a workaround to turn it back into a dataframe, then I need to use make_tracks and nest again to go back to the starting point, which is annoying. Code below with a reprex</p> <p><strong>First make the dataset</strong></p> <pre><code>library(random) test_df &lt;- data.frame(id = rep(c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;), each = 100), lon = runif(min = -9, max = -6, n = 300), lat = runif(min = 51, max = 55, n = 300), covar1 = runif(min = 0, max = 100, n = 300), covar2 = c(randomStrings(n=300, len=3, unique = F, upperalpha = T, loweralpha = F, digits = F))) </code></pre> <p><strong>Now make it a nested track</strong></p> <pre><code>test_tracks &lt;- test_df %&gt;% make_track(lon, lat, all_cols = T, crs = 4326, check_duplicates = FALSE, verbose = TRUE) %&gt;% nest(data = c(-id)) </code></pre> <p><strong>Calculate step lengths</strong></p> <pre><code>test_tracks2 &lt;- test_tracks %&gt;% mutate(sl = map(data, step_lengths)) </code></pre> <p>This produces a nested df that has an additional &quot;list&quot; column, sl</p> <pre><code>&gt; str(test_tracks2, 2) nested_track [3 × 3] (S3: nested_track/tbl_df/tbl/data.frame) $ id : chr [1:3] &quot;A&quot; &quot;B&quot; &quot;C&quot; $ data:List of 3 $ sl :List of 3 </code></pre> <p><strong>Unnest</strong></p> <pre><code>test_tracks3 &lt;- test_tracks2 %&gt;% unnest(cols = c(data, sl)) </code></pre> <p>This produces a list, but of class NULL</p> <pre><code>&gt; class(test_tracks3) [1] &quot;NULL&quot; &gt; str(test_tracks3) List of 6 $ id : chr [1:300] &quot;A&quot; &quot;A&quot; &quot;A&quot; &quot;A&quot; ... $ x_ : num [1:300] -7.67 -7.96 -8.39 -7.26 -8.49 ... $ y_ : num [1:300] 54.3 53.6 54.8 51.9 52.2 ... $ covar1: num [1:300] 55.028 0.772 76.037 64.362 34.512 ... $ covar2: chr [1:300] &quot;KRU&quot; &quot;RJL&quot; &quot;RVG&quot; &quot;BUW&quot; ... $ sl : num [1:300] 0.718 1.28 3.087 1.261 0.648 ... - attr(*, &quot;class&quot;)= chr &quot;NULL&quot; - attr(*, &quot;row.names&quot;)= int [1:300] 1 2 3 4 5 6 7 8 9 10 ... </code></pre> <p>I can turn this list back to a normal df with do.call, but other dplyr or tibble methods won't work</p> <pre><code>x &lt;- as.data.frame(do.call(cbind, test_tracks3)) &gt; str(x) 'data.frame': 300 obs. of 6 variables: $ id : chr &quot;A&quot; &quot;A&quot; &quot;A&quot; &quot;A&quot; ... $ x_ : chr &quot;-7.67035690904595&quot; &quot;-7.96027435711585&quot; &quot;-8.38539077946916&quot; &quot;-7.25699410191737&quot; ... $ y_ : chr &quot;54.2703927513212&quot; &quot;53.6132442755625&quot; &quot;54.8205336350948&quot; &quot;51.9466292150319&quot; ... $ covar1: chr &quot;55.0277820788324&quot; &quot;0.772069441154599&quot; &quot;76.0366528760642&quot; &quot;64.3617564812303&quot; ... $ covar2: chr &quot;KRU&quot; &quot;RJL&quot; &quot;RVG&quot; &quot;BUW&quot; ... $ sl : chr &quot;0.718259177377767&quot; &quot;1.27994983112401&quot; &quot;3.08749181012144&quot; &quot;1.26120128657495&quot; ... </code></pre> <p>However it is a plain df now, and all the variables have lost their format (they are all chr) which is not ideal.</p> <p>Any idea why this is happening and how to fix it?</p>
[ { "answer_id": 74494236, "author": " S.Bird", "author_id": 9064598, "author_profile": "https://Stackoverflow.com/users/9064598", "pm_score": 2, "selected": true, "text": "test_df <- data.frame(id = rep(c(\"A\", \"B\", \"C\"), each = 100), \n lon = runif(min = -9, max = -6, n = 300),\n lat = runif(min = 51, max = 55, n = 300), \n covar1 = runif(min = 0, max = 100, n = 300), \n covar2 = c(randomStrings(n=300, len=3, unique = F, \n upperalpha = T, loweralpha = F, \n digits = F)))\n\ntest_tracks <- test_df %>% \n nest(data = -id) %>%\n mutate(trk = map(data, function(d) {\n make_track(d, lon, lat, \n all_cols = T,\n crs = 4326, \n check_duplicates = FALSE, \n verbose = TRUE)}))\n\ntest_tracks2 = test_tracks %>% \n mutate(sl = map(trk, amt::step_lengths))\n\ntest_tracks3 <- test_tracks2 %>%\n select(-c(data)) %>%\n tidyr::unnest(cols=c(trk, sl))\n" }, { "answer_id": 74604839, "author": "johannes", "author_id": 603625, "author_profile": "https://Stackoverflow.com/users/603625", "pm_score": 0, "selected": false, "text": "library(random)\nlibrary(amt)\ntest_df <- data.frame(id = rep(c(\"A\", \"B\", \"C\"), each = 100), \n lon = runif(min = -9, max = -6, n = 300),\n lat = runif(min = 51, max = 55, n = 300), \n covar1 = runif(min = 0, max = 100, n = 300), \n covar2 = c(randomStrings(n=300, len=3, unique = F, \n upperalpha = T, loweralpha = F, \n digits = F)))\n\ntrk <- test_df %>% \n nest(data = -id) %>%\n mutate(data = map(data, ~ {\n make_track(\n .x, lon, lat, \n all_cols = TRUE,\n crs = 4326, \n check_duplicates = FALSE, \n verbose = TRUE)}))\n\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4676165/" ]
74,474,414
<p>we want to automate an web application with Robot framework/SeleniumLibrary. The app contains some tables, which do not have simple unique identifiers like id/name/class... They only can be uniquely identified via a nested property. Here a sample excerpt of the properties window (DevTools)</p> <pre><code>grid: window.&lt;computed&gt; &gt; FormSubmitOnlyChanged : true &gt; ... &gt; _dataprocessor: dataProcessor &gt; autoUpdate: false &gt; ... &gt; serverProcessor: &quot;/TEST/GridNew/multi?group=getMetaData&amp;name=Sources&amp;editing=true&quot; &gt; ... &gt; ... ... </code></pre> <p>The Element looks as following: <a href="https://i.stack.imgur.com/EWoLa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EWoLa.png" alt="enter image description here" /></a> * The id parameter contains an dynamic id and can therefore not be used for object identification.</p> <p>We tried some approaches, e.g.</p> <pre><code>//div[contains(@grid._dataprocessor.serverProcessor, 'group=getMetaData&amp;name=Sources')] </code></pre> <p>or</p> <pre><code>//div[contains(@serverProcessor, 'group=getMetaData&amp;name=Sources')] </code></pre> <p>but none of them did work. Does anybody have an idea how to get an XPath that makes it possible to contain the nested property? Thank you in advance.</p>
[ { "answer_id": 74494236, "author": " S.Bird", "author_id": 9064598, "author_profile": "https://Stackoverflow.com/users/9064598", "pm_score": 2, "selected": true, "text": "test_df <- data.frame(id = rep(c(\"A\", \"B\", \"C\"), each = 100), \n lon = runif(min = -9, max = -6, n = 300),\n lat = runif(min = 51, max = 55, n = 300), \n covar1 = runif(min = 0, max = 100, n = 300), \n covar2 = c(randomStrings(n=300, len=3, unique = F, \n upperalpha = T, loweralpha = F, \n digits = F)))\n\ntest_tracks <- test_df %>% \n nest(data = -id) %>%\n mutate(trk = map(data, function(d) {\n make_track(d, lon, lat, \n all_cols = T,\n crs = 4326, \n check_duplicates = FALSE, \n verbose = TRUE)}))\n\ntest_tracks2 = test_tracks %>% \n mutate(sl = map(trk, amt::step_lengths))\n\ntest_tracks3 <- test_tracks2 %>%\n select(-c(data)) %>%\n tidyr::unnest(cols=c(trk, sl))\n" }, { "answer_id": 74604839, "author": "johannes", "author_id": 603625, "author_profile": "https://Stackoverflow.com/users/603625", "pm_score": 0, "selected": false, "text": "library(random)\nlibrary(amt)\ntest_df <- data.frame(id = rep(c(\"A\", \"B\", \"C\"), each = 100), \n lon = runif(min = -9, max = -6, n = 300),\n lat = runif(min = 51, max = 55, n = 300), \n covar1 = runif(min = 0, max = 100, n = 300), \n covar2 = c(randomStrings(n=300, len=3, unique = F, \n upperalpha = T, loweralpha = F, \n digits = F)))\n\ntrk <- test_df %>% \n nest(data = -id) %>%\n mutate(data = map(data, ~ {\n make_track(\n .x, lon, lat, \n all_cols = TRUE,\n crs = 4326, \n check_duplicates = FALSE, \n verbose = TRUE)}))\n\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5143239/" ]
74,474,504
<p>So, I have a data frame of this type:</p> <pre><code> Name 1 2 3 4 5 Alex 10 40 20 11 50 Alex 10 60 20 11 60 Sam 30 15 50 15 60 Sam 30 12 50 15 43 John 50 18 100 8 32 John 50 15 100 8 21 </code></pre> <p>I am trying to keep only the columns that have repeated values for all unique row values. For example, in this case, I want to keep columns 1,3,4 because they have repeated values for each 'duplicate' row. But I want to keep the column only if the values are repeated for EACH pair of names - so, the whole column should consist of pairs of same values. Any ideas of how to do that?</p>
[ { "answer_id": 74474848, "author": "will-wright-eng", "author_id": 14343465, "author_profile": "https://Stackoverflow.com/users/14343465", "pm_score": 0, "selected": false, "text": "from collections import Counter\n\nimport pandas as pd\n\ndata = [[ 'Name', 1, 2, 3, 4, 5],\n[ 'Alex', 10, 40, 20, 11, 50],\n[ 'Alex', 10, 60, 20, 11, 60],\n[ 'Sam', 30, 15, 50, 15, 60],\n[ 'Sam', 30, 12, 50, 15, 43],\n[ 'John', 50, 18, 100, 8, 32],\n[ 'John', 50, 15, 100, 8, 21]]\n\ndf = pd.DataFrame(data)\n\nvals = []\nfor row in range(0,len(df)):\n tmp = Counter(df.iloc[row])\n if 2 not in tmp.values():\n vals.append(row)\n \nndf = df.iloc[vals]\nndf.drop_duplicates(subset='Name',keep='first')\n" }, { "answer_id": 74474927, "author": "Nuri Taş", "author_id": 19255749, "author_profile": "https://Stackoverflow.com/users/19255749", "pm_score": 2, "selected": true, "text": "list" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18134832/" ]
74,474,521
<p>I have below CSS for a dropdown menu:</p> <pre><code>.dropdown { position: relative; display: inline-block; } .dropdown-content { display: none; position: absolute; right: 0; top: 30px; background-color: #f9f9f9; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); z-index: 1; button, a { border-bottom: 1px solid #e7e7e7; border-radius: unset; text-align: left; display: inline-block; width: 100%!important; .icon { margin-right: 15px; top: 0.13em; } &amp;:hover { background-color: #e7e7e7 !important; } &amp;:active { background-color: #c7c7c7 !important; } } } .dropdown:hover .dropdown-content { display: block; } </code></pre> <p>And below markup:</p> <pre><code> &lt;div class=&quot;dropdown&quot;&gt; &lt;button class=&quot;material-icon-button&quot;&gt; &lt;i class=&quot;icon icon-more_vert&quot;&gt;&lt;/i&gt; &lt;/button&gt; &lt;div class=&quot;dropdown-content&quot; style=&quot;width: 295px;&quot;&gt; &lt;button class=&quot;material-button&quot;&gt; &lt;i class=&quot;icon icon-undo&quot;&gt;&lt;/i&gt; &lt;span&gt;Button 1&lt;/span&gt; &lt;/button&gt; &lt;button class=&quot;material-button&quot;&gt; &lt;i class=&quot;icon icon-add_alert&quot;&gt;&lt;/i&gt; Button 2 &lt;/button&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>This works fine and shows menu on mouseover.</p> <p>What I am trying to achieve is that, instead of mouseover, the dropdown is shown when the user actually clicks the button.</p> <p>I have tried:</p> <pre><code>.dropdown:active .dropdown-content { display: block; } </code></pre> <p>But It doesn't seem to work, it show the menu on click but hides immediately.</p> <p>I was wondering if this could be done without JavaScript and with pure css? if so, can someone please guide on this.</p> <p>Thanks</p>
[ { "answer_id": 74474848, "author": "will-wright-eng", "author_id": 14343465, "author_profile": "https://Stackoverflow.com/users/14343465", "pm_score": 0, "selected": false, "text": "from collections import Counter\n\nimport pandas as pd\n\ndata = [[ 'Name', 1, 2, 3, 4, 5],\n[ 'Alex', 10, 40, 20, 11, 50],\n[ 'Alex', 10, 60, 20, 11, 60],\n[ 'Sam', 30, 15, 50, 15, 60],\n[ 'Sam', 30, 12, 50, 15, 43],\n[ 'John', 50, 18, 100, 8, 32],\n[ 'John', 50, 15, 100, 8, 21]]\n\ndf = pd.DataFrame(data)\n\nvals = []\nfor row in range(0,len(df)):\n tmp = Counter(df.iloc[row])\n if 2 not in tmp.values():\n vals.append(row)\n \nndf = df.iloc[vals]\nndf.drop_duplicates(subset='Name',keep='first')\n" }, { "answer_id": 74474927, "author": "Nuri Taş", "author_id": 19255749, "author_profile": "https://Stackoverflow.com/users/19255749", "pm_score": 2, "selected": true, "text": "list" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474521", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2755616/" ]
74,474,547
<p>This one is a bit of a long shot, but is there a way to determine which cell in a table is the right-most cell that isn't blank? I have a table that has empty cells on purpose; there's nothing to be recorded. I want to retrieve the right-most cell that still has data. For example:</p> <p><strong>Table 1</strong></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Primary Key</th> <th>Status 1</th> <th>Status 2</th> <th>Status 3</th> </tr> </thead> <tbody> <tr> <td>Alice</td> <td>Alpha</td> <td>Beta</td> <td>Charlie</td> </tr> <tr> <td>Bob</td> <td>Delta</td> <td></td> <td></td> </tr> <tr> <td>Carol</td> <td>Echo</td> <td>Foxtrot</td> <td></td> </tr> <tr> <td>Eve</td> <td>Golf</td> <td>Hotel</td> <td></td> </tr> <tr> <td>Frank</td> <td>India</td> <td>Juliet</td> <td>Kilo</td> </tr> </tbody> </table> </div> <p>Ideally, the formula would return a list of all the cells it retrieves. In my particular implementation, I don't think it matters what order the returned list is in; this example is more to demonstrate what the table looks like rather than what my data is. It also doesn't matter if it's &quot;attached&quot; to the primary key; the ideal return would be a list that looks like &quot;Charlie, Delta, Foxtrot, Hotel, Kilo.&quot; I will be using this generated list for a FILTER function later on, if that changes anything.</p> <p>Theoretically, it <em>might</em> be possible for me to re-work the data? However, since there are 1000+ entries, I'd rather not have to go through by hand, especially since I will be using this data structure for other formulas later.</p> <p>EDIT: The values are non-consecutive and are strings; I misrepresented the data in the original example. My apologies.</p>
[ { "answer_id": 74475112, "author": "player0", "author_id": 5632629, "author_profile": "https://Stackoverflow.com/users/5632629", "pm_score": 2, "selected": false, "text": "=IFNA(BYROW(A2:E; LAMBDA(x; LOOKUP(1; INDEX(1/(x<>\"\")); x))))\n" }, { "answer_id": 74475379, "author": "Klon Aquwerttag", "author_id": 20131755, "author_profile": "https://Stackoverflow.com/users/20131755", "pm_score": 0, "selected": false, "text": "column A" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20526820/" ]
74,474,552
<p>I need some help with testing my python package using <code>tox</code> in a gitlab-ci pipeline:</p> <p>I want to test my package on multiple versions. For this, I can write the following in my <code>tox.ini</code>:</p> <pre class="lang-ini prettyprint-override"><code>[tox] envlist = py{310, 311} [testenv] deps = -rrequirements.txt commands = python -m pytest tests -s </code></pre> <p>Running the command <code>tox</code> works locally, as I have multiple python versions installed via conda (I believe this is the reason).</p> <p>Until now, I have always also tested my package in my gitlab pipeline: (<code>.gitlab-ci.yml</code>)</p> <pre class="lang-yaml prettyprint-override"><code>image: python:3.11 unit-test: stage: test script: - pip install tox - tox -r </code></pre> <p>This causes the pipeline to fail with the following message:</p> <pre><code>ERROR: py310: InterpreterNotFound: python3.10 py311: commands succeeded </code></pre> <p>Is there a gitlab ci container image already out there, that includes multiple python versions?</p>
[ { "answer_id": 74478107, "author": "CodingTil", "author_id": 9406165, "author_profile": "https://Stackoverflow.com/users/9406165", "pm_score": 0, "selected": false, "text": ".gitlab-ci.yml" }, { "answer_id": 74480411, "author": "sinoroc", "author_id": 11138259, "author_profile": "https://Stackoverflow.com/users/11138259", "pm_score": 2, "selected": true, "text": "'.review':\n before_script:\n - 'python -m pip install tox'\n script:\n - 'export TOXENV=\"${CI_JOB_NAME##review}\"'\n - 'tox'\n\n'review py38':\n extends: '.review'\n image: 'python:3.8'\n\n'review py39':\n extends: '.review'\n image: 'python:3.9'\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9406165/" ]
74,474,577
<p>I have array .</p> <pre><code>const arr = [{ &quot;status&quot;: &quot;success&quot;, &quot;data&quot;: [{ &quot;name&quot;: &quot;user1&quot;, &quot;games&quot;: [{ &quot;id&quot;: 1, &quot;gamename&quot;: &quot;cricket&quot; }, { &quot;id&quot;: 2, &quot;gamename&quot;: &quot;football&quot; }] }, { &quot;name&quot;: &quot;user1&quot;, &quot;games&quot;: [{ &quot;id&quot;: 1, &quot;gamename&quot;: &quot;videogames&quot; }, { &quot;id&quot;: 2, &quot;gamename&quot;: &quot;volleyball&quot; }] } ] }] </code></pre> <p>I tried following the code to filter it. and no output show</p> <pre><code>arr.map((item,idx) =&gt; ( console.log(item.data.games.gamename) ) )) </code></pre> <p>I want to print all game name eg.</p> <p>cricket football videogames volleyball</p>
[ { "answer_id": 74474631, "author": "Disco", "author_id": 11196441, "author_profile": "https://Stackoverflow.com/users/11196441", "pm_score": 0, "selected": false, "text": "const arr = [\n {\n status: \"success\",\n data: [\n {\n name: \"user1\",\n games: [\n {\n id: 1,\n gamename: \"cricket\",\n },\n {\n id: 2,\n gamename: \"football\",\n },\n ],\n },\n {\n name: \"user1\",\n games: [\n {\n id: 1,\n gamename: \"videogames\",\n },\n {\n id: 2,\n gamename: \"volleyball\",\n },\n ],\n },\n ],\n },\n];\n\narr.map((item) => {\n item.data.map((item) => {\n item.games.map((item) => {\n console.log(item.gamename);\n });\n });\n});\n\n" }, { "answer_id": 74474650, "author": "flyingfox", "author_id": 3176419, "author_profile": "https://Stackoverflow.com/users/3176419", "pm_score": 1, "selected": false, "text": "flatMap()" }, { "answer_id": 74475501, "author": "Tiwari", "author_id": 9756399, "author_profile": "https://Stackoverflow.com/users/9756399", "pm_score": 0, "selected": false, "text": "const arr = [{\n\"status\": \"success\",\n\"data\": [{\n \"name\": \"user1\",\n \"games\": [{\n \"id\": 1,\n \"gamename\": \"cricket\"\n }, {\n \"id\": 2,\n \"gamename\": \"football\"\n }]\n },\n {\n \"name\": \"user1\",\n \"games\": [{\n \"id\": 1,\n \"gamename\": \"videogames\"\n }, {\n \"id\": 2,\n \"gamename\": \"volleyball\"\n }]\n }\n]\n}];\nconsole.log(JSON.stringify(arr.filter(e=>e.status==\"success\").map(e=>e.data.map(f=>f.games.map(g=>g.gamename)).join(\",\")).join(\",\")));\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20424966/" ]
74,474,642
<p>I have an inline table-valued function, which splits strings into row of substrings based on a specified separator.</p> <p>It is as follows:</p> <pre><code>ALTER FUNCTION [dbo].[SplitString] (@List NVARCHAR(MAX), @Delim VARCHAR(255)) RETURNS TABLE AS RETURN (SELECT [Value], idx = RANK() OVER (ORDER BY n) FROM (SELECT n = Number, [Value] = LTRIM(RTRIM(SUBSTRING(@List, [Number], CHARINDEX(@Delim, @List + @Delim, [Number]) - [Number]))) FROM (SELECT Number = ROW_NUMBER() OVER (ORDER BY name) FROM sys.all_objects) AS x WHERE Number &lt;= LEN(@List) AND SUBSTRING(@Delim + @List, [Number], LEN(@Delim)) = @Delim) AS y ); GO </code></pre> <p>Usage:</p> <pre class="lang-sql prettyprint-override"><code>SELECT value FROM dbo.SplitString('a|b|c', '|') </code></pre> <p>returns:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>value</th> </tr> </thead> <tbody> <tr> <td>a</td> </tr> <tr> <td>b</td> </tr> <tr> <td>c</td> </tr> </tbody> </table> </div> <p>But when sending an empty value as the first argument, it doesn't return anything.</p> <p>For example:</p> <pre class="lang-sql prettyprint-override"><code>SELECT value FROM dbo.SplitString('','|') </code></pre> <p>This doesn't return anything.</p> <p>What modification I need to do to the <code>dbo.SplitString</code> function, so that it returns an empty result set, when an empty string is passed in as first argument?</p> <p>PS: I can't use the inbuilt <code>STRING_SPLIT</code> function because of compatibility issues.</p>
[ { "answer_id": 74483364, "author": "Bernie156", "author_id": 20522983, "author_profile": "https://Stackoverflow.com/users/20522983", "pm_score": 1, "selected": false, "text": "@list with " }, { "answer_id": 74485748, "author": "Karthik Karnam", "author_id": 14187904, "author_profile": "https://Stackoverflow.com/users/14187904", "pm_score": 0, "selected": false, "text": "CREATE FUNCTION [SplitString]\n(\n @ActualString VARCHAR(MAX),\n @DelimiterCharacter VARCHAR(10)\n)\nRETURNS @TableRes TABLE (Id INT IDENTITY(1,1),Value VARCHAR(MAX))\nAS\nBEGIN\nDECLARE @SubStr VARCHAR(MAX)\n WHILE (CHARINDEX(@DelimiterCharacter ,@ActualString)<>0)\n BEGIN\n SET @SubStr=SUBSTRING(@ActualString,1,CHARINDEX(@DelimiterCharacter ,@ActualString)-1)\n SET @ActualString= STUFF(@ActualString,1,CHARINDEX(@DelimiterCharacter,@ActualString),'') \n INSERT INTO @TableRes\n SELECT @SubStr\n\n END\n INSERT INTO @TableRes\n SELECT @ActualString\n\n\n RETURN\nEND\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14187904/" ]
74,474,721
<p>I have the following code:</p> <pre><code>struct ContentView: View { @State var isOn: Bool = false var body: some View { HStack(alignment: .top) { Toggle(isOn: $isOn) { Text(&quot;Hello&quot;) } Text(&quot;The quick brown fox jumped over the lazy dog&quot;) Spacer() Button(&quot;Go&quot;) { print(&quot;Knock knock.&quot;) } .padding() } .padding() } } </code></pre> <p>Which results in:</p> <p><a href="https://i.stack.imgur.com/BjSHf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BjSHf.png" alt="Result" /></a></p> <p>How do I vertically align the top line: <code>The quick brown fox</code> and <code>Go</code> with desiredly positioned <code>Hello</code>?</p> <p>Of course I can manually tune the alignment with hard-coded <code>.offset()</code>; I have this now in my code. But that's ugly and will fall apart if I'd change the font size(s) for example. I'm looking for a proper method without hard-code values.</p> <p>Isn't this possible with SwiftUI alignment features?</p>
[ { "answer_id": 74498192, "author": "Qazi Ammar", "author_id": 6026338, "author_profile": "https://Stackoverflow.com/users/6026338", "pm_score": -1, "selected": false, "text": "struct ContentView: View {\n \n @State var isOn: Bool = false\n\n var body: some View {\n HStack(alignment: .top) {\n HStack(alignment: .top) {\n Text(\"Hello\")\n Toggle(isOn: $isOn) {\n \n }\n }\n\n Text(\"The quick brown fox jumped over the lazy dog\")\n\n Spacer()\n\n Button(\"Go\") {\n print(\"Knock knock.\")\n }\n .padding()\n }\n .padding()\n }\n}\n" }, { "answer_id": 74501305, "author": "DonMag", "author_id": 6257435, "author_profile": "https://Stackoverflow.com/users/6257435", "pm_score": 2, "selected": true, "text": "import SwiftUI\n\nstruct ContentView: View {\n \n @State var isOn: Bool = false\n\n @State var c1: Color = Color(red: 1.00, green: 0.75, blue: 0.75)\n @State var c2: Color = Color(red: 0.75, green: 1.00, blue: 0.75)\n @State var c3: Color = Color(red: 1.00, green: 1.00, blue: 0.00)\n @State var c4: Color = Color(red: 0.80, green: 1.00, blue: 0.75)\n @State var c5: Color = Color(red: 0.75, green: 0.75, blue: 0.25)\n \n var body: some View {\n \n HStack(alignment: .top) {\n \n Spacer()\n \n Toggle(isOn: $isOn) {\n Text(\"Hello\")\n .background(isOn ? c1 : .clear)\n }\n .background(isOn ? c2 : .clear)\n .offset(CGSize(width: 0.0, height: -5.0))\n \n Text(\"The quick brown fox jumped over the lazy dog\")\n .background(isOn ? c3 : .clear)\n \n Spacer()\n \n Button(\"Go\") {\n print(\"Knock knock.\")\n }\n .background(isOn ? c4 : .clear)\n \n Spacer()\n \n }\n .background(isOn ? c5 : .clear)\n .padding()\n \n }\n\n}\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1971013/" ]
74,474,733
<p>I'm trying to make a log in form in Reactjs using bootstrap. I've created two classes, the <code>App.js</code> one which is the main class and the <code>Handler.js</code> one which is supposed to show different content based on state variable, using the alert function, I discovered that state gets reset after submit button is clicked.</p> <p>Why does this happen? What do I have to change in order for the state variable to be set to one after the pushing of the button? Also, the username and password values have to be passed in the input fields?</p> <p><strong>Handler.js</strong></p> <pre class="lang-js prettyprint-override"><code>import Container from 'react-bootstrap/Container'; import Row from 'react-bootstrap/Row'; import Col from 'react-bootstrap/Col'; import { Component } from 'react'; import 'bootstrap/dist/css/bootstrap.min.css'; import &quot;bootstrap/dist/js/bootstrap&quot;; import Button from 'react-bootstrap/Button'; import { Form } from 'react-bootstrap'; class Handler extends Component { state = 0; username = null; password = null; constructor() { super(); this.state = 0; } submitUserPass = () =&gt; { this.state = 1 alert(this.state); } setUs(username) { this.username = username; } setPs(password) { this.password = password; } render() { if (this.state == 0) { return ( &lt;Form onSubmit = {this.submitUserPass}&gt; &lt;Form.Group controlId = &quot;usernameId&quot; &gt; &lt;Form.Label &gt; Username &lt; /Form.Label&gt; &lt;Form.Control value = {this.username} onChange = {event =&gt; this.setUs(event.target.value)} type = &quot;text&quot; placeholder = &quot;username&quot; / &gt; &lt;/Form.Group&gt; &lt;Form.Group controlId = &quot;passwordId&quot; &gt; &lt;Form.Label &gt; Password &lt;/Form.Label&gt; &lt;Form.Control value = {this.password} onChange = {event =&gt; this.setPs(event.target.value)} type = &quot;password&quot; placeholder = &quot;password&quot; /&gt; &lt;/Form.Group&gt; &lt;Button className = &quot;mt-2 &quot; variant = &quot;primary&quot; type = &quot;submit&quot; &gt; Log in &lt;/Button&gt; &lt;/Form &gt; ); } } } export default Handler; </code></pre> <p><strong>App.js</strong></p> <pre><code>class App extends Component { constructor() { super() } render() { return ( &lt;Container &gt; &lt;Row &gt; &lt;Col &gt; &lt;/Col&gt; &lt;Col&gt; &lt;/Col&gt; &lt;Col&gt; &lt;/Col&gt; &lt;/Row&gt; &lt;Row&gt; &lt;Col&gt; &lt;/Col&gt; &lt;Col xs = {5} &gt; &lt;Handler/&gt; // The handler component &lt;/Col&gt; &lt;Col&gt; &lt;/Col&gt; &lt;/Row&gt; &lt;Row&gt; &lt;Col&gt; &lt;/Col&gt; &lt;Col&gt; &lt;/Col&gt; &lt;Col&gt; &lt;/Col&gt; &lt;/Row&gt; &lt;/Container&gt; ); } } export default App; </code></pre> <p><strong>index.js</strong></p> <pre class="lang-js prettyprint-override"><code> import React from 'react'; import ReactDOM from 'react-dom/client'; import App from './App'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render( &lt;React.StrictMode&gt; &lt;App /&gt; &lt;/React.StrictMode&gt; ); </code></pre> <p><strong>package json</strong></p> <pre class="lang-js prettyprint-override"><code> { &quot;name&quot;: &quot;boot&quot;, &quot;version&quot;: &quot;0.1.0&quot;, &quot;private&quot;: true, &quot;dependencies&quot;: { &quot;@testing-library/jest-dom&quot;: &quot;^5.16.5&quot;, &quot;@testing-library/react&quot;: &quot;^13.4.0&quot;, &quot;@testing-library/user-event&quot;: &quot;^13.5.0&quot;, &quot;bootstrap&quot;: &quot;^5.2.2&quot;, &quot;jquery&quot;: &quot;^3.6.1&quot;, &quot;popper.js&quot;: &quot;^1.16.1&quot;, &quot;react&quot;: &quot;^18.2.0&quot;, &quot;react-bootstrap&quot;: &quot;^2.6.0&quot;, &quot;react-dom&quot;: &quot;^18.2.0&quot;, &quot;react-scripts&quot;: &quot;5.0.1&quot;, &quot;web-vitals&quot;: &quot;^2.1.4&quot; }, &quot;scripts&quot;: { &quot;start&quot;: &quot;react-scripts start&quot;, &quot;build&quot;: &quot;react-scripts build&quot;, &quot;test&quot;: &quot;react-scripts test&quot;, &quot;eject&quot;: &quot;react-scripts eject&quot; }, } </code></pre>
[ { "answer_id": 74474755, "author": "Dhaval Jardosh", "author_id": 7427111, "author_profile": "https://Stackoverflow.com/users/7427111", "pm_score": 2, "selected": false, "text": "submitUserPass=(e)=>{\n e.preventDefault(); // This will stop the page from refreshing\n this.state=1 // Also this is not the right way to assign a state, if that's what you're trying to do.\n alert(this.state);\n}\n" }, { "answer_id": 74474796, "author": "compli", "author_id": 16006373, "author_profile": "https://Stackoverflow.com/users/16006373", "pm_score": 1, "selected": false, "text": "const submitUserPass = (event) => {\n event.preventDefault()\n //operation to be performed on submit\n this.setState(1)\n };\n\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15984730/" ]
74,474,734
<p>I'm a beginner developer and I have problem with implementation of BloC framework. Let's assume that I have this code (Model, NetworkService, Repository, Cubit, State, Widget):</p> <pre><code>class NetworkService { Future getData(Uri uri) async { try { http.Response httpsResponse = await http.get( uri, headers: { // some headers // }, ); if (httpsResponse.statusCode == 200) { return httpsResponse.body; } else { throw 'Request failed with status: ${httpsResponse.statusCode}'; } } catch (e) { // What I shloud return here? return e.toString(); } } Future&lt;List&lt;dynamic&gt;&gt; fetchData() async { final uri = Uri.parse('some url'); var data = await getData(uri); return = jsonDecode(data) as List; } } class Repository { final NetworkService networkService = NetworkService(); Future&lt;List&lt;SomeObject&gt;&gt; fetchDataList() async { final dataRaw = await networkService.fetchDataList(); return dataRaw.map((e) =&gt; SomeObject.fromJson(e)).toList(); } } class SomeCubit extends Cubit&lt;CubitState&gt; { final Repository repository; SomeCubit(this.repository) : super(LoadingState()) { fetchDataList(); } void fetchDataList() { try { repository .fetchDataList() .then((dataList) =&gt; emit(LoadedState(dataList))); } catch (e) { // What I shloud return here? emit(ErrorState(e.toString())); } } } </code></pre> <p>How to make this code &quot;bullet proof&quot; because I don't know how to &quot;pass&quot; error from NetworkService to Cubit? It works fine till I have dynamic responses in functions but in Repository class I want to return List of specific objects and when function fail I will return null. If I write try/catch I have to provide return statement in catch block - and I can't return List. I want to return some kind of Error...</p>
[ { "answer_id": 74474755, "author": "Dhaval Jardosh", "author_id": 7427111, "author_profile": "https://Stackoverflow.com/users/7427111", "pm_score": 2, "selected": false, "text": "submitUserPass=(e)=>{\n e.preventDefault(); // This will stop the page from refreshing\n this.state=1 // Also this is not the right way to assign a state, if that's what you're trying to do.\n alert(this.state);\n}\n" }, { "answer_id": 74474796, "author": "compli", "author_id": 16006373, "author_profile": "https://Stackoverflow.com/users/16006373", "pm_score": 1, "selected": false, "text": "const submitUserPass = (event) => {\n event.preventDefault()\n //operation to be performed on submit\n this.setState(1)\n };\n\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12672451/" ]
74,474,774
<p>how to redirect to app settings in react native for android 12 only?</p> <pre><code>NativeModules.OpenSettings.openNetworkSettings(() =&gt; null); </code></pre> <p>i can't use that code right now</p> <pre><code>import { openSettings } from 'react-native-permissions'; openSettings(); </code></pre> <p>this also not working for me</p>
[ { "answer_id": 74474755, "author": "Dhaval Jardosh", "author_id": 7427111, "author_profile": "https://Stackoverflow.com/users/7427111", "pm_score": 2, "selected": false, "text": "submitUserPass=(e)=>{\n e.preventDefault(); // This will stop the page from refreshing\n this.state=1 // Also this is not the right way to assign a state, if that's what you're trying to do.\n alert(this.state);\n}\n" }, { "answer_id": 74474796, "author": "compli", "author_id": 16006373, "author_profile": "https://Stackoverflow.com/users/16006373", "pm_score": 1, "selected": false, "text": "const submitUserPass = (event) => {\n event.preventDefault()\n //operation to be performed on submit\n this.setState(1)\n };\n\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12723803/" ]
74,474,779
<p>I've been learning flutter for 2 months. I'm trying to develop a wallpaper app. I created a model and a function. But right now I can only download 1 wallpaper. How can I make this a list? I get this error when I make a list.</p> <p>This is url.</p> <pre><code> String url = 'https://images.hdqwalls.com/download/the-witcher-season-2-2022-5k-u1-1080x1920.jpg'; </code></pre> <p>the list i want to use</p> <pre><code> List&lt;String&gt; url = [ 'https://images.hdqwalls.com/download/the-witcher-season-2-2022-5k-u1-1080x1920.jpg', 'https://images.hdqwalls.com/download/the-witcher-season-2-2022-5k-u1-1080x1920.jpg', ]; </code></pre> <p>and function</p> <pre><code> void saveimage() async { await GallerySaver.saveImage(url, albumName: album_name); } </code></pre> <p>and clicking this button provides download</p> <pre><code> ElevatedButton DownloadButton(BuildContext context) { return ElevatedButton( style: ElevatedButton.styleFrom( minimumSize: Size(40, 40), shape: CircleBorder(), backgroundColor: Colors.grey.shade600.withOpacity(0.1), ), child: Icon(Icons.download, color: Colors.white.withOpacity(0.7)), onPressed: () { saveimage(); ScaffoldMessenger.of(context).showSnackBar( SnackBar( duration: Duration(seconds: 2), content: Text('Wallpaper downloaded!'), action: SnackBarAction( label: '', onPressed: () {}, ), ), ); }, ); } </code></pre> <p><a href="https://i.stack.imgur.com/vUuVh.png" rel="nofollow noreferrer">Problem image</a></p> <p>The packages I use are</p> <ul> <li>gallery_saver: ^2.3.2</li> <li>async_wallpaper: ^2.0.1</li> </ul> <p>I want to use it in gridview</p> <pre><code>GridView.builder( itemCount: url.length, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, childAspectRatio: 9 / 16, ), itemBuilder: (BuildContext context, int index) { return Card( child: Padding( padding: EdgeInsets.all(1.0), child: FullScreenWidget( child: Stack(fit: StackFit.expand, children: [ Image.network(url, fit: BoxFit.cover), </code></pre>
[ { "answer_id": 74474755, "author": "Dhaval Jardosh", "author_id": 7427111, "author_profile": "https://Stackoverflow.com/users/7427111", "pm_score": 2, "selected": false, "text": "submitUserPass=(e)=>{\n e.preventDefault(); // This will stop the page from refreshing\n this.state=1 // Also this is not the right way to assign a state, if that's what you're trying to do.\n alert(this.state);\n}\n" }, { "answer_id": 74474796, "author": "compli", "author_id": 16006373, "author_profile": "https://Stackoverflow.com/users/16006373", "pm_score": 1, "selected": false, "text": "const submitUserPass = (event) => {\n event.preventDefault()\n //operation to be performed on submit\n this.setState(1)\n };\n\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474779", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20529353/" ]
74,474,785
<p>The model is not getting updated in the database while using the below methods.</p> <p>This is upload form in views</p> <pre><code>def upload(request): if request.method == 'POST': form = UploadForm(request.POST, request.FILES) if form.is_valid(): upload = form.save(commit= False) upload.user = request.user upload.save() messages.info(request,&quot;Added Successfully..!&quot;) return redirect(&quot;home&quot;) return render(request, &quot;upload.html&quot;, {'form': UploadForm}) </code></pre> <p>This is my edit function in views</p> <pre><code>def editbug(request, pk): edit = bug.objects.get(id=pk) if request.method == 'POST': form = UploadForm(request.POST, instance= edit) if form.is_valid(): form.save() print(&quot;uploaded&quot;) messages.info('Record updated successfully..!') return redirect(&quot;home&quot;) else: form = UploadForm(instance= edit) return render(request, &quot;upload.html&quot;, {'form': form}) </code></pre> <p>urls.py</p> <pre class="lang-py prettyprint-override"><code>urlpatterns = [ path('home',views.home, name='home'), path('index',views.index, name='index'), path(&quot;records/&lt;int:pk&gt;/&quot;, views.records, name=&quot;records&quot;), path(&quot;&quot;, views.login_request, name=&quot;login&quot;), path(&quot;logout&quot;, views.logout_request, name=&quot;logout&quot;), path(&quot;upload&quot;, views.upload, name='upload'), path(&quot;edit/&lt;int:pk&gt;/&quot;, views.editbug, name=&quot;edit&quot;) ] </code></pre> <p>Relevant Template:</p> <pre><code> {% for bug in b %} &lt;tr&gt; &lt;td&gt;{{ forloop.counter }}&lt;/td&gt; &lt;td&gt;&lt;a href=&quot;{% url 'records' pk=bug.pk %}&quot;&gt;{{bug.name}}&lt;/a&gt; &lt;/td&gt; &lt;td&gt;{{bug.created_at}}&lt;/td&gt; &lt;td&gt;{{bug.user}}&lt;/td&gt; &lt;td&gt;{{bug.status}}&lt;/td&gt; &lt;td&gt;&lt;a class=&quot;btn btn-sm btn-info&quot; href=&quot;{% url 'edit' bug.id %}&quot;&gt;Edit&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; {% endfor %} </code></pre> <p>This is the template used for editing the form</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;style&gt; table { font-family: arial, sans-serif; border-collapse: collapse; width: 60%; margin-left: auto; margin-right: auto; } td, th { border: 1px solid #dddddd; text-align: left; padding: 8px; } tr:nth-child(even) { background-color: #dddddd; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;h2 style=&quot;text-align: center;&quot;&gt;Bug List&lt;/h2&gt; &lt;table&gt; &lt;tr&gt; &lt;th style=&quot;width: 5%;&quot;&gt;Sl no.&lt;/th&gt; &lt;th&gt;Bug&lt;/th&gt; &lt;th style=&quot;width: 20%;&quot;&gt;Created at&lt;/th&gt; &lt;th&gt;Created by&lt;/th&gt; &lt;th&gt;Status&lt;/th&gt; &lt;/tr&gt; {% block content %} {% for bug in b %} &lt;tr&gt; &lt;td&gt;{{ forloop.counter }}&lt;/td&gt; &lt;td&gt;&lt;a href=&quot;{% url 'records' pk=bug.pk %}&quot;&gt;{{bug.name}}&lt;/a&gt; &lt;/td&gt; &lt;td&gt;{{bug.created_at}}&lt;/td&gt; &lt;td&gt;{{bug.user}}&lt;/td&gt; &lt;td&gt;{{bug.status}}&lt;/td&gt; &lt;td&gt;&lt;a class=&quot;btn btn-sm btn-info&quot; href=&quot;{% url 'edit' bug.id %}&quot;&gt;Edit&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; {% endfor %} {% endblock %} &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This is the upload form for the form creation and editing.</p> <pre><code>class UploadForm(ModelForm): name = forms.CharField(max_length=200) info = forms.TextInput() status = forms.ChoiceField(choices = status_choice, widget= forms.RadioSelect()) fixed_by = forms.CharField(max_length=30) phn_number = PhoneNumberField() #created_by = forms.CharField(max_length=30) #created_at = forms.DateTimeField() #updated_at = forms.DateTimeField() screeenshot = forms.ImageField() class Meta: model = bug fields = ['name', 'info', 'status', 'fixed_by', 'phn_number', 'screeenshot'] </code></pre> <p>Tried editing the record but it is not getting updated. please check the views, templates and urls.</p>
[ { "answer_id": 74474996, "author": "Manoj Tolagekar", "author_id": 17808039, "author_profile": "https://Stackoverflow.com/users/17808039", "pm_score": 0, "selected": false, "text": "def update(request, id): \n edit = bug.objects.get(id=id) \n form = Formname(request.POST,instance=edit) \n if form.is_valid(): \n form.save() \n return HttpResponseRedirect('/') \n return render(request,'edit.html',{'edit': edit})\n" }, { "answer_id": 74475037, "author": "Sunderam Dubey", "author_id": 17562044, "author_profile": "https://Stackoverflow.com/users/17562044", "pm_score": 3, "selected": true, "text": "request.FILES" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20529531/" ]
74,474,789
<p>I'm trying to get the primary auto incremented key from one table and store this in another using MySQL connector and JDBC. Although its giving me this error:</p> <blockquote> <p>statement.executeupdate() cannot issue statements that produce result sets.</p> </blockquote> <p>I think its something to do with the storing of the integer variable but not too sure.</p> <pre><code>public void insertIntoWorkoutLogs(String field_setNumber, String field_repNumber, String field_weightAmount) { try{ Class.forName(&quot;com.mysql.cj.jdbc.Driver&quot;); Connection connection= DriverManager.getConnection(&quot;jdbc:mysql://localhost:3306/workout&quot;,&quot;root&quot;,&quot;&quot;); Statement statement =connection.createStatement(); String insert =&quot;INSERT INTO `workout`.`workoutlogs`&quot; + &quot; (`SetNumber`, `RepNumber` , `WeightAmount`)&quot; + &quot;VALUES('&quot; +field_setNumber+&quot;','&quot;+field_repNumber+&quot;','&quot;+field_weightAmount+&quot;')&quot;; statement.executeUpdate(insert); int workoutID = insertQueryGetId(&quot;SELECT workoutID FROM workout&quot;); String insert2 =&quot;INSERT INTO `workout`.`workoutlogs`&quot; + &quot; (`WorkoutID`)&quot; + &quot;VALUES('&quot; +workoutID+&quot;')&quot;; statement.executeUpdate(insert2); connection.close(); }catch(Exception e) { System.out.println(e); } } public int insertQueryGetId(String query) throws ClassNotFoundException, SQLException { Class.forName(&quot;com.mysql.cj.jdbc.Driver&quot;); Connection connection= DriverManager.getConnection(&quot;jdbc:mysql://localhost:3306/workout&quot;,&quot;root&quot;,&quot;&quot;); Statement statement =connection.createStatement(); int workoutID=0; int result=-1; try { workoutID = statement.executeUpdate(query, Statement.RETURN_GENERATED_KEYS); ResultSet rs = statement.getGeneratedKeys(); if (rs.next()){ result=rs.getInt(1); } rs.close(); statement.close(); } catch (Exception e) { e.printStackTrace(); } return result; } </code></pre> <p>I've tried using statement for this, but I'm thinking it may have to be prepared statement for it to work. Expecting to store the auto incremented primary key of one table (workouts) into a field within another table (workoutlogs).</p>
[ { "answer_id": 74475151, "author": "Syed Asad Manzoor", "author_id": 20477563, "author_profile": "https://Stackoverflow.com/users/20477563", "pm_score": 0, "selected": false, "text": " public void insertIntoWorkoutLogs(String field_setNumber, String field_repNumber, String field_weightAmount) {\n try{\n Class.forName(\"com.mysql.cj.jdbc.Driver\");\n Connection connection= DriverManager.getConnection(\"jdbc:mysql://localhost:3306/workout\",\"root\",\"\");\n Statement statement =connection.createStatement();\n \n String insert =\"INSERT INTO `workout`.`workoutlogs`\" + \" (`SetNumber`, `RepNumber` , `WeightAmount`)\"\n + \"VALUES('\" +field_setNumber+\"','\"+field_repNumber+\"','\"+field_weightAmount+\"')\";\n statement.executeUpdate(insert);\n \n **int workoutID = insertQueryGetId(\"SELECT workoutID FROM workout\");** // Line of Concern 1\n \n String insert2 =\"INSERT INTO `workout`.`workoutlogs`\" + \" (`WorkoutID`)\"\n + \"VALUES('\" +workoutID+\"')\";\n statement.executeUpdate(insert2);\n \n connection.close();\n }catch(Exception e) {\n System.out.println(e);\n }\n }\n \n public int insertQueryGetId(String query) throws ClassNotFoundException, SQLException {\n Class.forName(\"com.mysql.cj.jdbc.Driver\");\n Connection connection= DriverManager.getConnection(\"jdbc:mysql://localhost:3306/workout\",\"root\",\"\");\n Statement statement =connection.createStatement();\n \n int workoutID=0;\n int result=-1;\n \n try {\n// Line of Concern 2\n **workoutID = statement.executeUpdate(query, Statement.RETURN_GENERATED_KEYS);** \n" }, { "answer_id": 74475188, "author": "Akash", "author_id": 20262528, "author_profile": "https://Stackoverflow.com/users/20262528", "pm_score": 1, "selected": false, "text": "Statement.RETURN_GENERATED_KEYS" }, { "answer_id": 74475469, "author": "Joop Eggen", "author_id": 984823, "author_profile": "https://Stackoverflow.com/users/984823", "pm_score": 0, "selected": false, "text": "Class.forName(\"com.mysql.cj.jdbc.Driver\");\ntry (Connection connection = DriverManager.getConnection(\n \"jdbc:mysql://localhost:3306/workout\", \"root\", \"\")) {\n String insertSql = \"INSERT INTO `workout`.`workoutlogs`\"\n + \" (`SetNumber`, `RepNumber` , `WeightAmount`)\"\n + \" VALUES(?, ?, ?)\";\n try (PreparedStatement statement = connection.prepareStatement(insertSql,\n Statement.RETURN_GENERATED_KEYS)) {\n statement.setString(field_setNumber);\n statement.setString(field_repNumber);\n statement.setBigDecimal(field_weightAmount);\n statement.executeUpdate();\n try (ResultSet rs = statement.getGeneratedKey()) {\n if (rs.next()) {\n int workoutID = rs.getInt(0);\n //... second insert here\n }\n }\n }\n}\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474789", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20529569/" ]
74,474,795
<p>I have a strange bug when I reload a certain row of UITableView via the .reloadRows() method. Snippets of code:</p> <pre><code> func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int { return news_section.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: &quot;cell_section&quot;, for: indexPath) as! NewsSectionCell cell.delegate_press_btn = self var news_index = self.news_section[indexPath.row] cell.number = news_index cell.indexPath = indexPath return cell } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -&gt; CGFloat { var highCell = self.needs_high_cell(news_sect: self.news_section[indexPath.row]) return highCell ? 150 : 90.0 } </code></pre> <p>The cell has a button when pressed via delegate does following:</p> <pre><code> self.news_section[index] = 0 self.news_table_view.reloadRows(at: [indexPath], with: .none) </code></pre> <p>Sometimes it works sometimes it produces this: NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds</p> <p>I tried to change the cell number by changing the array from where the cell gets his number. And then reload only that row.</p>
[ { "answer_id": 74475013, "author": "keyur kathrotiya", "author_id": 10363229, "author_profile": "https://Stackoverflow.com/users/10363229", "pm_score": 1, "selected": false, "text": "let indexPath = IndexPath(item: rowNumber, section: 0)\ntableView.reloadRows(at: [indexPath], with: .top)\n" }, { "answer_id": 74476905, "author": "0xhello", "author_id": 19653319, "author_profile": "https://Stackoverflow.com/users/19653319", "pm_score": -1, "selected": false, "text": "// Reconfigures any existing cells for the rows. Reconfiguring is more efficient than reloading a row, as it does not replace the\n// existing cell with a new cell. Prefer reconfiguring over reloading unless you actually need an entirely new cell for the row.\n@available(iOS 15.0, *)\nopen func reconfigureRows(at indexPaths: [IndexPath])\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19653319/" ]
74,474,818
<p>I have a table of water quality data. Currently it looks like this, except the last three columns are populated with data:</p> <p><a href="https://i.stack.imgur.com/6flLe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6flLe.png" alt="enter image description here" /></a></p> <p>But I'd like to change it into this format:</p> <p><a href="https://i.stack.imgur.com/ZlIpn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZlIpn.png" alt="enter image description here" /></a></p> <h3>Example Dataframe</h3> <pre><code>structure(list(season = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L), levels = c(&quot;Winter&quot;, &quot;Spring&quot;, &quot;Summer&quot;, &quot;Autumn&quot;), class = &quot;factor&quot;), site = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L), levels = c(&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;, &quot;5&quot;, &quot;6&quot;), class = &quot;factor&quot;), Temp = c(&quot;7.2(1.56)&quot;, &quot;7.05(1.91)&quot;, &quot;6.3(1.7)&quot;, &quot;6.25(2.33)&quot;, &quot;6.2(2.4)&quot;, &quot;5.4(2.4)&quot;, &quot;11.77(2.75)&quot;, &quot;12.5(4.62)&quot;, &quot;11.6(3.68)&quot;, &quot;11.13(3.81)&quot;, &quot;11(3.67)&quot;, &quot;13.57(4.15)&quot;, &quot;13(1.51)&quot;, &quot;15.13(1.65)&quot;, &quot;14.4(0.75)&quot;, &quot;14.93(1.19)&quot;, &quot;14.97(1.29)&quot;, &quot;21(3.24)&quot;), pH = c(&quot;7.44(0.29)&quot;, &quot;7.38(0.28)&quot;, &quot;7.52(0.1)&quot;, &quot;7.53(0.12)&quot;, &quot;7.38(0.06)&quot;, &quot;7.56(0.26)&quot;, &quot;7.21(0.1)&quot;, &quot;7.2(0.13)&quot;, &quot;7.35(0.08)&quot;, &quot;7.44(0.06)&quot;, &quot;7.46(0.02)&quot;, &quot;7.72(0.11)&quot;, &quot;7.35(0.1)&quot;, &quot;7.48(0.12)&quot;, &quot;7.44(0.05)&quot;, &quot;7.12(0.14)&quot;, &quot;7.15(0.03)&quot;, &quot;7.86(0.38)&quot;), `DO` = c(&quot;9(0)&quot;, &quot;9.1(0.42)&quot;, &quot;8.25(0.07)&quot;, &quot;8.85(0.49)&quot;, &quot;9.25(0.64)&quot;, &quot;9(0.42)&quot;, &quot;8.73(1.32)&quot;, &quot;8.13(2.85)&quot;, &quot;7.37(1.16)&quot;, &quot;8.3(1.5)&quot;, &quot;8.47(1.21)&quot;, &quot;9.2(0.79)&quot;, &quot;7.43(1.21)&quot;, &quot;5.63(3.33)&quot;, &quot;7.07(1.12)&quot;, &quot;4.77(2.5)&quot;, &quot;5(1.1)&quot;, &quot;7.87(1.07)&quot; ), `EC` = c(&quot;337.5(55.86)&quot;, &quot;333(41.01)&quot;, &quot;321.5(51.62)&quot;, &quot;322(32.53)&quot;, &quot;309(25.46)&quot;, &quot;300.5(30.41)&quot;, &quot;407.67(13.58)&quot;, &quot;404(12.29)&quot;, &quot;376.33(8.08)&quot;, &quot;337.33(8.5)&quot;, &quot;333.67(13.5)&quot;, &quot;290.67(9.24)&quot;, &quot;474(7.21)&quot;, &quot;464.33(8.33)&quot;, &quot;409(4.36)&quot;, &quot;389.33(30.27)&quot;, &quot;368.67(19.6)&quot;, &quot;327.67(18.58)&quot; )), row.names = c(NA, 18L), class = &quot;data.frame&quot;) </code></pre>
[ { "answer_id": 74474936, "author": "TarJae", "author_id": 13321647, "author_profile": "https://Stackoverflow.com/users/13321647", "pm_score": 3, "selected": true, "text": "df %>% \n pivot_longer(-c(season,site)) %>% \n pivot_wider(names_from = season, values_from = value) %>% \n arrange(name, site) %>% \n relocate(name, site) %>% \n mutate(name = factor(name, levels = colnames(df[-c(1:2)]))) %>% \n arrange(name) %>% \n group_by(name) %>% \n mutate(name = ifelse(row_number()==1, as.character(name), \"\")) %>% \n print(n=30)\n" }, { "answer_id": 74474957, "author": "cgvoller", "author_id": 17144974, "author_profile": "https://Stackoverflow.com/users/17144974", "pm_score": 0, "selected": false, "text": "tidyr" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18143306/" ]
74,474,839
<p>guys. I'm trying to set up e2e testing using Playwright. I'm following along these steps (<a href="https://playwright.dev/docs/intro" rel="nofollow noreferrer">enter link description here</a>) and I can see the tests are passing but I'd like to see the browser window so I can try and interact with the elements. How can I make the test runner open a browser window or tab?</p>
[ { "answer_id": 74474936, "author": "TarJae", "author_id": 13321647, "author_profile": "https://Stackoverflow.com/users/13321647", "pm_score": 3, "selected": true, "text": "df %>% \n pivot_longer(-c(season,site)) %>% \n pivot_wider(names_from = season, values_from = value) %>% \n arrange(name, site) %>% \n relocate(name, site) %>% \n mutate(name = factor(name, levels = colnames(df[-c(1:2)]))) %>% \n arrange(name) %>% \n group_by(name) %>% \n mutate(name = ifelse(row_number()==1, as.character(name), \"\")) %>% \n print(n=30)\n" }, { "answer_id": 74474957, "author": "cgvoller", "author_id": 17144974, "author_profile": "https://Stackoverflow.com/users/17144974", "pm_score": 0, "selected": false, "text": "tidyr" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10864272/" ]
74,474,886
<p>After running this typescript code it gives me an error on the item parameter of a callback function.Can't find what the problem is</p> <pre><code>function tap&lt;T&gt;(array:T[],callback:(array:T[])=&gt; T ):T{ return callback(array) } const myResult = tap&lt;number&gt;([1,2,3,4],(item)=&gt;{ if(item.length !==0 ){ return item.pop() }else{ return 1 } }) </code></pre> <p>error output</p> <pre><code>Argument of type '(item: number[]) =&gt; (() =&gt; number | undefined) | 10' is not assignable to parameter of type '(array: number[]) =&gt; number'. Type '(() =&gt; number | undefined) | 10' is not assignable to type 'number'. Type '() =&gt; number | undefined' is not assignable to type 'number'.ts(2345) </code></pre>
[ { "answer_id": 74474956, "author": "Vayne Valerius", "author_id": 11888674, "author_profile": "https://Stackoverflow.com/users/11888674", "pm_score": 2, "selected": false, "text": "function tap<T>(array: T[], callback: (array: T[]) => T): T {\n return callback(array);\n}\n\nconst myResult = tap<number | undefined>([1, 2, 3, 4], (item) => {\n if (item.length !== 0) {\n return item.pop();\n } else {\n return 1;\n }\n});\n" }, { "answer_id": 74474979, "author": "LoveriusB", "author_id": 16689682, "author_profile": "https://Stackoverflow.com/users/16689682", "pm_score": 2, "selected": false, "text": "return item.pop()\n" }, { "answer_id": 74474992, "author": "Erlind Bylykbashi", "author_id": 11830645, "author_profile": "https://Stackoverflow.com/users/11830645", "pm_score": 3, "selected": true, "text": "item.pop()" }, { "answer_id": 74477190, "author": "Alasgar", "author_id": 15102213, "author_profile": "https://Stackoverflow.com/users/15102213", "pm_score": 1, "selected": false, "text": "function tap<T>(array:T[],callback:(array:T[])=> T ):T{\n return callback(array)\n}\n\n\nconst myResult = tap<number>([1,2,3,4],(item)=>{\n return item.pop() || 1\n})\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15102213/" ]
74,474,932
<p>I have a table with names of players like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Player</th> </tr> </thead> <tbody> <tr> <td>John</td> </tr> <tr> <td>Eric</td> </tr> <tr> <td>Valerie</td> </tr> <tr> <td>Carmen</td> </tr> </tbody> </table> </div> <p>And another table with a list of played matches (match number, match date and the list of players that played in the match). Something like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Match</th> <th>Date</th> <th>Player1</th> <th>Player2</th> <th>Player3</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>15/11/2022</td> <td>John</td> <td>Eric</td> <td></td> </tr> <tr> <td>2</td> <td>15/11/2022</td> <td>John</td> <td>Eric</td> <td></td> </tr> <tr> <td>3</td> <td>15/11/2022</td> <td>John</td> <td>Eric</td> <td></td> </tr> <tr> <td>4</td> <td>16/11/2022</td> <td>John</td> <td>Valerie</td> <td>Carmen</td> </tr> <tr> <td>5</td> <td>16/11/2022</td> <td>John</td> <td>Carmen</td> <td></td> </tr> <tr> <td>6</td> <td>17/11/2022</td> <td>John</td> <td>Carmen</td> <td></td> </tr> </tbody> </table> </div> <p>Now with these information I would like to add a column to the player table showing the number of different days each player has played. Something like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Player</th> <th>Days (attendance)</th> </tr> </thead> <tbody> <tr> <td>John</td> <td>3</td> </tr> <tr> <td>Eric</td> <td>1</td> </tr> <tr> <td>Valerie</td> <td>1</td> </tr> <tr> <td>Carmen</td> <td>2</td> </tr> </tbody> </table> </div> <p>How can I do this?</p> <p>My idea was:</p> <ul> <li>foreach player, select all records from the matches tables containing the player. For example with player Carmen I will select these:</li> </ul> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Match</th> <th>Date</th> <th>Player1</th> <th>Player2</th> <th>Player3</th> </tr> </thead> <tbody> <tr> <td>4</td> <td>16/11/2022</td> <td>John</td> <td>Valerie</td> <td>Carmen</td> </tr> <tr> <td>5</td> <td>16/11/2022</td> <td>John</td> <td>Carmen</td> <td></td> </tr> <tr> <td>6</td> <td>17/11/2022</td> <td>John</td> <td>Carmen</td> <td></td> </tr> </tbody> </table> </div> <ul> <li>from these records consider only the column date and and the column current player</li> </ul> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Date</th> <th>Player</th> </tr> </thead> <tbody> <tr> <td>16/11/2022</td> <td>Carmen</td> </tr> <tr> <td>16/11/2022</td> <td>Carmen</td> </tr> <tr> <td>17/11/2022</td> <td>Carmen</td> </tr> </tbody> </table> </div> <ul> <li>remove duplicates</li> </ul> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Date</th> <th>Player</th> </tr> </thead> <tbody> <tr> <td>16/11/2022</td> <td>Carmen</td> </tr> <tr> <td>17/11/2022</td> <td>Carmen</td> </tr> </tbody> </table> </div> <ul> <li>And finally count the number of elements</li> </ul> <p>This was my idea but I'm a novice and I have not been able to implement it. How can I do this (or something similar)? Thanks!!</p>
[ { "answer_id": 74475039, "author": "player0", "author_id": 5632629, "author_profile": "https://Stackoverflow.com/users/5632629", "pm_score": 3, "selected": true, "text": "=INDEX(QUERY(SPLIT(UNIQUE(FLATTEN(IF(C2:E=\"\",,B2:B&\"​\"&C2:E))), \"​\"), \n \"select Col2,count(Col2) where Col2 is not null group by Col2 label count(Col2)''\"))\n" }, { "answer_id": 74475155, "author": "Gabino Antuña Ortiz", "author_id": 17351698, "author_profile": "https://Stackoverflow.com/users/17351698", "pm_score": 0, "selected": false, "text": "players['Days_Attendance'] = [list(matches['Player 1']).count(e) + \nlist(matches['Player 2']).count(e) + list(matches['Player 2']).count(e) for e in \nplayers['Player']]\n" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/511956/" ]
74,474,942
<p>First of all, I'm a complete newbie at Powershell. I've basically compiled a script from a number google search results and it works to a certain degree, so be gentle :)</p> <p>I have a number of large plain text files that need scanning, junk data needs removing, and characters need renaming. Then create a new file in the same directory</p> <p>Here is the script I have for individual files, I have replaced actual keywords for something unrelated, but for testing purposes you should see what I am trying to achieve:</p> <pre><code>Get-Content C:\Temp\Tomatoes-2022-09-27.txt | Where-Object { - $_.Contains('red') } | # Keeping only lines containing &quot;red&quot; Foreach {$_ -replace &quot;[/()]&quot;,&quot;:&quot;}| # replacing specific characters to a colon Where-Object { -not $_.Contains('too red') } | # removing lines containing &quot;too red&quot; Set-Content C:\Temp\Tomatoes-2022-09-27Ripe.txt # saving as a new file *Ripe.txt </code></pre> <p>This works for individual files just fine but what I need to do is the same process for any file within the Temp directory. They all have similar names other than the date.</p> <p>Here's what I have compiled for all files, but it overwrites existing files rather than creating a new one and I don't know how to get it to write to new files ie Tomotoes*Ripe.txt: *being the unique date</p> <pre><code>Get-ChildItem C:\Temp\*.* -Recurse | ForEach-Object { (Get-Content $_) | Where-Object { - $_.Contains('red') } | ForEach-Object { $_ -replace &quot;[/()]&quot;, &quot;:&quot; } | Where-Object { -not $_.Contains('too red') } | Set-Content $_ } </code></pre> <p>Or will it be better to create a copy first using New-Item then process the other jobs?</p> <p>It's going to be something very simple I know! And will most definitely kick myself once corrected.</p> <p>Thanks in advance</p>
[ { "answer_id": 74475975, "author": "Theo", "author_id": 9898643, "author_profile": "https://Stackoverflow.com/users/9898643", "pm_score": 2, "selected": true, "text": "Get-ChildItem -Path 'C:\\Temp' -File -Recurse | ForEach-Object { \n $newFile = Join-Path -Path $_.DirectoryName -ChildPath ('{0}Ripe{1}' -f $_.BaseName, $_.Extension)\n $newContent = Get-Content $_.FullName | \n Where-Object { $_ -like '*red*' -and $_ -notlike '*too red*' } | \n ForEach-Object { $_ -replace \"[/()]\", \":\" } \n $newContent | Set-Content -Path $newFile\n}\n" }, { "answer_id": 74477086, "author": "mklement0", "author_id": 45375, "author_profile": "https://Stackoverflow.com/users/45375", "pm_score": 0, "selected": false, "text": "-PipelineVariable" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20529415/" ]
74,474,976
<p>let's assume the following <code>data.frame</code></p> <pre><code>set.seed(20221117) df &lt;- data.frame(x = as.POSIXct(sample(2e9, 1e5), origin = &quot;1970-01-01 00:00.00 UTC&quot;), y = as.POSIXct(sample(2e9, 1e5), origin = &quot;1970-01-01 00:00.00 UTC&quot;)) </code></pre> <p>What would be a reasonably fast way to select the maximum for each row (ideally without having to explicitely convert into <code>double</code>)?</p>
[ { "answer_id": 74475038, "author": "sindri_baldur", "author_id": 4552295, "author_profile": "https://Stackoverflow.com/users/4552295", "pm_score": 3, "selected": true, "text": "do.call(pmax, df)\n\n[1] \"2020-11-30 22:09:29 GMT\" \"2026-06-14 20:00:05 GMT\"\n[3] \"2008-02-08 01:32:23 GMT\" \"2021-06-17 10:44:05 GMT\"\n[5] \"2025-02-18 23:20:28 GMT\" \"1997-03-27 18:10:44 GMT\"\n...\n" }, { "answer_id": 74475044, "author": "Tom Hoel", "author_id": 17213355, "author_profile": "https://Stackoverflow.com/users/17213355", "pm_score": 0, "selected": false, "text": "data.frame" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74474976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1586820/" ]
74,475,009
<p>I encountered the problem when I tired to run my regex function on my text which can be found <a href="https://www.gutenberg.org/files/45839/45839.txt" rel="nofollow noreferrer">here</a>.</p> <p>With a HttpRequest I fetch the text form the link above. Then I run my regex to clean up the text before filtering the most occurrences of a certain word.</p> <p>After cleaning up the word I split the string by whitespace and added it into a string array and notice there was a huge difference in the number of indexes.</p> <p>Does anyone know why this happens because the result of occurrences for the word &quot; the &quot; - is 6806 hits.<br /> <a href="https://i.stack.imgur.com/9l9fT.png" rel="nofollow noreferrer">raw data correct answer is 6806</a></p> <p>And with my regex I get - 8073 hits</p> <p><a href="https://i.stack.imgur.com/Im9m8.png" rel="nofollow noreferrer">with regex</a></p> <p>The regex i'm using is <a href="https://regex101.com/r/8KfL6F/1" rel="nofollow noreferrer">here in the sandbox with the text</a> and below in the code.</p> <pre><code>//Application storing. var dictionary = new Dictionary&lt;string, long&gt;(StringComparer.OrdinalIgnoreCase); // Cleaning up a bit var words = CleanByRegex(rawSource); string[] arr = words.Split(&quot; &quot;, StringSplitOptions.RemoveEmptyEntries); string CleanByRegex(string rawSource) { Regex r = RemoveSpecialChars(); return r.Replace(rawSource, &quot; &quot;); } // arr {string[220980]} - with regex // arr {string[157594]} - without regex foreach (var word in arr) { // some logic } ``` partial class Program { [GeneratedRegex(&quot;(?:[^a-zA-Z0-9]|(?&lt;=['\\\&quot;]\\s))&quot;, RegexOptions.IgnoreCase | RegexOptions.Compiled, &quot;en-SE&quot;)] private static partial Regex RemoveSpecialChars(); } ``` </code></pre> <p>I have tried debugging it and I have my suspicion that I'm adding trailing whitespace but I don't know how to handle it.</p> <p>I have tired to add a whitespace removing regex where I remove multiple whitespace and replace that with one whitespace.</p> <p>the regex would look something like - <code>[ ]{2,}&quot;</code></p> <pre><code>partial class Program { [GeneratedRegex(&quot;[ ]{2,}&quot;, RegexOptions.Compiled)] private static partial Regex RemoveWhiteSpaceTrails(); } </code></pre>
[ { "answer_id": 74475038, "author": "sindri_baldur", "author_id": 4552295, "author_profile": "https://Stackoverflow.com/users/4552295", "pm_score": 3, "selected": true, "text": "do.call(pmax, df)\n\n[1] \"2020-11-30 22:09:29 GMT\" \"2026-06-14 20:00:05 GMT\"\n[3] \"2008-02-08 01:32:23 GMT\" \"2021-06-17 10:44:05 GMT\"\n[5] \"2025-02-18 23:20:28 GMT\" \"1997-03-27 18:10:44 GMT\"\n...\n" }, { "answer_id": 74475044, "author": "Tom Hoel", "author_id": 17213355, "author_profile": "https://Stackoverflow.com/users/17213355", "pm_score": 0, "selected": false, "text": "data.frame" } ]
2022/11/17
[ "https://Stackoverflow.com/questions/74475009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20529565/" ]