qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,408,366
<p>Using this as a reference: <a href="https://airflow.apache.org/docs/apache-airflow/stable/howto/define_extra_link.html" rel="nofollow noreferrer">https://airflow.apache.org/docs/apache-airflow/stable/howto/define_extra_link.html</a></p> <p>I can not get links to show in the UI. I have tried adding the link within the operator itself and building the separate extra_link.py file to add it and the link doesn't show up when looking at the task in graph or grid view. Here is my code for creating it in the operator:</p> <pre><code>class upstream_link(BaseOperatorLink): &quot;&quot;&quot;Create a link to the upstream task&quot;&quot;&quot; name = &quot;Test Link&quot; def get_link(self, operator, *, ti_key): return &quot;https://www.google.com&quot; # Defining the plugin class class AirflowExtraLinkPlugin(AirflowPlugin): name = &quot;integration_links&quot; operator_extra_links = [ upstream_link(), ] class BaseOperator(BaseOperator, SkipMixin, ABC): &quot;&quot;&quot; Base Operator for all integrations &quot;&quot;&quot; operator_extra_links = (upstream_link(),) </code></pre> <p>This is a custom BaseOperator class used by a few operators in my deployment. I don’t know if the inheritance is causing the issue or not. Any help would be greatly appreciated.</p> <p>Also, the goal is to have this on mapped tasks, this does work with mapped tasks right?</p> <p>Edit: Here is the code I used when i tried the stand alone file approach in the plugins folder:</p> <pre><code>from airflow.models.baseoperator import BaseOperatorLink from plugins.operators.integrations.base_operator import BaseOperator from airflow.plugins_manager import AirflowPlugin class upstream_link(BaseOperatorLink): &quot;&quot;&quot;Create a link to the upstream task&quot;&quot;&quot; name = &quot;Upstream Data&quot; operators = [BaseOperator] def get_link(self, operator, *, ti_key): return &quot;https://www.google.com&quot; # Defining the plugin class class AirflowExtraLinkPlugin(AirflowPlugin): name = &quot;extra_link_plugin&quot; operator_extra_links = [ upstream_link(), ] </code></pre>
[ { "answer_id": 74408483, "author": "Denis", "author_id": 14202100, "author_profile": "https://Stackoverflow.com/users/14202100", "pm_score": 0, "selected": false, "text": "modelBuilder.Entity<Customer>" }, { "answer_id": 74439613, "author": "jomsk1e", "author_id": 1638261, "author_profile": "https://Stackoverflow.com/users/1638261", "pm_score": 0, "selected": false, "text": "modelBuilder.Entity<Customer>().ToTable(\"Customer\").Property(e => e.Name).IsRequired();\n" }, { "answer_id": 74492291, "author": "thunderkill", "author_id": 10670947, "author_profile": "https://Stackoverflow.com/users/10670947", "pm_score": 0, "selected": false, "text": "modelBuilder.Entity<Customer>" }, { "answer_id": 74517729, "author": "Matteo Umili", "author_id": 2541809, "author_profile": "https://Stackoverflow.com/users/2541809", "pm_score": 2, "selected": true, "text": "modelBuilder.Entity<Customer>" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14179104/" ]
74,408,393
<p>I am trying to figure out why my image won't add to the WordPress website I am creating. This course came with other images that will display but not the ones I add as a jpg file. I am not sure why it will add the other jpg images but not the ones I want. Here's my code:</p> <pre><code>&lt;?php get_header(); ?&gt; &lt;div class=&quot;page-banner&quot;&gt; &lt;div class=&quot;page-banner__bg-image&quot; style=&quot;background-image: url(&lt;?php echo get_theme_file_uri('images/traffic.jpg') ?&gt;)&quot;&gt;&lt;/div&gt; &lt;div class=&quot;page-banner__content container t-center c-white&quot;&gt; &lt;h1 class=&quot;headline headline--large&quot;&gt;TBS&lt;/h1&gt; &lt;h2 class=&quot;headline headline--medium&quot;&gt;Working to make traffic safer&lt;/h2&gt; &lt;h3 class=&quot;headline headline--small&quot;&gt;Explore constructing, utlities, and other types of work we do&lt;/h3&gt; &lt;a href=&quot;#&quot; class=&quot;btn btn--large btn--blue&quot;&gt;Service &amp; Support&lt;/a&gt; &lt;a href=&quot;#&quot; class=&quot;btn btn--large btn--blue&quot;&gt;Signs&lt;/a&gt; &lt;a href=&quot;#&quot; class=&quot;btn btn--large btn--blue&quot;&gt;Utilities&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I am not sure if I need to add more information to this.</p>
[ { "answer_id": 74408536, "author": "Krunal Bhimajiyani", "author_id": 19587288, "author_profile": "https://Stackoverflow.com/users/19587288", "pm_score": 1, "selected": false, "text": "<div class=\"page-banner\">\n <div class=\"page-banner__bg-image\" style=\"background-image: url(<?php echo\nget_theme_file_uri('images/traffic.jpg'); height:200px;width:100% ?>)\"></div>\n <div class=\"page-banner__content container t-center c-white\">\n <h1 class=\"headline headline--large\">TBS</h1>\n <h2 class=\"headline headline--medium\">Working to make traffic safer</h2>\n <h3 class=\"headline headline--small\">Explore constructing, utlities, and other types of work we do</h3>\n <a href=\"#\" class=\"btn btn--large btn--blue\">Service & Support</a>\n <a href=\"#\" class=\"btn btn--large btn--blue\">Signs</a>\n <a href=\"#\" class=\"btn btn--large btn--blue\">Utilities</a>\n </div>\n </div>\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19265401/" ]
74,408,396
<p>I want to turn a number like 0.1235 to 1235.</p> <p>i tried to do it through a loop by multiplying by 10 but i didnt know how to stop the loop.</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;math.h&gt; #include &lt;stdlib.h&gt; int main (){ double a; printf(&quot;a:&quot;); scanf(&quot;%lf&quot;, &amp;a); while (/* condition */) { a = a*10; } printf(&quot;a: %lf&quot;,a) getch (); return 0; } </code></pre>
[ { "answer_id": 74408536, "author": "Krunal Bhimajiyani", "author_id": 19587288, "author_profile": "https://Stackoverflow.com/users/19587288", "pm_score": 1, "selected": false, "text": "<div class=\"page-banner\">\n <div class=\"page-banner__bg-image\" style=\"background-image: url(<?php echo\nget_theme_file_uri('images/traffic.jpg'); height:200px;width:100% ?>)\"></div>\n <div class=\"page-banner__content container t-center c-white\">\n <h1 class=\"headline headline--large\">TBS</h1>\n <h2 class=\"headline headline--medium\">Working to make traffic safer</h2>\n <h3 class=\"headline headline--small\">Explore constructing, utlities, and other types of work we do</h3>\n <a href=\"#\" class=\"btn btn--large btn--blue\">Service & Support</a>\n <a href=\"#\" class=\"btn btn--large btn--blue\">Signs</a>\n <a href=\"#\" class=\"btn btn--large btn--blue\">Utilities</a>\n </div>\n </div>\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20167462/" ]
74,408,405
<p>I have a c program that comes below:</p> <pre><code>int A[size][size] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; int B[size][size] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; int C[size][size]; int multiplication() { //using array A, B and C here return 0; } </code></pre> <p>I also wrote a startup file by myself and compile them using risc-v compiler by the following command:</p> <pre><code>riscv64-unknown-elf-gcc -ffreestanding -march=rv32im -mabi=ilp32 -nostartfiles -nodefaultlibs -mno-relax crt0.s Myprogram.c -o Myprogram </code></pre> <p>Then using <code>riscv64-unknown-elf-objdump -t Myprogram</code> I can see that arrays <code>A</code> and <code>B</code> are in <code>.data</code> segment and array <code>C</code> is in <code>.bss</code> segment that makes sense.</p> <p>But when I change my code such that I declared arrays <code>A</code> and <code>B</code> as local arrays to the function:</p> <pre><code>int C[size][size]; int multiplication() { int A[size][size] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; int B[size][size] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; //using array A, B and C here return 0; } </code></pre> <p>I got the compilation error: <code>undefined reference to `memcpy'</code>. It seems that it uses <code>memcpy</code> for allocating memory to the arrays while it's not the case when I declared the arrays as global.</p> <p>Does anybody know why and what's the difference?</p>
[ { "answer_id": 74408536, "author": "Krunal Bhimajiyani", "author_id": 19587288, "author_profile": "https://Stackoverflow.com/users/19587288", "pm_score": 1, "selected": false, "text": "<div class=\"page-banner\">\n <div class=\"page-banner__bg-image\" style=\"background-image: url(<?php echo\nget_theme_file_uri('images/traffic.jpg'); height:200px;width:100% ?>)\"></div>\n <div class=\"page-banner__content container t-center c-white\">\n <h1 class=\"headline headline--large\">TBS</h1>\n <h2 class=\"headline headline--medium\">Working to make traffic safer</h2>\n <h3 class=\"headline headline--small\">Explore constructing, utlities, and other types of work we do</h3>\n <a href=\"#\" class=\"btn btn--large btn--blue\">Service & Support</a>\n <a href=\"#\" class=\"btn btn--large btn--blue\">Signs</a>\n <a href=\"#\" class=\"btn btn--large btn--blue\">Utilities</a>\n </div>\n </div>\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9353594/" ]
74,408,416
<p>I'm really new to Ruby. I have the following scenario where - I need to check if a keyword is an array or not in ruby?</p> <p>Something like this -</p> <pre><code>if(value == array) { do something } else do something </code></pre> <p>How can I do so using the if condition in ruby?</p> <p>Any teachings would be really appreciated.</p>
[ { "answer_id": 74408536, "author": "Krunal Bhimajiyani", "author_id": 19587288, "author_profile": "https://Stackoverflow.com/users/19587288", "pm_score": 1, "selected": false, "text": "<div class=\"page-banner\">\n <div class=\"page-banner__bg-image\" style=\"background-image: url(<?php echo\nget_theme_file_uri('images/traffic.jpg'); height:200px;width:100% ?>)\"></div>\n <div class=\"page-banner__content container t-center c-white\">\n <h1 class=\"headline headline--large\">TBS</h1>\n <h2 class=\"headline headline--medium\">Working to make traffic safer</h2>\n <h3 class=\"headline headline--small\">Explore constructing, utlities, and other types of work we do</h3>\n <a href=\"#\" class=\"btn btn--large btn--blue\">Service & Support</a>\n <a href=\"#\" class=\"btn btn--large btn--blue\">Signs</a>\n <a href=\"#\" class=\"btn btn--large btn--blue\">Utilities</a>\n </div>\n </div>\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408416", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20400359/" ]
74,408,424
<p>I'm making an outlined button component and getting the button colors dynamically in hex type by the backend. Whatever color comes, the hover color should be one tone darker than the normal color. I used <code>filter: brightness(85%)</code> for button text color but I can't use it for border color. How can I dynamically make the hover color of the border color one shade darker? By the way, I saw that there are recommendations for using HSL in similar questions, unfortunately it is not possible for me to use HSL at this stage.</p> <p>I'm sharing the snippet below to make it a little more descriptive. In my case, instead of predetermined colors, there are colors that come from the backend as hex code and are kept as css variable.</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>.outlined-button { color: #FF0000; border: 5px solid #FF0000; width: 400px; height: 100px; font-size: 20px; background-color: transparent; transition: all 0.15s linear; cursor: pointer; } .outlined-button:hover { color: #aa2c2c; border: 5px solid #aa2c2c; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;button class="outlined-button"&gt;hi&lt;/button&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74408504, "author": "K i", "author_id": 11196771, "author_profile": "https://Stackoverflow.com/users/11196771", "pm_score": 3, "selected": true, "text": "border" }, { "answer_id": 74408795, "author": "Franco Gabriel", "author_id": 19499461, "author_profile": "https://Stackoverflow.com/users/19499461", "pm_score": 1, "selected": false, "text": "const colorFromAPI = '#0bbeb7'\n\n// The other answer code\nconst pSBC = (p, c0, c1, l) => {\n let r, g, b, P, f, t, h, i = parseInt,\n m = Math.round,\n a = typeof(c1) == \"string\";\n if (typeof(p) != \"number\" || p < -1 || p > 1 || typeof(c0) != \"string\" || (c0[0] != 'r' && c0[0] != '#') || (c1 && !a)) return null;\n if (!this.pSBCr) this.pSBCr = (d) => {\n let n = d.length,\n x = {};\n if (n > 9) {\n [r, g, b, a] = d = d.split(\",\"), n = d.length;\n if (n < 3 || n > 4) return null;\n x.r = i(r[3] == \"a\" ? r.slice(5) : r.slice(4)), x.g = i(g), x.b = i(b), x.a = a ? parseFloat(a) : -1\n } else {\n if (n == 8 || n == 6 || n < 4) return null;\n if (n < 6) d = \"#\" + d[1] + d[1] + d[2] + d[2] + d[3] + d[3] + (n > 4 ? d[4] + d[4] : \"\");\n d = i(d.slice(1), 16);\n if (n == 9 || n == 5) x.r = d >> 24 & 255, x.g = d >> 16 & 255, x.b = d >> 8 & 255, x.a = m((d & 255) / 0.255) / 1000;\n else x.r = d >> 16, x.g = d >> 8 & 255, x.b = d & 255, x.a = -1\n }\n return x\n };\n h = c0.length > 9, h = a ? c1.length > 9 ? true : c1 == \"c\" ? !h : false : h, f = this.pSBCr(c0), P = p < 0, t = c1 && c1 != \"c\" ? this.pSBCr(c1) : P ? {\n r: 0,\n g: 0,\n b: 0,\n a: -1\n } : {\n r: 255,\n g: 255,\n b: 255,\n a: -1\n }, p = P ? p * -1 : p, P = 1 - p;\n if (!f || !t) return null;\n if (l) r = m(P * f.r + p * t.r), g = m(P * f.g + p * t.g), b = m(P * f.b + p * t.b);\n else r = m((P * f.r ** 2 + p * t.r ** 2) ** 0.5), g = m((P * f.g ** 2 + p * t.g ** 2) ** 0.5), b = m((P * f.b ** 2 + p * t.b ** 2) ** 0.5);\n a = f.a, t = t.a, f = a >= 0 || t >= 0, a = f ? a < 0 ? t : t < 0 ? a : a * P + t * p : 0;\n if (h) return \"rgb\" + (f ? \"a(\" : \"(\") + r + \",\" + g + \",\" + b + (f ? \",\" + m(a * 1000) / 1000 : \"\") + \")\";\n else return \"#\" + (4294967296 + r * 16777216 + g * 65536 + b * 256 + (f ? m(a * 255) : 0)).toString(16).slice(1, f ? undefined : -2)\n}\n\n// Calculate new color with above function, negative first argument is for darken\nconst newColor = pSBC(-.50, colorFromAPI);\n\n// We create new CSS to append\nconst newCSS = `\n .outlined-button {\n color: ${colorFromAPI};\n border-color: ${colorFromAPI};\n }\n .outlined-button:hover {\n color: ${newColor};\n border-color: ${newColor};\n }`\n \nconst style = document.createElement('style');\n\nif (style.styleSheet) {\n style.styleSheet.cssText = newCSS;\n} else {\n style.appendChild(document.createTextNode(newCSS));\n}\n\ndocument.getElementsByTagName('head')[0].appendChild(style);" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14044506/" ]
74,408,454
<p>I am trying to create a java program which compares the stored string(meaning password stored) and another string to check password. and also trying to add a number of attempts like 3 in it. am almost done. but am still getting one small logical error. i tried so many changes and adding break statements to my knowledge but still the program isn't becoming perfect. if i change something then another logical error comes. everything works fine but this extra line occurs if i put right pass and right amount which i don't want.&quot;Account is blocked. Contact Bank Manager&quot;. how can i stop getting that. hope you guys will help me!</p> <pre><code>public class Test { int otherBankUserId=345; otherBankUserPass=&quot;suresh&quot;; int otherAcc;String otherPass=null; Scanner sc = new Scanner(System.in); public void checkOtherPass() { System.out.println(&quot;Enter the account&quot;); otherAcc = sc.nextInt(); if(otherAcc==otherBankUserId) { while(passError&lt;3) { System.out.println(&quot;Account number is verified. Enter the password&quot;); otherPass = sc.next(); if(otherPass.equals(otherBankUserPass)) { System.out.println(&quot;logged in successfully&quot;); System.out.println(&quot;Enter the amount:&quot;); int amountSum=sc.nextInt(); System.out.println(amountSum+&quot;Rs withdraw successfully done. Remove the card!&quot;); } else { System.out.println(&quot;wrong password!&quot;); passError=passError+1; System.out.println(&quot;Wrong Entries:&quot;+passError+&quot;\nMax Wrong pass entries:3&quot;); } } System.out.println(&quot;Account is blocked. Contact Bank manager&quot;); } else { System.out.println(&quot;Wrong account number.Do the process again&quot;); } } public static void main(String[] args) { Test t = new Test(); t.checkOtherPass(); } } </code></pre> <pre><code>output: Enter the account 345 Account number is verified. Enter the password suresh logged in successfully Enter the amount: 333 333 withdraw successfully done. Remove the card! Account is blocked. Contact Bank manager </code></pre> <p>Everything works fine but this extra line occurs if i put right pass and right amount which i don't want.&quot;Account is blocked. Contact Bank Manager&quot;. how can i stop getting that</p>
[ { "answer_id": 74408504, "author": "K i", "author_id": 11196771, "author_profile": "https://Stackoverflow.com/users/11196771", "pm_score": 3, "selected": true, "text": "border" }, { "answer_id": 74408795, "author": "Franco Gabriel", "author_id": 19499461, "author_profile": "https://Stackoverflow.com/users/19499461", "pm_score": 1, "selected": false, "text": "const colorFromAPI = '#0bbeb7'\n\n// The other answer code\nconst pSBC = (p, c0, c1, l) => {\n let r, g, b, P, f, t, h, i = parseInt,\n m = Math.round,\n a = typeof(c1) == \"string\";\n if (typeof(p) != \"number\" || p < -1 || p > 1 || typeof(c0) != \"string\" || (c0[0] != 'r' && c0[0] != '#') || (c1 && !a)) return null;\n if (!this.pSBCr) this.pSBCr = (d) => {\n let n = d.length,\n x = {};\n if (n > 9) {\n [r, g, b, a] = d = d.split(\",\"), n = d.length;\n if (n < 3 || n > 4) return null;\n x.r = i(r[3] == \"a\" ? r.slice(5) : r.slice(4)), x.g = i(g), x.b = i(b), x.a = a ? parseFloat(a) : -1\n } else {\n if (n == 8 || n == 6 || n < 4) return null;\n if (n < 6) d = \"#\" + d[1] + d[1] + d[2] + d[2] + d[3] + d[3] + (n > 4 ? d[4] + d[4] : \"\");\n d = i(d.slice(1), 16);\n if (n == 9 || n == 5) x.r = d >> 24 & 255, x.g = d >> 16 & 255, x.b = d >> 8 & 255, x.a = m((d & 255) / 0.255) / 1000;\n else x.r = d >> 16, x.g = d >> 8 & 255, x.b = d & 255, x.a = -1\n }\n return x\n };\n h = c0.length > 9, h = a ? c1.length > 9 ? true : c1 == \"c\" ? !h : false : h, f = this.pSBCr(c0), P = p < 0, t = c1 && c1 != \"c\" ? this.pSBCr(c1) : P ? {\n r: 0,\n g: 0,\n b: 0,\n a: -1\n } : {\n r: 255,\n g: 255,\n b: 255,\n a: -1\n }, p = P ? p * -1 : p, P = 1 - p;\n if (!f || !t) return null;\n if (l) r = m(P * f.r + p * t.r), g = m(P * f.g + p * t.g), b = m(P * f.b + p * t.b);\n else r = m((P * f.r ** 2 + p * t.r ** 2) ** 0.5), g = m((P * f.g ** 2 + p * t.g ** 2) ** 0.5), b = m((P * f.b ** 2 + p * t.b ** 2) ** 0.5);\n a = f.a, t = t.a, f = a >= 0 || t >= 0, a = f ? a < 0 ? t : t < 0 ? a : a * P + t * p : 0;\n if (h) return \"rgb\" + (f ? \"a(\" : \"(\") + r + \",\" + g + \",\" + b + (f ? \",\" + m(a * 1000) / 1000 : \"\") + \")\";\n else return \"#\" + (4294967296 + r * 16777216 + g * 65536 + b * 256 + (f ? m(a * 255) : 0)).toString(16).slice(1, f ? undefined : -2)\n}\n\n// Calculate new color with above function, negative first argument is for darken\nconst newColor = pSBC(-.50, colorFromAPI);\n\n// We create new CSS to append\nconst newCSS = `\n .outlined-button {\n color: ${colorFromAPI};\n border-color: ${colorFromAPI};\n }\n .outlined-button:hover {\n color: ${newColor};\n border-color: ${newColor};\n }`\n \nconst style = document.createElement('style');\n\nif (style.styleSheet) {\n style.styleSheet.cssText = newCSS;\n} else {\n style.appendChild(document.createTextNode(newCSS));\n}\n\ndocument.getElementsByTagName('head')[0].appendChild(style);" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10288727/" ]
74,408,469
<p>Running our spring boot application takes 2-3 minutes to boot. Bulk of the time was spent on connecting to different servers via Spring Cloud Consul Discovery Client.</p> <p>I'm looking for a way to cache service discovery in a separate application like in the following diagram:</p> <pre><code>+----------------------+ +----------------------+ | | | | | Target Server | | Consul Server | | | | | +-----------^----------+ +-----------^----------+ |(3) |(2) | | +----------------------+ +----------------------+ | |(1) | | | Application |---&gt; | Consul Client Cache | | | | | +----------------------+ +----------------------+ </code></pre> <ol> <li>Application queries consul client cache instead consul server directly to retrieve the network address of the target server.</li> <li>Consul Client Cache is a standalone application where it loads and caches the IP addresses of the services registered in consul server.</li> <li>Application connects to target server.</li> </ol> <p>At the top of my mind, I believe this is possible by:</p> <ol> <li>Writing a spring boot application of consul client cache wherein it caches the services registered in consul server and serves them to the application upon request.</li> <li>Intercept the HTTP requests of application and re-route to consul client cache server.</li> </ol> <p>But this seems a generic problem so I'm hoping there is already a ready-made solution out there.</p> <p>Anyone has ideas?</p>
[ { "answer_id": 74408504, "author": "K i", "author_id": 11196771, "author_profile": "https://Stackoverflow.com/users/11196771", "pm_score": 3, "selected": true, "text": "border" }, { "answer_id": 74408795, "author": "Franco Gabriel", "author_id": 19499461, "author_profile": "https://Stackoverflow.com/users/19499461", "pm_score": 1, "selected": false, "text": "const colorFromAPI = '#0bbeb7'\n\n// The other answer code\nconst pSBC = (p, c0, c1, l) => {\n let r, g, b, P, f, t, h, i = parseInt,\n m = Math.round,\n a = typeof(c1) == \"string\";\n if (typeof(p) != \"number\" || p < -1 || p > 1 || typeof(c0) != \"string\" || (c0[0] != 'r' && c0[0] != '#') || (c1 && !a)) return null;\n if (!this.pSBCr) this.pSBCr = (d) => {\n let n = d.length,\n x = {};\n if (n > 9) {\n [r, g, b, a] = d = d.split(\",\"), n = d.length;\n if (n < 3 || n > 4) return null;\n x.r = i(r[3] == \"a\" ? r.slice(5) : r.slice(4)), x.g = i(g), x.b = i(b), x.a = a ? parseFloat(a) : -1\n } else {\n if (n == 8 || n == 6 || n < 4) return null;\n if (n < 6) d = \"#\" + d[1] + d[1] + d[2] + d[2] + d[3] + d[3] + (n > 4 ? d[4] + d[4] : \"\");\n d = i(d.slice(1), 16);\n if (n == 9 || n == 5) x.r = d >> 24 & 255, x.g = d >> 16 & 255, x.b = d >> 8 & 255, x.a = m((d & 255) / 0.255) / 1000;\n else x.r = d >> 16, x.g = d >> 8 & 255, x.b = d & 255, x.a = -1\n }\n return x\n };\n h = c0.length > 9, h = a ? c1.length > 9 ? true : c1 == \"c\" ? !h : false : h, f = this.pSBCr(c0), P = p < 0, t = c1 && c1 != \"c\" ? this.pSBCr(c1) : P ? {\n r: 0,\n g: 0,\n b: 0,\n a: -1\n } : {\n r: 255,\n g: 255,\n b: 255,\n a: -1\n }, p = P ? p * -1 : p, P = 1 - p;\n if (!f || !t) return null;\n if (l) r = m(P * f.r + p * t.r), g = m(P * f.g + p * t.g), b = m(P * f.b + p * t.b);\n else r = m((P * f.r ** 2 + p * t.r ** 2) ** 0.5), g = m((P * f.g ** 2 + p * t.g ** 2) ** 0.5), b = m((P * f.b ** 2 + p * t.b ** 2) ** 0.5);\n a = f.a, t = t.a, f = a >= 0 || t >= 0, a = f ? a < 0 ? t : t < 0 ? a : a * P + t * p : 0;\n if (h) return \"rgb\" + (f ? \"a(\" : \"(\") + r + \",\" + g + \",\" + b + (f ? \",\" + m(a * 1000) / 1000 : \"\") + \")\";\n else return \"#\" + (4294967296 + r * 16777216 + g * 65536 + b * 256 + (f ? m(a * 255) : 0)).toString(16).slice(1, f ? undefined : -2)\n}\n\n// Calculate new color with above function, negative first argument is for darken\nconst newColor = pSBC(-.50, colorFromAPI);\n\n// We create new CSS to append\nconst newCSS = `\n .outlined-button {\n color: ${colorFromAPI};\n border-color: ${colorFromAPI};\n }\n .outlined-button:hover {\n color: ${newColor};\n border-color: ${newColor};\n }`\n \nconst style = document.createElement('style');\n\nif (style.styleSheet) {\n style.styleSheet.cssText = newCSS;\n} else {\n style.appendChild(document.createTextNode(newCSS));\n}\n\ndocument.getElementsByTagName('head')[0].appendChild(style);" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4535957/" ]
74,408,488
<p>Hi everyone I am revisiting an older project that I haven't toyed with in quite some time.</p> <p>I was trying out vue for the first time and attempted to create an calculator for archery (Kinetic energy/velocity/etc). Didnt want to do a full fledge vue app setup so i just used a cdn link. It was initially completely functional but now that i am checking it out again I see the results are no longer populating when numbers have been added. I have linked a codepen here -&gt; <a href="https://codepen.io/gchis66/pen/ZERKBwd" rel="nofollow noreferrer">https://codepen.io/gchis66/pen/ZERKBwd</a></p> <pre><code>new Vue({ el: &quot;#archery-calculator&quot;, data() { return { IBO:'', drawLength:'', drawWeight:'', arrowWeight:'', additionalWeight:'', arrowLength:'', distanceFromNock:'' } }, computed: { calcVelocity: function(e){ let ibo = this.IBO; let dL = this.drawLength; let dW = this.drawWeight; let aW = this.arrowWeight; let adW = this.additionalWeight; let result = ibo + (dL - 30) * 10 - adW / 3 + Math.min(0,-(aW - (5*dW))/ 3); let truncated = Math.round(result); if (truncated &gt; 0){ return truncated; }else{ return 0; } }, calcKineticEnergy: function(){ let ibo = this.IBO; let dL = this.drawLength; let dW = this.drawWeight; let aW = this.arrowWeight; let adW = this.additionalWeight; let s = ibo + (dL - 30) * 10 - adW / 3 + Math.min(0,-(aW - (5*dW))/ 3); let result = (aW*(s**2))/450800; let truncated = Math.round(result); return truncated; }, calcMomentum: function(){ let ibo = this.IBO; let dL = this.drawLength; let dW = this.drawWeight; let aW = this.arrowWeight; let adW = this.additionalWeight; let velocity = ibo + (dL - 30) * 10 - adW / 3 + Math.min(0,-(aW - (5*dW))/ 3); let momentum = (aW * velocity)/225400; let truncated = momentum.toFixed(2); return truncated; }, calcFoc: function(){ let aL = this.arrowLength; let dN = this.distanceFromNock; let result = ((100 * (dN-(aL/2)))/aL); if (result &gt; 0) { return result.toFixed(1); } else{ return 0; } } } }); </code></pre> <p>I am receiving the error &quot;Vue is not a constructor&quot;. There's probably an obvious issue but I am short on time and decided to ask here since this calculator is live on a website.</p> <p>Any help is greatly appreciated!</p>
[ { "answer_id": 74408504, "author": "K i", "author_id": 11196771, "author_profile": "https://Stackoverflow.com/users/11196771", "pm_score": 3, "selected": true, "text": "border" }, { "answer_id": 74408795, "author": "Franco Gabriel", "author_id": 19499461, "author_profile": "https://Stackoverflow.com/users/19499461", "pm_score": 1, "selected": false, "text": "const colorFromAPI = '#0bbeb7'\n\n// The other answer code\nconst pSBC = (p, c0, c1, l) => {\n let r, g, b, P, f, t, h, i = parseInt,\n m = Math.round,\n a = typeof(c1) == \"string\";\n if (typeof(p) != \"number\" || p < -1 || p > 1 || typeof(c0) != \"string\" || (c0[0] != 'r' && c0[0] != '#') || (c1 && !a)) return null;\n if (!this.pSBCr) this.pSBCr = (d) => {\n let n = d.length,\n x = {};\n if (n > 9) {\n [r, g, b, a] = d = d.split(\",\"), n = d.length;\n if (n < 3 || n > 4) return null;\n x.r = i(r[3] == \"a\" ? r.slice(5) : r.slice(4)), x.g = i(g), x.b = i(b), x.a = a ? parseFloat(a) : -1\n } else {\n if (n == 8 || n == 6 || n < 4) return null;\n if (n < 6) d = \"#\" + d[1] + d[1] + d[2] + d[2] + d[3] + d[3] + (n > 4 ? d[4] + d[4] : \"\");\n d = i(d.slice(1), 16);\n if (n == 9 || n == 5) x.r = d >> 24 & 255, x.g = d >> 16 & 255, x.b = d >> 8 & 255, x.a = m((d & 255) / 0.255) / 1000;\n else x.r = d >> 16, x.g = d >> 8 & 255, x.b = d & 255, x.a = -1\n }\n return x\n };\n h = c0.length > 9, h = a ? c1.length > 9 ? true : c1 == \"c\" ? !h : false : h, f = this.pSBCr(c0), P = p < 0, t = c1 && c1 != \"c\" ? this.pSBCr(c1) : P ? {\n r: 0,\n g: 0,\n b: 0,\n a: -1\n } : {\n r: 255,\n g: 255,\n b: 255,\n a: -1\n }, p = P ? p * -1 : p, P = 1 - p;\n if (!f || !t) return null;\n if (l) r = m(P * f.r + p * t.r), g = m(P * f.g + p * t.g), b = m(P * f.b + p * t.b);\n else r = m((P * f.r ** 2 + p * t.r ** 2) ** 0.5), g = m((P * f.g ** 2 + p * t.g ** 2) ** 0.5), b = m((P * f.b ** 2 + p * t.b ** 2) ** 0.5);\n a = f.a, t = t.a, f = a >= 0 || t >= 0, a = f ? a < 0 ? t : t < 0 ? a : a * P + t * p : 0;\n if (h) return \"rgb\" + (f ? \"a(\" : \"(\") + r + \",\" + g + \",\" + b + (f ? \",\" + m(a * 1000) / 1000 : \"\") + \")\";\n else return \"#\" + (4294967296 + r * 16777216 + g * 65536 + b * 256 + (f ? m(a * 255) : 0)).toString(16).slice(1, f ? undefined : -2)\n}\n\n// Calculate new color with above function, negative first argument is for darken\nconst newColor = pSBC(-.50, colorFromAPI);\n\n// We create new CSS to append\nconst newCSS = `\n .outlined-button {\n color: ${colorFromAPI};\n border-color: ${colorFromAPI};\n }\n .outlined-button:hover {\n color: ${newColor};\n border-color: ${newColor};\n }`\n \nconst style = document.createElement('style');\n\nif (style.styleSheet) {\n style.styleSheet.cssText = newCSS;\n} else {\n style.appendChild(document.createTextNode(newCSS));\n}\n\ndocument.getElementsByTagName('head')[0].appendChild(style);" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9168755/" ]
74,408,501
<p>I need to apply the same join i do in this code, but in another code i build it with Eloquent\Builder $query</p> <p>The join I want is this:</p> <pre><code>$afiliates = DB::table('ad_afiliado as af') -&gt;join('af_promocion as promo', 'af.Clave', '=', 'promo.id_afiliado') -&gt;select('af.logo_url', 'af.NombreComercial', 'af.Destacado', 'af.id_afiliado', 'af.Clave', 'af.DestacadoInicio') -&gt;where('promo.v_fin','&gt;',$FechaActual) -&gt;paginate(9); </code></pre> <p>The Code where I want to put the join is this:</p> <pre><code> $afiliates = AdAfiliado::query() -&gt;where('Activo','=', 'S') -&gt;where(function (\Illuminate\Database\Eloquent\Builder $query) use ($request) { $query-&gt;orWhere('NombreComercial', 'like', &quot;%{$request-&gt;search}%&quot;); $query-&gt;orWhere('Etiqueta', 'like', &quot;%{$request-&gt;search}%&quot;); $query-&gt;orWhere('Categoria', 'like', &quot;{$request-&gt;search}&quot;); }) -&gt;orderBy('CLAVE', $request-&gt;order) -&gt;paginate(9); </code></pre> <p>I appreciate your help!</p>
[ { "answer_id": 74408910, "author": "N69S", "author_id": 4369919, "author_profile": "https://Stackoverflow.com/users/4369919", "pm_score": 0, "selected": false, "text": "whereHas()" }, { "answer_id": 74415717, "author": "Pepe F.", "author_id": 20292715, "author_profile": "https://Stackoverflow.com/users/20292715", "pm_score": -1, "selected": true, "text": "I got solved, as I read in this site:\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20292715/" ]
74,408,509
<p>Pretty new to excel VBA and coding, I wanted to get some support with the following text. I would like to have the following text split into columns. Usually, the data is always in the same format being a TEXT: TEXT Name: John Doe</p> <p>Could someone help me understand how to begin splitting this text into columns? or direct me to a previously answered questions or an online resource. Anything would help</p> <p>thanks,</p> <pre><code>Name: JOHN DOE Date: 13-Jan-2020 Issue: HAL BOARD [2,1,0] Error failed to fill Observation: HAL BOARD [2,1,0] Error failed to fill Action taken: Safe stopped machine, replaced bank inlet filter Product Impact: No, No product impacted, safe stopped Validation Impact : No, repair made to instrument does not impact fit for or function Verification: Repair made to instrument does not impact product as it is before the depense Parts: 1 in line filter Remarks : N/A Name:JOHN Doewr Date: 13-Jan-2020 Issue: HAL BOARD [2,1,0] Error failed to fill Observation: HAL BOARD [2,1,0] Error failed to fill Action taken: Safe stopped machine, replaced bank inlet filter Product Impact: No, No product impacted, safe stopped Validation Impact : No, repair made to instrument does not impact fit for or function Verification: Repair made to instrument does not impact product as it is before the depense Parts: 1 in line filter Remarks : N/A </code></pre>
[ { "answer_id": 74408910, "author": "N69S", "author_id": 4369919, "author_profile": "https://Stackoverflow.com/users/4369919", "pm_score": 0, "selected": false, "text": "whereHas()" }, { "answer_id": 74415717, "author": "Pepe F.", "author_id": 20292715, "author_profile": "https://Stackoverflow.com/users/20292715", "pm_score": -1, "selected": true, "text": "I got solved, as I read in this site:\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6053001/" ]
74,408,527
<p>I am trying to find a way to do the following:</p> <p>Find the string &quot;John&quot; in column &quot;Zone&quot;, then if the previous cell above it with a value (some rows are empty) in &quot;Zone&quot; column was the string &quot;Four&quot;, replace that string with the word &quot;Five&quot;.</p> <p>I could do this with a mutate/lead function but the space between the data is not uniform, and I can't figure out how to count back the required rows.</p> <p>My next thought was I could extract only the rows from the &quot;Zone&quot; column into a new dataframe so that the data was more uniform, and then mutate as required and then merge the data back into the original dataframe. This became too messy and I couldn't make it work either.</p> <p>Can anyone suggest a way to achieve this? Any help would be greatly appreciated.</p> <p>Sample input:</p> <pre><code>structure(list(City = c(&quot;Mumbai&quot;, &quot;Delhi&quot;, &quot;Bangalore&quot;, &quot;Red&quot;, &quot;Hyderabad&quot;, &quot;Ahmedabad&quot;, &quot;Chennai&quot;, &quot;Kolkata&quot;, &quot;Surat&quot;, &quot;Pune&quot;, &quot;Yellow&quot;, &quot;Jaipur&quot;, &quot;Lucknow&quot;, &quot;Kanpur&quot;, &quot;Nagpur&quot;, &quot;Indore&quot;, &quot;Blue&quot;, &quot;Bhopal&quot;, &quot;Pimpri-Chinchwad&quot;, &quot;Patna&quot;, &quot;Vadodara&quot;, &quot;Green&quot; ), Pop = c(&quot;12442373&quot;, &quot;11007835&quot;, &quot;8425970&quot;, &quot;31876178&quot;, &quot;6809970&quot;, &quot;5570585&quot;, &quot;4681087&quot;, &quot;4486679&quot;, &quot;4467797&quot;, &quot;3115431&quot;, &quot;12069907&quot;, &quot;3046163&quot;, &quot;2815601&quot;, &quot;2767031&quot;, &quot;2405665&quot;, &quot;1960631&quot;, &quot;7133327&quot;, &quot;1795648&quot;, &quot;1727692&quot;, &quot;1684222&quot;, &quot;1670806&quot;, &quot;5082720&quot;), Zone = c(&quot;One&quot;, &quot;&quot;, &quot;&quot;, &quot;Tony&quot;, &quot;Two&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;John&quot;, &quot;Three&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;Mary&quot;, &quot;Four&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;John&quot;), Test = c(&quot;Yes&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;No&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;Yes&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;No&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;)), row.names = 1:22, class = &quot;data.frame&quot;) </code></pre> <p>Desired output</p> <pre><code>structure(list(City = c(&quot;Mumbai&quot;, &quot;Delhi&quot;, &quot;Bangalore&quot;, &quot;Red&quot;, &quot;Hyderabad&quot;, &quot;Ahmedabad&quot;, &quot;Chennai&quot;, &quot;Kolkata&quot;, &quot;Surat&quot;, &quot;Pune&quot;, &quot;Yellow&quot;, &quot;Jaipur&quot;, &quot;Lucknow&quot;, &quot;Kanpur&quot;, &quot;Nagpur&quot;, &quot;Indore&quot;, &quot;Blue&quot;, &quot;Bhopal&quot;, &quot;Pimpri-Chinchwad&quot;, &quot;Patna&quot;, &quot;Vadodara&quot;, &quot;Green&quot; ), Pop = c(&quot;12442373&quot;, &quot;11007835&quot;, &quot;8425970&quot;, &quot;31876178&quot;, &quot;6809970&quot;, &quot;5570585&quot;, &quot;4681087&quot;, &quot;4486679&quot;, &quot;4467797&quot;, &quot;3115431&quot;, &quot;12069907&quot;, &quot;3046163&quot;, &quot;2815601&quot;, &quot;2767031&quot;, &quot;2405665&quot;, &quot;1960631&quot;, &quot;7133327&quot;, &quot;1795648&quot;, &quot;1727692&quot;, &quot;1684222&quot;, &quot;1670806&quot;, &quot;5082720&quot;), Zone = c(&quot;One&quot;, &quot;&quot;, &quot;&quot;, &quot;Tony&quot;, &quot;Two&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;John&quot;, &quot;Three&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;Mary&quot;, &quot;Five&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;John&quot;), Test = c(&quot;Yes&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;No&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;Yes&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;No&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;)), row.names = 1:22, class = &quot;data.frame&quot;) </code></pre>
[ { "answer_id": 74409176, "author": "alice_hooper", "author_id": 20384402, "author_profile": "https://Stackoverflow.com/users/20384402", "pm_score": 0, "selected": false, "text": "test = filter(input, Zone != \"\")\nanswer <- test %>%\n mutate(Zone1 = if_else(lead(Zone, default = first(Zone)) == \"John\", \"Five\", Zone))\nanswer = answer %>% dplyr::mutate(Zone = ifelse(Zone != \"Four\", Zone, Zone1))\noutput = left_join(input, answer ,by=c('City'='City', 'Pop'='Pop', 'Test' = 'Test'))\noutput = output[c(\"City\",\"Pop\",\"Zone.y\",\"Test\")]\noutput[is.na(output)] <- \"\"\ncolnames(output) = colnames(input)\n" }, { "answer_id": 74409229, "author": "AndS.", "author_id": 9778513, "author_profile": "https://Stackoverflow.com/users/9778513", "pm_score": 2, "selected": true, "text": "Zone" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20384402/" ]
74,408,557
<p>I've spent the whole day trying to find a solution for showing the images in the template but I couldn't find any solution to my case.</p> <p>This is my settings</p> <pre><code>STATIC_URL = '/static/' MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'DataCallGuide/static') ] </code></pre> <p>My model</p> <pre><code>class TroubleshootingSteps(models.Model): box_header = models.CharField(blank=True, null=True, max_length=250) box_content = models.CharField(blank=True, null=True, max_length=250) box_botton = models.CharField(blank=True, null=True, max_length=250) header = models.TextField(blank=True, null=True) sub_header = models.TextField(blank=True, null=True) text1 = models.TextField(blank=True, null=True) image1 = models.ImageField(blank=True, null=True, upload_to=&quot;images/&quot;) </code></pre> <p>and the template</p> <pre><code>{% extends 'base.html' %} {% load static %} {% block content %} &lt;div class=&quot;container overflow-hidden&quot;&gt; &lt;div class=&quot;text-center&quot;&gt; &lt;h4 class=&quot;mt-5 mb-5&quot;&gt;{{data.header}}&lt;/h4&gt; &lt;/div&gt; &lt;h3 dir=&quot;rtl&quot; class=&quot;rtlss&quot;&gt;{{data.sub_header}}&lt;/h3&gt; &lt;img src=&quot;{{ data.image1.url }}&quot;&gt; &lt;/div&gt; {% endblock%} </code></pre> <p>Also when I click on the image link in admin pages it doesn't show the image and display page not found error with the below link <code>http://127.0.0.1:8000/media/images/IMG-20220901-WA0009.jpg</code> What is wrong please?</p>
[ { "answer_id": 74408619, "author": "saro", "author_id": 18366396, "author_profile": "https://Stackoverflow.com/users/18366396", "pm_score": 0, "selected": false, "text": "urlpatterns = [\n Your urls\n] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)\n" }, { "answer_id": 74410487, "author": "Manoj Tolagekar", "author_id": 17808039, "author_profile": "https://Stackoverflow.com/users/17808039", "pm_score": 0, "selected": false, "text": " <img src=\"{{ data.image1.url }}\">\n" }, { "answer_id": 74411475, "author": "Mahammadhusain kadiwala", "author_id": 19205926, "author_profile": "https://Stackoverflow.com/users/19205926", "pm_score": 2, "selected": true, "text": "# do comment static root path\n\nSTATIC_ROOT = os.path.join(BASE_DIR, 'static')\n\n# add static dirs path like this\n\nSTATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]\n\n#----------- OR ---------------\n\nSTATICFILES_DIRS = [BASE_DIR / 'static']\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10987656/" ]
74,408,612
<p>I am trying to change the text in a column by removing a word in all rows.</p> <p>For example, if a row contained &quot;second row&quot;, I want to replace it with &quot;second&quot;. Here is an example dataset</p> <pre><code>df &lt;- data.frame(row_num = c(1,2,3,4,5), text_long = c(&quot;first row&quot;, &quot;second row&quot;, &quot;third row&quot;, &quot;fourth row&quot;, &quot;fifth row&quot;)) &gt; df # row_num text_long #1 1 first row #2 2 second row #3 3 third row #4 4 fourth row #5 5 fifth row </code></pre> <p>How do I create a new column called &quot;text_short&quot; where the word row is removed from each of the text_long values?</p> <p>I tried using the following function with <code>mutate()</code> in the <code>dplyr</code> package</p> <pre><code>library(dplyr) shorten_text &lt;- function(x) { return(unlist(strsplit(x, split=' '))[1]) } df &lt;- mutate(df, text_short = shorten_text(df$text_long)) </code></pre> <p>But every row of text_short contains the same value:</p> <pre><code>&gt;df # row_num text_long text_short #1 1 first row first #2 2 second row first #3 3 third row first #4 4 fourth row first #5 5 fifth row first </code></pre>
[ { "answer_id": 74408619, "author": "saro", "author_id": 18366396, "author_profile": "https://Stackoverflow.com/users/18366396", "pm_score": 0, "selected": false, "text": "urlpatterns = [\n Your urls\n] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)\n" }, { "answer_id": 74410487, "author": "Manoj Tolagekar", "author_id": 17808039, "author_profile": "https://Stackoverflow.com/users/17808039", "pm_score": 0, "selected": false, "text": " <img src=\"{{ data.image1.url }}\">\n" }, { "answer_id": 74411475, "author": "Mahammadhusain kadiwala", "author_id": 19205926, "author_profile": "https://Stackoverflow.com/users/19205926", "pm_score": 2, "selected": true, "text": "# do comment static root path\n\nSTATIC_ROOT = os.path.join(BASE_DIR, 'static')\n\n# add static dirs path like this\n\nSTATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]\n\n#----------- OR ---------------\n\nSTATICFILES_DIRS = [BASE_DIR / 'static']\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1112097/" ]
74,408,661
<p>First of all I am new to Laravel framework, so please bear with me. I am creating an e-commerce website and created a registration page. The problem is whenever I fill the registration form and press register button the page will refresh but the data I filled will not be updated in MySQL database.</p> <p>the registration file. <strong>registration.blade.php</strong> `</p> <pre><code>@extends('layouts.master') @section('content') @section('title', 'Register') &lt;section class=&quot;login-page&quot;&gt; &lt;div class=&quot;login-form-box&quot;&gt; &lt;div class=&quot;login-title&quot;&gt; Register&lt;/div&gt; &lt;div class=&quot;login-form&quot;&gt; &lt;form action=&quot;{{route('register')}}&quot; method=&quot;post&quot;&gt; @csrf &lt;div class=&quot;field&quot;&gt; &lt;label for=&quot;name&quot;&gt;name&lt;/label&gt; &lt;input type=&quot;text&quot; id=&quot;name&quot; name=&quot;name&quot; placeholder=&quot;john&quot; &gt; &lt;/div&gt; &lt;div class=&quot;field&quot;&gt; &lt;label for=&quot;email&quot;&gt;email&lt;/label&gt; &lt;input type=&quot;email&quot; id=&quot;email&quot; name=&quot;name&quot; placeholder=&quot;john@gmail.com&quot; &gt; &lt;/div&gt; &lt;div class=&quot;field&quot;&gt; &lt;label for=&quot;password&quot;&gt;password&lt;/label&gt; &lt;input type=&quot;password&quot; id=&quot;password&quot; name=&quot;password&quot; placeholder=&quot;******&quot; &gt; &lt;/div&gt; &lt;div class=&quot;field&quot;&gt; &lt;label for=&quot;passowrd_confirmation&quot;&gt;confirm password&lt;/label&gt; &lt;input type=&quot;password&quot; id=&quot;password&quot; name=&quot;passowrd_confirmation&quot; placeholder=&quot;******&quot; &gt; &lt;/div&gt; &lt;div class=&quot;field&quot;&gt; &lt;button type= &quot;submit&quot; class=&quot;btn btn-primary btn-block&quot;&gt;Register&lt;/button&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/section&gt; @endsection </code></pre> <p>` Also, here the route file in laravel</p> <p><strong>web.php</strong></p> <pre><code>&lt;?php use App\Http\Controllers\AuthController; use App\Http\Controllers\PagesController; use Illuminate\Support\Facades\Route; /* |-------------------------------------------------------------------------- | Web Routes |-------------------------------------------------------------------------- | | Here is where you can register web routes for your application. These | routes are loaded by the RouteServiceProvider within a group which | contains the &quot;web&quot; middleware group. Now create something great! | */ Route::get('/', [PagesController::class, 'home'])-&gt;name('home'); Route::get('/cart', [PagesController::class, 'cart'])-&gt;name('cart'); //Auth Route::get('/login', [AuthController::class, 'showLogin'])-&gt;name('login'); Route::get('/register', [AuthController::class, 'showRegister'])-&gt;name('register'); Route::post('/register', [AuthController::class, 'postRegister'])-&gt;name('register'); </code></pre> <p>And here is the file for registration functions <strong>AuthController.php</strong> `</p> <pre><code>&lt;?php namespace App\Http\Controllers; use App\Models\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; class AuthController extends Controller { //show login page public function showLogin() { return view('pages.login'); } //show register page public function showRegister() { return view('pages.register'); } //register user public function postRegister(Request $request) { //validation $request-&gt;validate([ 'name' =&gt; 'required|min:3|max:255', 'email' =&gt; 'required|email|max:255|unique:users', 'password' =&gt; 'required|min:8|confirmed' ]); //registration $user = User::create([ 'name' =&gt; $request-&gt;name, 'email' =&gt; $request-&gt;email, 'password' =&gt; Hash::make($request-&gt;password), ]); //login user Auth::login($user); return back()-&gt;with('success','succesfully Logged in'); } } </code></pre> <p>` here is my Database in phpmyadmin after filling the form: <a href="https://i.stack.imgur.com/6IyBY.png" rel="nofollow noreferrer">users database</a> I tried to use showRegister function in my AuthController.php in order to check if the data being filled can be seen in the webpage. However, I was not able to see anything.</p>
[ { "answer_id": 74408619, "author": "saro", "author_id": 18366396, "author_profile": "https://Stackoverflow.com/users/18366396", "pm_score": 0, "selected": false, "text": "urlpatterns = [\n Your urls\n] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)\n" }, { "answer_id": 74410487, "author": "Manoj Tolagekar", "author_id": 17808039, "author_profile": "https://Stackoverflow.com/users/17808039", "pm_score": 0, "selected": false, "text": " <img src=\"{{ data.image1.url }}\">\n" }, { "answer_id": 74411475, "author": "Mahammadhusain kadiwala", "author_id": 19205926, "author_profile": "https://Stackoverflow.com/users/19205926", "pm_score": 2, "selected": true, "text": "# do comment static root path\n\nSTATIC_ROOT = os.path.join(BASE_DIR, 'static')\n\n# add static dirs path like this\n\nSTATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]\n\n#----------- OR ---------------\n\nSTATICFILES_DIRS = [BASE_DIR / 'static']\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20254214/" ]
74,408,677
<p>I am trying to get the user's name from a form input and display it on the page in the form of a greeting &quot;Hello (user)&quot;. I have already got the solution to do it in 2 separate HTML files but I need to do it all in one file using query string and onload options.</p> <p>Thanks for your help!</p> <p><strong>firstpage.html</strong></p> <pre><code>&lt;input type=&quot;text&quot; id=&quot;titletxt&quot;&gt; &lt;button onclick=&quot;Submit()&quot;&gt;Submit&lt;/button&gt; &lt;script&gt; function Submit() { let name = document.getElementById(&quot;txtname&quot;).value; window.location.href = &quot;secondpage.html?&quot; + name; } &lt;/script&gt; </code></pre> <p><strong>secondpage.html</strong></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Test&lt;/title&gt; &lt;script&gt; function loadTitle() { let queryString = window.location.search.split('?')[1]; document.write(&quot;&lt;h2&gt;Hello &quot;+queryString+&quot;&lt;/h2&gt;&quot;) document.title = &quot;hello &quot;+queryString; } &lt;/script&gt; &lt;/head&gt; &lt;body onload=&quot;loadTitle()&quot;&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
[ { "answer_id": 74408619, "author": "saro", "author_id": 18366396, "author_profile": "https://Stackoverflow.com/users/18366396", "pm_score": 0, "selected": false, "text": "urlpatterns = [\n Your urls\n] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)\n" }, { "answer_id": 74410487, "author": "Manoj Tolagekar", "author_id": 17808039, "author_profile": "https://Stackoverflow.com/users/17808039", "pm_score": 0, "selected": false, "text": " <img src=\"{{ data.image1.url }}\">\n" }, { "answer_id": 74411475, "author": "Mahammadhusain kadiwala", "author_id": 19205926, "author_profile": "https://Stackoverflow.com/users/19205926", "pm_score": 2, "selected": true, "text": "# do comment static root path\n\nSTATIC_ROOT = os.path.join(BASE_DIR, 'static')\n\n# add static dirs path like this\n\nSTATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]\n\n#----------- OR ---------------\n\nSTATICFILES_DIRS = [BASE_DIR / 'static']\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20481542/" ]
74,408,699
<p>I currently have a list with the following filenames [file1, file2] I want to read each files by iterating through the list and read the contents of the file into dictionary</p> <p>So I am trying to create dictionary with key and value as :</p> <p>thisisdict={ &quot;file1&quot; : &quot;abcdefgh&quot;, &quot;file2&quot; :&quot; defssfifj&quot;}</p> <p>I am able to read and store values of each individuals files but unsure when multiple filenames are to iterated and opened and read.</p>
[ { "answer_id": 74408619, "author": "saro", "author_id": 18366396, "author_profile": "https://Stackoverflow.com/users/18366396", "pm_score": 0, "selected": false, "text": "urlpatterns = [\n Your urls\n] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)\n" }, { "answer_id": 74410487, "author": "Manoj Tolagekar", "author_id": 17808039, "author_profile": "https://Stackoverflow.com/users/17808039", "pm_score": 0, "selected": false, "text": " <img src=\"{{ data.image1.url }}\">\n" }, { "answer_id": 74411475, "author": "Mahammadhusain kadiwala", "author_id": 19205926, "author_profile": "https://Stackoverflow.com/users/19205926", "pm_score": 2, "selected": true, "text": "# do comment static root path\n\nSTATIC_ROOT = os.path.join(BASE_DIR, 'static')\n\n# add static dirs path like this\n\nSTATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]\n\n#----------- OR ---------------\n\nSTATICFILES_DIRS = [BASE_DIR / 'static']\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20443396/" ]
74,408,735
<p>I'm looking for a way to redirect any url that start with <code>/D/</code> to the same URL with lowercased <code>/d/</code>.</p> <p><code>/D/&lt;anything_including_url_params&gt;</code></p> <p>to</p> <p><code>/d/&lt;anything_including_url_params&gt;</code></p> <p>I literally only want to redirect urls that start with <code>/D/</code> - not <code>/DABC/</code> etc...</p> <p>The suffix can also be empty, eg. <code>/D/</code> &gt; <code>/d/</code></p> <p>Is there a way to do that in Django? It is for a third-party app with urls included in projects urls.</p> <p>The alternative is to use <code>re_path</code> and change:</p> <pre><code>path(&quot;d/&quot;, include(...)) </code></pre> <p>to</p> <pre><code>re_path(r&quot;^[dD]/$&quot;, include(...)) </code></pre> <p>but I'd rather do a redirect instead of this.</p>
[ { "answer_id": 74408800, "author": "Swift", "author_id": 8874154, "author_profile": "https://Stackoverflow.com/users/8874154", "pm_score": 0, "selected": false, "text": "/D/" }, { "answer_id": 74415898, "author": "Willem Van Onsem", "author_id": 67579, "author_profile": "https://Stackoverflow.com/users/67579", "pm_score": 3, "selected": true, "text": "# some_app/urls.py\n\nfrom django.views.generic import RedirectView\n\n# …\n\nurlpatterns = [\n path('d/', include(…)),\n path(\n 'D/<path:path>',\n RedirectView.as_view(\n url='/d/%(path)s', query_string=True, permanent=True\n ),\n ),\n]" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2607447/" ]
74,408,773
<p>I'm able to call function from DLL created in C (.c file), but i can't do it from DLL created in C++ (.cpp file). I want to find out why it doesn't work in .cpp file.</p> <p>I'm trying to call function <code>printword()</code> from a simple DLL, created with Visual Studio 2022:</p> <pre><code>// FILE: dllmain.cpp BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; } __declspec(dllexport) void printword() { std::cout &lt;&lt; &quot;word&quot; &lt;&lt; std::endl; //with printf() doesn't work too } </code></pre> <p>And when i call function the way like this:</p> <pre><code>int main() { HMODULE dll; if ((dll = LoadLibrary(L&quot;D:\\Visual Studio projects\\Dll1\\x64\\Debug\\Dll1.dll&quot;)) == NULL) { return GetLastError(); } FARPROC func; if ((func = GetProcAddress(dll, &quot;printword&quot;)) == NULL) { return GetLastError(); } func(); return 0; } </code></pre> <p><code>GetProcAddress</code> throws error <code>ERROR_PROC_NOT_FOUND</code></p> <p>But if i create DLL in file with <code>.c</code> suffix <code>printword()</code> function calls correctly (with same code above):</p> <pre><code>// FILE: dllmain.c BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; } __declspec(dllexport) void printword() { printf(&quot;word\n&quot;); } </code></pre>
[ { "answer_id": 74408800, "author": "Swift", "author_id": 8874154, "author_profile": "https://Stackoverflow.com/users/8874154", "pm_score": 0, "selected": false, "text": "/D/" }, { "answer_id": 74415898, "author": "Willem Van Onsem", "author_id": 67579, "author_profile": "https://Stackoverflow.com/users/67579", "pm_score": 3, "selected": true, "text": "# some_app/urls.py\n\nfrom django.views.generic import RedirectView\n\n# …\n\nurlpatterns = [\n path('d/', include(…)),\n path(\n 'D/<path:path>',\n RedirectView.as_view(\n url='/d/%(path)s', query_string=True, permanent=True\n ),\n ),\n]" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19259079/" ]
74,408,778
<p>i have partial form on my rails project. this form is for nested route(post and comment), and this form only brings me to make new data. the url to edit page works well, but when i get into that edit page, form tag was written like -&gt; posts/1/comment (method: post), which makes me can not update data. my expecting result is -&gt; posts/1/comment/1 (method: put)</p> <p>form for nested route-&gt;</p> <pre><code>&lt;%= form_with model: [post, post.comments.build] do |f| %&gt; &lt;div class=&quot;form-item-box&quot;&gt; &lt;%= f.hidden_field :post_id %&gt; &lt;%= f.label :content %&gt; &lt;%= f.text_field :content %&gt; &lt;% post.comments.build.errors.full_messages_for(:content).each do |error_message| %&gt; &lt;div class=&quot;warning-box&quot;&gt; &lt;%= error_message %&gt; &lt;/div&gt; &lt;% end %&gt; &lt;%= f.submit %&gt; &lt;/div&gt; &lt;% end %&gt; </code></pre> <p>edit page-&gt;</p> <pre><code> &lt;%= render partial: &quot;form&quot;, locals: { post: @post } %&gt; </code></pre> <p>on controller (testing for update method works well, so i did not write it. only the problem is form tag build as post method all time.)</p> <pre><code> def edit @post = Post.find(params[:post_id]) end </code></pre> <p>this edit form link is in post's show page, and i written @post in postcontroller</p> <pre><code> def show @post = Post.find(params[:id]) end </code></pre> <p>routes</p> <pre><code> resources :posts do resources :comments end </code></pre> <p>how can i solve it?</p> <p>partial form build as -&gt; posts/1/comment (method: post) my expecting result is -&gt; posts/1/comment/1 (method: put)</p> <p>i tried change variable for glocal variable, change form for not nested(it works but i thought using nested route is right for this situation)</p>
[ { "answer_id": 74410730, "author": "Alter Lagos", "author_id": 895789, "author_profile": "https://Stackoverflow.com/users/895789", "pm_score": 2, "selected": true, "text": "<%= form_with model: [post, post.comments.build] do |f| %>\n" }, { "answer_id": 74424450, "author": "nicecoding521235", "author_id": 20142639, "author_profile": "https://Stackoverflow.com/users/20142639", "pm_score": 0, "selected": false, "text": "<%= form_with model: [post, comment] do |f| %>\n <div class=\"form-item-box\">\n <%= f.hidden_field :post_id %>\n <%= f.label :content %>\n <%= f.text_field :content %>\n <% comment.errors.full_messages_for(:content).each do |error_message| %>\n <div class=\"warning-box\">\n <%= error_message %>\n </div>\n <% end %>\n <%= f.submit %>\n </div>\n<% end %>\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20142639/" ]
74,408,817
<p>I have been trying to understand why this is not working properly for the past five hours.</p> <p>The question explicitly asks for the use of switch() and no if-else (or of the likes) to count the number of words, lines, and characters in typed up text. And exit the program with Ctrl+D or Ctrl+Z.</p> <p>Here, I deconstructed the counting by figuring different cases of whether the current typed input is whitespace or not, and from thereon, judging by the previous letter, whether it is justified to count it as an extra word, character, and/or line. ( input = punctuation, previous input= character --&gt; add 1 to word count and 1 to character count ; if input = newline and previous input !=whitespace --&gt; add one to line counter + one to word counter, etc.)</p> <p>My code is the following:</p> <pre><code> int main() { int letter = 0, prev_letter = 0, num_char = 0, num_words = 0, num_lines = 0; printf(&quot;User, please provide any text you wish using letters, spaces, tabs, &quot; &quot;and enter. \n When done, enter Ctrl+D or Ctrl+Z on your keyboard.&quot;); while ((letter = getchar()) != 4 &amp;&amp; letter != 26) // In ASCII, Ctrl+D is 4, and Ctrl+Z is 26 { switch (isspace(letter)) { case 0: // False = is not a whitespace { switch ( isalpha(prev_letter)) // checking to see if alphanumeric input or not { case 1: switch (ispunct(letter)) { case 1: num_words++; num_char++; // Punctuation considered as characters in this particular // sub-exercise. break; } break; case 0: num_char++; break; // All other cases are just another character added in this case // 0 (Not whitespace) } } break; case 1: { switch (letter) { case 9: // 9 =Horizontal tab { switch (isspace(prev_letter)) { case 0: num_words++; // Assuming if not whitespace, then punctuation or // character. break; default: break; } } break; case 32: // 32 = Space { switch (isspace(prev_letter)) { case 0: num_words++; // Assuming if not whitespace, then punctuation or // character. break; default: break; } } break; case 13: // 13 = Carriage return { switch (isspace(prev_letter)) { case 0: num_words++; num_lines++; break; default: num_lines++; } } break; case 10: // 13 = Line Feed { switch (isspace(prev_letter)) { case 0: num_words++; num_lines++; break; default: num_lines++; } } break; default: printf(&quot;Test2&quot;); } } break; default: break; } prev_letter = letter; } printf(&quot;Number of characters is: %d. \n&quot;, num_char); printf(&quot;Number of words is: %d. \n&quot;, num_words); printf(&quot;Number of lines is: %d. \n&quot;, num_lines); return 0; }``` It seems like isalpha(), ispunct(), isalnum() are not feeding properly my cases. I have tried breaking it down to individual cases but when inputting text with tabs, spaces, and alphanumeric inputs, it fails to count words, characters, and lines properly. What am I not seeing properly? Any pointers greatly appreciated. </code></pre>
[ { "answer_id": 74410730, "author": "Alter Lagos", "author_id": 895789, "author_profile": "https://Stackoverflow.com/users/895789", "pm_score": 2, "selected": true, "text": "<%= form_with model: [post, post.comments.build] do |f| %>\n" }, { "answer_id": 74424450, "author": "nicecoding521235", "author_id": 20142639, "author_profile": "https://Stackoverflow.com/users/20142639", "pm_score": 0, "selected": false, "text": "<%= form_with model: [post, comment] do |f| %>\n <div class=\"form-item-box\">\n <%= f.hidden_field :post_id %>\n <%= f.label :content %>\n <%= f.text_field :content %>\n <% comment.errors.full_messages_for(:content).each do |error_message| %>\n <div class=\"warning-box\">\n <%= error_message %>\n </div>\n <% end %>\n <%= f.submit %>\n </div>\n<% end %>\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20480864/" ]
74,408,864
<p>I have this Body Component set:</p> <pre><code>import 'bootstrap/dist/css/bootstrap.css'; import {Container} from &quot;react-bootstrap&quot;; import Navigation from './Navigation' import axios from 'axios' import {useState,useEffect} from &quot;react&quot;; function Body() { const [searchItems, setSearchItems] = useState([{}]) useEffect(() =&gt; { console.log(searchItems) }, []) return ( &lt;Container&gt; &lt;Navigation setSearchItems={setSearchItems}/&gt; &lt;/Container&gt; ); } export default Body; </code></pre> <p>And here is my Navigation Component with an Inputfield as anther component named SearchInput. As you can see I pass the setSearchItems from the start to each child, because I want to use the searchItems-Array to display some data later:</p> <pre><code>import Navbar from 'react-bootstrap/Navbar'; import Form from 'react-bootstrap/Form'; import {InputGroup} from &quot;react-bootstrap&quot;; import axios from 'axios'; import {useState, useEffect} from &quot;react&quot;; const api_key = process.env.API_KEY; const SearchInput = (setSearchItems) =&gt; { async function changeHandler(e, setSearchItems) { if (e.target.value.length &gt; 2) { const url = 'https://api.thedogapi.com/v1/breeds/search?q=' + e.target.value const config = { method: 'GET', mode: 'cors', headers: { 'x-api-key': api_key } } const data = await axios.get(url, config) setSearchItems(data['data']) } } return ( &lt;InputGroup style={{ marginLeft: '50px', marginRight: '50px', paddingTop: '10px', paddingBottom: '10px', width: '50%' }}&gt; &lt;Form.Control placeholder=&quot;Enter Dogs Breed&quot; aria-label=&quot;Breed&quot; onChange={(e) =&gt; changeHandler(e, setSearchItems)} /&gt; &lt;/InputGroup&gt; ) } const Navigation = (setSearchInput) =&gt; { return ( &lt;Navbar fixed=&quot;top&quot; bg='light'&gt; &lt;SearchInput setSearchInput={setSearchInput}/&gt; &lt;/Navbar&gt; ) } export default Navigation; </code></pre> <p>everytime I try to call setSearchItems, I get <strong>Uncaught (in promise) TypeError: setSearchItems is not a function</strong></p> <p>I also tried this version of changeHandler before:</p> <pre><code>async function changeHandler(e) { if (e.target.value.length &gt; 2) { const url = 'https://api.thedogapi.com/v1/breeds/search?q=' + e.target.value const config = { method: 'GET', mode: 'cors', headers: { 'x-api-key': api_key } } await axios.get(url, config) .then((response) =&gt; setSearchItems([response.data])) } } </code></pre> <p>but it's an error al the time</p>
[ { "answer_id": 74409098, "author": "Nijat Mursali", "author_id": 10489887, "author_profile": "https://Stackoverflow.com/users/10489887", "pm_score": 2, "selected": true, "text": "Body" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2823842/" ]
74,408,874
<p>I want to do two things :</p> <p><strong>1)</strong></p> <pre><code>char *myStr = &quot;2 1 3 2 5 2 5 4 6 1 6 2 7 1 7 3 7 4 8 1 &quot;; </code></pre> <p>The goal is to have my string to be of this form</p> <pre><code>2 1 3 2 5 2 ... ... </code></pre> <p>And so on until the end of the string.</p> <p><strong>2)</strong> With a string like this, I want to put these values in a 2D array in the form myArr[0][0] = 2, myArr[0][1] = 1, myArr[1][0] = 3, myArr[1][1] = 2, and so on and so forth.</p> <p>I firstly tried with strtok but I think it's not appropriate as the delimiters are not enough for this problem And then by iterating character by character to split but up to this point I don't know how to do that:</p> <pre><code>const char * separator = &quot; &quot; char * strToken = strtok ( out, separator ); while ( strToken != NULL ) { printf ( &quot;%s\n&quot;, strToken); strToken = strtok ( NULL, separator); } </code></pre> <p>what I get :</p> <pre><code>2 1 3 2 5 2 5 4 6 1 6 2 7 1 7 3 7 4 8 1 </code></pre>
[ { "answer_id": 74409426, "author": "John Bayko", "author_id": 11846953, "author_profile": "https://Stackoverflow.com/users/11846953", "pm_score": 1, "selected": false, "text": "char * myStrPtr = myStr;\n\nint myArr[NUM_PAIRS][2];\nint myArrIdx = 0;\n" }, { "answer_id": 74409470, "author": "William Pursell", "author_id": 140750, "author_profile": "https://Stackoverflow.com/users/140750", "pm_score": 0, "selected": false, "text": "strtol" }, { "answer_id": 74409637, "author": "Andreas Wenzel", "author_id": 12149471, "author_profile": "https://Stackoverflow.com/users/12149471", "pm_score": 0, "selected": false, "text": "strtok" }, { "answer_id": 74409779, "author": "etsuhisa", "author_id": 13841016, "author_profile": "https://Stackoverflow.com/users/13841016", "pm_score": 1, "selected": true, "text": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#define NROW 10\n#define NCOL 2\nint main()\n{\n char *myStr = \"2 1 3 2 5 2 5 4 6 1 6 2 7 1 7 3 7 4 8 1 \";\n const char * separator = \" \";\n char * strToken;\n char *out;\n char *end;\n /* 1D array */\n int arrBuf[NROW*NCOL];\n /* 2D array */\n int (*myArr)[NCOL] = (int(*)[NCOL])arrBuf;\n int i;\n out = strdup(myStr);\n /* Store numbers as 1D array */\n strToken = strtok ( out, separator );\n for (i = 0; i < NROW*NCOL && strToken != NULL ; i++) {\n arrBuf[i] = (int)strtol(strToken, &end, 10);\n strToken = strtok ( NULL, separator);\n }\n /* Display numbers as 2D array */\n for (i = 0; i < NROW; i++) {\n printf(\"%d %d\\n\", myArr[i][0], myArr[i][1]);\n }\n free(out);\n return 0;\n}\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19176243/" ]
74,408,887
<p>consider a library module <code>ctx</code></p> <pre><code>xquery version &quot;3.1&quot;; module namespace ctx=&quot;module/ctx&quot;; declare function ctx:resolve ( $ctx as function(xs:string) as xs:QName ) as function(xs:string, xs:integer) as function(*)? { function ($name as xs:string, $arity as xs:integer) as function(*)? { function-lookup($ctx($name), $arity) } }; </code></pre> <p>and a library module <code>a</code></p> <pre><code>xquery version &quot;3.1&quot;; module namespace a=&quot;module/a&quot;; declare function a:f () { &quot;a:f&quot; }; </code></pre> <p>And a main module</p> <pre><code>xquery version &quot;3.1&quot;; import module namespace a=&quot;module/a&quot; at &quot;a.xqm&quot;; import module namespace ctx=&quot;module/ctx&quot; at &quot;ctx.xqm&quot;; ctx:resolve(xs:QName(?))(&quot;a:f&quot;, 0)() </code></pre> <p>Is it safe to assume that the function reference returned by <code>xs:QName(?)</code> will keep the context in which the namespace <code>a</code> is declared so that the main module will output &quot;a:f&quot;?</p> <p>This does work in eXist-db (tested on 5.3.0) but I am not sure if this code is portable to other XQuery 3.1 processors.</p> <p>---- UPDATE ----</p> <p>What does not work in eXist-db 5.3.0 is</p> <pre><code>import module namespace ctx=&quot;module/ctx&quot; at &quot;ctx.xqm&quot;; declare namespace app = &quot;app&quot;; declare function app:f () { &quot;app:f&quot; }; ctx:resolve(xs:QName(?))(&quot;app:f&quot;, 0)() </code></pre>
[ { "answer_id": 74409036, "author": "Dimitre Novatchev", "author_id": 36305, "author_profile": "https://Stackoverflow.com/users/36305", "pm_score": 2, "selected": false, "text": "ctx" }, { "answer_id": 74413508, "author": "Michael Kay", "author_id": 415448, "author_profile": "https://Stackoverflow.com/users/415448", "pm_score": 4, "selected": true, "text": "xs:QName(?)" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408887", "https://Stackoverflow.com", "https://Stackoverflow.com/users/426832/" ]
74,408,906
<p>I noticed that if I try to use EOMONTH on more than one cell at a time on for instance:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th></th> <th>A</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1/1/2022</td> </tr> <tr> <td>2</td> <td>1/2/2022</td> </tr> <tr> <td>3</td> <td>1/3/2022</td> </tr> <tr> <td>4</td> <td>1/4/2022</td> </tr> <tr> <td>5</td> <td>1/5/2022</td> </tr> <tr> <td>6</td> <td>1/6/2022</td> </tr> <tr> <td>7</td> <td>1/7/2022</td> </tr> <tr> <td>8</td> <td>1/8/2022</td> </tr> <tr> <td>9</td> <td>1/9/2022</td> </tr> <tr> <td>10</td> <td>1/10/2022</td> </tr> <tr> <td>11</td> <td>1/11/2022</td> </tr> <tr> <td>12</td> <td>1/12/2022</td> </tr> <tr> <td>13</td> <td>1/13/2022</td> </tr> </tbody> </table> </div> <p>If I use the following formula: <code>=EOMONTH(A1:A13,0)</code></p> <p>I get a #VALUE! Error.</p> <p><a href="https://i.stack.imgur.com/Xt5P1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xt5P1.jpg" alt="enter image description here" /></a></p> <p>If I was to transpose the range (and transpose back to the original state) it works without errors:</p> <p><code>=EOMONTH(TRANSPOSE(TRANSPOSE(A1:A13)),0)</code></p> <p><a href="https://i.stack.imgur.com/oQkxz.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oQkxz.jpg" alt="enter image description here" /></a></p> <p>Could someone explain this behaviour?</p> <p>PS same goes for EDATE()</p>
[ { "answer_id": 74409107, "author": "lisboakotor", "author_id": 16454771, "author_profile": "https://Stackoverflow.com/users/16454771", "pm_score": 2, "selected": true, "text": "=EOMONTH(A1:A13,0)" }, { "answer_id": 74410809, "author": "Jos Woolley", "author_id": 17007704, "author_profile": "https://Stackoverflow.com/users/17007704", "pm_score": 3, "selected": false, "text": "=EOMONTH(+A1:A13,0)" }, { "answer_id": 74473902, "author": "Robert Mearns", "author_id": 5050, "author_profile": "https://Stackoverflow.com/users/5050", "pm_score": 1, "selected": false, "text": "=EOMONTH(--A1:A13,0)\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12634230/" ]
74,408,925
<p>I'm trying to make a function that will delete &quot;negative&quot; responses in a magic 8-ball application. I'm trying to delete any elements of the response array that have the word &quot;no&quot; in them but I don't want to delete responses that include &quot;now&quot; or &quot;not&quot;.</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 responses = [ "It is certain", "It is decidedly so", "Without a doubt", "Yes, definitely", "You may rely on it", "As I see it, yes", "Most likely", "Outlook good", "Yes", "Signs point to yes", "Reply hazy try again", "Ask again later", "Better not tell you now", "Can't predict now", "Concentrate and ask again", "Don't count on it", "My reply is no", "My sources say no", "Outlook not so good", "Very doubtful" ] const negativeResponseDeleter = () =&gt; { let splitTracker = 0 let holdingArray = [] for (i = 0; i &lt; responses.length; i++) { holdingArray = responses[i].split(" ") if (holdingArray.includes("no")) { } } } console.log(negativeResponseDeleter())</code></pre> </div> </div> </p> <p>Above is the code I have so far but I keep running into roadblocks, wondering what the best way to go about this would be.</p>
[ { "answer_id": 74408962, "author": "LeoDog896", "author_id": 7589775, "author_profile": "https://Stackoverflow.com/users/7589775", "pm_score": 1, "selected": false, "text": "words" }, { "answer_id": 74408997, "author": "Andy", "author_id": 1377002, "author_profile": "https://Stackoverflow.com/users/1377002", "pm_score": 0, "selected": false, "text": "\\b" }, { "answer_id": 74409006, "author": "Peter Thoeny", "author_id": 7475450, "author_profile": "https://Stackoverflow.com/users/7475450", "pm_score": 0, "selected": false, "text": "const responses = [\n \"It is certain\",\n \"It is decidedly so\",\n \"Without a doubt\",\n \"Yes, definitely\",\n \"You may rely on it\",\n \"As I see it, yes\",\n \"Most likely\",\n \"Outlook good\",\n \"Yes\",\n \"Signs point to yes\",\n \"Reply hazy try again\",\n \"Ask again later\",\n \"Better not tell you now\",\n \"Can't predict now\",\n \"Concentrate and ask again\",\n \"Don't count on it\",\n \"My reply is no\",\n \"My sources say no\",\n \"Outlook not so good\",\n \"Very doubtful\"\n];\n\nconst negativeResponseDeleter = () => {\n let holdingArray = responses.filter(str => !/\\bno\\b/.test(str));\n console.log(holdingArray)\n}\n\nnegativeResponseDeleter();" }, { "answer_id": 74409411, "author": "eRtuSa", "author_id": 16422168, "author_profile": "https://Stackoverflow.com/users/16422168", "pm_score": 0, "selected": false, "text": "const responses = [\n 'It is certain',\n 'It is decidedly so',\n 'Without a doubt',\n 'Yes, definitely',\n 'You may rely on it',\n 'As I see it, yes',\n 'Most likely',\n 'Outlook good',\n 'Yes',\n 'Signs point to yes',\n 'Reply hazy try again',\n 'Ask again later',\n 'Better not tell you now',\n \"Can't predict now\",\n 'Concentrate and ask again',\n \"Don't count on it\",\n 'My reply is no',\n 'My sources say no',\n 'Outlook not so good',\n 'Very doubtful',\n];\n\nconst output = responses.filter(elem => !/(no)\\b/g.test(elem));\n\nconsole.log(output);" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,408,926
<p>While running a query that selects a Location, date, and visitIDs, I need to be able to select a new combined location name (eg. &quot;LOC3+4&quot;) which includes all the rows from locations &quot;LOC3&quot; and &quot;LOC4&quot;. This new dataset need to have <strong>its own location name</strong> so that I can group the data by Location in an SSRS report.</p> <p><strong>Simplified Query - EDITED to add joins and subqueries-- the combined location that doesn't exist yet</strong>.</p> <pre><code> SELECT subq1.Date, subq1.Location, Count(subq1.VisitID) FROM (SELECT t1.Date, t1.Location, t1.VisitID FROM table t1 LEFT OUTER JOIN table t2 ON t2.VisitID = t1.VisitID LEFT OUTER JOIN table t3 ON t3.ClientID = t2.ClientID (etc) WHERE t1.FacID = FAC1 AND t1.Status = 'Adm') subq1 WHERE subq1.Location = 'LOC1' AND subq1.Room NOT IN ('Room1','Room2',etc....) UNION ALL -- repeat for LOC2-5 UNION ALL (not sure how to do the combined location) </code></pre> <p><strong>Expected Results (includes combined location with expected result)</strong></p> <p><a href="https://i.stack.imgur.com/MVHfH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MVHfH.png" alt="expected data" /></a></p>
[ { "answer_id": 74408962, "author": "LeoDog896", "author_id": 7589775, "author_profile": "https://Stackoverflow.com/users/7589775", "pm_score": 1, "selected": false, "text": "words" }, { "answer_id": 74408997, "author": "Andy", "author_id": 1377002, "author_profile": "https://Stackoverflow.com/users/1377002", "pm_score": 0, "selected": false, "text": "\\b" }, { "answer_id": 74409006, "author": "Peter Thoeny", "author_id": 7475450, "author_profile": "https://Stackoverflow.com/users/7475450", "pm_score": 0, "selected": false, "text": "const responses = [\n \"It is certain\",\n \"It is decidedly so\",\n \"Without a doubt\",\n \"Yes, definitely\",\n \"You may rely on it\",\n \"As I see it, yes\",\n \"Most likely\",\n \"Outlook good\",\n \"Yes\",\n \"Signs point to yes\",\n \"Reply hazy try again\",\n \"Ask again later\",\n \"Better not tell you now\",\n \"Can't predict now\",\n \"Concentrate and ask again\",\n \"Don't count on it\",\n \"My reply is no\",\n \"My sources say no\",\n \"Outlook not so good\",\n \"Very doubtful\"\n];\n\nconst negativeResponseDeleter = () => {\n let holdingArray = responses.filter(str => !/\\bno\\b/.test(str));\n console.log(holdingArray)\n}\n\nnegativeResponseDeleter();" }, { "answer_id": 74409411, "author": "eRtuSa", "author_id": 16422168, "author_profile": "https://Stackoverflow.com/users/16422168", "pm_score": 0, "selected": false, "text": "const responses = [\n 'It is certain',\n 'It is decidedly so',\n 'Without a doubt',\n 'Yes, definitely',\n 'You may rely on it',\n 'As I see it, yes',\n 'Most likely',\n 'Outlook good',\n 'Yes',\n 'Signs point to yes',\n 'Reply hazy try again',\n 'Ask again later',\n 'Better not tell you now',\n \"Can't predict now\",\n 'Concentrate and ask again',\n \"Don't count on it\",\n 'My reply is no',\n 'My sources say no',\n 'Outlook not so good',\n 'Very doubtful',\n];\n\nconst output = responses.filter(elem => !/(no)\\b/g.test(elem));\n\nconsole.log(output);" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3412156/" ]
74,408,952
<p>I am running tests using <code>rails test:models</code> and got this error (though the tests still run)</p> <pre><code>ActiveRecord::NoDatabaseError: We could not find your database: postgres. Which can be found in the database configuration file located at config/database.yml. </code></pre> <p>A database called <code>postgres</code> does not exist because I gave the DB's a different name.</p> <p>My <code>database.yml</code> is :</p> <pre><code># config/database.yml default: &amp;default adapter: postgresql encoding: unicode username: &lt;%= ENV['POSTGRES_USER'] %&gt; password: &lt;%= ENV['POSTGRES_PASSWORD'] %&gt; pool: 5 timeout: 5000 host: &lt;%= ENV['POSTGRES_HOST'] %&gt; development: &lt;&lt;: *default database: &lt;%= ENV['POSTGRES_DB'] %&gt; test: &lt;&lt;: *default database: &lt;%= ENV['POSTGRES_TEST_DB'] %&gt; production: &lt;&lt;: *default database: &lt;%= ENV['POSTGRES_DB'] %&gt; </code></pre> <p>and my respective .env is :</p> <pre><code># ./env POSTGRES_USER='bob' # If you declared a password when creating the database: POSTGRES_HOST='localhost' POSTGRES_DB='database1' POSTGRES_TEST_DB='database1_test' </code></pre> <p>In <code>PSQL</code>, you can also see the <code>test</code> database isn't using the <code>.env</code> value for its owner but the production database is :</p> <pre><code> List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges --------------+---------------+----------+---------+-------+--------------------------------- database1 | bob | UTF8 | C | C | database1_test | bobsurname | UTF8 | C | C | </code></pre>
[ { "answer_id": 74411736, "author": "Lee Drum", "author_id": 17457026, "author_profile": "https://Stackoverflow.com/users/17457026", "pm_score": 1, "selected": false, "text": "database1_test " }, { "answer_id": 74417640, "author": "Chiperific", "author_id": 1880203, "author_profile": "https://Stackoverflow.com/users/1880203", "pm_score": 1, "selected": true, "text": "ENV" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9356904/" ]
74,408,956
<p>Within an Azure Data Factory Pipeline I am attempting to remove an empty directory.</p> <p>The files within the directory were removed by a previous pipelines' iterative operation thus leaving an empty directory to be removed.</p> <p>The directory is a sub-folder: The hierarchy being:</p> <p>container / top-level-folder (always present) / directory - dynamically created - the result of an unzip operation.</p> <p>I have defined a specific dataset that points to</p> <p>container / @concat('top-level-folder/',dataset().dataset_folder)</p> <p>where 'dataset_folder' is the only parameter.</p> <p>The Delete Activity is configured like this:</p> <p><a href="https://i.stack.imgur.com/vbhcQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vbhcQ.png" alt="enter image description here" /></a></p> <p>On running the pipeline it errors with this error:</p> <p><strong>Failed to execute delete activity with data source 'AzureBlobStorage' and error 'The required Blob is missing. Folder path: container/top level directory/Directory to be removed/.'. For details, please reference log file here:</strong></p> <p>The log is an empty spreadsheet.</p> <p>What am I missing from either the dataset or delete activity?</p>
[ { "answer_id": 74411736, "author": "Lee Drum", "author_id": 17457026, "author_profile": "https://Stackoverflow.com/users/17457026", "pm_score": 1, "selected": false, "text": "database1_test " }, { "answer_id": 74417640, "author": "Chiperific", "author_id": 1880203, "author_profile": "https://Stackoverflow.com/users/1880203", "pm_score": 1, "selected": true, "text": "ENV" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74408956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3609480/" ]
74,409,033
<p>I'm new to pandas (version 1.1.5) and have tried <code>str.split()</code> and <code>str.extract()</code> to split column <code>POS</code> of numerical values with no success. My dataframe is about 3000 lines and is structured like this (note <code>_</code> and <code>-</code> delimiters in subset):</p> <pre><code>df.head() SAMPLE CHROM POS REF ALT 1 Sample1 7 105121514 C T 2 Sample2 17 7359940 C A 3 Sample3 X 76777781 A G 4 Sample4 16 70531965-70531965 C G 5 Sample5 6 26093141-26093141 G A 6 Sample6 12 11905465 C T 7 Sample7 4 103527484_103527848 G A </code></pre> <p>I would like for the dataframe to look like this (i.e. retain values preceding all delimiters):</p> <pre><code> SAMPLE CHROM POS REF ALT 1 Sample1 7 105121514 C T 2 Sample2 17 7359940 C A 3 Sample3 X 76777781 A G 4 Sample4 16 70531965 C G 5 Sample5 6 26093141 G A 6 Sample6 12 11905465 C T 7 Sample7 4 103527484 G A </code></pre> <p>My attempts have either split the rows only containing a delimiter and dropping all other rows, dropping all rows containing just the delimiters, or dropping all values.</p> <p>For example, <code>df['POS'] = df['POS'].str.replace(r'[-|_]\d+', '')</code> outputs:</p> <pre><code> SAMPLE CHROM POS REF ALT 1 Sample1 7 NaN C T 2 Sample2 17 NaN C A 3 Sample3 X NaN A G 4 Sample4 16 NaN C G 5 Sample5 6 NaN G A 6 Sample6 12 NaN C T 7 Sample7 4 NaN G A </code></pre> <hr /> <p>Accepting the solution from @PaulS below as I needed to convert the column datatype from object to string first in order for <code>str.replace()</code> to work!</p> <pre><code>df.dtypes SAMPLE object CHROM object POS object REF object ALT object dtype: object df['POS'] = df['POS'].astype('str') df['POS'] = df['POS'].str.replace(r'[-|_]\d+', '') </code></pre>
[ { "answer_id": 74409060, "author": "PaulS", "author_id": 11564487, "author_profile": "https://Stackoverflow.com/users/11564487", "pm_score": 1, "selected": true, "text": "_" }, { "answer_id": 74409113, "author": "scotscotmcc", "author_id": 15804190, "author_profile": "https://Stackoverflow.com/users/15804190", "pm_score": 0, "selected": false, "text": "str.split()" }, { "answer_id": 74409164, "author": "Mato", "author_id": 20390882, "author_profile": "https://Stackoverflow.com/users/20390882", "pm_score": 1, "selected": false, "text": "df.POS = df.POS.str.replace(\"-\", \" \")\ndf.POS = df.POS.str.replace(\"_\", \" \")\ndf.POS = df.POS.str.split()\ndf.POS = [x[0] for x in df.POS]\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74409033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4400289/" ]
74,409,058
<p>I found the following example to walk myself through a part of SpringBoot: <a href="https://dev.to/reytech-lesson/spring-boot-hello-world-example-by-using-spring-initilizr-b7o" rel="nofollow noreferrer">found here</a></p> <p>The example works without an error, but I am not able to wrap my head around why the addAttribute will not display the changed message, but rather returns only &quot;message&quot; as a string.</p> <p><strong>UPDATE</strong> The use of the <strong>@Controller</strong> annotation leads to an inability to execute for the project, and as a resolution, it needs to be <strong>@RestController</strong>. I'm not sure if that bears any significance for the general issue.</p> <p>This is the controller code:</p> <pre><code> package com.example.MySecondSpringBootProject.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HomeController { @GetMapping(&quot;/&quot;) public String hello(){ return &quot;hello&quot;; } @GetMapping(&quot;/message&quot;) public String message(Model model) { model.addAttribute(&quot;message&quot;, &quot;This is a custom message&quot;); return &quot;message&quot;; } } </code></pre> <p>This is the message html page:</p> <pre><code> &lt;!DOCTYPE html&gt; &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:th=&quot;http://www.thymeleaf.org&quot;&gt; &lt;head&gt; &lt;meta charset=&quot;UTF-8&quot;&gt; &lt;title&gt;Spring Demo Project&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1 th:text=&quot;${message}&quot;&gt;&lt;/h1&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And this is the output from &quot;/message&quot; on the locahost: <a href="https://i.stack.imgur.com/zYjYd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zYjYd.png" alt="enter image description here" /></a></p> <p>I've looked at various implementations of addAttribute <a href="https://www.tabnine.com/code/java/methods/org.springframework.ui.Model/addAttribute" rel="nofollow noreferrer">here</a> and they all use an incoming value from a frontend to assign a value to said attribute, which makes sense for this endpoint, but in this case, the frontend is pulling the value passed into it from the second parameter of the method - at least it should.</p> <p>I've tried this, to no effect:</p> <pre><code> @RequestMapping(&quot;/message&quot;) public String message(Model model, @RequestParam(value=&quot;message&quot;) String message) { model.addAttribute(&quot;message&quot;, &quot;This is a custom message&quot;); return &quot;message&quot;; } </code></pre> <p>Passing a second argument in the method, also to no effect, it just returns the &quot;message&quot; string:</p> <pre><code>@GetMapping(&quot;/message&quot;) public String message(Model model, String str) { model.addAttribute(&quot;message&quot;, &quot;This is a custom message&quot;); return &quot;message&quot;; } </code></pre> <p>I will keep looking into it, but my head is going into circles at this point, or I'm just not quite understanding something about the model.addAttribute concept.</p> <p>Thank you in advance!</p>
[ { "answer_id": 74409060, "author": "PaulS", "author_id": 11564487, "author_profile": "https://Stackoverflow.com/users/11564487", "pm_score": 1, "selected": true, "text": "_" }, { "answer_id": 74409113, "author": "scotscotmcc", "author_id": 15804190, "author_profile": "https://Stackoverflow.com/users/15804190", "pm_score": 0, "selected": false, "text": "str.split()" }, { "answer_id": 74409164, "author": "Mato", "author_id": 20390882, "author_profile": "https://Stackoverflow.com/users/20390882", "pm_score": 1, "selected": false, "text": "df.POS = df.POS.str.replace(\"-\", \" \")\ndf.POS = df.POS.str.replace(\"_\", \" \")\ndf.POS = df.POS.str.split()\ndf.POS = [x[0] for x in df.POS]\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74409058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6254385/" ]
74,409,063
<p>My code is setup like this:</p> <pre><code> private void TrySpawningAnAgent(GameObject startStructure, GameObject endStructure){ if (startStructure != null &amp;&amp; endStructure != null){ houses=GameObject.FindGameObjectsWithTag(&quot;Houses&quot;); specials = GameObject.FindGameObjectsWithTag(&quot;Special&quot;); Vector3Int startPosition = Mathf.FloorToInt(houses[UnityEngine.Random.Range(0, houses.Length)].transform.position); Vector3Int endPosition = Mathf.FloorToInt(specials[UnityEngine.Random.Range(0, specials.Length)].transform.position); var agent = Instantiate(GetRandomPedestrian(), startPosition, Quaternion.identity); var path = placementManager.GetPathBetween(startPosition, endPosition); if (path.Count &gt; 0) { path.Reverse(); var aiAgent = agent.GetComponent&lt;AIAgent&gt;(); aiAgent.Initialize(new List&lt;Vector3&gt;(path.Select(x =&gt; (Vector3)x).ToList())); } } } </code></pre> <p>My other function is set up like this:</p> <pre><code>internal List&lt;Vector3Int&gt; GetPathBetween(Vector3Int startPosition, Vector3Int endPosition) { var resultPath = GridSearch.AStarSearch(placementGrid, new Point(startPosition.x, startPosition.z), new Point(endPosition.x, endPosition.z)); List&lt;Vector3Int&gt; path = new List&lt;Vector3Int&gt;(); foreach (Point point in resultPath) { path.Add(new Vector3Int(point.X, 0, point.Y)); } return path; } </code></pre> <p>However I keep getting the same error when running FloorToInt. cannot convert from UnityEngine.Vector3 to Float</p> <p>I'm trying to figure out why I can't pass it through the function.</p>
[ { "answer_id": 74409060, "author": "PaulS", "author_id": 11564487, "author_profile": "https://Stackoverflow.com/users/11564487", "pm_score": 1, "selected": true, "text": "_" }, { "answer_id": 74409113, "author": "scotscotmcc", "author_id": 15804190, "author_profile": "https://Stackoverflow.com/users/15804190", "pm_score": 0, "selected": false, "text": "str.split()" }, { "answer_id": 74409164, "author": "Mato", "author_id": 20390882, "author_profile": "https://Stackoverflow.com/users/20390882", "pm_score": 1, "selected": false, "text": "df.POS = df.POS.str.replace(\"-\", \" \")\ndf.POS = df.POS.str.replace(\"_\", \" \")\ndf.POS = df.POS.str.split()\ndf.POS = [x[0] for x in df.POS]\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74409063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15415023/" ]
74,409,074
<p>I created a react product list using state and I also created a filter to filter the product. My problem is when I clicked on the category button the second time my page disappear.</p> <p>I tried not to use state to store data in memory but did not work. A link to my sandbox code is here.</p> <p><a href="https://codesandbox.io/s/l1b3od?file=/src/styles.css&amp;resolutionWidth=612&amp;resolutionHeight=675" rel="nofollow noreferrer">https://codesandbox.io/s/l1b3od?file=/src/styles.css&amp;resolutionWidth=612&amp;resolutionHeight=675</a></p>
[ { "answer_id": 74409060, "author": "PaulS", "author_id": 11564487, "author_profile": "https://Stackoverflow.com/users/11564487", "pm_score": 1, "selected": true, "text": "_" }, { "answer_id": 74409113, "author": "scotscotmcc", "author_id": 15804190, "author_profile": "https://Stackoverflow.com/users/15804190", "pm_score": 0, "selected": false, "text": "str.split()" }, { "answer_id": 74409164, "author": "Mato", "author_id": 20390882, "author_profile": "https://Stackoverflow.com/users/20390882", "pm_score": 1, "selected": false, "text": "df.POS = df.POS.str.replace(\"-\", \" \")\ndf.POS = df.POS.str.replace(\"_\", \" \")\ndf.POS = df.POS.str.split()\ndf.POS = [x[0] for x in df.POS]\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74409074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18580694/" ]
74,409,116
<p>I am trying to use generic programming in Haskell and need to sort an array of numbers but for some reason when I run the code, I receive an error stating &quot;No instance for (Fractional Nums) In the expression: 645.41....&quot; Every time I look at my code, I think it makes sense, but I'm not sure why it does not work...</p> <pre><code>import Data.List (sortBy) import Data.Ord (comparing) data Nums = Nums {numbers::Double} deriving(Ord, Eq, Show) sortNums :: [Nums] -&gt; [Nums] sortNums = sortBy(comparing numbers) arr = [645.41, 37.59, 76.41, 5.31, 1.11, 1.10, 23.46, 635.47, 467.83, 62.25] main:: IO () main = do print(sortNums arr) </code></pre> <p>I apologize if this code looks messy or does not make sense, I am new to Haskell....</p>
[ { "answer_id": 74409171, "author": "Robin Zigmond", "author_id": 8475054, "author_profile": "https://Stackoverflow.com/users/8475054", "pm_score": 1, "selected": false, "text": "arr" }, { "answer_id": 74409253, "author": "Daniel Wagner", "author_id": 791604, "author_profile": "https://Stackoverflow.com/users/791604", "pm_score": 2, "selected": true, "text": "Nums" }, { "answer_id": 74412899, "author": "Iceland_jack", "author_id": 165806, "author_profile": "https://Stackoverflow.com/users/165806", "pm_score": 0, "selected": false, "text": "1" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74409116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8768617/" ]
74,409,125
<p>I'm trying to correct a specific customer type in our database from a character customer type of &quot;05&quot; to a character customer type of &quot;09&quot;. I need to iterate through the database and find a customer name of ex.&quot;Gas Station 123&quot; and then change the customer type to a '09' for each record found. The problem I keep having is how to find a partial string in the customer name for each record. Any help would be appreciated.</p> <p>`</p> <pre><code>Dcl-F CUSTMST Keyed Usage(*INPUT:*OUTPUT:*UPDATE); Dcl-S CUSTNM Uns(10); SETLL 80000 Custmst; READ CUSTMST; DoW not %EoF(CUSTMST); If CUSTNM = %CHECK('GAS STATION 123':BL2LN1); CSTYP = %REPLACE('09':'05'); ENDIF; UPDATE CUSTREC; READ CUSTMST; ENDDO; Return; </code></pre> <p>`</p> <p>I've tried %scan and %check but get &quot;Operands are not compatible with the type of operator.&quot; I can assign an uns variable to the function which gets rid of the error but then doesn't find anything. I've looked for any kind of wildcard function that would allow partial string searches but haven't had any success.</p>
[ { "answer_id": 74411663, "author": "Dam", "author_id": 939484, "author_profile": "https://Stackoverflow.com/users/939484", "pm_score": 3, "selected": true, "text": "%SCAN(search argument : source string {: start position {: length}})\n" }, { "answer_id": 74524551, "author": "jmarkmurphy", "author_id": 2296441, "author_profile": "https://Stackoverflow.com/users/2296441", "pm_score": 0, "selected": false, "text": "select * \nfrom custmst\nwhere regexp_like(custnm, 'gas station [0-9]{3}', 1, 'i')\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74409125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11914714/" ]
74,409,133
<p>I am using Mapbox GL JS to capture frame by frame video of the animation of a geoJson (similar to what is described here: <a href="https://docs.mapbox.com/mapbox-gl-js/example/animate-a-line/" rel="nofollow noreferrer">https://docs.mapbox.com/mapbox-gl-js/example/animate-a-line/</a>).</p> <p>The strategy for encoding mapbox animations into mp4 here are described here: <a href="https://github.com/mapbox/mapbox-gl-js/issues/5297" rel="nofollow noreferrer">https://github.com/mapbox/mapbox-gl-js/issues/5297</a> and <a href="https://github.com/mapbox/mapbox-gl-js/pull/10172" rel="nofollow noreferrer">https://github.com/mapbox/mapbox-gl-js/pull/10172</a> .</p> <p>I would like to show the distance the polyline has covered as I draw each frame. I need the distance to be in the GL itself (as opposed to, for example, an HTML element on top of the canvas), since that's where I'm capturing the video from.</p> <p>Can someone help describe a performant strategy for doing this to me?</p>
[ { "answer_id": 74411663, "author": "Dam", "author_id": 939484, "author_profile": "https://Stackoverflow.com/users/939484", "pm_score": 3, "selected": true, "text": "%SCAN(search argument : source string {: start position {: length}})\n" }, { "answer_id": 74524551, "author": "jmarkmurphy", "author_id": 2296441, "author_profile": "https://Stackoverflow.com/users/2296441", "pm_score": 0, "selected": false, "text": "select * \nfrom custmst\nwhere regexp_like(custnm, 'gas station [0-9]{3}', 1, 'i')\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74409133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1193105/" ]
74,409,162
<p>Somehow I got operator looping till I get correct input. When i try to put num1 or num2 in &quot;if&quot; statement, It says that I cannot convert &quot;int&quot; to &quot;boolean&quot;. Please help</p> <pre class="lang-java prettyprint-override"><code>public class main { public static void main(String[] args) { int num1; int num2; String operator; Scanner scan = new Scanner(System.in); System.out.print(&quot;tell me first number: &quot;); num1 = scan.nextInt(); //&lt;--input only numbers, loop if not System.out.print(&quot;tell me second number: &quot;); num2 = scan.nextInt(); //&lt;--input only numbers, loop if not //////////////////operator//////////////////////// System.out.print(&quot;tell me operator: &quot;); operator = scan.next(); while(true) { if(operator.equals(&quot;+&quot;)) { System.out.println(&quot;answer is: &quot; +(num1 + num2)); break; } else if(operator.equals(&quot;-&quot;)) { System.out.println(&quot;answer is: &quot; +(num1 - num2)); break; } else if(operator.equals(&quot;*&quot;)) { System.out.println(&quot;answer is: &quot; +(num1 * num2)); break; } else if(operator.equals(&quot;/&quot;)) { System.out.println(&quot;answer is: &quot; +(num1 / num2)); break; } else { System.out.print(&quot;wrong input! try again!: &quot;); operator = scan.next(); } } } } </code></pre>
[ { "answer_id": 74411663, "author": "Dam", "author_id": 939484, "author_profile": "https://Stackoverflow.com/users/939484", "pm_score": 3, "selected": true, "text": "%SCAN(search argument : source string {: start position {: length}})\n" }, { "answer_id": 74524551, "author": "jmarkmurphy", "author_id": 2296441, "author_profile": "https://Stackoverflow.com/users/2296441", "pm_score": 0, "selected": false, "text": "select * \nfrom custmst\nwhere regexp_like(custnm, 'gas station [0-9]{3}', 1, 'i')\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74409162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20481566/" ]
74,409,199
<p>I'm iterating 4 million times (for a project). This is taking forever to do. I was wondering how I can go faster.</p> <pre><code>numbers = [0,1] evenNumbers = [] y = 0 l = 0 for x in range (1,4000000): l = numbers[x-1] + numbers[x] numbers.append(l) for k in numbers: if k % 2 ==0: evenNumbers.append(k) for n in evenNumbers: y += n print(y) </code></pre>
[ { "answer_id": 74409249, "author": "Samwise", "author_id": 3799759, "author_profile": "https://Stackoverflow.com/users/3799759", "pm_score": 2, "selected": false, "text": "m, n = 0, 1\ny = 0\nfor _ in range(1, 4000000):\n m, n = n, m + n\n if n % 2 == 0:\n y += n\n\nprint(y)\n" }, { "answer_id": 74409358, "author": "Shawn Bragdon", "author_id": 19753194, "author_profile": "https://Stackoverflow.com/users/19753194", "pm_score": 0, "selected": false, "text": "import time\n\ndef foreach(arr):\n for i in range(len(arr)):\n print(arr[i])\n\ndef forin(arr):\n for i in arr:\n print(i)\n\ndef whileloop(arr):\n i = 0\n while i < len(arr):\n print(arr[i])\n i += 1\n \ndef main():\n arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n\n start = time.time()\n foreach(arr)\n end = time.time()\n print(\"foreach: \", end - start)\n\n start = time.time()\n forin(arr)\n end = time.time()\n print(\"forin: \", end - start)\n\n start = time.time()\n whileloop(arr)\n end = time.time()\n print(\"whileloop: \", end - start)\n\nif __name__ == \"__main__\":\n main()\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74409199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14024430/" ]
74,409,202
<p>My table has 650M rows (according to a fast but decently precise estimate from a query I found <a href="https://stackoverflow.com/a/7945274/470749">here</a>).</p> <p>It has a text column called <code>receiver_account_id</code>, and I need to be able to search those records like: <code>r.receiver_account_id LIKE '%otherWordsHere'</code>.</p> <p>Because I'm using a leading wildcard, those searches are impossibly slow. I need an index. And my guess from <a href="https://stackoverflow.com/a/13452528/470749">here</a> is that I need a GIN index.</p> <p>I ran:</p> <pre class="lang-sql prettyprint-override"><code>CREATE EXTENSION pg_trgm; CREATE EXTENSION btree_gin; CREATE INDEX CONCURRENTLY receipts_receiver_account_id_gin_idx ON public.receipts USING gin (receiver_account_id); </code></pre> <p>But I'm not sure that the index is even being created.</p> <p>I <a href="https://dba.stackexchange.com/a/249784/18098">ran</a>:</p> <pre><code>SELECT now()::TIME(0), a.query, p.phase, round(p.blocks_done / p.blocks_total::numeric * 100, 2) AS &quot;% done&quot;, p.blocks_total, p.blocks_done, p.tuples_total, p.tuples_done, ai.schemaname, ai.relname, ai.indexrelname FROM pg_stat_progress_create_index p JOIN pg_stat_activity a ON p.pid = a.pid LEFT JOIN pg_stat_all_indexes ai on ai.relid = p.relid AND ai.indexrelid = p.index_relid; </code></pre> <p>But I just see <code>&lt;insufficient privilege&gt;</code> (which is bizarre since I own this machine) and a bunch of <code>NULL</code>s.</p> <p>The next 2 status queries I got from <a href="https://dba.stackexchange.com/a/242079/18098">here</a>.</p> <p><code>SELECT * FROM pg_class, pg_index WHERE pg_index.indisvalid = false AND pg_index.indexrelid = pg_class.oid;</code> shows:</p> <p><a href="https://i.stack.imgur.com/XdF7w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XdF7w.png" alt="screenshot1" /></a></p> <p>And then:</p> <pre><code>SELECT a.datname, l.relation::regclass, l.transactionid, l.mode, l.GRANTED, a.usename, a.query, a.query_start, age(now(), a.query_start) AS &quot;age&quot;, a.pid FROM pg_stat_activity a JOIN pg_locks l ON l.pid = a.pid WHERE mode = 'ShareUpdateExclusiveLock' ORDER BY a.query_start; </code></pre> <p>Shows: <a href="https://i.stack.imgur.com/BI3NC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BI3NC.png" alt="screenshot2" /></a></p> <p>Am I doing this correctly? How can I know when the index creation will finish?</p>
[ { "answer_id": 74409249, "author": "Samwise", "author_id": 3799759, "author_profile": "https://Stackoverflow.com/users/3799759", "pm_score": 2, "selected": false, "text": "m, n = 0, 1\ny = 0\nfor _ in range(1, 4000000):\n m, n = n, m + n\n if n % 2 == 0:\n y += n\n\nprint(y)\n" }, { "answer_id": 74409358, "author": "Shawn Bragdon", "author_id": 19753194, "author_profile": "https://Stackoverflow.com/users/19753194", "pm_score": 0, "selected": false, "text": "import time\n\ndef foreach(arr):\n for i in range(len(arr)):\n print(arr[i])\n\ndef forin(arr):\n for i in arr:\n print(i)\n\ndef whileloop(arr):\n i = 0\n while i < len(arr):\n print(arr[i])\n i += 1\n \ndef main():\n arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n\n start = time.time()\n foreach(arr)\n end = time.time()\n print(\"foreach: \", end - start)\n\n start = time.time()\n forin(arr)\n end = time.time()\n print(\"forin: \", end - start)\n\n start = time.time()\n whileloop(arr)\n end = time.time()\n print(\"whileloop: \", end - start)\n\nif __name__ == \"__main__\":\n main()\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74409202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/470749/" ]
74,409,209
<p>I am trying to write a Query in Google Sheets using the following formula:</p> <p><code>=QUERY(Input!A2:AD,&quot;SELECT Col1, Col4, Col5, Col6, Col7, Col12, Col13 WHERE Col12 &gt; 200 AND Col30 = '&quot;&amp;B3&amp;&quot;' ORDER BY Col13 DESC LIMIT 10&quot;)</code></p> <p>I have also tried:</p> <p><code>=QUERY(Input!A2:AD,&quot;SELECT A, D, E, F, G, L, M WHERE L &gt; 200 AND AD = '&quot;&amp;B3&amp;&quot;' ORDER BY M DESC LIMIT 10&quot;)</code></p> <p>Can anyone help with where I am going wrong please?</p> <p>Thanks!</p> <p>I tried the two formulas listed above.</p> <p>I was expecting the formula to produce a list of 10 results, ranked in order highest to lowest</p>
[ { "answer_id": 74409369, "author": "player0", "author_id": 5632629, "author_profile": "https://Stackoverflow.com/users/5632629", "pm_score": 3, "selected": true, "text": "=QUERY({Input!A2:AD}, \n \"select Col1,Col4,Col5,Col6,Col7,Col12,Col13 \n where Col12 > 200 \n and Col30 = '\"&TO_TEXT(B3)&\"' \n order by Col13 desc \n limit 10\", )\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74409209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20481875/" ]
74,409,230
<p>I want to write some symbols in the console, but I have troubles with the output of the <code>\</code> character.</p> <p>I know it is reserved by C for formatting inside <code>printf()</code>, but I really want to output it.</p> <pre><code>printf(&quot; __ __ __ __ ____ \n&quot;); printf(&quot; ||\ /|| || // ||/\\ \n&quot;); printf(&quot; ||\\//|| ||// ||\// \n&quot;); printf(&quot; || \/ || ||\\ ||‾‾ \n&quot;); printf(&quot; || || || \\ || \n&quot;); printf(&quot; ‾‾ </code></pre> <p>I expect that <code>\\</code> in this will just output like any other char, but it can't just output.</p>
[ { "answer_id": 74409233, "author": "lorro", "author_id": 6292621, "author_profile": "https://Stackoverflow.com/users/6292621", "pm_score": 2, "selected": true, "text": "'\\n'" }, { "answer_id": 74409251, "author": "pm100", "author_id": 173397, "author_profile": "https://Stackoverflow.com/users/173397", "pm_score": 0, "selected": false, "text": " printf(\" || || || \\\\ || \\n\");\n" }, { "answer_id": 74409310, "author": "Pignotto", "author_id": 15114624, "author_profile": "https://Stackoverflow.com/users/15114624", "pm_score": 2, "selected": false, "text": "\\\\" }, { "answer_id": 74409313, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 0, "selected": false, "text": "\\" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74409230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20481926/" ]
74,409,246
<p>Im trying to get my Card components to take the full width and height of my 4x4 Tailwindcss grid, right now they only take about 1/4 of the full width even with w-max.</p> <p>Here's my code:</p> <pre><code>function Card({ title, description }: Props) { return ( &lt;div className=&quot;border border-zinc-700 hover:bg-white-500 p rounded-md m-auto my-8&quot;&gt; &lt;div className=&quot;px-5 py-4&quot;&gt; &lt;h3 className=&quot;text-2xl mb-1 font-medium&quot;&gt;ok&lt;/h3&gt; &lt;p className=&quot;text-zinc-300&quot;&gt;{title}&lt;/p&gt; &lt;/div&gt; &lt;div className=&quot;border-t border-zinc-700 bg-zinc-900 p-4 text-zinc-500 rounded-b-md&quot;&gt; {description} &lt;/div&gt; &lt;/div&gt; ); } export default function Home() { return ( &lt;section className=&quot;bg-black&quot;&gt; &lt;section className=&quot;bg-black&quot;&gt; &lt;div className=&quot;max-w-6xl mx-auto py-8 sm:py-24 px-4 sm:px-6 lg:px-8&quot;&gt; &lt;div className=&quot;sm:flex sm:flex-col sm:align-center&quot;&gt; &lt;h1 className=&quot;text-4xl font-extrabold text-white sm:text-center sm:text-6xl&quot;&gt; Nom &lt;/h1&gt; &lt;p className=&quot;mt-5 text-xl text-zinc-200 sm:text-center sm:text-2xl max-w-2xl m-auto&quot;&gt; The Best Electronic Arbitrage Opportunity Finder. &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/section&gt; &lt;section className=&quot;bg-zinc-900 flex items-center justify-center h-screen&quot;&gt; &lt;div className=&quot;grid grid-cols-2 gap-1 w-4/5 place-items-center auto-cols-max auto-rows-max&quot;&gt; &lt;Card title=&quot;card-1&quot; description=&quot;desc-1&quot;&gt;&lt;/Card&gt; &lt;Card title=&quot;card-2&quot; description=&quot;desc-2&quot;&gt;&lt;/Card&gt; &lt;Card title=&quot;card-3&quot; description=&quot;desc-3&quot;&gt;&lt;/Card&gt; &lt;Card title=&quot;card-4&quot; description=&quot;desc-4&quot;&gt;&lt;/Card&gt; &lt;/div&gt; &lt;/section&gt; &lt;/section&gt; ); } </code></pre>
[ { "answer_id": 74409233, "author": "lorro", "author_id": 6292621, "author_profile": "https://Stackoverflow.com/users/6292621", "pm_score": 2, "selected": true, "text": "'\\n'" }, { "answer_id": 74409251, "author": "pm100", "author_id": 173397, "author_profile": "https://Stackoverflow.com/users/173397", "pm_score": 0, "selected": false, "text": " printf(\" || || || \\\\ || \\n\");\n" }, { "answer_id": 74409310, "author": "Pignotto", "author_id": 15114624, "author_profile": "https://Stackoverflow.com/users/15114624", "pm_score": 2, "selected": false, "text": "\\\\" }, { "answer_id": 74409313, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 0, "selected": false, "text": "\\" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74409246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15828620/" ]
74,409,254
<p>I have this JSON an I want to get just license_key.</p> <pre><code>{&quot;data&quot;: {&quot;enabled&quot;: true,&quot;product_link&quot;: &quot;example&quot;,&quot;license_key&quot;: &quot;BS7X4-55UH7-ZG2EV-ME2N5&quot;,&quot;buyer_email&quot;: &quot;example@gmail.com&quot;,&quot;uses&quot;: 0,&quot;date&quot;: &quot;2022-11-11T20:56:37+00:00&quot;}} </code></pre> <p>I try this script but when i open it I get white page</p> <pre><code>&lt;?php $url = &quot;https://example.com/&quot;; $curl = curl_init($url); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $resp = curl_exec($curl); curl_close($curl); $json_decoded = json_decode($resp); $license_key = ''; for ($i = 0; $i &lt; count($json_decoded-&gt;{'data'}); $i++) { $license_key = $json_decoded-&gt;{'data'}[$i]-&gt;{'license_key'}; } echo $license_key; </code></pre>
[ { "answer_id": 74409233, "author": "lorro", "author_id": 6292621, "author_profile": "https://Stackoverflow.com/users/6292621", "pm_score": 2, "selected": true, "text": "'\\n'" }, { "answer_id": 74409251, "author": "pm100", "author_id": 173397, "author_profile": "https://Stackoverflow.com/users/173397", "pm_score": 0, "selected": false, "text": " printf(\" || || || \\\\ || \\n\");\n" }, { "answer_id": 74409310, "author": "Pignotto", "author_id": 15114624, "author_profile": "https://Stackoverflow.com/users/15114624", "pm_score": 2, "selected": false, "text": "\\\\" }, { "answer_id": 74409313, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 0, "selected": false, "text": "\\" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74409254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20330453/" ]
74,409,286
<p>Pretty rusty at tcl so bear with me if the solution to this questions is a fairly simple one.</p> <p>I have a .txt file that contains sites and addresses with one space between them. It looks something like this:</p> <pre><code>site1 address1 site2 address2 site3 address3 . . . . </code></pre> <p>I want to read the .txt file and create a dictionary with sites as keys and values as addresses in tcl. So my result tcl dictionary should look something like this:</p> <p>dict = {&quot;site1&quot;: &quot;address1&quot;, &quot;site2&quot;: &quot;address2&quot;, ........}</p> <p>How do I do this in tcl?</p> <p>I only have an idea on how to implement this in Python but no clue whatsoever in tcl.</p>
[ { "answer_id": 74409233, "author": "lorro", "author_id": 6292621, "author_profile": "https://Stackoverflow.com/users/6292621", "pm_score": 2, "selected": true, "text": "'\\n'" }, { "answer_id": 74409251, "author": "pm100", "author_id": 173397, "author_profile": "https://Stackoverflow.com/users/173397", "pm_score": 0, "selected": false, "text": " printf(\" || || || \\\\ || \\n\");\n" }, { "answer_id": 74409310, "author": "Pignotto", "author_id": 15114624, "author_profile": "https://Stackoverflow.com/users/15114624", "pm_score": 2, "selected": false, "text": "\\\\" }, { "answer_id": 74409313, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 0, "selected": false, "text": "\\" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74409286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10226550/" ]
74,409,289
<p>I am trying to replace a CSS file with another one on a page by toggling between the day/night themes using an eventlistener. I tried to do this in numerous ways, but none of them worked completely.</p> <p>My default theme is dark and I can only manage to change it to light theme using my code, not back to dark again. What am I doing wrong? Thanks a lot everyone!</p> <pre><code>colorModeBtn.addEventListener(&quot;click&quot;, function() { if (cssFile.href = &quot;styles.css&quot;) { cssFile.setAttribute(&quot;href&quot;, &quot;styles-daylight.css&quot;) } else { cssFile.setAttribute(&quot;href&quot;, &quot;styles.css&quot;) } }) </code></pre> <pre><code>colorModeBtn.addEventListener(&quot;click&quot;, function() { if (cssFileDay.disabled = true) { cssFileDay.disabled = false cssFile.disabled = true } else { cssFileDay.disabled = true cssFile.disabled = false } }) </code></pre> <pre><code>colorModeBtn.addEventListener(&quot;click&quot;, function() { const cssLink = document.createElement(&quot;link&quot;) if (cssFile.href = &quot;styles.css&quot;) { cssLink.rel = &quot;stylesheet&quot; cssLink.href = &quot;styles-daylight.css&quot; document.head.appendChild(cssLink) cssFile.disabled = true } else if (document.head.cssLink) { document.head.removeChild(cssLink) cssFile.disabled = false } }) </code></pre> <pre><code>colorModeBtn.addEventListener(&quot;click&quot;, function() { const cssLink = document.createElement(&quot;link&quot;) if (cssFile.href = &quot;styles.css&quot;) { cssLink.rel = &quot;stylesheet&quot; cssLink.href = &quot;styles-daylight.css&quot; document.head.appendChild(cssLink) cssFile.disabled = true } else if (document.head.cssLink) { var linkNode = document.querySelector('link[href*=&quot;styles-daylight.css&quot;]') linkNode.removeChild(linkNode) cssFile.disabled = false } }) </code></pre>
[ { "answer_id": 74409233, "author": "lorro", "author_id": 6292621, "author_profile": "https://Stackoverflow.com/users/6292621", "pm_score": 2, "selected": true, "text": "'\\n'" }, { "answer_id": 74409251, "author": "pm100", "author_id": 173397, "author_profile": "https://Stackoverflow.com/users/173397", "pm_score": 0, "selected": false, "text": " printf(\" || || || \\\\ || \\n\");\n" }, { "answer_id": 74409310, "author": "Pignotto", "author_id": 15114624, "author_profile": "https://Stackoverflow.com/users/15114624", "pm_score": 2, "selected": false, "text": "\\\\" }, { "answer_id": 74409313, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 0, "selected": false, "text": "\\" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74409289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19251767/" ]
74,409,291
<p>How do I use the Loop Summing Pattern to calculate and print the total score of all the games in this list of dictionaries? The Sum function is not allowed, nor is importing functions:</p> <pre><code>games = [ {&quot;Name&quot;: &quot;UD&quot;, &quot;Score&quot;: 27, &quot;Away?&quot;: False}, {&quot;Name&quot;: &quot;Clemson&quot;, &quot;Score&quot;: 14, &quot;Away?&quot;: True}, {&quot;Name&quot;: &quot;Pitt&quot;, &quot;Score&quot;: 32, &quot;Away?&quot;: True}, ] </code></pre> <p>I would suppose that there is some way of accessing it via a for loop?</p> <pre><code>for i in games: ...... for i in games[&quot;Score&quot;]: </code></pre> <p>gets SyntaxError: unexpected EOF while parsing</p> <p>I tried:</p> <pre><code>sum_hold = sum(d.get(&quot;Score&quot;, 0) for d in games) </code></pre> <p>but I am not allowed to use the sum function for the assignment</p>
[ { "answer_id": 74409233, "author": "lorro", "author_id": 6292621, "author_profile": "https://Stackoverflow.com/users/6292621", "pm_score": 2, "selected": true, "text": "'\\n'" }, { "answer_id": 74409251, "author": "pm100", "author_id": 173397, "author_profile": "https://Stackoverflow.com/users/173397", "pm_score": 0, "selected": false, "text": " printf(\" || || || \\\\ || \\n\");\n" }, { "answer_id": 74409310, "author": "Pignotto", "author_id": 15114624, "author_profile": "https://Stackoverflow.com/users/15114624", "pm_score": 2, "selected": false, "text": "\\\\" }, { "answer_id": 74409313, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 0, "selected": false, "text": "\\" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74409291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20481928/" ]
74,409,300
<p>so im trying to display the fields name into a html page i used this code to display it but sometimes the result becomes undefined not sure why this is happening the columnNames will return to the html page.</p> <pre><code>var dataset = mongoose.connection.db.collection(dsName) populations = await mongoose.connection.db.collection(dsName+ '_pops').distinct(&quot;_id&quot;, {}); var mykeys; console.log('select'); dataset.findOne({}, function(err,result) { try{ mykeys = Object.keys(result); //here is the error console.log(dataset); columnNames = mykeys.splice(0,mykeys.length) }catch{ console.log(dataset); } if(err){console.log(&quot;not working&quot;)} </code></pre>
[ { "answer_id": 74409233, "author": "lorro", "author_id": 6292621, "author_profile": "https://Stackoverflow.com/users/6292621", "pm_score": 2, "selected": true, "text": "'\\n'" }, { "answer_id": 74409251, "author": "pm100", "author_id": 173397, "author_profile": "https://Stackoverflow.com/users/173397", "pm_score": 0, "selected": false, "text": " printf(\" || || || \\\\ || \\n\");\n" }, { "answer_id": 74409310, "author": "Pignotto", "author_id": 15114624, "author_profile": "https://Stackoverflow.com/users/15114624", "pm_score": 2, "selected": false, "text": "\\\\" }, { "answer_id": 74409313, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 0, "selected": false, "text": "\\" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74409300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20200597/" ]
74,409,375
<p>I tried modifying the array &quot;newTab&quot; but without use <em>tab.copy()</em> but it always modifies the original array.</p> <pre><code>tab = [[1]*2]*3 newTab = [None] * len(tab) for i in range(0, len(tab)): newTab[i] = tab[i] newTab[0][0] = 2 print(tab) [[2, 1], [2, 1], [2, 1]] print(newTab) [[2, 1], [2, 1], [2, 1]] </code></pre> <p>I also tried using something like this : <code>a = b[:]</code> but it doesn't work. Somehow the original array is always a reference to the new one. I just started learning python and we can only use the basics for our homework. So i'm not allowed to use things like deepcopy() Any help would be appreciated!</p>
[ { "answer_id": 74409446, "author": "Shawn Bragdon", "author_id": 19753194, "author_profile": "https://Stackoverflow.com/users/19753194", "pm_score": 1, "selected": false, "text": "copy" }, { "answer_id": 74409596, "author": "KEcoding", "author_id": 14055405, "author_profile": "https://Stackoverflow.com/users/14055405", "pm_score": 1, "selected": true, "text": "tab = [[1]*2]*3\ntab2 = []\nfor t in tab:\n tab2.append(t.copy())\n#check that it worked - none of the values from tab2 should be the same as tab:\nfor t in tab:\n print(id(t))\nfor t in tab2:\n print(id(t))\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20153722/" ]
74,409,378
<p>I'm currently programming a discord bot in module type, and the problem with the reload command is that the import doesn't notice the file changes.</p> <p>Folder structure (only what relevant)</p> <pre><code>application ├── src │   ├── handlers │ │ └── commands.js │   └── commands │ └── reload.js </code></pre> <p>commands.js</p> <pre><code>import { readdirSync } from 'fs'; async function reloadCommands(client) { await client.commands.clear(); await client.aliases.clear(); const commandFiles = readdirSync('./src/commands').filter(file =&gt; file.endsWith('.js')); for (let i = 0; i &lt; commandFiles.length; i++) { const cmd = await import(`../commands/${commandFiles[i]}`); await client.commands.set(cmd.default.name, cmd.default); console.log(`[COMMAND] Reloaded ${commandFiles[i]} with command ${cmd.default.name}${cmd.default.aliases}`); if (cmd.default.aliases) { cmd.default.aliases.forEach(async (alias) =&gt; { await client.aliases.set(alias, cmd.default); }); } } return commandFiles.length; } export default { loadCommands, reloadCommands }; </code></pre> <p>reload.js</p> <pre><code>import commandHandler from '../handlers/commands.js'; export default { name: 'reload', description: 'Reloads all commands', aliases: ['rl'], async execute(message, args, client) { try { let cmd = await commandHandler.reloadCommands(client); message.reply(`${cmd} commands have been reloaded!`); } catch (error) { console.log(error); } } }; </code></pre> <p>Node v18.9.0</p> <p>I googled but found nothing that helps me</p>
[ { "answer_id": 74409432, "author": "Shawn Bragdon", "author_id": 19753194, "author_profile": "https://Stackoverflow.com/users/19753194", "pm_score": 0, "selected": false, "text": "loadCommands" }, { "answer_id": 74412909, "author": "Zilou1", "author_id": 17245939, "author_profile": "https://Stackoverflow.com/users/17245939", "pm_score": 1, "selected": false, "text": "const cmd = await import(`../commands/${commandFiles[i]}?${Date.now()}`);\nawait client.commands.set(cmd.default.name, cmd.default);\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17245939/" ]
74,409,420
<p>I have this code where I want the bot to reply to a command, in the console it says it has received the message but does not reply.</p> <pre><code>client.on('message', msg =&gt; { console.log(&quot;Message recieved.&quot;) if (msg.content === 'ping') { msg.reply(&quot;pong&quot;) msg.delete() } }); </code></pre> <p>I have tried replacing the code with different code in different ways, but nothing has worked.</p>
[ { "answer_id": 74409698, "author": "Shawn Bragdon", "author_id": 19753194, "author_profile": "https://Stackoverflow.com/users/19753194", "pm_score": 1, "selected": false, "text": "client.on('message', message => {\n if (message.content === 'ping') {\n message.reply('pong');\n }\n});\n" }, { "answer_id": 74416785, "author": "Thunder", "author_id": 16499723, "author_profile": "https://Stackoverflow.com/users/16499723", "pm_score": 0, "selected": false, "text": "message" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20482039/" ]
74,409,441
<p>I want to write a program to find the position of letter <code>e</code> in a sentence and print the output (indices) as a list.</p> <p>This is my code,</p> <pre><code>def find_position(x): n=len(x) for test in range(0,n): if x[test]==&quot;e&quot;: b=test return b text=&quot;Helloe&quot; ans=find_position(text) print(ans) </code></pre> <p>I am getting output as <code>1</code> which is wrong. How can I get the correct answer?</p>
[ { "answer_id": 74409487, "author": "Swifty", "author_id": 20267366, "author_profile": "https://Stackoverflow.com/users/20267366", "pm_score": 0, "selected": false, "text": " def find_position(x):\n pos = []\n n=len(x)\n for test in range(0,n):\n if x[test]==\"e\":\n pos.append(test)\n return pos\n \n text=\"Helloe\"\n ans=find_position(text)\n print(ans)\n # [1, 5]\n" }, { "answer_id": 74409595, "author": "Daniel Hao", "author_id": 10760768, "author_profile": "https://Stackoverflow.com/users/10760768", "pm_score": 2, "selected": false, "text": "enumerate" }, { "answer_id": 74409867, "author": "Arifa Chan", "author_id": 19574157, "author_profile": "https://Stackoverflow.com/users/19574157", "pm_score": 0, "selected": false, "text": "def find_position(x):\n n=len(x)\n for test in range(0,n):\n if x[test]=='e':\n b=test\n yield b\n\ntext=\"Helloe\"\n\nans=find_position(text)\n\nprint(list(ans))\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20482099/" ]
74,409,442
<p>So I like to use ruby <code>inspect</code> for debugging, however I have a class that have an array that have 6000+ elements and whenever I <code>puts obj.inspect</code> the array clutters the entire screen. Is there any way to make the array attribute hidden from inspect?</p> <pre class="lang-rb prettyprint-override"><code>class Test def initialize @x = 1 @array = [1, 2, 3, 4, 5, 6, 7, 8, 9] end def myinspect # ?? end end c = Test.new puts c.inspect # &lt;Test:0x00007f1d49e33b00 @x=1, @array=[1, 2, 3, 4, 5, 6, 7, 8, 9]&gt; puts c.myinspect # &lt;Test:0x00007f1d49e33b00 @x=1&gt; </code></pre>
[ { "answer_id": 74409663, "author": "mechnicov", "author_id": 10608621, "author_profile": "https://Stackoverflow.com/users/10608621", "pm_score": 2, "selected": false, "text": "class Test\n def initialize\n @x = 1\n @array = [1, 2, 3, 4, 5, 6, 7, 8, 9]\n end\n\n def myinspect\n \"#<#{self.class.name}:0x#{(object_id * 2).to_s(16).rjust(16, '0')} @x=#{instance_variable_get(:@x)}>\"\n end\nend\n" }, { "answer_id": 74409806, "author": "jvx8ss", "author_id": 11107859, "author_profile": "https://Stackoverflow.com/users/11107859", "pm_score": 1, "selected": false, "text": "inspect_except" }, { "answer_id": 74409830, "author": "Masa Sakano", "author_id": 3577922, "author_profile": "https://Stackoverflow.com/users/3577922", "pm_score": 2, "selected": false, "text": "inspect" }, { "answer_id": 74411700, "author": "Cary Swoveland", "author_id": 256970, "author_profile": "https://Stackoverflow.com/users/256970", "pm_score": 2, "selected": false, "text": "my_inspect" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11107859/" ]
74,409,448
<p>after learning javascript, I started to learn React and I'm not quite sure how DOM manipulation works in React, for example, I want to change the background colour in React, is it similar to Javascript or it's totally something else?</p> <pre><code> const onClick = () =&gt;{ document.body.style.backgroundColor = 'Dodgerblue'; } return ( &lt;div&gt; &lt;button onClick={onClick}&gt;Change background Color&lt;/button&gt; &lt;/div&gt; ) }``` </code></pre>
[ { "answer_id": 74409883, "author": "Aleksandar", "author_id": 12737879, "author_profile": "https://Stackoverflow.com/users/12737879", "pm_score": 2, "selected": true, "text": "null" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14552086/" ]
74,409,456
<p>So I have an app deployed with docker but I'm tired to delete and rebuild the image everytime so i used wrote a script to do everything for me:</p> <pre><code>#!/usr/bin/env sh docker-compose ps # lists all services (id, name) docker-compose stop dee506ab283a #this will stop only the selected container docker-compose rm dee506ab283a # this will remove the docker container permanently docker-compose up </code></pre> <p>The problem is that the container wont have the same id everytime so this only works once. How can I get the new generated id so I can just run this script everytime?</p>
[ { "answer_id": 74409883, "author": "Aleksandar", "author_id": 12737879, "author_profile": "https://Stackoverflow.com/users/12737879", "pm_score": 2, "selected": true, "text": "null" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17583130/" ]
74,409,471
<p>I have one data frame with aircraft types, speed and range.</p> <pre><code>Aircraft &lt;- data.frame(type=c(&quot;X&quot;,&quot;Y&quot;,&quot;Z&quot;), Range=c(100,200,300), Speed=c(50,60,70)) Aircraft </code></pre> <p>and a second long data frame with a list of destinations and distances</p> <pre><code>Destination &lt;- data.frame(Location=c(&quot;A&quot;,&quot;B&quot;,&quot;C&quot;, &quot;D&quot;), Distance=c(50,150,200,400)) Destination </code></pre> <p>I would like to use the first data frame to add multiple columns to the second data frame based on a calculation, eg, the time taken based on the speed (Destination$Distance/Aircraft$Speed). Ideally I would also like the new column names to take part of their label from the first data frame. So that Destination would end up with the following columns Destination, Distance, TimeX, TimeY, TimeZ.</p> <p>I am just getting started in R and have no idea if this is possible.</p> <p>Thanks</p>
[ { "answer_id": 74409557, "author": "SALAR", "author_id": 12517976, "author_profile": "https://Stackoverflow.com/users/12517976", "pm_score": 0, "selected": false, "text": "library(dplyr)\nDestination<-mutate(Destination\n ,TimeX=Distance/50\n ,TimeY=Distance/60\n ,TimeZ=Distance/70 )\n\nDestination\n Location Distance TimeX TimeY TimeZ\n A 50 1 0.8333333 0.7142857\n B 150 3 2.5000000 2.1428571\n C 200 4 3.3333333 2.8571429\n D 400 8 6.6666667 5.7142857\n" }, { "answer_id": 74409870, "author": "Ido Sarig", "author_id": 2193050, "author_profile": "https://Stackoverflow.com/users/2193050", "pm_score": 1, "selected": false, "text": "for (i in 1:nrow(Aircraft)) {\n varname <- paste(\"Time\",Aircraft$type[i] , sep=\"_\")\n Destination[[varname]] <-with(Destination, Distance/Aircraft$Speed[i])\n}\n\nDestination\n\n\n\n\n Location Distance Time_X Time_Y Time_Z\n1 A 50 1 0.8333333 0.7142857\n2 B 150 3 2.5000000 2.1428571\n3 C 200 4 3.3333333 2.8571429\n4 D 400 8 6.6666667 5.7142857\n" }, { "answer_id": 74409937, "author": "zephryl", "author_id": 17303805, "author_profile": "https://Stackoverflow.com/users/17303805", "pm_score": 1, "selected": true, "text": "Aircraft" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20482025/" ]
74,409,481
<p>I am new to android. I implemented a GIF in my activity.</p> <p>I found a way to make it loop only once. So far everything is fine but I would like to display the image of this gif at the end of the animation of this one, this time in image and not in gif. Basically I would like the gif to loop once and then become an image again</p> <p>I implemented this on my build.gradle :</p> <pre><code>implementation 'com.github.bumptech.glide:glide:4.12.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0' </code></pre> <p>After that I set up my imageView :</p> <pre><code>&lt;ImageView android:id=&quot;@+id/fuse&quot; android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;match_parent&quot; android:layout_marginStart=&quot;@dimen/_4sdp&quot; android:layout_marginLeft=&quot;@dimen/_4sdp&quot; android:padding=&quot;@dimen/_8sdp&quot; android:src=&quot;@drawable/fuseev4&quot; tools:ignore=&quot;InvalidId&quot; /&gt; </code></pre> <p>Now this is my java file to loop once:</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); binding = ActivityChatRoomBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); imageView = binding.fuse; try { setListeners(); } catch (InterruptedException e) { e.printStackTrace(); } } public void setListeners() throws InterruptedException { binding.LayoutSend.setOnClickListener(view -&gt; { try { Glide.with(this) .asGif() .load(R.drawable.fuseev4) //Your gif resource .apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.NONE)) .listener(new RequestListener&lt;GifDrawable&gt;() { @Override public boolean onLoadFailed(@Nullable @org.jetbrains.annotations.Nullable GlideException e, Object model, Target&lt;GifDrawable&gt; target, boolean isFirstResource) { return false; } @Override public boolean onResourceReady(GifDrawable resource, Object model, Target&lt;GifDrawable&gt; target, DataSource dataSource, boolean isFirstResource) { resource.setLoopCount(1); return false; } }) .into(imageView); } catch (Exception e){ System.out.println(e); } afterListeners(); }); } public void afterListeners(){ Glide.with(this) .asBitmap() .load(R.drawable.fuseev4) .into(imageView); } </code></pre> <p>I couldn't find a way to solve my problem.</p> <p>Thanks in advance for your help !</p>
[ { "answer_id": 74409557, "author": "SALAR", "author_id": 12517976, "author_profile": "https://Stackoverflow.com/users/12517976", "pm_score": 0, "selected": false, "text": "library(dplyr)\nDestination<-mutate(Destination\n ,TimeX=Distance/50\n ,TimeY=Distance/60\n ,TimeZ=Distance/70 )\n\nDestination\n Location Distance TimeX TimeY TimeZ\n A 50 1 0.8333333 0.7142857\n B 150 3 2.5000000 2.1428571\n C 200 4 3.3333333 2.8571429\n D 400 8 6.6666667 5.7142857\n" }, { "answer_id": 74409870, "author": "Ido Sarig", "author_id": 2193050, "author_profile": "https://Stackoverflow.com/users/2193050", "pm_score": 1, "selected": false, "text": "for (i in 1:nrow(Aircraft)) {\n varname <- paste(\"Time\",Aircraft$type[i] , sep=\"_\")\n Destination[[varname]] <-with(Destination, Distance/Aircraft$Speed[i])\n}\n\nDestination\n\n\n\n\n Location Distance Time_X Time_Y Time_Z\n1 A 50 1 0.8333333 0.7142857\n2 B 150 3 2.5000000 2.1428571\n3 C 200 4 3.3333333 2.8571429\n4 D 400 8 6.6666667 5.7142857\n" }, { "answer_id": 74409937, "author": "zephryl", "author_id": 17303805, "author_profile": "https://Stackoverflow.com/users/17303805", "pm_score": 1, "selected": true, "text": "Aircraft" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20325819/" ]
74,409,510
<p>Hi How can we control the line space? It seems we can only adjust font</p> <p>For example, how can I make 'my name' 'is' closer to each other without changing the font?</p> <pre><code>import PySimpleGUI as sg layout = [ [sg.pin(sg.T('Hello'))], [sg.pin(sg.T('my name'))], [sg.pin(sg.T('is'))], [sg.pin(sg.T('Mike'))], ] window = sg.Window(&quot;Title&quot;, layout) while True: event, values = window.read() if event == sg.WIN_CLOSED: break window.close() </code></pre>
[ { "answer_id": 74409557, "author": "SALAR", "author_id": 12517976, "author_profile": "https://Stackoverflow.com/users/12517976", "pm_score": 0, "selected": false, "text": "library(dplyr)\nDestination<-mutate(Destination\n ,TimeX=Distance/50\n ,TimeY=Distance/60\n ,TimeZ=Distance/70 )\n\nDestination\n Location Distance TimeX TimeY TimeZ\n A 50 1 0.8333333 0.7142857\n B 150 3 2.5000000 2.1428571\n C 200 4 3.3333333 2.8571429\n D 400 8 6.6666667 5.7142857\n" }, { "answer_id": 74409870, "author": "Ido Sarig", "author_id": 2193050, "author_profile": "https://Stackoverflow.com/users/2193050", "pm_score": 1, "selected": false, "text": "for (i in 1:nrow(Aircraft)) {\n varname <- paste(\"Time\",Aircraft$type[i] , sep=\"_\")\n Destination[[varname]] <-with(Destination, Distance/Aircraft$Speed[i])\n}\n\nDestination\n\n\n\n\n Location Distance Time_X Time_Y Time_Z\n1 A 50 1 0.8333333 0.7142857\n2 B 150 3 2.5000000 2.1428571\n3 C 200 4 3.3333333 2.8571429\n4 D 400 8 6.6666667 5.7142857\n" }, { "answer_id": 74409937, "author": "zephryl", "author_id": 17303805, "author_profile": "https://Stackoverflow.com/users/17303805", "pm_score": 1, "selected": true, "text": "Aircraft" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20043803/" ]
74,409,512
<p>i m using the an csv file of the following format:</p> <pre><code>&quot;LatD&quot;, &quot;LatM&quot;, &quot;LatS&quot;, &quot;NS&quot;, &quot;LonD&quot;, &quot;LonM&quot;, &quot;LonS&quot;, &quot;EW&quot;, &quot;City&quot;, &quot;State&quot; 41, 5, 59, &quot;N&quot;, 80, 39, 0, &quot;W&quot;, &quot;Youngstown&quot;, OH 42, 52, 48, &quot;N&quot;, 97, 23, 23, &quot;W&quot;, &quot;Yankton&quot;, SD 46, 35, 59, &quot;N&quot;, 120, 30, 36, &quot;W&quot;, &quot;Yakima&quot;, WA 42, 16, 12, &quot;N&quot;, 71, 48, 0, &quot;W&quot;, &quot;Worcester&quot;, MA 43, 37, 48, &quot;N&quot;, 89, 46, 11, &quot;W&quot;, &quot;Wisconsin Dells&quot;, WI </code></pre> <p>When it with:</p> <pre><code>cities = pd.read_csv(&quot;cities.csv&quot;) </code></pre> <p>And try to invoke a column with:</p> <pre><code>print(cities[cities.City.str.contains(&quot;Y&quot;)]) </code></pre> <p>I get this error:</p> <pre><code>AttributeError: 'DataFrame' object has no attribute 'City' </code></pre> <p>I tried using to fix it but the problem remains:</p> <pre><code>cities.columns = cities.columns.str.strip() </code></pre> <p>Is this related to the quotes on the first row? And if so is there a way to convert them programmatically?</p> <p>Thank you in advance.</p>
[ { "answer_id": 74409567, "author": "KEcoding", "author_id": 14055405, "author_profile": "https://Stackoverflow.com/users/14055405", "pm_score": 0, "selected": false, "text": "cities[\"City\"].str.contains('Y').any()\n" }, { "answer_id": 74409584, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 2, "selected": true, "text": "\"" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5449244/" ]
74,409,520
<p>I have the following list -</p> <pre><code> pts1_list = [ [224.95256042, 321.64755249], [280.72879028, 296.15835571], [302.34194946, 364.82437134], [434.68283081, 402.86990356], [244.64321899, 308.50286865], [488.62979126, 216.26953125], [214.77470398, 430.75869751], [299.20846558, 312.07217407], [266.94125366, 119.36679077], [384.41549683, 442.05865479], [475.28448486, 254.28138733]] </code></pre> <p>I would like to append ones to this so that it finally looks like this -</p> <pre><code> pts1_list = [ [224.95256042, 321.64755249, 1], [280.72879028, 296.15835571, 1], [302.34194946, 364.82437134, 1], [434.68283081, 402.86990356, 1], [244.64321899, 308.50286865, 1], [488.62979126, 216.26953125, 1], [214.77470398, 430.75869751, 1], [299.20846558, 312.07217407, 1], [266.94125366, 119.36679077, 1], [384.41549683, 442.05865479, 1], [475.28448486, 254.28138733, 1]] </code></pre> <p>I have tried doing the following -</p> <pre><code>for i in range(len(pts1)): points1_list = [pts1[i]] points1_list = np.append(points1_list,1) print(points1_list) print(pts1_list) </code></pre> <p>for which <code>print(points1_list)</code> prints out only <code>[475.28448486, 254.28138733, 1]</code> i.e. the last element ; whereas if I print <code>pts1_list</code>, it prints out all the elements in the list. How do I get <code>points1_list</code> to also print out all the elements in the list, with a 1 appended to it? Thanks</p>
[ { "answer_id": 74409567, "author": "KEcoding", "author_id": 14055405, "author_profile": "https://Stackoverflow.com/users/14055405", "pm_score": 0, "selected": false, "text": "cities[\"City\"].str.contains('Y').any()\n" }, { "answer_id": 74409584, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 2, "selected": true, "text": "\"" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10083150/" ]
74,409,526
<p>Question: Write JFrame that when you press the &quot;start&quot; button draws, and keep drawing random colored and sized filled ovals until the &quot;stop&quot; button is pressed. Problem: loop inside the actionPerformed method() Doesn't Work. The Code:</p> <pre><code>import java.awt.*; import java.awt.event.*; import javax.swing.*; public class p6 extends JFrame implements ActionListener { String str; JButton start,stop; int h=0,w=0; p6() { setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(1500,1000); start= new JButton(&quot;Start&quot;); stop= new JButton(&quot;Stop&quot;); setLayout(null); start.setBounds(500, 50, 100,30); stop.setBounds(610, 50, 100,30); add(start); add(stop); start.addActionListener(this); stop.addActionListener(this); } public void actionPerformed(ActionEvent ae) { String c=ae.getActionCommand(); if(c==&quot;Start&quot;) { while(c!=&quot;Stop&quot;) { h+=20; w+=20; } repaint(); } str=&quot; &quot;+h+&quot; &quot;+w; } public void paint(Graphics g) { super.paintComponents(g); g.drawString(str, 100, 100); //g.drawOval(100, 100, 100, 100); g.drawOval((int)Math.random()*2000,(int) Math.random()*2000, w,h); } public static void main(String[] args) { new p6(); } } </code></pre>
[ { "answer_id": 74409810, "author": "MadProgrammer", "author_id": 992484, "author_profile": "https://Stackoverflow.com/users/992484", "pm_score": 1, "selected": false, "text": "Timer" }, { "answer_id": 74409863, "author": "Mad_Oum", "author_id": 20482393, "author_profile": "https://Stackoverflow.com/users/20482393", "pm_score": 0, "selected": false, "text": " start.setActionCommand(\"start\");\n stop.setActionCommand(\"stop\");\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17617579/" ]
74,409,566
<p>I'm trying to write a regex that will find any CRLF in python.<br /> I am able to successfully open the file and use newlines to determine what newlines its using CRLF or LF. My numerous regex attempts have failed</p> <pre><code>with open('test.txt', 'rU') as f: text = f.read() print repr(f.newlines) regex = re.compile(r&quot;[^\r\n]+&quot;, re.MULTILINE) print(regex.match(text)) </code></pre> <p>I've done numerous iterations on the regex and in every case it till either detect \n as \r\n or not work at all.</p>
[ { "answer_id": 74409589, "author": "Shawn Bragdon", "author_id": 19753194, "author_profile": "https://Stackoverflow.com/users/19753194", "pm_score": 2, "selected": true, "text": "re" }, { "answer_id": 74415499, "author": "jamesdlin", "author_id": 179715, "author_profile": "https://Stackoverflow.com/users/179715", "pm_score": 0, "selected": false, "text": "from __future__ import print_function\nimport re\n\nwith open('test.txt', 'rb') as f:\n text = f.read()\n\nregex = re.compile(r\"[^\\r\\n]+\", re.MULTILINE)\nprint(regex.match(text))\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409566", "https://Stackoverflow.com", "https://Stackoverflow.com/users/814830/" ]
74,409,594
<p>I am very sorry for the confusing title, I did not know how else to phrase the question.</p> <p>Let's say I have a class, <code>A</code>. It is described as shown:</p> <pre><code>class A: def __init__(self, argument): self.value = argument def submethod(self, argumentThatWillBeAClass): print(dir(argumentThatWillBeAClass)) </code></pre> <p>And then I initialize it as shown below:</p> <pre><code>classAInstance = A('42.0') </code></pre> <p>Now, I have a class, <code>B</code>. Let's add a submethod that calls <code>A</code>'s submethod with <code>B</code> as an argument.</p> <pre><code>class B: def __init__(self, argumentThatIsAClassAInstance): self.classAInstance = argumentThatIsAClassAInstance def submethod(self): self.classAInstance.submethod(self) </code></pre> <p>Let's initialize it with <code>classInstance</code>:</p> <pre><code>classBInstance = B(classAInstance) </code></pre> <p>My desired result is that all the attributes of <code>B</code> are printed when <code>B.submethod</code> is called. Is this possible, and if not, how would I achieve something like this?</p>
[ { "answer_id": 74409752, "author": "12944qwerty", "author_id": 11177720, "author_profile": "https://Stackoverflow.com/users/11177720", "pm_score": -1, "selected": false, "text": "class B" }, { "answer_id": 74409762, "author": "juanpa.arrivillaga", "author_id": 5014455, "author_profile": "https://Stackoverflow.com/users/5014455", "pm_score": 0, "selected": false, "text": " self.classAInstance.submethod(self)\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17064640/" ]
74,409,625
<p>Does anyone know the use cases for the trace_block method by Openethereum?</p> <p>Here's the link to it:</p> <p><a href="https://docs.alchemy.com/reference/trace-block" rel="nofollow noreferrer">https://docs.alchemy.com/reference/trace-block</a></p> <p>I cannot find any use cases listed for this method anywhere. Even in the official docs, it's not written.</p>
[ { "answer_id": 74409833, "author": "Shawn Bragdon", "author_id": 19753194, "author_profile": "https://Stackoverflow.com/users/19753194", "pm_score": 1, "selected": false, "text": "curl -X POST --data '{\"jsonrpc\":\"2.0\",\"method\":\"trace_block\",\"params\":[\"0x1\"],\"id\":1}' https://eth-mainnet.alchemyapi.io/v2/your-api-key\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17658136/" ]
74,409,655
<p>I put together the following pen to illustrate my problem: <a href="https://codepen.io/ganakim/pen/jOKmByM" rel="nofollow noreferrer">https://codepen.io/ganakim/pen/jOKmByM</a></p> <p>For some reason, even though column 1 has <code>overflow-y: auto</code> it doesn't scroll, and instead forces the footer outside the max height of the card. How do I fix this?</p>
[ { "answer_id": 74556981, "author": "Dakshank", "author_id": 4940513, "author_profile": "https://Stackoverflow.com/users/4940513", "pm_score": 0, "selected": false, "text": "overflow: hidden" }, { "answer_id": 74561717, "author": "Cervus camelopardalis", "author_id": 10347145, "author_profile": "https://Stackoverflow.com/users/10347145", "pm_score": -1, "selected": true, "text": "overflow: hidden" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4061471/" ]
74,409,678
<p>In the past I used to start a new thread for sorting, and abort it when the user clicked 'Cancel', and it worked flawlessly on virtually all .NET Framework versions. But since the introduction of .NET Core and .NET 5+, a call to <code>Thread.Abort()</code> throws <code>PlatformNotSupportedException</code>.</p> <p>So it is time now to find a better way to do that. The main problem is that <code>Array.Sort()</code> and <code>List.Sort()</code> methods do not acccept a <code>CancellationToken</code>. I could go by sending my own <code>Comparison</code> delegate and call <code>cancellationToken.ThrowIfCancellationRequested();</code> inside but that would have a significant performance impact.</p> <p>How to properly cancel an in-place sort without sacrificing much performance in newer dotnet versions?</p> <p>Attached a snippet that used to work on .NET Framework:</p> <pre><code>byte[] arr = new byte[1024 * 1024 * 1024]; Thread thread = new Thread(() =&gt; Array.Sort(arr)); thread.IsBackground = true; thread.Start(); if (!thread.Join(1000)) thread.Abort(); </code></pre>
[ { "answer_id": 74410274, "author": "shingo", "author_id": 6196568, "author_profile": "https://Stackoverflow.com/users/6196568", "pm_score": -1, "selected": false, "text": "class ByteComparer : IComparer<byte>\n{\n private bool _cancel;\n\n public int Compare(byte x, byte y)\n {\n if (!_cancel) return x - y;\n throw new TaskCanceledException();\n }\n \n public void Cancel() => _cancel = true;\n}\n\nvar arr = new byte[1024 * 1024 * 100];\nvar comparer = new ByteComparer();\nTask.Run(() => Array.Sort(arr, comparer));\n...\ncomparer.Cancel();\n" }, { "answer_id": 74420741, "author": "Theodor Zoulias", "author_id": 11178549, "author_profile": "https://Stackoverflow.com/users/11178549", "pm_score": 1, "selected": false, "text": "Comparison<T>" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409678", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191727/" ]
74,409,679
<p>I am working on working on forming a logic:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>user_id</th> <th>city</th> <th>county</th> <th>state</th> <th>country</th> <th>region</th> <th>is_perm</th> </tr> </thead> <tbody> <tr> <td>First</td> <td>Oakland</td> <td>Alameda</td> <td>California</td> <td>United States</td> <td>North America</td> <td>True</td> </tr> <tr> <td>First</td> <td>Fremont</td> <td>Alameda</td> <td>California</td> <td>United States</td> <td>North America</td> <td>False</td> </tr> <tr> <td>First</td> <td>Broolyn</td> <td>Kings</td> <td>New York</td> <td>United States</td> <td>North America</td> <td>True</td> </tr> <tr> <td>Second</td> <td>San Francisco</td> <td>San Francisco</td> <td>California</td> <td>United States</td> <td>North America</td> <td>True</td> </tr> <tr> <td>Second</td> <td>Cleveland</td> <td>Cuyahoga</td> <td>Ohio</td> <td>United States</td> <td>North America</td> <td>False</td> </tr> </tbody> </table> </div> <p>I am looking for output of following:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>user_id</th> <th>unique_city_count</th> <th>unique_county_count</th> <th>unique_state_count</th> <th>unique_country</th> <th>unique_region</th> <th>perm_unique_city_count</th> <th>perm_unique_county_count</th> <th>perm_unique_state_count</th> <th>perm_unique_country</th> <th>perm_unique_region</th> </tr> </thead> <tbody> <tr> <td>First</td> <td>3</td> <td>2</td> <td>2</td> <td>1</td> <td>1</td> <td>2</td> <td>2</td> <td>2</td> <td>1</td> <td>1</td> </tr> <tr> <td>Second</td> <td>2</td> <td>2</td> <td>2</td> <td>1</td> <td>1</td> <td>1</td> <td>1</td> <td>1</td> <td>1</td> <td>1</td> </tr> </tbody> </table> </div> <p><strong>Column definitions:</strong></p> <ul> <li>user_id: User ID</li> <li>unique_city_count: Unique City Counts</li> <li>unique_county_count: Unique County Counts</li> <li>unique_state_count: Unique State Counts</li> <li>unique_country: Unique Country Counts</li> <li>unique_region: Unique Region Counts</li> <li>perm_unique_city_count: Unique City Counts who has a permanent home</li> <li>perm_unique_county_count: Unique City Counts who has a permanent home</li> <li>perm_unique_state_count: Unique City Counts who has a permanent home</li> <li>perm_unique_country: Unique City Counts who has a permanent home</li> <li>perm_unique_region: Unique City Counts who has a permanent home</li> </ul> <p>Could anyone help me to achieve this?</p> <p>Thanks a lot.</p>
[ { "answer_id": 74410274, "author": "shingo", "author_id": 6196568, "author_profile": "https://Stackoverflow.com/users/6196568", "pm_score": -1, "selected": false, "text": "class ByteComparer : IComparer<byte>\n{\n private bool _cancel;\n\n public int Compare(byte x, byte y)\n {\n if (!_cancel) return x - y;\n throw new TaskCanceledException();\n }\n \n public void Cancel() => _cancel = true;\n}\n\nvar arr = new byte[1024 * 1024 * 100];\nvar comparer = new ByteComparer();\nTask.Run(() => Array.Sort(arr, comparer));\n...\ncomparer.Cancel();\n" }, { "answer_id": 74420741, "author": "Theodor Zoulias", "author_id": 11178549, "author_profile": "https://Stackoverflow.com/users/11178549", "pm_score": 1, "selected": false, "text": "Comparison<T>" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3055164/" ]
74,409,684
<p>I am asking a user for four ranges of floating point numbers. I want to check that there is no overlap between them.</p> <p>If the ranges were integer ranges it seems that I could either create sets or use Swift Range (or NSRange) and check for intersections.</p> <p>Is there a way to figure this out if the ranges where then upper and lower bounds are floating point values?</p> <p>Would I just have to check that each lower and upper bound of each range is not between the lower/upper bound of each of the other ranges? Is there a better way?</p> <p>Thanks</p>
[ { "answer_id": 74410274, "author": "shingo", "author_id": 6196568, "author_profile": "https://Stackoverflow.com/users/6196568", "pm_score": -1, "selected": false, "text": "class ByteComparer : IComparer<byte>\n{\n private bool _cancel;\n\n public int Compare(byte x, byte y)\n {\n if (!_cancel) return x - y;\n throw new TaskCanceledException();\n }\n \n public void Cancel() => _cancel = true;\n}\n\nvar arr = new byte[1024 * 1024 * 100];\nvar comparer = new ByteComparer();\nTask.Run(() => Array.Sort(arr, comparer));\n...\ncomparer.Cancel();\n" }, { "answer_id": 74420741, "author": "Theodor Zoulias", "author_id": 11178549, "author_profile": "https://Stackoverflow.com/users/11178549", "pm_score": 1, "selected": false, "text": "Comparison<T>" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13376883/" ]
74,409,716
<p>I have been going at the endlessly all semester. I was able to add project from my prior year in school but have been unable to push and new projects to my repository.</p> <p>I have tried deleting my key credentials via my key access chain. I have created a new GitHub account and tried using that one. I have deleted repositories started from scratch over and over.</p> <p>I have read question on question and tried following multiple different answers on here. What I wouldn't give to understand what is going on and why nothing seems to allow me to push a project anymore.</p> <p>The most current attempt was going back to my original GitHub account. I created a brand new repository. I created a new folder and copied my simple python project into it and saved.</p> <pre><code>error: remote origin already exists. (base) stephaniebrandon@Stephanies-MacBook-Pro-2 pythonGame % git remote rm origin (base) stephaniebrandon@Stephanies-MacBook-Pro-2 pythonGame % git remote rm upstream error: No such remote: 'upstream' (base) stephaniebrandon@Stephanies-MacBook-Pro-2 pythonGame % git remote add origin https://github.com/stephanieBrandon/GuessARandomNumberGame.git (base) stephaniebrandon@Stephanies-MacBook-Pro-2 pythonGame % git push -u origin main error: src refspec main does not match any error: failed to push some refs to 'https://github.com/stephanieBrandon/GuessARandomNumberGame.git' (base) stephaniebrandon@Stephanies-MacBook-Pro-2 pythonGame % ls -a . .. guess_a_random_number.py (base) stephaniebrandon@Stephanies-MacBook-Pro-2 pythonGame % git init hint: Using 'master' as the name for the initial branch. This default branch name hint: is subject to change. To configure the initial branch name to use in all hint: of your new repositories, which will suppress this warning, call: hint: hint: git config --global init.defaultBranch &lt;name&gt; hint: hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and hint: 'development'. The just-created branch can be renamed via this command: hint: hint: git branch -m &lt;name&gt; Initialized empty Git repository in /Users/stephaniebrandon/Documents/GitHubPortfolio/Python/GuessARandomNumberGame/pythonGame/.git/ (base) stephaniebrandon@Stephanies-MacBook-Pro-2 pythonGame % git remote add origin https://github.com/stephanieBrandon/GuessARandomNumberGame.git (base) stephaniebrandon@Stephanies-MacBook-Pro-2 pythonGame % git push -u origin main error: src refspec main does not match any error: failed to push some refs to 'https://github.com/stephanieBrandon/GuessARandomNumberGame.git' (base) stephaniebrandon@Stephanies-MacBook-Pro-2 pythonGame % ls -a . .. .git guess_a_random_number.py (base) stephaniebrandon@Stephanies-MacBook-Pro-2 pythonGame % git status On branch master </code></pre> <p>I am hoping there is just some simple thing I am missing, if someone could explain and help me out it would be much appreciated.</p>
[ { "answer_id": 74410274, "author": "shingo", "author_id": 6196568, "author_profile": "https://Stackoverflow.com/users/6196568", "pm_score": -1, "selected": false, "text": "class ByteComparer : IComparer<byte>\n{\n private bool _cancel;\n\n public int Compare(byte x, byte y)\n {\n if (!_cancel) return x - y;\n throw new TaskCanceledException();\n }\n \n public void Cancel() => _cancel = true;\n}\n\nvar arr = new byte[1024 * 1024 * 100];\nvar comparer = new ByteComparer();\nTask.Run(() => Array.Sort(arr, comparer));\n...\ncomparer.Cancel();\n" }, { "answer_id": 74420741, "author": "Theodor Zoulias", "author_id": 11178549, "author_profile": "https://Stackoverflow.com/users/11178549", "pm_score": 1, "selected": false, "text": "Comparison<T>" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20258926/" ]
74,409,754
<p>I'm trying to make a simple formula for multiple running totals.</p> <p><img src="https://i.stack.imgur.com/liVQt.png" alt="Sample:" /></p> <p>Basically, it's for recording transactions for different accounts, showing the running total of that particular account for each row. So, it's impossible to use SCAN+LAMBDA function. One way to do it is to have a set of helper arrays somewhere, but here I'm using another way, by using XLOOKUP.</p> <p><code>=C2+XLOOKUP(D2,D$1:OFFSET(D2,-1,),E$1:OFFSET(E2,-1,),0,,-1)</code></p> <p>Basically, it looks up the last account balance above the current row of the corresponding account and add the current transaction amounnt to it. It works by draggin down to all the transaction rows.</p> <p>Since the number of transactions is over 10 thousand, I was trying to minimize the file size by using named function with LAMBDA.</p> <p>Name: AddtoBalance</p> <p><code>=LAMBDA(c,c+XLOOKUP(OFFSET(c,,1),Sheet1!E$1:OFFSET(c,-1,1),Sheet1!F$1:OFFSET(c,-1,2),0,,-1))</code></p> <p>And changed cell E2 to <code>=AddtoBalance(C2)</code></p> <p>and dragged it down to all transaction rows.</p> <p>However, after saving and re-opening, the cells are having errors. I have to go to Name Manager, click Edit but without doing anything and Close it. Then the cells becomes fine again. It seems to me that when re-opening a workbook, the formulas are not calculated sequentially from top to bottom. Is that right? Is there any options to change it?</p> <p><img src="https://i.stack.imgur.com/pOcdE.png" alt="Error:" /></p>
[ { "answer_id": 74410259, "author": "Max R", "author_id": 19662289, "author_profile": "https://Stackoverflow.com/users/19662289", "pm_score": 1, "selected": false, "text": "=SUMIF( B$2:B2, B2, C$2:C2 )" }, { "answer_id": 74416403, "author": "P.b", "author_id": 12634230, "author_profile": "https://Stackoverflow.com/users/12634230", "pm_score": 0, "selected": false, "text": "=LET(f,ISNUMBER(C:C),\n c,FILTER(C:C,f),\n d,FILTER(D:D,f),\n s,SEQUENCE(COUNTA(d)),\nMMULT(\n (d=TRANSPOSE(d))*(s>=TRANSPOSE(s)),\n c))\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4658181/" ]
74,409,759
<p>I've been working on a project where my goal is to have a chrome extension that looks for words on a page, then displays a popup with a message that depends on whether it finds that word (or words). I'm not very experienced in JavaScript + HTML, but I've been trying my best. At the moment, the extension does have a pop-up, but it doesn't change the text of the pop-up. I can't tell if it's an issue with it searching the page or taking the results of the search and updating (or both). I'm working in manifest v3.</p> <p>My manifest looks like this</p> <pre><code>{ &quot;manifest_version&quot;: 3, &quot;name&quot;: &quot;Chrome Extension&quot;, &quot;version&quot;: &quot;1.0&quot;, &quot;action&quot;: { &quot;default_popup&quot;: &quot;popup.html&quot; }, &quot;description&quot;: &quot;searches for keywords to provide product safety information&quot;, &quot;content_scripts&quot;:[{ &quot;matches&quot;:[&quot;*://*.facebook.com/*&quot;], &quot;js&quot;:[&quot;search.js&quot;,&quot;popup.js&quot;] }] } </code></pre> <p>This is the html.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Baby Safety Extension&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Baby Safety Extension&lt;/h1&gt; &lt;p id=&quot;product&quot;&gt;We could not determine the type of product.&lt;/p&gt; &lt;script src=&quot;popup.js&quot;&gt;whichproduct();&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Here's what I've tried to create to search the page (search.js). I would definitely not be surprised if this was wrong, but it's what I had put together based on the chrome examples</p> <pre><code>//creates a variable that selects the body of the page const body = document.querySelector(&quot;body&quot;); //if a body exists, checks to see if certain elements exist in the body, sets their corresponding variables to true if they do if (body) { var text = body.textContent; var bouncer = text.includes(&quot;bouncer&quot; || &quot;Bouncer&quot;); } </code></pre> <p>And this is my whichproduct function in popup.js</p> <pre><code>function whichproduct(){ if (bouncer === true){ document.getElementById(&quot;product&quot;)=(&quot;You're looking at a bouncer. Here's some tips for using a bouncer safely&quot;); } } </code></pre> <p>Does anyone have tips about where my code is going wrong or where I could find additional documentation about some of these functions? Thanks so much for reading!</p>
[ { "answer_id": 74410259, "author": "Max R", "author_id": 19662289, "author_profile": "https://Stackoverflow.com/users/19662289", "pm_score": 1, "selected": false, "text": "=SUMIF( B$2:B2, B2, C$2:C2 )" }, { "answer_id": 74416403, "author": "P.b", "author_id": 12634230, "author_profile": "https://Stackoverflow.com/users/12634230", "pm_score": 0, "selected": false, "text": "=LET(f,ISNUMBER(C:C),\n c,FILTER(C:C,f),\n d,FILTER(D:D,f),\n s,SEQUENCE(COUNTA(d)),\nMMULT(\n (d=TRANSPOSE(d))*(s>=TRANSPOSE(s)),\n c))\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20482324/" ]
74,409,780
<p>I have an Outlook addin that utilizes the <strong>appendOnSendAsync</strong> function.</p> <pre><code> Office.context.mailbox.item.body.appendOnSendAsync( &quot;&lt;img src='xxxx' /&gt;&quot;, { coercionType: Office.CoercionType.Html }, function(asyncResult) { console.log(asyncResult); } ); </code></pre> <p>I do a check for the below before enabling it.</p> <pre><code>Office.context.requirements.isSetSupported('MailBox', '1.9') </code></pre> <p>The feature works as designed when testing it on <strong>outlook.com</strong>. However, on my Mac OS Outlook (version 16.66.2), the function does not seem to append the pixel like it does when I send a message on <strong>outlook.com</strong>.</p> <p>Is there anything else I need to be doing to get it to work on my Outlook Mac client?</p> <p>Below is how I initiate the call. I don't reference the below in the Manifest since its not triggered by any buttons within the toolbar. Again, this code works on Outlook.com but not on my Mac Outlook with the new UI.</p> <pre><code>jQuery(&quot;#track_email_code&quot;).on(&quot;click&quot;, function(){ var pixel_code = jQuery(&quot;#track_email_code&quot;).val(); if(Query(&quot;#track_email_code&quot;).is(&quot;:checked&quot;)) { appendText = '&lt;img src=&quot;XXXXXXX'+pixel_code+'&quot; /&gt;'; } else { appendText = ''; } Office.context.mailbox.item.body.appendOnSendAsync( appendText, { coercionType: Office.CoercionType.Html }, function(asyncResult) { console.log(asyncResult); } ); }); </code></pre> <p>Here is my manifest file</p> <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;OfficeApp xmlns=&quot;http://schemas.microsoft.com/office/appforoffice/1.1&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:bt=&quot;http://schemas.microsoft.com/office/officeappbasictypes/1.0&quot; xmlns:mailappor=&quot;http://schemas.microsoft.com/office/mailappversionoverrides&quot; xsi:type=&quot;MailApp&quot;&gt; &lt;Id&gt;xxxxxxxxxxx&lt;/Id&gt; &lt;!--Version. Updates from the store only get triggered if there is a version change. --&gt; &lt;Version&gt;2.0.1.6&lt;/Version&gt; &lt;ProviderName&gt;xxxxxx&lt;/ProviderName&gt; &lt;DefaultLocale&gt;en-US&lt;/DefaultLocale&gt; &lt;!-- The display name of your add-in. Used on the store and various places of the Office UI such as the add-ins dialog. --&gt; &lt;DisplayName DefaultValue=&quot;xxxxxx&quot; /&gt; &lt;Description DefaultValue=&quot;xxxx&quot;/&gt; &lt;!-- Icon for your add-in. Used on installation screens and the add-ins dialog. --&gt; &lt;IconUrl DefaultValue=&quot;https://xxxxx/icon_64.png&quot; /&gt; &lt;HighResolutionIconUrl DefaultValue=&quot;https://xxxxx/icon.png&quot;/&gt; &lt;!--If you plan to submit this add-in to the Office Store, uncomment the SupportUrl element below--&gt; &lt;SupportUrl DefaultValue=&quot;https://xxxxx.com&quot; /&gt; &lt;!-- Domains that will be allowed when navigating. For example, if you use ShowTaskpane and then have an href link, navigation will only be allowed if the domain is on this list. --&gt; &lt;AppDomains&gt; &lt;AppDomain&gt;https://xxxxxx.com&lt;/AppDomain&gt; &lt;AppDomain&gt;https://o365.xxxxxx.com&lt;/AppDomain&gt; &lt;/AppDomains&gt; &lt;!--End Basic Settings. --&gt; &lt;Hosts&gt; &lt;Host Name=&quot;Mailbox&quot; /&gt; &lt;/Hosts&gt; &lt;Requirements&gt; &lt;Sets&gt; &lt;Set Name=&quot;Mailbox&quot; MinVersion=&quot;1.1&quot; /&gt; &lt;/Sets&gt; &lt;/Requirements&gt; &lt;FormSettings&gt; &lt;Form xsi:type=&quot;ItemRead&quot;&gt; &lt;DesktopSettings&gt; &lt;SourceLocation DefaultValue=&quot;https://xxxxxx/beta/index.html&quot;/&gt; &lt;RequestedHeight&gt;250&lt;/RequestedHeight&gt; &lt;/DesktopSettings&gt; &lt;/Form&gt; &lt;/FormSettings&gt; &lt;Permissions&gt;ReadWriteMailbox&lt;/Permissions&gt; &lt;Rule xsi:type=&quot;RuleCollection&quot; Mode=&quot;Or&quot;&gt; &lt;Rule xsi:type=&quot;ItemIs&quot; ItemType=&quot;Message&quot; FormType=&quot;Read&quot; /&gt; &lt;/Rule&gt; &lt;DisableEntityHighlighting&gt;false&lt;/DisableEntityHighlighting&gt; &lt;VersionOverrides xmlns=&quot;http://schemas.microsoft.com/office/mailappversionoverrides&quot; xsi:type=&quot;VersionOverridesV1_0&quot;&gt; &lt;Requirements&gt; &lt;bt:Sets DefaultMinVersion=&quot;1.1&quot;&gt; &lt;bt:Set Name=&quot;Mailbox&quot; /&gt; &lt;/bt:Sets&gt; &lt;/Requirements&gt; &lt;Hosts&gt; &lt;Host xsi:type=&quot;MailHost&quot;&gt; &lt;DesktopFormFactor&gt; &lt;!-- Location of the Functions that UI-less buttons can trigger (ExecuteFunction Actions). --&gt; &lt;FunctionFile resid=&quot;functionFile&quot; /&gt; &lt;ExtensionPoint xsi:type=&quot;MessageReadCommandSurface&quot;&gt; &lt;OfficeTab id=&quot;TabDefault&quot;&gt; &lt;Group id=&quot;msgReadMMGroup&quot;&gt; &lt;Label resid=&quot;groupLabel&quot;/&gt; &lt;Control xsi:type=&quot;Button&quot; id=&quot;msgComposeAddContact&quot;&gt; &lt;Label resid=&quot;addContactLabel&quot;/&gt; &lt;Supertip&gt; &lt;Title resid=&quot;addContactTitle&quot;/&gt; &lt;Description resid=&quot;addContactDesc&quot;/&gt; &lt;/Supertip&gt; &lt;Icon&gt; &lt;bt:Image size=&quot;16&quot; resid=&quot;icon16&quot;/&gt; &lt;bt:Image size=&quot;32&quot; resid=&quot;icon32&quot;/&gt; &lt;bt:Image size=&quot;80&quot; resid=&quot;icon80&quot;/&gt; &lt;/Icon&gt; &lt;Action xsi:type=&quot;ShowTaskpane&quot;&gt; &lt;SourceLocation resid=&quot;readEmailContactPaneUrl&quot; /&gt; &lt;/Action&gt; &lt;/Control&gt; &lt;/Group&gt; &lt;/OfficeTab&gt; &lt;/ExtensionPoint&gt; &lt;ExtensionPoint xsi:type=&quot;MessageComposeCommandSurface&quot;&gt; &lt;OfficeTab id=&quot;TabDefault&quot;&gt; &lt;Group id=&quot;msgComposeCmdGroup&quot;&gt; &lt;Label resid=&quot;groupLabel&quot;/&gt; &lt;Control xsi:type=&quot;Button&quot; id=&quot;msgComposeInsertGist&quot;&gt; &lt;Label resid=&quot;insertGistLabel&quot;/&gt; &lt;Supertip&gt; &lt;Title resid=&quot;insertIconTitle&quot;/&gt; &lt;Description resid=&quot;insertGistDesc&quot;/&gt; &lt;/Supertip&gt; &lt;Icon&gt; &lt;bt:Image size=&quot;16&quot; resid=&quot;icon16&quot;/&gt; &lt;bt:Image size=&quot;32&quot; resid=&quot;icon32&quot;/&gt; &lt;bt:Image size=&quot;80&quot; resid=&quot;icon80&quot;/&gt; &lt;/Icon&gt; &lt;Action xsi:type=&quot;ShowTaskpane&quot;&gt; &lt;SourceLocation resid=&quot;addActivityUrl&quot; /&gt; &lt;/Action&gt; &lt;/Control&gt; &lt;/Group&gt; &lt;/OfficeTab&gt; &lt;/ExtensionPoint&gt; &lt;ExtensionPoint xsi:type=&quot;AppointmentAttendeeCommandSurface&quot;&gt; &lt;OfficeTab id=&quot;TabDefault&quot;&gt; &lt;Group id=&quot;apptAttendeeGroup&quot;&gt; &lt;Label resid=&quot;groupLabel&quot;/&gt; &lt;Control xsi:type=&quot;Button&quot; id=&quot;apptAttendeeOpenPaneButton&quot;&gt; &lt;Label resid=&quot;logActivityLabel&quot;/&gt; &lt;Supertip&gt; &lt;Title resid=&quot;logActivityLabel&quot;/&gt; &lt;Description resid=&quot;logActivityDesc&quot;/&gt; &lt;/Supertip&gt; &lt;Icon&gt; &lt;bt:Image size=&quot;16&quot; resid=&quot;icon16&quot;/&gt; &lt;bt:Image size=&quot;32&quot; resid=&quot;icon32&quot;/&gt; &lt;bt:Image size=&quot;80&quot; resid=&quot;icon80&quot;/&gt; &lt;/Icon&gt; &lt;Action xsi:type=&quot;ShowTaskpane&quot;&gt; &lt;SourceLocation resid=&quot;meetingContactPaneUrl&quot;/&gt; &lt;/Action&gt; &lt;/Control&gt; &lt;/Group&gt; &lt;/OfficeTab&gt; &lt;/ExtensionPoint&gt; &lt;ExtensionPoint xsi:type=&quot;AppointmentOrganizerCommandSurface&quot;&gt; &lt;OfficeTab id=&quot;TabDefault&quot;&gt; &lt;Group id=&quot;msgReadGroup&quot;&gt; &lt;Label resid=&quot;groupLabel&quot;/&gt; &lt;Control xsi:type=&quot;Button&quot; id=&quot;msgReadOpenPaneButton&quot;&gt; &lt;Label resid=&quot;logActivityLabel&quot;/&gt; &lt;Supertip&gt; &lt;Title resid=&quot;logActivityLabel&quot;/&gt; &lt;Description resid=&quot;logActivityDesc&quot;/&gt; &lt;/Supertip&gt; &lt;Icon&gt; &lt;bt:Image size=&quot;16&quot; resid=&quot;icon16&quot;/&gt; &lt;bt:Image size=&quot;32&quot; resid=&quot;icon32&quot;/&gt; &lt;bt:Image size=&quot;80&quot; resid=&quot;icon80&quot;/&gt; &lt;/Icon&gt; &lt;Action xsi:type=&quot;ShowTaskpane&quot;&gt; &lt;SourceLocation resid=&quot;meetingContactPaneUrl&quot;/&gt; &lt;/Action&gt; &lt;/Control&gt; &lt;/Group&gt; &lt;/OfficeTab&gt; &lt;/ExtensionPoint&gt; &lt;!-- Go to http://aka.ms/ExtensionPointsCommands to learn how to add more Extension Points: MessageRead, AppointmentOrganizer, AppointmentAttendee --&gt; &lt;/DesktopFormFactor&gt; &lt;/Host&gt; &lt;/Hosts&gt; &lt;Resources&gt; &lt;bt:Images&gt; &lt;bt:Image id=&quot;icon16&quot; DefaultValue=&quot;https://xxxxxx/assets/mm_icon_16.png&quot;/&gt; &lt;bt:Image id=&quot;icon32&quot; DefaultValue=&quot;https://xxxxxx/assets/mm_icon_32.png&quot;/&gt; &lt;bt:Image id=&quot;icon80&quot; DefaultValue=&quot;https://xxxxxx/assets/mm_icon_80.png&quot;/&gt; &lt;/bt:Images&gt; &lt;bt:Urls&gt; &lt;bt:Url id=&quot;functionFile&quot; DefaultValue=&quot;https://xxxxxx/beta/function-file/function-file.html&quot;/&gt; &lt;bt:Url id=&quot;messageReadTaskPaneUrl&quot; DefaultValue=&quot;https://xxxxxx/beta/index.html&quot;/&gt; &lt;bt:Url id=&quot;addActivityUrl&quot; DefaultValue=&quot;https://xxxxxx/beta/msg-compose/activity.html&quot;/&gt; &lt;bt:Url id=&quot;readEmailContactPaneUrl&quot; DefaultValue=&quot;https://xxxxxx/beta/contacts/index_mobile.html&quot;/&gt; &lt;bt:Url id=&quot;apptContactPaneUrl&quot; DefaultValue=&quot;https://xxxxxx/beta/contacts/index_mobile.html&quot;/&gt; &lt;bt:Url id=&quot;meetingContactPaneUrl&quot; DefaultValue=&quot;https://xxxxxx/beta/contacts/index_mobile.html&quot;/&gt; &lt;/bt:Urls&gt; &lt;bt:ShortStrings&gt; &lt;bt:String id=&quot;logMeetingLabel&quot; DefaultValue=&quot;Log Meeting&quot;&gt;&lt;/bt:String&gt; &lt;bt:String id=&quot;logActivityLabel&quot; DefaultValue=&quot;xxxxxxxxxxx Log Activity&quot;&gt;&lt;/bt:String&gt; &lt;bt:String id=&quot;groupLabel&quot; DefaultValue=&quot;xxxxxxxxxxx&quot;/&gt; &lt;bt:String id=&quot;customTabLabel&quot; DefaultValue=&quot;My Add-in Tab&quot;/&gt; &lt;bt:String id=&quot;paneReadButtonLabel&quot; DefaultValue=&quot;Display all properties&quot;/&gt; &lt;bt:String id=&quot;paneReadSuperTipTitle&quot; DefaultValue=&quot;Get all properties&quot;/&gt; &lt;bt:String id=&quot;addContactTitle&quot; DefaultValue=&quot;Add Contacts to xxxxxxxxxxx&quot;&gt;&lt;/bt:String&gt; &lt;bt:String id=&quot;addContactLabel&quot; DefaultValue=&quot;xxxxxxxxxxx&quot;&gt;&lt;/bt:String&gt; &lt;bt:String id=&quot;insertGistLabel&quot; DefaultValue=&quot;Log Email&quot;&gt;&lt;/bt:String&gt; &lt;bt:String id=&quot;insertGistTitle&quot; DefaultValue=&quot;Log Email&quot;&gt;&lt;/bt:String&gt; &lt;bt:String id=&quot;insertIconTitle&quot; DefaultValue=&quot;Log Email&quot;&gt;&lt;/bt:String&gt; &lt;bt:String id=&quot;insertDefaultGistLabel&quot; DefaultValue=&quot;Insert Default Gist&quot;&gt;&lt;bt:Override Locale=&quot;es-ES&quot; Value=&quot;Inserte el Gist predeterminado&quot;/&gt;&lt;/bt:String&gt; &lt;bt:String id=&quot;insertDefaultGistTitle&quot; DefaultValue=&quot;Insert Default Gist&quot;&gt;&lt;bt:Override Locale=&quot;es-ES&quot; Value=&quot;Inserte el Gist predeterminado&quot;/&gt;&lt;/bt:String&gt; &lt;/bt:ShortStrings&gt; &lt;bt:LongStrings&gt; &lt;bt:String id=&quot;logActivityDesc&quot; DefaultValue=&quot;Log activity to xxxxxxxxxxx&quot;&gt;&lt;/bt:String&gt; &lt;bt:String id=&quot;addContactDesc&quot; DefaultValue=&quot;Add/Update Contacts&quot;&gt;&lt;/bt:String&gt; &lt;bt:String id=&quot;paneReadSuperTipDescription&quot; DefaultValue=&quot;Opens a pane displaying available properties. This is an example of a button that opens a task pane.&quot;/&gt; &lt;bt:String id=&quot;insertGistDesc&quot; DefaultValue=&quot;Allows you to log emails to your xxxxxxxxxxx Account.&quot;&gt; &lt;bt:Override Locale=&quot;es-ES&quot; Value=&quot;Muestra una lista de sus Gists y permite insertar su contenido en el mensaje actual&quot;/&gt; &lt;/bt:String&gt; &lt;bt:String id=&quot;insertDefaultGistDesc&quot; DefaultValue=&quot;Inserts the contents of the Gist you mark as default into the current message&quot;&gt; &lt;bt:Override Locale=&quot;es-ES&quot; Value=&quot;Inserta el contenido de lo Gist que marca como predeterminado en el mensaje actual&quot;/&gt; &lt;/bt:String&gt; &lt;/bt:LongStrings&gt; &lt;/Resources&gt; &lt;VersionOverrides xmlns=&quot;http://schemas.microsoft.com/office/mailappversionoverrides/1.1&quot; xsi:type=&quot;VersionOverridesV1_1&quot;&gt; &lt;Requirements&gt; &lt;bt:Sets DefaultMinVersion=&quot;1.1&quot;&gt; &lt;bt:Set Name=&quot;Mailbox&quot; /&gt; &lt;/bt:Sets&gt; &lt;/Requirements&gt; &lt;Hosts&gt; &lt;Host xsi:type=&quot;MailHost&quot;&gt; &lt;DesktopFormFactor&gt; &lt;!-- Location of the Functions that UI-less buttons can trigger (ExecuteFunction Actions). --&gt; &lt;FunctionFile resid=&quot;functionFile&quot; /&gt; &lt;ExtensionPoint xsi:type=&quot;MessageReadCommandSurface&quot;&gt; &lt;OfficeTab id=&quot;TabDefault&quot;&gt; &lt;Group id=&quot;msgReadMMGroup&quot;&gt; &lt;Label resid=&quot;groupLabel&quot;/&gt; &lt;Control xsi:type=&quot;Button&quot; id=&quot;msgComposeAddContact&quot;&gt; &lt;Label resid=&quot;addContactLabel&quot;/&gt; &lt;Supertip&gt; &lt;Title resid=&quot;addContactTitle&quot;/&gt; &lt;Description resid=&quot;addContactDesc&quot;/&gt; &lt;/Supertip&gt; &lt;Icon&gt; &lt;bt:Image size=&quot;16&quot; resid=&quot;icon16&quot;/&gt; &lt;bt:Image size=&quot;32&quot; resid=&quot;icon32&quot;/&gt; &lt;bt:Image size=&quot;80&quot; resid=&quot;icon80&quot;/&gt; &lt;/Icon&gt; &lt;Action xsi:type=&quot;ShowTaskpane&quot;&gt; &lt;SourceLocation resid=&quot;readEmailContactPaneUrl&quot; /&gt; &lt;SupportsPinning&gt;true&lt;/SupportsPinning&gt; &lt;/Action&gt; &lt;/Control&gt; &lt;/Group&gt; &lt;/OfficeTab&gt; &lt;/ExtensionPoint&gt; &lt;ExtensionPoint xsi:type=&quot;MessageComposeCommandSurface&quot;&gt; &lt;OfficeTab id=&quot;TabDefault&quot;&gt; &lt;Group id=&quot;msgComposeCmdGroup&quot;&gt; &lt;Label resid=&quot;groupLabel&quot;/&gt; &lt;Control xsi:type=&quot;Button&quot; id=&quot;msgComposeInsertGist&quot;&gt; &lt;Label resid=&quot;insertGistLabel&quot;/&gt; &lt;Supertip&gt; &lt;Title resid=&quot;insertIconTitle&quot;/&gt; &lt;Description resid=&quot;insertGistDesc&quot;/&gt; &lt;/Supertip&gt; &lt;Icon&gt; &lt;bt:Image size=&quot;16&quot; resid=&quot;icon16&quot;/&gt; &lt;bt:Image size=&quot;32&quot; resid=&quot;icon32&quot;/&gt; &lt;bt:Image size=&quot;80&quot; resid=&quot;icon80&quot;/&gt; &lt;/Icon&gt; &lt;Action xsi:type=&quot;ShowTaskpane&quot;&gt; &lt;SourceLocation resid=&quot;addActivityUrl&quot; /&gt; &lt;SupportsPinning&gt;true&lt;/SupportsPinning&gt; &lt;/Action&gt; &lt;/Control&gt; &lt;/Group&gt; &lt;/OfficeTab&gt; &lt;/ExtensionPoint&gt; &lt;ExtensionPoint xsi:type=&quot;AppointmentAttendeeCommandSurface&quot;&gt; &lt;OfficeTab id=&quot;TabDefault&quot;&gt; &lt;Group id=&quot;apptAttendeeGroup&quot;&gt; &lt;Label resid=&quot;groupLabel&quot;/&gt; &lt;Control xsi:type=&quot;Button&quot; id=&quot;apptAttendeeOpenPaneButton&quot;&gt; &lt;Label resid=&quot;logActivityLabel&quot;/&gt; &lt;Supertip&gt; &lt;Title resid=&quot;logActivityLabel&quot;/&gt; &lt;Description resid=&quot;logActivityDesc&quot;/&gt; &lt;/Supertip&gt; &lt;Icon&gt; &lt;bt:Image size=&quot;16&quot; resid=&quot;icon16&quot;/&gt; &lt;bt:Image size=&quot;32&quot; resid=&quot;icon32&quot;/&gt; &lt;bt:Image size=&quot;80&quot; resid=&quot;icon80&quot;/&gt; &lt;/Icon&gt; &lt;Action xsi:type=&quot;ShowTaskpane&quot;&gt; &lt;SourceLocation resid=&quot;meetingContactPaneUrl&quot;/&gt; &lt;/Action&gt; &lt;/Control&gt; &lt;/Group&gt; &lt;/OfficeTab&gt; &lt;/ExtensionPoint&gt; &lt;ExtensionPoint xsi:type=&quot;AppointmentOrganizerCommandSurface&quot;&gt; &lt;OfficeTab id=&quot;TabDefault&quot;&gt; &lt;Group id=&quot;msgReadGroup&quot;&gt; &lt;Label resid=&quot;groupLabel&quot;/&gt; &lt;Control xsi:type=&quot;Button&quot; id=&quot;msgReadOpenPaneButton&quot;&gt; &lt;Label resid=&quot;logActivityLabel&quot;/&gt; &lt;Supertip&gt; &lt;Title resid=&quot;logActivityLabel&quot;/&gt; &lt;Description resid=&quot;logActivityDesc&quot;/&gt; &lt;/Supertip&gt; &lt;Icon&gt; &lt;bt:Image size=&quot;16&quot; resid=&quot;icon16&quot;/&gt; &lt;bt:Image size=&quot;32&quot; resid=&quot;icon32&quot;/&gt; &lt;bt:Image size=&quot;80&quot; resid=&quot;icon80&quot;/&gt; &lt;/Icon&gt; &lt;Action xsi:type=&quot;ShowTaskpane&quot;&gt; &lt;SourceLocation resid=&quot;meetingContactPaneUrl&quot;/&gt; &lt;/Action&gt; &lt;/Control&gt; &lt;/Group&gt; &lt;/OfficeTab&gt; &lt;/ExtensionPoint&gt; &lt;!-- Go to http://aka.ms/ExtensionPointsCommands to learn how to add more Extension Points: MessageRead, AppointmentOrganizer, AppointmentAttendee --&gt; &lt;/DesktopFormFactor&gt; &lt;MobileFormFactor&gt; &lt;FunctionFile resid=&quot;residUILessFunctionFileUrl&quot; /&gt; &lt;ExtensionPoint xsi:type=&quot;MobileMessageReadCommandSurface&quot;&gt; &lt;Group id=&quot;mobileMsgRead&quot;&gt; &lt;Label resid=&quot;groupLabel&quot; /&gt; &lt;Control xsi:type=&quot;MobileButton&quot; id=&quot;mobileMessageRead&quot;&gt; &lt;Label resid=&quot;addContactLabel&quot;/&gt; &lt;Icon xsi:type=&quot;bt:MobileIconList&quot;&gt; &lt;bt:Image size=&quot;25&quot; scale=&quot;1&quot; resid=&quot;icon32&quot; /&gt; &lt;bt:Image size=&quot;25&quot; scale=&quot;2&quot; resid=&quot;icon32&quot; /&gt; &lt;bt:Image size=&quot;25&quot; scale=&quot;3&quot; resid=&quot;icon32&quot; /&gt; &lt;bt:Image size=&quot;32&quot; scale=&quot;1&quot; resid=&quot;icon32&quot; /&gt; &lt;bt:Image size=&quot;32&quot; scale=&quot;2&quot; resid=&quot;icon32&quot; /&gt; &lt;bt:Image size=&quot;32&quot; scale=&quot;3&quot; resid=&quot;icon32&quot; /&gt; &lt;bt:Image size=&quot;48&quot; scale=&quot;1&quot; resid=&quot;icon80&quot; /&gt; &lt;bt:Image size=&quot;48&quot; scale=&quot;2&quot; resid=&quot;icon80&quot; /&gt; &lt;bt:Image size=&quot;48&quot; scale=&quot;3&quot; resid=&quot;icon80&quot; /&gt; &lt;/Icon&gt; &lt;Action xsi:type=&quot;ShowTaskpane&quot;&gt; &lt;SourceLocation resid=&quot;readEmailMobileContactPaneUrl&quot; /&gt; &lt;/Action&gt; &lt;/Control&gt; &lt;/Group&gt; &lt;/ExtensionPoint&gt; &lt;/MobileFormFactor&gt; &lt;/Host&gt; &lt;/Hosts&gt; &lt;Resources&gt; &lt;bt:Images&gt; &lt;bt:Image id=&quot;icon16&quot; DefaultValue=&quot;https://xxxxxx/assets/mm_icon_16.png&quot;/&gt; &lt;bt:Image id=&quot;icon32&quot; DefaultValue=&quot;https://xxxxxx/assets/mm_icon_32.png&quot;/&gt; &lt;bt:Image id=&quot;icon80&quot; DefaultValue=&quot;https://xxxxxx/assets/mm_icon_80.png&quot;/&gt; &lt;/bt:Images&gt; &lt;bt:Urls&gt; &lt;bt:Url id=&quot;functionFile&quot; DefaultValue=&quot;https://xxxxxx/beta/function-file/function-file.html&quot;/&gt; &lt;bt:Url id=&quot;messageReadTaskPaneUrl&quot; DefaultValue=&quot;https://xxxxxx/beta/index.html&quot;/&gt; &lt;bt:Url id=&quot;addActivityUrl&quot; DefaultValue=&quot;https://xxxxxx/beta/msg-compose/activity.html&quot;/&gt; &lt;bt:Url id=&quot;readEmailContactPaneUrl&quot; DefaultValue=&quot;https://xxxxxx/beta/contacts/index_mobile.html&quot;/&gt; &lt;bt:Url id=&quot;readEmailMobileContactPaneUrl&quot; DefaultValue=&quot;https://xxxxxx/beta/contacts/index_mobile.html&quot;/&gt; &lt;bt:Url id=&quot;meetingContactPaneUrl&quot; DefaultValue=&quot;https://xxxxxx/beta/contacts/index_mobile.html&quot;/&gt; &lt;/bt:Urls&gt; &lt;bt:ShortStrings&gt; &lt;bt:String id=&quot;logMeetingLabel&quot; DefaultValue=&quot;Log Meeting&quot;&gt;&lt;/bt:String&gt; &lt;bt:String id=&quot;logActivityLabel&quot; DefaultValue=&quot;xxxxxxxxxxx Log Activity&quot;&gt;&lt;/bt:String&gt; &lt;bt:String id=&quot;addContactTitle&quot; DefaultValue=&quot;Add Contacts to xxxxxxxxxxx&quot;&gt;&lt;/bt:String&gt; &lt;bt:String id=&quot;addContactLabel&quot; DefaultValue=&quot;xxxxxxxxxxx&quot;&gt;&lt;/bt:String&gt; &lt;bt:String id=&quot;groupLabel&quot; DefaultValue=&quot;xxxxxxxxxxx&quot;/&gt; &lt;bt:String id=&quot;customTabLabel&quot; DefaultValue=&quot;My Add-in Tab&quot;/&gt; &lt;bt:String id=&quot;paneReadButtonLabel&quot; DefaultValue=&quot;Display all properties&quot;/&gt; &lt;bt:String id=&quot;paneReadSuperTipTitle&quot; DefaultValue=&quot;Get all properties&quot;/&gt; &lt;bt:String id=&quot;insertGistLabel&quot; DefaultValue=&quot;Log Email&quot;&gt;&lt;/bt:String&gt; &lt;bt:String id=&quot;insertGistTitle&quot; DefaultValue=&quot;Log Email&quot;&gt;&lt;/bt:String&gt; &lt;bt:String id=&quot;insertIconTitle&quot; DefaultValue=&quot;Log Email&quot;&gt;&lt;/bt:String&gt; &lt;/bt:ShortStrings&gt; &lt;bt:LongStrings&gt; &lt;bt:String id=&quot;logActivityDesc&quot; DefaultValue=&quot;Log activity to xxxxxxxxxxx&quot;&gt;&lt;/bt:String&gt; &lt;bt:String id=&quot;addContactDesc&quot; DefaultValue=&quot;Add/Update Contacts&quot;&gt;&lt;/bt:String&gt; &lt;bt:String id=&quot;paneReadSuperTipDescription&quot; DefaultValue=&quot;Log Email&quot;/&gt; &lt;bt:String id=&quot;insertGistDesc&quot; DefaultValue=&quot;Allows you to log emails to your xxxxxxxxxxx Account.&quot; /&gt; &lt;bt:String id=&quot;insertDefaultGistDesc&quot; DefaultValue=&quot;Log Email&quot; /&gt; &lt;/bt:LongStrings&gt; &lt;/Resources&gt; &lt;ExtendedPermissions&gt; &lt;ExtendedPermission&gt;AppendOnSend&lt;/ExtendedPermission&gt; &lt;/ExtendedPermissions&gt; &lt;/VersionOverrides&gt; &lt;/VersionOverrides&gt; &lt;/OfficeApp&gt; </code></pre>
[ { "answer_id": 74410259, "author": "Max R", "author_id": 19662289, "author_profile": "https://Stackoverflow.com/users/19662289", "pm_score": 1, "selected": false, "text": "=SUMIF( B$2:B2, B2, C$2:C2 )" }, { "answer_id": 74416403, "author": "P.b", "author_id": 12634230, "author_profile": "https://Stackoverflow.com/users/12634230", "pm_score": 0, "selected": false, "text": "=LET(f,ISNUMBER(C:C),\n c,FILTER(C:C,f),\n d,FILTER(D:D,f),\n s,SEQUENCE(COUNTA(d)),\nMMULT(\n (d=TRANSPOSE(d))*(s>=TRANSPOSE(s)),\n c))\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/331165/" ]
74,409,784
<p>I have a dataframe in pyspark that looks like this</p> <pre><code>+------------------+--------------------+ | Community_Area| Date| +------------------+--------------------+ | New City|09/05/2015 01:30:...| | Austin|09/04/2015 11:30:...| | New City|09/05/2015 12:01:...| | Avondale|09/05/2015 12:45:...| | Austin|09/04/2015 01:00:...| | Auburn Gresham|09/05/2015 10:55:...| | West Town|09/04/2015 06:00:...| | Avondale|09/05/2015 01:00:...| </code></pre> <p>I'm trying to add a count column so that if a community_area shows up more than once on the same day, that count will increase as below, first appearance as 1 seems like the right way.</p> <pre><code> +------------------+--------------------+-----------+ | Community_Area| Date| Count | +------------------+--------------------+-----------+ | New City|09/05/2015 01:30:...| 1 | | Austin|09/04/2015 11:30:...| 1 | | New City|09/05/2015 12:01:...| 2 | | Avondale|09/05/2015 12:45:...| 1 | | Austin|09/04/2015 01:00:...| 2 | | Auburn Gresham|09/05/2015 10:55:...| 1 | | West Town|09/04/2015 06:00:...| 1 | | Avondale|09/05/2015 01:00:...| 2 | </code></pre> <p>...</p> <p>The goal is to add a rolling 7-day sum column using the window function so the final table has 3 columns (Community, Date, Rolling 7-day sum).</p> <p>My initial approach is to use the count column to use in the window function.</p> <p>The code I've used to do that is</p> <pre><code>df4b = df4b.groupby([&quot;Community_Area&quot;, &quot;Date&quot;])[&quot;Community_Area&quot;].count().reset_index(name=&quot;count&quot;) df4b.show() </code></pre>
[ { "answer_id": 74410259, "author": "Max R", "author_id": 19662289, "author_profile": "https://Stackoverflow.com/users/19662289", "pm_score": 1, "selected": false, "text": "=SUMIF( B$2:B2, B2, C$2:C2 )" }, { "answer_id": 74416403, "author": "P.b", "author_id": 12634230, "author_profile": "https://Stackoverflow.com/users/12634230", "pm_score": 0, "selected": false, "text": "=LET(f,ISNUMBER(C:C),\n c,FILTER(C:C,f),\n d,FILTER(D:D,f),\n s,SEQUENCE(COUNTA(d)),\nMMULT(\n (d=TRANSPOSE(d))*(s>=TRANSPOSE(s)),\n c))\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20381469/" ]
74,409,785
<p>I'd like to find the rows that group A and group B have the same values in the <code>feature</code> column and the <code>value</code> column.</p> <p>My data:</p> <pre><code> group feature value 1 A f1 1 2 B f1 1 3 A f2 1 4 B f2 0 5 A f3 0 6 B f3 1 df = data.frame(group = rep(c(&quot;A&quot;, &quot;B&quot;), 3), feature = c(&quot;f1&quot;, &quot;f1&quot;, &quot;f2&quot;, &quot;f2&quot;, &quot;f3&quot;, &quot;f3&quot;), value = c(1,1,1,0,0,1)) </code></pre> <p>Desired outputs:</p> <ol> <li>Shared:</li> </ol> <pre><code> group feature value 1 A f1 1 2 B f1 1 </code></pre> <ol start="2"> <li>Group-specific:</li> </ol> <pre><code> group feature value 1 A f2 1 2 B f2 0 3 A f3 0 4 B f3 1 </code></pre> <p>I've got the results by doing it manually:</p> <ol> <li>split the dataframe by the <code>group</code> column --&gt; get two dataframe, one only has group <code>A</code> and another only has group <code>B</code>.</li> <li>create a new column <code>feature_value</code> using <code>paste(df$feature, df$value, sep = &quot;_&quot;)</code>.</li> <li>use <code>intersect</code> and <code>setdiff</code> to find the shared and group-specific <code>feature_value</code>.</li> <li>filter the orginal <code>df</code> using the extracted <code>feature_value</code>.</li> </ol> <p>This is laborious and I hope there is a better way.</p>
[ { "answer_id": 74410333, "author": "diomedesdata", "author_id": 10366237, "author_profile": "https://Stackoverflow.com/users/10366237", "pm_score": 1, "selected": false, "text": "data.table" }, { "answer_id": 74410371, "author": "zephryl", "author_id": 17303805, "author_profile": "https://Stackoverflow.com/users/17303805", "pm_score": 3, "selected": true, "text": "feature" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7816373/" ]
74,409,795
<p>i got this weird error in my app yesterday when i try to run it and i cant quite understand how to fix it. it shows a lot of error line, this wasnt happen before and i dont know what went wrong. here's the error</p> <pre><code>Invalid depfile: D:\Kuliah\Mata Kuliah\Pemrograman Mobile\medreminder.dart_tool\flutter_build\0e1b116fd39faa66306b0a2d36ef7692\kernel_snapshot.d Invalid depfile: D:\Kuliah\Mata Kuliah\Pemrograman Mobile\medreminder.dart_tool\flutter_build\0e1b116fd39faa66306b0a2d36ef7692\kernel_snapshot.d /D:/Software/Flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/js-0.6.4/lib/js.dart:8:1: Error: Not found: 'dart:js' export 'dart:js' show allowInterop, allowInteropCaptureThis; ^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/plugin_registry.dart:66:8: Error: Method not found: 'webOnlySetPluginHandler'. ui.webOnlySetPluginHandler(handleFrameworkMessage); ^^^^^^^^^^^^^^^^^^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/utils.dart:7:7: Error: Type 'AnchorElement' not found.final AnchorElement _urlParsingNode = AnchorElement(); ^^^^^^^^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/utils.dart:20:7: Error: Type 'Element' not found. final Element? _baseElement = document.querySelector('base'); ^^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/utils.dart:7:7: Error: 'AnchorElement' isn't a type. final AnchorElement _urlParsingNode = AnchorElement(); ^^^^^^^^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/utils.dart:7:39: Error: Method not found: 'AnchorElement'. final AnchorElement _urlParsingNode = AnchorElement(); ^^^^^^^^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/utils.dart:20:7: Error: 'Element' isn't a type. final Element? _baseElement = document.querySelector('base'); ^^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/utils.dart:20:31: Error: Undefined name 'document'. final Element? _baseElement = document.querySelector('base'); ^^^^^^^^ lib/main.dart:7:8: Error: Not found: 'dart:html' import 'dart:html' as html; ^ lib/Reminder/ui/home_reminder.dart:8:8: Error: Not found: 'dart:html' import 'dart:html' as html; ^ /D:/Software/Flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/flutter_native_timezone-2.0.0/lib/flutter_native_timezone_web.dart:2:8: Error: Not found: 'dart:html' import 'dart:html' as html; ^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:13:8: Error: Not found: 'dart:html' import 'dart:html' as html; ^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:6:8: Error: Not found: 'dart:html' import 'dart:html' as html; ^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/utils.dart:5:8: Error: Not found: 'dart:html' import 'dart:html'; ^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:193:3: Error: Type 'html.Location' not found. html.Location get _location =&gt; html.window.location; ^^^^^^^^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:195:3: Error: Type 'html.History' not found. html.History get _history =&gt; html.window.history; ^^^^^^^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:198:28: Error: Type 'html.EventListener' not found. void addPopStateListener(html.EventListener fn) { ^^^^^^^^^^^^^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:203:31: Error: Type 'html.EventListener' not found. void removePopStateListener(html.EventListener fn) { ^^^^^^^^^^^^^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:193:39: Error: Undefined name 'window'. html.Location get _location =&gt; html.window.location; ^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:195:37: Error: Undefined name 'window'. html.History get history =&gt; html.window.history; ^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:198:33: Error: 'EventListener' isn't a type. void addPopStateListener(html.EventListener fn) { ^^^^^^^^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:199:10: Error: Undefined name 'window'. html.window.addEventListener('popstate', fn); ^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:203:36: Error: 'EventListener' isn't a type. void removePopStateListener(html.EventListener fn) { ^^^^^^^^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:204:10: Error: Undefined name 'window'. html.window.removeEventListener('popstate', fn); ^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:79:48: Error: Type 'html.EventListener' not found. external ui.VoidCallback addPopStateListener(html.EventListener fn); ^^^^^^^^^^^^^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:48:14: Error: Method not found: 'allowInterop'. getPath: allowInterop(strategy.getPath), ^^^^^^^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:49:15: Error: Method not found: 'allowInterop'. getState: allowInterop(strategy.getState), ^^^^^^^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:50:26: Error: Method not found: 'allowInterop'. addPopStateListener: allowInterop(strategy.addPopStateListener), ^^^^^^^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:51:25: Error: Method not found: 'allowInterop'. prepareExternalUrl: allowInterop(strategy.prepareExternalUrl), ^^^^^^^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:52:16: Error: Method not found: 'allowInterop'. pushState: allowInterop(strategy.pushState), ^^^^^^^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:53:19: Error: Method not found: 'allowInterop'. replaceState: allowInterop(strategy.replaceState), ^^^^^^^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:54:9: Error: Method not found: 'allowInterop'. go: allowInterop(strategy.go), ^^^^^^^^^^^^ /D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:79:53: Error: 'EventListener' isn't a type. external ui.VoidCallback addPopStateListener(html.EventListener fn); ^^^^^^^^^^^^^ U nhandled exception: FileSystemException(uri=org-dartlang-u ntranslatable-uri:dart%3Ahtml; message=StandardFileSystem only supports file:* and data:* URIs) #0 StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file syst em.dart:34:7) #1 asFileUri (package:vm/kernel_front_end.dart:659:37) #2 writeDepfile (package:vm/kernel_front_end.dart:799 :21) #3 FrontendCompiler.compile (package:frontend_s erver/frontend_server.dart:625:9) #4 starter (package:frontend_server/frontend_server.dart:1451:12) #5 main (file:///C:/b/s/w/ir/x/w/sdk/pkg/frontend_serv er/bin/frontend_server_starter.dart:10:14) </code></pre> <p>a lot of this error have &quot;Error: Not found: 'dart:html' import 'dart:html' as html;&quot; i look for a way to fix it, a lot suggest to delete import dart:html in my folder, when i do that the error still the same . if anyone know how to fix this please help it would mean so much to me. thankyou</p>
[ { "answer_id": 74409851, "author": "Gwhyyy", "author_id": 18670641, "author_profile": "https://Stackoverflow.com/users/18670641", "pm_score": 0, "selected": false, "text": "flutter clean\nflutter packages get\ndart pub get\n" }, { "answer_id": 74410020, "author": "Tim Brückner", "author_id": 1151983, "author_profile": "https://Stackoverflow.com/users/1151983", "pm_score": 0, "selected": false, "text": "dart:html" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20229067/" ]
74,409,801
<p>I have a .env that is used to create k8s secrets as a file. Before creating the secret, I have to set the values in it as per the environment for the respective keys. I am trying to use Terraform's Kubernetes provider for secret creation. Outside of Terraform, we have ways like scripting to set the.env file, and then pass it for the secret creation. However, is there a way of setting up a .env file using terraform?</p> <p>Terraform secret construct</p> <pre><code>data &quot;kubernetes_secret&quot; &quot;test-env&quot; { metadata { name = &quot;app-env&quot; } data = { &quot;app.env&quot; = filebase64(&quot;./tomcat/app.env&quot;) } } resource &quot;kubernetes_secret&quot; &quot;test-env&quot; { metadata { name = &quot;app-env&quot; namespace = &quot;test-deployment&quot; } type = &quot;Opaque&quot; data = &quot;{data.kubernetes_secret.test-env.template}&quot; } </code></pre> <p>app.env (*_value to be replaced before the secret creation)</p> <pre><code>JAVA_OPTS =&quot;java_opts_value&quot; NGINX_VERSION=&quot;nginx_version_value&quot; TOMCAT_VERSION=&quot;tomcat_version_value&quot; POSTGRES_VERSION=&quot;postgres_version_value&quot; </code></pre> <p>I am new to Terraform and any guidance would be appreciated.</p>
[ { "answer_id": 74437740, "author": "Martin Atkins", "author_id": 281848, "author_profile": "https://Stackoverflow.com/users/281848", "pm_score": 0, "selected": false, "text": "locals {\n env_values = {\n JAVA_OPTS = \"java_opts_value\"\n NGINX_VERSION = \"nginx_version_value\"\n TOMCAT_VERSION = \"tomcat_version_value\"\n POSTGRES_VERSION = \"postgres_version_value\"\n }\n\n env_file_content = <<EOT\n%{ for k, v in local.env_values ~}\n${k}=${format(\"%q\", v)}\n%{ endfor ~}\nEOT\n}\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5877576/" ]
74,409,805
<p>For example:</p> <pre><code>input [TOTAL_CH-1:0] start_frame_i, // start of frame </code></pre> <p>Change to:</p> <pre><code>input [TOTAL_CH-1:0] i_start_frame, // start of frame </code></pre> <p>Add on to clarify: There are many different strings are like above.</p>
[ { "answer_id": 74409954, "author": "SaSkY", "author_id": 18104248, "author_profile": "https://Stackoverflow.com/users/18104248", "pm_score": 3, "selected": true, "text": "cat file.txt | sed -r 's/(\\w+)_i\\b/i_\\1/g'\n" }, { "answer_id": 74410835, "author": "ghoti", "author_id": 1072112, "author_profile": "https://Stackoverflow.com/users/1072112", "pm_score": 0, "selected": false, "text": "bash" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409805", "https://Stackoverflow.com", "https://Stackoverflow.com/users/981714/" ]
74,409,817
<p>What regex do I use to select the first instance of a string in single quotes when the line contains multiple comma separated single quote values ?</p> <p>There could be multiple lines and <strong>I want to match <em>first instance</em> on <em>each line</em></strong>.</p> <p><code>‘(.*?)’</code> selects all instances so the lazy quantified is not working exactly as I expected</p> <p>Here’s an example of <a href="https://regexr.com/727sp" rel="nofollow noreferrer">what I’m seeing</a>:</p> <pre class="lang-none prettyprint-override"><code>Fucntion(12345, 'ThisOneOnly', 'NotThis', 'NotThisEither'); Fucntion(12345, 'ThisOneOnly', 'NotThis', 'NotThisEither'); Fucntion(12345, 'ThisOneOnly', 'NotThis', 'NotThisEither'); </code></pre>
[ { "answer_id": 74409954, "author": "SaSkY", "author_id": 18104248, "author_profile": "https://Stackoverflow.com/users/18104248", "pm_score": 3, "selected": true, "text": "cat file.txt | sed -r 's/(\\w+)_i\\b/i_\\1/g'\n" }, { "answer_id": 74410835, "author": "ghoti", "author_id": 1072112, "author_profile": "https://Stackoverflow.com/users/1072112", "pm_score": 0, "selected": false, "text": "bash" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5487094/" ]
74,409,835
<p>I need to read the user's name from a “Form” text input and display it somewhere on the page in a greeting message i.e. Hello (user). I need to use the “Form” input and extract the user’s name from the URL using the query string. I also need to read the query string when the page is loaded, not when the button is pressed i.e. need to write a function for the <code>onload</code> event This all must be done in one HTML file not two separate HTML files. Any help will be appreciated!</p> <pre><code> &lt;form&gt; &lt;input type=&quot;text&quot; name=&quot;user_name&quot; placeholder=&quot;Enter your name!&quot;&gt; &lt;button type=&quot;submit&quot;&gt;Apply!&lt;/button&gt; &lt;/form&gt; </code></pre>
[ { "answer_id": 74410031, "author": "KylianJay", "author_id": 17792463, "author_profile": "https://Stackoverflow.com/users/17792463", "pm_score": 0, "selected": false, "text": " <!DOCTYPE html>\n<html>\n<head>\n</head>\n<body>\n <h1 id=\"h1\">Hello World</h1>\n\n <form> \n <input type=\"text\" name=\"user_name\" placeholder=\"Enter your name!\" id=\"input\"> \n <button type=\"submit\">Apply!</button> \n </form> \n <script>\n // update the body h1 element with real-time user input\n function updateH1() {\n var h1 = document.getElementById(\"h1\");\n var input = document.getElementById(\"input\");\n h1.innerHTML = input.value;\n }\n // call updateH1() when the user types in the input element\n function init() {\n var input = document.getElementById(\"input\");\n input.addEventListener(\"keyup\", updateH1);\n }\n // call init() when the page loads\n window.addEventListener(\"load\", init);\n </script>\n</body>\n</html>\n" }, { "answer_id": 74410400, "author": "user2182349", "author_id": 2182349, "author_profile": "https://Stackoverflow.com/users/2182349", "pm_score": 2, "selected": true, "text": "// use the ids to access the elements in the DOM\nconst userName = document.getElementById(\"user-name\");\nconst output = document.getElementById(\"output\");\n\n// if there query string is not empty\nif (location.search !== '') {\n\n // get the parameters\n const params = new URLSearchParams(location.search);\n \n // pick out the user name\n const un = params.get(\"user_name\");\n \n // update the input and the display\n output.textContent = userName.value = un;\n}" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20481542/" ]
74,409,839
<p>I want to scrape Congressional stock trades from <a href="https://www.capitoltrades.com/trades" rel="nofollow noreferrer">Capitol Trades</a>. I can scrape the data, but the column that contains stock tickers has a span tag that separates company names from company tickers. <code>pandas.read_html()</code> removes this span tag, which concatenates company names and tickers and makes it difficult to recover tickers.</p> <p>For example, company names that end with an &quot;INC&quot; suffix run into tickers, which are also capital letters. See my example below with &quot;INC&quot; and &quot;AE&quot;.</p> <p><a href="https://i.stack.imgur.com/xSQey.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xSQey.png" alt="INC and AE" /></a></p> <p>Here is where I found the span tag:</p> <p><a href="https://i.stack.imgur.com/uiEjW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uiEjW.png" alt="span tag" /></a></p> <p>Company tickers are 1 to 5 characters in length, and I have failed to regex tickers because there are many varieties of company suffixes (e.g., &quot;INC&quot;, &quot;CORP&quot;, &quot;PLC&quot;, &quot;SE&quot;, etc.), and not all company names have suffixes.</p> <p>How can I either replace span tags with whitespace to separate company names and tickers or parse the span as another column?</p> <p>Here is my code:</p> <pre class="lang-py prettyprint-override"><code> import pandas as pd import yfinance as yf from selenium import webdriver from bs4 import BeautifulSoup import time import datetime def get_url(page=1, pageSize=50, assetType='stock'): if page == 1: return f'https://www.capitoltrades.com/trades?assetType={assetType}&amp;pageSize={pageSize}' elif page &gt; 1: return f'https://www.capitoltrades.com/trades?assetType={assetType}&amp;page={page}&amp;pageSize={pageSize}' else: return None driver = webdriver.Firefox() driver.get(get_url(page=1)) driver.implicitly_wait(10) time.sleep(1) soup = BeautifulSoup(driver.page_source, 'lxml') tables = soup.find_all('table') table = pd.read_html(str(tables))[0] driver.close() </code></pre>
[ { "answer_id": 74410031, "author": "KylianJay", "author_id": 17792463, "author_profile": "https://Stackoverflow.com/users/17792463", "pm_score": 0, "selected": false, "text": " <!DOCTYPE html>\n<html>\n<head>\n</head>\n<body>\n <h1 id=\"h1\">Hello World</h1>\n\n <form> \n <input type=\"text\" name=\"user_name\" placeholder=\"Enter your name!\" id=\"input\"> \n <button type=\"submit\">Apply!</button> \n </form> \n <script>\n // update the body h1 element with real-time user input\n function updateH1() {\n var h1 = document.getElementById(\"h1\");\n var input = document.getElementById(\"input\");\n h1.innerHTML = input.value;\n }\n // call updateH1() when the user types in the input element\n function init() {\n var input = document.getElementById(\"input\");\n input.addEventListener(\"keyup\", updateH1);\n }\n // call init() when the page loads\n window.addEventListener(\"load\", init);\n </script>\n</body>\n</html>\n" }, { "answer_id": 74410400, "author": "user2182349", "author_id": 2182349, "author_profile": "https://Stackoverflow.com/users/2182349", "pm_score": 2, "selected": true, "text": "// use the ids to access the elements in the DOM\nconst userName = document.getElementById(\"user-name\");\nconst output = document.getElementById(\"output\");\n\n// if there query string is not empty\nif (location.search !== '') {\n\n // get the parameters\n const params = new URLSearchParams(location.search);\n \n // pick out the user name\n const un = params.get(\"user_name\");\n \n // update the input and the display\n output.textContent = userName.value = un;\n}" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/334755/" ]
74,409,881
<p>I have the following array of array of objects that is a result of a <code>CloudWatch</code> query using <code>AWS-SDK-V3 JS</code>:</p> <pre><code>const respCW = [ [ { field: '@timestamp', value: '2022-10-25 15:30:36.685' }, { field: '@message', value: 'foo' }, { field: '@ptr', value: 'xxxxxxxxxxxxxxxxxxxxxxxxxx' } ], [ { field: '@timestamp', value: '2022-10-25 15:04:56.155' }, { field: '@message', value: 'bar' }, { field: '@ptr', value: 'xxxxxxxxxxxxxxxxxxxxxxxxxx' } ] ] </code></pre> <p>I would lie to convert that array to the following:</p> <pre><code>const desiredResp = [ { timestamp: '2022-10-25 15:30:36.685', message: 'foo' }, { timestamp: '2022-10-25 15:04:56.155', message: 'bar' } ] </code></pre> <p>I have created the following code:</p> <pre><code>if(respCW.length&gt;0){ respCW.forEach( arrOfObje=&gt; { let logObj = { timestamp:&quot;&quot;, message:&quot;&quot;, } arrOfObje.forEach(obj =&gt; { if(obj.field === '@timestamp' || obj.field === '@message'){ if(obj.field === '@timestamp'){ date = new Date(obj.value) logObj.timestamp = date.getTime() } if(obj.field === '@message'){ logObj.message = obj.value newResult.push(logObj) } } }) }) } </code></pre> <p>The code is working but I would like to know if there is a way to redesign it using array map or reduce.</p>
[ { "answer_id": 74410031, "author": "KylianJay", "author_id": 17792463, "author_profile": "https://Stackoverflow.com/users/17792463", "pm_score": 0, "selected": false, "text": " <!DOCTYPE html>\n<html>\n<head>\n</head>\n<body>\n <h1 id=\"h1\">Hello World</h1>\n\n <form> \n <input type=\"text\" name=\"user_name\" placeholder=\"Enter your name!\" id=\"input\"> \n <button type=\"submit\">Apply!</button> \n </form> \n <script>\n // update the body h1 element with real-time user input\n function updateH1() {\n var h1 = document.getElementById(\"h1\");\n var input = document.getElementById(\"input\");\n h1.innerHTML = input.value;\n }\n // call updateH1() when the user types in the input element\n function init() {\n var input = document.getElementById(\"input\");\n input.addEventListener(\"keyup\", updateH1);\n }\n // call init() when the page loads\n window.addEventListener(\"load\", init);\n </script>\n</body>\n</html>\n" }, { "answer_id": 74410400, "author": "user2182349", "author_id": 2182349, "author_profile": "https://Stackoverflow.com/users/2182349", "pm_score": 2, "selected": true, "text": "// use the ids to access the elements in the DOM\nconst userName = document.getElementById(\"user-name\");\nconst output = document.getElementById(\"output\");\n\n// if there query string is not empty\nif (location.search !== '') {\n\n // get the parameters\n const params = new URLSearchParams(location.search);\n \n // pick out the user name\n const un = params.get(\"user_name\");\n \n // update the input and the display\n output.textContent = userName.value = un;\n}" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3788767/" ]
74,409,902
<p>For a homework assignment we are to calculate the perimeter of a triangle with one function: <code>perimeter()</code></p> <p>Then we are supposed to calculate the area of a triangle with the second function: <code>area()</code></p> <p>Then we are supposed to create a third function called: <code>perimeterArea()</code> that calls the functions <code>perimeter()</code> and <code>area()</code>.</p> <p>We are then supposed to <code>cout</code> the <code>perimeterArea()</code> function so it looks like this:</p> <pre class="lang-none prettyprint-override"><code>Its perimeter is 12 Its area is 6 </code></pre> <p>I am looking for help on how to create the <code>perimeterArea()</code> function, and how to output it correctly.</p> <p>Currently the program won't run.</p> <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt; #include &lt;cmath&gt; using namespace std; // Function prototypes double perimeter (double, double, double, double&amp;); //memory allocation// double area (double, double, double, double&amp;, double&amp;, double&amp;); // memory allocatation // void perimeterArea (double&amp;, double&amp;); // memory allocation // // Beginning of Main Function int main () { double side1, side2, side3, trianglePerimeter, s, triangleArea; // memory allocation // char yes; do { // Starts loop cout &lt;&lt; &quot;Enter the lengths of the three sides of a triangle -- &quot;; cin &gt;&gt; side1 &gt;&gt; side2 &gt;&gt; side3; perimeterArea (trianglePerimeter, triangleArea) ; // Doesn't work! //or/// perimeterArea (perimeter, area); // second idea cout &lt;&lt; &quot;Its perimeter is &quot; &lt;&lt; trianglePerimeter &lt;&lt; endl; cout &lt;&lt; &quot;Its area is &quot; &lt;&lt; triangleArea &lt;&lt; endl; // End program loop requirement cout &lt;&lt; endl; cout &lt;&lt; &quot;Run again (Y/N)? &quot;; cin &gt;&gt; yes; } while (tolower(yes) == 'y'); cout &lt;&lt; &quot;Good bye!&quot;; } // calculate perimeter function double perimeter (double side1, double side2, double side3, double&amp; trianglePerimeter) { trianglePerimeter = (side1 + side2 + side3); return trianglePerimeter; } // calculate area function double area (double side1, double side2, double side3, double&amp; trianglePerimeter, double&amp; s, double&amp; triangleArea) { s = trianglePerimeter / 2; triangleArea = sqrt (s*(s-side1)*(s-side2)*(s-side3)); return triangleArea; } // calculate perimeterArea function void perimeterArea (double&amp; trianglePerimeter, double&amp; triangleArea) { Call previous perimeter function?; call previous area function?; Output through some type of statement in int main () } </code></pre> <p>I need help with the syntax for calling two functions with a new function and inputting. Not sure what to try, however.</p> <p>I previously tried:</p> <pre class="lang-cpp prettyprint-override"><code>void perimeterArea (double&amp; trianglePerimeter, double&amp; triangleArea) </code></pre> <p>But I do not know where to go from there.</p>
[ { "answer_id": 74410031, "author": "KylianJay", "author_id": 17792463, "author_profile": "https://Stackoverflow.com/users/17792463", "pm_score": 0, "selected": false, "text": " <!DOCTYPE html>\n<html>\n<head>\n</head>\n<body>\n <h1 id=\"h1\">Hello World</h1>\n\n <form> \n <input type=\"text\" name=\"user_name\" placeholder=\"Enter your name!\" id=\"input\"> \n <button type=\"submit\">Apply!</button> \n </form> \n <script>\n // update the body h1 element with real-time user input\n function updateH1() {\n var h1 = document.getElementById(\"h1\");\n var input = document.getElementById(\"input\");\n h1.innerHTML = input.value;\n }\n // call updateH1() when the user types in the input element\n function init() {\n var input = document.getElementById(\"input\");\n input.addEventListener(\"keyup\", updateH1);\n }\n // call init() when the page loads\n window.addEventListener(\"load\", init);\n </script>\n</body>\n</html>\n" }, { "answer_id": 74410400, "author": "user2182349", "author_id": 2182349, "author_profile": "https://Stackoverflow.com/users/2182349", "pm_score": 2, "selected": true, "text": "// use the ids to access the elements in the DOM\nconst userName = document.getElementById(\"user-name\");\nconst output = document.getElementById(\"output\");\n\n// if there query string is not empty\nif (location.search !== '') {\n\n // get the parameters\n const params = new URLSearchParams(location.search);\n \n // pick out the user name\n const un = params.get(\"user_name\");\n \n // update the input and the display\n output.textContent = userName.value = un;\n}" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20120602/" ]
74,409,911
<p>I'm looking for a way to print all the phone numbers (10 digit number) in column <code>Phone_num</code> of table <code>Customer</code> that has digit 5 6 7 in 5th 6th 7th position in the whole number, using <code>SELECT FROM WHERE</code> format.</p>
[ { "answer_id": 74409920, "author": "Shawn Bragdon", "author_id": 19753194, "author_profile": "https://Stackoverflow.com/users/19753194", "pm_score": 1, "selected": false, "text": "SELECT * FROM table WHERE number ~ '^[0-9]{4}567[0-9]{3}$'\n" }, { "answer_id": 74409958, "author": "qwerty13579", "author_id": 20482489, "author_profile": "https://Stackoverflow.com/users/20482489", "pm_score": 3, "selected": true, "text": "select phone_num from customer where substring(phone_num, 5, 3) = '567'\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18265893/" ]
74,409,933
<p>I cannot figure out why this is returning 1 instead of 7.</p> <pre><code> const getNextEventCountTest = () =&gt; { let sum = 0; let q = 0; do { sum = sum + 0.5 } while (sum &lt; 4){ q = q + 1; } return q; }; </code></pre> <p>do-while is good here, since I want to always run the first code block but only conditionally increment q.</p> <p>But this:</p> <pre><code>console.log(getNextEventCountTest()); =&gt; 1 </code></pre> <p>whereas this has the right behavior:</p> <pre><code>const getNextEventCountTest = () =&gt; { let sum = 0; let q = 0; // this is desired behavior: while (sum &lt; 4){ sum = sum + 0.5 if(sum &lt; 4){ q = q + 1; } } return q; }; </code></pre>
[ { "answer_id": 74409920, "author": "Shawn Bragdon", "author_id": 19753194, "author_profile": "https://Stackoverflow.com/users/19753194", "pm_score": 1, "selected": false, "text": "SELECT * FROM table WHERE number ~ '^[0-9]{4}567[0-9]{3}$'\n" }, { "answer_id": 74409958, "author": "qwerty13579", "author_id": 20482489, "author_profile": "https://Stackoverflow.com/users/20482489", "pm_score": 3, "selected": true, "text": "select phone_num from customer where substring(phone_num, 5, 3) = '567'\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1223975/" ]
74,409,934
<p>Each time I click enter when typing in the form, the app refreshes.</p> <p>I am trying to capture the input of the form as a value and set the state as that value.</p> <pre><code>&lt;form&gt; &lt;input value={input} disabled={!channelId} onChange={(e) =&gt; setInput(e.target.value)} placeholder=&quot;what's on your mind...&quot; /&gt; &lt;button type=&quot;submit&quot; disabled={!channelId} className=&quot;chat__inputButton&quot; &gt; Send &lt;/button&gt; &lt;/form&gt; </code></pre> <p>Here is the code. I have tried to manipulate the code using preventDefault(), but that isn't keeping the app from refreshing.</p> <p>For reference, I am following along with this tutorial: <a href="https://www.youtube.com/watch?v=zc1loX80TX8" rel="nofollow noreferrer">https://www.youtube.com/watch?v=zc1loX80TX8</a></p> <p>I tried using preventDefault(), but that didn't work.</p> <p>When I remove onChange from the input, I am not able to type in the input form.</p>
[ { "answer_id": 74409920, "author": "Shawn Bragdon", "author_id": 19753194, "author_profile": "https://Stackoverflow.com/users/19753194", "pm_score": 1, "selected": false, "text": "SELECT * FROM table WHERE number ~ '^[0-9]{4}567[0-9]{3}$'\n" }, { "answer_id": 74409958, "author": "qwerty13579", "author_id": 20482489, "author_profile": "https://Stackoverflow.com/users/20482489", "pm_score": 3, "selected": true, "text": "select phone_num from customer where substring(phone_num, 5, 3) = '567'\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19066133/" ]
74,409,961
<p>got a question that I hope is easy to answer!</p> <p>I'm self teaching myself C# right now - I do know JavaScript and PHP so far. One thing I've been struggling with is how to deal with List&lt;&gt;, Dictionary&lt;&gt; etc, with regard to actually initiating these things - if that makes sense.</p> <p>So for example, I have the record:</p> <pre><code> record Beat(string beat, int note, List&lt;int&gt; loc, bool powerup); </code></pre> <p>but I'm having the hardest of time actually declaring this record. For example, I tried this:</p> <pre><code>Beat beat = new Beat(&quot;00:00&quot;, 2, [200,400], true); </code></pre> <p>or even</p> <pre><code>Beat beat = new Beat(&quot;00:00, 2, new(200,400), true); </code></pre> <p>which both produce errors and I just can't figure out how i'm supposed to declare this.</p> <p>So I appreciate any help or pointing in the right direction. I tried to Google it but couldn't formulate the query correctly! :)</p>
[ { "answer_id": 74409991, "author": "ESG", "author_id": 1251127, "author_profile": "https://Stackoverflow.com/users/1251127", "pm_score": 3, "selected": true, "text": "Beat beat = new Beat(\"00:00\", 2, new List<int> { 200, 400 }, true);\n" }, { "answer_id": 74410030, "author": "qwerty13579", "author_id": 20482489, "author_profile": "https://Stackoverflow.com/users/20482489", "pm_score": 1, "selected": false, "text": " Beat b = new Beat { beat = \"xxx\", note = 100, loc = new List<int>() { 1, 2, 5 }, powerup = false };\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74409961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15006497/" ]
74,410,011
<p>How can I generate a Random (N*M) 0's and 1's Matrix in which the sum of each row equals to 10? (in python using numpy)</p> <p>for example for <code>10*10(N*M)</code> matrix we can use:</p> <pre><code>import numpy as np np.random.randint(2, size=(10, 10)) </code></pre> <p>but I want sum of each rows equals to 10</p>
[ { "answer_id": 74410079, "author": "Warren Weckesser", "author_id": 1217358, "author_profile": "https://Stackoverflow.com/users/1217358", "pm_score": 2, "selected": false, "text": "In [29]: rng = np.random.default_rng(121263137472525314065)\n\nIn [30]: n_rows = 5\n\nIn [31]: n_cols = 20\n\nIn [32]: n_ones = 10\n\nIn [33]: rng.multivariate_hypergeometric([1]*n_cols, n_ones, size=n_rows)\nOut[33]: \narray([[0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1],\n [1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0],\n [0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1],\n [0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1],\n [1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0]])\n" }, { "answer_id": 74410088, "author": "Joran Beasley", "author_id": 541038, "author_profile": "https://Stackoverflow.com/users/541038", "pm_score": 0, "selected": false, "text": "def make_thing(n):\n if n <= 10:\n return np.ones((10,10))\n \n matrix = np.zeros((n, n))\n for row in range(n):\n ten_random_index = random.sample(range(n),10)\n matrix[row][ten_random_index] = 1\n return matrix\n" }, { "answer_id": 74410221, "author": "hilberts_drinking_problem", "author_id": 4585963, "author_profile": "https://Stackoverflow.com/users/4585963", "pm_score": 1, "selected": false, "text": "import numpy as np\n\nn_rows = 5\nn_cols = 20\nn_ones = 10\n\narr = np.tile(np.repeat([0, 1], [n_ones, n_cols-n_ones]), (n_rows,1))\n# [[0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1]\n# [0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1]\n# [0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1]\n# [0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1]\n# [0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1]]\nnp.apply_along_axis(np.random.shuffle, 1, arr) # operates on arr inplace\n# [[1 1 0 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 1]\n# [1 0 1 1 0 1 1 0 0 0 1 0 1 0 1 1 0 0 1 0]\n# [1 1 0 1 0 0 0 1 0 0 1 1 0 0 1 0 1 1 1 0]\n# [1 0 0 1 0 0 0 1 0 0 1 1 0 1 1 0 1 0 1 1]\n# [1 1 1 0 1 0 1 0 1 0 1 0 1 0 0 1 1 0 0 0]]\n" }, { "answer_id": 74410365, "author": "Sachin Nayak", "author_id": 8191861, "author_profile": "https://Stackoverflow.com/users/8191861", "pm_score": 0, "selected": false, "text": "def matrix_generator(n_rows, n_columns):\n if n_columns < 10:\n print('Number of rows need to be greater than or equal to 10.')\n return 0\n \n row_list = [1,1,1,1,1,1,1,1,1,1]\n add_columns = n_columns-10\n\n for i in range(add_columns):\n row_list.append(0)\n \n matrix = [[]]*n_rows\n \n for i in range(n_rows):\n random.shuffle(row_list)\n matrix[i] = row_list[:]\n \n random.shuffle(matrix)\n \n return matrix\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74410011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20482557/" ]
74,410,034
<p>Have a dataset for determining interrater reliability. Trying to restructure my data from wide to long form. Here is my data.</p> <pre><code>Subject Rater Item_1 Item_2 AB 1 6 4 AB 2 5 5 CD 1 4 5 CD 2 6 5 EF 1 4 4 EF 2 7 5 </code></pre> <p>I want to restructure it so that it looks like this:</p> <pre><code>Subject Item Rater_1 Rater_2 AB 1 6 5 AB 2 4 5 CD 1 4 6 CD 2 5 5 EF 1 4 7 EF 2 4 5 </code></pre> <p>I've tried <code>pivot_longer</code> but am unable to separate &quot;rater&quot; into two columns. Any ideas?</p>
[ { "answer_id": 74410082, "author": "Ronak Shah", "author_id": 3962914, "author_profile": "https://Stackoverflow.com/users/3962914", "pm_score": 2, "selected": false, "text": "library(dplyr)\nlibrary(tidyr)\n\n#Thanks to @Dan Adams for the `NA` trick. \ndf %>%\n pivot_longer(cols = starts_with('Item'), \n names_to = c(NA, 'Item'), \n names_sep = \"_\") %>%\n pivot_wider(names_from = Rater, values_from = value, names_prefix = \"Rater_\")\n\n# Subject Item Rater_1 Rater_2\n# <chr> <chr> <int> <int>\n#1 AB 1 6 5\n#2 AB 2 4 5\n#3 CD 1 4 6\n#4 CD 2 5 5\n#5 EF 1 4 7\n#6 EF 2 4 5\n" }, { "answer_id": 74414444, "author": "AndS.", "author_id": 9778513, "author_profile": "https://Stackoverflow.com/users/9778513", "pm_score": 0, "selected": false, "text": "Map(\\(s) {\n x <- subset(df, df$Subject == s)\n x[,c(\"Item_1\", \"Item_2\")] <- t(x[,c(\"Item_1\", \"Item_2\")])\n colnames(x) <- c(\"Subject\", \"Item\", \"Rater_1\", \"Rater_2\")\n x\n}, unique(df$Subject)) |>\n do.call(what = rbind)\n#> # A tibble: 6 x 4\n#> Subject Item Rater_1 Rater_2\n#> * <chr> <dbl> <dbl> <dbl>\n#> 1 AB 1 6 5\n#> 2 AB 2 4 5\n#> 3 CD 1 4 6\n#> 4 CD 2 5 5\n#> 5 EF 1 4 7\n#> 6 EF 2 4 5\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74410034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17518136/" ]
74,410,037
<p>I am looking to mutate data into one column seperated by &quot;,&quot;</p> <p>I can do this if I name each input column, but is there a way to do it without having to type out each V1...V11?</p> <pre><code>input = mtcars colnames(input) = c('V1','V2','V3','V4','V5','V6','V7','V8','V9','V10','V11') joined = mutate(output11, join = paste(V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11, sep = &quot;,&quot;)) output = select(joined, join) </code></pre>
[ { "answer_id": 74410051, "author": "Ronak Shah", "author_id": 3962914, "author_profile": "https://Stackoverflow.com/users/3962914", "pm_score": 4, "selected": true, "text": "tidyr::unite" }, { "answer_id": 74411013, "author": "TarJae", "author_id": 13321647, "author_profile": "https://Stackoverflow.com/users/13321647", "pm_score": 0, "selected": false, "text": "rowwise" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74410037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20384402/" ]
74,410,083
<p>I am trying to figure out a way to reset the cumulative counting every time I reach &quot;SI&quot;.</p> <p>For example i am doing a running total of word &quot;NO&quot; , if there are some blanks then result should be blank, if there is a &quot;NO&quot; after blank then it again start doing running count of &quot;No&quot;, only it reset at word &quot;SI&quot;.</p> <p>I have write this formula</p> <p>=IF(OR(E3=&quot;SI&quot;,E3=&quot;&quot;),&quot;&quot;,IF(E2=&quot;No&quot;,G2+1,IF(E3=&quot;No&quot;,COUNTA(E3))))</p> <p>which working as here in the picture</p> <p><a href="https://i.stack.imgur.com/B8Snx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B8Snx.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74411568, "author": "aclayden", "author_id": 20175535, "author_profile": "https://Stackoverflow.com/users/20175535", "pm_score": 0, "selected": false, "text": "=IF(E3=\"No\", IF(G2=\"\", 1, G2+1), \"\")\n" }, { "answer_id": 74411978, "author": "Tom Sharpe", "author_id": 3894917, "author_profile": "https://Stackoverflow.com/users/3894917", "pm_score": 1, "selected": false, "text": "=IF(E3=\"NO\",1,\"\")\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74410083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17635658/" ]
74,410,117
<p>I have a string that is received over Ethernet and I want to convert the string to std::float_t data.<br> I'm using <code>std::regex_replace</code> to strip out all non-digit, non-decimal, non-sign (plus, minus) and replace with empty string.<br> When I execute the <code>std::regex_replace</code>, it only returns digits.<br> Code</p> <pre><code>std::string::size_type sz; const std::regex e(&quot;[(\D)|(^+-.)]&quot;); // matches not digit, decimal point (.), plus sign, minus sign std::string numeric_string = std::regex_replace(temporary_recieve_data, e, &quot;&quot;); std::float_t value = std::stof(numeric_string, &amp;sz); </code></pre>
[ { "answer_id": 74410864, "author": "rici", "author_id": 1566221, "author_profile": "https://Stackoverflow.com/users/1566221", "pm_score": 2, "selected": false, "text": "\\D" }, { "answer_id": 74412354, "author": "shy45", "author_id": 20313707, "author_profile": "https://Stackoverflow.com/users/20313707", "pm_score": 1, "selected": false, "text": "const std::regex e(R\"([^-+.\\d])\");\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74410117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6319901/" ]
74,410,129
<p>I get these error. what do i do?</p> <p>`</p> <pre><code>import React, { useState } from &quot;react&quot;; import &quot;./App.css&quot;; import { Button } from &quot;@mui/material&quot;; //declaring the colors const colorSequence = [ { &quot;color&quot;: &quot;#3db44b&quot; }, { &quot;color&quot;: &quot;#bfef45&quot; }, { &quot;color&quot;: &quot;#42d3f4&quot; }, { &quot;color&quot;: &quot;#4263d8&quot; }, { &quot;color&quot;: &quot;#f68232&quot; }, { &quot;color&quot;: &quot;#fee118&quot; }, { &quot;color&quot;: &quot;#e6194a&quot; }, { &quot;color&quot;: &quot;#f032e6&quot; }, { &quot;color&quot;: &quot;#921eb3&quot; } ] function App() { const [colors, setColors] = useState([]) //shuffle the colors const shuffleColors = () =&gt; { const shuffledColors = [...colorSequence] .sort(() =&gt; Math.random() - 0.5) .map((color) =&gt; ({ ...color, id: Math.random() })) setColors(shuffledColors) } setColors(shuffledColors) returns an error of </code></pre> <p>Argument of type '{ id: number; color: string; }[]' is not assignable to parameter of type 'SetStateAction&lt;never[]&gt;'. Type '{ id: number; color: string; }[]' is not assignable to type 'never[]'. Type '{ id: number; color: string; }' is not assignable to type 'never'.ts(2345)</p> <pre><code> [![enter image description here](https://i.stack.imgur.com/1nWXL.png)](https://i.stack.imgur.com/1nWXL.png) </code></pre>
[ { "answer_id": 74410147, "author": "kind user", "author_id": 6695924, "author_profile": "https://Stackoverflow.com/users/6695924", "pm_score": 1, "selected": false, "text": "const [colors, setColors] = useState<{ color: string; id?: number }[]>([]);\n" }, { "answer_id": 74410155, "author": "Mohanad", "author_id": 3759355, "author_profile": "https://Stackoverflow.com/users/3759355", "pm_score": 2, "selected": true, "text": "colors" }, { "answer_id": 74410204, "author": "Yadav Shiv", "author_id": 19021757, "author_profile": "https://Stackoverflow.com/users/19021757", "pm_score": 0, "selected": false, "text": "const [colors, setColors] = useState<{ color: string, id: number }[]>([]);\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74410129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20242528/" ]
74,410,131
<p>for an assignment I have to implement my own floats. They are working for many possible combinations of inputs i could think of, so I set out to make a JUnit test with random values. Now I encountered some trouble with dynamically setting the delta value in the method call assertEquals(String message, Double expected, Double actual, Double delta).</p> <p>This is my test method:</p> <pre><code>@Test public void testRandomMath() { DoubleStream doubleStream = ThreadLocalRandom.current().doubles(100); //limiting the doubles to be withing a workable range for my ownFloat class double[] doubles = doubleStream.map(d -&gt; { if (ThreadLocalRandom.current().nextBoolean()) { return d * -1d; } else { return d; } }).map(d -&gt; d * Math.pow(2, ThreadLocalRandom.current().nextInt(-8, 9))).toArray(); OwnFloat[] ownFloats = new OwnFloat[doubles.length]; for (int i = 0; i &lt; doubles.length; i++) { ownFloats[i] = new OwnFloat(doubles[i]); } for (int i = 0; i &lt; doubles.length; i++) { for (int j = 0; j &lt; doubles.length; j++) { assertEquals(&quot;Failed &quot; + doubles[i] + &quot; + &quot; + doubles[j],doubles[i] + doubles[j], ownFloats[i].add(ownFloats[j]).toDouble(), Math.min(doubles[i], doubles[j])); assertEquals(&quot;Failed &quot; + doubles[i] + &quot; - &quot; + doubles[j], doubles[i] - doubles[j], ownFloats[i].sub(ownFloats[j]).toDouble(), Math.min(doubles[i], doubles[j])); } } } </code></pre> <p>And this is the test error:</p> <pre><code>java.lang.AssertionError: Failed -0.01393084463838419 + -0.01393084463838419 Expected :-0.02786168927676838 Actual :-0.027861595153808594 </code></pre> <p>What am I getting wrong about how the delta works? What could I use instead of the minimum of the inputs as delta value?</p> <p>Kind regards, Lantanar</p>
[ { "answer_id": 74410147, "author": "kind user", "author_id": 6695924, "author_profile": "https://Stackoverflow.com/users/6695924", "pm_score": 1, "selected": false, "text": "const [colors, setColors] = useState<{ color: string; id?: number }[]>([]);\n" }, { "answer_id": 74410155, "author": "Mohanad", "author_id": 3759355, "author_profile": "https://Stackoverflow.com/users/3759355", "pm_score": 2, "selected": true, "text": "colors" }, { "answer_id": 74410204, "author": "Yadav Shiv", "author_id": 19021757, "author_profile": "https://Stackoverflow.com/users/19021757", "pm_score": 0, "selected": false, "text": "const [colors, setColors] = useState<{ color: string, id: number }[]>([]);\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74410131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14623254/" ]
74,410,187
<p>I have a Django Form where users inserts numeric values. I am sending the Ajax to a url but I keep receiving:</p> <pre><code>TypeError: addlog() missing 1 required positional argument: 'id' </code></pre> <p>I have tried to add the id in the url I got:</p> <pre><code>Reverse for 'addlog' with arguments '(2,)' not found. 1 pattern(s) tried: ['workout/addlog/\\Z'] </code></pre> <p>Here is the views:</p> <pre><code>def addlog(request, id): workout = get_object_or_404(Workout, id=id) url = request.META.get('HTTP_REFERER') active_session = ActiveSession.objects.get(id=ActiveSession.objects.last().id) if request.headers.get('x-requested-with') == 'XMLHttpRequest' and request.method == 'POST': form = LogForm(request.POST) if form.is_valid(): data = Log() data.log_workout = request.POST.get('log_workout') data.save() context = { 'log_workout': data.log_workout, 'id': workout.id, } html = render_to_string('my_gym/log_form.html', context, request=request) return JsonResponse({'form': html}) else: print(&quot;The errors in addlog:&quot;,form.errors.as_data()) else: print(&quot;What happened??&quot;) return HttpResponseRedirect(url) </code></pre> <p>Here is the form:</p> <pre><code> &lt;form class=&quot;review-form&quot; action=&quot;{% url 'my_gym:addlog' object.id %}&quot; method=&quot;post&quot;&gt; {% csrf_token %} &lt;/form&gt; </code></pre> <p>Here is the script:</p> <pre><code>&lt;script type=&quot;text/javascript&quot;&gt; $(document).ready(function(event){ $(document).on('click','#submitlog', function(event){ event.preventDefault(); var log_workout = $('#id_log_workout').val(); $.ajax({ type:'POST', url:'{% url 'my_gym:addlog' object.id %}', data:{'log_workout' : log_workout, csrfmiddlewaretoken':'{{csrf_token}}'}, dataType:'json', success:function(response){ $('#log_form').html(response['form']), console.log($('#log_form').html(response['form','div'])); }, error:function(rs, e){ console.log(rs.responseText); }, }); }); }); &lt;/script&gt; </code></pre> <p>Here is the url:</p> <pre><code> path('workout/addlog/&lt;int:id&gt;', addlog, name='addlog'), </code></pre> <p>Here is the traceback:</p> <pre><code>Internal Server Error: /workout/addlog/2 Traceback (most recent call last): File &quot;C:\Users\User\Desktop\Project\venv\lib\site-packages\django\core\handlers\exception.py&quot;, line 55, in inner response = get_response(request) File &quot;C:\Users\User\Desktop\Project\venv\lib\site-packages\django\core\handlers\base.py&quot;, line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File &quot;C:\Users\User\Desktop\Project\my_gym\views.py&quot;, line 291, in addlog html = render_to_string('my_gym/log_form.html', context, request=request) File &quot;C:\Users\User\Desktop\Project\venv\lib\site-packages\django\template\loader.py&quot;, line 62, in render_to_string return template.render(context, request) File &quot;C:\Users\User\Desktop\Project\venv\lib\site-packages\django\template\backends\django.py&quot;, line 62, in render return self.template.render(context) File &quot;C:\Users\User\Desktop\Project\venv\lib\site-packages\django\template\base.py&quot;, line 175, in render return self._render(context) File &quot;C:\Users\User\Desktop\Project\venv\lib\site-packages\django\template\base.py&quot;, line 167, in _render return self.nodelist.render(context) File &quot;C:\Users\User\Desktop\Project\venv\lib\site-packages\django\template\base.py&quot;, line 1005, in render return SafeString(&quot;&quot;.join([node.render_annotated(context) for node in self])) File &quot;C:\Users\User\Desktop\Project\venv\lib\site-packages\django\template\base.py&quot;, line 1005, in &lt;listcomp&gt; return SafeString(&quot;&quot;.join([node.render_annotated(context) for node in self])) File &quot;C:\Users\User\Desktop\Project\venv\lib\site-packages\django\template\base.py&quot;, line 966, in render_annotated return self.render(context) File &quot;C:\Users\User\Desktop\Project\venv\lib\site-packages\django\template\defaulttags.py&quot;, line 472, in render url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app) File &quot;C:\Users\User\Desktop\Project\venv\lib\site-packages\django\urls\base.py&quot;, line 88, in reverse return resolver._reverse_with_prefix(view, prefix, *args, **kwargs) File &quot;C:\Users\User\Desktop\Project\venv\lib\site-packages\django\urls\resolvers.py&quot;, line 828, in _reverse_with_prefix raise NoReverseMatch(msg) </code></pre> <p>My question</p> <p>How can I fix this error knowing that I tried changing the workout.id to object.id still same error.</p>
[ { "answer_id": 74410147, "author": "kind user", "author_id": 6695924, "author_profile": "https://Stackoverflow.com/users/6695924", "pm_score": 1, "selected": false, "text": "const [colors, setColors] = useState<{ color: string; id?: number }[]>([]);\n" }, { "answer_id": 74410155, "author": "Mohanad", "author_id": 3759355, "author_profile": "https://Stackoverflow.com/users/3759355", "pm_score": 2, "selected": true, "text": "colors" }, { "answer_id": 74410204, "author": "Yadav Shiv", "author_id": 19021757, "author_profile": "https://Stackoverflow.com/users/19021757", "pm_score": 0, "selected": false, "text": "const [colors, setColors] = useState<{ color: string, id: number }[]>([]);\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74410187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13176726/" ]
74,410,190
<p>I have a table like this</p> <p><a href="https://i.stack.imgur.com/q4Jmy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q4Jmy.png" alt="enter image description here" /></a></p> <p>TRX_NUMBER is a invoice, and this field have a return number inside of the invoice.</p> <p>And I want to select table and join to the same table use CUSTOMER_TRX_ID and PREVIOUS_CUSTOMER_TRX_ID as the connection (ON)</p> <p>And the result what I want</p> <p><a href="https://i.stack.imgur.com/1ZhYf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1ZhYf.png" alt="enter image description here" /></a></p> <p>Can you help me about this ?</p>
[ { "answer_id": 74411288, "author": "Littlefoot", "author_id": 9097906, "author_profile": "https://Stackoverflow.com/users/9097906", "pm_score": 2, "selected": true, "text": "SQL> with invoice (customer_trx_id, trx_number, previous_customer_trx_id) as\n 2 (select 81196, 'ARR05-09', 22089 from dual union all\n 3 select 22089, 'IJU86-09', null from dual union all\n 4 select 13931, 'IJU07-09', null from dual\n 5 )\n" }, { "answer_id": 74411320, "author": "Slonsoid", "author_id": 20474992, "author_profile": "https://Stackoverflow.com/users/20474992", "pm_score": 0, "selected": false, "text": "SELECT t1.TRX_NUMBER AS TRX_NUMBER, t2.TRX_NUMBER AS RETUR\nFROM INVOICE t1\nLEFT JOIN INVOICE t2 ON t1.CUSTOMER_TRX_ID = t2.PREVIOUS_CUSTOMER_TRX_ID\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74410190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20328169/" ]
74,410,224
<p>here is the code and when I run code it's print my result correctly but there is a null as result (in line 4) :</p> <pre><code> main() { var ferrari = Car(); ferrari.armor = 85; print(ferrari.armor); } class Car { int? _armor; int? get armor { return _armor; } set armor(int? armor) { if (armor != null &amp;&amp; armor &lt; 100) { print(true); } else { print(false); } } </code></pre>
[ { "answer_id": 74411288, "author": "Littlefoot", "author_id": 9097906, "author_profile": "https://Stackoverflow.com/users/9097906", "pm_score": 2, "selected": true, "text": "SQL> with invoice (customer_trx_id, trx_number, previous_customer_trx_id) as\n 2 (select 81196, 'ARR05-09', 22089 from dual union all\n 3 select 22089, 'IJU86-09', null from dual union all\n 4 select 13931, 'IJU07-09', null from dual\n 5 )\n" }, { "answer_id": 74411320, "author": "Slonsoid", "author_id": 20474992, "author_profile": "https://Stackoverflow.com/users/20474992", "pm_score": 0, "selected": false, "text": "SELECT t1.TRX_NUMBER AS TRX_NUMBER, t2.TRX_NUMBER AS RETUR\nFROM INVOICE t1\nLEFT JOIN INVOICE t2 ON t1.CUSTOMER_TRX_ID = t2.PREVIOUS_CUSTOMER_TRX_ID\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74410224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14901385/" ]
74,410,231
<p>So I'm self-studying a compiler's textbook and I'm getting the hang of it but I have a question regarding compilation of simple high level expressions, such as <code>52 + -10</code>, to x86-64 (AT&amp;T).</p> <p>Consider the following expressions:</p> <p><code>10 + 32</code> generates the following assembly:</p> <pre><code> .globl main main: movq $10, %rax addq $32, %rax retq </code></pre> <p>but this next expression <code>52 + -10</code> generates the following x86-64 assembly:</p> <pre><code> .globl main main: pushq %rbp movq %rsp, %rbp subq $16, %rsp movq $10, -8(%rbp) negq -8(%rbp) movq -8(%rbp), %rax addq $52, %rax addq $16, %rsp popq %rbp retq </code></pre> <p>My understanding is the following. To compile a high level expression such as <code>52 + -10</code> you need to remove complex operands so you need to make intermediate variables to compile, such as:</p> <pre><code>tmp_0 = -10 52 + temp_0 </code></pre> <p>So I am guessing that the difference lies in the fact that there's intermediate variables involved. In the book in relation to this example (ie <code>52 + -10</code>) it says:</p> <blockquote> <p>We exhibit the use of memory for storing intermediate results in the next example. Figure 2.7 lists an x86 program that computes 52 + -10. This program uses a region of memory called the procedure call stack (stack for short).</p> </blockquote> <p>So I'm wondering why the expression <code>52 + -10</code> uses the stack (due to the intermediate variable) and why <code>10 + 32</code> doesn't. The stack, a region of memory is used to store the intermediate variables but I want to know WHY.</p> <p>Thanks.</p>
[ { "answer_id": 74410303, "author": "chez93", "author_id": 15403542, "author_profile": "https://Stackoverflow.com/users/15403542", "pm_score": 1, "selected": false, "text": "subq $16, %rsp" }, { "answer_id": 74410403, "author": "Peter Cordes", "author_id": 224132, "author_profile": "https://Stackoverflow.com/users/224132", "pm_score": 2, "selected": false, "text": "clang -O0" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74410231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15403542/" ]
74,410,242
<p>I'm trying to obtain the variable with the highest number so basically this are the variables:</p> <pre><code>number_no = 17 number_yes = 2 number_dontknow = 10 </code></pre> <p>I would like to know with one is the highest I was using max(number_no, number_yes) but it gave me the number and I need the variable name, so I would like to have something like:</p> <pre><code>highest_variable = max(number_no, number_yes) if highest_variable == number_no: total = sum(number_no + number_yes + number_dontknow) percentage = number_no/total print(percentage+ &quot;%&quot;) #Show percentage to use it in another function if else highest_variable == number_yes: total = sum(number_no + number_yes + number_dontknow) percentage = number_yes/total print(percentage+ &quot;%&quot;) #Show percentage to use it in another function </code></pre>
[ { "answer_id": 74410303, "author": "chez93", "author_id": 15403542, "author_profile": "https://Stackoverflow.com/users/15403542", "pm_score": 1, "selected": false, "text": "subq $16, %rsp" }, { "answer_id": 74410403, "author": "Peter Cordes", "author_id": 224132, "author_profile": "https://Stackoverflow.com/users/224132", "pm_score": 2, "selected": false, "text": "clang -O0" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74410242", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16239103/" ]
74,410,254
<p>I've the following data structure:</p> <pre><code>id flag date 101 A may 101 A jun 101 1 jul 101 A aug 101 1 sep 101 2 oct 101 3 nov 201 A jun 201 A jul </code></pre> <p>I want to create variable based off flag values and count the frequency of occurrence in SQL.</p> <p>I'm trying to use window functions over id ordering by date and the resultant data set is like this:</p> <pre><code>id flag_1 flag_2 flag_3 flag_else 101 2 1 1 2 201 0 0 0 2 </code></pre> <p>Any suggestions how to achieve this on SQL</p>
[ { "answer_id": 74410762, "author": "Shiva", "author_id": 3007402, "author_profile": "https://Stackoverflow.com/users/3007402", "pm_score": 0, "selected": false, "text": "SELECT\n id,\n flag_1,\n flag_2,\n flag_3,\n (flag_all - flag_1 - flag_2 - flag_3) AS flag_else\nFROM\n (\n SELECT\n id,\n flag_1,\n flag_2,\n flag_3,\n flag_all\n FROM\n (\n SELECT\n id,\n cardinality(array_positions(array_agg(flag), '1')) AS flag_1,\n cardinality(array_positions(array_agg(flag), '2')) AS flag_2,\n cardinality(array_positions(array_agg(flag), '3')) AS flag_3,\n cardinality(array_agg(flag)) AS flag_all\n FROM\n flags\n GROUP BY\n id\n ) t\n ) t2;\n" }, { "answer_id": 74444336, "author": "ahmed", "author_id": 12705912, "author_profile": "https://Stackoverflow.com/users/12705912", "pm_score": 3, "selected": true, "text": "SELECT id,\n COUNT(CASE WHEN flag='1' THEN 1 END) AS flag_1,\n COUNT(CASE WHEN flag='2' THEN 1 END) AS flag_2,\n COUNT(CASE WHEN flag='3' THEN 1 END) AS flag_3,\n COUNT(CASE WHEN flag NOT IN ('1','2','3') THEN 1 END) AS flag_else\nFROM table_name\nGROUP BY id\nORDER BY id\n" }, { "answer_id": 74463289, "author": "d r", "author_id": 19023353, "author_profile": "https://Stackoverflow.com/users/19023353", "pm_score": 0, "selected": false, "text": "SELECT ID \"ID\",\n Sum(FLAG_1) \"FLAG_1\", Sum(FLAG_2) \"FLAG_2\", Sum(FLAG_3) \"FLAG_3\", Sum(FLAG_ELSE) \"FLAG_ELSE\"\nFROM( SELECT * FROM tbl \n MODEL Partition By (ID) \n Dimension By (A_DATE) \n Measures (FLAG, 0 \"FLAG_1\", 0 \"FLAG_2\", 0 \"FLAG_3\", 0 \"FLAG_ELSE\")\n Rules (FLAG_1[ANY] = Count(1)[CASE FLAG[CV()] WHEN '1' THEN CV() ELSE 'XXX' END],\n FLAG_2[ANY] = Count(1)[CASE FLAG[CV()] WHEN '2' THEN CV() ELSE 'XXX' END],\n FLAG_3[ANY] = Count(1)[CASE FLAG[CV()] WHEN '3' THEN CV() ELSE 'XXX' END],\n FLAG_ELSE[ANY] = Count(1)[CASE WHEN FLAG[CV()] NOT IN('1', '2', '3') THEN CV() ELSE 'XXX' END])\n )\nGROUP BY ID\nORDER BY ID\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74410254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1696975/" ]
74,410,261
<p>So, I'm trying to read a .sav file using python and turn it into a .csv. I already got my code to read .sav files, and I also checked it with a test .sav, which I managed to turn into a csv. I then went on to use the real .sav file, and not it no longer works. Here is the code:</p> <pre><code>import pyreadstat df, meta = pyreadstat.read_sav('./RaceDatas.sav') df.to_csv('BloodRace.csv', index=False) </code></pre> <p>Here is the error:</p> <pre><code>runfile('C:/Users/usuario/Desktop/Python tests/ARK Projects/no.py', wdir='C:/Users/usuario/Desktop/Python tests/ARK Projects') Traceback (most recent call last): File &quot;C:\Program Files\Spyder\pkgs\spyder_kernels\py3compat.py&quot;, line 356, in compat_exec exec(code, globals, locals) File &quot;c:\users\usuario\desktop\python tests\ark projects\no.py&quot;, line 3, in &lt;module&gt; df, meta = pyreadstat.read_sav('./RaceDatas.sav') File &quot;pyreadstat\pyreadstat.pyx&quot;, line 364, in pyreadstat.pyreadstat.read_sav File &quot;pyreadstat\_readstat_parser.pyx&quot;, line 1099, in pyreadstat._readstat_parser.run_conversion File &quot;pyreadstat\_readstat_parser.pyx&quot;, line 867, in pyreadstat._readstat_parser.run_readstat_parser File &quot;pyreadstat\_readstat_parser.pyx&quot;, line 797, in pyreadstat._readstat_parser.check_exit_status ReadstatError: Invalid file, or file has unsupported features </code></pre> <p>Does anyone know what can be the problem? I thought perhaps it was the way in which the .sav I'm trying out is structured in a weird way, but its structured like normal.</p> <p>The .sav itself is 451 KB</p> <p>I tried with a simple .sav file, and it worked like intended. I tried with the main code, and it didn't work. I'm expecting it to at least turn the .sav into a python/pandas data frame to then turn into a .csv</p>
[ { "answer_id": 74410762, "author": "Shiva", "author_id": 3007402, "author_profile": "https://Stackoverflow.com/users/3007402", "pm_score": 0, "selected": false, "text": "SELECT\n id,\n flag_1,\n flag_2,\n flag_3,\n (flag_all - flag_1 - flag_2 - flag_3) AS flag_else\nFROM\n (\n SELECT\n id,\n flag_1,\n flag_2,\n flag_3,\n flag_all\n FROM\n (\n SELECT\n id,\n cardinality(array_positions(array_agg(flag), '1')) AS flag_1,\n cardinality(array_positions(array_agg(flag), '2')) AS flag_2,\n cardinality(array_positions(array_agg(flag), '3')) AS flag_3,\n cardinality(array_agg(flag)) AS flag_all\n FROM\n flags\n GROUP BY\n id\n ) t\n ) t2;\n" }, { "answer_id": 74444336, "author": "ahmed", "author_id": 12705912, "author_profile": "https://Stackoverflow.com/users/12705912", "pm_score": 3, "selected": true, "text": "SELECT id,\n COUNT(CASE WHEN flag='1' THEN 1 END) AS flag_1,\n COUNT(CASE WHEN flag='2' THEN 1 END) AS flag_2,\n COUNT(CASE WHEN flag='3' THEN 1 END) AS flag_3,\n COUNT(CASE WHEN flag NOT IN ('1','2','3') THEN 1 END) AS flag_else\nFROM table_name\nGROUP BY id\nORDER BY id\n" }, { "answer_id": 74463289, "author": "d r", "author_id": 19023353, "author_profile": "https://Stackoverflow.com/users/19023353", "pm_score": 0, "selected": false, "text": "SELECT ID \"ID\",\n Sum(FLAG_1) \"FLAG_1\", Sum(FLAG_2) \"FLAG_2\", Sum(FLAG_3) \"FLAG_3\", Sum(FLAG_ELSE) \"FLAG_ELSE\"\nFROM( SELECT * FROM tbl \n MODEL Partition By (ID) \n Dimension By (A_DATE) \n Measures (FLAG, 0 \"FLAG_1\", 0 \"FLAG_2\", 0 \"FLAG_3\", 0 \"FLAG_ELSE\")\n Rules (FLAG_1[ANY] = Count(1)[CASE FLAG[CV()] WHEN '1' THEN CV() ELSE 'XXX' END],\n FLAG_2[ANY] = Count(1)[CASE FLAG[CV()] WHEN '2' THEN CV() ELSE 'XXX' END],\n FLAG_3[ANY] = Count(1)[CASE FLAG[CV()] WHEN '3' THEN CV() ELSE 'XXX' END],\n FLAG_ELSE[ANY] = Count(1)[CASE WHEN FLAG[CV()] NOT IN('1', '2', '3') THEN CV() ELSE 'XXX' END])\n )\nGROUP BY ID\nORDER BY ID\n" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74410261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19401453/" ]
74,410,270
<p>Following is my numpy array.</p> <pre><code>import numpy as np arr = np.array([1,2,3,4,5]) arrc=arr arrc[arr&lt;3]=3 </code></pre> <p>When I run</p> <pre><code>&gt;&gt;&gt; arrc output : array([3,3,3,4,5]) &gt;&gt;&gt; arr output : array([3,3,3,4,5]) </code></pre> <p>I expected changing arrc does not affect arr. However, both array is changing. In my actual code I am changing arrc multiple times so I observe error if arrc have influence to arr. Is there any good way to fix this?</p>
[ { "answer_id": 74410277, "author": "Royadma", "author_id": 20476279, "author_profile": "https://Stackoverflow.com/users/20476279", "pm_score": 1, "selected": false, "text": "a[1,2] = \"some value\"\n" }, { "answer_id": 74410311, "author": "Austin", "author_id": 8472377, "author_profile": "https://Stackoverflow.com/users/8472377", "pm_score": 0, "selected": false, "text": ".copy()" } ]
2022/11/12
[ "https://Stackoverflow.com/questions/74410270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16188807/" ]