qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,538,318
<p>I created a project that needs a tomcat server to host a small website. Now I want to add a JavaFX application to this project. This should also start when the Tomcat starts up, but unfortunately nothing happens. FX has been added to the project library.</p> <pre><code>public class Start { public static void main( String args[] ) { try { Tomcat tomcat = new Tomcat( ); String webappDirectory = new File( &quot;src/main/webapp&quot; ).getAbsolutePath( ); tomcat.setPort( 8080 ); Context context = tomcat.addWebapp( &quot;&quot;, webappDirectory ); Tomcat.addServlet( context, &quot;blockchain&quot;, new ServletContainer( new Applications( ) ) ); context.addServletMappingDecoded( &quot;/blockchain/api/*&quot;, &quot;blockchain&quot; ); tomcat.start( ); tomcat.getServer( ).await( ); ConfigurationGui config = new ConfigurationGui(); Stage stage = new Stage(); config.start(stage); } catch ( Exception e ) { e.printStackTrace( ); } } } </code></pre> <p>Application-Class:</p> <pre><code>import javafx.application.Application; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; public class ConfigurationGui extends Application { @Override public void start(Stage primaryStage) throws Exception { Parent root = new BorderPane(); Scene scene = new Scene(root,400,400); scene.getStylesheets().add(getClass().getResource(&quot;application.css&quot;).toExternalForm()); primaryStage.setScene(scene); primaryStage.show(); } } </code></pre>
[ { "answer_id": 74539131, "author": "jewelsea", "author_id": 1155209, "author_profile": "https://Stackoverflow.com/users/1155209", "pm_score": 4, "selected": true, "text": "start() launch() Application init() stop() stop() Start src src\\main src" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19896523/" ]
74,538,328
<p>I'm trying to assign two different color palettes to my data set below based on gender. It's important to see both graphs side by side:</p> <p><a href="https://i.stack.imgur.com/M6kuK.png" rel="nofollow noreferrer">enter image description here</a></p> <p>This is my code so far:</p> <pre><code>import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import os g = sns.catplot(data = run_data, x = 'Disc_Age', kind = 'count', col = 'SEX', aspect = 2); h = sns.catplot(data = run_data, x = 'Disc_Age', kind = 'count', col = 'SEX', height = 6, palette=(sns.color_palette('rocket', 11))) h.set_xticklabels(rotation=45, horizontalalignment='right'); </code></pre> <p>Could you please help me see where I went wrong?</p> <p><strong>EDIT:</strong> I added this to the code and this has gotten me the closest to what I want (except I don't have separate seaborn palettes for males and females):</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>palette = { 'M': 'tab:blue', 'F': 'tab:red', } h = sns.catplot(data = run_data, x = 'Disc_Age', kind = 'count', col = 'SEX', aspect = 2, hue = 'SEX', palette = palette) h.set_xticklabels(rotation = 45, horizontalalignment = 'right', fontsize = 18); plt.show()</code></pre> </div> </div> </p> <p><a href="https://i.stack.imgur.com/MBL6v.png" rel="nofollow noreferrer">enter image description here</a></p>
[ { "answer_id": 74539131, "author": "jewelsea", "author_id": 1155209, "author_profile": "https://Stackoverflow.com/users/1155209", "pm_score": 4, "selected": true, "text": "start() launch() Application init() stop() stop() Start src src\\main src" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20575748/" ]
74,538,349
<p>I found some code here: <a href="https://stackoverflow.com/a/29007874/3042018">https://stackoverflow.com/a/29007874/3042018</a> which makes 12 circle sectors using rotate and skew CSS (e.g.<code>transform: rotate(30deg) skewY(-60deg); </code>).</p> <p>I want to modify the code to have 6 sectors instead of 12. I thought it should be simple. I've done my due diligence and had a good go, but I'm stumped. I deleted the last six list elements and the css rules for these, then modified the angles to what I though would give me what I want, but now there are gaps in my circle.</p> <p>Can someone please explain how to have six even-sized sectors filling the whole circle, based on the existing code?</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>.circle { position: relative; border: 1px solid black; padding: 0; margin: 1em auto; width: 20em; height: 20em; border-radius: 50%; list-style: none; overflow: hidden; } li { overflow: hidden; position: absolute; top: 0; right: 0; width: 50%; height: 50%; transform-origin: 0% 100%; } .text { position: absolute; left: -100%; width: 200%; height: 200%; text-align: center; -webkit-transform: skewY(60deg) rotate(15deg); -ms-transform: skewY(60deg) rotate(15deg); transform: skewY(60deg) rotate(15deg); padding-top: 20px; } li:first-child { -webkit-transform: rotate(0deg) skewY(-60deg); -ms-transform: rotate(0deg) skewY(-60deg); transform: rotate(0deg) skewY(-60deg); } li:nth-child(2) { -webkit-transform: rotate(60deg) skewY(-60deg); -ms-transform: rotate(60deg) skewY(-60deg); transform: rotate(60deg) skewY(-60deg); } li:nth-child(3) { -webkit-transform: rotate(120deg) skewY(-60deg); -ms-transform: rotate(120deg) skewY(-60deg); transform: rotate(120deg) skewY(-60deg); } li:nth-child(4) { -webkit-transform: rotate(180deg) skewY(-60deg); -ms-transform: rotate(180deg) skewY(-60deg); transform: rotate(180deg) skewY(-60deg); } li:nth-child(5) { -webkit-transform: rotate(240deg) skewY(-60deg); -ms-transform: rotate(240deg) skewY(-60deg); transform: rotate(240deg) skewY(-60deg); } li:nth-child(6) { -webkit-transform: rotate(300deg) skewY(-60deg); -ms-transform: rotate(300deg) skewY(-60deg); transform: rotate(300deg) skewY(-60deg); } li:first-child .text { background: green; } li:nth-child(2) .text { background: tomato; } li:nth-child(3) .text { background: aqua; } li:nth-child(4) .text { background: yellow; } li:nth-child(5) .text { background: orange; } li:nth-child(6) .text { background: purple; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;ul class="circle"&gt; &lt;li&gt; &lt;div class="text"&gt;1&lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;div class="text"&gt;2&lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;div class="text"&gt;3&lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;div class="text"&gt;4&lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;div class="text"&gt;5&lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;div class="text"&gt;6&lt;/div&gt; &lt;/li&gt; &lt;/ul&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74538554, "author": "Ouroborus", "author_id": 367865, "author_profile": "https://Stackoverflow.com/users/367865", "pm_score": 2, "selected": false, "text": "skewY li skewY(-30deg) li:first-child {\n transform: rotate(0deg) skewY(-30deg);\n}\nli:nth-child(2) {\n transform: rotate(60deg) skewY(-30deg);\n}\nli:nth-child(3) {\n transform: rotate(120deg) skewY(-30deg);\n}\nli:nth-child(4) {\n transform: rotate(180deg) skewY(-30deg);\n}\nli:nth-child(5) {\n transform: rotate(240deg) skewY(-30deg);\n}\nli:nth-child(6) {\n transform: rotate(300deg) skewY(-30deg);\n}\n transform padding-top .text .text {\n transform: skewY(30deg) rotate(30deg);\n padding-top: 15px;\n}\n -webkit-transform -ms-transform" }, { "answer_id": 74538560, "author": "Paulo Santos", "author_id": 44375, "author_profile": "https://Stackoverflow.com/users/44375", "pm_score": 3, "selected": true, "text": ".circle {\n position: relative;\n border: 1px solid black;\n padding: 0;\n margin: 1em auto;\n width: 20em;\n height: 20em;\n border-radius: 50%;\n list-style: none;\n overflow: hidden;\n}\nli {\n overflow: hidden;\n position: absolute;\n top: 0; right: 0;\n width: 50%; height: 50%;\n transform-origin: 0% 100%; \n}\n.text {\n position: absolute;\n left: -100%;\n width: 200%; height: 200%;\n text-align: center;\n -webkit-transform: skewY(30deg) rotate(15deg);\n -ms-transform: skewY(30deg) rotate(15deg);\n transform: skewY(30deg) rotate(15deg);\n padding-top: 20px;\n}\n\nli:first-child {\n -webkit-transform: rotate(0deg) skewY(-30deg);\n -ms-transform: rotate(0deg) skewY(-30deg);\n transform: rotate(0deg) skewY(-30deg); \n}\nli:nth-child(2) {\n -webkit-transform: rotate(60deg) skewY(-30deg);\n -ms-transform: rotate(60deg) skewY(-30deg);\n transform: rotate(60deg) skewY(-30deg); \n}\nli:nth-child(3) {\n -webkit-transform: rotate(120deg) skewY(-30deg);\n -ms-transform: rotate(120deg) skewY(-30deg);\n transform: rotate(120deg) skewY(-30deg); \n}\nli:nth-child(4) {\n -webkit-transform: rotate(180deg) skewY(-30deg);\n -ms-transform: rotate(180deg) skewY(-30deg);\n transform: rotate(180deg) skewY(-30deg); \n}\nli:nth-child(5) {\n -webkit-transform: rotate(240deg) skewY(-30deg);\n -ms-transform: rotate(240deg) skewY(-30deg);\n transform: rotate(240deg) skewY(-30deg); \n}\nli:nth-child(6) {\n -webkit-transform: rotate(300deg) skewY(-30deg);\n -ms-transform: rotate(300deg) skewY(-30deg);\n transform: rotate(300deg) skewY(-30deg); \n}\n\nli:first-child .text {\n background: green; \n}\nli:nth-child(2) .text {\n background: tomato; \n}\nli:nth-child(3) .text {\n background: aqua; \n}\nli:nth-child(4) .text {\n background: yellow; \n}\nli:nth-child(5) .text {\n background: orange; \n}\nli:nth-child(6) .text {\n background: purple; \n} <ul class=\"circle\">\n <li><div class=\"text\">1</div></li>\n <li><div class=\"text\">2</div></li>\n <li><div class=\"text\">3</div></li>\n <li><div class=\"text\">4</div></li>\n <li><div class=\"text\">5</div></li>\n <li><div class=\"text\">6</div></li>\n</ul>" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3042018/" ]
74,538,373
<p>I'm trying to understand why this is invalid but googling hasn't lead me to any answers so I'm hoping somebody can point me in the right direction here.</p> <pre><code>const latestTotal: number | { x: any; y: any; fillColor?: string | undefined; strokeColor?: string | undefined; meta?: any; goals?: any; } | [number, number | null] | [number, (number | null)[]] | null | undefined console.log(latestTotal.y) // Property 'y' does not exist on type 'number | { x: any; y: any; fillColor?: string | undefined; strokeColor?: string | undefined; meta?: any; goals?: any; } | [number, number | null] | [number, (number | null)[]]'. Property 'y' does not exist on type 'number' </code></pre> <p>Shouldn't it look at the object definition instead of the number definition? This def is from a library so I can't change it. Can anybody paint me a picture here?</p>
[ { "answer_id": 74538422, "author": "MalwareMoon", "author_id": 20241005, "author_profile": "https://Stackoverflow.com/users/20241005", "pm_score": 2, "selected": false, "text": "number | {...} // I have made interface from that object\ninterface chart {\n x: any;\n y: any;\n fillColor?: string | undefined;\n strokeColor?: string | undefined;\n meta?: any;\n goals?: any;\n}\n// You were using \":\" to give variable a value. : Is used to give it type\nvar latestTotal: number | chart | [number, number | null] |[number, (number | null)[]] | null | undefined = {\n x: 0,\n y: 0\n}\n\nif (typeof latestTotal === \"object\") {\n console.log(latestTotal.y)\n}\n\n const var const const" }, { "answer_id": 74538532, "author": "Tabish Mohammed", "author_id": 17244086, "author_profile": "https://Stackoverflow.com/users/17244086", "pm_score": -1, "selected": false, "text": "const let" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/796611/" ]
74,538,402
<p>I want to edit an HTML document and parse some text using Beautifulsoup. I'm interested in <code>&lt;span&gt;</code> tags but the ones that are NOT inside a <code>&lt;table&gt;</code> element. I want to skip all tables when finding the <code>&lt;span&gt;</code> elements.</p> <p>I've tried to find all <code>&lt;span&gt;</code> elements first and then filter out the ones that have <code>&lt;table&gt;</code> in any parent level. Here is the code. But this is too slow.</p> <pre><code>for tag in soup.find_all('span'): ancestor_tables = [x for x in tag.find_all_previous(name='table')] if len(ancestor_tables) &gt; 0: continue text = tag.text </code></pre> <p>Is there a more efficient alternative? Is it possible to 'hide' / skip tags while searching for <code>&lt;span&gt;</code> in <code>find_all</code> method?</p>
[ { "answer_id": 74538468, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 0, "selected": false, "text": ".find_parent() for tag in soup.find_all(\"span\"):\n if tag.find_parent(\"table\"):\n continue\n # we are not inside <table>\n # ...\n" }, { "answer_id": 74538506, "author": "psychicesp", "author_id": 13741789, "author_profile": "https://Stackoverflow.com/users/13741789", "pm_score": 3, "selected": true, "text": "\nfor table in soup.find_all(\"table\"):\n table.extract()\n\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4029467/" ]
74,538,403
<p>I have a function that takes in a slice. What I want to do is to check if the end value in this slice is equal to -1. If that is the case, I want to reset the slice to another value. I can't find supporting documentation and do not know how to proceed.</p> <pre><code>datalist=[None, 'Grey', 'EE20-700', 'EE-42-01', 'EE15-767', 'EE0-70650', 'B&amp;B', 1, 1, 1, 1, 1, '300R', True, 'Nov. 2, 2022', 'Nov. 2, 2022', 1, 1, 1, True, 3] #If we just apply the given slice_dimensions, the following happens: slice_dimensions=slice(1, -1) datalist[slice_dimensions] ['Grey', 'EE20-700', 'EE-42-01', 'EE15-767', 'EE0-70650', 'B&amp;B', 1, 1, 1, 1, 1, '300R', True, 'Nov. 2, 2022', 'Nov. 2, 2022', 1, 1, 1, True] </code></pre> <p>As you can see this is problematic, because the last element of my list (3) is omitted with the current slice dimension. I have seen many solutions saying I should use len(datalist)-1 or something similar instead, but this is not a workable option because the list lengths differ, and I want to keep it simple. If we can just check if end of slice is equal to -1 and change it to None, the problem is solved:</p> <pre><code>#If we just apply the given slice_dimensions, the following happens: slice_dimensions=slice(1, None) datalist[slice_dimensions] ['Grey', 'EE20-700', 'EE-42-01', 'EE15-767', 'EE0-70650', 'B&amp;B', 1, 1, 1, 1, 1, '300R', True, 'Nov. 2, 2022', 'Nov. 2, 2022', 1, 1, 1, True, 3] </code></pre> <p>I would like to make a function to do so, but do not know how to proceed, something like this:</p> <pre><code>def slicer(slice_dimensions): if slice_dimensions[1] == -1: #This part I do not know how to proceed slice_dimensions= slice(1, None) data_of_interest=datalist[slice_dimensions] return(data_of_interest) </code></pre> <p>How should I proceed in doing so?</p>
[ { "answer_id": 74538544, "author": "SUTerliakov", "author_id": 14401160, "author_profile": "https://Stackoverflow.com/users/14401160", "pm_score": 1, "selected": false, "text": "slice start stop step def slicer(objects, slice_dimensions):\n if slice_dimensions.end == -1:\n # Create a copy slice with end replaced with None\n slice_dimensions = slice(slice_dimensions.start, None, slice_dimensions.step)\n return objects[slice_dimensions]\n indices (start, stop, step) None" }, { "answer_id": 74538570, "author": "Barmar", "author_id": 1491895, "author_profile": "https://Stackoverflow.com/users/1491895", "pm_score": 3, "selected": true, "text": "slice() def nonwrapping_slice(start=0, stop=None, stride=1):\n if stop is not None and stop < 0 and stride > 0:\n stop = None\n return slice(start, stop, stride)\n nonwrapping_slice(1, -1) slice(1, None, 1)" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9536233/" ]
74,538,404
<p>I want to select a word or more words of the input and click push button to replace the selected portion of the string with an underscore.</p> <p>This is not complete code but gives you the idea somehow:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const blankInput = document.getElementById('blank-input'); const dictatePush = document.querySelector('.dictate-push'); dictatePush.addEventListener('click', (e) =&gt; { const start = blankInput.selectionStart; const finish = blankInput.selectionEnd + 1; blankInput.value = blankInput.value.substring(0, start) + '_'; });</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>input { width: 50vw; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;input data-collect="blank" id="blank-input" type="text" value="Select (highlight) a word and click Push"&gt; &lt;button type="button" class="dictate-push"&gt;Push&lt;/button&gt;</code></pre> </div> </div> </p> <p>So if you type <code>I think I might need a car</code> and select the <code>might</code> as a word after clicking push we should get this:</p> <p><code>I think I _ need a car</code></p> <ol> <li>Note that we want it clean so if you select the exact word or select the word and surrounding spaces we should still get the same result.</li> <li>we want to return the replaced word too, here it's <code>might</code></li> </ol> <p>How would you do this ?</p>
[ { "answer_id": 74538552, "author": "Pipe", "author_id": 1172363, "author_profile": "https://Stackoverflow.com/users/1172363", "pm_score": 3, "selected": true, "text": "const blankInput = document.getElementById('blank-input');\nconst dictatePush = document.querySelector('.dictate-push');\n\n\ndictatePush.addEventListener('click', (e) => {\n const value = blankInput.value;\n const start = blankInput.selectionStart;\n const finish = blankInput.selectionEnd;\n if(start !== finish) { //There is a selection\n\n const removedWord = value.substring(start, finish).trim();\n const substringStart = value.substring(0, start).trimEnd();\n const substringEnd = value.substring(finish).trimStart();\n console.log(\"Result:\", substringStart + \" _ \" + substringEnd); \n console.log(\"Removed Word:\", removedWord);\n }\n\n \n}); <input data-collect=\"blank\" id=\"blank-input\" type=\"text\">\n<button type=\"button\" class=\"dictate-push\">Push</button>" }, { "answer_id": 74538612, "author": "Sweet Chilly Philly", "author_id": 2551591, "author_profile": "https://Stackoverflow.com/users/2551591", "pm_score": 1, "selected": false, "text": "_ const blankInput = document.getElementById('blank-input');\nconst dictatePush = document.querySelector('.dictate-push');\n\ndictatePush.addEventListener('click', (e) => {\n blankInput.value = blankInput.value.replace(window.getSelection().toString(), \" _ \");\n blankInput.value = blankInput.value.replace(\" \", \" \");\n}); input {\n width: 50vw;\n} <input data-collect=\"blank\" id=\"blank-input\" type=\"text\" value=\"Select (highlight) a word and click Push\">\n<button type=\"button\" class=\"dictate-push\">Push</button>" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10715551/" ]
74,538,427
<p><strong>i'm trying to solve this problem:</strong></p> <p>I've 3 percentage (%) stored in three callers: (Caller1, Caller2 and Caller3) like this:</p> <pre><code>$callers = [ 'Caller1' =&gt; 50, 'Caller2' =&gt; 30, 'Caller3' =&gt; 20 ]; </code></pre> <p>and I've ten <code>numbers</code> to call, i want to assign the numbers to each caller based on their percentage.</p> <p><strong>Example:</strong></p> <p>if numbers are (1, 2, 3 ,4 ,5 ,6 ,7 ,8,9,10), then the calls should be split like the bellow <strong>sequence</strong> based on their percentage (Note: like the below sequence):</p> <ul> <li>Caller1: 1,4,7,9,10</li> <li>Caller2: 2,5,8</li> <li>Caller3: 3,6</li> </ul> <p><strong>my code like this:</strong></p> <pre><code>class MyClassName { // Each caller with their call percentage private $callers = [ 'caller1' =&gt; 50, 'caller2' =&gt; 30, 'caller3' =&gt; 20 ]; public $caller1 = array(); public $caller2 = array(); public $caller3 = array(); public function splitCalls(array $numbers) { //count numbers //get spesific number of each percentage //loop on numbers and push numbers into 3 arrays based on percentage $count = count($numbers); $callerOneNumbers = floor(($this-&gt;callers['caller1'] / 100) * $count); $callerTwoNumbers = floor(($this-&gt;callers['caller2'] / 100) * $count); $callerThreeNumbers = floor(($this-&gt;callers['caller3'] / 100) * $count); for ($i = 0; $i &lt;= $count; $i++) { if (count($this-&gt;caller1) &lt; $callerOneNumbers) { array_push($this-&gt;caller1, $numbers[$i]); $i++; } if (count($this-&gt;caller2) &lt; $callerTwoNumbers) { array_push($this-&gt;caller2, $numbers[$i]); $i++; } if (count($this-&gt;caller3) &lt; $callerThreeNumbers) { array_push($this-&gt;caller3, $numbers[$i]); $i++; } } } } $obj = new MyClassName; $split = $obj-&gt;splitCalls([1, 2, 3, 4, 5, 6, 7, 8,9,10]); var_dump($obj-&gt;caller1); var_dump($obj-&gt;caller2); var_dump($obj-&gt;caller3); </code></pre> <p><strong>my result like this:</strong></p> <pre><code>array (size=3) 0 =&gt; int 1 1 =&gt; int 5 2 =&gt; int 9 C:\wamp64\www\test.php:102: array (size=3) 0 =&gt; int 2 1 =&gt; int 6 2 =&gt; int 10 C:\wamp64\www\test.php:103: array (size=2) 0 =&gt; int 3 1 =&gt; int 7 </code></pre> <p><strong>but i want like this:</strong></p> <pre><code>array (size=3) 0 =&gt; int 1 1 =&gt; int 4 2 =&gt; int 7 3 =&gt; int 9 4 =&gt; int 10 array (size=2) 0 =&gt; int 2 1 =&gt; int 5 2 =&gt; int 8 array (size=1) 0 =&gt; int 3 1 =&gt; int 6 </code></pre> <p>any help please</p>
[ { "answer_id": 74538515, "author": "Markus Zeller", "author_id": 2645713, "author_profile": "https://Stackoverflow.com/users/2645713", "pm_score": 1, "selected": false, "text": "$distribute = function(array $callers, array $data): array {\n $distribution = array_values(array_map(fn($percentage) => (int) $percentage/100 * count($data), $callers));\n $results = [];\n $index = 0;\n $length = count($callers);\n foreach ($data as $value) {\n $added = false;\n while (!$added) {\n $row = $index % $length;\n if ($distribution[$row] > 0) {\n $results[$row][] = $value;\n $distribution[$row]--;\n $added = true;\n }\n $index++;\n }\n }\n\n return array_combine(array_keys($callers), $results);\n};\n\necho json_encode($distribute(['Caller1' => 50, 'Caller2' => 30, 'Caller3' => 20], range(1,10)));\n {\"Caller1\":[1,4,7,9,10],\"Caller2\":[2,5,8],\"Caller3\":[3,6]}\n" }, { "answer_id": 74538614, "author": "Nigel Ren", "author_id": 1213708, "author_profile": "https://Stackoverflow.com/users/1213708", "pm_score": 2, "selected": false, "text": "$i++ for() for ($i = 0; $i < $count;) {\n round floor" }, { "answer_id": 74553283, "author": "mickmackusa", "author_id": 2943403, "author_profile": "https://Stackoverflow.com/users/2943403", "pm_score": 1, "selected": false, "text": "function splitCallers($callers, $numbers) {\n $count = count($numbers);\n $limits = array_map(\n fn($v) => (int) $count * $v / 100,\n $callers\n );\n\n $result = [];\n while ($limits && $numbers) {\n foreach ($limits as $caller => &$limit) {\n if (!$limit) {\n unset($limits[$caller]);\n continue;\n }\n if (!$numbers) {\n break;\n }\n --$limit;\n $result[$caller][] = array_shift($numbers);\n }\n }\n return $result;\n}\nvar_export(splitCallers($callers, range(1, 10)));\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14225902/" ]
74,538,433
<p>I recently converted my Storyboard SpriteKit WatchOS app from Storyboards to SwiftUI, in one part of my code I use the <code>WKInterfaceSKScene.texture</code> method to render some <code>SKNodes</code> to a texture for use later on in my game.</p> <p>Unfortunately after the conversion you no longer have a <code>WKInterfaceSKScene</code> object as part of the view, but I realized that I can just create one using the <code>WKInterfaceSKScene.init() </code>initializer, this seems to work great, however, the init initializer is now deprecated and I assume will be removed in a future WatchOS version.</p> <p>The warning is:</p> <blockquote> <p>'init()' was deprecated in watchOS 7.0: Use SpriteKit.SpriteView instead.</p> </blockquote> <p>Unfortunately SpriteView does not seem to have a similar method to render an <code>SKNode</code> to a texture.</p> <p>I tried finding a different way of rendering <code>SKNodes</code> to a texture without using the <code>WKInterfaceSKScene</code> object but can’t find one, does anybody know how to do this on watchOS 9 without utilizing deprecated functionality?</p> <p>WKInterfaceSKScene init() - <a href="https://developer.apple.com/documentation/watchkit/wkinterfaceskscene/3141929-init" rel="nofollow noreferrer">https://developer.apple.com/documentation/watchkit/wkinterfaceskscene/3141929-init</a></p> <p>WKInterfaceSKScene texture() - <a href="https://developer.apple.com/documentation/watchkit/wkinterfaceskscene/1650802-texture" rel="nofollow noreferrer">https://developer.apple.com/documentation/watchkit/wkinterfaceskscene/1650802-texture</a></p> <p>Thank you.</p>
[ { "answer_id": 74538515, "author": "Markus Zeller", "author_id": 2645713, "author_profile": "https://Stackoverflow.com/users/2645713", "pm_score": 1, "selected": false, "text": "$distribute = function(array $callers, array $data): array {\n $distribution = array_values(array_map(fn($percentage) => (int) $percentage/100 * count($data), $callers));\n $results = [];\n $index = 0;\n $length = count($callers);\n foreach ($data as $value) {\n $added = false;\n while (!$added) {\n $row = $index % $length;\n if ($distribution[$row] > 0) {\n $results[$row][] = $value;\n $distribution[$row]--;\n $added = true;\n }\n $index++;\n }\n }\n\n return array_combine(array_keys($callers), $results);\n};\n\necho json_encode($distribute(['Caller1' => 50, 'Caller2' => 30, 'Caller3' => 20], range(1,10)));\n {\"Caller1\":[1,4,7,9,10],\"Caller2\":[2,5,8],\"Caller3\":[3,6]}\n" }, { "answer_id": 74538614, "author": "Nigel Ren", "author_id": 1213708, "author_profile": "https://Stackoverflow.com/users/1213708", "pm_score": 2, "selected": false, "text": "$i++ for() for ($i = 0; $i < $count;) {\n round floor" }, { "answer_id": 74553283, "author": "mickmackusa", "author_id": 2943403, "author_profile": "https://Stackoverflow.com/users/2943403", "pm_score": 1, "selected": false, "text": "function splitCallers($callers, $numbers) {\n $count = count($numbers);\n $limits = array_map(\n fn($v) => (int) $count * $v / 100,\n $callers\n );\n\n $result = [];\n while ($limits && $numbers) {\n foreach ($limits as $caller => &$limit) {\n if (!$limit) {\n unset($limits[$caller]);\n continue;\n }\n if (!$numbers) {\n break;\n }\n --$limit;\n $result[$caller][] = array_shift($numbers);\n }\n }\n return $result;\n}\nvar_export(splitCallers($callers, range(1, 10)));\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/738380/" ]
74,538,449
<p>I have a question on how pdf file size scales.</p> <p>I noticed that when I produce single page pdfs from a given pdf, then the file size is almost always approximately half of the size of the original file. (See attached.) My question is:</p> <ol> <li>Why is this the case? This seems to suggest that the non-text information (e.g. styling) takes up more than half of the pdf file size.</li> <li>Is there any tricks to &quot;compressing&quot; pdfs so that it has smaller memory?</li> </ol> <p>Figures: For both figures, the pdf with the long name (2211.11725.pdf and 2211.11712.pdf) is the original document, and were produced by print -&gt; save as pdf on MacOS Monterey Ver 12.4.</p> <p>Original documents:</p> <ul> <li><a href="https://arxiv.org/pdf/2211.11725.pdf" rel="nofollow noreferrer">Thurston Norm and Euler Classes of Tight Contact Structures</a></li> <li><a href="https://arxiv.org/pdf/2211.11712.pdf" rel="nofollow noreferrer">Symplectic Morse Theory I</a></li> </ul> <p><a href="https://i.stack.imgur.com/nbsXl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nbsXl.png" alt="enter image description here" /></a> <a href="https://i.stack.imgur.com/E4GiE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E4GiE.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74538515, "author": "Markus Zeller", "author_id": 2645713, "author_profile": "https://Stackoverflow.com/users/2645713", "pm_score": 1, "selected": false, "text": "$distribute = function(array $callers, array $data): array {\n $distribution = array_values(array_map(fn($percentage) => (int) $percentage/100 * count($data), $callers));\n $results = [];\n $index = 0;\n $length = count($callers);\n foreach ($data as $value) {\n $added = false;\n while (!$added) {\n $row = $index % $length;\n if ($distribution[$row] > 0) {\n $results[$row][] = $value;\n $distribution[$row]--;\n $added = true;\n }\n $index++;\n }\n }\n\n return array_combine(array_keys($callers), $results);\n};\n\necho json_encode($distribute(['Caller1' => 50, 'Caller2' => 30, 'Caller3' => 20], range(1,10)));\n {\"Caller1\":[1,4,7,9,10],\"Caller2\":[2,5,8],\"Caller3\":[3,6]}\n" }, { "answer_id": 74538614, "author": "Nigel Ren", "author_id": 1213708, "author_profile": "https://Stackoverflow.com/users/1213708", "pm_score": 2, "selected": false, "text": "$i++ for() for ($i = 0; $i < $count;) {\n round floor" }, { "answer_id": 74553283, "author": "mickmackusa", "author_id": 2943403, "author_profile": "https://Stackoverflow.com/users/2943403", "pm_score": 1, "selected": false, "text": "function splitCallers($callers, $numbers) {\n $count = count($numbers);\n $limits = array_map(\n fn($v) => (int) $count * $v / 100,\n $callers\n );\n\n $result = [];\n while ($limits && $numbers) {\n foreach ($limits as $caller => &$limit) {\n if (!$limit) {\n unset($limits[$caller]);\n continue;\n }\n if (!$numbers) {\n break;\n }\n --$limit;\n $result[$caller][] = array_shift($numbers);\n }\n }\n return $result;\n}\nvar_export(splitCallers($callers, range(1, 10)));\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14727615/" ]
74,538,462
<p>Im making a code that gets the user input and put then in descending order, but i need help in this part, to put the user input into a array, the much input the user make, only stopping when '-1' is typed. Here is the code:</p> <pre><code> int []vet = new int[]{}; for(int i = 0; i != -1;i++) { Console.WriteLine(&quot;digite os valores&quot;); int input = int.Parse(Console.ReadLine()); vet[i] = input; } </code></pre> <p>This code generates this error: &quot;Unhandled exception. System.IndexOutOfRangeException: Index was outside the bounds of the array.&quot;</p>
[ { "answer_id": 74538651, "author": "DevyBoiii", "author_id": 16861861, "author_profile": "https://Stackoverflow.com/users/16861861", "pm_score": 2, "selected": false, "text": "List<int> System.Collections.Generic" }, { "answer_id": 74538839, "author": "Jonathan Barraone", "author_id": 17957703, "author_profile": "https://Stackoverflow.com/users/17957703", "pm_score": 2, "selected": true, "text": "List<int> vet = new List<int>();\nint Response = 0;\n\nConsole.WriteLine(\"digite os valores\");\nResponse = int.Parse(Console.ReadLine());\nvet.Add(Response);\n\nwhile (Response != -1)\n{\n Console.WriteLine(\"digite os valores\");\n Response = int.Parse(Console.ReadLine());\n vet.Add(Response);\n}\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15391900/" ]
74,538,496
<p>I'm wondering why my <code>ExposedDropdownMenuBox</code> doesn't recomposed when the parent composable function parameters value changed.</p> <pre><code>@Composable private fun Title( isTitleEnabled: Boolean ) { ... ExposedDropdownMenuBox( expanded = expanded, onExpandedChange = { if (isTitleEnabled){ expanded = !expanded } } ){...} } </code></pre> <p>So why isTitleEnable value changed but ExposedDropdownMenuBox does not recomposed?</p> <p>What I tried for now to solve the issue is to create a variable state then change it before passing it to the composable.</p> <p>So my code after the changes looks something like this.</p> <pre><code>@Composable private fun Title( isTitleEnabled: Boolean ) { ... var titleEnabled by remember { mutableStateOf(isTitleEnabled) } titleEnabled = isTitleEnabled ExposedDropdownMenuBox( expanded = expanded, onExpandedChange = { if (titleEnabled){ expanded = !expanded } } ){...} } </code></pre> <p>After these changes my ExposedDropdownMenuBox recomposed, but I'm wondering why it doesn't before adding the state variable.</p>
[ { "answer_id": 74542861, "author": "Subfly", "author_id": 10840292, "author_profile": "https://Stackoverflow.com/users/10840292", "pm_score": 2, "selected": false, "text": "LaunchedEffect(isTitleEnabled) {\n if (isTitleEnabled) expanded = !expanded\n}\n" }, { "answer_id": 74574217, "author": "Tarik", "author_id": 3307130, "author_profile": "https://Stackoverflow.com/users/3307130", "pm_score": 1, "selected": false, "text": "ExposedDropdownMenuBox isTitleEnabled onExpandedChange State ExposedDropdownMenuBox key(isTitleEnabled) key(isTitleEnabled) {\n ExposedDropdownMenuBox(\n expanded = expanded,\n onExpandedChange = {\n if (isTitleEnabled) {\n expanded = !expanded\n }\n }\n ) {...}\n}\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538496", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11078931/" ]
74,538,501
<pre><code>arr = ['Jack', 'Ross', 'Buggi', 'Mimi', 'Zolo', 'Roy'] </code></pre> <p>From this array if want to remove certain values like lets say Buggi and Zolo, how can I do that so that the arr looks something like</p> <pre><code>arr = ['Jack', 'Ross', 'Mimi', 'Roy'] </code></pre> <p>Buggie and Zolo are just examples, it can be any element Ross, Roy.</p> <p>I want to implement this in rails.</p>
[ { "answer_id": 74538527, "author": "Code-Apprentice", "author_id": 1440565, "author_profile": "https://Stackoverflow.com/users/1440565", "pm_score": 2, "selected": true, "text": "arr.filter()" }, { "answer_id": 74540184, "author": "TonyArra", "author_id": 81216, "author_profile": "https://Stackoverflow.com/users/81216", "pm_score": 0, "selected": false, "text": "arr = ['Buggi', 'Mimi', 'Zolo', 'Roy'].without('Buggie', 'Zolo')\n without excluding" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12763413/" ]
74,538,507
<p>I have the first year as <code>2007</code>. The last year is <code>2021</code></p> <p>I need to create a character vector just like the vector bellow:</p> <pre><code>c(&quot;2007-2008&quot;,&quot;2007-2010&quot;,&quot;2007-2012&quot;,&quot;2007-2014&quot;,&quot;2007-2016&quot;,&quot;2007-2018&quot;,&quot;2007-2021&quot;) </code></pre> <p>The idea is to have: <code>first-year -second year</code>, <code>first-year - first-year+3</code>, <code>first-year - first-year+5</code>, <code>first-year - first-year+7</code>, <code>first-year - first-year+9</code>, <code>first-year - first-year+11</code>, <code>first-year - first-year+13</code> But when I have <code>first-year - first-year+13</code> and the next step is bigger than the last year (<code>2021</code>) I consider <code>first-year - lastyear</code></p> <p>In other words the difference between the last years should be at least 2 (2008....2010...2012...2014..2016...2018...2020) But once I have 2020 it will lead the next interval <code>2007-2021</code> have a difference of 1 year, if this happens I consider <code>2007-2018</code>and <code>2007-2021</code></p> <p>How can I create something like this in R?</p>
[ { "answer_id": 74538527, "author": "Code-Apprentice", "author_id": 1440565, "author_profile": "https://Stackoverflow.com/users/1440565", "pm_score": 2, "selected": true, "text": "arr.filter()" }, { "answer_id": 74540184, "author": "TonyArra", "author_id": 81216, "author_profile": "https://Stackoverflow.com/users/81216", "pm_score": 0, "selected": false, "text": "arr = ['Buggi', 'Mimi', 'Zolo', 'Roy'].without('Buggie', 'Zolo')\n without excluding" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20359538/" ]
74,538,558
<p>I am new to coding and I have a Json file, locally stored. I have accessed the file but when I store the Json data in a list, it throws a binding error. Any help is highly appreciated.</p> <pre><code>Future&lt;void&gt; readJson() async { final response = await rootBundle.loadString('assets/json/units.json'); final data = await json.decode(response); setState(() { List jsonList = data[&quot;length&quot;]; print(jsonList); }); } </code></pre> <p>here this is how the json data look like.</p> <pre><code>{ &quot;length&quot; : [ { &quot;name&quot;: &quot;Meter&quot;, &quot;conversion&quot;: 1.0, &quot;base_unit&quot;: true }, { &quot;name&quot;: &quot;Millimeter&quot;, &quot;conversion&quot;: 1000.0 }, { &quot;name&quot;: &quot;Centimeter&quot;, &quot;conversion&quot;: 100.0 } ] } </code></pre> <p>I have tried many things but nothing has worked so far.</p>
[ { "answer_id": 74538826, "author": "Mohsen Mohamed", "author_id": 3130386, "author_profile": "https://Stackoverflow.com/users/3130386", "pm_score": 0, "selected": false, "text": "jsonList = (data[\"length\"] as List).map((e)=>e[\"conversion\"]).toList();\n" }, { "answer_id": 74538906, "author": "eamirho3ein", "author_id": 10306997, "author_profile": "https://Stackoverflow.com/users/10306997", "pm_score": 3, "selected": true, "text": "data List List jsonList = data[\"length\"] as List;\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9702001/" ]
74,538,568
<p>So How to merge values of a Json object like this: <code>{&quot;zz0&quot;: &quot;value 1&quot;,&quot;zz1&quot;: &quot;value 2&quot;,&quot;zz2&quot;: &quot;value 3&quot;}</code> into this: <code>{&quot;key&quot;:[&quot;value 1&quot;,&quot;value 2&quot;,&quot;value 3&quot;]}</code> In my javascript form this is the first Json file:</p> <pre><code> [ { &quot;fotos&quot;: [ { &quot;foto&quot;: &quot;foto 1&quot;, &quot;zz0&quot;: &quot;first line.&quot;, &quot;zz1&quot;: &quot;second line.&quot;, &quot;zz2&quot;: &quot;third line.&quot; }, { &quot;foto&quot;: &quot;foto 2&quot;, &quot;zz0&quot;: &quot;first line.&quot; } ] } ] </code></pre> <p>And this is the second Json File:</p> <pre><code> [ { &quot;fotos&quot;: [ { &quot;foto&quot;: [&quot;foto 1&quot;], &quot;tekst&quot;: [&quot;first line.&quot;, &quot;second line.&quot;, &quot;third line.&quot;] }, { &quot;foto&quot;: [&quot;foto 2&quot;], &quot;tekst&quot;: [&quot;first line.&quot;] } ] } ] </code></pre> <p>Searched a solution with map and arrow functions but got stuck... Any idea?</p>
[ { "answer_id": 74538810, "author": "Asraf", "author_id": 20361860, "author_profile": "https://Stackoverflow.com/users/20361860", "pm_score": 3, "selected": true, "text": "const arr = [{ \"fotos\": [{ \"foto\": \"foto 1\", \"zz0\": \"first line.\", \"zz1\": \"second line.\", \"zz2\": \"third line.\" }, { \"foto\": \"foto 2\", \"zz0\": \"first line.\" }]}];\n\nconst ans = arr.map(({fotos}) => ({fotos: fotos.map(({foto, ...res}) =>({foto: [foto], tekst: Object.values(res)}))}));\n\nconsole.log(ans);" }, { "answer_id": 74538855, "author": "slowloris", "author_id": 20571507, "author_profile": "https://Stackoverflow.com/users/20571507", "pm_score": 0, "selected": false, "text": "const a = {a: 2, b: 3, c: 4}\nObject.keys(a).reduce((acc, key) => {\n acc['key'].push(a[key])\n return acc\n}, {'key': []})\n {'key': [2, 3, 4]}" }, { "answer_id": 74538944, "author": "GrafiCode", "author_id": 5334486, "author_profile": "https://Stackoverflow.com/users/5334486", "pm_score": 1, "selected": false, "text": "Array.map() Object.keys() Array.reduce() const data = [{\n \"fotos\": [{\n \"foto\": \"foto 1\",\n \"zz0\": \"first line.\",\n \"zz1\": \"second line.\",\n \"zz2\": \"third line.\"\n },\n {\n \"foto\": \"foto 2\",\n \"zz0\": \"first line.\"\n }\n ]\n}]\n\nconst res = data[0].fotos.map(obj => {\n const tekst = Object.keys(obj).reduce((acc,key) => {\n if (key != 'foto') { acc.push(obj[key]) }\n return acc\n }, [])\n \n return { foto: [obj.foto], tekst: tekst }\n})\n\nconsole.log(res)" }, { "answer_id": 74538951, "author": "Carsten Massmann", "author_id": 2610061, "author_profile": "https://Stackoverflow.com/users/2610061", "pm_score": 1, "selected": false, "text": "const dat=[\n {\n \"fotos\": [\n {\n \"foto\": \"foto 1\",\n \"zz0\": \"first line.\",\n \"zz1\": \"second line.\",\n \"zz2\": \"third line.\"\n },\n {\n \"foto\": \"foto 2\",\n \"zz0\": \"first line.\"\n }\n ]\n }\n];\n\nconst res=dat[0].fotos.map(f=>({foto:f.foto,key:Object.entries(f).filter(a=>a[0]!='foto').map(a=>a[1])}));\n\nconsole.log(res);" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6867033/" ]
74,538,578
<p>I am trying to change the contentY of customerList inside the <strong>checkB.onClicked</strong> function. However I get the &quot;<strong>ReferenceError: customerList is not defined</strong>&quot; error on the <strong>customerList.contentY=oldY;</strong> line and that line only.</p> <p>customerList is found in every other line inside that function and they work fine. However, I cannot edit the contentY.</p> <p>The reason why I am trying to edit the contentY is that when I do customerList.model.select(); the customerList gets updated and gets positioned at the start but I do not want that. How can I fix this?</p> <pre><code> ListView{ id:customerList Layout.preferredHeight: 452 Layout.preferredWidth: parent.width Layout.fillHeight: true clip: true spacing:0 model: myListModel delegate: CustomerListDelegate{ id:listDelegate checkB.checked: model.checked===&quot;true&quot; ? true : false isCheckAvailable: true width: customerList.width height: 64 customerProfileImageSource: imageSource customerName: name customerDate: date customerTotalPd: totalPd customerPanto: panto customerVertex: vertex customerLensType: lensType itemIndex: index checkB.onClicked: { var oldY=customerList.contentY; if(checkB.checked==true) myListModel.checkCustomer(index); else myListModel.uncheckCustomer(index); customerList.model.select(); customerList.contentY=oldY; } } } </code></pre>
[ { "answer_id": 74538810, "author": "Asraf", "author_id": 20361860, "author_profile": "https://Stackoverflow.com/users/20361860", "pm_score": 3, "selected": true, "text": "const arr = [{ \"fotos\": [{ \"foto\": \"foto 1\", \"zz0\": \"first line.\", \"zz1\": \"second line.\", \"zz2\": \"third line.\" }, { \"foto\": \"foto 2\", \"zz0\": \"first line.\" }]}];\n\nconst ans = arr.map(({fotos}) => ({fotos: fotos.map(({foto, ...res}) =>({foto: [foto], tekst: Object.values(res)}))}));\n\nconsole.log(ans);" }, { "answer_id": 74538855, "author": "slowloris", "author_id": 20571507, "author_profile": "https://Stackoverflow.com/users/20571507", "pm_score": 0, "selected": false, "text": "const a = {a: 2, b: 3, c: 4}\nObject.keys(a).reduce((acc, key) => {\n acc['key'].push(a[key])\n return acc\n}, {'key': []})\n {'key': [2, 3, 4]}" }, { "answer_id": 74538944, "author": "GrafiCode", "author_id": 5334486, "author_profile": "https://Stackoverflow.com/users/5334486", "pm_score": 1, "selected": false, "text": "Array.map() Object.keys() Array.reduce() const data = [{\n \"fotos\": [{\n \"foto\": \"foto 1\",\n \"zz0\": \"first line.\",\n \"zz1\": \"second line.\",\n \"zz2\": \"third line.\"\n },\n {\n \"foto\": \"foto 2\",\n \"zz0\": \"first line.\"\n }\n ]\n}]\n\nconst res = data[0].fotos.map(obj => {\n const tekst = Object.keys(obj).reduce((acc,key) => {\n if (key != 'foto') { acc.push(obj[key]) }\n return acc\n }, [])\n \n return { foto: [obj.foto], tekst: tekst }\n})\n\nconsole.log(res)" }, { "answer_id": 74538951, "author": "Carsten Massmann", "author_id": 2610061, "author_profile": "https://Stackoverflow.com/users/2610061", "pm_score": 1, "selected": false, "text": "const dat=[\n {\n \"fotos\": [\n {\n \"foto\": \"foto 1\",\n \"zz0\": \"first line.\",\n \"zz1\": \"second line.\",\n \"zz2\": \"third line.\"\n },\n {\n \"foto\": \"foto 2\",\n \"zz0\": \"first line.\"\n }\n ]\n }\n];\n\nconst res=dat[0].fotos.map(f=>({foto:f.foto,key:Object.entries(f).filter(a=>a[0]!='foto').map(a=>a[1])}));\n\nconsole.log(res);" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12355161/" ]
74,538,582
<p>I am trying to get PHP to accept the information from a series of checkboxes in a form but when I try to verify/use said data to manipulate other data it isn't there.</p> <pre><code>&lt;p&gt;&lt;input type=&quot;checkbox&quot; name=&quot;toppings[]&quot; value=&quot;xchese&quot;/&gt;Extra Cheese&lt;/p&gt; &lt;p&gt;&lt;input type=&quot;checkbox&quot; name=&quot;toppings[]&quot; value=&quot;xmeat&quot;/&gt;Extra Meat&lt;/p&gt; &lt;p&gt;&lt;input type=&quot;checkbox&quot; name=&quot;toppings[]&quot; value=&quot;veg&quot;/&gt;Vegetarian&lt;/p&gt; </code></pre> <pre><code>if (isset($_POST[&quot;toppings&quot;])) { $toppings = $_POST[&quot;toppings&quot;]; for ($i = 0; $i &lt; count($_POST[&quot;toppings&quot;]); $i++) { printf(&quot;&lt;p&gt;Topping %s&lt;/p&gt;&quot;, $_POST[&quot;toppings&quot;][$i]); if ($toppings[$i] == &quot;xchese&quot;) { $sando_total += 1.50; printf(&quot;&lt;p&gt;Extra Cheese&lt;/p&gt;&quot;); } else if ($toppings[$i] == &quot;xmeat&quot;) { $sando_total += 2.00; printf(&quot;&lt;p&gt;Extra Meat&lt;/p&gt;&quot;); } else if ($toppings[$i] == &quot;veg&quot;) { $sando_total += 2.00; printf(&quot;&lt;p&gt;Vegetarian&lt;/p&gt;&quot;); } } } </code></pre> <p>Main issue happening in the for loop. It detects how many are being checked but not what the values are.</p>
[ { "answer_id": 74538705, "author": "Paulo Santos", "author_id": 44375, "author_profile": "https://Stackoverflow.com/users/44375", "pm_score": -1, "selected": false, "text": "method form GET page.php?toppings=xchese&toppings=xmeat&toppings=veg\n $_POST[\"toppings\"]" }, { "answer_id": 74539395, "author": "Marco", "author_id": 2969320, "author_profile": "https://Stackoverflow.com/users/2969320", "pm_score": 0, "selected": false, "text": "<?php\n \n$sando_total = 0;\n$toppings = filter_input(INPUT_POST, \"toppings\", FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);\n\nif (!empty($toppings)) {\n foreach ($toppings as $item) {\n printf(\"<p>Topping %s</p>\", $item);\n if ($item == \"xchese\") {\n $sando_total += 1.50;\n printf(\"<p>Extra Cheese</p>\");\n } else if ($item == \"xmeat\") {\n $sando_total += 2.00;\n printf(\"<p>Extra Meat</p>\");\n } else if ($item == \"veg\") {\n $sando_total += 2.00;\n printf(\"<p>Vegetarian</p>\");\n }\n }\n}\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20575873/" ]
74,538,595
<p>I have a landing page with a button that is a <code>Link</code> to a <code>Register</code> component but as I click on the button my <code>Register</code> component is being underneath my landing page and not in a new page. Why is this happening?</p> <p>App.js:</p> <pre><code>import './App.css'; import { Fragment } from 'react'; import Navbar from './components/layout/Navbar'; import Landing from './components/layout/Landing'; import Register from './components/auth/Register'; import { BrowserRouter as Router, Route, Routes } from 'react-router-dom'; function App() { return ( &lt;div className=&quot;App&quot;&gt; &lt;Router&gt; &lt;Fragment&gt; &lt;Navbar/&gt; &lt;Landing/&gt; &lt;Routes&gt; &lt;Route path='/register' element={&lt;Register /&gt;} /&gt; &lt;/Routes&gt; &lt;/Fragment&gt; &lt;/Router&gt; &lt;/div&gt; ); } export default App; </code></pre> <p>Register.js:</p> <pre><code>import React from 'react' const Register = () =&gt; { return ( &lt;section className=&quot;container&quot;&gt; &lt;h1 className=&quot;large text-primary&quot;&gt;Sign Up&lt;/h1&gt; &lt;p className=&quot;lead&quot;&gt; &lt;i className=&quot;fas fa-user&quot; /&gt; Create Your Account &lt;/p&gt; &lt;form className=&quot;form&quot; &gt; &lt;div className=&quot;form-group&quot;&gt; &lt;input type=&quot;text&quot; placeholder=&quot;Name&quot; name=&quot;name&quot; /&gt; &lt;/div&gt; &lt;div className=&quot;form-group&quot;&gt; &lt;input type=&quot;email&quot; placeholder=&quot;Email Address&quot; name=&quot;email&quot; /&gt; &lt;small className=&quot;form-text&quot;&gt; This site uses Gravatar so if you want a profile image, use a Gravatar email &lt;/small&gt; &lt;/div&gt; &lt;div className=&quot;form-group&quot;&gt; &lt;input type=&quot;password&quot; placeholder=&quot;Password&quot; name=&quot;password&quot; /&gt; &lt;/div&gt; &lt;div className=&quot;form-group&quot;&gt; &lt;input type=&quot;password&quot; placeholder=&quot;Confirm Password&quot; name=&quot;password2&quot; /&gt; &lt;/div&gt; &lt;input type=&quot;submit&quot; className=&quot;btn btn-primary&quot; value=&quot;Register&quot; /&gt; &lt;/form&gt; &lt;p className=&quot;my-1&quot;&gt; &lt;/p&gt; &lt;/section&gt; ) } export default Register </code></pre> <p>So my <code>/</code> path is a navbar with a landing page component, when i click on the button my path becomes <code>/register</code> but the landing page with the navbar are still being rendered and my register component also but below the others.</p>
[ { "answer_id": 74538742, "author": "Drew Reese", "author_id": 8690857, "author_profile": "https://Stackoverflow.com/users/8690857", "pm_score": 1, "selected": false, "text": "Landing Landing function App() {\n return (\n <div className=\"App\">\n <Router>\n <Navbar />\n <Routes>\n <Route path=\"/\" element={<Landing />} />\n <Route path='/register' element={<Register />} />\n </Routes>\n </Router>\n </div>\n );\n}\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20121254/" ]
74,538,635
<p><strong>EDIT:</strong> I am reading from an Excel Report using ExcelDataReader.DataSet and reading a string cell to convert to DateTime. Added a pic showing where is located the cell with the string</p> <p><a href="https://i.stack.imgur.com/UxvfQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UxvfQ.png" alt="DataTable Visualizer" /></a></p> <pre><code>dataSet = reader.AsDataSet(); DataTable = dataTable = dataSet.Tables[0]; foreach (DataRow fila in dataTable.Rows) { // &quot;Miercoles, 16 de Noviembre de 2022 15:21&quot; string dateString = fila[&quot;Column18&quot;].ToString(); // I remove the hour as is not necessary dateString = dateString.Remove(dateString.Length-7); string format = @&quot;dddd, d \o\f MMMM \o\f yyyy&quot;; var date = DateTime.ParseExact(dateString, format, CultureInfo.CreateSpecificCulture(&quot;en-PY&quot;)); Console.WriteLine(date); } </code></pre> <p>But I get This error format exception:</p> <ul> <li> <pre><code> $exception {&quot;The string 'Miercoles, 16 de Noviembre de 2022 15:21' was not recognized as a valid DateTime. There is an unknown word starting at index '0'.&quot;} System.FormatException </code></pre> </li> </ul>
[ { "answer_id": 74538809, "author": "Olivier Jacot-Descombes", "author_id": 880990, "author_profile": "https://Stackoverflow.com/users/880990", "pm_score": 2, "selected": true, "text": "string s = \"Viernes, 18 de noviembre de 2022\";\n\nvar es = CultureInfo.GetCultureInfo(\"es\");\nif (DateTime.TryParse(s, es, out DateTime date)) {\n Console.WriteLine(date);\n} else {\n Console.WriteLine(\"parse error\");\n}\n \"Miercoles, 16 de Noviembre de 2022 15:21\" var es = CultureInfo.GetCultureInfo(\"es\");\n\nint index = dateString.IndexOf(',');\nif (index >= 0) {\n dateString = dateString.Substring(index + 1);\n}\nif (DateTime.TryParse(dateString, es, out DateTime date)) {\n Console.WriteLine(date);\n} else {\n Console.WriteLine(\"parse error\");\n}\n" }, { "answer_id": 74538834, "author": "D Stanley", "author_id": 1081897, "author_profile": "https://Stackoverflow.com/users/1081897", "pm_score": 2, "selected": false, "text": "of de string dateString = \"Tuesday, 7 of March of 2023\";\n string format = @\"dddd, d \\o\\f MMMM \\o\\f yyyy\";\n var date = DateTime.ParseExact(dateString, format, CultureInfo.CreateSpecificCulture(\"en-US\"));\n Console.WriteLine(date);\n string dateString = \"Martes, 7 de Marzo de 2023\";\nstring format = @\"dddd, d \\d\\e MMMM \\d\\e yyyy\";\nvar date = DateTime.ParseExact(dateString, format, CultureInfo.CreateSpecificCulture(\"es-MX\"));\n \n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20392015/" ]
74,538,645
<p>Is there an effective way to essentially do something else when any exception is thrown in .NET 6?</p> <p>Specifically, this is using Azure Functions v4 if that helps.</p> <p>Essentially, If I have a function that throws due to a Null Reference Exception, is it possible to send an HTTP request before killing the program?</p> <p>IE:</p> <p>C#</p> <pre><code>public async Task&lt;Exception&gt; SendErrorMessage(Exception ex) { _httpClient.PostAsync(&quot;https://myloggingurl.com/&quot;, new StringContent(ex.Message)); return ex; } </code></pre> <p>Essentially writing a solution that throws all exceptions through this method.</p>
[ { "answer_id": 74538707, "author": "Jonathan Barraone", "author_id": 17957703, "author_profile": "https://Stackoverflow.com/users/17957703", "pm_score": -1, "selected": false, "text": "public async Task<Exception> SendErrorMessage(Exception ex)\n {\n try\n {\n _httpClient.PostAsync(\"https://myloggingurl.com/\", new StringContent(ex.Message));\n }\n catch\n {\n throw ex;\n }\n }\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10719288/" ]
74,538,669
<p>Can I use an <code>ngFor</code> instead of repeating <code>&lt;table&gt;</code> two times? NB: I thought to combine all the items into objects as items of a single array of mapping(each object contains a variable, label and value) but it does not work for me)</p> <pre><code>.... this.maxValueTable.push(selectedData.res.maxValue); this.minValueTable.push(selectedData.res.minValue); ... </code></pre> <pre><code>&lt;div style=&quot;display: flex;&quot;&gt; &lt;table style=&quot;width:100%;&quot;&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Max&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr *ngFor=&quot;let maxValue of maxValueTable&quot;&gt; &lt;td&gt; {{ maxValue | numberFormatter: (getUnit() | async)}}&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;table style=&quot;width:100%;&quot;&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Min&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr *ngFor=&quot;let maxValue of minValueTable&quot;&gt; &lt;td&gt; {{ MinValue| numberFormatter: (getUnit() | async)}}&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt; </code></pre>
[ { "answer_id": 74538707, "author": "Jonathan Barraone", "author_id": 17957703, "author_profile": "https://Stackoverflow.com/users/17957703", "pm_score": -1, "selected": false, "text": "public async Task<Exception> SendErrorMessage(Exception ex)\n {\n try\n {\n _httpClient.PostAsync(\"https://myloggingurl.com/\", new StringContent(ex.Message));\n }\n catch\n {\n throw ex;\n }\n }\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18135012/" ]
74,538,710
<p>I use PostgreSQL 14 to work on a <code>student_books</code> table which manages books borrowed by students. Each student can have zero or more books borrowed at any point in time. The table look like this (the order of rows doesn't matter).</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: right;">student_id</th> <th style="text-align: right;">book_id</th> </tr> </thead> <tbody> <tr> <td style="text-align: right;">1</td> <td style="text-align: right;">113</td> </tr> <tr> <td style="text-align: right;">2</td> <td style="text-align: right;">37</td> </tr> <tr> <td style="text-align: right;">5</td> <td style="text-align: right;">94</td> </tr> </tbody> </table> </div> <p>Furthermore, I have an (append-only) <code>library_ledger</code> table with recent transactions at the library. It keeps track of whether a student borrowed or returned a book, and when. The order of rows matters, it's sorted in ascending order on the first <code>date</code> column:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>date</th> <th>action</th> <th style="text-align: right;">student_id</th> <th style="text-align: right;">book_id</th> </tr> </thead> <tbody> <tr> <td>2022-11-20 09:14:09</td> <td>borrow</td> <td style="text-align: right;">2</td> <td style="text-align: right;">3</td> </tr> <tr> <td>2022-11-21 17:43:22</td> <td>return</td> <td style="text-align: right;">1</td> <td style="text-align: right;">113</td> </tr> <tr> <td>2022-11-22 14:03:04</td> <td>borrow</td> <td style="text-align: right;">5</td> <td style="text-align: right;">204</td> </tr> <tr> <td>2022-11-22 14:03:08</td> <td>return</td> <td style="text-align: right;">5</td> <td style="text-align: right;">94</td> </tr> <tr> <td>2022-11-22 14:03:15</td> <td>return</td> <td style="text-align: right;">5</td> <td style="text-align: right;">204</td> </tr> </tbody> </table> </div> <p>Given the <code>student_books</code> and <code>library_ledger</code> tables, I'd like to compute the new set of books borrowed by each student. In the above case, I'd like to get the result set</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: right;">student_id</th> <th style="text-align: right;">book_id</th> </tr> </thead> <tbody> <tr> <td style="text-align: right;">2</td> <td style="text-align: right;">3</td> </tr> <tr> <td style="text-align: right;">2</td> <td style="text-align: right;">37</td> </tr> </tbody> </table> </div> <p>It's not difficult to write e.g. a Java program which processes each row in the <code>library_ledger</code> and updates the <code>student_books</code> table by issuing <code>INSERT</code>/<code>DELETE</code> queries. However, I wonder if this can be done in SQL directly.</p> <p>Maybe if the initial table is grouped by student_id and aggregating the book IDs using <code>array_agg</code>, one could use that as the starting value for an aggregate function which processes the actions in <code>library_ledger</code> by transforming the array using either <code>array_append</code> or <code>array_remove</code> (depending on the value in the <code>action</code> column). At the end, the result could be un-nested.</p> <p>Is there maybe a simpler way to achieve this, possibly even without using a custom aggregate function?</p>
[ { "answer_id": 74539043, "author": "EdmCoff", "author_id": 5504922, "author_profile": "https://Stackoverflow.com/users/5504922", "pm_score": 3, "selected": true, "text": "library_ledger DELETE\nFROM student_books\nWHERE (student_id, book_id) IN\n(\n SELECT student_id, book_id\n FROM\n (\n SELECT student_id, book_id, action, row_number() OVER (PARTITION BY student_id, book_id ORDER BY date DESC) rn\n FROM library_ledger\n ) sq\n WHERE rn = 1 AND action='return' -- Most recent action is \"return\"\n)\n student_books INSERT INTO student_books\nSELECT student_id, book_id\nFROM \n(\n SELECT student_id, book_id, action, row_number() OVER (PARTITION BY student_id, book_id ORDER BY date DESC) rn\n FROM library_ledger\n) sq\nWHERE rn = 1 AND action='borrow' -- Most recent action is \"borrow\"\nAND (student_id, book_id) NOT IN -- Doesn't already exist in table\n (\n SELECT student_id, book_id\n FROM student_books\n )\n" }, { "answer_id": 74539495, "author": "JHH", "author_id": 20127235, "author_profile": "https://Stackoverflow.com/users/20127235", "pm_score": 0, "selected": false, "text": "journal ledger select student_id, \n book_id,\n action,\n date,\n count(action) filter (where action='borrow') over (partition by student_id, book_id order by date) as borrow_count,\n count(action) filter (where action='return') over (partition by student_id, book_id order by date) as return_count\n from library_ledger;\n student_id|book_id|action|date |borrow_count|return_count|\n----------+-------+------+-----------------------+------------+------------+\n 1| 113|return|2022-11-21 17:43:22.000| 0| 1|\n 2| 3|borrow|2022-11-20 09:14:09.000| 1| 0|\n 5| 94|return|2022-11-22 14:03:08.000| 0| 1|\n 5| 204|borrow|2022-11-22 14:03:04.000| 1| 0|\n 5| 204|return|2022-11-22 14:03:15.000| 1| 1|\n with cte as (\nselect student_id, \n book_id,\n action,\n date,\n count(action) filter (where action='borrow') over (partition by student_id, book_id order by date) as borrow_count,\n count(action) filter (where action='return') over (partition by student_id, book_id order by date) as return_count\n from library_ledger)\nselect student_id,\n book_id,\n max(borrow_count) as borrow_count,\n max(return_count) as return_count,\n case \n when max(borrow_count) > max(return_count) then 'insert'\n when max(borrow_count) < max(return_count) then 'delete'\n else 'noop'\n end as sql_action\n from cte\n group by 1,2;\n student_id|book_id|borrow_count|return_count|sql_action|\n----------+-------+------------+------------+----------+\n 1| 113| 0| 1|delete |\n 2| 3| 1| 0|insert |\n 5| 94| 0| 1|delete |\n 5| 204| 1| 1|noop |\n student_books -- 1. delete\nwith cte as (\nselect student_id, \n book_id,\n action,\n date,\n count(action) filter (where action='borrow') over (partition by student_id, book_id order by date) as borrow_count,\n count(action) filter (where action='return') over (partition by student_id, book_id order by date) as return_count\n from library_ledger),\ncte_delete as (\nselect student_id,\n book_id\n from cte\n group by 1,2\n having max(borrow_count) < max(return_count))\ndelete from student_books sb\n using cte_delete d\n where sb.student_id = d.student_id\n and sb.book_id = d.book_id;\n\nselect * from student_books; \n \n-- 2. insert\nwith cte as (\nselect student_id, \n book_id,\n action,\n date,\n count(action) filter (where action='borrow') over (partition by student_id, book_id order by date) as borrow_count,\n count(action) filter (where action='return') over (partition by student_id, book_id order by date) as return_count\n from library_ledger),\ncte_insert as (\nselect student_id,\n book_id\n from cte\n group by 1,2\n having max(borrow_count) > max(return_count))\n insert into student_books\n select student_id, book_id\n from cte_insert;\n student_id|book_id|\n----------+-------+\n 2| 37|\n 2| 3|\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91757/" ]
74,538,722
<pre><code>def plot(self): plt.figure(figsize=(20, 5)) ax1 = plt.subplot(211) ax1.plot(self.signals['CLOSE']) ax1.set_title('Price') ax2 = plt.subplot(212, sharex=ax1) ax2.set_title('RSI') ax2.plot(self.signals[['RSI']]) ax2.axhline(30, linestyle='--', alpha=0.5, color='#ff0000') ax2.axhline(70, linestyle='--', alpha=0.5, color='#ff0000') plt.show() </code></pre> <p>I am plotting two charts in python application. But the x axis values are indexes like 1,2,3,....</p> <p>But my dataframe has a column <code>self.signals['DATA']</code> so how can I use it as x axis values?</p>
[ { "answer_id": 74539043, "author": "EdmCoff", "author_id": 5504922, "author_profile": "https://Stackoverflow.com/users/5504922", "pm_score": 3, "selected": true, "text": "library_ledger DELETE\nFROM student_books\nWHERE (student_id, book_id) IN\n(\n SELECT student_id, book_id\n FROM\n (\n SELECT student_id, book_id, action, row_number() OVER (PARTITION BY student_id, book_id ORDER BY date DESC) rn\n FROM library_ledger\n ) sq\n WHERE rn = 1 AND action='return' -- Most recent action is \"return\"\n)\n student_books INSERT INTO student_books\nSELECT student_id, book_id\nFROM \n(\n SELECT student_id, book_id, action, row_number() OVER (PARTITION BY student_id, book_id ORDER BY date DESC) rn\n FROM library_ledger\n) sq\nWHERE rn = 1 AND action='borrow' -- Most recent action is \"borrow\"\nAND (student_id, book_id) NOT IN -- Doesn't already exist in table\n (\n SELECT student_id, book_id\n FROM student_books\n )\n" }, { "answer_id": 74539495, "author": "JHH", "author_id": 20127235, "author_profile": "https://Stackoverflow.com/users/20127235", "pm_score": 0, "selected": false, "text": "journal ledger select student_id, \n book_id,\n action,\n date,\n count(action) filter (where action='borrow') over (partition by student_id, book_id order by date) as borrow_count,\n count(action) filter (where action='return') over (partition by student_id, book_id order by date) as return_count\n from library_ledger;\n student_id|book_id|action|date |borrow_count|return_count|\n----------+-------+------+-----------------------+------------+------------+\n 1| 113|return|2022-11-21 17:43:22.000| 0| 1|\n 2| 3|borrow|2022-11-20 09:14:09.000| 1| 0|\n 5| 94|return|2022-11-22 14:03:08.000| 0| 1|\n 5| 204|borrow|2022-11-22 14:03:04.000| 1| 0|\n 5| 204|return|2022-11-22 14:03:15.000| 1| 1|\n with cte as (\nselect student_id, \n book_id,\n action,\n date,\n count(action) filter (where action='borrow') over (partition by student_id, book_id order by date) as borrow_count,\n count(action) filter (where action='return') over (partition by student_id, book_id order by date) as return_count\n from library_ledger)\nselect student_id,\n book_id,\n max(borrow_count) as borrow_count,\n max(return_count) as return_count,\n case \n when max(borrow_count) > max(return_count) then 'insert'\n when max(borrow_count) < max(return_count) then 'delete'\n else 'noop'\n end as sql_action\n from cte\n group by 1,2;\n student_id|book_id|borrow_count|return_count|sql_action|\n----------+-------+------------+------------+----------+\n 1| 113| 0| 1|delete |\n 2| 3| 1| 0|insert |\n 5| 94| 0| 1|delete |\n 5| 204| 1| 1|noop |\n student_books -- 1. delete\nwith cte as (\nselect student_id, \n book_id,\n action,\n date,\n count(action) filter (where action='borrow') over (partition by student_id, book_id order by date) as borrow_count,\n count(action) filter (where action='return') over (partition by student_id, book_id order by date) as return_count\n from library_ledger),\ncte_delete as (\nselect student_id,\n book_id\n from cte\n group by 1,2\n having max(borrow_count) < max(return_count))\ndelete from student_books sb\n using cte_delete d\n where sb.student_id = d.student_id\n and sb.book_id = d.book_id;\n\nselect * from student_books; \n \n-- 2. insert\nwith cte as (\nselect student_id, \n book_id,\n action,\n date,\n count(action) filter (where action='borrow') over (partition by student_id, book_id order by date) as borrow_count,\n count(action) filter (where action='return') over (partition by student_id, book_id order by date) as return_count\n from library_ledger),\ncte_insert as (\nselect student_id,\n book_id\n from cte\n group by 1,2\n having max(borrow_count) > max(return_count))\n insert into student_books\n select student_id, book_id\n from cte_insert;\n student_id|book_id|\n----------+-------+\n 2| 37|\n 2| 3|\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538722", "https://Stackoverflow.com", "https://Stackoverflow.com/users/694716/" ]
74,538,723
<p>I have the following app which has a CollectionView populated from an SQLite database, but I am having difficulty passing the selected value from the CollectionView to another page when clicked on.</p> <p>Records.cs</p> <pre><code>using SQLite; namespace b_records.Models { [Table(&quot;records)&quot;)] public class Record { [PrimaryKey, AutoIncrement] public int Id { get; set; } [MaxLength(250)] public string Amount { get; set; } } } </code></pre> <p>AppShell.xaml.cs</p> <pre><code>namespace b_records; public partial class AppShell : Shell { public AppShell() { InitializeComponent(); Routing.RegisterRoute(&quot;DetailPage&quot;, typeof(DetailPage)); } } </code></pre> <p>MainPage.xaml</p> <pre><code>&lt;CollectionView x:Name=&quot;recordList&quot; Grid.Row=&quot;5&quot; SelectionChanged=&quot;OnCollectionViewSelectionChanged&quot; SelectionMode=&quot;Single&quot;&gt; &lt;CollectionView.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width=&quot;*&quot; /&gt; &lt;ColumnDefinition Width=&quot;2*&quot; /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Label Text=&quot;{Binding Id}&quot; /&gt; &lt;Label Grid.Column=&quot;1&quot; Text=&quot;{Binding Amount}&quot; /&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt; &lt;/CollectionView.ItemTemplate&gt; &lt;/CollectionView&gt; </code></pre> <p>MainPage.xaml.cs</p> <pre><code>private async void OnCollectionViewSelectionChanged(object sender, SelectionChangedEventArgs e) { int id = (e.CurrentSelection.FirstOrDefault() as Record).Id; await Shell.Current.GoToAsync($&quot;DetailPage?id={id}&quot;); } </code></pre> <p>DetailPage.xaml.cs</p> <pre><code>namespace b_records; [QueryProperty(nameof(id), &quot;id&quot;)] public partial class DetailPage : ContentPage { public int id { get; set; } public DetailPage() { InitializeComponent(); lblText.Text = id.ToString(); } } </code></pre> <p>Trying to follow the details from Microsoft's documentation here: <a href="https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/shell/navigation?view=net-maui-6.0#pass-data" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/shell/navigation?view=net-maui-6.0#pass-data</a></p> <p>But each time I click on the CollectionView, I am taken to DetailPage, and the value in the lblText.text is 0 instead of the id value on the row in the CollectionView populated from the SQLite database.</p> <p>Any idea why?</p>
[ { "answer_id": 74539043, "author": "EdmCoff", "author_id": 5504922, "author_profile": "https://Stackoverflow.com/users/5504922", "pm_score": 3, "selected": true, "text": "library_ledger DELETE\nFROM student_books\nWHERE (student_id, book_id) IN\n(\n SELECT student_id, book_id\n FROM\n (\n SELECT student_id, book_id, action, row_number() OVER (PARTITION BY student_id, book_id ORDER BY date DESC) rn\n FROM library_ledger\n ) sq\n WHERE rn = 1 AND action='return' -- Most recent action is \"return\"\n)\n student_books INSERT INTO student_books\nSELECT student_id, book_id\nFROM \n(\n SELECT student_id, book_id, action, row_number() OVER (PARTITION BY student_id, book_id ORDER BY date DESC) rn\n FROM library_ledger\n) sq\nWHERE rn = 1 AND action='borrow' -- Most recent action is \"borrow\"\nAND (student_id, book_id) NOT IN -- Doesn't already exist in table\n (\n SELECT student_id, book_id\n FROM student_books\n )\n" }, { "answer_id": 74539495, "author": "JHH", "author_id": 20127235, "author_profile": "https://Stackoverflow.com/users/20127235", "pm_score": 0, "selected": false, "text": "journal ledger select student_id, \n book_id,\n action,\n date,\n count(action) filter (where action='borrow') over (partition by student_id, book_id order by date) as borrow_count,\n count(action) filter (where action='return') over (partition by student_id, book_id order by date) as return_count\n from library_ledger;\n student_id|book_id|action|date |borrow_count|return_count|\n----------+-------+------+-----------------------+------------+------------+\n 1| 113|return|2022-11-21 17:43:22.000| 0| 1|\n 2| 3|borrow|2022-11-20 09:14:09.000| 1| 0|\n 5| 94|return|2022-11-22 14:03:08.000| 0| 1|\n 5| 204|borrow|2022-11-22 14:03:04.000| 1| 0|\n 5| 204|return|2022-11-22 14:03:15.000| 1| 1|\n with cte as (\nselect student_id, \n book_id,\n action,\n date,\n count(action) filter (where action='borrow') over (partition by student_id, book_id order by date) as borrow_count,\n count(action) filter (where action='return') over (partition by student_id, book_id order by date) as return_count\n from library_ledger)\nselect student_id,\n book_id,\n max(borrow_count) as borrow_count,\n max(return_count) as return_count,\n case \n when max(borrow_count) > max(return_count) then 'insert'\n when max(borrow_count) < max(return_count) then 'delete'\n else 'noop'\n end as sql_action\n from cte\n group by 1,2;\n student_id|book_id|borrow_count|return_count|sql_action|\n----------+-------+------------+------------+----------+\n 1| 113| 0| 1|delete |\n 2| 3| 1| 0|insert |\n 5| 94| 0| 1|delete |\n 5| 204| 1| 1|noop |\n student_books -- 1. delete\nwith cte as (\nselect student_id, \n book_id,\n action,\n date,\n count(action) filter (where action='borrow') over (partition by student_id, book_id order by date) as borrow_count,\n count(action) filter (where action='return') over (partition by student_id, book_id order by date) as return_count\n from library_ledger),\ncte_delete as (\nselect student_id,\n book_id\n from cte\n group by 1,2\n having max(borrow_count) < max(return_count))\ndelete from student_books sb\n using cte_delete d\n where sb.student_id = d.student_id\n and sb.book_id = d.book_id;\n\nselect * from student_books; \n \n-- 2. insert\nwith cte as (\nselect student_id, \n book_id,\n action,\n date,\n count(action) filter (where action='borrow') over (partition by student_id, book_id order by date) as borrow_count,\n count(action) filter (where action='return') over (partition by student_id, book_id order by date) as return_count\n from library_ledger),\ncte_insert as (\nselect student_id,\n book_id\n from cte\n group by 1,2\n having max(borrow_count) > max(return_count))\n insert into student_books\n select student_id, book_id\n from cte_insert;\n student_id|book_id|\n----------+-------+\n 2| 37|\n 2| 3|\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/364312/" ]
74,538,741
<p>I am trying to train a model for supervised learning for Hidden Markov Model (HMM)and test it on a set of observations however, keep getting this error. The goal is to predict the state based on the observations. How can I fix this and how can I view the transition matrix?</p> <p>The version for Pomegranate is 0.14.4 Trying this from the source: <a href="https://github.com/jmschrei/pomegranate/issues/1005" rel="nofollow noreferrer">https://github.com/jmschrei/pomegranate/issues/1005</a></p> <pre><code>from pomegranate import * import numpy as np # Supervised method that calculates the transition matrix: d1 = State(UniformDistribution.from_samples([3.243221498397177, 3.210684537495482, 3.227662201472816, 3.286410817416738, 3.290573650708864, 3.286058136226862, 3.266480693857006])) d2 = State(UniformDistribution.from_samples([3.449282367485096, 1.97317859465635, 1.897551432353011, 3.454609351559659, 3.127357456033111, 1.779308337786426, 3.802891929694426, 3.359766157565077, 2.959428499979418])) d3 = State(UniformDistribution.from_samples([1.892812118441474, 1.589353118681066, 2.09269978285637, 2.104391496570218, 1.656771181054144])) model = HiddenMarkovModel() model.add_states(d1, d2, d3) # print(model.to_json()) model.bake() model.fit([3.2, 6.7, 10.55], labels=[1, 2, 3], algorithm='labeled') all_pred = model.predict([2.33, 1.22, 1.4, 10.6]) </code></pre> <p>Error:</p> <pre><code> File &quot;C:\Program Files\JetBrains\PyCharm Community Edition 2021.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_umd.py&quot;, line 198, in runfile pydev_imports.execfile(filename, global_vars, local_vars) # execute the script File &quot;C:\Program Files\JetBrains\PyCharm Community Edition 2021.2\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py&quot;, line 18, in execfile exec(compile(contents+&quot;\n&quot;, file, 'exec'), glob, loc) File &quot;C:/Users/&quot;, line 774, in &lt;module&gt; model.bake() File &quot;pomegranate/hmm.pyx&quot;, line 1047, in pomegranate.hmm.HiddenMarkovModel.bake UnboundLocalError: local variable 'dist' referenced before assignment </code></pre>
[ { "answer_id": 74539043, "author": "EdmCoff", "author_id": 5504922, "author_profile": "https://Stackoverflow.com/users/5504922", "pm_score": 3, "selected": true, "text": "library_ledger DELETE\nFROM student_books\nWHERE (student_id, book_id) IN\n(\n SELECT student_id, book_id\n FROM\n (\n SELECT student_id, book_id, action, row_number() OVER (PARTITION BY student_id, book_id ORDER BY date DESC) rn\n FROM library_ledger\n ) sq\n WHERE rn = 1 AND action='return' -- Most recent action is \"return\"\n)\n student_books INSERT INTO student_books\nSELECT student_id, book_id\nFROM \n(\n SELECT student_id, book_id, action, row_number() OVER (PARTITION BY student_id, book_id ORDER BY date DESC) rn\n FROM library_ledger\n) sq\nWHERE rn = 1 AND action='borrow' -- Most recent action is \"borrow\"\nAND (student_id, book_id) NOT IN -- Doesn't already exist in table\n (\n SELECT student_id, book_id\n FROM student_books\n )\n" }, { "answer_id": 74539495, "author": "JHH", "author_id": 20127235, "author_profile": "https://Stackoverflow.com/users/20127235", "pm_score": 0, "selected": false, "text": "journal ledger select student_id, \n book_id,\n action,\n date,\n count(action) filter (where action='borrow') over (partition by student_id, book_id order by date) as borrow_count,\n count(action) filter (where action='return') over (partition by student_id, book_id order by date) as return_count\n from library_ledger;\n student_id|book_id|action|date |borrow_count|return_count|\n----------+-------+------+-----------------------+------------+------------+\n 1| 113|return|2022-11-21 17:43:22.000| 0| 1|\n 2| 3|borrow|2022-11-20 09:14:09.000| 1| 0|\n 5| 94|return|2022-11-22 14:03:08.000| 0| 1|\n 5| 204|borrow|2022-11-22 14:03:04.000| 1| 0|\n 5| 204|return|2022-11-22 14:03:15.000| 1| 1|\n with cte as (\nselect student_id, \n book_id,\n action,\n date,\n count(action) filter (where action='borrow') over (partition by student_id, book_id order by date) as borrow_count,\n count(action) filter (where action='return') over (partition by student_id, book_id order by date) as return_count\n from library_ledger)\nselect student_id,\n book_id,\n max(borrow_count) as borrow_count,\n max(return_count) as return_count,\n case \n when max(borrow_count) > max(return_count) then 'insert'\n when max(borrow_count) < max(return_count) then 'delete'\n else 'noop'\n end as sql_action\n from cte\n group by 1,2;\n student_id|book_id|borrow_count|return_count|sql_action|\n----------+-------+------------+------------+----------+\n 1| 113| 0| 1|delete |\n 2| 3| 1| 0|insert |\n 5| 94| 0| 1|delete |\n 5| 204| 1| 1|noop |\n student_books -- 1. delete\nwith cte as (\nselect student_id, \n book_id,\n action,\n date,\n count(action) filter (where action='borrow') over (partition by student_id, book_id order by date) as borrow_count,\n count(action) filter (where action='return') over (partition by student_id, book_id order by date) as return_count\n from library_ledger),\ncte_delete as (\nselect student_id,\n book_id\n from cte\n group by 1,2\n having max(borrow_count) < max(return_count))\ndelete from student_books sb\n using cte_delete d\n where sb.student_id = d.student_id\n and sb.book_id = d.book_id;\n\nselect * from student_books; \n \n-- 2. insert\nwith cte as (\nselect student_id, \n book_id,\n action,\n date,\n count(action) filter (where action='borrow') over (partition by student_id, book_id order by date) as borrow_count,\n count(action) filter (where action='return') over (partition by student_id, book_id order by date) as return_count\n from library_ledger),\ncte_insert as (\nselect student_id,\n book_id\n from cte\n group by 1,2\n having max(borrow_count) > max(return_count))\n insert into student_books\n select student_id, book_id\n from cte_insert;\n student_id|book_id|\n----------+-------+\n 2| 37|\n 2| 3|\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16378913/" ]
74,538,812
<p>Looking up Bootstrap 5 code, I faced this following statement on <a href="https://github.com/twbs/bootstrap/blob/main/scss/mixins/_forms.scss#L5" rel="nofollow noreferrer" title="Bootstrap form.scss"><code>bootstrap/scss/mixins/_forms.scss</code></a> file:</p> <pre class="lang-scss prettyprint-override"><code>@mixin form-validation-state-selector($state) { @if ($state == &quot;valid&quot; or $state == &quot;invalid&quot;) { .was-validated #{if(&amp;, &quot;&amp;&quot;, &quot;&quot;)}:#{$state}, #{if(&amp;, &quot;&amp;&quot;, &quot;&quot;)}.is-#{$state} { @content; } } @else { #{if(&amp;, &quot;&amp;&quot;, &quot;&quot;)}.is-#{$state} { @content; } } } </code></pre> <p>And could not exactly understand the usage of <code>&amp;</code> <em>variable</em> inside the <code>#{if(&amp;, &quot;&amp;&quot;, &quot;&quot;)}</code> statements. How is it working?</p> <p>I know the <a href="https://css-tricks.com/the-sass-ampersand/" rel="nofollow noreferrer">Ampersand (<code>&amp;</code>) character</a> is used, os SASS, to include the parent selector(s), when writing on an indented hierarchy. But I couldn't guess how it has been using on the mentioned statement inside the <code>@mixin</code>, when out of quotes <code>&quot;</code>. Can someone explaning it?</p> <p>Thanks in advance!</p>
[ { "answer_id": 74539143, "author": "F. Müller", "author_id": 1294283, "author_profile": "https://Stackoverflow.com/users/1294283", "pm_score": 2, "selected": false, "text": "&" }, { "answer_id": 74539214, "author": "Tanner Dolby", "author_id": 11389581, "author_profile": "https://Stackoverflow.com/users/11389581", "pm_score": 2, "selected": true, "text": "#{if(&, \"&\", \"\")}:#{$state} if() if(val, res1, res2) & .was-validated &:valid, .was-validated :valid #{if(&, \"&\", \"\"}" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2989289/" ]
74,538,818
<p>I want when I click on link label it give me the name of the textbox which in the same line in a variable named AA `</p> <pre><code> Dim serial As Integer = 1 Public Function addnewline() Dim lbl As New System.Windows.Forms.LinkLabel Dim txt As New System.Windows.Forms.TextBox ' add label Me.Controls.Add(lbl) lbl.Top = serial * 27 lbl.Left = 100 lbl.Text = Me.serial lbl.Name = &quot;lbl&quot; &amp; Me.serial ' add textbox Me.Controls.Add(txt) txt.Top = serial * 27 txt.Left = 200 txt.Height = 500 txt.Width = 100 txt.TextAlign = HorizontalAlignment.Center txt.Text = &quot;text&quot; &amp; Me.serial txt.Name = &quot;txt&quot; &amp; Me.serial serial += 1 Return lbl Return txt End Function </code></pre> <p>` here is a gif for my code <a href="https://i.stack.imgur.com/f73L3.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f73L3.gif" alt="enter image description here" /></a></p>
[ { "answer_id": 74539012, "author": "Jonathan Barraone", "author_id": 17957703, "author_profile": "https://Stackoverflow.com/users/17957703", "pm_score": 1, "selected": false, "text": "AddHandler Dim serial As Integer = 1\n Dim AA As String = \"\"\n\nPublic Function addnewline()\n Dim lbl As New System.Windows.Forms.LinkLabel\n Dim txt As New System.Windows.Forms.TextBox\n\n ' add label\n Me.Controls.Add(lbl)\n lbl.Top = serial * 27\n lbl.Left = 100\n lbl.Text = Me.serial\n lbl.Name = \"lbl\" & Me.serial\n \n ' add textbox\n Me.Controls.Add(txt)\n txt.Top = serial * 27\n txt.Left = 200\n txt.Height = 500\n txt.Width = 100\n txt.TextAlign = HorizontalAlignment.Center\n txt.Text = \"text\" & Me.serial\n txt.Name = \"txt\" & Me.serial\n\n AddHandler lbl.Click, Sub ()\n AA = txt.Name\n MessageBox.Show(AA)\n End Sub\n serial += 1\n\n Return lbl\n Return txt\nEnd Function\n" }, { "answer_id": 74539307, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 2, "selected": false, "text": ".Tag AddHandler Dim serial As Integer = 1\n\nPublic Sub addnewline()\n 'Textbox\n Dim txt As New System.Windows.Forms.TextBox\n txt.Top = serial * 27\n txt.Left = 200\n txt.Height = 500\n txt.Width = 100\n txt.TextAlign = HorizontalAlignment.Center\n txt.Text = \"text\" & Me.serial\n txt.Name = \"txt\" & Me.serial\n\n 'Label \n Dim lbl As New System.Windows.Forms.LinkLabel\n lbl.Top = serial * 27\n lbl.Left = 100\n lbl.Text = Me.serial\n lbl.Name = \"lbl\" & Me.serial.ToString()\n ' Next two lines are new\n lbl.Tag = txt \n AddHandler lbl.Click, AddressOf labelClick\n\n Me.SuspendLayout()\n Me.Controls.Add(lbl)\n Me.Controls.Add(txt)\n Me.ResumeLayout()\n\n serial += 1\nEnd Sub\n\nPublic Sub labelClick(sender As Control, e As EventHandler)\n Dim txt As TextBox = TryCast(sender.Tag, TextBox)\n If txt IsNot Nothing Then\n AA.Text = txt.Name\n End If\nEnd Sub\n" }, { "answer_id": 74544016, "author": "Hans", "author_id": 20520336, "author_profile": "https://Stackoverflow.com/users/20520336", "pm_score": 2, "selected": true, "text": "Dim Serial As Integer = 1\nDim AA As String = \"\"\nPublic Sub AddNewline()\n Dim lbl As New System.Windows.Forms.LinkLabel\n Dim txt As New System.Windows.Forms.TextBox\n\n ' add label\n Me.Controls.Add(lbl)\n lbl.Top = Serial * 27\n lbl.Left = 100\n lbl.Text = Me.Serial\n lbl.Name = \"lbl\" & Me.Serial\n\n ' add textbox\n Me.Controls.Add(txt)\n txt.Top = Serial * 27\n txt.Left = 200\n txt.Height = 500\n txt.Width = 100\n txt.TextAlign = HorizontalAlignment.Center\n txt.Text = \"text\" & Me.Serial\n txt.Name = \"txt\" & Me.Serial\n\n AddHandler lbl.Click, AddressOf Label_Click\n\n Serial += 1\n 'Return lbl\n 'Return txt\nEnd Sub\n\nPrivate Sub Label_Click(sender As Object, e As EventArgs)\n AA = \"\"\n Dim Lbl As Label = DirectCast(sender, Label)\n If Lbl IsNot Nothing Then\n Dim Idx As String = System.Text.RegularExpressions.Regex.Replace(Lbl.Name, \"[^\\d]\", \"\")\n If Idx <> \"\" Then\n If Me.Controls.Find(\"txt\" & Idx, True).Count = 1 Then\n Dim T As TextBox = Me.Controls.Find(\"txt\" & Idx, True)(0)\n AA = T.Text\n ' or\n TextBoxYellow.Text = AA\n End If\n End If\n End If\nEnd Sub\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14807922/" ]
74,538,822
<p>I'm trying to flatten this json response into a pandas dataframe to export to csv.</p> <p>It looks like this:</p> <pre class="lang-py prettyprint-override"><code>j = [ { &quot;id&quot;: 401281949, &quot;teams&quot;: [ { &quot;school&quot;: &quot;Louisiana Tech&quot;, &quot;conference&quot;: &quot;Conference USA&quot;, &quot;homeAway&quot;: &quot;away&quot;, &quot;points&quot;: 34, &quot;stats&quot;: [ {&quot;category&quot;: &quot;rushingTDs&quot;, &quot;stat&quot;: &quot;1&quot;}, {&quot;category&quot;: &quot;puntReturnYards&quot;, &quot;stat&quot;: &quot;24&quot;}, {&quot;category&quot;: &quot;puntReturnTDs&quot;, &quot;stat&quot;: &quot;0&quot;}, {&quot;category&quot;: &quot;puntReturns&quot;, &quot;stat&quot;: &quot;3&quot;}, ], } ], } ] </code></pre> <p>...Many more items in the stats area. If I run this and flatten to the teams level:</p> <pre class="lang-py prettyprint-override"><code>multiple_level_data = pd.json_normalize(j, record_path =['teams']) </code></pre> <p>I get:</p> <pre class="lang-none prettyprint-override"><code> school conference homeAway points stats 0 Louisiana Tech Conference USA away 34 [{'category': 'rushingTDs', 'stat': '1'}, {'ca... </code></pre> <p>How do I flatten it twice so that all of the stats are on their own column in each row?</p> <p>If I do this:</p> <pre class="lang-py prettyprint-override"><code>multiple_level_data = pd.json_normalize(j, record_path =['teams']) multiple_level_data = multiple_level_data.explode('stats').reset_index(drop=True) multiple_level_data=multiple_level_data.join(pd.json_normalize(multiple_level_data.pop('stats'))) </code></pre> <p>I end up with multiple rows instead of more columns:</p> <p><a href="https://i.stack.imgur.com/t0wFu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t0wFu.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74538845, "author": "Bushmaster", "author_id": 15415267, "author_profile": "https://Stackoverflow.com/users/15415267", "pm_score": 2, "selected": false, "text": "multiple_level_data = pd.json_normalize(j, record_path =['teams'])\nmultiple_level_data = multiple_level_data.explode('stats').reset_index(drop=True)\nmultiple_level_data=multiple_level_data.join(pd.json_normalize(multiple_level_data.pop('stats')))\n\n#convert rows to columns.\nmultiple_level_data=multiple_level_data.set_index(multiple_level_data.columns[0:4].to_list())\ndfx=multiple_level_data.pivot_table(values='stat',columns='category',aggfunc=list).apply(pd.Series.explode).reset_index(drop=True)\nmultiple_level_data=multiple_level_data.reset_index().drop(['stat','category'],axis=1).drop_duplicates().reset_index(drop=True)\nmultiple_level_data=multiple_level_data.join(dfx)\n\n" }, { "answer_id": 74539059, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 3, "selected": true, "text": "df = pd.DataFrame(j).explode(\"teams\")\ndf = pd.concat([df, df.pop(\"teams\").apply(pd.Series)], axis=1)\n\ndf[\"stats\"] = df[\"stats\"].apply(lambda x: {d[\"category\"]: d[\"stat\"] for d in x})\n\ndf = pd.concat(\n [\n df,\n df.pop(\"stats\").apply(pd.Series),\n ],\n axis=1,\n)\n\nprint(df)\n id school conference homeAway points rushingTDs puntReturnYards puntReturnTDs puntReturns\n0 401281949 Louisiana Tech Conference USA away 34 1 24 0 3\n" }, { "answer_id": 74539549, "author": "cottontail", "author_id": 19123103, "author_profile": "https://Stackoverflow.com/users/19123103", "pm_score": 1, "selected": false, "text": "explode() json_normalize() json_normalize() ['teams', 'school'] ['teams', 'conference'] pivot() # normalize json\ndf = pd.json_normalize(\n j, record_path=['teams', 'stats'], \n meta=['id', *(['teams', c] for c in ('school', 'conference', 'homeAway', 'points'))]\n)\n# column name contains 'teams' prefix; remove it\ndf.columns = [c.split('.')[1] if '.' in c else c for c in df]\n\n# pivot the intermediate result\ndf = (\n df.astype({'points': int, 'id': int})\n .pivot(['id', 'school', 'conference', 'homeAway', 'points'], 'category', 'stat')\n .reset_index()\n)\n# remove index name\ndf.columns.name = None\ndf\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5525514/" ]
74,538,864
<p>I am working with objects and creating constructors such as this:</p> <pre><code>Employee employee1 = new Employee(); </code></pre> <p>When I go to run each individual constructor, I get this error:</p> <pre><code>Employee cannot be resolved to a type </code></pre> <p>My instructor informed me that this error had to do with Visual Studio Code and having to create packages within the project. I scoured the internet for tips on how to do this and even attempted to use Maven to set up the project but I was unable to produce any results thus far.</p>
[ { "answer_id": 74538845, "author": "Bushmaster", "author_id": 15415267, "author_profile": "https://Stackoverflow.com/users/15415267", "pm_score": 2, "selected": false, "text": "multiple_level_data = pd.json_normalize(j, record_path =['teams'])\nmultiple_level_data = multiple_level_data.explode('stats').reset_index(drop=True)\nmultiple_level_data=multiple_level_data.join(pd.json_normalize(multiple_level_data.pop('stats')))\n\n#convert rows to columns.\nmultiple_level_data=multiple_level_data.set_index(multiple_level_data.columns[0:4].to_list())\ndfx=multiple_level_data.pivot_table(values='stat',columns='category',aggfunc=list).apply(pd.Series.explode).reset_index(drop=True)\nmultiple_level_data=multiple_level_data.reset_index().drop(['stat','category'],axis=1).drop_duplicates().reset_index(drop=True)\nmultiple_level_data=multiple_level_data.join(dfx)\n\n" }, { "answer_id": 74539059, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 3, "selected": true, "text": "df = pd.DataFrame(j).explode(\"teams\")\ndf = pd.concat([df, df.pop(\"teams\").apply(pd.Series)], axis=1)\n\ndf[\"stats\"] = df[\"stats\"].apply(lambda x: {d[\"category\"]: d[\"stat\"] for d in x})\n\ndf = pd.concat(\n [\n df,\n df.pop(\"stats\").apply(pd.Series),\n ],\n axis=1,\n)\n\nprint(df)\n id school conference homeAway points rushingTDs puntReturnYards puntReturnTDs puntReturns\n0 401281949 Louisiana Tech Conference USA away 34 1 24 0 3\n" }, { "answer_id": 74539549, "author": "cottontail", "author_id": 19123103, "author_profile": "https://Stackoverflow.com/users/19123103", "pm_score": 1, "selected": false, "text": "explode() json_normalize() json_normalize() ['teams', 'school'] ['teams', 'conference'] pivot() # normalize json\ndf = pd.json_normalize(\n j, record_path=['teams', 'stats'], \n meta=['id', *(['teams', c] for c in ('school', 'conference', 'homeAway', 'points'))]\n)\n# column name contains 'teams' prefix; remove it\ndf.columns = [c.split('.')[1] if '.' in c else c for c in df]\n\n# pivot the intermediate result\ndf = (\n df.astype({'points': int, 'id': int})\n .pivot(['id', 'school', 'conference', 'homeAway', 'points'], 'category', 'stat')\n .reset_index()\n)\n# remove index name\ndf.columns.name = None\ndf\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20144034/" ]
74,538,885
<p>I have the following code.</p> <p>I am trying to create a <strong>'pom.xml'</strong> file for a <strong>bukkit</strong> plugin (Minecraft) using Maven.</p> <p>However, this gives me the error: <strong>'The POM for org.apache.maven.plugins:maven-compiler-plugin:jar:3.8.6 is missing'</strong>.</p> <p>I have tried to trouble shoot a few different solutions but haven't been successful in any.</p> <p>I would be so grateful for a helping hand!</p> <pre><code>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;groupId&gt;newestfile.here&lt;/groupId&gt; &lt;artifactId&gt;newestplugin&lt;/artifactId&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt; &lt;build&gt; &lt;pluginManagement&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt; &lt;version&gt;3.8.6&lt;/version&gt; &lt;configuration&gt; &lt;source&gt;19&lt;/source&gt; &lt;target&gt;19&lt;/target&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/pluginManagement&gt; </code></pre>
[ { "answer_id": 74538845, "author": "Bushmaster", "author_id": 15415267, "author_profile": "https://Stackoverflow.com/users/15415267", "pm_score": 2, "selected": false, "text": "multiple_level_data = pd.json_normalize(j, record_path =['teams'])\nmultiple_level_data = multiple_level_data.explode('stats').reset_index(drop=True)\nmultiple_level_data=multiple_level_data.join(pd.json_normalize(multiple_level_data.pop('stats')))\n\n#convert rows to columns.\nmultiple_level_data=multiple_level_data.set_index(multiple_level_data.columns[0:4].to_list())\ndfx=multiple_level_data.pivot_table(values='stat',columns='category',aggfunc=list).apply(pd.Series.explode).reset_index(drop=True)\nmultiple_level_data=multiple_level_data.reset_index().drop(['stat','category'],axis=1).drop_duplicates().reset_index(drop=True)\nmultiple_level_data=multiple_level_data.join(dfx)\n\n" }, { "answer_id": 74539059, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 3, "selected": true, "text": "df = pd.DataFrame(j).explode(\"teams\")\ndf = pd.concat([df, df.pop(\"teams\").apply(pd.Series)], axis=1)\n\ndf[\"stats\"] = df[\"stats\"].apply(lambda x: {d[\"category\"]: d[\"stat\"] for d in x})\n\ndf = pd.concat(\n [\n df,\n df.pop(\"stats\").apply(pd.Series),\n ],\n axis=1,\n)\n\nprint(df)\n id school conference homeAway points rushingTDs puntReturnYards puntReturnTDs puntReturns\n0 401281949 Louisiana Tech Conference USA away 34 1 24 0 3\n" }, { "answer_id": 74539549, "author": "cottontail", "author_id": 19123103, "author_profile": "https://Stackoverflow.com/users/19123103", "pm_score": 1, "selected": false, "text": "explode() json_normalize() json_normalize() ['teams', 'school'] ['teams', 'conference'] pivot() # normalize json\ndf = pd.json_normalize(\n j, record_path=['teams', 'stats'], \n meta=['id', *(['teams', c] for c in ('school', 'conference', 'homeAway', 'points'))]\n)\n# column name contains 'teams' prefix; remove it\ndf.columns = [c.split('.')[1] if '.' in c else c for c in df]\n\n# pivot the intermediate result\ndf = (\n df.astype({'points': int, 'id': int})\n .pivot(['id', 'school', 'conference', 'homeAway', 'points'], 'category', 'stat')\n .reset_index()\n)\n# remove index name\ndf.columns.name = None\ndf\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12985497/" ]
74,538,933
<p>I want to get the time data and the temperature data (for all 7 days) from JSON (that came after my initial request to an external weather API - open meteo), parse the JSON and populate a HTML table with it. I cant get to populate the table with data....below is my code, please help me!</p> <p>Thank you!</p> <pre><code> &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js&quot;&gt;&lt;/script&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css&quot; integrity=&quot;sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T&quot; crossorigin=&quot;anonymous&quot;&gt; &lt;style&gt; th{ color:#fff; } &lt;/style&gt; &lt;table class=&quot;table table-striped&quot;&gt; &lt;tr class=&quot;bg-info&quot;&gt; &lt;th&gt;time&lt;/th&gt; &lt;th&gt;temperature&lt;/th&gt; &lt;/tr&gt; &lt;tbody id=&quot;myTable&quot;&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;script&gt; var myArray = [ ] $.ajax({ method: 'GET', url: 'https://api.open-meteo.com/v1/forecast?latitude=44.32&amp;longitude=23.80&amp;start_date=2022-11-30&amp;end_date=2022-12-06&amp;daily=temperature_2m_max&amp;timezone=GMT', success:function(response){ myArray = response.daily buildTable(myArray) console.log(myArray) } }) function buildTable(data){ var table = document.getElementById('myTable') for (var i = 0; i &lt; data.length; i++){ var row = `&lt;tr&gt; &lt;td&gt;${data[i].time}&lt;/td&gt; &lt;td&gt;${data[i].temperature_2m_max}&lt;/td&gt; &lt;/tr&gt;` table.innerHTML += row } } &lt;/script&gt; </code></pre> <p>The JSON data that I get</p> <p>Raw--</p> <pre><code>{&quot;latitude&quot;:44.3125,&quot;longitude&quot;:23.8125,&quot;generationtime_ms&quot;:0.3180503845214844,&quot;utc_offset_seconds&quot;:0,&quot;timezone&quot;:&quot;GMT&quot;,&quot;timezone_abbreviation&quot;:&quot;GMT&quot;,&quot;elevation&quot;:106.0,&quot;daily_units&quot;:{&quot;time&quot;:&quot;iso8601&quot;,&quot;temperature_2m_max&quot;:&quot;°C&quot;},&quot;daily&quot;:{&quot;time&quot;:[&quot;2022-11-30&quot;,&quot;2022-12-01&quot;,&quot;2022-12-02&quot;,&quot;2022-12-03&quot;,&quot;2022-12-04&quot;,&quot;2022-12-05&quot;,&quot;2022-12-06&quot;],&quot;temperature_2m_max&quot;:[5.9,6.1,8.1,9.5,9.3,7.3,4.3]}} </code></pre> <p>Parsed ---</p> <pre><code>{ &quot;latitude&quot;: 44.3125, &quot;longitude&quot;: 23.8125, &quot;generationtime_ms&quot;: 0.3180503845214844, &quot;utc_offset_seconds&quot;: 0, &quot;timezone&quot;: &quot;GMT&quot;, &quot;timezone_abbreviation&quot;: &quot;GMT&quot;, &quot;elevation&quot;: 106, &quot;daily_units&quot;: {}, &quot;daily&quot;: { &quot;time&quot;: [ &quot;2022-11-30&quot;, &quot;2022-12-01&quot;, &quot;2022-12-02&quot;, &quot;2022-12-03&quot;, &quot;2022-12-04&quot;, &quot;2022-12-05&quot;, &quot;2022-12-06&quot; ], &quot;temperature_2m_max&quot;: [ 5.9, 6.1, 8.1, 9.5, 9.3, 7.3, 4.3 ] } } </code></pre>
[ { "answer_id": 74538997, "author": "Rohit Khanna", "author_id": 7306148, "author_profile": "https://Stackoverflow.com/users/7306148", "pm_score": 2, "selected": true, "text": "function buildTable(data){\n var table = document.getElementById('myTable')\n \n for (var i = 0; i < data.time.length; i++){ // edited\n var row = `<tr>\n <td>${data.time[i]}</td> // edited\n <td>${data.temperature_2m_max[i]}</td> // edited \n </tr>`\n table.innerHTML += row\n \n }\n }\n" }, { "answer_id": 74549952, "author": "Victor", "author_id": 20576072, "author_profile": "https://Stackoverflow.com/users/20576072", "pm_score": 0, "selected": false, "text": "function buildTable(data){\n var table = document.getElementById('myTable')\n \n for (var i = 0; i < data.time.length; i++){ // edited\n var row = `<tr>\n <td>${data.time[i]}</td> // edited\n <td>${data.temperature_2m_max[i]}</td> // edited \n </tr>`\n table.innerHTML += row\n \n }\n }\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20576072/" ]
74,538,967
<h1>Setup</h1> <p>I have an app in production used by thousands of users daily.</p> <p>I'm using retrofit2 version 2.9.0 (latest)</p> <p>My <code>build.gradle</code> below.</p> <pre><code>def retrofitVersion = '2.9.0' api &quot;com.squareup.retrofit2:converter-gson:${retrofitVersion}&quot; api &quot;com.squareup.retrofit2:converter-scalars:${retrofitVersion}&quot; api &quot;com.squareup.retrofit2:adapter-rxjava2:${retrofitVersion}&quot; api &quot;com.squareup.retrofit2:retrofit:${retrofitVersion}&quot; </code></pre> <p>I integrated Firebase Crashlytics and made it so that app would report any API related exceptions in <code>try-catch</code> blocks.</p> <p>e.g.</p> <pre class="lang-kotlin prettyprint-override"><code>viewModelScope.launch { try { val response = myRepository.getProfile() if (response.isSuccessful) { // continue with some business logic } else { Log.e(tag, &quot;error&quot;, RunTimeException(&quot;some error&quot;) } } catch (throwable: Throwable){ Log.e(tag, &quot;error thrown&quot;, throwable) crashlytics.recordException(throwable) } } </code></pre> <h1>Knowns</h1> <p>Now in Crashlytics, I get THOUSANDS of reports daily saying there were some errors. Before I get to those errors, I want to assure you that users ARE connected to internet with proper network permissions. I see logs that users are opening other contents at the time. So these errors seem to be really random.</p> <h1>Erros</h1> <ol> <li>UnknownHostException</li> </ol> <pre><code>Non-fatal Exception: java.net.UnknownHostException: Unable to resolve host &quot;my-host-address.com&quot;: No address associated with hostname at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:156) at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103) at java.net.InetAddress.getAllByName(InetAddress.java:1152) at okhttp3.Dns$Companion$DnsSystem.lookup(Dns.java:5) ... Caused by android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname) at libcore.io.Linux.android_getaddrinfo(Linux.java) at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:74) at libcore.io.BlockGuardOs.android_getaddrinfo(BlockGuardOs.java:200) at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:74) at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:135) at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103) ... </code></pre> <ol start="2"> <li>ConnectionException</li> </ol> <pre><code>Non-fatal Exception: java.net.ConnectException: Failed to connect to my-host-address.com/123.123.123.123:443 at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:146) at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:191) at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.java:257) at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.java) at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.java:47) ... Caused by java.net.ConnectException: failed to connect to my-host-address.com/123.123.123.123 (port 443) from /:: (port 0) after 10000ms: connect failed: ENETUNREACH (Network is unreachable) at libcore.io.IoBridge.connect(IoBridge.java:142) at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436) at java.net.Socket.connect(Socket.java:621) ... Caused by android.system.ErrnoException: connect failed: ENETUNREACH (Network is unreachable) at libcore.io.Linux.connect(Linux.java) at libcore.io.ForwardingOs.connect(ForwardingOs.java:94) at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:138) at libcore.io.ForwardingOs.connect(ForwardingOs.java:94) at libcore.io.IoBridge.connectErrno(IoBridge.java:173) at libcore.io.IoBridge.connect(IoBridge.java:134) ... </code></pre> <ol start="3"> <li>SocketTimeoutException</li> </ol> <pre><code>Non-fatal Exception: java.net.SocketTimeoutException: timeout at okhttp3.internal.http2.Http2Stream$StreamTimeout.newTimeoutException(Http2Stream.java:4) at okhttp3.internal.http2.Http2Stream$StreamTimeout.exitAndThrowIfTimedOut(Http2Stream.java:8) at okhttp3.internal.http2.Http2Stream.takeHeaders(Http2Stream.java:24) at okhttp3.internal.http2.Http2ExchangeCodec.readResponseHeaders(Http2ExchangeCodec.java:5) at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.java:2) at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:145) ... </code></pre> <ol start="4"> <li>Another SocketTimeoutException</li> </ol> <pre><code>Non-fatal Exception: java.net.SocketTimeoutException: SSL handshake timed out at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(NativeCrypto.java) at com.android.org.conscrypt.NativeSsl.doHandshake(NativeSsl.java:387) at com.android.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(ConscryptFileDescriptorSocket.java:234) at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:72) at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.java:52) at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:196) at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.java:257) at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.java) at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.java:47) </code></pre> <p>And lastly, what makes me think it's not my server issue is that I get this kind of error when I request banner ads to Google server as well. I get thousands of reports of the following</p> <pre><code>{ &quot;Message&quot;: &quot;Error while connecting to ad server: Failed to connect to pubads.g.doubleclick.net/216.58.195.130:443&quot;, &quot;Cause&quot;: &quot;null&quot;, &quot;Response Info&quot;: { &quot;Adapter Responses&quot;: [], &quot;Response ID&quot;: &quot;null&quot;, &quot;Response Extras&quot;: {}, &quot;Mediation Adapter Class Name&quot;: &quot;&quot; }, &quot;Domain&quot;: &quot;com.google.android.gms.ads&quot;, &quot;Code&quot;: 0 } </code></pre> <p>from Google ads SDK's <code>onAdFailedToLoad</code> listener.</p> <h1>Attempt</h1> <p>I tried to find some solutions in Retrofit2/OkHttp3 github issues, SO community, and everyone says there may be some network permission issues or network connection problem itself. But I know users are connected to internet and not using some sort of proxy. I worked with customer service team and they walked through with users, and they did not find any network issues.</p> <p>Any insight would be helpful. Thank you in advance!</p>
[ { "answer_id": 74538997, "author": "Rohit Khanna", "author_id": 7306148, "author_profile": "https://Stackoverflow.com/users/7306148", "pm_score": 2, "selected": true, "text": "function buildTable(data){\n var table = document.getElementById('myTable')\n \n for (var i = 0; i < data.time.length; i++){ // edited\n var row = `<tr>\n <td>${data.time[i]}</td> // edited\n <td>${data.temperature_2m_max[i]}</td> // edited \n </tr>`\n table.innerHTML += row\n \n }\n }\n" }, { "answer_id": 74549952, "author": "Victor", "author_id": 20576072, "author_profile": "https://Stackoverflow.com/users/20576072", "pm_score": 0, "selected": false, "text": "function buildTable(data){\n var table = document.getElementById('myTable')\n \n for (var i = 0; i < data.time.length; i++){ // edited\n var row = `<tr>\n <td>${data.time[i]}</td> // edited\n <td>${data.temperature_2m_max[i]}</td> // edited \n </tr>`\n table.innerHTML += row\n \n }\n }\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3690442/" ]
74,538,999
<h1>Problem description</h1> <p>When merging two branches in git with conflicting files, git adds markers to the conflicting areas. For example, a file with conflict would look like this</p> <pre><code>Some code &lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD Changes in branch A ||||||| cbf9a68 Original code ======= changes in branch B &gt;&gt;&gt;&gt;&gt;&gt;&gt; branch-B some more code </code></pre> <p>where <code>branch-A</code>/<code>HEAD</code> is the branch to merge into, <code>branch-B</code> is the branch to merge, and <code>&lt;&lt;&lt;</code>, <code>===</code>, and <code>&gt;&gt;&gt;</code> are referred to as <em>conflict markers</em>. There are various tools that help in resolving these conflicts. These include <a href="http://meldmerge.org/" rel="nofollow noreferrer">meld</a>, <a href="https://www.vim.org/scripts/script.php?script_id=1797" rel="nofollow noreferrer">vimdiff</a>, <a href="https://github.com/sindrets/diffview.nvim" rel="nofollow noreferrer">diffview</a>, and many more. However, these tools can only be used in git repos that are in conflict-resolution status (i.e., when the two branches are not yet merged).</p> <p>There are situations where these tools can no longer be used (as far as I'm aware), and these include:</p> <ol> <li>if the conflicting files are comitted with the conflict markers (i.e., the conflicting files are comitted with <code>&lt;&lt;&lt;</code>, <code>===</code>, and <code>&gt;&gt;&gt;</code> markers);</li> <li>if the conflicting file with the conflict markers are moved outside a git repo (e.g., to keep track of conflicts).</li> </ol> <p>In such situations, the git merge tools can no longer be used to resolve these conflicts.</p> <p>It seems that these conflict tools are only possible to use in a git repo, which makes sense. So, my question is as follow: <strong>is it possible to use the git merge tools on files that contain conflict markers (i.e., <code>&lt;&lt;&lt;</code>, <code>===</code>, and <code>&gt;&gt;&gt;</code>) <em>outside</em> a git repo (or after comitting the file with conflict markers)?</strong></p> <p>That is, I would like the process to look like this:</p> <pre class="lang-bash prettyprint-override"><code>git checkout branch-A git merge branch-B # Part 1: committing file with conflict markers git add foo.txt # Add conflicting file, with conflict markers (i.e., withOUT resolving conflicts) git commit -m &quot;Add conflicting file&quot; # Commit file with conflict markers # Part 2: resolve conflict on committed files (i.e., this is what I'm asking for) # TODO: Use conflict resolution tools such as meld, diffview, etc. to find conflict markers and resolve them git add foo.txt # Stage and commit files after resolving conflicts git commit -m &quot;Conflicts resolved&quot; </code></pre> <h1>When is this problem encountered?</h1> <p>I understand this is an unusual way to use the git merge tools, but here's a situation where it can be used. Some organizations ask developers to commit the conflicting files <em>with the conflict markers</em>, and then resolve the conflicts in <em>another commit</em>. The reasoning is that when creating a PR, the reviewers can see how the developer resolved the conflicts.</p> <p>I understand this may be considered a bad practice (e.g., committing the files with conflict markers means there's a commit at which the code doesn't work or compile). However, my question is not about this practice since I have no option but to follow this convention.</p> <h1>Sub-optimal solution</h1> <p>A possible sub-optimal solution to the problem above is the following</p> <pre class="lang-bash prettyprint-override"><code>git checkout branch-A git merge branch-B # Part 1: committing file with conflict markers git add foo.txt # Add conflicting file, with conflict markers (i.e., withOUT resolving conflicts) git commit -m &quot;Add conflicting file&quot; # Commit file with conflict markers # Part 2: committing file to another branch after conflict resolution git checkout HEAD~1 # Checkout previous commit (i.e., before merging) git checkout -b branch-A-resolved # Create a branch at which the conflicts are to be resolved git merge branch-B # Merge branch-B # Resolve conflicts git add foo.txt # Add file *after* resolving conflicts git commit -m &quot;Resolve conflicts&quot; # Commit file withOUT conflict markers # Part 3: cherry-pick conflict-resolved files into branch-A git checkout branch-A git cherry-pick branch-A-resolved -m 1 -X theirs # `theirs` is used since `branch-A-resolved` contains the resolved file git branch -D branch-A-resolved </code></pre> <p>The above solution works, but as you can see, it's quite tedious.</p>
[ { "answer_id": 74539069, "author": "matt", "author_id": 341994, "author_profile": "https://Stackoverflow.com/users/341994", "pm_score": 0, "selected": false, "text": "diff3" }, { "answer_id": 74544745, "author": "torek", "author_id": 1256452, "author_profile": "https://Stackoverflow.com/users/1256452", "pm_score": 1, "selected": false, "text": "git mergetool git mergetool git update-index git mergetool git update-index git mergetool" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74538999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15749309/" ]
74,539,030
<p>I have a table with a column <code>LastUpdated</code> of type <code>DateTime</code>, and would like to add a column <code>LastUpdated2</code> to this table. I would like to populate it with whatever <code>LastUpdated</code> is for each existing row in the table.</p> <p>Eg:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>LastUpdated</th> </tr> </thead> <tbody> <tr> <td>12:01 PM</td> </tr> <tr> <td>5:00 PM</td> </tr> </tbody> </table> </div> <p>Becomes:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>LastUpdated</th> <th>LastUpdated2</th> </tr> </thead> <tbody> <tr> <td>12:01 PM</td> <td>12:01 PM</td> </tr> <tr> <td>5:00 PM</td> <td>5:00 PM</td> </tr> </tbody> </table> </div> <p>Quite simply as you can see, I just want them to match.</p> <p>I see a lot of example out there for an <code>ALTER</code> statement that has a default value, but didn't find any that have a specific value for each row as they're updated.</p> <p>Optimally I'd want my code to be something like this, hopefully this pseudocode makes sense:</p> <pre><code>ALTER TABLE dbo.Appointments ADD LastUpdated2 DATETIME DEFAULT (SELECT LastUpdated FROM CurrentRow) </code></pre> <p>I've also considered maybe just doing an <code>ALTER</code> statement, and then an <code>UPDATE</code> statement. Maybe this is the only way how to do it?</p>
[ { "answer_id": 74539069, "author": "matt", "author_id": 341994, "author_profile": "https://Stackoverflow.com/users/341994", "pm_score": 0, "selected": false, "text": "diff3" }, { "answer_id": 74544745, "author": "torek", "author_id": 1256452, "author_profile": "https://Stackoverflow.com/users/1256452", "pm_score": 1, "selected": false, "text": "git mergetool git mergetool git update-index git mergetool git update-index git mergetool" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20576171/" ]
74,539,087
<p>I want to write a java8 library and I have to compile it with java8 because it uses a ByteBuffer which has some nasty method signature change (which then throw the infamous error “method not found”).</p> <p>However the new Java versions has some nice features that I’d like to use if those are available at runtime. For instance newer version of Java has Inflater.setValue(ByteBuffer) and Arrays.compareUnsigned that allow the application to run faster based on a benchmark I did.</p> <p>How can I arrange a gradle project to use those features if are available considering that I have to build the project with JDK8?</p> <p>I was thinking of creating 2 different libraries, one named -jdk8 and the second one with postfix jdk9 but I’d like to avoid too much duplicate code.</p> <p>What’s the best practise?</p> <p>Thank you.</p>
[ { "answer_id": 74539668, "author": "Hoov", "author_id": 6760706, "author_profile": "https://Stackoverflow.com/users/6760706", "pm_score": 1, "selected": false, "text": "src/main/java src/main/java9" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1254562/" ]
74,539,145
<p>I have a hashtable with each element being an array:</p> <pre><code>PS\&gt;$table Name Value ---- ----- Size {2.72 GB, 5.18 GB} Computer {Server01, Server02} Count {363,765, 446,832} </code></pre> <p>Basically, I used the Invoke-Command to find the directory sizes of 2 computers rather than using a ForEach. I would like to display the results like:</p> <pre><code>Computer Count Size -------- ----- ---- Server01 363,765 2.72 GB Server02 446,832 4.18 GB </code></pre> <p>Having difficulty trying to get the values split up to display. I suspect I will have to use some sort of ForEach to create the display table. But noit sure what to loop on. TIA</p> <pre><code>$badmailtable | foreach {[PSCustomObject]$_} Size Computer Count ---- -------- ----- {2.72 GB, 5.18 GB} {Server01, Server02} {363,765, 446,832} </code></pre> <p>[EDIT: Code below] Original script:</p> <pre><code>$BadMailPath=&quot;D:\InetPub\mailroot\badmail&quot; $QueuePath=&quot;D:\InetPub\mailroot\queue&quot; $BadMailTable=@() $QueueTable=@() $Computers=@( [PSCustomObject]@{Server=&quot;Server01&quot;;Alias=&quot;SV01.anydomain.com&quot;} [PSCustomObject]@{Server=&quot;Server02&quot;;Alias=&quot;SV02.anydomain.com&quot;} ) Foreach ($Svr in $Computers) {Write-Color &quot;Retrieving &quot;,$Svr.Server,&quot; contents &quot;,$Svr.Alias White,Yellow,White,Green} $ScriptBlock = {param ($ParamPath) Get-ChildItem -path $ParamPath -recurse -force -erroraction silentlycontinue | Measure-Object -property Length -sum | Select-Object Sum,Count} $Params = @{ 'Computer'=$Computers.Server 'ScriptBlock'=$ScriptBlock 'Credential'=$ADCred 'ArgumentList'=$BadMailPath } $BadMailFolderSize = Invoke-Command @Params $Params = @{ 'Computer'=$Computers.Server 'ScriptBlock'=$ScriptBlock 'Credential'=$ADCred 'ArgumentList'=$QueuePath } $QueueFolderSize = Invoke-Command @Params </code></pre>
[ { "answer_id": 74539668, "author": "Hoov", "author_id": 6760706, "author_profile": "https://Stackoverflow.com/users/6760706", "pm_score": 1, "selected": false, "text": "src/main/java src/main/java9" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20576224/" ]
74,539,146
<p>I have a scenario where I would like to initialize the plot and plot a bunch of stuff on it before I run a widget on it. However, the jupyter widget refuses to plot on my already made plot. Instead, nothing shows up. A simplified example of this is below.</p> <pre><code>import matplotlib.pyplot as plt import ipywidgets as widgets from IPython import display fig=plt.figure(1,(2,2)) axs=fig.gca() def testAnimate(x): axs.text(0.5,0.5,x) xs=widgets.IntSlider(min=0,max=3,value=1) #Create our intslider such that the range is [1,50] and default is 10 gui = widgets.interactive(testAnimate, x=xs) #Create our interactive graphic with the slider as the argument display.display(gui) #display it </code></pre> <p>I would expect the value of x to show up on axs, but it does not. I realize that in this case I could just do plt.text, however in my actual project that is not viable. So, how do I get the value of x to show up on my plot?</p> <p>Thanks!</p>
[ { "answer_id": 74539668, "author": "Hoov", "author_id": 6760706, "author_profile": "https://Stackoverflow.com/users/6760706", "pm_score": 1, "selected": false, "text": "src/main/java src/main/java9" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20576265/" ]
74,539,196
<p>I deleted some non repeatable migrations <code>flyway_schema_history</code> from a certain point onwards. Now I want to rerun the migrations so they get inserted into the history table but of course they fail because they have already been applied (columns renamed for example). Is there a way to apply the migrations to the history table without actually running them in the database? Failing that, is there a different way to fix this that you could suggest? <code>repair</code> option didn't work, then again not sure if I used it right.</p>
[ { "answer_id": 74539668, "author": "Hoov", "author_id": 6760706, "author_profile": "https://Stackoverflow.com/users/6760706", "pm_score": 1, "selected": false, "text": "src/main/java src/main/java9" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1944515/" ]
74,539,221
<pre><code>Help New-item -parameter &quot;Value&quot; </code></pre> <p>show us -Value &lt;System.Object&gt; could be bind ByPropertyName or ByValue. The question is:</p> <p>** Is it possible <em>pipe</em> ByPropertyName? **</p> <p>As ByValue takes precedence over ByPropertyName, I can't find any example to be able to do that <em>pipe</em>. Anything I write to the left is an object, and is bound by ByValue, even if that object has the -Value attribute.</p> <p>Thank you</p> <p>Example:</p> <pre><code>$customObject = [PSCustomObject]@{ Value = &quot;Lorem ipsum&quot; } $customObject | New-Item -Name BPN_value.txt </code></pre> <p>The content of BPN_value.txt is @{Value = &quot;Lorem ipsum&quot;} because $customObject is an object (obviously) and it's binding byValue to the paramete Value of New_Item</p>
[ { "answer_id": 74539804, "author": "Santiago Squarzon", "author_id": 15339544, "author_profile": "https://Stackoverflow.com/users/15339544", "pm_score": 3, "selected": true, "text": "New-Item -Value ByPropertyName System.Object ValueFromPipeline ValueFromPipelineByPropertyName System.Object $null = New-Item -Path function:Say-Hello -Value {\n 'hey there'\n}\n\nSay-Hello\n -Value New-Item System.Object System.String ValueFromPipeline ValueFromPipelineByPropertyName $PROFILE FileSystem ItemType = File function New-File {\n [CmdletBinding(DefaultParameterSetName='pathSet', SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='https://go.microsoft.com/fwlink/?LinkID=2096592')]\n param(\n [Parameter(ParameterSetName='pathSet', Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]\n [Parameter(ParameterSetName='nameSet', Position=0, ValueFromPipelineByPropertyName=$true)]\n [string[]]\n ${Path},\n\n [Parameter(ParameterSetName='nameSet', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]\n [AllowNull()]\n [AllowEmptyString()]\n [string]\n ${Name},\n\n [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]\n [Alias('Target')]\n [string]\n ${Value},\n\n [switch]\n ${Force}\n )\n\n begin {\n try {\n $outBuffer = $null\n if ($PSBoundParameters.TryGetValue('OutBuffer', [ref] $outBuffer)) {\n $PSBoundParameters['OutBuffer'] = 1\n }\n\n $PSBoundParameters['ItemType'] = 'File'\n\n $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Microsoft.PowerShell.Management\\New-Item', [System.Management.Automation.CommandTypes]::Cmdlet)\n $scriptCmd = { & $wrappedCmd @PSBoundParameters }\n\n $steppablePipeline = $scriptCmd.GetSteppablePipeline($myInvocation.CommandOrigin)\n $steppablePipeline.Begin($PSCmdlet)\n }\n catch {\n $PSCmdlet.ThrowTerminatingError($_)\n }\n }\n\n process {\n try {\n $steppablePipeline.Process($Value)\n }\n catch {\n $PSCmdlet.ThrowTerminatingError($_)\n }\n }\n\n end {\n try {\n $steppablePipeline.End()\n } catch {\n $PSCmdlet.ThrowTerminatingError($_)\n }\n }\n <#\n .ForwardHelpTargetName Microsoft.PowerShell.Management\\New-Item\n .ForwardHelpCategory Cmdlet\n #>\n}\n\n[PSCustomObject]@{ Value = \"Lorem ipsum\" } | New-File .\\BPN_value.txt -Force\n\"Lorem ipsum\" | New-File .\\BPN_value2.txt -Force\n [System.Management.Automation.ProxyCommand]::Create((Get-Command New-Item))\n" }, { "answer_id": 74542645, "author": "Keith Miller", "author_id": 9406738, "author_profile": "https://Stackoverflow.com/users/9406738", "pm_score": 0, "selected": false, "text": "-Path -Name [PSCustomObject]@{\n name = 'TestFile'\n value = 'Hello World'\n} | New-Item\n PS ScratchPad> [PSCustomObject]@{\n>> Name = 'TestFile'\n>> value = 'Hello World'\n>> } | New-Item\n\n\n Directory: C:\\ScratchPad\n\n\nMode LastWriteTime Length Name\n---- ------------- ------ ----\n-a---- 11/23/2022 12:07 AM 35 TestFile\n PS ScratchPad> [PSCustomObject]@{\n>> Path = \"$Home\\Documents\\TestFile.txt\"\n>> value = 'Hello World'\n>> } | New-Item\n\n\n Directory: C:\\Users\\keith\\Documents\n\n\nMode LastWriteTime Length Name\n---- ------------- ------ ----\n-a---- 11/23/2022 12:27 AM 64 TestFile.txt\n -Path -Name PS ScratchPad> [PSCustomObject]@{\n>> Path = \"$Home\\Documents\"\n>> Name = 'TestFile'\n>> value = 'Hello World'\n>> } | New-Item\nNew-Item : Access to the path 'C:\\Users\\keith\\Documents' is denied.\nAt line:5 char:5\n+ } | New-Item\n+ ~~~~~~~~\n + CategoryInfo : PermissionDenied: (C:\\Users\\keith\\Documents:String) [New\n -Item], UnauthorizedAccessException\n + FullyQualifiedErrorId : NewItemUnauthorizedAccessError,Microsoft.PowerShell.Comm\n ands.NewItemCommand\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20576058/" ]
74,539,243
<p>My string value;</p> <p><code>09:00-10:00,12:00-14:30,16:00-18:00</code> (this string repeats time intervals n times like this)</p> <p>and I want to find out that a string is in the correct format using pattern matching;</p> <pre><code>Pattern.matches(&quot;&lt;Pattern Here&gt;&quot;, stringValue); </code></pre> <p>is it possible?</p> <p>I tried;</p> <pre><code>Pattern.matches(&quot;^[0-9:0-9-0-9:0-9,]+$&quot;, value); </code></pre> <p>But doesn't work properly</p>
[ { "answer_id": 74539333, "author": "Yonatan Karp-Rudin", "author_id": 3899765, "author_profile": "https://Stackoverflow.com/users/3899765", "pm_score": 3, "selected": true, "text": "private static final String HOURLY_TIME_PATTERN = \"([01][0-9]|2[0-3]):([0-5][0-9])\";\nprivate static final String TIME_RANGER_PATTERN = HOURLY_TIME_PATTERN + \"-\" + HOURLY_TIME_PATTERN;\nprivate static final String PATTERN = \"^\" + TIME_RANGER_PATTERN + \"(,\" + TIME_RANGER_PATTERN + \"?)*$\";\nprivate static final Pattern pattern = Pattern.compile(PATTERN);\n\npublic static void main(String[] args) {\n String input = \"09:00-10:00,12:00-14:30,16:00-18:00\";\n if (pattern.matcher(input).matches()) {\n System.out.println(\"We have a match!\");\n }\n}\n HOURLY_TIME_PATTERN" }, { "answer_id": 74539634, "author": "Arvind Kumar Avinash", "author_id": 10819573, "author_profile": "https://Stackoverflow.com/users/10819573", "pm_score": 3, "selected": false, "text": "^(?:(?:\\d{2}:\\d{2}\\-\\d{2}:\\d{2})(?:,(?!$))?)*$ ^ $ String#matches , - import java.time.LocalTime;\nimport java.time.format.DateTimeParseException;\n\npublic class Main {\n public static void main(String[] args) {\n // Test\n System.out.println(hasCorrectFormat(\"09:00-10:00,12:00-14:30,16:00-18:00\")); // true\n System.out.println(hasCorrectFormat(\"09:00-10:00,12:00-1:30,16:00-18:00\")); // false -> 1:30 is not in desired\n // format\n System.out.println(hasCorrectFormat(\"09:00-10:00\")); // true\n System.out.println(hasCorrectFormat(\"09:00 10:00\")); // false\n System.out.println(hasCorrectFormat(\"09:00-10:00,09:00 10:00\")); // false\n System.out.println(hasCorrectFormat(\"09:00-10:00-12:00-14:30,16:00-18:00\")); // false\n System.out.println(hasCorrectFormat(\"09:00-10:00,12:00-14:30,16:00-18:00,\")); // false\n }\n\n static boolean hasCorrectFormat(String strTimeRanges) {\n if (!strTimeRanges.matches(\"(?:(?:\\\\d{2}:\\\\d{2}\\\\-\\\\d{2}:\\\\d{2})(?:,(?!$))?)*\"))\n return false;\n String[] times = strTimeRanges.split(\"[-,]\");\n for (String time : times) {\n try {\n LocalTime.parse(time);\n } catch (DateTimeParseException e) {\n return false;\n }\n }\n return true;\n }\n}\n true\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\n import java.time.LocalTime;\nimport java.time.format.DateTimeParseException;\n\npublic class Main {\n public static void main(String[] args) {\n // Test\n System.out.println(hasCorrectFormatAndRanges(\"09:00-10:00,12:00-14:30,16:00-18:00\")); // true\n System.out.println(hasCorrectFormatAndRanges(\"09:00-10:00,12:00-1:30,16:00-18:00\")); // false -> 1:30\n System.out.println(hasCorrectFormatAndRanges(\"10:00-09:00,12:00-14:30,16:00-18:00\")); // false -> 10:00-09:00\n System.out.println(hasCorrectFormatAndRanges(\"09:00-10:00\")); // true\n System.out.println(hasCorrectFormatAndRanges(\"09:00 10:00\")); // false\n System.out.println(hasCorrectFormatAndRanges(\"09:00-10:00,09:00 10:00\")); // false\n System.out.println(hasCorrectFormatAndRanges(\"09:00-10:00-12:00-14:30,16:00-18:00\")); // false\n System.out.println(hasCorrectFormatAndRanges(\"09:00-10:00,12:00-14:30,16:00-18:00,\")); // false\n }\n\n static boolean hasCorrectFormatAndRanges(String strTimeRanges) {\n if (!strTimeRanges.matches(\"(?:(?:\\\\d{2}:\\\\d{2}\\\\-\\\\d{2}:\\\\d{2})(?:,(?!$))?)*\"))\n return false;\n String[] timeRanges = strTimeRanges.split(\",\");\n for (String timeRange : timeRanges) {\n String[] times = timeRange.split(\"-\");\n try {\n if (LocalTime.parse(times[1]).isBefore(LocalTime.parse(times[0])))\n return false;\n } catch (DateTimeParseException e) {\n return false;\n }\n }\n return true;\n }\n}\n true\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8488586/" ]
74,539,288
<pre><code>door = input(&quot;Do you want to open the door? Enter yes or no: &quot;).lower() while door != &quot;yes&quot; and door != &quot;no&quot;: print(&quot;Invalid answer.&quot;) door = input(&quot;Do you want to open the door? Enter yes or no: &quot;).lower() if door == &quot;yes&quot;: print(&quot;You try to twist open the doorknob but it is locked.&quot;) elif door == &quot;no&quot;: print(&quot;You decide not to open the door.&quot;) </code></pre> <p>Is there an easier way to use the while loop for invalid answers? So I won't need to add that line after every single question in the program.</p> <p>I tried def() and while true, but not quite sure how to use the them correctly.</p>
[ { "answer_id": 74539329, "author": "Johnny Mopp", "author_id": 669576, "author_profile": "https://Stackoverflow.com/users/669576", "pm_score": 3, "selected": true, "text": "while True\n door = input(\"Do you want to open the door? Enter yes or no: \").lower()\n if door in (\"yes\", \"no\"):\n break\n print(\"Invalid answer.\")\n def get_input(prompt, error, choices):\n while True:\n answer = input(f\"{prompt} Enter {', '.join(choices)}: \")\n if answer in choices:\n return answer\n print(error)\n door = get_input(\"Do you want to open the door?\", \"Invalid answer.\", (\"yes\", \"no\"))\nif door == \"yes\":\n print(\"You try to twist open the doorknob but it is locked.\")\nelse:\n print(\"You decide not to open the door.\")\n" }, { "answer_id": 74539331, "author": "John Gordon", "author_id": 494134, "author_profile": "https://Stackoverflow.com/users/494134", "pm_score": -1, "selected": false, "text": "while True:\n answer = (\"Enter yes or no: \").lower()\n if answer in [\"yes\", \"no\"]:\n break\n print(\"Invalid answer.\")\n # loop will repeat again\n \n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20576200/" ]
74,539,303
<p>I am trying to install the migrations on a fresh install of laravel 9, however I am getting this error</p> <blockquote> <p>Problem 1</p> <ul> <li>Root composer.json requires laravel-doctrine/migrations ^2.3 -&gt; satisfiable by laravel-doctrine/migrations[2.3.0, 2.3.1, 2.x-dev].</li> <li>laravel-doctrine/migrations[2.3.0, ..., 2.x-dev] require illuminate/config ^6.0|^7.0|^8.0 -&gt; found illuminate/config[v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev] but these were not loaded, likely because it conflicts with another require.</li> </ul> <p>You can also try re-running composer require with an explicit version constraint, e.g. &quot;composer require laravel-doctrine/migrations:*&quot; to figure out if any version is installable, or &quot;composer require laravel-doctrine/migrations:^2.1&quot; if you know which you need.</p> </blockquote> <p>previously I installed the orm with this command</p> <pre><code>composer require laravel-doctrine/orm </code></pre> <p>I have tried to install other versions but the message is the same</p> <p>composer.json</p> <pre><code>{ &quot;name&quot;: &quot;laravel/laravel&quot;, &quot;type&quot;: &quot;project&quot;, &quot;description&quot;: &quot;The Laravel Framework.&quot;, &quot;keywords&quot;: [&quot;framework&quot;, &quot;laravel&quot;], &quot;license&quot;: &quot;MIT&quot;, &quot;require&quot;: { &quot;php&quot;: &quot;^8.0.2&quot;, &quot;guzzlehttp/guzzle&quot;: &quot;^7.2&quot;, &quot;laravel-doctrine/orm&quot;: &quot;^1.8&quot;, &quot;laravel-doctrine/migrations&quot;:&quot;^2.3&quot;, &quot;laravel/framework&quot;: &quot;^9.19&quot;, &quot;laravel/sanctum&quot;: &quot;^3.0&quot;, &quot;laravel/tinker&quot;: &quot;^2.7&quot; }, &quot;require-dev&quot;: { &quot;fakerphp/faker&quot;: &quot;^1.9.1&quot;, &quot;laravel/pint&quot;: &quot;^1.0&quot;, &quot;laravel/sail&quot;: &quot;^1.0.1&quot;, &quot;mockery/mockery&quot;: &quot;^1.4.4&quot;, &quot;nunomaduro/collision&quot;: &quot;^6.1&quot;, &quot;phpunit/phpunit&quot;: &quot;^9.5.10&quot;, &quot;spatie/laravel-ignition&quot;: &quot;^1.0&quot; }, &quot;autoload&quot;: { &quot;psr-4&quot;: { &quot;App\\&quot;: &quot;app/&quot;, &quot;Database\\Factories\\&quot;: &quot;database/factories/&quot;, &quot;Database\\Seeders\\&quot;: &quot;database/seeders/&quot; } }, &quot;autoload-dev&quot;: { &quot;psr-4&quot;: { &quot;Tests\\&quot;: &quot;tests/&quot; } }, &quot;scripts&quot;: { &quot;post-autoload-dump&quot;: [ &quot;Illuminate\\Foundation\\ComposerScripts::postAutoloadDump&quot;, &quot;@php artisan package:discover --ansi&quot; ], &quot;post-update-cmd&quot;: [ &quot;@php artisan vendor:publish --tag=laravel-assets --ansi --force&quot; ], &quot;post-root-package-install&quot;: [ &quot;@php -r \&quot;file_exists('.env') || copy('.env.example', '.env');\&quot;&quot; ], &quot;post-create-project-cmd&quot;: [ &quot;@php artisan key:generate --ansi&quot; ] }, &quot;extra&quot;: { &quot;laravel&quot;: { &quot;dont-discover&quot;: [] } }, &quot;config&quot;: { &quot;optimize-autoloader&quot;: true, &quot;preferred-install&quot;: &quot;dist&quot;, &quot;sort-packages&quot;: true, &quot;allow-plugins&quot;: { &quot;pestphp/pest-plugin&quot;: true } }, &quot;minimum-stability&quot;: &quot;dev&quot;, &quot;prefer-stable&quot;: true } </code></pre> <h2><strong>UPDATE</strong></h2> <p>I am trying to install the package with laravel 8 however I have this error when executing the command for version ~1.7</p> <p>command</p> <pre><code>composer require laravel-doctrine/orm doctrine/inflector:&quot;^1.4|^2.0&quot; </code></pre> <p>Error</p> <blockquote> <p>Problem 1 - laravel-doctrine/orm[1.8.0, ..., 1.8.x-dev] require illuminate/support ^9.0 -&gt; found illuminate/support[v9.0.0-beta.1, ..., 9.x-dev] but these were not loaded, likely because it conflicts with another require. - Root composer.json requires laravel-doctrine/orm ^1.8 -&gt; satisfiable by laravel-doctrine/orm[1.8.0, 1.8.1, 1.8.x-dev].</p> <p>You can also try re-running composer require with an explicit version constraint, e.g. &quot;composer require laravel-doctrine/orm:*&quot; to figure out if any version is installable, or &quot;composer require laravel-doctrine/orm:^2.1&quot; if you know which you need.</p> </blockquote>
[ { "answer_id": 74539546, "author": "Felipe Castillo", "author_id": 7115643, "author_profile": "https://Stackoverflow.com/users/7115643", "pm_score": 0, "selected": false, "text": "composer require laravel-doctrine/orm \"^1.7\" doctrine/inflector:\"^1.4|^2.0\"\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7115643/" ]
74,539,318
<p>I have a string that has highlighted portions with <code>^</code> sign:</p> <pre><code>const inputValue = 'jhon duo ^has a car^ right ^we know^ that'; </code></pre> <p>Now how to return an array which is splited based on words and <code>^</code> highlights, so that we return this array:</p> <pre><code>['jhon','duo', 'has a car', 'right', 'we know', 'that'] </code></pre> <p>Using <code>const input = inputValue.split('^');</code> to split by <code>^</code> and <code>const input = inputValue.split(' ');</code> to split by words is not working and I think we need a better idea.</p> <p>How would you do this?</p>
[ { "answer_id": 74539393, "author": "trincot", "author_id": 5459839, "author_profile": "https://Stackoverflow.com/users/5459839", "pm_score": 3, "selected": true, "text": "match const inputValue = 'jhon duo ^has a car^ right ^we know^ that';\nconst result = Array.from(inputValue.matchAll(/\\^(.*?)\\^|([^^\\s]+)/g),\n ([, a, b]) => a || b);\nconsole.log(result); \\^(.*?)\\^ ^ ^ ([^^\\s]+) ^ | Array.from ^" }, { "answer_id": 74539706, "author": "CCC", "author_id": 1687399, "author_profile": "https://Stackoverflow.com/users/1687399", "pm_score": 1, "selected": false, "text": "^ function splitHighlights (inputValue) {\n const inputSplit = inputValue.split('^');\n let highlighted = true\n const result = inputSplit.flatMap(splitVal => {\n highlighted = !highlighted\n if (splitVal == '') {\n return [];\n } else if (highlighted) {\n return splitVal.trim();\n } else {\n return splitVal.trim().split(' ')\n }\n })\n if (highlighted) {\n throw new Error(`unmatched '^' char: expected an even number of '^' characters in input`);\n }\n return result;\n}\nconsole.log(splitHighlights('^jhon duo^ has a car right ^we know^ that'));\nconsole.log(splitHighlights('jhon duo^ has^ a car right we^ know that^'));\nconsole.log(splitHighlights('jhon duo^ has a car^ right ^we know^ that'));\nconsole.log(splitHighlights('jhon ^duo^ has a car^ right ^we know^ that'));" }, { "answer_id": 74539785, "author": "bobble bubble", "author_id": 5527985, "author_profile": "https://Stackoverflow.com/users/5527985", "pm_score": 1, "selected": false, "text": "split() *\\^([^^]*)\\^ *| + const inputValue = 'jhon duo ^has a car^ right ^we know^ that';\n\n// filtering avoids empty items if split-sequence at start or end\nlet input = inputValue.split(/ *\\^([^^]*)\\^ *| +/).filter(Boolean);\n\nconsole.log(input); *\\^ ([^^]*) \\^ * | +" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10715551/" ]
74,539,336
<p>Why does this go into an infinite loop and why does it dump char 0x20?</p> <pre><code>#include &lt;iostream&gt; struct Outer { Outer(std::string &amp;outerString, std::string &amp;superfluousString1, std::string &amp;superfluousString2) : outerString(outerString), inner(*this) {} struct Inner { Inner(Outer &amp;outer) { std::cout &lt;&lt; outer.outerString; } } inner; std::string &amp;outerString; }; int main() { std::string outerString(&quot;outerString&quot;), superfluousString1(&quot;superfluousString1&quot;), superfluousString2(&quot;superfluousString2&quot;); Outer outer(outerString, superfluousString1, superfluousString2); return 0; } </code></pre> <p>I discover this whist I was playing around with inner classes. C++ is not main language, and I am coming to this from a long hiatus, so I am asking this to improve my knowledge. I do know that I should not be using the fields of Outer before it has been properly created, so this is a very bad thing to do generally. I feel that the real answer is likely that just because I do not have a compiler error does not mean that something is correct.</p> <p>An interesting side note is that, if I remove either of the superfluous strings, I get a compiler error or it will simply segfault, and that is kind of what I had expected it to do. I boiled this down from a more complex structure that I was playing with, and the elements involved seem to be the minimum required to evoke this response.</p>
[ { "answer_id": 74539526, "author": "Yksisarvinen", "author_id": 7976805, "author_profile": "https://Stackoverflow.com/users/7976805", "pm_score": 4, "selected": true, "text": "inner outerString outerString struct Outer {\n Outer(std::string &outerString, std::string &superfluousString, std::string &innerString): outerString(outerString), inner(*this) {}\n\n std::string &outerString; //declared before 'inner'\n struct Inner {\n Inner(Outer &outer) {\n std::cout << outer.outerString;\n }\n } inner;\n};\n" }, { "answer_id": 74539527, "author": "M.M", "author_id": 1505939, "author_profile": "https://Stackoverflow.com/users/1505939", "pm_score": 2, "selected": false, "text": "Outer::outerString outerString inner Outer" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1859605/" ]
74,539,366
<p>I'm struggling with OpenMaya here.</p> <p>I want to be able to take transform information from a list of locators and plug these values to particles shapes. The goal is to use this over 25000 locators, so I can't create a particle system for each instance. I really need to store position and rotation values to the particles themselves.</p> <p>To do that I started to dive into OpenMaya... (╯°□°)╯︵ ┻━┻</p> <p>Anyway, the problem I'm facing now is that my scene crashes every time I launch this script and I can't figure out what I did wrong. I think I'm pretty close, but crashing Maya is not considered a victory.</p> <pre class="lang-py prettyprint-override"><code>import pymel.core as pm import maya.OpenMaya as om import maya.OpenMayaFX as omfx import random ### A short script to create the scene with bunch of locators with random pos rot numOfLoc = 5 # this number will eventually be set 25000 when the script will work. # create locators with random position location(for test) def create_gazillion_locators(numOfLoc): for i in range(0, numOfLoc): # to create variation tx = random.uniform(-10, 10) ty = random.uniform(0, 5) tz = random.uniform(-10, 10) rx = random.uniform(0, 360) ry = random.uniform(0, 360) rz = random.uniform(0, 360) pm.spaceLocator() pm.move(tx, ty, tz) pm.rotate(rx, ry, rz, ws=True) # Select locators def select_locators(): pm.select(cl=True) loc_selection = pm.listRelatives(pm.ls(type = 'locator'), p=True) pm.select(loc_selection, r=True) return loc_selection # delete the locators def clean_the_scene(): #del locators (for testing purpiose) sel = select_locators() if sel is not None: pm.delete(sel) clean_the_scene() create_gazillion_locators(numOfLoc) ### Actual script # Found this on the internet. it seems to be more neat class Vector(om.MVector): def __str__(self): return '{0}, {1}, {2}'.format(self.x, self.y, self.z) def __repr__(self): return '{0}, {1}, {2}'.format(self.x, self.y, self.z) # OpenMaya treatment sel = select_locators() mSel = om.MSelectionList() om.MGlobal.getActiveSelectionList(mSel) mSel_iter = om.MItSelectionList(mSel) mSel_DagPath = om.MDagPath() # bvariables to store the transform in pos_array = om.MVectorArray() rot_array = om.MVectorArray() mLoc = om.MObject() # Main loop of selection iterator. while not mSel_iter.isDone(): # Get list of selected mSel_iter.getDagPath(mSel_DagPath) mSel_iter.getDependNode(mLoc) dep_node_name = om.MFnDependencyNode(mLoc).name() transl = pm.getAttr('{}.translate'.format(dep_node_name)) rotate = pm.getAttr('{}.rotate'.format(dep_node_name)) print(dep_node_name) print(Vector(transl[0], transl[1], transl[2])) print(Vector(rotate[0], rotate[1], rotate[2])) pos_array.append(Vector(transl[0], transl[1], transl[2])) rot_array.append(Vector(rotate[0], rotate[1], rotate[2])) mSel_iter.next() # Up untill there it seems to work ok. nparticles_transform, nparticles_shape = pm.nParticle(position = pos_array) pm.setAttr('nucleus1.gravity', 0.0) nparticles_shape.computeRotation.set(True) pm.addAttr(nparticles_shape, ln = 'rotationPP', dt = 'vectorArray') pm.addAttr(nparticles_shape, ln = 'rotationPP0', dt = 'vectorArray') pm.particleInstancer(nparticles_shape, name = p_instancer, edit = True, rotation = &quot;rotationPP&quot;) particle_fn = omfx.MFnParticleSystem(nparticles_shape.__apimobject__()) particle_fn.setPerParticleAttribute('rotationPP', rot_array) particle_fn.setPerParticleAttribute('rotationPP0', rot_array) </code></pre> <p>I read lots of things, went through the stack and google, I based my script on several other stuff I found/learnt (I listened to the OpenMaya course on Youtube by Chayan Vinayak)... But I've had a hard time understanding the OpenMaya documentation though.</p>
[ { "answer_id": 74539526, "author": "Yksisarvinen", "author_id": 7976805, "author_profile": "https://Stackoverflow.com/users/7976805", "pm_score": 4, "selected": true, "text": "inner outerString outerString struct Outer {\n Outer(std::string &outerString, std::string &superfluousString, std::string &innerString): outerString(outerString), inner(*this) {}\n\n std::string &outerString; //declared before 'inner'\n struct Inner {\n Inner(Outer &outer) {\n std::cout << outer.outerString;\n }\n } inner;\n};\n" }, { "answer_id": 74539527, "author": "M.M", "author_id": 1505939, "author_profile": "https://Stackoverflow.com/users/1505939", "pm_score": 2, "selected": false, "text": "Outer::outerString outerString inner Outer" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17300895/" ]
74,539,375
<p>I have labels in a ListView that display the size and finish of an object (an SKU). I would like to change the color of the font of those labels if that particular SKU is &quot;in stock&quot; (has a stockedid of 1). The stocked attribute is part of the table with the size and finish, but it is not displayed. I have looked for a solution, but nothing seems to be exactly what I want, since I am not displaying the information that is used to format the label.</p> <p>Please &quot;speak slowly&quot; :-) as I'm a relative novice with this type of thing. (As is probably evident.)</p> <pre><code>&lt;asp:ListView ID=&quot;ListViewSSD&quot; runat=&quot;server&quot; DataSourceID=&quot;SSD&quot; &gt; &lt;ItemTemplate&gt; &lt;div id=&quot;sdoptions&quot;&gt; &lt;asp:HyperLink ID=&quot;HyperLink1&quot; runat=&quot;server&quot; NavigateUrl='&lt;%# Eval(&quot;SKU&quot;, &quot;ST.aspx?SKU={0}&quot;) %&gt;' ImageUrl='&lt;%# Eval(&quot;image1path&quot;, &quot;Images/{0}&quot;) %&gt;' &gt;&lt;/asp:HyperLink&gt; &lt;asp:Label ID=&quot;Label8&quot; runat=&quot;server&quot; Text='&lt;%# Eval(&quot;length&quot;, &quot;{0}\&quot; x &quot;) %&gt;'&gt;&lt;/asp:Label&gt; &lt;asp:Label ID=&quot;Label9&quot; runat=&quot;server&quot; Text='&lt;%# Eval(&quot;width&quot;, &quot;{0}\&quot;&quot;) %&gt;'&gt;&lt;/asp:Label&gt; &lt;asp:Label ID=&quot;finishLabel&quot; runat=&quot;server&quot; cssClass=&quot;tinyprint&quot; Text='&lt;%# Eval(&quot;finish&quot;, &quot;({0})&quot;) %&gt;' /&gt; &lt;/div&gt; &lt;/ItemTemplate&gt; &lt;/asp:ListView&gt; </code></pre> <p>Thank you.</p>
[ { "answer_id": 74539526, "author": "Yksisarvinen", "author_id": 7976805, "author_profile": "https://Stackoverflow.com/users/7976805", "pm_score": 4, "selected": true, "text": "inner outerString outerString struct Outer {\n Outer(std::string &outerString, std::string &superfluousString, std::string &innerString): outerString(outerString), inner(*this) {}\n\n std::string &outerString; //declared before 'inner'\n struct Inner {\n Inner(Outer &outer) {\n std::cout << outer.outerString;\n }\n } inner;\n};\n" }, { "answer_id": 74539527, "author": "M.M", "author_id": 1505939, "author_profile": "https://Stackoverflow.com/users/1505939", "pm_score": 2, "selected": false, "text": "Outer::outerString outerString inner Outer" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2687065/" ]
74,539,388
<p>In my ASP.NET Core API, I need to make 3 separate calls to 3 different repositories in order to collect all the data I need to make decisions.</p> <p>I want to shave off all the time I can in order to speed things up. Is there any difference in terms of time it will take for all 3 call to complete using the regular or a parallel invoke approach?</p> <p>The regular way would be:</p> <pre><code>var customer = await _customersRepository.GetCustomer(customerId); var balance = await _salesRepository.GetCustomerBalance(customerId); var product = await _productsRepository.GetProduct(productId); </code></pre> <p>I haven't used the parallel approach before but I think it goes something like this:</p> <pre><code>Customer customer; Balance balance; Product product; Parallel.Invoke( () =&gt; { customer = await _customerRepository.GetCustomer(customerId); }, () =&gt; { balance = await _salesRepository.GetCustomerBalance(customerId); }, () =&gt; { product = await _productRepository.GetProduct(productid); }); </code></pre> <p>Again, my main concern is to complete all three repository/database calls as quickly as I can so that I have all the data I need to make a decision. With that said:</p> <ol> <li>Is there any benefit to running parallel tasks to save time?</li> <li>Are there any other benefits or concerns to using the parallel invoke approach?</li> </ol>
[ { "answer_id": 74539526, "author": "Yksisarvinen", "author_id": 7976805, "author_profile": "https://Stackoverflow.com/users/7976805", "pm_score": 4, "selected": true, "text": "inner outerString outerString struct Outer {\n Outer(std::string &outerString, std::string &superfluousString, std::string &innerString): outerString(outerString), inner(*this) {}\n\n std::string &outerString; //declared before 'inner'\n struct Inner {\n Inner(Outer &outer) {\n std::cout << outer.outerString;\n }\n } inner;\n};\n" }, { "answer_id": 74539527, "author": "M.M", "author_id": 1505939, "author_profile": "https://Stackoverflow.com/users/1505939", "pm_score": 2, "selected": false, "text": "Outer::outerString outerString inner Outer" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1705266/" ]
74,539,394
<h1>Problem</h1> <p>I have a list of approximatly 200000 nodes that represent lat/lon position in a city and I have to compute the Minimum Spanning Tree. I know that I need to use Prim algorithm but first of all I need a connected graph. (We can assume that those nodes are in a Euclidian plan)</p> <p>To build this connected graph I thought firstly to compute the complete graph but (205000*(205000-1)/2 is around 19 billions edges and I can't handle that.</p> <h1>Options</h1> <p>Then I came across to Delaunay triangulation: with the fact that if I build this &quot;Delauney graph&quot;, it contains a sub graph that is the Minimum Spanning Tree according and I have a total of around 600000 edges according to <a href="https://en.wikipedia.org/wiki/Euclidean_minimum_spanning_tree#Two_dimensions" rel="nofollow noreferrer">Wikipedia</a> <em>[..]it has at most 3n-6 edges.</em> So it may be a good starting point for a Minimum Spanning Tree algorithm.</p> <p>Another options is to build an approximately connected graph but with that I will maybe miss important edges that will influence my Minimum Spanning Tree.</p> <h1>My question</h1> <p>Is Delaunay a reliable solution in this case? If so, is there any other reliable solution than delaunay triangulation to this problem ?</p> <p>Further information: this problem has to be solved in C.</p>
[ { "answer_id": 74539600, "author": "Edward Peters", "author_id": 6016064, "author_profile": "https://Stackoverflow.com/users/6016064", "pm_score": 2, "selected": false, "text": "n^2 100*100 p p" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20576185/" ]
74,539,426
<p>I have a form (F_ptselect) with multiple subforms (F_s1, F_s2, F_s3). On the main form I have a combo box that allows me to choose an integer identifier (i.e., ID = 1001, id = 1002, id = 1003, id = 1004, etc.). The subforms are also all linked by ID using &quot;Link Master Fields&quot; and &quot;Link Child Fields&quot;. I've found and modified vba that allows me to choose an ID (say 1001) from the combo box on F_ptselect, and subsequently pull up all the data for ID = 1001 on F_s1, F_s2, and F_s3.</p> <p>Here's that vba:</p> <pre><code>Private Sub find_ID_AfterUpdate() ' Find the record that matches the control. Dim rs As Object Set rs = Me.Recordset.Clone rs.FindFirst &quot;[ID] = &quot; &amp; Me![find_ID] &amp; &quot;&quot; If Not rs.EOF Then Me.Bookmark = rs.Bookmark End Sub </code></pre> <p>Now, for each ID there are multiple records (i.e., ID=1001 and day=1, ID=1001 and day=2, ID=1002 and day=1, ID=1002 and day=2 etc.). I'd like to be able to have a combo box or button or something that allows me to synchronize the ability to cycle through these records of a single ID. So if I select ID 1001 from the F_ptselect combo box, I'd like to see F_s1, F_s2, and F_s3 for ID 1001, day 1. Then I'd like to be able to change to day 2 for ID 1001 quickly using a combo box selection, button or something. Currently, I'd have to go to the record arrows at the bottom of each subform to change the record. Each row of data has a primary key (let's call it KEY) as well. So a query row or table row would look like:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>KEY</th> <th>ID</th> <th>Day</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1001</td> <td>1</td> </tr> <tr> <td>2</td> <td>1001</td> <td>2</td> </tr> <tr> <td>3</td> <td>1002</td> <td>1</td> </tr> <tr> <td>4</td> <td>1002</td> <td>2</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74551787, "author": "June7", "author_id": 7607190, "author_profile": "https://Stackoverflow.com/users/7607190", "pm_score": 2, "selected": true, "text": "ctrFS1 Sub cbxDay_AfterUpdate()\nDim strF As String\nWith Me\nstrF = \"[Day]=\" & .cbxDay\n.ctrFS1.Form.Filter = strF\n.ctrFS1.Form.FilterOn = True\n.ctrFS2.Form.Filter = strF\n.ctrFS2.Form.FilterOn = True\n.ctrFS3.Form.Filter = strF\n.ctrFS3.Form.FilterOn = True\nEnd With\nEnd Sub\n Dim x As Integer\nWith Me\nFor x = 1 to 3\n .Controls(\"ctrFS\" & x).Form.Filter = \"Day=\" & .cbxDay\n .Controls(\"ctrFS\" & x).Form.FilterOn = True\nNext\nEnd With\n" }, { "answer_id": 74552541, "author": "ElphiusMostafa", "author_id": 10225568, "author_profile": "https://Stackoverflow.com/users/10225568", "pm_score": 0, "selected": false, "text": "Private Sub find_day_AfterUpdate()\nDim strF1 As String\nWith Me\nstrF1 = \"[Day]='\" & .find_day & \"'\"\n.F_s1.Form.Filter = strF1\n.F_s1.Form.FilterOn = True\nEnd With\n\nDim strF2 As String\nWith Me\nstrF2 = \"[Day]='\" & .find_day & \"'\"\n.F_s2.Form.Filter = strF2\n.F_s2.Form.FilterOn = True\nEnd With\n\nDim strF3 As String\nWith Me\nstrF3 = \"[Day]='\" & .find_day & \"'\"\n.F_s3.Form.Filter = strF3\n.F_s3.Form.FilterOn = True\nEnd With\nEnd Sub\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10225568/" ]
74,539,432
<p>I would like to show row and column numbers in a format of <code>(x, y)</code>. I do an <code>if</code> check for each <code>row</code> variable. I was wondering if there would be a better approach to show row and column numbers.</p> <p>There are 3 rows. The 1st row has 2 columns, the 2nd row has 1 column, and the 3rd row has 3 columns. 2nd and 3rd rows may not exist at all, but the 1st row always exists.</p> <p>All I did was to run a loop iteration for <code>rowFirst</code>, <code>rowSecond</code>, and <code>rowThird</code>. Is my approach fine or could it be better?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const labels = []; const rows = 3; ///////////// const rowFirst = 2; const rowSecond = 1; // could be ''. const rowThird = 3; // could be ''. ///////////// for (let i = 0; i &lt; rowFirst; i += 1) { labels.push(`(1, ${i + 1})`); } if (rowSecond) { for (let i = 0; i &lt; rowSecond; i += 1) { labels.push(`(2, ${i + 1})`); } } if (rowThird) { for (let i = 0; i &lt; rowThird; i += 1) { labels.push(`(3, ${i + 1})`); } } console.log('LABELS', labels);</code></pre> </div> </div> </p>
[ { "answer_id": 74551787, "author": "June7", "author_id": 7607190, "author_profile": "https://Stackoverflow.com/users/7607190", "pm_score": 2, "selected": true, "text": "ctrFS1 Sub cbxDay_AfterUpdate()\nDim strF As String\nWith Me\nstrF = \"[Day]=\" & .cbxDay\n.ctrFS1.Form.Filter = strF\n.ctrFS1.Form.FilterOn = True\n.ctrFS2.Form.Filter = strF\n.ctrFS2.Form.FilterOn = True\n.ctrFS3.Form.Filter = strF\n.ctrFS3.Form.FilterOn = True\nEnd With\nEnd Sub\n Dim x As Integer\nWith Me\nFor x = 1 to 3\n .Controls(\"ctrFS\" & x).Form.Filter = \"Day=\" & .cbxDay\n .Controls(\"ctrFS\" & x).Form.FilterOn = True\nNext\nEnd With\n" }, { "answer_id": 74552541, "author": "ElphiusMostafa", "author_id": 10225568, "author_profile": "https://Stackoverflow.com/users/10225568", "pm_score": 0, "selected": false, "text": "Private Sub find_day_AfterUpdate()\nDim strF1 As String\nWith Me\nstrF1 = \"[Day]='\" & .find_day & \"'\"\n.F_s1.Form.Filter = strF1\n.F_s1.Form.FilterOn = True\nEnd With\n\nDim strF2 As String\nWith Me\nstrF2 = \"[Day]='\" & .find_day & \"'\"\n.F_s2.Form.Filter = strF2\n.F_s2.Form.FilterOn = True\nEnd With\n\nDim strF3 As String\nWith Me\nstrF3 = \"[Day]='\" & .find_day & \"'\"\n.F_s3.Form.Filter = strF3\n.F_s3.Form.FilterOn = True\nEnd With\nEnd Sub\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13690356/" ]
74,539,441
<p>I can cast &amp;mut i32 to *mut i32 in rust like so</p> <pre class="lang-rust prettyprint-override"><code>fn main() { let mut x = 1; let mut xref = &amp;mut x; unsafe { let xref_ptr = xref as *mut i32; *xref_ptr = 2; } println!(&quot;{}&quot;, x); } </code></pre> <p>Prints 2.</p> <p>But I can't cast &amp;mut &amp;mut i32 to *mut *mut i32 and I don't understand why.</p> <pre class="lang-rust prettyprint-override"><code>fn main() { let mut x = 1; let mut xref = &amp;mut x; let mut xrefref = &amp;mut xref; unsafe { let xrefptr = xrefref as *mut (*mut i32); **xrefptr = 2; } println!(&quot;{}&quot;, x); } </code></pre> <pre><code>error[E0606]: casting `&amp;mut &amp;mut i32` as `*mut *mut i32` is invalid --&gt; src/main.rs:16:23 | 16 | let xrefptr = xrefref as *mut (*mut i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ </code></pre> <p>If references are pointers under the hood I was expecting &amp;mut &amp;mut i32 to be a pointer to pointer to an i32 but it appears this cast is wrong.</p> <p>Why is the first cast allowed but not the second?</p>
[ { "answer_id": 74539636, "author": "isaactfa", "author_id": 11423104, "author_profile": "https://Stackoverflow.com/users/11423104", "pm_score": 3, "selected": true, "text": "T as U U as V T as V let mut x = 1;\nlet mut xref = &mut x;\nlet mut xrefref = &mut xref;\nlet xrefptr = (xrefref as *mut &mut i32) as *mut *mut i32;\nunsafe {\n **xrefptr = 2;\n}\nprintln!(\"{}\", x); // 2\n" }, { "answer_id": 74539644, "author": "Frxstrem", "author_id": 423170, "author_profile": "https://Stackoverflow.com/users/423170", "pm_score": 2, "selected": false, "text": "e U e as U *T *V V: Sized &m₁ T *m₂ T m₁ mut m₂ const &mut T *mut T *mut T *mut V &mut T *mut V T != V let xrefref: &mut &mut i32 = &mut xref;\nlet xref_ptr = xrefref as *mut &mut i32 as *mut *mut i32;\n// &mut T -> *mut T ^^^^^^^^^^^^^^^^\n// *mut T -> *mut V ^^^^^^^^^^^^^^^^\n// where T = &mut i32 and V = *mut i32\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12417483/" ]
74,539,464
<p>I have an entity class with a custom type field among other fields</p> <pre class="lang-java prettyprint-override"><code>@Entity @Table(name = &quot;something&quot;) public class Test { @Id private Integer id; private &lt;SomethingHere&gt; customTypeObject; // Other fields, getters, and setters not shown } </code></pre> <p>Using that class I am generating a json representation of the data using repository.findAll()</p> <pre class="lang-java prettyprint-override"><code>@Controller public class TestController { @AutoWired private TestRepository repo @GetMapping(&quot;/test&quot;) private List&lt;Test&gt; test() { return repo.findAll(); } } </code></pre> <p>The JSON response to the user is intended to display the fields within the custom type in JSON format. If I label the customTypeObject as a String, the reponse is something like below <code>[{id: 1, customTypeObject: &quot;(1,2)&quot;}]</code> Whereas I would prefer a response like <code>[{id: 1, customTypeObject: { A: 1, B: 2 }}]</code></p> <p>I realize I could do this by creating another entity class for the custom type where I manually type out the fields but I plan on increasing the number of fields in the custom type frequently during the development process so I would prefer if the program would keep track of the fields for me.</p> <p>Is there any way this could be accomplished?</p>
[ { "answer_id": 74539636, "author": "isaactfa", "author_id": 11423104, "author_profile": "https://Stackoverflow.com/users/11423104", "pm_score": 3, "selected": true, "text": "T as U U as V T as V let mut x = 1;\nlet mut xref = &mut x;\nlet mut xrefref = &mut xref;\nlet xrefptr = (xrefref as *mut &mut i32) as *mut *mut i32;\nunsafe {\n **xrefptr = 2;\n}\nprintln!(\"{}\", x); // 2\n" }, { "answer_id": 74539644, "author": "Frxstrem", "author_id": 423170, "author_profile": "https://Stackoverflow.com/users/423170", "pm_score": 2, "selected": false, "text": "e U e as U *T *V V: Sized &m₁ T *m₂ T m₁ mut m₂ const &mut T *mut T *mut T *mut V &mut T *mut V T != V let xrefref: &mut &mut i32 = &mut xref;\nlet xref_ptr = xrefref as *mut &mut i32 as *mut *mut i32;\n// &mut T -> *mut T ^^^^^^^^^^^^^^^^\n// *mut T -> *mut V ^^^^^^^^^^^^^^^^\n// where T = &mut i32 and V = *mut i32\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14694240/" ]
74,539,482
<p>I am using this line to read the image in base64 :</p> <pre class="lang-js prettyprint-override"><code>const base64_image = await FileSystem.readAsStringAsync(image, { encoding: 'base64' }) </code></pre> <p>The <code>image</code> variable is the uri that I have got from the ImagePicker library. This is the code snippet for that:</p> <pre class="lang-js prettyprint-override"><code>const pickImage = async () =&gt; { let permissionResult = await ImagePicker.requestMediaLibraryPermissionsAsync(); if (permissionResult.granted === false) { alert(&quot;Permission to access camera roll is required!&quot;); return; } else { let result = await ImagePicker.launchImageLibraryAsync({ mediaTypes: ImagePicker.MediaTypeOptions.All, allowsEditing: true, aspect: [4, 3], quality: 1, }); if (!result.cancelled) { setImage(result.uri); } } } </code></pre> <p>setImage is a function from useState that sets the image state. This is working fine and I am getting the uri.</p> <p>I am facing no problems at all with this method on ios. It is working and I am able to retrieve the image and change it to base 64 string.</p> <p>The problem is on android, I am always getting the following error:</p> <p><code>[Error: Location 'file:///data/user/0/host.exp.exponent/cache/ImagePicker/976e1b20-9fa9-4f80-9e0e-7bee580f0749.jpeg' isn't readable.]</code></p> <p>The location for some reason seems is not readable. What could be problem, given that it is working on ios?</p> <p>I tried different functions from the expo-file-system library, but the only method to retrieve images from the device is using FileSystem.readAsStringAsync which is not serving the purpose</p>
[ { "answer_id": 74539636, "author": "isaactfa", "author_id": 11423104, "author_profile": "https://Stackoverflow.com/users/11423104", "pm_score": 3, "selected": true, "text": "T as U U as V T as V let mut x = 1;\nlet mut xref = &mut x;\nlet mut xrefref = &mut xref;\nlet xrefptr = (xrefref as *mut &mut i32) as *mut *mut i32;\nunsafe {\n **xrefptr = 2;\n}\nprintln!(\"{}\", x); // 2\n" }, { "answer_id": 74539644, "author": "Frxstrem", "author_id": 423170, "author_profile": "https://Stackoverflow.com/users/423170", "pm_score": 2, "selected": false, "text": "e U e as U *T *V V: Sized &m₁ T *m₂ T m₁ mut m₂ const &mut T *mut T *mut T *mut V &mut T *mut V T != V let xrefref: &mut &mut i32 = &mut xref;\nlet xref_ptr = xrefref as *mut &mut i32 as *mut *mut i32;\n// &mut T -> *mut T ^^^^^^^^^^^^^^^^\n// *mut T -> *mut V ^^^^^^^^^^^^^^^^\n// where T = &mut i32 and V = *mut i32\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17159185/" ]
74,539,492
<p>It seems that <code>getresult()</code> is trying to <code>console.log('here', x)</code> before <code>getMathvalue()</code> finish is task. I would like to &quot;pause&quot; <code>getresult()</code> so it would only <code>console.log('here', x)</code> when <code>getMathvalue()</code> is done</p> <p>Here I'm trying to get a specific value a only this value which is <code>value</code> after <code>getMathvalue()</code> finished is task</p> <pre class="lang-js prettyprint-override"><code>function quickmath() { const [value, setvalue] = useState() function getMathvalue() { var a = 1 a++ setvalue(a) } useEffect(() =&gt; { getMathvalue() }, []) getresult({ value }) function getresult(x) { console.log('here', x) } </code></pre> <p><a href="https://i.stack.imgur.com/C8snS.png" rel="nofollow noreferrer">Obtained Output:</a></p> <p><a href="https://i.stack.imgur.com/3ktrY.png" rel="nofollow noreferrer">Expected Output:</a></p> <p><strong>Edit ---</strong></p> <p>I added and ,</p> <pre><code> useEffect(() =&gt; { getresult({ value }) }, [value]); </code></pre> <p>there is still value as <a href="https://i.stack.imgur.com/T7WNj.png" rel="nofollow noreferrer">undefined</a></p>
[ { "answer_id": 74539535, "author": "SwaD", "author_id": 20014359, "author_profile": "https://Stackoverflow.com/users/20014359", "pm_score": 2, "selected": false, "text": " useEffect(() => {\n getresult({ value })\n }, [value]);\n \n\n function getresult(x) {\n console.log('here', x)\n }\n" }, { "answer_id": 74539606, "author": "Oleg Brazhnichenko", "author_id": 7028321, "author_profile": "https://Stackoverflow.com/users/7028321", "pm_score": 1, "selected": true, "text": "value getresult useEffect(() => {\n getresult({value}) // will be called after value was updated\n}, [value])\n" }, { "answer_id": 74539621, "author": "DrunkOldDog", "author_id": 12222861, "author_profile": "https://Stackoverflow.com/users/12222861", "pm_score": 1, "selected": false, "text": "getresult useEffect undefined useEffect useEffect(() => {\n // using an if clause because *value* starts as undefined on the first call\n if (value) {\n getresult({ value }); // this method would be called each time the *value* changes\n }\n}, [value]);\n getresult" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20078517/" ]
74,539,523
<p>I am trying to clean up broken VTT files, where the lines show: <code>00:00.000 -- constituent 00:06.880</code> but instead should show <code>00:00.000 --&gt; 00:06.880</code></p> <p>VTT is written so that it's MM:SS:MSMSMS, and minutes can be any value, so I tried to match that via a regexp using <code>^\d+\:\d+\.\d+$</code>, which apparently should work and on some regexp testing places it matches at first, but then when I add additional content to the string the match fails.</p> <p>How can I get the string between these two matches so that I can replace it with <code>--&gt;</code> ? The word here (<code>constituent</code>) is variable and so I need a general regexp rather than just a match and replace for the string. Thanks!</p>
[ { "answer_id": 74539535, "author": "SwaD", "author_id": 20014359, "author_profile": "https://Stackoverflow.com/users/20014359", "pm_score": 2, "selected": false, "text": " useEffect(() => {\n getresult({ value })\n }, [value]);\n \n\n function getresult(x) {\n console.log('here', x)\n }\n" }, { "answer_id": 74539606, "author": "Oleg Brazhnichenko", "author_id": 7028321, "author_profile": "https://Stackoverflow.com/users/7028321", "pm_score": 1, "selected": true, "text": "value getresult useEffect(() => {\n getresult({value}) // will be called after value was updated\n}, [value])\n" }, { "answer_id": 74539621, "author": "DrunkOldDog", "author_id": 12222861, "author_profile": "https://Stackoverflow.com/users/12222861", "pm_score": 1, "selected": false, "text": "getresult useEffect undefined useEffect useEffect(() => {\n // using an if clause because *value* starts as undefined on the first call\n if (value) {\n getresult({ value }); // this method would be called each time the *value* changes\n }\n}, [value]);\n getresult" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3973137/" ]
74,539,584
<p>So I have a vector of numbers, say 1:8000. I want generate exactly <code>n</code> distinct permutations of this vector. What is a way to do this without having to calculate all permutations (since 8000! is huge and can't fit in RAM).</p> <pre><code>function distinct_permutations(L, N){ # Return N distinct permutations of L as a list of lists return(x) } x &lt;- seq(1:8000) </code></pre>
[ { "answer_id": 74539842, "author": "jay.sf", "author_id": 6574038, "author_profile": "https://Stackoverflow.com/users/6574038", "pm_score": 2, "selected": false, "text": "RcppAlgos::permuteSample set.seed(42)\nRcppAlgos::permuteSample(v=10, m=10, n=3)\n# [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]\n# [1,] 9 8 5 3 4 1 10 6 2 7\n# [2,] 1 3 5 9 7 6 8 10 2 4\n# [3,] 2 8 5 9 4 7 3 10 6 1\n" }, { "answer_id": 74540021, "author": "polkas", "author_id": 5442527, "author_profile": "https://Stackoverflow.com/users/5442527", "pm_score": 2, "selected": false, "text": "perm_n sample unique RcppAlgos::permuteSample arrangements::permutations perm_n <- function(vec, n) {\n # sample 2 * N samples as a risk of duplicates for bigger samples\n unique(\n lapply(seq_len(n * 2), function(x) sample(vec, length(vec)))\n )[seq_len(n)]\n}\n\nmicrobenchmark::microbenchmark(\n RcppAlgos::permuteSample(v=10, m=10, n=10),\n perm_n(1:10, 10),\n arrangements::permutations(10, 10, nsample = 10)\n)\n#> Warning in microbenchmark::microbenchmark(RcppAlgos::permuteSample(v = 10, :\n#> less accurate nanosecond times to avoid potential integer overflows\n#> Unit: microseconds\n#> expr min lq mean\n#> RcppAlgos::permuteSample(v = 10, m = 10, n = 10) 230.174 249.7105 1605.4817\n#> perm_n(1:10, 10) 65.559 68.0190 182.8387\n#> arrangements::permutations(10, 10, nsample = 10) 3.649 4.1205 238.7746\n#> median uq max neval\n#> 1038.961 2292.556 28600.70 100\n#> 71.217 82.861 10617.61 100\n#> 4.633 7.298 23295.99 100\n\nmicrobenchmark::microbenchmark(\n RcppAlgos::permuteSample(v=8000, m=8000, n=10),\n perm_n(1:8000, 10),\n arrangements::permutations(8000, 8000, nsample = 10),\n times = 10\n)\n#> Unit: milliseconds\n#> expr min lq\n#> RcppAlgos::permuteSample(v = 8000, m = 8000, n = 10) 199.5939 199.858108\n#> perm_n(1:8000, 10) 4.3911 4.428697\n#> arrangements::permutations(8000, 8000, nsample = 10) 593.0577 594.338993\n#> mean median uq max neval\n#> 200.44507 200.282540 200.944936 201.960178 10\n#> 4.49205 4.457807 4.555182 4.663914 10\n#> 600.67245 598.277678 604.146808 619.717132 10\n\nmicrobenchmark::microbenchmark(\n RcppAlgos::permuteSample(v=8000, m=8000, n=300),\n perm_n(1:8000, 300),\n arrangements::permutations(8000, 8000, nsample = 300),\n times = 3\n)\n#> Unit: milliseconds\n#> expr min lq\n#> RcppAlgos::permuteSample(v = 8000, m = 8000, n = 300) 5939.2831 5965.0268\n#> perm_n(1:8000, 300) 136.7174 137.3693\n#> arrangements::permutations(8000, 8000, nsample = 300) 17875.7788 17877.2049\n#> mean median uq max neval\n#> 5984.365 5990.7704 6006.9057 6023.0410 3\n#> 138.048 138.0212 138.7133 139.4053 3\n#> 17891.089 17878.6310 17898.7438 17918.8566 3\n" }, { "answer_id": 74548468, "author": "jblood94", "author_id": 9463489, "author_profile": "https://Stackoverflow.com/users/9463489", "pm_score": 1, "selected": false, "text": "lapply sample library(RcppAlgos)\n\nperm_n.safe <- function(v, n) {\n if (n/permuteCount(v) > 0.01) return(as.list(data.frame(t(permuteSample(v, n = n)))))\n k <- 0L\n out <- vector(\"list\", n)\n m <- n\n \n while (k < m) {\n s <- unique(lapply(1:n, function(i) sample(v)))\n out[(k + 1L):(k + length(s))] <- s\n k <- k + length(s)\n n <- ceiling(1.1*n/k)\n }\n \n out\n}\n n n set.seed(148461194)\n\nmicrobenchmark::microbenchmark(\n perm_n = perm_n(1:8000, 300),\n perm_n.safe = perm_n.safe(1:8000, 300),\n times = 10\n)\n#> Unit: milliseconds\n#> expr min lq mean median uq max neval\n#> perm_n 229.9223 231.2907 233.5303 233.0133 235.8125 237.5975 10\n#> perm_n.safe 117.1336 118.6889 123.5767 119.3938 122.4304 147.8789 10\n\nmicrobenchmark::microbenchmark(\n perm_n = perm_n(1:5, 100),\n perm_n.safe = perm_n.safe(1:5, 100)\n)\n#> Unit: microseconds\n#> expr min lq mean median uq max neval\n#> perm_n 728.8 766.75 908.462 789.85 993.4 3327.8 100\n#> perm_n.safe 168.9 186.90 211.721 200.80 228.4 414.1 100\n\nsum(lengths(perm_n(1:5, 100)) == 5)\n#> [1] 92\nsum(lengths(perm_n.safe(1:5, 100)) == 5)\n#> [1] 100\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18821623/" ]
74,539,589
<p>I'm facing a lot of trouble on what seems to be a simple matter:</p> <p>I have a column with some beverages names, but they are poluted with &quot;12oz&quot; and &quot;Boxes&quot;. I want to get only the name of the beverages. Unfortunally, they are not typed in the same particular form, so i cant just [0:5] them. I know all the beverages names on the column, if that helps</p> <p>Ex: Column name: <strong>WHISKY BALLANTINES12YO 12X1000 ML RESTAGE</strong></p> <p>Column Created based on the previous one: <strong>BALLANTINES</strong></p> <p>Thanks in advance,</p> <p><strong>EDIT</strong> Some other examples:</p> <p><strong>CHIVAS REGAL 12 ANOS 12X1L</strong> should be <strong>CHIVAS</strong></p> <p><strong>VODKA ABSOLUT 12X1000ML</strong> should be <strong>ABSOLUT</strong></p>
[ { "answer_id": 74539648, "author": "imad97", "author_id": 18183846, "author_profile": "https://Stackoverflow.com/users/18183846", "pm_score": 2, "selected": false, "text": "df.replace('12oz', '', regex=True)\n" }, { "answer_id": 74539972, "author": "abokey", "author_id": 16120011, "author_profile": "https://Stackoverflow.com/users/16120011", "pm_score": 1, "selected": false, "text": "pandas.Series.extract import re\n​\nlist_of_bvr= [\"ballantines\", \"chivas\", \"absolut\"]\n\ndf[\"Col1\"]= df[\"Col1\"].str.extract(f\"({'|'.join(list_of_bvr)})\", flags=re.I, expand=False)\n print(df)\n\n Col1\n0 BALLANTINES\n1 CHIVAS\n2 ABSOLUT\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539589", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14211825/" ]
74,539,598
<p>I want to be able to build a midi sheet as shown here: <a href="https://i.stack.imgur.com/bnYPO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bnYPO.png" alt="example" /></a></p> <p>I've used a relative layout to place the buttons at certain positions (not finalised, still in testing). However, I can't get the scrollview to scroll horizontally or vertically for that matter. Could someone help me out? Or if you have any suggestions for a better implementation, that would be helpful. Where I create this relative layout is in the screen called MidiSheet:</p> <pre><code>class MidiSheet(Screen): def __init__(self, **kwargs): super(MidiSheet, self).__init__(**kwargs) screen = ScrollView(size=(Window.width, Window.height), do_scroll_x=True, do_scroll_y=False) notes = get_notes_in_song(&quot;../data/&quot; + self.name) layout = RelativeLayout(size=(Window.width, Window.height)) layout.add_widget(BackButton(self)) initial_y_pos = Window.height/2 initial_x_pos = Window.width*0.1 for note in notes: note_name = note.split(&quot;:&quot;)[1] layout.add_widget(MidiButton(note_name, initial_x_pos, initial_y_pos)) initial_x_pos += 100 screen.add_widget(layout) self.add_widget(screen) </code></pre> <p>Here's my full .py</p> <pre><code>from kivy.app import App from kivy.uix.button import Button from kivy.uix.scrollview import ScrollView from kivy.uix.gridlayout import GridLayout from kivy.core.window import Window from kivy.uix.relativelayout import RelativeLayout from kivy.uix.screenmanager import ScreenManager, Screen, SlideTransition import os def get_notes_in_song(song): with open(song) as f: lines = f.readlines() return lines class SongButton(Button): def __init__(self, file_name, **kwargs): super(SongButton, self).__init__(**kwargs) self.background_color = [0, 0, 0, 0] self.size_hint = (0.5, None) self.height = 40 self.file_name = file_name def on_press(self): App.get_running_app().root.add_widget(MidiSheet(name=self.file_name)) App.get_running_app().root.transition.direction = &quot;left&quot; App.get_running_app().root.current = self.file_name class BackButton(Button): def __init__(self, screen_instance, **kwargs): super(BackButton, self).__init__(**kwargs) self.background_color = [1, 1, 1, 1] self.size_hint = (0.1, 0.1) self.text = &quot;Back&quot; self.screen_instance = screen_instance def on_press(self): App.get_running_app().root.remove_widget(self.screen_instance) App.get_running_app().root.transition.direction = &quot;right&quot; App.get_running_app().root.current = &quot;home&quot; class MidiButton(Button): def __init__(self, name, pos_x, pos_y, **kwargs): super(MidiButton, self).__init__(**kwargs) self.background_color = [1, 1, 1, 1] self.size_hint = (0.1, 0.1) self.pos = (pos_x, pos_y) self.text = name self.padding = (10, 10) def on_press(self): self.background_color = [0, 1, 0, 1] if self.background_color == [1, 1, 1, 1] else [1, 1, 1, 1] class Home(Screen): def __init__(self, **kwargs): super(Home, self).__init__(**kwargs) screen = ScrollView(size_hint=(1, None), size=(Window.width, Window.height)) layout = GridLayout(cols=1, spacing=10, size_hint_y=None) songs = [x for x in os.listdir(&quot;../data/&quot;) if &quot;.txt&quot; in x] for song in songs: name = song.replace(&quot;_&quot;, &quot; &quot;).replace(&quot;.txt&quot;, &quot;&quot;) layout.add_widget(SongButton(song, text=name)) screen.add_widget(layout) self.add_widget(screen) class MidiSheet(Screen): def __init__(self, **kwargs): super(MidiSheet, self).__init__(**kwargs) screen = ScrollView(size=(Window.width, Window.height), do_scroll_x=True, do_scroll_y=False) notes = get_notes_in_song(&quot;../data/&quot; + self.name) layout = RelativeLayout(size=(Window.width, Window.height)) layout.add_widget(BackButton(self)) initial_y_pos = Window.height/2 initial_x_pos = Window.width*0.1 for note in notes: note_name = note.split(&quot;:&quot;)[1] layout.add_widget(MidiButton(note_name, initial_x_pos, initial_y_pos)) initial_x_pos += 100 screen.add_widget(layout) self.add_widget(screen) class Localiser(App): def build(self): sm = ScreenManager(transition=SlideTransition()) sm.add_widget(Home(name=&quot;home&quot;)) return sm </code></pre>
[ { "answer_id": 74550425, "author": "John Anderson", "author_id": 7254633, "author_profile": "https://Stackoverflow.com/users/7254633", "pm_score": 1, "selected": false, "text": "height GridLayout Buttons GridLayut minimum_height GridLayout layout = GridLayout(cols=1, spacing=10, size_hint_y=None)\n layout.bind(minimum_height=layout.setter('height'))\n" }, { "answer_id": 74573818, "author": "Diyon335", "author_id": 11263029, "author_profile": "https://Stackoverflow.com/users/11263029", "pm_score": 1, "selected": true, "text": "screen = ScrollView(size_hint=(None, None), size=(Window.width, Window.height), do_scroll_x=True, do_scroll_y=False)\n\nclass MidiLayout(RelativeLayout):\n\n def __init__(self, midi_buttons, **kwargs):\n super(MidiLayout, self).__init__(**kwargs)\n\n self.size_hint = (None, None)\n\n self.window_width = Window.width\n\n for note in midi_buttons:\n self.window_width += note.size[0]\n\n self.add_widget(note)\n\n self.size = (self.window_width + 100, Window.height)\n\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11263029/" ]
74,539,618
<p>The following Code on Scala outputs <code>return java 11 instance</code>.</p> <p>I'm using openjdk-11 and sbt 1.8.0.</p> <pre><code># Main.scala import breeze.linalg.{DenseMatrix, DenseVector} object Main extends App { val X = DenseMatrix((1.0, 0.0), (1.0, 1.0), (1.0, 2.0), (1.0, 3.0)) val Y = DenseVector(0.0, 1.0) X * Y } </code></pre> <pre><code># build.sbt ThisBuild / version := &quot;0.1.0-SNAPSHOT&quot; ThisBuild / scalaVersion := &quot;2.13.10&quot; libraryDependencies ++= Seq( &quot;org.scalanlp&quot; %% &quot;breeze&quot; % &quot;2.1.0&quot; ) </code></pre> <p>What is the reason for this output and how can I avoid this in my projects with Breeze?</p> <p>Moreover this problem reproduces with other versions of jdk, this code always prints java version from which it was built.</p>
[ { "answer_id": 74542002, "author": "Dmytro Mitin", "author_id": 5249621, "author_profile": "https://Stackoverflow.com/users/5249621", "pm_score": 3, "selected": true, "text": "dev.ludovic.netlib.blas.InstanceBuilder private static JavaBLAS initializeJava() {\n String[] fullVersion = System.getProperty(\"java.version\").split(\"[+.\\\\-]+\", 2);\n int major = Integer.parseInt(fullVersion[0]);\n if (major >= 16) {\n try {\n System.out.println(\"trying to return java 16 instance\");\n return VectorBLAS.getInstance();\n } catch (Throwable t) {\n log.warning(\"Failed to load implementation from:\" + VectorBLAS.class.getName());\n }\n }\n if (major >= 11) {\n System.out.println(\"return java 11 instance\");\n return Java11BLAS.getInstance();\n } else {\n System.out.println(\"return java 8 instance\");\n return Java8BLAS.getInstance();\n }\n}\n setLevel import java.util.logging.{Level, Logger}\n\nval logger = Logger.getLogger(\"dev.ludovic.netlib.blas.InstanceBuilder\")\n\nlogger.log(Level.SEVERE, \"AAAA!!!\") // prints\n\nlogger.setLevel(Level.OFF)\nlogger.log(Level.SEVERE, \"BBBB!!!\") // doesn't print\n return java... log doLog System.out.println InstanceBuilder InstanceBuilder System.setOut(new java.io.PrintStream(System.out) {\n override def println(s: String): Unit =\n if (Seq(\"trying to return java\", \"return java\").forall(!s.startsWith(_)))\n super.println(s)\n})\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10344534/" ]
74,539,633
<p>I am trying to make an API call (getAccounts) that returns a list, then make a second list that by making a call(get for details of every object in that list (instead of just the first in the block below). How do I do that and then notify the observer when that series of calls is complete?</p> <pre><code> viewModelScope.launch { gateway.getAccounts( ).fold( onSuccess = { v -&gt; // fetch account details for first credit account in list gateway.getCreditAccountDetails(v.first().accountId, v.first().accountIdType).fold( onSuccess = { v -&gt; addAccountToList(v)} ) } ) } </code></pre> <p>Coroutines functions:</p> <pre><code> suspend fun getAccounts(): Result&lt;List&lt;LOCAccountInfo&gt;&gt; { return withContext(Dispatchers.IO) { AccountServicing.getCreditAccounts(creditAuthClient) } } suspend fun getCreditAccountDetails(accountId: AccountId, accountIdType: AccountIdType): Result&lt;LOCAccount&gt; { return getCreditAccountDetails(accountId, accountIdType, creditAuthClient) } </code></pre>
[ { "answer_id": 74542002, "author": "Dmytro Mitin", "author_id": 5249621, "author_profile": "https://Stackoverflow.com/users/5249621", "pm_score": 3, "selected": true, "text": "dev.ludovic.netlib.blas.InstanceBuilder private static JavaBLAS initializeJava() {\n String[] fullVersion = System.getProperty(\"java.version\").split(\"[+.\\\\-]+\", 2);\n int major = Integer.parseInt(fullVersion[0]);\n if (major >= 16) {\n try {\n System.out.println(\"trying to return java 16 instance\");\n return VectorBLAS.getInstance();\n } catch (Throwable t) {\n log.warning(\"Failed to load implementation from:\" + VectorBLAS.class.getName());\n }\n }\n if (major >= 11) {\n System.out.println(\"return java 11 instance\");\n return Java11BLAS.getInstance();\n } else {\n System.out.println(\"return java 8 instance\");\n return Java8BLAS.getInstance();\n }\n}\n setLevel import java.util.logging.{Level, Logger}\n\nval logger = Logger.getLogger(\"dev.ludovic.netlib.blas.InstanceBuilder\")\n\nlogger.log(Level.SEVERE, \"AAAA!!!\") // prints\n\nlogger.setLevel(Level.OFF)\nlogger.log(Level.SEVERE, \"BBBB!!!\") // doesn't print\n return java... log doLog System.out.println InstanceBuilder InstanceBuilder System.setOut(new java.io.PrintStream(System.out) {\n override def println(s: String): Unit =\n if (Seq(\"trying to return java\", \"return java\").forall(!s.startsWith(_)))\n super.println(s)\n})\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539633", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9996859/" ]
74,539,699
<p>I have a function that I'm passing as a parameter like this:</p> <pre><code>public async Task&lt;Number&gt; MeasureAsync&lt;Number&gt;(Func&lt;Task&lt;Number&gt;&gt; sendFunc) { //implementation } </code></pre> <p>I want to test this function and test a case where the <code>sendFunc</code> returns <code>null</code>. In my unit test, I'm attempting to mock the <code>sendFunc</code> but I'm getting an error saying my mock is ambiguous. Here is my mock:</p> <pre><code>var functionMock = new Mock&lt;Func&lt;Task&lt;Number&gt;&gt;&gt;(); functionMock.Setup(x =&gt; x.Invoke()).ReturnsAsync(null); // error on ReturnsAsync because the call is ambiguous </code></pre> <p>Is there a way I'm supposed to specify the return type?</p>
[ { "answer_id": 74542002, "author": "Dmytro Mitin", "author_id": 5249621, "author_profile": "https://Stackoverflow.com/users/5249621", "pm_score": 3, "selected": true, "text": "dev.ludovic.netlib.blas.InstanceBuilder private static JavaBLAS initializeJava() {\n String[] fullVersion = System.getProperty(\"java.version\").split(\"[+.\\\\-]+\", 2);\n int major = Integer.parseInt(fullVersion[0]);\n if (major >= 16) {\n try {\n System.out.println(\"trying to return java 16 instance\");\n return VectorBLAS.getInstance();\n } catch (Throwable t) {\n log.warning(\"Failed to load implementation from:\" + VectorBLAS.class.getName());\n }\n }\n if (major >= 11) {\n System.out.println(\"return java 11 instance\");\n return Java11BLAS.getInstance();\n } else {\n System.out.println(\"return java 8 instance\");\n return Java8BLAS.getInstance();\n }\n}\n setLevel import java.util.logging.{Level, Logger}\n\nval logger = Logger.getLogger(\"dev.ludovic.netlib.blas.InstanceBuilder\")\n\nlogger.log(Level.SEVERE, \"AAAA!!!\") // prints\n\nlogger.setLevel(Level.OFF)\nlogger.log(Level.SEVERE, \"BBBB!!!\") // doesn't print\n return java... log doLog System.out.println InstanceBuilder InstanceBuilder System.setOut(new java.io.PrintStream(System.out) {\n override def println(s: String): Unit =\n if (Seq(\"trying to return java\", \"return java\").forall(!s.startsWith(_)))\n super.println(s)\n})\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1110590/" ]
74,539,711
<p>I have a dataframe like this</p> <pre><code>Id b_num b_type b_ver price 100 55 A 0 100 101 55 A 0 50 102 55 A 1 100 103 55 A 1 60 104 30 C 2 100 105 30 C 2 50 106 30 C 2 100 107 30 C 2 60 108 30 C 4 200 109 30 C 4 55 110 30 C 4 80 111 30 C 4 120 112 30 C 4 20 </code></pre> <p>I would like to keep the latest version of b_num and b_type, b_ver is the number of version</p> <p>The output expected:</p> <pre><code>Id b_num b_type b_ver price 102 55 A 1 100 103 55 A 1 60 108 30 C 4 200 109 30 C 4 55 110 30 C 4 80 111 30 C 4 120 112 30 C 4 20 </code></pre> <p>thanks</p>
[ { "answer_id": 74539754, "author": "Celius Stingher", "author_id": 11897007, "author_profile": "https://Stackoverflow.com/users/11897007", "pm_score": 3, "selected": true, "text": "df.merge(df.groupby(['b_num','b_type'],as_index=False)['b_ver'].last(),\n on=['b_num','b_type','b_ver'])\n Id b_num b_type b_ver price\n0 102 55 A 1 100\n1 103 55 A 1 60\n2 108 30 C 4 200\n3 109 30 C 4 55\n4 110 30 C 4 80\n5 111 30 C 4 120\n6 112 30 C 4 20\n" }, { "answer_id": 74539800, "author": "rhug123", "author_id": 13802115, "author_profile": "https://Stackoverflow.com/users/13802115", "pm_score": 1, "selected": false, "text": "groupby.rank() df.loc[df.groupby(['b_num','b_type'])['b_ver'].rank(ascending=False,method = 'dense').eq(1)]\n groupby.nlargest() df.loc[df.groupby(['b_num','b_type'])['b_ver'].nlargest(1,keep = 'all').droplevel([0,1]).index]\n groupby.transform() df.loc[df.groupby(['b_num','b_type'])['b_ver'].transform('max').eq(df['b_ver'])]\n Id b_num b_type b_ver price\n2 102 55 A 1 100\n3 103 55 A 1 60\n8 108 30 C 4 200\n9 109 30 C 4 55\n10 110 30 C 4 80\n11 111 30 C 4 120\n12 112 30 C 4 20\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5688876/" ]
74,539,722
<p>I have this data that describes the occurrence of some cell types, in responding patients vs non responsive patients for some drug:</p> <pre><code>&gt; dput(cellsdata) structure(list(response = c(1, 7, 2, 3, 4, 2, 1, 2, 1, 5, 5, 4, 2, 0, 0, 2, 0, 0, 1, 3, 1, 2, 1, 0, 4, 3, 2, 3, 1, 1, 5, 0, 2, 2, 5, 4, 4, 2), no_response = c(1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 3, 2, 3, 2, 0, 3, 0, 0, 0, 1, 1, 0, 1, 4, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0)), class = &quot;data.frame&quot;, row.names = c(&quot;Adipocytes&quot;, &quot;B-cells&quot;, &quot;Basophils&quot;, &quot;CD4+ memory T-cells&quot;, &quot;CD4+ naive T-cells&quot;, &quot;CD4+ T-cells&quot;, &quot;CD4+ Tcm&quot;, &quot;CD4+ Tem&quot;, &quot;CD8+ naive T-cells&quot;, &quot;CD8+ T-cells&quot;, &quot;CD8+ Tcm&quot;, &quot;Class-switched memory B-cells&quot;, &quot;DC&quot;, &quot;Endothelial cells&quot;, &quot;Eosinophils&quot;, &quot;Epithelial cells&quot;, &quot;Fibroblasts&quot;, &quot;Hepatocytes&quot;, &quot;ly Endothelial cells&quot;, &quot;Macrophages&quot;, &quot;Macrophages M1&quot;, &quot;Macrophages M2&quot;, &quot;Mast cells&quot;, &quot;Melanocytes&quot;, &quot;Memory B-cells&quot;, &quot;Monocytes&quot;, &quot;mv Endothelial cells&quot;, &quot;naive B-cells&quot;, &quot;Neutrophils&quot;, &quot;NK cells&quot;, &quot;pDC&quot;, &quot;Pericytes&quot;, &quot;Plasma cells&quot;, &quot;pro B-cells&quot;, &quot;Tgd cells&quot;, &quot;Th1 cells&quot;, &quot;Th2 cells&quot;, &quot;Tregs&quot; )) </code></pre> <p>I want a bar plot, to look something like this, and I also need it to be in order, from the highest bin on the left to the right.</p> <p><a href="https://i.stack.imgur.com/HLIqg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HLIqg.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74539754, "author": "Celius Stingher", "author_id": 11897007, "author_profile": "https://Stackoverflow.com/users/11897007", "pm_score": 3, "selected": true, "text": "df.merge(df.groupby(['b_num','b_type'],as_index=False)['b_ver'].last(),\n on=['b_num','b_type','b_ver'])\n Id b_num b_type b_ver price\n0 102 55 A 1 100\n1 103 55 A 1 60\n2 108 30 C 4 200\n3 109 30 C 4 55\n4 110 30 C 4 80\n5 111 30 C 4 120\n6 112 30 C 4 20\n" }, { "answer_id": 74539800, "author": "rhug123", "author_id": 13802115, "author_profile": "https://Stackoverflow.com/users/13802115", "pm_score": 1, "selected": false, "text": "groupby.rank() df.loc[df.groupby(['b_num','b_type'])['b_ver'].rank(ascending=False,method = 'dense').eq(1)]\n groupby.nlargest() df.loc[df.groupby(['b_num','b_type'])['b_ver'].nlargest(1,keep = 'all').droplevel([0,1]).index]\n groupby.transform() df.loc[df.groupby(['b_num','b_type'])['b_ver'].transform('max').eq(df['b_ver'])]\n Id b_num b_type b_ver price\n2 102 55 A 1 100\n3 103 55 A 1 60\n8 108 30 C 4 200\n9 109 30 C 4 55\n10 110 30 C 4 80\n11 111 30 C 4 120\n12 112 30 C 4 20\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539722", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17945841/" ]
74,539,726
<p>in this code i try to make toggle effect, so when user click the &quot;Male&quot; button its color will be green and other's is grey, and unlike the other. code make the icon &amp; text color green, but do not toggle.</p> <pre><code>import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; class GenderBox extends StatefulWidget { final String gender; const GenderBox({super.key, required this.gender}); @override State&lt;GenderBox&gt; createState() =&gt; _GenderBoxState(); } class _GenderBoxState extends State&lt;GenderBox&gt; { String selected = ''; Color maleColor = Colors.black54; Color femaleColor = Colors.black54; void selectGender(gender) { setState(() { if (gender == 'male') { femaleColor = Colors.black45; maleColor = Colors.green; } else { femaleColor = Colors.green; maleColor = Colors.black45; } }); } @override Widget build(BuildContext context) { return TextButton( onPressed: () { selectGender(widget.gender); }, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ widget.gender == 'female' ? FaIcon( FontAwesomeIcons.venus, size: 40, color: femaleColor, ) : FaIcon( FontAwesomeIcons.mars, size: 40, color: maleColor, ), Padding( padding: const EdgeInsets.all(8.0), child: Text( widget.gender == &quot;female&quot; ? 'Female' : 'Male', style: TextStyle( fontSize: 25, color: widget.gender == &quot;female&quot; ? femaleColor : maleColor), ), ) ], ), ); } } </code></pre>
[ { "answer_id": 74539754, "author": "Celius Stingher", "author_id": 11897007, "author_profile": "https://Stackoverflow.com/users/11897007", "pm_score": 3, "selected": true, "text": "df.merge(df.groupby(['b_num','b_type'],as_index=False)['b_ver'].last(),\n on=['b_num','b_type','b_ver'])\n Id b_num b_type b_ver price\n0 102 55 A 1 100\n1 103 55 A 1 60\n2 108 30 C 4 200\n3 109 30 C 4 55\n4 110 30 C 4 80\n5 111 30 C 4 120\n6 112 30 C 4 20\n" }, { "answer_id": 74539800, "author": "rhug123", "author_id": 13802115, "author_profile": "https://Stackoverflow.com/users/13802115", "pm_score": 1, "selected": false, "text": "groupby.rank() df.loc[df.groupby(['b_num','b_type'])['b_ver'].rank(ascending=False,method = 'dense').eq(1)]\n groupby.nlargest() df.loc[df.groupby(['b_num','b_type'])['b_ver'].nlargest(1,keep = 'all').droplevel([0,1]).index]\n groupby.transform() df.loc[df.groupby(['b_num','b_type'])['b_ver'].transform('max').eq(df['b_ver'])]\n Id b_num b_type b_ver price\n2 102 55 A 1 100\n3 103 55 A 1 60\n8 108 30 C 4 200\n9 109 30 C 4 55\n10 110 30 C 4 80\n11 111 30 C 4 120\n12 112 30 C 4 20\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9917730/" ]
74,539,733
<p>I am trying to create an app where I sign on clients to mailchimp and when I try to sign them up I get this error message:</p> <pre><code>ReferenceError: response is not defined    at C:\Users\Owner\Desktop\Newsletter-Signup\app.js:57:3    at Layer.handle [as handle_request] (C:\Users\Owner\Desktop\Newsletter-Signup\node_modules\express\lib\router\layer.js:95:5)    at next (C:\Users\Owner\Desktop\Newsletter-Signup\node_modules\express\lib\router\route.js:144:13)    at Route.dispatch (C:\Users\Owner\Desktop\Newsletter-Signup\node_modules\express\lib\router\route.js:114:3)    at Layer.handle [as handle_request] (C:\Users\Owner\Desktop\Newsletter-Signup\node_modules\express\lib\router\layer.js:95:5)    at C:\Users\Owner\Desktop\Newsletter-Signup\node_modules\express\lib\router\index.js:284:15    at Function.process_params (C:\Users\Owner\Desktop\Newsletter-Signup\node_modules\express\lib\router\index.js:346:12)    at next (C:\Users\Owner\Desktop\Newsletter-Signup\node_modules\express\lib\router\index.js:280:10)    at C:\Users\Owner\Desktop\Newsletter-Signup\node_modules\body-parser\lib\read.js:137:5    at AsyncResource.runInAsyncScope (async_hooks.js:193:9) </code></pre> <p>Here is my code at app.js</p> <pre><code>//require installed node packages const express = require(&quot;express&quot;); const https = require(&quot;https&quot;); //create new express app const app = express(); //enable express to access static files in the folder called &quot;Public&quot; app.use(express.static(&quot;Public&quot;)); //enable express to parse URL-encoded bodies app.use(express.urlencoded({ extended: true })); //send html file to browser on request app.get(&quot;/&quot;, function(req, res) { res.sendFile(__dirname + &quot;/signup.html&quot;); }); //require mailchimp const client = require(&quot;@mailchimp/mailchimp_marketing&quot;); //note that &quot;mailchimp-marketing&quot; causes errors client.setConfig({ apiKey: &quot;f628d1e9327aaf60e1c9873ff13787f2-us21&quot;, server: &quot;us21&quot;, }); app.post(&quot;/&quot;, function(req, res) { //set up constants linked to html form input 'name' attributes const firstName = req.body.fName; const lastName = req.body.lName; const email = req.body.email; //code from Node snippet linked above, but with members values filled in as described in Angela's video const run = async () =&gt; { const response = await client.lists.batchListMembers(&quot;347eed265e&quot;, { members: [{ email_address: email, status: &quot;subscribed&quot;, merge_fields: { FNAME: firstName, LNAME: lastName } }], }); console.log(response); }; if (response.statusCode === 200){ res.send(&quot;Successfully subscribed!&quot;); } else { res.send(&quot;There was an error with signing up, please try again!&quot;); } run(); }); //use express app to listen on 3000 and log when it's working app.listen(3000, function() { console.log(&quot;Server is running on port 3000.&quot;) }); // API KEY // f628d1e9327aaf60e1c9873ff13787f2-us21 // List ID // 347eed265e </code></pre> <p>I was wondering if you can help me figure out any errors in my code Thanks, Mark</p> <p>I tried to be able to sign up a client by putting the persons name and address in the field and hoping to get the response &quot;Succussfully subscribed&quot;, instead of getting the error that I received.</p> <p>Here is what my signup page looks like, when I try to sign up a client:</p> <p>[Here is my form page for my app(https://i.stack.imgur.com/ok5iE.png)</p>
[ { "answer_id": 74539754, "author": "Celius Stingher", "author_id": 11897007, "author_profile": "https://Stackoverflow.com/users/11897007", "pm_score": 3, "selected": true, "text": "df.merge(df.groupby(['b_num','b_type'],as_index=False)['b_ver'].last(),\n on=['b_num','b_type','b_ver'])\n Id b_num b_type b_ver price\n0 102 55 A 1 100\n1 103 55 A 1 60\n2 108 30 C 4 200\n3 109 30 C 4 55\n4 110 30 C 4 80\n5 111 30 C 4 120\n6 112 30 C 4 20\n" }, { "answer_id": 74539800, "author": "rhug123", "author_id": 13802115, "author_profile": "https://Stackoverflow.com/users/13802115", "pm_score": 1, "selected": false, "text": "groupby.rank() df.loc[df.groupby(['b_num','b_type'])['b_ver'].rank(ascending=False,method = 'dense').eq(1)]\n groupby.nlargest() df.loc[df.groupby(['b_num','b_type'])['b_ver'].nlargest(1,keep = 'all').droplevel([0,1]).index]\n groupby.transform() df.loc[df.groupby(['b_num','b_type'])['b_ver'].transform('max').eq(df['b_ver'])]\n Id b_num b_type b_ver price\n2 102 55 A 1 100\n3 103 55 A 1 60\n8 108 30 C 4 200\n9 109 30 C 4 55\n10 110 30 C 4 80\n11 111 30 C 4 120\n12 112 30 C 4 20\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18175954/" ]
74,539,791
<p>I have a nodejs expressjs api server and a frontend server with reactjs. I have different routes to create and post different things but I am struggling to understand how it works. How can I send the data that a user inputs in my frontend form to my API and store it in my mongodb database?</p> <p>This is my Register.js component in reactjs:</p> <pre><code>import React, { useState } from 'react' const Register = () =&gt; { const [ formData, setFormData ] = useState({ name: '', email: '', password: '', password2: '' }); const { name, email, password, password2 } = formData; const onChange = (e) =&gt; setFormData({ ...formData, [e.target.name]: e.target.value }); return ( &lt;section className=&quot;container&quot;&gt; &lt;h1 className=&quot;large text-primary&quot;&gt;Sign Up&lt;/h1&gt; &lt;p className=&quot;lead&quot;&gt; &lt;i className=&quot;fas fa-user&quot; /&gt; Create Your Account &lt;/p&gt; &lt;form className=&quot;form&quot; &gt; &lt;div className=&quot;form-group&quot;&gt; &lt;input type=&quot;text&quot; placeholder=&quot;Name&quot; name=&quot;name&quot; value={name} onChange={onChange} /&gt; &lt;/div&gt; &lt;div className=&quot;form-group&quot;&gt; &lt;input type=&quot;email&quot; placeholder=&quot;Email Address&quot; name=&quot;email&quot; value={email} onChange={onChange} /&gt; &lt;small className=&quot;form-text&quot;&gt; &lt;/small&gt; &lt;/div&gt; &lt;div className=&quot;form-group&quot;&gt; &lt;input type=&quot;password&quot; placeholder=&quot;Password&quot; name=&quot;password&quot; value={password} onChange={onChange} /&gt; &lt;/div&gt; &lt;div className=&quot;form-group&quot;&gt; &lt;input type=&quot;password&quot; placeholder=&quot;Confirm Password&quot; name=&quot;password2&quot; value={password2} onChange={onChange} /&gt; &lt;/div&gt; &lt;input type=&quot;submit&quot; className=&quot;btn btn-primary&quot; value=&quot;Register&quot; /&gt; &lt;/form&gt; &lt;p className=&quot;my-1&quot;&gt; &lt;/p&gt; &lt;/section&gt; ) } export default Register </code></pre> <p>This is my API to register a user:</p> <pre><code>//@route POST api/users //@desc Register user //@access public router.post('/', [ check('name', 'Name is required') .not() .isEmpty(), check('email', 'Plese include a valid email').isEmail(), check('password', 'Please enter a password with 6 or more characters').isLength({min:6}) ], async (req, res)=&gt; { const errors = validationResult(req); if(!errors.isEmpty()){ return res.status(400).json({ errors:errors.array()}); //400 is for bad requests } const { name, email, password } = req.body; try{ //See if user exists let user = await User.findOne({ email }); if(user){ return res.status(400).json({ errors: [{ msg:'User already exists' }] }); } //Get users gravatar const avatar = gravatar.url(email,{ s:'200', r:'pg', d:'mm' }) user = new User({ name, email, avatar, password }); //Encrypt password const salt = await bcrypt.genSalt(10); user.password = await bcrypt.hash(password, salt); await user.save(); //Return jsonwebtoken -&gt; this for users to be logged in right after registration const payload = { user:{ id: user.id } } jwt.sign( payload, config.get('jwtSecret'), {expiresIn: 360000}, //change to 3600 for production (err, token)=&gt;{ if(err) throw err; res.json({ token }); } ) }catch(err){ console.error('err.message'); res.status(500).send('Server Error'); } }); module.exports = router; </code></pre> <p>How and where i have to consume my API to send data?</p>
[ { "answer_id": 74539754, "author": "Celius Stingher", "author_id": 11897007, "author_profile": "https://Stackoverflow.com/users/11897007", "pm_score": 3, "selected": true, "text": "df.merge(df.groupby(['b_num','b_type'],as_index=False)['b_ver'].last(),\n on=['b_num','b_type','b_ver'])\n Id b_num b_type b_ver price\n0 102 55 A 1 100\n1 103 55 A 1 60\n2 108 30 C 4 200\n3 109 30 C 4 55\n4 110 30 C 4 80\n5 111 30 C 4 120\n6 112 30 C 4 20\n" }, { "answer_id": 74539800, "author": "rhug123", "author_id": 13802115, "author_profile": "https://Stackoverflow.com/users/13802115", "pm_score": 1, "selected": false, "text": "groupby.rank() df.loc[df.groupby(['b_num','b_type'])['b_ver'].rank(ascending=False,method = 'dense').eq(1)]\n groupby.nlargest() df.loc[df.groupby(['b_num','b_type'])['b_ver'].nlargest(1,keep = 'all').droplevel([0,1]).index]\n groupby.transform() df.loc[df.groupby(['b_num','b_type'])['b_ver'].transform('max').eq(df['b_ver'])]\n Id b_num b_type b_ver price\n2 102 55 A 1 100\n3 103 55 A 1 60\n8 108 30 C 4 200\n9 109 30 C 4 55\n10 110 30 C 4 80\n11 111 30 C 4 120\n12 112 30 C 4 20\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20121254/" ]
74,539,798
<p>I'm creating a card game in Haskell where I need to know the color of the card for each suit.</p> <p>Right now I construct all possible combinations of suit, rank, and color using <code>cardCombinations</code> and then filter the result with <code>cardWithColors</code> to construct the <code>Deck</code></p> <p>The requirement is I want the suits to have the correct associated color: Diamonds, Hearts are Red and Spades, Clubs are Black.</p> <p>Is there possibly a more concise way to express this logic rather than first constructing all combinations and then filtering them?</p> <pre><code>module Deck (Suit,Color,Rank,Card,Deck) where data Color = Red | Black deriving (Eq,Enum,Show,Ord,Bounded) data Suit = Clubs | Diamonds | Hearts | Spades deriving (Eq,Ord,Enum,Bounded,Show) data Rank = Two | Three | Four | Five | Six | Seven | Eight | Nine | Ten | Jack | Queen | King | Ace deriving (Eq,Ord,Enum,Bounded,Show) data Card = Card { rank :: Rank , suit :: Suit , color :: Color } deriving (Eq,Ord,Bounded,Show) type Deck = [Card] findColorForSuit :: Suit -&gt; Color findColorForSuit suit | any (suit==) [Diamonds, Hearts] = Red | any (suit==) [Spades, Clubs] = Black cardCombinations = [(ranks, suits, colors) | ranks &lt;- [minBound :: Rank .. maxBound :: Rank], suits &lt;- [minBound :: Suit .. maxBound :: Suit], colors &lt;- [minBound :: Color .. maxBound :: Color]] cardsWithColors = filter (\(_,suit,color) -&gt; (findColorForSuit suit) == color) cardCombinations makeCard :: (Rank, Suit, Color) -&gt; Card makeCard (rank, suit, color) = Card rank suit color makeCards :: Deck makeCards = map makeCard cardsWithColors </code></pre> <p>I tried creating all combinations and then filtering the result based off a filter predicate to determine how to associate the color to the suit.</p>
[ { "answer_id": 74540166, "author": "Ben", "author_id": 450128, "author_profile": "https://Stackoverflow.com/users/450128", "pm_score": 2, "selected": false, "text": "Card findColourForSuit any == even :: Bool Integer" }, { "answer_id": 74540187, "author": "Ambros", "author_id": 12893756, "author_profile": "https://Stackoverflow.com/users/12893756", "pm_score": 4, "selected": true, "text": "Color Suit color data Card = Card { rank :: Rank, suit :: Suit }\n deriving (..)\n\ncolor :: Card -> Color\ncolor card = findColorForSuit (suit card)\n \n Card" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7405989/" ]
74,539,805
<p>I want to make a background like this picture .please help me <a href="https://i.stack.imgur.com/PBSjg.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PBSjg.jpg" alt="enter image description here" /></a></p>
[ { "answer_id": 74540166, "author": "Ben", "author_id": 450128, "author_profile": "https://Stackoverflow.com/users/450128", "pm_score": 2, "selected": false, "text": "Card findColourForSuit any == even :: Bool Integer" }, { "answer_id": 74540187, "author": "Ambros", "author_id": 12893756, "author_profile": "https://Stackoverflow.com/users/12893756", "pm_score": 4, "selected": true, "text": "Color Suit color data Card = Card { rank :: Rank, suit :: Suit }\n deriving (..)\n\ncolor :: Card -> Color\ncolor card = findColorForSuit (suit card)\n \n Card" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539805", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12064346/" ]
74,539,822
<p>I would like to know the definition of the character/literal '\1' in the c language. Or more generally the definition of '\x' where latex{x\in\N} (is a natural number 0,1,2,3,4,5,6,...etc.)</p> <p>I wrote this to try to figure it out but I would like an &quot;authoritative&quot; definition. Or even better how/where to find this &quot;authoritative&quot; definition. Would this be in the c standard? or compiler dependent? or something else?</p> <pre><code>#include &lt;stdio.h&gt; int main(void) { printf(&quot;test###_%c_###test\n&quot;, '\0'); printf(&quot;test###_%c_###test\n&quot;, '\1'); printf(&quot;test###_%c_###test\n&quot;, '\2'); printf(&quot;test###_%c_###test\n&quot;, '\3'); printf(&quot;test###_\1\2\3_###test\n&quot;); // printf(&quot;tetest###_\0_###test\n&quot;); ###this will cause a compiler warning return 0; } </code></pre> <p>Note: compiled with gcc version: gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0 with no special option (i.e. gcc test.c)</p> <p>The program outputs the following:</p> <pre><code>test###__###test test###__###test test###__###test test###__###test test###__###test </code></pre> <p>I know '\0' is the null character, so that makes sense to me. But the next lines just seems to also be treated as &quot;null characters&quot; but not exactly. They more accurately just seem to be ignored. They don't signify the end of a string like the null character. For example, un-commenting the line with '\0' in the format string of printf, and ignoring the compiler error, stops the line printing at test###_ which makes sense since it's the &quot;end&quot; of the string. But '\0' is just ignored if it is &quot;passed&quot; into the format string? Do I need to look more into the implementation details of printf to understand this '\0' behavior?</p> <p>Sorry, I know it's a few questions in one. Please let me know if I can make my question clearer or explain more.</p> <p>I tried other &quot;characters&quot; like '\a' and get the same result, is this because these &quot;escaped&quot; characters are &quot;unknown/undefined&quot;, compared to '\n', or something else?</p>
[ { "answer_id": 74539838, "author": "dbush", "author_id": 1687119, "author_profile": "https://Stackoverflow.com/users/1687119", "pm_score": 3, "selected": false, "text": "\\ \\0 \\1 \\10" }, { "answer_id": 74539856, "author": "Vlad from Moscow", "author_id": 2877241, "author_profile": "https://Stackoverflow.com/users/2877241", "pm_score": 2, "selected": false, "text": "octal-escape-sequence:\n \\ octal-digit\n \\ octal-digit octal-digit\n \\ octal-digit octal-digit octal-digit\n octal-digit: one of\n 0 1 2 3 4 5 6 7\n \\x hexadecimal-escape-sequence:\n \\x hexadecimal-digit\n hexadecimal-escape-sequence hexadecimal-digit\n '\\17' '\\xf' 15" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20576407/" ]
74,539,831
<p>I have a data out of 50k reading line by line, one got a,</p> <pre><code>s = &quot;2018-11-05T06:14:10.6-05:00&quot;. </code></pre> <p>Which will get error on,</p> <pre><code>public static DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter .ofPattern(&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX&quot;); if(s!=null &amp;&amp; isValidDate(s)) { OffsetDateTime oDAtOffset = OffsetDateTime.parse(s, DATE_TIME_FORMATTER); //error! } </code></pre> <p>If <code>s = &quot;2018-11-05T06:14:10.006-05:00&quot;</code> then it won't get error.</p> <p>How do I convert from <code>&quot;2018-11-05T06:14:10.6-05:00&quot;</code> to <code>&quot;2018-11-05T06:14:10.006-05:00&quot;</code>?</p>
[ { "answer_id": 74541593, "author": "uniwinux", "author_id": 16443788, "author_profile": "https://Stackoverflow.com/users/16443788", "pm_score": 0, "selected": false, "text": "s = s.substring(21,22).equals(\"-\") ? s.substring(0,21)+\"00\"+s.substring(21,27) : s;\n" }, { "answer_id": 74567594, "author": "Christoph Dahlen", "author_id": 20370596, "author_profile": "https://Stackoverflow.com/users/20370596", "pm_score": 1, "selected": false, "text": "var t = java.time.ZonedDateTime.parse(\"2018-11-05T06:14:10.6-05:00\");\nSystem.out.println(t);\n 2018-11-05T06:14:10.600-05:00\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16443788/" ]
74,539,840
<pre><code>a = ('A','B','C') b = (45.43453453, 'Bad Val', 76.45645657 ) </code></pre> <p>I want to create a dict, very simple:</p> <pre><code>{ k:v for k,v in zip(a,b) } </code></pre> <p>My problem is, now I want to apply float (if possible) or replace it with None</p> <p>so, I want to apply a round of 2 and therefore my output should be:</p> <pre><code>{'A': 45.43, 'B': None, 'C': 76.46} </code></pre>
[ { "answer_id": 74539872, "author": "gog", "author_id": 3494774, "author_profile": "https://Stackoverflow.com/users/3494774", "pm_score": 0, "selected": false, "text": "def try_round(n, d):\n try:\n return round(n, d)\n except TypeError:\n return None\n result = {k: try_round(v, 2) for k, v in zip(a, b)}\n" }, { "answer_id": 74539875, "author": "Samathingamajig", "author_id": 12101554, "author_profile": "https://Stackoverflow.com/users/12101554", "pm_score": 1, "selected": false, "text": "round TypeError __round__ def safe_round(val, decimals):\n try:\n return round(val, decimals)\n except TypeError:\n return None\n\na = ('A','B','C')\nb = (45.43453453, 'Bad Val', 76.45645657 )\n\nd = { k:safe_round(v, 2) for k,v in zip(a,b) }\n {'A': 45.43, 'B': None, 'C': 76.46}\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1202863/" ]
74,539,851
<p>I have the following vector for an example.</p> <pre><code>isotopes &lt;- c(&quot;6Li&quot;, &quot;7Li&quot;, &quot;7LiH&quot;, &quot;10B&quot;, &quot;11B&quot;, &quot;11BH&quot;) </code></pre> <p>I want to remove the strings <code>&quot;7LiH&quot;</code> and <code>&quot;11BH&quot;</code> from the vector. These values have two capital letters and so I am trying to figure out how to use <code>grep</code> to remove those values or just index out the other strings in the vector. How can I do this?</p>
[ { "answer_id": 74539874, "author": "SUTerliakov", "author_id": 14401160, "author_profile": "https://Stackoverflow.com/users/14401160", "pm_score": 4, "selected": true, "text": "grep('[A-Z].*[A-Z]', isotopes, value=TRUE, invert=TRUE)\n" }, { "answer_id": 74539881, "author": "Anoushiravan R", "author_id": 14314520, "author_profile": "https://Stackoverflow.com/users/14314520", "pm_score": 2, "selected": false, "text": "isotopes[!grepl('[A-Z]([1-9a-z]+)?[A-Z]', isotopes)]\n" }, { "answer_id": 74540171, "author": "AndrewGB", "author_id": 15293191, "author_profile": "https://Stackoverflow.com/users/15293191", "pm_score": 2, "selected": false, "text": "stringr library(stringr)\n\nisotopes[str_count(isotopes, \"[A-Z]\") < 2]\n\n# \"6Li\" \"7Li\" \"10B\" \"11B\"\n stringi library(stringi)\n\nisotopes[stri_count(isotopes, regex=\"[A-Z]\") < 2]\n isotopes[lengths(gregexpr(\"[A-Z]\", isotopes)) < 2]\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940523/" ]
74,539,871
<p>I am setting the TTL on my Cosmos Container to 1 to force the deletion of all items, I then query <code>SELECT VALUE COUNT(1) from c</code> to check that all items are deleted before setting TTL back to its previous value.</p> <p>My issue is, I can see via the portal that the items are deleted but my query via the SDK returns the &quot;old&quot; wrong value for an inordinate time. Is there a way to force it to read the &quot;real&quot; value from the back end or establish a fresh connection etc?</p> <pre><code> //I create my client like so, setting Consistencylevel.STRONG will throw an error as //it is higher level than the DB CosmosClient cosmosClient= new CosmosClientBuilder().endpoint(DATABASE_HOST) .key(DATABASE_KEY) .consistencyLevel(ConsistencyLevel.SESSION) .contentResponseOnWriteEnabled(true) .buildClient(); //get the database CosmosDatabase dataBase = cosmosClient.getDatabase(databaseName); return dataBase; //get the container CosmosContainer container = theDatabase.getContainer(containerProps.getId());# //update the TTL containerProps.setDefaultTimeToLiveInSeconds(1); container.replace(containerProps); Thread.sleep(1000); //now confirm that the container contents are deleted //i tried refreshing my client/db/container objects to see if it would help CosmosClient refreshedCosmosClient = createSyncCosmosClient(); CosmosDatabase refreshedDatabase = refreshedCosmosClient.getDatabase(DATABASE_NAME); CosmosContainer refreshedContainer = refreshedDatabase.getContainer(container.getId()); //query the number of ITEMS in the container CosmosPagedIterable&lt;JsonNode&gt; countOfDocs = refreshedContainer.queryItems(CHECK_CONTAINER_EMPTY_QUERY, new CosmosQueryRequestOptions(), JsonNode.class); context.getLogger().info(&quot;wooooooooooooooooaaaa&quot; +countOfDocs.toString()); //THIS VALUE IS NOT UP TO DATE. IT IS THE OLD VALUE JsonNode count = countOfDocs.iterator().next(); int numberOfDocuments = count.asInt(); </code></pre>
[ { "answer_id": 74539874, "author": "SUTerliakov", "author_id": 14401160, "author_profile": "https://Stackoverflow.com/users/14401160", "pm_score": 4, "selected": true, "text": "grep('[A-Z].*[A-Z]', isotopes, value=TRUE, invert=TRUE)\n" }, { "answer_id": 74539881, "author": "Anoushiravan R", "author_id": 14314520, "author_profile": "https://Stackoverflow.com/users/14314520", "pm_score": 2, "selected": false, "text": "isotopes[!grepl('[A-Z]([1-9a-z]+)?[A-Z]', isotopes)]\n" }, { "answer_id": 74540171, "author": "AndrewGB", "author_id": 15293191, "author_profile": "https://Stackoverflow.com/users/15293191", "pm_score": 2, "selected": false, "text": "stringr library(stringr)\n\nisotopes[str_count(isotopes, \"[A-Z]\") < 2]\n\n# \"6Li\" \"7Li\" \"10B\" \"11B\"\n stringi library(stringi)\n\nisotopes[stri_count(isotopes, regex=\"[A-Z]\") < 2]\n isotopes[lengths(gregexpr(\"[A-Z]\", isotopes)) < 2]\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1843591/" ]
74,539,877
<h3>Context</h3> <p>In Dart, if I have a list:</p> <pre><code>final myList = ['b', 'a']; </code></pre> <p>and I wanted to sort it alphabetically, I would use:</p> <pre><code>myList.sort( (String a, String b) =&gt; a.compareTo(b), ); </code></pre> <p>The output of <code>myList</code> is now:</p> <pre><code>['a', 'b'] </code></pre> <p>Now, this works on letters that are in the <em>English</em> alphabet.</p> <h3>Question</h3> <p>But if I have a list that's in Hebrew:</p> <pre><code>final unorderedHebAlphabet = ['א', 'ב']; </code></pre> <p>I <em>can't</em> sort it as above using with:</p> <pre><code> unorderedHebAlphabet.sort((String a, String b) =&gt; a.compareTo(b)) </code></pre> <p>It doesn't sort.</p> <p>Expected output, instead of:</p> <pre><code>['א', 'ב'] </code></pre> <p>Should be:</p> <pre><code>['ב', 'א'] </code></pre> <ul> <li>How can I sort a list Alphabetically in the Hebrew language?</li> </ul> <h4>Notes</h4> <p>As a reference, the Hebrew alphabet sorted would be in this order:</p> <pre><code>final sortedHebrewAlphabet = [ 'א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ז', 'ח', 'ט', 'י', 'כ', 'ל', 'מ', 'נ', 'ס', 'ע', 'פ', 'צ', 'ק', 'ר', 'ש', 'ת', ]; </code></pre>
[ { "answer_id": 74565094, "author": "jamesdlin", "author_id": 179715, "author_profile": "https://Stackoverflow.com/users/179715", "pm_score": 3, "selected": false, "text": "final unorderedHebAlphabet = ['א', 'ב']; א ב import 'package:collection/collection.dart';\n\nvoid main() {\n var literal = ['א', 'ב'];\n print(literal[0]); // Prints: א\n print(literal[1]); // Prints: ב\n\n const alef = 'א';\n const bet = 'ב';\n const expectedOrder = [alef, bet];\n\n const listEquals = ListEquality();\n \n print(listEquals.equals(literal..sort(), expectedOrder)); // Prints: true\n print(listEquals.equals([bet, alef]..sort(), expectedOrder)); // Prints: true\n}\n const ltr = '\\u202D';\nprint('$expectedOrder');\nprint('$ltr$expectedOrder');\n expectedOrder.forEach(print);\n א\nב\n" }, { "answer_id": 74600265, "author": "Jarvis098", "author_id": 7372400, "author_profile": "https://Stackoverflow.com/users/7372400", "pm_score": -1, "selected": false, "text": "import 'dart:io';\n\nfinal unorderedHebAlphabet = [\n 'ב',\n 'ג',\n 'ד',\n 'ה',\n 'ו',\n 'ז',\n 'ח',\n 'ט',\n 'י',\n 'כ',\n 'ל',\n 'מ',\n 'נ',\n 'ס',\n 'ע',\n 'פ',\n 'צ',\n 'ק',\n 'ר',\n 'ש',\n 'ת',\n 'א'\n];\n\n\nvoid main() {\n print(unorderedHebAlphabet);\n unorderedHebAlphabet\n .sort((a, b) => a.codeUnitAt(0).compareTo(b.codeUnitAt(0)));\n print(unorderedHebAlphabet);\n}\n" }, { "answer_id": 74603505, "author": "Rahul", "author_id": 16569443, "author_profile": "https://Stackoverflow.com/users/16569443", "pm_score": 1, "selected": false, "text": "אב STDOUT import 'dart:io';\n\nvoid main(List<String> arguments) {\n final myList = [\n 'א',\n 'ב',\n 'ג',\n 'ד',\n 'ה',\n 'ו',\n 'ז',\n 'ח',\n 'ט',\n 'י',\n 'כ',\n 'ל',\n 'מ',\n 'נ',\n 'ס',\n 'ע',\n 'פ',\n 'צ',\n 'ק',\n 'ר',\n 'ש',\n 'ת'\n ];\n\n // for (var i in myList) {\n // print(\"$i => ${i.runes.toList()}\");\n // }\n\n myList.sort();\n\n String s = \"\";\n\n for (var i in myList) {\n s += i;\n }\n\n print('$s');\n\n print(myList.first);\n\n final file = new File('/Users/rahul/Desktop/string_l/test.txt');\n file.writeAsStringSync(s, flush: true);\n\n final read = file.readAsStringSync().substring(0, 2);\n print(read);\n\n // You can also verify by calling print with every element\n for (var i in myList) {\n print(i);\n }\n}\n\n אבגדהוזחטיכלמנסעפצקרשת\nא\nאב\nא\nב\nג\nד\nה\nו\nז\nח\nט\nי\nכ\nל\nמ\nנ\nס\nע\nפ\nצ\nק\nר\nש\nת\n" }, { "answer_id": 74666766, "author": "Begging", "author_id": 16606223, "author_profile": "https://Stackoverflow.com/users/16606223", "pm_score": 2, "selected": false, "text": "final unorderedHebAlphabet = ['א', 'ב'];\n\nunorderedHebAlphabet.sort((String a, String b) =>\na.compareTo(b, String.localeCompare));\n\n// Output: ['ב', 'א']\n unorderedHebAlphabet.sort((String a, String b) =>\na.compareTo(b, locale: 'he'));\n\n// Output: ['ב', 'א']\n" }, { "answer_id": 74672692, "author": "Ataberk", "author_id": 4857232, "author_profile": "https://Stackoverflow.com/users/4857232", "pm_score": 0, "selected": false, "text": "import 'package:intl/intl.dart';\n\n// Define the unordered list of Hebrew strings\nfinal unorderedHebAlphabet = ['א', 'ב'];\n\n// Create a Collator instance for the Hebrew language\nfinal collator = Collator('he');\n\n// Use the Collator instance's compare method to sort the list of Hebrew strings alphabetically\nunorderedHebAlphabet.sort((String a, String b) => collator.compare(a, b));\n\n// The unorderedHebAlphabet list is now sorted\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12349734/" ]
74,539,884
<p>My aim is to create a function, list_powers, and use a for loop to take a list and return a new list (power_list) where each element is exponentiated to a specified power.</p> <p>I have moved the return statement appropriately in order to collect all topowers in power_list and return them but it still returns None. How do I change it so that it returns the list of powers?</p> <pre><code>def list_powers(collection = [], power = 2): power_list = [] for elem in collection: topower = elem ** power power_list.append(topower) return power_list.append(topower) </code></pre> <p>test:</p> <pre><code>list_powers([2, 4, 1, 5, 12], power = 2) </code></pre> <p>output:</p> <pre><code>None </code></pre>
[ { "answer_id": 74539935, "author": "Matthias", "author_id": 1209921, "author_profile": "https://Stackoverflow.com/users/1209921", "pm_score": 3, "selected": true, "text": "return topower def list_powers(iterable, power = 2):\n power_list = []\n\n for elem in iterable:\n topower = elem ** power\n power_list.append(topower)\n\n return power_list\n\nprint(list_powers([2, 4, 1, 5, 12]))\n def list_powers(iterable, power = 2):\n return [elem ** power for elem in iterable]\n" }, { "answer_id": 74539937, "author": "Trimonu", "author_id": 15324906, "author_profile": "https://Stackoverflow.com/users/15324906", "pm_score": 1, "selected": false, "text": "return topower return power_list" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20287833/" ]
74,539,951
<p>I have a list consisting of 4 attributes: subject, test, score, and result. I need to calculate the total score for each subject, by adding up the test scores for each subject. I currently have that. But I need to calculate the total test score of passed tests, and then divide that number by the total test score of all tests.</p> <p>This is the first part of the code that works correctly:</p> <pre><code>from collections import defaultdict d = defaultdict(float) dc = defaultdict(float) subject = ['Math', 'Math', 'Math', 'Math', 'Biology', 'Biology', 'Chemistry'] test = ['Test 1','Test 2','Test 3','Test 4','Test 1','Test 2','Test 1'] score = ['1.0', '0.0', '4.0', '0.0', '4.0', '6.0', '2.0'] result = ['fail', 'fail', 'pass', 'fail', 'fail', 'pass', 'pass'] points = [float(x) for x in score] mylist = list(zip(subject, test, points, result)) for subject, test, points, completion, in mylist: d[subject] += points dc[(subject, test)] += points print(d) </code></pre> <p>Expected result &amp; actual result is:</p> <pre><code>{'Math': 5.0, 'Biology': 10.0, 'Chemistry': 2.0} </code></pre> <p>Now the issue I'm having is I need to add up the total number of points for each subject on only the tests that have been passed. And then divide that number from the total number of all tests (passed and failed) in a subject. So something like, 'if result == &quot;passed&quot; then do 'rest of calculations'.</p> <p>This is the remaining code:</p> <pre><code>dc = {f&quot;{subject} {test}&quot; : round(points / d[subject], 2) if d[subject]!=0 else 'division by zero' for (subject, test), points in dc.items()} print(dc) </code></pre> <p>Expected result:</p> <pre><code>Math: 4/5, Biology: 6/10, Chemistry: 2/2 </code></pre> <p>Actual result:</p> <pre><code>'Math Test 1': 0.2, 'Math Test 2': 0.0, 'Math Test 3': 0.8, 'Math Test 4': 0.0, 'Biology Test 1': 0.4, 'Biology Test 2': 0.6, 'Chemistry Test 1': 1.0 </code></pre>
[ { "answer_id": 74540084, "author": "Pranav Hosangadi", "author_id": 843953, "author_profile": "https://Stackoverflow.com/users/843953", "pm_score": 2, "selected": true, "text": "dc for sub, scr, completion, in zip(subject, score, result):\n points = float(scr)\n d[sub] += points\n if completion == \"pass\":\n dc[sub] += points\n d = defaultdict(float, {'Math': 5.0, 'Biology': 10.0, 'Chemistry': 2.0}) \n\ndc = defaultdict(float, {'Math': 4.0, 'Biology': 6.0, 'Chemistry': 2.0})\n d d dc for sub, total_score in d.items():\n print(f\"{sub}: {dc[sub]} / {total_score}\")\n Math: 4.0 / 5.0\nBiology: 6.0 / 10.0\nChemistry: 2.0 / 2.0\n points list() zip(...) mylist zip float" }, { "answer_id": 74540098, "author": "wrbp", "author_id": 16662333, "author_profile": "https://Stackoverflow.com/users/16662333", "pm_score": 0, "selected": false, "text": "dapssed=defaultdic(float)\nfor subject, test, points, completion, in mylist:\n d[subject] += points # this is the total passed and not passed\n dc[(subject, test)] += points\n if completition == 'pass':\n dpassed[subject]=+=points # Only pass point\n" }, { "answer_id": 74544634, "author": "Mike", "author_id": 18061901, "author_profile": "https://Stackoverflow.com/users/18061901", "pm_score": 1, "selected": false, "text": "from collections import defaultdict\n\nd = defaultdict(float)\ndc = defaultdict(float) \n\n\nsubject = ['Math', 'Math', 'Math', 'Math', 'Biology', 'Biology', 'Chemistry']\ntest = ['Test 1','Test 2','Test 3','Test 4','Test 1','Test 2','Test 1']\nscore = ['1.0', '0.0', '4.0', '0.0', '4.0', '6.0', '2.0']\nresult = ['fail', 'fail', 'pass', 'fail', 'fail', 'pass', 'pass']\n\npoints = [float(x) for x in score]\n\nmylist = list(zip(subject, test, points, result))\n\nfor subject, test, points, completion, in mylist:\n d[subject] += points\n dc[(subject, test)] += points\nprint(d)\n\n# Here are my changes\n# result dict will hold your final data\nresult = defaultdict(float) \n\nfor subject, test, points, completion, in mylist:\n if completion == 'pass' and int(d[subject]) > 0:\n print( float(points/d[subject]) )\n result[subject] = float(points/d[subject])\nprint(result)\n {'Math': 0.8, 'Biology': 0.6, 'Chemistry': 1.0}\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20511050/" ]
74,539,983
<p>I want my app to be available for the web.</p> <p>I run this command: <code>flutter create .</code></p> <p>I get this error: <code>&quot;Fredi&quot; is not a valid Dart package name.</code></p> <p>I know that there shouldn't be any capital letters. However, I do not know how to change the dart package name.</p> <p>I have already used these packages successfully, but they seem to be changing other things, not the <strong>Dart Package Name.</strong></p> <pre><code>change_app_package_name: ^1.1.0 rename: ^2.0.1 </code></pre> <p>The only thing in my project with the name 'Fredi' is the root folder (original project name). However, I don't know how to change it (file explorer won't let me) and it will probably break things.</p> <p>What step can I take?</p> <h2>Config Files</h2> <p>app/build.gradle -&gt; <code>applicationId &quot;com.tomasward.fredi&quot;</code></p> <p>android manifest -&gt; <code>package=&quot;com.tomasward.fredi&quot;</code></p> <p>android manifest -&gt; <code>android:label=&quot;Fredi&quot;&gt;</code> [I understand this is the name displayed to the user, I've tried changing it but it doesn't fix the error.]</p>
[ { "answer_id": 74540084, "author": "Pranav Hosangadi", "author_id": 843953, "author_profile": "https://Stackoverflow.com/users/843953", "pm_score": 2, "selected": true, "text": "dc for sub, scr, completion, in zip(subject, score, result):\n points = float(scr)\n d[sub] += points\n if completion == \"pass\":\n dc[sub] += points\n d = defaultdict(float, {'Math': 5.0, 'Biology': 10.0, 'Chemistry': 2.0}) \n\ndc = defaultdict(float, {'Math': 4.0, 'Biology': 6.0, 'Chemistry': 2.0})\n d d dc for sub, total_score in d.items():\n print(f\"{sub}: {dc[sub]} / {total_score}\")\n Math: 4.0 / 5.0\nBiology: 6.0 / 10.0\nChemistry: 2.0 / 2.0\n points list() zip(...) mylist zip float" }, { "answer_id": 74540098, "author": "wrbp", "author_id": 16662333, "author_profile": "https://Stackoverflow.com/users/16662333", "pm_score": 0, "selected": false, "text": "dapssed=defaultdic(float)\nfor subject, test, points, completion, in mylist:\n d[subject] += points # this is the total passed and not passed\n dc[(subject, test)] += points\n if completition == 'pass':\n dpassed[subject]=+=points # Only pass point\n" }, { "answer_id": 74544634, "author": "Mike", "author_id": 18061901, "author_profile": "https://Stackoverflow.com/users/18061901", "pm_score": 1, "selected": false, "text": "from collections import defaultdict\n\nd = defaultdict(float)\ndc = defaultdict(float) \n\n\nsubject = ['Math', 'Math', 'Math', 'Math', 'Biology', 'Biology', 'Chemistry']\ntest = ['Test 1','Test 2','Test 3','Test 4','Test 1','Test 2','Test 1']\nscore = ['1.0', '0.0', '4.0', '0.0', '4.0', '6.0', '2.0']\nresult = ['fail', 'fail', 'pass', 'fail', 'fail', 'pass', 'pass']\n\npoints = [float(x) for x in score]\n\nmylist = list(zip(subject, test, points, result))\n\nfor subject, test, points, completion, in mylist:\n d[subject] += points\n dc[(subject, test)] += points\nprint(d)\n\n# Here are my changes\n# result dict will hold your final data\nresult = defaultdict(float) \n\nfor subject, test, points, completion, in mylist:\n if completion == 'pass' and int(d[subject]) > 0:\n print( float(points/d[subject]) )\n result[subject] = float(points/d[subject])\nprint(result)\n {'Math': 0.8, 'Biology': 0.6, 'Chemistry': 1.0}\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14496570/" ]
74,539,988
<p>I am trying to create a sheet that has a list of areas, and then has a dropdown next to each area name that lets you select one item found in that area.</p> <p>The contents of each area are in Col A of a sheet that is titled with the name of that area.</p> <p>I am trying to use Indirect to point to the name of the area, in Col A, and then create a Dropdown using the contents of Col A on the sheet referenced.</p> <p>The formula I am trying to use is =INDIRECT(&quot;'&quot;&amp;A1&amp;&quot;'!A:A&quot;)</p> <p>When I put this into B1, for example, it spits out a list of all the items on the tab that shares a name with the contents of A1.</p> <p>However, when I try to use this formula to define the range for the dropdown list in Data Validation, it says that it is an invalid range.</p> <p>Example of what I am trying to make:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Location</th> <th>Item</th> </tr> </thead> <tbody> <tr> <td>Area 1</td> <td>▼</td> </tr> <tr> <td>Area 2</td> <td>▼</td> </tr> <tr> <td>Area 3</td> <td>▼</td> </tr> </tbody> </table> </div> <p>And then for example there would be a tab named &quot;Area 1&quot;, and Col A would just be a list of all the items in that Area.</p> <p>The use case here is that I am trying to create a sheet to track encounters in a video game where you're only allowed to acquire the first character you encounter in area named are of the game, and I would like to be able to apply it to any number of different datasets (games), so I would prefer to avoid having to hardcode or specifically limit any names or ranges.</p>
[ { "answer_id": 74541164, "author": "George", "author_id": 20345563, "author_profile": "https://Stackoverflow.com/users/20345563", "pm_score": 1, "selected": false, "text": "App Script Area Location Location function onEdit() {\n var ss = SpreadsheetApp.getActiveSpreadsheet(); \n var sheet = ss.getSheetByName('Main'); \n\n var range = sheet.getRange(2,1,sheet.getLastRow() -1,1).getValues(); //contains list of areas\n \n for(var i = 0; i < range.length; i++){\n var sh = ss.getSheetByName(range[i]);\n var values = sh.getRange(1,1,sh.getLastRow(),1);\n var itemrange = sheet.getRange(2+i,2);\n var rule = SpreadsheetApp.newDataValidation().requireValueInRange(values).build(); \n itemrange.setDataValidation(rule);\n }\n\n}\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74539988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8529030/" ]
74,540,010
<p>I'm new to react and wonder how to do weird code stuff. I have a div component that I need to add child divs to depending on where I clicked on the div. I could do this easily in vanilla JS - here is a code sandbox of JS of what I want to do : <a href="https://codepen.io/Webasics/pen/YXXyEO" rel="nofollow noreferrer">https://codepen.io/Webasics/pen/YXXyEO</a></p> <p>here is what I have in react so far (this is inside my App component):</p> <pre><code>const imgAdder = (e) =&gt; { console.log(e.pageX, e.pageY) } &lt;main onClick={imgAdder} &lt;/main&gt; </code></pre> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() { $(this).click(function(e) { var x = e.pageX; var y = e.pageY; $('&lt;div/&gt;').css({ 'top': y, 'left': x }).appendTo('body'); }); });</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>div { background-color: red; width: 50px; height: 50px; position: absolute; transform: translate(-50%, -50%); /* optional */ border: 1px solid black; /* optional */ } h2 { z-index: 10; /* optional */ /* This always keeps the title on top*/ position: absolute; } body { background-color: #E1E7E8; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt; &lt;h2&gt;Click anywhere&lt;/h2&gt;</code></pre> </div> </div> </p> <p>Any directions would be lovely ! thank you.</p>
[ { "answer_id": 74540086, "author": "Konrad", "author_id": 5089567, "author_profile": "https://Stackoverflow.com/users/5089567", "pm_score": 3, "selected": true, "text": "function App() {\n // declare array of boxes\n const [boxes, setBoxes] = useState([]);\n\n const handleClick = ({ pageX, pageY }) => {\n // on every click push a new coordinate to the boxes array\n setBoxes((boxes) => [...boxes, { x: pageX, y: pageY }]);\n };\n\n return (\n <div className=\"app\" onClick={handleClick}>\n // display boxes\n {boxes.map((box) => (\n // map coordinates to left and top\n <div className=\"box\" style={{ left: box.x, top: box.y }}></div>\n ))}\n </div>\n );\n}\n .app {\n width: 100%;\n height: 100vh;\n}\n\n.box {\n position: absolute;\n width: 50px;\n height: 50px;\n background: red;\n transform: translate(-50%, -50%);\n}\n" }, { "answer_id": 74540092, "author": "Benjamin", "author_id": 1830563, "author_profile": "https://Stackoverflow.com/users/1830563", "pm_score": 2, "selected": false, "text": "useEffect document state import { useEffect, useState } from \"react\";\nimport \"./styles.css\";\n\nexport default function App() {\n const elements = useDynamicElements();\n\n return (\n <>\n <h2>Click anywhere</h2>\n {elements}\n </>\n );\n}\n\nconst useDynamicElements = () => {\n const [state, setState] = useState([]);\n\n useEffect(() => {\n const handler = (event) => {\n setState((previous) => [\n ...previous,\n <div style={{ top: event.pageY, left: event.pageX }} />\n ]);\n };\n document.addEventListener(\"click\", handler);\n return () => document.removeEventListener(\"click\", handler);\n });\n\n return state;\n};\n\n" }, { "answer_id": 74540216, "author": "John Li", "author_id": 20436957, "author_profile": "https://Stackoverflow.com/users/20436957", "pm_score": 0, "selected": false, "text": "const App = () => {\n const [boxList, setBoxList] = React.useState([]);\n\n const handleClick = (e) => {\n if (e.target.classList.contains(\"btn\")) {\n setBoxList([]);\n return;\n }\n setBoxList((prev) => {\n const { pageX, pageY } = e;\n const newBox = { left: pageX, top: pageY };\n return [...prev, newBox];\n });\n };\n\n return (\n <div className=\"app\" onClick={handleClick}>\n <button className=\"btn\">CLEAN UP</button>\n <h2>Click anywhere</h2>\n {boxList.length > 0 &&\n boxList.map((box, index) => (\n <div className=\"box\" style={{ top: box.top, left: box.left }} key={index}></div>\n ))}\n </div>\n );\n};\n\nReactDOM.render(<App />, document.querySelector(\"#root\")); * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\n.app {\n width: 100%;\n height: 100vh;\n background-color: pink;\n position: relative;\n}\n\n.box {\n background-color: #000;\n width: 50px;\n height: 50px;\n position: absolute;\n transform: translate(-50%, -50%);\n border: 1px solid black;\n}\n\nh2 {\n top: 50%;\n left: 50%;\n position: absolute;\n transform: translate(-50%, -50%);\n}\n\n.btn {\n margin: 15px;\n padding: 15px;\n background-color: #fff;\n border: 0;\n border-radius: 12px;\n} <div id=\"root\"></div>\n<script src=\"https://cdnjs.cloudflare.com/ajax/libs/react/18.1.0/umd/react.production.min.js\"></script>\n<script src=\"https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.1.0/umd/react-dom.production.min.js\"></script>" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74540010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11791622/" ]
74,540,039
<p>if I have data</p> <pre><code> dogNames = [[]]; dogNames.push([Bill],[Ben],[jack, Allen],[Barbra],[Jill, Jenny],[George]); </code></pre> <p>if i wanted to loop though and print all to console e.g.</p> <pre><code> for(let x=0;x&lt;dogNames.length;x++){ console.log(dogNames[x]); } </code></pre> <p>is it possible to hide any value after ',' in each array</p> <p>so my printed value may be</p> <p>Bill Ben Jack Barbra Jill George</p> <p>with Allen and Jenny both hidden/removed</p> <p>Unsure where to start. tried using .split() but unsure how to use it on 2d arrays.</p>
[ { "answer_id": 74540121, "author": "user3425506", "author_id": 3425506, "author_profile": "https://Stackoverflow.com/users/3425506", "pm_score": 1, "selected": false, "text": "[0] console.log(dogNames[x][0]); dogNames = [];\n\ndogNames.push(['Bill'],['Ben'],['jack', 'Allen'],['Barbra'],['Jill', 'Jenny'],['George']);\n \nfor(let x=0;x<dogNames.length;x++){\n console.log(dogNames[x][0]);\n}" }, { "answer_id": 74540194, "author": "voidbrain", "author_id": 1000137, "author_profile": "https://Stackoverflow.com/users/1000137", "pm_score": 1, "selected": false, "text": "dogNames = [[]];\ndogNames.push([\"Bill\"],[\"Ben\"],[\"jack\", \"Allen\"],[\"Barbra\"],[\"Jill\", \"Jenny\"],[\"George\"]);\n\n\n// SOLUTION 1 --> JUST PICK ARRAY FIRST ELEMENT\nfor(let x=0;x<dogNames.length; x++){\n console.log(dogNames[x][0]);\n}\n\n//SOLUTION 2 --> ARRAY to STRING\nfor(let x=0;x<dogNames.length;x++){\n const dogNameRow = dogNames[x];\n const dogString = dogNameRow.join();\n console.log(dogString.split(\",\")[0]);\n}\n" }, { "answer_id": 74547500, "author": "Rohìt Jíndal", "author_id": 4116300, "author_profile": "https://Stackoverflow.com/users/4116300", "pm_score": 0, "selected": false, "text": "Array.map() const dogNames = [[],['Bill'],['Ben'],['jack', 'Allen'],['Barbra'],['Jill', 'Jenny'],['George']];\n\nconsole.log(dogNames.map(arr => arr[0]).filter(Boolean).join())" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74540039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12001410/" ]
74,540,056
<pre class="lang-java prettyprint-override"><code>String accountQuery = &quot;insert into Account (accountNumber,currentBalance,type,personId) values (?,?,?,?);&quot;; PreparedStatement accountPs = null; try { // These are my prepare Statements for my queries accountPs = conn.prepareStatement(accountQuery); // accountPs.setInt(1, personId.getPersonId()); accountPs.setInt(1, accountHolder.getAccountNumber()); accountPs.setDouble(2, accountHolder.getCurrentBalance()); accountPs.setString(3, accountHolder.getType()); accountPs.setInt(4, personId.getPersonId()); accountPs.executeUpdate(); accountPs.close(); conn.close(); } </code></pre> <p>How can I check if accountNumber (non primary key) already exists in my database? Whenever I run my program more than once, it'll populate my tables with repeated data because accountNumber isn't a primary key and because my accountId is an auto_increment. Note I cannot change any of the contents of the table.</p> <pre class="lang-sql prettyprint-override"><code>create table Account( accountId int primary key not null auto_increment, accountNumber int not null, currentBalance double not null, type varchar(1) not null, personId int not null, foreign key(personId) references Person(personId) ); </code></pre>
[ { "answer_id": 74540159, "author": "Elliott Frisch", "author_id": 2970947, "author_profile": "https://Stackoverflow.com/users/2970947", "pm_score": 2, "selected": false, "text": "ALTER TABLE Account ADD CONSTRAINT account_number_uniq UNIQUE (accountNumber)\n" }, { "answer_id": 74557005, "author": "Fredy Fischer", "author_id": 7078384, "author_profile": "https://Stackoverflow.com/users/7078384", "pm_score": 0, "selected": false, "text": "String accountQuery = \"insert into Account (accountNumber,currentBalance,type,personId) values (?,?,?,?);\";\nPreparedStatement accountPs = null;\nString checkQuery = \"select count(*) noAccounts from Account where accountNumber = ?\";\nPreparedStatement accountCheck = null;\nResultSet checker = null;\n\ntry {\n accountCheck = conn.prepareStatement(checkQuery);\n accountCheck.setInt(1,accountHolder.getAccountNumber());\n checker = accountCheck.executeQuery();\n checker.next(); \n if ( checker.getInt(1) == 0 ) {\n\n // These are my prepare Statements for my queries\n accountPs = conn.prepareStatement(accountQuery);\n accountPs.setInt(1, accountHolder.getAccountNumber());\n accountPs.setDouble(2, accountHolder.getCurrentBalance());\n accountPs.setString(3, accountHolder.getType());\n accountPs.setInt(4, personId.getPersonId());\n\n accountPs.executeUpdate();\n }\n checker.close();\n accountCheck.close();\n accountPs.close();\n conn.close();\n}\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74540056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20535068/" ]
74,540,085
<p>I currently have a TreeSet that contains elements of type Pair, and I'm sorting them by their value in descending order.</p> <p>Here is the link to the original Pair class documentation: <a href="https://docs.oracle.com/javase/9/docs/api/javafx/util/Pair.html" rel="nofollow noreferrer">https://docs.oracle.com/javase/9/docs/api/javafx/util/Pair.html</a></p> <p>This is the declaration:</p> <pre><code>TreeSet&lt;Pair&lt;Integer, Integer&gt;&gt; sortedSet = new TreeSet&lt;Pair&lt;Integer, Integer&gt;&gt;((a,b) -&gt; b.getValue() - a.getValue()); </code></pre> <p>My issue is that if I try to insert a few pairs into the set, for example: Pair(4, 51), Pair(8, 85), Pair(1, 16), Pair(2,51), the Pair(2,51) doesn't get inserted.</p> <p>Code for inserting the pairs:</p> <pre><code>sortedSet.add(new Pair&lt;Integer, Integer&gt;(4, 51)); sortedSet.add(new Pair&lt;Integer, Integer&gt;(8, 85)); sortedSet.add(new Pair&lt;Integer, Integer&gt;(1, 16)); sortedSet.add(new Pair&lt;Integer, Integer&gt;(2, 51)); </code></pre> <p>I managed to figure out that the reason is because there already exists a pair element with the same value - P(4,51), however, they have different keys so they are different elements, and I expected the Pair(2,51) to be inserted before or after P(4,51).</p> <p>Is there a way I can solve this issue?</p>
[ { "answer_id": 74540211, "author": "meriton", "author_id": 183406, "author_profile": "https://Stackoverflow.com/users/183406", "pm_score": 0, "selected": false, "text": "Set List Collections.sort()" }, { "answer_id": 74540269, "author": "Turing85", "author_id": 4216641, "author_profile": "https://Stackoverflow.com/users/4216641", "pm_score": 3, "selected": true, "text": "Comparator (a,b) -> b.getValue() - a.getValue()\n Comparator Pair value Set add(...) Set Comparator Set Pair value key Comparator 0 Pair value key value key .reversed() value key final TreeSet<Pair<Integer, Integer>> sortedSet = new TreeSet<>(Comparator\n .comparingInt(Pair<Integer, Integer>::getValue).reversed()\n .thenComparing(Pair::getKey));\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74540085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12363706/" ]
74,540,087
<p>I have a json file with users, each users has <code>email</code> and <code>password</code> and corresponding POJO exist to deserialize them.</p> <p>I'm using both <code>jackson</code> and <code>JSON.simple</code>.</p> <p>However, I want to add users at will, and create a method to find them by their description, let's say this is my json:</p> <pre><code>{ &quot;user1&quot;: { &quot;email&quot;: &quot;user1@user.com&quot;, &quot;password&quot;: &quot;qwe123&quot;, }, &quot;user2&quot;: { &quot;email&quot;: &quot;user2@user.com&quot;, &quot;password&quot;: &quot;abc123&quot;, }, ... &quot;userX&quot;: { &quot;email&quot;: &quot;userX@user.com&quot;, &quot;password&quot;: &quot;omg123&quot;, } } </code></pre> <p>This is my POJO:</p> <pre><code>public record User(String email, String password) {} </code></pre> <p>I dont want to create superPOJO and add each user as I create them.</p> <p>I would like to create method that would read my json, and returned the <code>User</code> object based on String input.</p> <p>For now I created users in array and get them using their index, but now situation requires giving users &quot;nicknames&quot; and getting them by their nickname.</p> <p>Now I am keeping user like this:</p> <pre><code>[ { &quot;email&quot;: &quot;xxx@xxx.com&quot;, &quot;password&quot;: &quot;xxx111&quot;, }, { &quot;email&quot;: &quot;yyy@yyy.com&quot;, &quot;password&quot;: &quot;yyy222&quot;, } ] </code></pre> <p>This is my current method:</p> <pre><code>public User getUser(int index) throws IOException { return Parser.deserializeJson(getUserFile(), User[].class)[index]; } </code></pre> <p>where <code>Parser#deserializeJson()</code> is:</p> <pre><code>public &lt;T&gt; T deserializeJson(String fileName, Class&lt;T&gt; clazz) throws IOException { return new ObjectMapper().readValue(Utils.reader(fileName), clazz); } </code></pre> <p>And <code>Utils.reader</code> just brings file from the classpath.</p> <p>I would like a method like this:</p> <pre><code>public User getUser(String nickname) throws IOException { return Parser.deserializeJson(getUserFile(), User.class); } </code></pre> <p>and when calling this method with parameter <code>nickname</code> of <code>user2</code> I'd get <code>User</code> object with fields: email <code>user2@user.com</code> and password <code>abc123</code></p>
[ { "answer_id": 74540281, "author": "Garrett Motzner", "author_id": 8031815, "author_profile": "https://Stackoverflow.com/users/8031815", "pm_score": 3, "selected": true, "text": "{\n \"user1\": {\n \"email\": \"user1@user.com\",\n \"password\": \"qwe123\",\n },\n \"user2\": {\n \"email\": \"user2@user.com\",\n \"password\": \"abc123\",\n },\n\n...\n \"userX\": {\n \"email\": \"userX@user.com\",\n \"password\": \"omg123\",\n }\n}\n public <T> Map<String, Class<T>> deserializeJson(String fileName) throws IOException {\n return new ObjectMapper().readValue(Utils.reader(fileName), new TypeReference<HashMap<String, Class<T>>>(){});\n}\n public User getPredefinedUser(String nickname) throws IOException {\n return Parser.deserializeJson(getUserFile(), User.class).get(nickname);\n}\n" }, { "answer_id": 74540376, "author": "hetacz", "author_id": 18951958, "author_profile": "https://Stackoverflow.com/users/18951958", "pm_score": 0, "selected": false, "text": "JSON.simple com.fasterxml.jackson.core Parser MAPPER new ObjectMapper() public JsonNode toJsonNode(String fileName) throws IOException {\n return MAPPER.readTree(Utils.reader(fileName));\n }\n parseJson Parser public <T> T parseJson(String json, Class<T> clazz) throws JsonProcessingException {\n return MAPPER.readValue(json, clazz);\n }\n User public User getUser(String nickname) throws IOException {\n return Parser.parseJson(Parser.toJsonNode(USERS).get(nickname).toString(), User.class);\n }\n @Test(groups = Group.TEST)\n public void jsonTest() throws IOException, ParseException {\n User user = Utils.getUser(\"user2\");\n log.warn(user.email());\n log.warn(user.password());\n }\n 2022-11-23 T 02:47:58.177+0100 [28][WARN] tests.smoke.SmokeTest->jsonTest user2@user.com\n2022-11-23 T 02:47:58.177+0100 [28][WARN] tests.smoke.SmokeTest->jsonTest abc123\n asText() toString() toString() expected:<\"[\"This field is required\"]\"> but was:<\"[This field is required]\">\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74540087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18951958/" ]
74,540,104
<p>My first steps with 64 base encoding and i have an issue with the emoticon repeating partially horizontally.</p> <p>Here the result and i have trying many different encoding apps with same result :</p> <p><a href="https://i.stack.imgur.com/OfA2U.jpg" rel="nofollow noreferrer">enter image description here</a></p> <p>I have tried all encoding apps with same result. Also tried background no-repeat and width and height with same result.</p> <p>The code i have use :</p> <p>url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgoKPHN2Z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lbm9kZDtjbGlwLXJ1bGU6ZXZlbm9kZDtmaWxsOiNGRkZGRkY7fQoJLnN0M3tmaWxsLXJ1bGU6ZXZlbm9kZDtjbGlwLXJ1bGU6ZXZlbm9kZDtmaWxsOiNGRjAwNEY7fQo8L3N0eWxlPjxzdHlsZQogICAgIHR5cGU9InRleHQvY3NzIgogICAgIGlkPSJzdHlsZTE0NDg0MzUiPiAuc3Qwe2ZpbGw6I0UzRTI2Mzt9IC5zdDF7ZmlsbDojMDcwNzA1O30gLnN0MntmaWxsOiNFMTMxMUE7fSAuc3Qze2ZpbGw6I0ZGRkZGRjt9IC5zdDR7ZmlsbDojRTNFNjkzO30gLnN0NXtmaWxsOiNBNUM2MkE7fSA8L3N0eWxlPjwvc3ZnPgo=')</p>
[ { "answer_id": 74540281, "author": "Garrett Motzner", "author_id": 8031815, "author_profile": "https://Stackoverflow.com/users/8031815", "pm_score": 3, "selected": true, "text": "{\n \"user1\": {\n \"email\": \"user1@user.com\",\n \"password\": \"qwe123\",\n },\n \"user2\": {\n \"email\": \"user2@user.com\",\n \"password\": \"abc123\",\n },\n\n...\n \"userX\": {\n \"email\": \"userX@user.com\",\n \"password\": \"omg123\",\n }\n}\n public <T> Map<String, Class<T>> deserializeJson(String fileName) throws IOException {\n return new ObjectMapper().readValue(Utils.reader(fileName), new TypeReference<HashMap<String, Class<T>>>(){});\n}\n public User getPredefinedUser(String nickname) throws IOException {\n return Parser.deserializeJson(getUserFile(), User.class).get(nickname);\n}\n" }, { "answer_id": 74540376, "author": "hetacz", "author_id": 18951958, "author_profile": "https://Stackoverflow.com/users/18951958", "pm_score": 0, "selected": false, "text": "JSON.simple com.fasterxml.jackson.core Parser MAPPER new ObjectMapper() public JsonNode toJsonNode(String fileName) throws IOException {\n return MAPPER.readTree(Utils.reader(fileName));\n }\n parseJson Parser public <T> T parseJson(String json, Class<T> clazz) throws JsonProcessingException {\n return MAPPER.readValue(json, clazz);\n }\n User public User getUser(String nickname) throws IOException {\n return Parser.parseJson(Parser.toJsonNode(USERS).get(nickname).toString(), User.class);\n }\n @Test(groups = Group.TEST)\n public void jsonTest() throws IOException, ParseException {\n User user = Utils.getUser(\"user2\");\n log.warn(user.email());\n log.warn(user.password());\n }\n 2022-11-23 T 02:47:58.177+0100 [28][WARN] tests.smoke.SmokeTest->jsonTest user2@user.com\n2022-11-23 T 02:47:58.177+0100 [28][WARN] tests.smoke.SmokeTest->jsonTest abc123\n asText() toString() toString() expected:<\"[\"This field is required\"]\"> but was:<\"[This field is required]\">\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74540104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20351694/" ]
74,540,134
<p>I have a submit button that uses Gravity Forms to conditionally show or hide the button.</p> <p>When the button is shown the code looks like: <code>&lt;button class=&quot;button gform_button&quot; id=&quot;gform_submit_button_1&quot; style=&quot;&quot;&gt;</code></p> <p>When the button is not shown the code looks like: <code>&lt;button class=&quot;button gform_button&quot; id=&quot;gform_submit_button_1&quot; style=&quot;display: none;&quot;&gt;</code></p> <p>So, what I wanted to do was display a div when the button is not displayed or has the inline style <code>display: none</code>.</p> <p>I thought I could do something like this:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function myFunction() { var x = document.getElementById('gform_submit_button_1'); if (x.style.display = 'none') { document.getElementById("div1").style.display = "block"; } else { document.getElementById("div1").style.display = "none"; } }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="div1"&gt;This is a hidden div that we can show with JavaScript&lt;/div&gt;</code></pre> </div> </div> </p> <p>This shows <code>div1</code> when the page loads, but when <code>style=&quot;&quot;</code> the div does not hide. When the condition is true and <code>style=&quot;&quot;</code> the page does not refresh, which is probably the issue. Is there a way to tweak things so that when <code>style=&quot;&quot;</code> <code>div1</code> is not shown?</p> <p>Thanks,<br /> Josh</p>
[ { "answer_id": 74540349, "author": "Dream Bold", "author_id": 12743692, "author_profile": "https://Stackoverflow.com/users/12743692", "pm_score": 1, "selected": false, "text": "if (x.style.display = 'none') \n if (x.style.display == 'none') \n if true x.style.display 'none' = == ===" }, { "answer_id": 74540439, "author": "str1ng", "author_id": 12826055, "author_profile": "https://Stackoverflow.com/users/12826055", "pm_score": 0, "selected": false, "text": "if (x.style.display = 'none') \n if (x.style.display == 'none') \n == = if true x.style.display 'none' = == === action window.onload window.onload = function(){\nvar x = document.getElementById(\"gform_submit_button_1\");\nif(x.style.display == \"none\"){\nalert(\"Display of x is none\");\ndocument.getElementById(\"div1\").style.display = \"block\";\n}\nelse{\nalert(\"Display of x is not none\");\ndocument.getElementById(\"div1\").style.display = \"none\";\nx.style.display = \"block\";\n}\n}\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74540134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1258059/" ]
74,540,135
<p>How can DynamoDB be used as a sink to an AWS Data Analytics Application (Flink)?</p> <p>I'm not finding examples or an existing DynamoDB Sink implementation class.</p>
[ { "answer_id": 74540349, "author": "Dream Bold", "author_id": 12743692, "author_profile": "https://Stackoverflow.com/users/12743692", "pm_score": 1, "selected": false, "text": "if (x.style.display = 'none') \n if (x.style.display == 'none') \n if true x.style.display 'none' = == ===" }, { "answer_id": 74540439, "author": "str1ng", "author_id": 12826055, "author_profile": "https://Stackoverflow.com/users/12826055", "pm_score": 0, "selected": false, "text": "if (x.style.display = 'none') \n if (x.style.display == 'none') \n == = if true x.style.display 'none' = == === action window.onload window.onload = function(){\nvar x = document.getElementById(\"gform_submit_button_1\");\nif(x.style.display == \"none\"){\nalert(\"Display of x is none\");\ndocument.getElementById(\"div1\").style.display = \"block\";\n}\nelse{\nalert(\"Display of x is not none\");\ndocument.getElementById(\"div1\").style.display = \"none\";\nx.style.display = \"block\";\n}\n}\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74540135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/984368/" ]
74,540,142
<pre><code>import React, { useState } from 'react'; import NavBar from &quot;../../components/navBar/navbar&quot;; import &quot;./profile.scss&quot; import add from './Images/add.png' import added from './Images/added.png' const Profile = () =&gt; { return ( &lt;div className=&quot;navbar-display&quot;&gt; &lt;NavBar/&gt; &lt;div className=&quot;right&quot; &gt; &lt;img id='imageid' src={add} alt='' onClick={''}/&gt; &lt;/div&gt; &lt;/div&gt; ) } export default Profile; </code></pre> <pre><code> &lt;div className=&quot;right&quot; &gt; &lt;img id='imageid' src={add} alt='' onClick={''}/&gt; &lt;/div&gt; </code></pre> <p>This is the section im having troubles with. Ive tried lots of online methods but constantly ran into errors and cant seem to find a definitive way to onclick change image with ReactJS</p>
[ { "answer_id": 74540349, "author": "Dream Bold", "author_id": 12743692, "author_profile": "https://Stackoverflow.com/users/12743692", "pm_score": 1, "selected": false, "text": "if (x.style.display = 'none') \n if (x.style.display == 'none') \n if true x.style.display 'none' = == ===" }, { "answer_id": 74540439, "author": "str1ng", "author_id": 12826055, "author_profile": "https://Stackoverflow.com/users/12826055", "pm_score": 0, "selected": false, "text": "if (x.style.display = 'none') \n if (x.style.display == 'none') \n == = if true x.style.display 'none' = == === action window.onload window.onload = function(){\nvar x = document.getElementById(\"gform_submit_button_1\");\nif(x.style.display == \"none\"){\nalert(\"Display of x is none\");\ndocument.getElementById(\"div1\").style.display = \"block\";\n}\nelse{\nalert(\"Display of x is not none\");\ndocument.getElementById(\"div1\").style.display = \"none\";\nx.style.display = \"block\";\n}\n}\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74540142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12436148/" ]
74,540,146
<p>I'm using fetch to retrieve 2 datasets. Something like this:</p> <pre class="lang-js prettyprint-override"><code>Promise.all([ fetch(table1URL).then(response =&gt; response.json()), fetch(table2URL).then(response =&gt; response.json()) ]).then(response =&gt; { let table1 = response[0]; let table2 = response[1] let merged_data = ....... }) </code></pre> <p>I'm trying to create a new dataset called merged_data, which would be data from both tables merged</p> <p>The tables can be joined on the following fields via a left join;</p> <ul> <li>table1.name = table2.oldname</li> </ul> <p>The resulting dataset would look something like this:</p> <ul> <li>column 1 = table1.name</li> <li>column 2 = table1.modifiedDateTime</li> <li>column 3 = table1.modifiedBy</li> <li>column 4 = table2.Modified</li> <li>column 5 = table2.oldname</li> </ul> <p>Any help would be much appreciated</p>
[ { "answer_id": 74540325, "author": "Phil", "author_id": 283366, "author_profile": "https://Stackoverflow.com/users/283366", "pm_score": 2, "selected": false, "text": "table2 oldname table1 table2 const table2Index = table2.reduce(\n (map, row) => map.set(row.oldname, row),\n new Map()\n);\n\nconst result = table1.map(({ name, modifiedDateTime, modifiedBy }) => [\n name,\n modifiedDateTime,\n modifiedBy,\n table2Index.get(name)?.Modified,\n table2Index.get(name)?.oldname,\n]);\n" }, { "answer_id": 74540347, "author": "Cristian Torres", "author_id": 6233092, "author_profile": "https://Stackoverflow.com/users/6233092", "pm_score": 1, "selected": false, "text": "let table1 = [\n {name: 'a', modifiedDateTime: 'date', modifiedBy: 'user'}, \n {name: 'b', modifiedDateTime: 'date', modifiedBy: 'user'},\n {name: 'c', modifiedDateTime: 'date', modifiedBy: 'user'}\n]\n\nlet table2 = [\n {oldname: 'a', Modified: 'dateFromTable2'}, \n {oldname: 'b', Modified: 'dateFromTable2'}\n]\n\nlet right_table = new Map(table2.map(right_row => ([right_row.oldname, right_row])))\n\nlet merged_data = table1.map(left_row => ({\n column1:left_row.name,\n column2:left_row.modifiedDateTime,\n column3:left_row.modifiedBy,\n column4:right_table.get(left_row.name)?.Modified,\n column5:right_table.get(left_row.name)?.oldname\n })) \nconsole.log(merged_data)" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74540146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4214984/" ]
74,540,147
<p>Typing <code>postMessage</code> communication in my web app and currently stuck with trying to write Typescript types for <code>window.addEventListener</code> listeners.</p> <p>I have a list of possible messages my listeners can receive and I distinguish them by <code>event.data.method</code> property. However with the types I wrote I'm not able to determine the rest of the <code>event.data</code> content. Am I missing some type guards or my generics are just wrong? Thank you.</p> <p><a href="https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgLIQM4bgc08gbwChlTkBybATwFoALYcgLkJLPZyggjFBxYxgofANxtSAXzHtKcWgCMqEZq3bt4XAO4QANjoFDR45FKISiRMFQAOKdFlwQAMsEEQQ0ZAF5kAHlTIEAAekCAAJhjIANYQVAD2MGiY2HgYAHwAFMYQLPYpEACiAG7uYL7EamQAtjx0cWG50pXIYXBgcLnJjhgA2qgAuk2SaQA0RACU3mnIcCBUYkQIcSCCM2FheY7FpS5uHlDeyBk6rqHQnQ54u2dQ4yxFccBhU8aaoGFxmgB0cOvb4Nd3NAMuQapdlCNkCc9tBxgtfhsunh-mBAfsMhASuApqoyMBEhisWAvq12l8amA6s8vDSKNR6IxJhVmgB6FnIAAS0BQAElkJo4gBXHTPYK2BBgZCUtrIHnkPTIeQoODyHQoMBxZCCjAoABEmNKJLacCNZM43F4IBwush8kFkr5eDATGM7DZyAAClA4rYoFYKOaeHxyC04vgQHFJcFTshllKbChyARkIHLfxkIJhFaRCZkAAfQjIDQQbR6AxZnA5iTkL6usjur0+6D+8ip4Oh8ORwJBGNxqy2CjJ4ul-QZwzZkw1jIAJgAzLOAJzjOukJYrOJqr46OI4QmG0kmg9fNtWuHGcwSOFAA" rel="nofollow noreferrer">ts playground</a></p> <pre class="lang-js prettyprint-override"><code>interface Messages { 'say-hi': { greeting: string; }; 'say-bye': { farewell: string; }; } type MessageListener = &lt;M extends keyof Messages&gt;( e: MessageEvent&lt;{ method: M; data: Messages[M]; }&gt;, ) =&gt; any; const addMessageEventListener = (listener: MessageListener): void =&gt; window.addEventListener('message', listener); addMessageEventListener(event =&gt; { if (event.data.method === 'say-hi') { // Here I would expect that I'll be able to use &quot;event.data.data.greeting&quot;, but I get: // Property 'greeting' does not exist on type '{ greeting: string; } | { farewell: string; }'. // Property 'greeting' does not exist on type '{ farewell: string; }'.(2339) console.log(event.data.data.greeting); } }); </code></pre>
[ { "answer_id": 74540257, "author": "Alex Wayne", "author_id": 62076, "author_profile": "https://Stackoverflow.com/users/62076", "pm_score": 3, "selected": true, "text": "M e Messages type MyMessageEvent = {\n [K in keyof Messages]: MessageEvent<{\n method: K,\n data: Messages[K]\n }>\n}[keyof Messages]\n Messages type MyMessageEvent =\n | MessageEvent<{\n method: 'say-hi'\n data: { greeting: string }\n }>\n | MessageEvent<{\n method: 'say-bye'\n data: { farewell: string }\n }>\n\n method type MessageListener = (e: MyMessageEvent) => any;\n\nconst addMessageEventListener = (listener: MessageListener): void =>\n window.addEventListener('message', listener);\n\naddMessageEventListener(event => {\n if (event.data.method === 'say-hi') {\n console.log(event.data.data.greeting); // works\n }\n});\n" }, { "answer_id": 74540485, "author": "Chris Hamilton", "author_id": 12914833, "author_profile": "https://Stackoverflow.com/users/12914833", "pm_score": 1, "selected": false, "text": "type Messages = { method: 'say-hi', data: {greeting: string} } \n | { method: 'say-bye', data: {farewell: string} }\n\ntype MessageListener = ( e: MessageEvent<Messages> ) => any;\n\nconst addMessageEventListener = (listener: MessageListener): void =>\n window.addEventListener('message', listener);\n\naddMessageEventListener(event => {\n if (event.data.method === 'say-hi') {\n console.log(event.data.data.greeting); // ok\n }\n});\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74540147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11529155/" ]
74,540,196
<p>I use firestore and streambuilder to read data in a list, when i run the application for the first time i get a message &quot;Unexpected null value&quot; and I realized that &quot;snapshot.hasData&quot; is always false and snapshot.ConnectionState.waiting is always true. But when i restart application with hot reload i can retrieve data.</p> <p>This is my stream:</p> <pre><code>Stream&lt;QuerySnapshot&gt; _branchStream = FirebaseFirestore.instance.collection('Companies').doc(company_id).collection(&quot;Branch Offices&quot;).snapshots(); </code></pre> <p>This is my StreamBuilder</p> <pre><code>StreamBuilder&lt;QuerySnapshot&gt;( stream: _branchStream, builder: (BuildContext context, AsyncSnapshot&lt;QuerySnapshot&gt; snapshot) { /* if (snapshot.hasError) { return const Text('Something went wrong'); } if (snapshot.connectionState == ConnectionState.waiting) { return const Text(&quot;Loading&quot;); }*/ return ListView( children: snapshot.data!.docs .map((DocumentSnapshot document) { Map&lt;String, dynamic&gt; data = document.data()! as Map&lt;String, dynamic&gt;; return Padding( padding: const EdgeInsets.all(22.0), child: Card( elevation: 8, shadowColor: Colors.blueGrey, shape: cardShape, child: Row( children: [ Expanded( flex: 2, child: Padding( padding: const EdgeInsets.all(22.0), child: CircleAvatar( radius: 50, backgroundImage: NetworkImage(data['branch_image'],scale: 60), ), )), Expanded( flex: 4, child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.all(22.0), child: Text(data['branch_name'], style: textBlackTitle, textAlign: TextAlign.center,), ), Padding( padding: const EdgeInsets.all(22.0), child: Text(&quot;Ubicación: &quot;+data['branch_address'], style: textGraySubTitle, textAlign: TextAlign.center,), ), ], )), Expanded( flex: 2, child: IconButton( // focusColor: Color(color1), // color: Color(color1), onPressed: (){ Navigator.push(context, MaterialPageRoute(builder: (context) =&gt; Home(branch_id : data['branch_id'], company_id : company_id, branch_name : data['branch_name'], branch_image : data['branch_image']))); }, icon: Image.asset(&quot;assets/enter.png&quot;, fit: BoxFit.contain, height: 100,))) ], ), ), ); }) .toList() .cast(), ); }, ) </code></pre> <p>This is data that I want to get</p> <p><a href="https://i.stack.imgur.com/gv63i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gv63i.png" alt="enter image description here" /></a></p> <p>This is what I get at the first time</p> <p><a href="https://i.stack.imgur.com/03V34.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/03V34.png" alt="enter image description here" /></a></p> <p>This is what I get after hot reload (That I should have from the beginning).</p> <p><a href="https://i.stack.imgur.com/aDlBz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aDlBz.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74540257, "author": "Alex Wayne", "author_id": 62076, "author_profile": "https://Stackoverflow.com/users/62076", "pm_score": 3, "selected": true, "text": "M e Messages type MyMessageEvent = {\n [K in keyof Messages]: MessageEvent<{\n method: K,\n data: Messages[K]\n }>\n}[keyof Messages]\n Messages type MyMessageEvent =\n | MessageEvent<{\n method: 'say-hi'\n data: { greeting: string }\n }>\n | MessageEvent<{\n method: 'say-bye'\n data: { farewell: string }\n }>\n\n method type MessageListener = (e: MyMessageEvent) => any;\n\nconst addMessageEventListener = (listener: MessageListener): void =>\n window.addEventListener('message', listener);\n\naddMessageEventListener(event => {\n if (event.data.method === 'say-hi') {\n console.log(event.data.data.greeting); // works\n }\n});\n" }, { "answer_id": 74540485, "author": "Chris Hamilton", "author_id": 12914833, "author_profile": "https://Stackoverflow.com/users/12914833", "pm_score": 1, "selected": false, "text": "type Messages = { method: 'say-hi', data: {greeting: string} } \n | { method: 'say-bye', data: {farewell: string} }\n\ntype MessageListener = ( e: MessageEvent<Messages> ) => any;\n\nconst addMessageEventListener = (listener: MessageListener): void =>\n window.addEventListener('message', listener);\n\naddMessageEventListener(event => {\n if (event.data.method === 'say-hi') {\n console.log(event.data.data.greeting); // ok\n }\n});\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74540196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9906666/" ]
74,540,232
<p>I have these defined types</p> <pre><code> type Name = string type Flow = int type River = R of Name * Flow * River list type Tributaries = River list </code></pre> <p>And i want to declare a function contains n r that returns a boolean value if n is contained in River or any of it's branches/Tributaries. and i've came up with this so far</p> <pre><code>let rec contains (n:Name)(r:River) = match r with |R(Name,_,_) when Name = n -&gt; true |R(_,_,Tr) -&gt; contains n Tr |_ -&gt; false </code></pre> <p>However F# cant recoginze Tr as Tr is a list and not of type river so i can't pass it in of course, how can i do this in a nice and clean way without declaring two seperate functions to help?</p>
[ { "answer_id": 74542950, "author": "Gus", "author_id": 446822, "author_profile": "https://Stackoverflow.com/users/446822", "pm_score": 0, "selected": false, "text": "Tr |R(_,_,Tr) -> contains n Tr\n | R (name, f, x::xs) -> contains n x || contains n (R (name, f, xs))\n" }, { "answer_id": 74549167, "author": "MrD at KookerellaLtd", "author_id": 2088029, "author_profile": "https://Stackoverflow.com/users/2088029", "pm_score": 1, "selected": false, "text": "type Name = string\ntype Flow = int\ntype Tributaries = River list\nand River = R of Name * Flow * Tributaries\n let rec containsTributaries (n: Name) (rs: River list) =\n match rs with\n | R (name, _, _) :: _ when name = n -> true\n | R (_, _, tribs) :: tail -> containsTributaries n tail || containsTributaries n tribs\n | _ -> false\n let rec contains (n: Name) (river: River) =\n containsTributaries n [ river ]\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74540232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17041635/" ]
74,540,261
<p>My code looks something like this currently:</p> <pre><code>&lt;View&gt; &lt;TextInput placeholder='PlaceholderText'&gt; &lt;/TextInput&gt; &lt;/View&gt; </code></pre> <p>I want to make a <code>TextInput</code> component that has an <strong>opacity animation on click</strong> (exactly like <code>TouchableOpacity</code> changes opacity on click).</p> <p>I tried wrapping the <code>TextInput</code> inside <code>TouchableOpacity</code>, but it doesn't work since the touchable component surrounds text input. Is there a standard React Native or StyleSheet way of doing this or would I have to manually create an animation to mimic that effect?</p>
[ { "answer_id": 74540590, "author": "Abe", "author_id": 10718641, "author_profile": "https://Stackoverflow.com/users/10718641", "pm_score": 0, "selected": false, "text": "onPressIn onPressOut const [pressed, setPressed] = useState(false);\n\n// in render\n\n <TextInput\n onPressIn={() => setPressed(true)}\n onPressOut={() => setPressed(false)}\n style={pressed ? styles.textInputPressed : styles.textInput}\n // ...\n />\n" }, { "answer_id": 74544931, "author": "Sercan Samet Savran", "author_id": 6222189, "author_profile": "https://Stackoverflow.com/users/6222189", "pm_score": 2, "selected": true, "text": "TextInput View // First create an animated value to use for the view's opacity.\n const textInputAnimOpacity = useRef(new Animated.Value(1.0)).current;\n // create a method to set the opacity back to 1.0\n const showTxtInput = () => {\n Animated.timing(textInputAnimOpacity, {\n toValue: 1.0, // value to reach\n duration: 250 // time in ms \n }).start();\n };\n \n // this animated method differs from the first one by (obviously the value 0.7) \n //and the callback part that goes into the start()-method\n const blurTxtInput = () => {\n Animated.timing(textInputAnimOpacity, {\n toValue: 0.7, // value to reach\n duration: 250 // time in ms\n }).start(({ finished }) => {\n showTxtInput(); // Callback after finish, setting opacity back to 1.0\n });\n };\n /*Set the opacity to the value, we want to animate*/\n <View style={{opacity:textInputAnimOpacity}}>\n /* call blurTxtInput to set the value to 0.7 and again to 1.0 once it reaches 0.7*/\n <TextInput onPressIn={blurTxtInput} placeholder='PlaceholderText'>\n </TextInput>\n </View>\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74540261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11898152/" ]
74,540,272
<p>I'd like to add parentheses around grouped text separated by a comma using <code>stringr</code>. So if there is text that is separated by one or more commas, then I'd like parentheses around the text. There will always be a &quot;=&quot; before this type of string begins and there will either be a space or nothing (vector ends) after the string. Is there a generalized way to do this? Here's a sample problem:</p> <p>Sample:</p> <pre><code>a &lt;- data.frame(Rule = c(&quot;A=0 &amp; B=Grp1,Grp2&quot;, &quot;A=0 &amp; B=Grp1,Grp3,Grp4 &amp; C=1&quot;)) a Rule 1 A=0 &amp; B=Grp1,Grp2 2 A=0 &amp; B=Grp1,Grp3,Grp4 &amp; C=1 </code></pre> <p>Desired Output:</p> <pre><code> Rule 1 A=0 &amp; B=(Grp1,Grp2) 2 A=0 &amp; B=(Grp1,Grp3,Grp4) &amp; C=1 </code></pre>
[ { "answer_id": 74540590, "author": "Abe", "author_id": 10718641, "author_profile": "https://Stackoverflow.com/users/10718641", "pm_score": 0, "selected": false, "text": "onPressIn onPressOut const [pressed, setPressed] = useState(false);\n\n// in render\n\n <TextInput\n onPressIn={() => setPressed(true)}\n onPressOut={() => setPressed(false)}\n style={pressed ? styles.textInputPressed : styles.textInput}\n // ...\n />\n" }, { "answer_id": 74544931, "author": "Sercan Samet Savran", "author_id": 6222189, "author_profile": "https://Stackoverflow.com/users/6222189", "pm_score": 2, "selected": true, "text": "TextInput View // First create an animated value to use for the view's opacity.\n const textInputAnimOpacity = useRef(new Animated.Value(1.0)).current;\n // create a method to set the opacity back to 1.0\n const showTxtInput = () => {\n Animated.timing(textInputAnimOpacity, {\n toValue: 1.0, // value to reach\n duration: 250 // time in ms \n }).start();\n };\n \n // this animated method differs from the first one by (obviously the value 0.7) \n //and the callback part that goes into the start()-method\n const blurTxtInput = () => {\n Animated.timing(textInputAnimOpacity, {\n toValue: 0.7, // value to reach\n duration: 250 // time in ms\n }).start(({ finished }) => {\n showTxtInput(); // Callback after finish, setting opacity back to 1.0\n });\n };\n /*Set the opacity to the value, we want to animate*/\n <View style={{opacity:textInputAnimOpacity}}>\n /* call blurTxtInput to set the value to 0.7 and again to 1.0 once it reaches 0.7*/\n <TextInput onPressIn={blurTxtInput} placeholder='PlaceholderText'>\n </TextInput>\n </View>\n" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74540272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7999936/" ]
74,540,293
<p>I'm attempting to listen for a change in a boolean value &amp; changing the view once it has been heard which it does successfully, however, results in a yellow triangle. I haven't managed to pinpoint the issue but it doesn't seem to have anything to do with the view that it's transitioning to as even when changed the error still persists.</p> <p>My code is below</p> <pre><code>import SwiftUI struct ConversationsView: View { @State var isShowingNewMessageView = false @State var showChat = false @State var root = [Root]() var body: some View { NavigationStack(path: $root) { ZStack(alignment: .bottomTrailing) { ScrollView { LazyVStack { ForEach(0..&lt;20) { _ in Text(&quot;Test&quot;) } } }.padding() } Button { self.isShowingNewMessageView.toggle() } label: { Image(systemName: &quot;plus.message.fill&quot;) .resizable() .renderingMode(.template) .frame(width: 48, height: 48) .padding() .foregroundColor(Color.blue) .sheet(isPresented: $isShowingNewMessageView, content: { NewMessageView(show: $isShowingNewMessageView, startChat: $showChat) }) } } .onChange(of: showChat) { newValue in guard newValue else {return} root.append(.profile) }.navigationDestination(for: Root.self) { navigation in switch navigation { case .profile: ChatView() } } } enum Root { case profile } </code></pre> <p>}</p> <p>ChatView() Code:</p> <pre><code>import SwiftUI struct ChatView: View { @State var messageText: String = &quot;&quot; var body: some View { VStack { ScrollView { VStack(alignment: .leading, spacing: 12) { ForEach(MOCK_MESSAGES) { message in MessageView(message: message) } } }.padding(.top) MessageInputView(messageText: $messageText) .padding() } } </code></pre> <p>}</p> <p>Any support is much appreciated.</p>
[ { "answer_id": 74581873, "author": "Evgeny", "author_id": 7309962, "author_profile": "https://Stackoverflow.com/users/7309962", "pm_score": 2, "selected": false, "text": "navigationDestination NavigationStack NavigationStack(path: $root) {\n ZStack(alignment: .bottomTrailing) {\n \n ScrollView {\n LazyVStack {\n ForEach(0..<20) { _ in\n Text(\"Test\")\n }\n }\n }.padding()\n }.navigationDestination(for: Root.self) { navigation in\n switch navigation {\n case .profile:\n ChatView()\n }\n }\n\n //...\n}\n NavigationStack navigationDestination NavigationStack" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74540293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15471304/" ]
74,540,309
<p>so I'm try to &quot;connect&quot; two tables using <code>belongsTo</code> and <code>hasMany</code> but it doesn't seem to be working... I'll link my code down below, if there is anything else you might need to fully understand the problem, please feel free to ask!</p> <p><strong>pages.notification</strong></p> <pre><code>&lt;section class=&quot;all-notifications&quot;&gt; @each('partials.notification', $sent_notifications, 'notification') @each('partials.notification', $received_notifications, 'notification') &lt;/section&gt; </code></pre> <p><strong>partials.notification</strong></p> <pre><code>&lt;div class=&quot;singular-notification&quot;&gt; &lt;div class=&quot;notification-title&quot;&gt; &lt;a href=&quot;/event/{{ $notification-&gt;event-&gt;id }}&quot;&gt; {{ $notification-&gt;event-&gt;name }} &lt;/a&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>SQL</strong></p> <pre><code>CREATE TABLE event ( id SERIAL PRIMARY KEY, owner_id INT NOT NULL REFERENCES users(id), name TEXT NOT NULL, description TEXT NOT NULL, tag TEXT, start_datetime TIMESTAMP NOT NULL CHECK (start_datetime &gt;= now()), end_datetime TIMESTAMP NOT NULL CHECK (end_datetime &gt; start_datetime), price FLOAT DEFAULT 0.0, max_capacity INT DEFAULT NULL, attendee_counter INT DEFAULT 0 CHECK (attendee_counter &lt;= max_capacity AND attendee_counter &gt;= 0), location TEXT NOT NULL, image TEXT NOT NULL, is_private BOOLEAN DEFAULT false, is_full BOOLEAN DEFAULT false ); CREATE TABLE notification ( id SERIAL PRIMARY KEY, event_id INT NOT NULL REFERENCES event(id), sent_users_id INT NOT NULL REFERENCES users(id) CHECK (sent_users_id != receiver_users_id), receiver_users_id INT NOT NULL REFERENCES users(id), status notification_status NOT NULL ); </code></pre> <p><strong>NotificationController.php</strong></p> <pre><code>public function list($id) { if (!Auth::check()) return redirect('/login'); $sent_notifications = DB::table('notification')-&gt;where('sent_users_id', $id)-&gt;orderBy('id')-&gt;get(); $received_notifications = DB::table('notification')-&gt;where('receiver_users_id', $id)-&gt;orderBy('id')-&gt;get(); return view('pages.notifications', ['sent_notifications' =&gt; $sent_notifications, 'received_notifications' =&gt; $received_notifications]); } </code></pre> <p><strong>Event.php</strong></p> <pre><code>public function notifications() { return $this-&gt;hasMany('App\Models\Notification'); } public function notification() { return $this-&gt;hasMany(Notification::class); } </code></pre> <p><strong>Notification.php</strong></p> <pre><code>public function event() { return $this-&gt;belongsTo('App\Models\Event'); } public function events() { return $this-&gt;belongsTo(Event::class); } </code></pre> <p>The error I'm getting is <code>Undefined property: stdClass::$event</code> and I can't seem to get around it... please let me know if there's an easy fix.</p> <p>Thanks alot for your time</p>
[ { "answer_id": 74581873, "author": "Evgeny", "author_id": 7309962, "author_profile": "https://Stackoverflow.com/users/7309962", "pm_score": 2, "selected": false, "text": "navigationDestination NavigationStack NavigationStack(path: $root) {\n ZStack(alignment: .bottomTrailing) {\n \n ScrollView {\n LazyVStack {\n ForEach(0..<20) { _ in\n Text(\"Test\")\n }\n }\n }.padding()\n }.navigationDestination(for: Root.self) { navigation in\n switch navigation {\n case .profile:\n ChatView()\n }\n }\n\n //...\n}\n NavigationStack navigationDestination NavigationStack" } ]
2022/11/22
[ "https://Stackoverflow.com/questions/74540309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15775091/" ]
74,540,350
<p>A little background on my question, I am completely new to .NET Framework. I inherited a large project that has many dependencies and the solution is too large to upload onto GitHub. This project currently does not use any version control. My question is what is the best practice for .Net projects regarding version control with projects of this size? Any help or suggestions would be very much appreciated.</p> <p>I have tried uploading to GitHub and got an error message about file size.</p>
[ { "answer_id": 74541688, "author": "tymtam", "author_id": 581076, "author_profile": "https://Stackoverflow.com/users/581076", "pm_score": 2, "selected": false, "text": ".gitignore" } ]
2022/11/23
[ "https://Stackoverflow.com/questions/74540350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9258972/" ]
74,540,352
<p>I am using Oracle Apex 22.2 and Oracle Database XE 21c on CentOS7. I am traversing all the nested elements of JSON data with the procedure shown below. However when I get the value of a number, the number loses its original format. For example, instead of getting 100.0, I get 100. How can I reserve the original format of the number? As you can see in my code below, I am using to_String to get value of the number. This is was one of my attempts to reserve the original number format. I have also tried with TO_CHAR &amp; TO_NUMBER() . All give the same output. Your help is really appreciated.</p> <p><strong>Procedure Code</strong></p> <pre><code>create or replace PROCEDURE ETA_JSON_SERIALIZE ( json_in IN JSON_ELEMENT_T, can_str IN OUT VARCHAR2, object_key IN VARCHAR2 DEFAULT NULL ) IS BEGIN IF json_in.is_Object() THEN DECLARE l_object JSON_OBJECT_T := TREAT(json_in AS JSON_OBJECT_T); l_keys JSON_KEY_LIST := l_object.get_Keys(); BEGIN FOR i IN 1 .. l_keys.COUNT LOOP can_str := can_str || '&quot;'||UPPER(l_keys(i))||'&quot;'; ETA_JSON_SERIALIZE(l_object.get(l_keys(i)), can_str, l_keys(i)); END LOOP; END; ELSIF json_in.is_Array() THEN DECLARE l_array JSON_ARRAY_T := TREAT(json_in AS JSON_ARRAY_T); BEGIN FOR i IN 0 .. l_array.get_size - 1 LOOP IF object_key IS NOT NULL THEN can_str := can_str || '&quot;'||UPPER(object_key)||'&quot;'; END IF; ETA_JSON_SERIALIZE(l_array.get(i), can_str); END LOOP; END; ELSIF json_in.is_Scalar() THEN IF json_in.is_String() THEN can_str := can_str || json_in.to_String(); ELSIF json_in.is_Number() THEN can_str := can_str || '&quot;' || TO_NUMBER(json_in.to_String) || '&quot;'; END IF; END IF; END; </code></pre> <p><strong>Sample Code - PL/SQL Block</strong></p> <pre><code>SET SERVEROUTPUT ON DECLARE can_str VARCHAR2(32767); l_doc CLOB := '{ &quot;issuer&quot;: { &quot;address&quot;: { &quot;branchID&quot;: &quot;1&quot;, &quot;country&quot;: &quot;EG&quot;, &quot;governate&quot;: &quot;Cairo&quot;, &quot;regionCity&quot;: &quot;Nasr City&quot;, &quot;street&quot;: &quot;580 Clementina Key&quot;, &quot;buildingNumber&quot;: &quot;Bldg. 0&quot;, &quot;postalCode&quot;: &quot;68030&quot;, &quot;floor&quot;: &quot;1&quot;, &quot;room&quot;: &quot;123&quot;, &quot;landmark&quot;: &quot;7660 Melody Trail&quot;, &quot;additionalInformation&quot;: &quot;beside Townhall&quot; }, &quot;type&quot;: &quot;B&quot;, &quot;id&quot;: &quot;113317713&quot;, &quot;name&quot;: &quot;Issuer Company&quot; }, &quot;receiver&quot;: { &quot;address&quot;: { &quot;country&quot;: &quot;EG&quot;, &quot;governate&quot;: &quot;Egypt&quot;, &quot;regionCity&quot;: &quot;Mufazat al Ismlyah&quot;, &quot;street&quot;: &quot;580 Clementina Key&quot;, &quot;buildingNumber&quot;: &quot;Bldg. 0&quot;, &quot;postalCode&quot;: &quot;68030&quot;, &quot;floor&quot;: &quot;1&quot;, &quot;room&quot;: &quot;123&quot;, &quot;landmark&quot;: &quot;7660 Melody Trail&quot;, &quot;additionalInformation&quot;: &quot;beside Townhall&quot; }, &quot;type&quot;: &quot;B&quot;, &quot;id&quot;: &quot;313717919&quot;, &quot;name&quot;: &quot;Receiver&quot; }, &quot;documentType&quot;: &quot;I&quot;, &quot;documentTypeVersion&quot;: &quot;0.9&quot;, &quot;dateTimeIssued&quot;: &quot;2020-10-27T23:59:59Z&quot;, &quot;taxpayerActivityCode&quot;: &quot;4620&quot;, &quot;internalID&quot;: &quot;IID1&quot;, &quot;purchaseOrderReference&quot;: &quot;P-233-A6375&quot;, &quot;purchaseOrderDescription&quot;: &quot;purchase Order description&quot;, &quot;salesOrderReference&quot;: &quot;1231&quot;, &quot;salesOrderDescription&quot;: &quot;Sales Order description&quot;, &quot;proformaInvoiceNumber&quot;: &quot;SomeValue&quot;, &quot;payment&quot;: { &quot;bankName&quot;: &quot;SomeValue&quot;, &quot;bankAddress&quot;: &quot;SomeValue&quot;, &quot;bankAccountNo&quot;: &quot;SomeValue&quot;, &quot;bankAccountIBAN&quot;: &quot;&quot;, &quot;swiftCode&quot;: &quot;&quot;, &quot;terms&quot;: &quot;SomeValue&quot; }, &quot;delivery&quot;: { &quot;approach&quot;: &quot;SomeValue&quot;, &quot;packaging&quot;: &quot;SomeValue&quot;, &quot;dateValidity&quot;: &quot;2020-09-28T09:30:10Z&quot;, &quot;exportPort&quot;: &quot;SomeValue&quot;, &quot;countryOfOrigin&quot;: &quot;EG&quot;, &quot;grossWeight&quot;: 10.50, &quot;netWeight&quot;: 20.50, &quot;terms&quot;: &quot;SomeValue&quot; }, &quot;invoiceLines&quot;: [ { &quot;description&quot;: &quot;Computer1&quot;, &quot;itemType&quot;: &quot;GPC&quot;, &quot;itemCode&quot;: &quot;10001774&quot;, &quot;unitType&quot;: &quot;EA&quot;, &quot;quantity&quot;: 5, &quot;internalCode&quot;: &quot;IC0&quot;, &quot;salesTotal&quot;: 947.00, &quot;total&quot;: 2969.89, &quot;valueDifference&quot;: 7.00, &quot;totalTaxableFees&quot;: 817.42, &quot;netTotal&quot;: 880.71, &quot;itemsDiscount&quot;: 5.00, &quot;unitValue&quot;: { &quot;currencySold&quot;: &quot;EUR&quot;, &quot;amountEGP&quot;: 189.40, &quot;amountSold&quot;: 10.00, &quot;currencyExchangeRate&quot;: 18.94 }, &quot;discount&quot;: { &quot;rate&quot;: 7, &quot;amount&quot;: 66.29 }, &quot;taxableItems&quot;: [ { &quot;taxType&quot;: &quot;T1&quot;, &quot;amount&quot;: 272.07, &quot;subType&quot;: &quot;T1&quot;, &quot;rate&quot;: 14.00 }, { &quot;taxType&quot;: &quot;T2&quot;, &quot;amount&quot;: 208.22, &quot;subType&quot;: &quot;T2&quot;, &quot;rate&quot;: 12 }, { &quot;taxType&quot;: &quot;T3&quot;, &quot;amount&quot;: 30.00, &quot;subType&quot;: &quot;T3&quot;, &quot;rate&quot;: 0.00 }, { &quot;taxType&quot;: &quot;T4&quot;, &quot;amount&quot;: 43.79, &quot;subType&quot;: &quot;T4&quot;, &quot;rate&quot;: 5.00 }, { &quot;taxType&quot;: &quot;T5&quot;, &quot;amount&quot;: 123.30, &quot;subType&quot;: &quot;T5&quot;, &quot;rate&quot;: 14.00 }, { &quot;taxType&quot;: &quot;T6&quot;, &quot;amount&quot;: 60.00, &quot;subType&quot;: &quot;T6&quot;, &quot;rate&quot;: 0.00 }, { &quot;taxType&quot;: &quot;T7&quot;, &quot;amount&quot;: 88.07, &quot;subType&quot;: &quot;T7&quot;, &quot;rate&quot;: 10.00 }, { &quot;taxType&quot;: &quot;T8&quot;, &quot;amount&quot;: 123.30, &quot;subType&quot;: &quot;T8&quot;, &quot;rate&quot;: 14.00 }, { &quot;taxType&quot;: &quot;T9&quot;, &quot;amount&quot;: 105.69, &quot;subType&quot;: &quot;T9&quot;, &quot;rate&quot;: 12.00 }, { &quot;taxType&quot;: &quot;T10&quot;, &quot;amount&quot;: 88.07, &quot;subType&quot;: &quot;T10&quot;, &quot;rate&quot;: 10.00 }, { &quot;taxType&quot;: &quot;T11&quot;, &quot;amount&quot;: 123.30, &quot;subType&quot;: &quot;T11&quot;, &quot;rate&quot;: 14.00 }, { &quot;taxType&quot;: &quot;T12&quot;, &quot;amount&quot;: 105.69, &quot;subType&quot;: &quot;T12&quot;, &quot;rate&quot;: 12.00 }, { &quot;taxType&quot;: &quot;T13&quot;, &quot;amount&quot;: 88.07, &quot;subType&quot;: &quot;T13&quot;, &quot;rate&quot;: 10.00 }, { &quot;taxType&quot;: &quot;T14&quot;, &quot;amount&quot;: 123.30, &quot;subType&quot;: &quot;T14&quot;, &quot;rate&quot;: 14.00 }, { &quot;taxType&quot;: &quot;T15&quot;, &quot;amount&quot;: 105.69, &quot;subType&quot;: &quot;T15&quot;, &quot;rate&quot;: 12.00 }, { &quot;taxType&quot;: &quot;T16&quot;, &quot;amount&quot;: 88.07, &quot;subType&quot;: &quot;T16&quot;, &quot;rate&quot;: 10.00 }, { &quot;taxType&quot;: &quot;T17&quot;, &quot;amount&quot;: 88.07, &quot;subType&quot;: &quot;T17&quot;, &quot;rate&quot;: 10.00 }, { &quot;taxType&quot;: &quot;T18&quot;, &quot;amount&quot;: 123.30, &quot;subType&quot;: &quot;T18&quot;, &quot;rate&quot;: 14.00 }, { &quot;taxType&quot;: &quot;T19&quot;, &quot;amount&quot;: 105.69, &quot;subType&quot;: &quot;T19&quot;, &quot;rate&quot;: 12.00 }, { &quot;taxType&quot;: &quot;T20&quot;, &quot;amount&quot;: 88.07, &quot;subType&quot;: &quot;T20&quot;, &quot;rate&quot;: 10.00 } ] }, { &quot;description&quot;: &quot;Computer2&quot;, &quot;itemType&quot;: &quot;GPC&quot;, &quot;itemCode&quot;: &quot;10003752&quot;, &quot;unitType&quot;: &quot;EA&quot;, &quot;quantity&quot;: 7, &quot;internalCode&quot;: &quot;IC0&quot;, &quot;salesTotal&quot;: 662.90, &quot;total&quot;: 2226.61, &quot;valueDifference&quot;: 6.00, &quot;totalTaxableFees&quot;: 621.51, &quot;netTotal&quot;: 652.90, &quot;itemsDiscount&quot;: 9.00, &quot;unitValue&quot;: { &quot;currencySold&quot;: &quot;EUR&quot;, &quot;amountEGP&quot;: 94.70, &quot;amountSold&quot;: 5.00, &quot;currencyExchangeRate&quot;: 18.94 }, &quot;discount&quot;: { &quot;rate&quot;: 0, &quot;amount&quot;: 10.00 }, &quot;taxableItems&quot;: [ { &quot;taxType&quot;: &quot;T1&quot;, &quot;amount&quot;: 205.47, &quot;subType&quot;: &quot;T1&quot;, &quot;rate&quot;: 14.00 }, { &quot;taxType&quot;: &quot;T2&quot;, &quot;amount&quot;: 157.25, &quot;subType&quot;: &quot;T2&quot;, &quot;rate&quot;: 12 }, { &quot;taxType&quot;: &quot;T3&quot;, &quot;amount&quot;: 30.00, &quot;subType&quot;: &quot;T3&quot;, &quot;rate&quot;: 0.00 }, { &quot;taxType&quot;: &quot;T4&quot;, &quot;amount&quot;: 32.20, &quot;subType&quot;: &quot;T4&quot;, &quot;rate&quot;: 5.00 }, { &quot;taxType&quot;: &quot;T5&quot;, &quot;amount&quot;: 91.41, &quot;subType&quot;: &quot;T5&quot;, &quot;rate&quot;: 14.00 }, { &quot;taxType&quot;: &quot;T6&quot;, &quot;amount&quot;: 60.00, &quot;subType&quot;: &quot;T6&quot;, &quot;rate&quot;: 0.00 }, { &quot;taxType&quot;: &quot;T7&quot;, &quot;amount&quot;: 65.29, &quot;subType&quot;: &quot;T7&quot;, &quot;rate&quot;: 10.00 }, { &quot;taxType&quot;: &quot;T8&quot;, &quot;amount&quot;: 91.41, &quot;subType&quot;: &quot;T8&quot;, &quot;rate&quot;: 14.00 }, { &quot;taxType&quot;: &quot;T9&quot;, &quot;amount&quot;: 78.35, &quot;subType&quot;: &quot;T9&quot;, &quot;rate&quot;: 12.00 }, { &quot;taxType&quot;: &quot;T10&quot;, &quot;amount&quot;: 65.29, &quot;subType&quot;: &quot;T10&quot;, &quot;rate&quot;: 10.00 }, { &quot;taxType&quot;: &quot;T11&quot;, &quot;amount&quot;: 91.41, &quot;subType&quot;: &quot;T11&quot;, &quot;rate&quot;: 14.00 }, { &quot;taxType&quot;: &quot;T12&quot;, &quot;amount&quot;: 78.35, &quot;subType&quot;: &quot;T12&quot;, &quot;rate&quot;: 12.00 }, { &quot;taxType&quot;: &quot;T13&quot;, &quot;amount&quot;: 65.29, &quot;subType&quot;: &quot;T13&quot;, &quot;rate&quot;: 10.00 }, { &quot;taxType&quot;: &quot;T14&quot;, &quot;amount&quot;: 91.41, &quot;subType&quot;: &quot;T14&quot;, &quot;rate&quot;: 14.00 }, { &quot;taxType&quot;: &quot;T15&quot;, &quot;amount&quot;: 78.35, &quot;subType&quot;: &quot;T15&quot;, &quot;rate&quot;: 12.00 }, { &quot;taxType&quot;: &quot;T16&quot;, &quot;amount&quot;: 65.29, &quot;subType&quot;: &quot;T16&quot;, &quot;rate&quot;: 10.00 }, { &quot;taxType&quot;: &quot;T17&quot;, &quot;amount&quot;: 65.29, &quot;subType&quot;: &quot;T17&quot;, &quot;rate&quot;: 10.00 }, { &quot;taxType&quot;: &quot;T18&quot;, &quot;amount&quot;: 91.41, &quot;subType&quot;: &quot;T18&quot;, &quot;rate&quot;: 14.00 }, { &quot;taxType&quot;: &quot;T19&quot;, &quot;amount&quot;: 78.35, &quot;subType&quot;: &quot;T19&quot;, &quot;rate&quot;: 12.00 }, { &quot;taxType&quot;: &quot;T20&quot;, &quot;amount&quot;: 65.29, &quot;subType&quot;: &quot;T20&quot;, &quot;rate&quot;: 10.00 } ] } ], &quot;totalDiscountAmount&quot;: 76.29, &quot;totalSalesAmount&quot;: 1609.90, &quot;netAmount&quot;: 1533.61, &quot;taxTotals&quot;: [ { &quot;taxType&quot;: &quot;T1&quot;, &quot;amount&quot;: 477.54 }, { &quot;taxType&quot;: &quot;T2&quot;, &quot;amount&quot;: 365.47 }, { &quot;taxType&quot;: &quot;T3&quot;, &quot;amount&quot;: 60.00 }, { &quot;taxType&quot;: &quot;T4&quot;, &quot;amount&quot;: 75.99 }, { &quot;taxType&quot;: &quot;T5&quot;, &quot;amount&quot;: 214.71 }, { &quot;taxType&quot;: &quot;T6&quot;, &quot;amount&quot;: 120.00 }, { &quot;taxType&quot;: &quot;T7&quot;, &quot;amount&quot;: 153.36 }, { &quot;taxType&quot;: &quot;T8&quot;, &quot;amount&quot;: 214.71 }, { &quot;taxType&quot;: &quot;T9&quot;, &quot;amount&quot;: 184.04 }, { &quot;taxType&quot;: &quot;T10&quot;, &quot;amount&quot;: 153.36 }, { &quot;taxType&quot;: &quot;T11&quot;, &quot;amount&quot;: 214.71 }, { &quot;taxType&quot;: &quot;T12&quot;, &quot;amount&quot;: 184.04 }, { &quot;taxType&quot;: &quot;T13&quot;, &quot;amount&quot;: 153.36 }, { &quot;taxType&quot;: &quot;T14&quot;, &quot;amount&quot;: 214.71 }, { &quot;taxType&quot;: &quot;T15&quot;, &quot;amount&quot;: 184.04 }, { &quot;taxType&quot;: &quot;T16&quot;, &quot;amount&quot;: 153.36 }, { &quot;taxType&quot;: &quot;T17&quot;, &quot;amount&quot;: 153.36 }, { &quot;taxType&quot;: &quot;T18&quot;, &quot;amount&quot;: 214.71 }, { &quot;taxType&quot;: &quot;T19&quot;, &quot;amount&quot;: 184.04 }, { &quot;taxType&quot;: &quot;T20&quot;, &quot;amount&quot;: 153.36 } ], &quot;totalAmount&quot;: 5191.50, &quot;extraDiscountAmount&quot;: 5.00, &quot;totalItemsDiscountAmount&quot;: 14.00 }'; BEGIN ETA_JSON_SERIALIZE(JSON_ELEMENT_T.parse( l_doc ), can_str); DBMS_OUTPUT.PUT_LINE(can_str); END; / </code></pre> <p><strong>Output</strong></p> <pre> "ISSUER""ADDRESS""BRANCHID""1""COUNTRY""EG""GOVERNATE""Cairo""REGIONCITY""Nasr City""STREET""580 Clementina Key""BUILDINGNUMBER""Bldg. 0""POSTALCODE""68030""FLOOR""1""ROOM""123""LANDMARK""7660 Melody Trail""ADDITIONALINFORMATION""beside Townhall""TYPE""B""ID""113317713""NAME""Issuer Company""RECEIVER""ADDRESS""COUNTRY""EG""GOVERNATE""Egypt""REGIONCITY""Mufazat al Ismlyah""STREET""580 Clementina Key""BUILDINGNUMBER""Bldg. 0""POSTALCODE""68030""FLOOR""1""ROOM""123""LANDMARK""7660 Melody Trail""ADDITIONALINFORMATION""beside Townhall""TYPE""B""ID""313717919""NAME""Receiver""DOCUMENTTYPE""I""DOCUMENTTYPEVERSION""0.9""DATETIMEISSUED""2020-10-27T23:59:59Z""TAXPAYERACTIVITYCODE""4620""INTERNALID""IID1""PURCHASEORDERREFERENCE""P-233-A6375""PURCHASEORDERDESCRIPTION""purchase Order description""SALESORDERREFERENCE""1231""SALESORDERDESCRIPTION""Sales Order description""PROFORMAINVOICENUMBER""SomeValue""PAYMENT""BANKNAME""SomeValue""BANKADDRESS""SomeValue""BANKACCOUNTNO""SomeValue""BANKACCOUNTIBAN""""SWIFTCODE""""TERMS""SomeValue""DELIVERY""APPROACH""SomeValue""PACKAGING""SomeValue""DATEVALIDITY""2020-09-28T09:30:10Z""EXPORTPORT""SomeValue""COUNTRYOFORIGIN""EG""GROSSWEIGHT""10.5""NETWEIGHT""20.5""TERMS""SomeValue""INVOICELINES""INVOICELINES""DESCRIPTION""Computer1""ITEMTYPE""GPC""ITEMCODE""10001774""UNITTYPE""EA""QUANTITY""5""INTERNALCODE""IC0""SALESTOTAL""947""TOTAL""2969.89""VALUEDIFFERENCE""7""TOTALTAXABLEFEES""817.42""NETTOTAL""880.71""ITEMSDISCOUNT""5""UNITVALUE""CURRENCYSOLD""EUR""AMOUNTEGP""189.4""AMOUNTSOLD""10""CURRENCYEXCHANGERATE""18.94""DISCOUNT""RATE""7""AMOUNT""66.29""TAXABLEITEMS""TAXABLEITEMS""TAXTYPE""T1""AMOUNT""272.07""SUBTYPE""T1""RATE""14""TAXABLEITEMS""TAXTYPE""T2""AMOUNT""208.22""SUBTYPE""T2""RATE""12""TAXABLEITEMS""TAXTYPE""T3""AMOUNT""30""SUBTYPE""T3""RATE""0""TAXABLEITEMS""TAXTYPE""T4""AMOUNT""43.79""SUBTYPE""T4""RATE""5""TAXABLEITEMS""TAXTYPE""T5""AMOUNT""123.3""SUBTYPE""T5""RATE""14""TAXABLEITEMS""TAXTYPE""T6""AMOUNT""60""SUBTYPE""T6""RATE""0""TAXABLEITEMS""TAXTYPE""T7""AMOUNT""88.07""SUBTYPE""T7""RATE""10""TAXABLEITEMS""TAXTYPE""T8""AMOUNT""123.3""SUBTYPE""T8""RATE""14""TAXABLEITEMS""TAXTYPE""T9""AMOUNT""105.69""SUBTYPE""T9""RATE""12""TAXABLEITEMS""TAXTYPE""T10""AMOUNT""88.07""SUBTYPE""T10""RATE""10""TAXABLEITEMS""TAXTYPE""T11""AMOUNT""123.3""SUBTYPE""T11""RATE""14""TAXABLEITEMS""TAXTYPE""T12""AMOUNT""105.69""SUBTYPE""T12""RATE""12""TAXABLEITEMS""TAXTYPE""T13""AMOUNT""88.07""SUBTYPE""T13""RATE""10""TAXABLEITEMS""TAXTYPE""T14""AMOUNT""123.3""SUBTYPE""T14""RATE""14""TAXABLEITEMS""TAXTYPE""T15""AMOUNT""105.69""SUBTYPE""T15""RATE""12""TAXABLEITEMS""TAXTYPE""T16""AMOUNT""88.07""SUBTYPE""T16""RATE""10""TAXABLEITEMS""TAXTYPE""T17""AMOUNT""88.07""SUBTYPE""T17""RATE""10""TAXABLEITEMS""TAXTYPE""T18""AMOUNT""123.3""SUBTYPE""T18""RATE""14""TAXABLEITEMS""TAXTYPE""T19""AMOUNT""105.69""SUBTYPE""T19""RATE""12""TAXABLEITEMS""TAXTYPE""T20""AMOUNT""88.07""SUBTYPE""T20""RATE""10""INVOICELINES""DESCRIPTION""Computer2""ITEMTYPE""GPC""ITEMCODE""10003752""UNITTYPE""EA""QUANTITY""7""INTERNALCODE""IC0""SALESTOTAL""662.9""TOTAL""2226.61""VALUEDIFFERENCE""6""TOTALTAXABLEFEES""621.51""NETTOTAL""652.9""ITEMSDISCOUNT""9""UNITVALUE""CURRENCYSOLD""EUR""AMOUNTEGP""94.7""AMOUNTSOLD""5""CURRENCYEXCHANGERATE""18.94""DISCOUNT""RATE""0""AMOUNT""10""TAXABLEITEMS""TAXABLEITEMS""TAXTYPE""T1""AMOUNT""205.47""SUBTYPE""T1""RATE""14""TAXABLEITEMS""TAXTYPE""T2""AMOUNT""157.25""SUBTYPE""T2""RATE""12""TAXABLEITEMS""TAXTYPE""T3""AMOUNT""30""SUBTYPE""T3""RATE""0""TAXABLEITEMS""TAXTYPE""T4""AMOUNT""32.2""SUBTYPE""T4""RATE""5""TAXABLEITEMS""TAXTYPE""T5""AMOUNT""91.41""SUBTYPE""T5""RATE""14""TAXABLEITEMS""TAXTYPE""T6""AMOUNT""60""SUBTYPE""T6""RATE""0""TAXABLEITEMS""TAXTYPE""T7""AMOUNT""65.29""SUBTYPE""T7""RATE""10""TAXABLEITEMS""TAXTYPE""T8""AMOUNT""91.41""SUBTYPE""T8""RATE""14""TAXABLEITEMS""TAXTYPE""T9""AMOUNT""78.35""SUBTYPE""T9""RATE""12""TAXABLEITEMS""TAXTYPE""T10""AMOUNT""65.29""SUBTYPE""T10""RATE""10""TAXABLEITEMS""TAXTYPE""T11""AMOUNT""91.41""SUBTYPE""T11""RATE""14""TAXABLEITEMS""TAXTYPE""T12""AMOUNT""78.35""SUBTYPE""T12""RATE""12""TAXABLEITEMS""TAXTYPE""T13""AMOUNT""65.29""SUBTYPE""T13""RATE""10""TAXABLEITEMS""TAXTYPE""T14""AMOUNT""91.41""SUBTYPE""T14""RATE""14""TAXABLEITEMS""TAXTYPE""T15""AMOUNT""78.35""SUBTYPE""T15""RATE""12""TAXABLEITEMS""TAXTYPE""T16""AMOUNT""65.29""SUBTYPE""T16""RATE""10""TAXABLEITEMS""TAXTYPE""T17""AMOUNT""65.29""SUBTYPE""T17""RATE""10""TAXABLEITEMS""TAXTYPE""T18""AMOUNT""91.41""SUBTYPE""T18""RATE""14""TAXABLEITEMS""TAXTYPE""T19""AMOUNT""78.35""SUBTYPE""T19""RATE""12""TAXABLEITEMS""TAXTYPE""T20""AMOUNT""65.29""SUBTYPE""T20""RATE""10""TOTALDISCOUNTAMOUNT""76.29""TOTALSALESAMOUNT""1609.9""NETAMOUNT""1533.61""TAXTOTALS""TAXTOTALS""TAXTYPE""T1""AMOUNT""477.54""TAXTOTALS""TAXTYPE""T2""AMOUNT""365.47""TAXTOTALS""TAXTYPE""T3""AMOUNT""60""TAXTOTALS""TAXTYPE""T4""AMOUNT""75.99""TAXTOTALS""TAXTYPE""T5""AMOUNT""214.71""TAXTOTALS""TAXTYPE""T6""AMOUNT""120""TAXTOTALS""TAXTYPE""T7""AMOUNT""153.36""TAXTOTALS""TAXTYPE""T8""AMOUNT""214.71""TAXTOTALS""TAXTYPE""T9""AMOUNT""184.04""TAXTOTALS""TAXTYPE""T10""AMOUNT""153.36""TAXTOTALS""TAXTYPE""T11""AMOUNT""214.71""TAXTOTALS""TAXTYPE""T12""AMOUNT""184.04""TAXTOTALS""TAXTYPE""T13""AMOUNT""153.36""TAXTOTALS""TAXTYPE""T14""AMOUNT""214.71""TAXTOTALS""TAXTYPE""T15""AMOUNT""184.04""TAXTOTALS""TAXTYPE""T16""AMOUNT""153.36""TAXTOTALS""TAXTYPE""T17""AMOUNT""153.36""TAXTOTALS""TAXTYPE""T18""AMOUNT""214.71""TAXTOTALS""TAXTYPE""T19""AMOUNT""184.04""TAXTOTALS""TAXTYPE""T20""AMOUNT""153.36""TOTALAMOUNT""5191.5""EXTRADISCOUNTAMOUNT""5""TOTALITEMSDISCOUNTAMOUNT""14" </pre> <p><strong>Output Instances</strong> How to make it reserve the original number format? So &quot;EXTRADISCOUNTAMOUNT&quot;&quot;5.00&quot;<code>instead of</code>&quot;EXTRADISCOUNTAMOUNT&quot;&quot;5&quot;`</p> <p>OR</p> <p><code>&quot;NETWEIGHT&quot;&quot;20.50&quot;</code> instead of <code>&quot;NETWEIGHT&quot;&quot;20.5&quot;</code></p> <p>OR</p> <p><code>&quot;TOTALITEMSDISCOUNTAMOUNT&quot;&quot;14.00&quot;</code> instead of <code>&quot;TOTALITEMSDISCOUNTAMOUNT&quot;&quot;14&quot;</code></p> <p>OR</p> <p><code>&quot;RATE&quot;&quot;0.00&quot;</code> instead of <code>&quot;RATE&quot;&quot;0&quot;</code></p>
[ { "answer_id": 74544072, "author": "MT0", "author_id": 1509264, "author_profile": "https://Stackoverflow.com/users/1509264", "pm_score": 1, "selected": false, "text": "JSON_ELEMENT_T MEMBER FUNCTION to_String RETURN VARCHAR2\nMEMBER FUNCTION to_Number RETURN NUMBER\nMEMBER FUNCTION to_Date RETURN DATE\nMEMBER FUNCTION to_Timestamp RETURN TIMESTAMP\nMEMBER FUNCTION to_Boolean RETURN BOOLEAN\nMEMBER FUNCTION to_Clob RETURN CLOB\nMEMBER FUNCTION to_Blob RETURN BLOB\n\nMEMBER PROCEDURE to_Clob(c IN OUT CLOB)\nMEMBER PROCEDURE to_Blob(c IN OUT BLOB)\n NUMBER NUMBER NUMBER can_str := can_str || '\"' || TO_CHAR(json_in.to_Number(), 'FM9999990D00') || '\"';\n" }, { "answer_id": 74580673, "author": "AAB", "author_id": 20605152, "author_profile": "https://Stackoverflow.com/users/20605152", "pm_score": 0, "selected": false, "text": "ELSIF json_in.is_Scalar() THEN\nIF json_in.is_String() THEN\n can_str := can_str || json_in.to_String();\nELSIF json_in.is_Number() THEN\ncan_str := can_str ||'\"'|| json_in.to_String()||'\"';\nEND IF;\nEND IF;\n `create or replace PROCEDURE ETA_JSON_SERIALIZE (\n json_in IN JSON_ELEMENT_T,\n can_str IN OUT VARCHAR2,\n object_key IN VARCHAR2 DEFAULT NULL\n)\nIS\nBEGIN\n IF json_in.is_Object() THEN\n DECLARE\n l_object JSON_OBJECT_T := TREAT(json_in AS JSON_OBJECT_T);\n l_keys JSON_KEY_LIST := l_object.get_Keys();\n BEGIN\n FOR i IN 1 .. l_keys.COUNT LOOP\n can_str := can_str || '\"'||UPPER(l_keys(i))||'\"';\n ETA_JSON_SERIALIZE(l_object.get(l_keys(i)), can_str, \nl_keys(i));\n END LOOP;\n END;\n ELSIF json_in.is_Array() THEN\n DECLARE\n l_array JSON_ARRAY_T := TREAT(json_in AS JSON_ARRAY_T);\n BEGIN\n FOR i IN 0 .. l_array.get_size - 1 LOOP\n IF object_key IS NOT NULL THEN\n can_str := can_str || '\"'||UPPER(object_key)||'\"';\n END IF;\n ETA_JSON_SERIALIZE(l_array.get(i), can_str);\n END LOOP;\n END;\n \n ELSIF json_in.is_Scalar() THEN\n IF json_in.is_String() THEN\n can_str := can_str || json_in.to_String();\n ELSIF json_in.is_Number() THEN\n \n can_str := can_str ||'\"'|| json_in.to_String()||'\"';\n \nEND IF;\nEND IF;` \n \"ISSUER\"\"ADDRESS\"\"BRANCHID\"\"1\"\"COUNTRY\"\"EG\"\"GOVERNATE\"\"Cairo\"\"REGIONCITY\"\"Nasr City\"\"STREET\"\"580 Clementina Key\"\"BUILDINGNUMBER\"\"Bldg. 0\"\"POSTALCODE\"\"68030\"\"FLOOR\"\"1\"\"ROOM\"\"123\"\"LANDMARK\"\"7660 Melody Trail\"\"ADDITIONALINFORMATION\"\"beside Townhall\"\"TYPE\"\"B\"\"ID\"\"113317713\"\"NAME\"\"Issuer Company\"\"RECEIVER\"\"ADDRESS\"\"COUNTRY\"\"EG\"\"GOVERNATE\"\"Egypt\"\"REGIONCITY\"\"Mufazat al Ismlyah\"\"STREET\"\"580 Clementina Key\"\"BUILDINGNUMBER\"\"Bldg. 0\"\"POSTALCODE\"\"68030\"\"FLOOR\"\"1\"\"ROOM\"\"123\"\"LANDMARK\"\"7660 Melody Trail\"\"ADDITIONALINFORMATION\"\"beside Townhall\"\"TYPE\"\"B\"\"ID\"\"313717919\"\"NAME\"\"Receiver\"\"DOCUMENTTYPE\"\"I\"\"DOCUMENTTYPEVERSION\"\"0.9\"\"DATETIMEISSUED\"\"2020-10-27T23:59:59Z\"\"TAXPAYERACTIVITYCODE\"\"4620\"\"INTERNALID\"\"IID1\"\"PURCHASEORDERREFERENCE\"\"P-233-A6375\"\"PURCHASEORDERDESCRIPTION\"\"purchase Order description\"\"SALESORDERREFERENCE\"\"1231\"\"SALESORDERDESCRIPTION\"\"Sales Order description\"\"PROFORMAINVOICENUMBER\"\"SomeValue\"\"PAYMENT\"\"BANKNAME\"\"SomeValue\"\"BANKADDRESS\"\"SomeValue\"\"BANKACCOUNTNO\"\"SomeValue\"\"BANKACCOUNTIBAN\"\"\"\"SWIFTCODE\"\"\"\"TERMS\"\"SomeValue\"\"DELIVERY\"\"APPROACH\"\"SomeValue\"\"PACKAGING\"\"SomeValue\"\"DATEVALIDITY\"\"2020-09-28T09:30:10Z\"\"EXPORTPORT\"\"SomeValue\"\"COUNTRYOFORIGIN\"\"EG\"\"GROSSWEIGHT\"\"10.50\"\"NETWEIGHT\"\"20.50\"\"TERMS\"\"SomeValue\"\"INVOICELINES\"\"INVOICELINES\"\"DESCRIPTION\"\"Computer1\"\"ITEMTYPE\"\"GPC\"\"ITEMCODE\"\"10001774\"\"UNITTYPE\"\"EA\"\"QUANTITY\"\"5\"\"INTERNALCODE\"\"IC0\"\"SALESTOTAL\"\"947.00\"\"TOTAL\"\"2969.89\"\"VALUEDIFFERENCE\"\"7.00\"\"TOTALTAXABLEFEES\"\"817.42\"\"NETTOTAL\"\"880.71\"\"ITEMSDISCOUNT\"\"5.00\"\"UNITVALUE\"\"CURRENCYSOLD\"\"EUR\"\"AMOUNTEGP\"\"189.40\"\"AMOUNTSOLD\"\"10.00\"\"CURRENCYEXCHANGERATE\"\"18.94\"\"DISCOUNT\"\"RATE\"\"7\"\"AMOUNT\"\"66.29\"\"TAXABLEITEMS\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T1\"\"AMOUNT\"\"272.07\"\"SUBTYPE\"\"T1\"\"RATE\"\"14.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T2\"\"AMOUNT\"\"208.22\"\"SUBTYPE\"\"T2\"\"RATE\"\"12\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T3\"\"AMOUNT\"\"30.00\"\"SUBTYPE\"\"T3\"\"RATE\"\"0.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T4\"\"AMOUNT\"\"43.79\"\"SUBTYPE\"\"T4\"\"RATE\"\"5.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T5\"\"AMOUNT\"\"123.30\"\"SUBTYPE\"\"T5\"\"RATE\"\"14.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T6\"\"AMOUNT\"\"60.00\"\"SUBTYPE\"\"T6\"\"RATE\"\"0.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T7\"\"AMOUNT\"\"88.07\"\"SUBTYPE\"\"T7\"\"RATE\"\"10.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T8\"\"AMOUNT\"\"123.30\"\"SUBTYPE\"\"T8\"\"RATE\"\"14.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T9\"\"AMOUNT\"\"105.69\"\"SUBTYPE\"\"T9\"\"RATE\"\"12.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T10\"\"AMOUNT\"\"88.07\"\"SUBTYPE\"\"T10\"\"RATE\"\"10.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T11\"\"AMOUNT\"\"123.30\"\"SUBTYPE\"\"T11\"\"RATE\"\"14.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T12\"\"AMOUNT\"\"105.69\"\"SUBTYPE\"\"T12\"\"RATE\"\"12.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T13\"\"AMOUNT\"\"88.07\"\"SUBTYPE\"\"T13\"\"RATE\"\"10.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T14\"\"AMOUNT\"\"123.30\"\"SUBTYPE\"\"T14\"\"RATE\"\"14.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T15\"\"AMOUNT\"\"105.69\"\"SUBTYPE\"\"T15\"\"RATE\"\"12.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T16\"\"AMOUNT\"\"88.07\"\"SUBTYPE\"\"T16\"\"RATE\"\"10.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T17\"\"AMOUNT\"\"88.07\"\"SUBTYPE\"\"T17\"\"RATE\"\"10.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T18\"\"AMOUNT\"\"123.30\"\"SUBTYPE\"\"T18\"\"RATE\"\"14.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T19\"\"AMOUNT\"\"105.69\"\"SUBTYPE\"\"T19\"\"RATE\"\"12.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T20\"\"AMOUNT\"\"88.07\"\"SUBTYPE\"\"T20\"\"RATE\"\"10.00\"\"INVOICELINES\"\"DESCRIPTION\"\"Computer2\"\"ITEMTYPE\"\"GPC\"\"ITEMCODE\"\"10003752\"\"UNITTYPE\"\"EA\"\"QUANTITY\"\"7\"\"INTERNALCODE\"\"IC0\"\"SALESTOTAL\"\"662.90\"\"TOTAL\"\"2226.61\"\"VALUEDIFFERENCE\"\"6.00\"\"TOTALTAXABLEFEES\"\"621.51\"\"NETTOTAL\"\"652.90\"\"ITEMSDISCOUNT\"\"9.00\"\"UNITVALUE\"\"CURRENCYSOLD\"\"EUR\"\"AMOUNTEGP\"\"94.70\"\"AMOUNTSOLD\"\"5.00\"\"CURRENCYEXCHANGERATE\"\"18.94\"\"DISCOUNT\"\"RATE\"\"0\"\"AMOUNT\"\"10.00\"\"TAXABLEITEMS\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T1\"\"AMOUNT\"\"205.47\"\"SUBTYPE\"\"T1\"\"RATE\"\"14.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T2\"\"AMOUNT\"\"157.25\"\"SUBTYPE\"\"T2\"\"RATE\"\"12\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T3\"\"AMOUNT\"\"30.00\"\"SUBTYPE\"\"T3\"\"RATE\"\"0.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T4\"\"AMOUNT\"\"32.20\"\"SUBTYPE\"\"T4\"\"RATE\"\"5.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T5\"\"AMOUNT\"\"91.41\"\"SUBTYPE\"\"T5\"\"RATE\"\"14.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T6\"\"AMOUNT\"\"60.00\"\"SUBTYPE\"\"T6\"\"RATE\"\"0.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T7\"\"AMOUNT\"\"65.29\"\"SUBTYPE\"\"T7\"\"RATE\"\"10.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T8\"\"AMOUNT\"\"91.41\"\"SUBTYPE\"\"T8\"\"RATE\"\"14.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T9\"\"AMOUNT\"\"78.35\"\"SUBTYPE\"\"T9\"\"RATE\"\"12.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T10\"\"AMOUNT\"\"65.29\"\"SUBTYPE\"\"T10\"\"RATE\"\"10.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T11\"\"AMOUNT\"\"91.41\"\"SUBTYPE\"\"T11\"\"RATE\"\"14.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T12\"\"AMOUNT\"\"78.35\"\"SUBTYPE\"\"T12\"\"RATE\"\"12.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T13\"\"AMOUNT\"\"65.29\"\"SUBTYPE\"\"T13\"\"RATE\"\"10.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T14\"\"AMOUNT\"\"91.41\"\"SUBTYPE\"\"T14\"\"RATE\"\"14.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T15\"\"AMOUNT\"\"78.35\"\"SUBTYPE\"\"T15\"\"RATE\"\"12.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T16\"\"AMOUNT\"\"65.29\"\"SUBTYPE\"\"T16\"\"RATE\"\"10.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T17\"\"AMOUNT\"\"65.29\"\"SUBTYPE\"\"T17\"\"RATE\"\"10.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T18\"\"AMOUNT\"\"91.41\"\"SUBTYPE\"\"T18\"\"RATE\"\"14.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T19\"\"AMOUNT\"\"78.35\"\"SUBTYPE\"\"T19\"\"RATE\"\"12.00\"\"TAXABLEITEMS\"\"TAXTYPE\"\"T20\"\"AMOUNT\"\"65.29\"\"SUBTYPE\"\"T20\"\"RATE\"\"10.00\"\"TOTALDISCOUNTAMOUNT\"\"76.29\"\"TOTALSALESAMOUNT\"\"1609.90\"\"NETAMOUNT\"\"1533.61\"\"TAXTOTALS\"\"TAXTOTALS\"\"TAXTYPE\"\"T1\"\"AMOUNT\"\"477.54\"\"TAXTOTALS\"\"TAXTYPE\"\"T2\"\"AMOUNT\"\"365.47\"\"TAXTOTALS\"\"TAXTYPE\"\"T3\"\"AMOUNT\"\"60.00\"\"TAXTOTALS\"\"TAXTYPE\"\"T4\"\"AMOUNT\"\"75.99\"\"TAXTOTALS\"\"TAXTYPE\"\"T5\"\"AMOUNT\"\"214.71\"\"TAXTOTALS\"\"TAXTYPE\"\"T6\"\"AMOUNT\"\"120.00\"\"TAXTOTALS\"\"TAXTYPE\"\"T7\"\"AMOUNT\"\"153.36\"\"TAXTOTALS\"\"TAXTYPE\"\"T8\"\"AMOUNT\"\"214.71\"\"TAXTOTALS\"\"TAXTYPE\"\"T9\"\"AMOUNT\"\"184.04\"\"TAXTOTALS\"\"TAXTYPE\"\"T10\"\"AMOUNT\"\"153.36\"\"TAXTOTALS\"\"TAXTYPE\"\"T11\"\"AMOUNT\"\"214.71\"\"TAXTOTALS\"\"TAXTYPE\"\"T12\"\"AMOUNT\"\"184.04\"\"TAXTOTALS\"\"TAXTYPE\"\"T13\"\"AMOUNT\"\"153.36\"\"TAXTOTALS\"\"TAXTYPE\"\"T14\"\"AMOUNT\"\"214.71\"\"TAXTOTALS\"\"TAXTYPE\"\"T15\"\"AMOUNT\"\"184.04\"\"TAXTOTALS\"\"TAXTYPE\"\"T16\"\"AMOUNT\"\"153.36\"\"TAXTOTALS\"\"TAXTYPE\"\"T17\"\"AMOUNT\"\"153.36\"\"TAXTOTALS\"\"TAXTYPE\"\"T18\"\"AMOUNT\"\"214.71\"\"TAXTOTALS\"\"TAXTYPE\"\"T19\"\"AMOUNT\"\"184.04\"\"TAXTOTALS\"\"TAXTYPE\"\"T20\"\"AMOUNT\"\"153.36\"\"TOTALAMOUNT\"\"5191.50\"\"EXTRADISCOUNTAMOUNT\"\"5.00\"\"TOTALITEMSDISCOUNTAMOUNT\"\"14.00\"\n" } ]
2022/11/23
[ "https://Stackoverflow.com/questions/74540352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4793530/" ]
74,540,443
<p>I have a linux script that runs SnowSQL where two files are created and placed in a particular folder. Due to a downstream process, there needs to be a delay between the time the first and second files are placed in the folder. (I prefer not to use two separate ksh scripts.)</p> <p>This creates/places both files in the destination folder at the same time:</p> <p>get ${outFileNm} file://${inDir}/;</p> <p>get ${outFileNm2} file://${inDir}/;</p> <p>====================</p> <p>If SnowSQL supports something like this, I <em>believe</em> the command would be placed here in <strong>bold</strong>:</p> <p>get ${outFileNm} file://${inDir}/;</p> <p><strong>&lt;enter sleep/pause/timeout/wait command here&gt;</strong></p> <p>get ${outFileNm2} file://${inDir}/;</p>
[ { "answer_id": 74540681, "author": "Greg Pavlik", "author_id": 12756381, "author_profile": "https://Stackoverflow.com/users/12756381", "pm_score": 2, "selected": false, "text": "system$wait select system$wait(5);\n" }, { "answer_id": 74622383, "author": "Speedy", "author_id": 13485533, "author_profile": "https://Stackoverflow.com/users/13485533", "pm_score": 1, "selected": true, "text": "call system\\$wait(60);\n" } ]
2022/11/23
[ "https://Stackoverflow.com/questions/74540443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13485533/" ]
74,540,445
<p>I have a string that I am trying to split into 2 strings using Regex to form a list. Below is the string:</p> <p>Input: <code>'TLSD_IBPDEq.'</code></p> <p>Output: <code>['', '']</code></p> <p>Expected Output: <code>['TLSD_IBPD', 'Eq.']</code></p> <p>Below is what I have tried but is not working</p> <pre><code>pattern = r&quot;\S*Eq[\.,]&quot; l = re.split(pattern,&quot;TLSD_IBPDEq.&quot;) print(l) =&gt; ['', ''] </code></pre>
[ { "answer_id": 74540681, "author": "Greg Pavlik", "author_id": 12756381, "author_profile": "https://Stackoverflow.com/users/12756381", "pm_score": 2, "selected": false, "text": "system$wait select system$wait(5);\n" }, { "answer_id": 74622383, "author": "Speedy", "author_id": 13485533, "author_profile": "https://Stackoverflow.com/users/13485533", "pm_score": 1, "selected": true, "text": "call system\\$wait(60);\n" } ]
2022/11/23
[ "https://Stackoverflow.com/questions/74540445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20470119/" ]