qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,170,940
<p>I know the difference between the two clearly.</p> <p>Concurrency is performing multiple tasks alternately, while parallelism is performing multiple tasks at once.</p> <p>However, there is confusion in this code because a certain instructor has a different opinion than me.</p> <p>Here is code:</p> <pre class="lang-java prettyprint-override"><code>public static void main(String[] args) throws InterruptedException { Thread t1 = new Thread(() -&gt; System.out.println(&quot;T1&quot;)); Thread t2 = new Thread(() -&gt; System.out.println(&quot;T2&quot;)); t1.start(); t2.start(); t1.join(); t2.join(); } </code></pre> <p>I thought that running this code on <code>multiple cores</code> would run with parallelism, not concurrency, the instructor says concurrency.</p> <p>If concurrency is not parallel, what is the reason?</p>
[ { "answer_id": 74171093, "author": "pveentjer", "author_id": 2245707, "author_profile": "https://Stackoverflow.com/users/2245707", "pm_score": 2, "selected": false, "text": " public static void main(String[] args) throws InterruptedException {\n Thread t1 = new Thread(() -> Sys...
2022/10/23
[ "https://Stackoverflow.com/questions/74170940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19344103/" ]
74,170,964
<p>Currently it does it with a color, if I wanted to use an image instead, how would that be done?</p> <p>It works fine using a color as you can see, how would I be able to use an image here, where it breaks apart the same way, in 4 triangle shapes?</p> <p>How would this be done?</p> <p>Clicking on the play button causes it to split into 4 triangle shapes.</p> <p>Image being: 640 x 360</p> <pre><code> background: url(&quot;https://i.imgur.com/N15HzPQ.jpg&quot;); background-position: 0 0; background-size: cover; background-repeat: no-repeat; </code></pre> <p>code <a href="https://jsfiddle.net/j10eurz3/" rel="nofollow noreferrer">https://jsfiddle.net/j10eurz3/</a></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 manageCover = (function makeManageCover() { function show(el) { el.classList.remove("hide"); } function hide(el) { el.classList.add("hide"); } function openCurtain(cover) { hide(cover); const curtain = document.querySelector(".curtain"); curtain.classList.add("slide"); return curtain; } function showVideo(curtain) { const thewrap = curtain.parentElement.querySelector(".wrap"); show(thewrap); } function coverClickHandler(evt) { const cover = evt.currentTarget; const curtain = openCurtain(cover); showVideo(curtain); cover.dispatchEvent(new Event("afterClick")); } function init(callback) { const cover = document.querySelector(".play"); cover.addEventListener("click", coverClickHandler); cover.addEventListener("afterClick", callback); } return { init }; }()); const videoPlayer = (function makeVideoPlayer() { let player; function loadIframeScript() { const tag = document.createElement("script"); tag.src = "https://www.youtube.com/iframe_api"; const firstScriptTag = document.getElementsByTagName("script")[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); } function onYouTubeIframeAPIReady() { const cover = document.querySelector(".play"); const wrapper = cover.parentElement; const frameContainer = wrapper.querySelector(".video"); addPlayer(frameContainer); } function onPlayerReady() { player.setVolume(100); } function addPlayer(video) { const options = { height: 360, host: "https://www.youtube-nocookie.com", videoId: video.dataset.id, width: 640 }; options.playerVars = { autoplay: 0, cc_load_policy: 0, controls: 1, disablekb: 1, fs: 0, iv_load_policy: 3, rel: 0 }; options.events = { "onReady": onPlayerReady }; options.playerVars.loop = 1; options.playerVars.playlist = video.dataset.id; player = new YT.Player(video, options); } function play() { if (player &amp;&amp; player.playVideo) { player.playVideo(); } } function init() { player = null; loadIframeScript(); window.onYouTubeIframeAPIReady = onYouTubeIframeAPIReady; return play; } return { init, play }; }()); manageCover.init(videoPlayer.init());</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>html, body { height: 100%; margin: 0; padding: 0; } body { background-image: repeating-linear-gradient(135deg, rgb(0, 0, 0) 0px, rgb(0, 0, 0) 10px, transparent 10px, transparent 11px), repeating-linear-gradient(22.5deg, rgb(0, 0, 0) 0px, rgb(0, 0, 0) 10px, transparent 10px, transparent 11px), linear-gradient(90deg, rgb(0, 89, 221), rgb(0, 89, 221), rgb(0, 89, 221), rgb(0, 89, 221), rgb(0, 89, 221)); } .container { position: absolute; left: 0; right: 0; min-height: 100%; /*min-width: 255px;*/ display: flex; } .curtain { flex: 1 0 0; margin: auto; max-width: 640px; border: 21px solid; border-radius: 3.2px; border-color: #000 #101010 #000 #101010; position: relative; } .curtain::before { content: ''; position: absolute; top: -2px; left: -2px; right: -2px; bottom: -2px; background: #0a0a0a; border: 1px solid; border-color: #000 #101010 #000 #101010; } .curtain::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; top: 0; outline: 1px solid #333; pointer-events: none; } .curtain.slide::after { outline: 1px solid #0059dd; transition: outline 2s ease-in; /* add this */ /*background-image: none;*/ } .ratio-keeper { position: relative; height: 0; padding-top: 56.25%; margin: auto; overflow: hidden; } .video-frame { position: absolute; top: 0; left: 0; width: 100%; height: 100%; animation: fade 3s ease-in 0s forwards; } @keyframes fade { 0% { opacity: 0; } 100% { opacity: 1; } } iframe { user-select: none; } .panel-up, .panel-down, .panel-left, .panel-right { position: absolute; transition: all 8s ease; transition-delay: 0s; overflow: hidden; width: 0; height: 0; } .panel-up { left: -100%; right: -100%; margin: 0 auto; bottom: 50%; border-top: 180px solid red; border-left: 320px solid transparent; border-right: 320px solid transparent; } .panel-down { left: -100%; right: -100%; margin: 0 auto; top: 50%; border-bottom: 180px solid blue; border-left: 320px solid transparent; border-right: 320px solid transparent; } .panel-left { top: -100%; bottom: -100%; right: 50%; margin: auto 0; border-left: 320px solid green; border-top: 180px solid transparent; border-bottom: 180px solid transparent; } .panel-right { top: -100%; bottom: -100%; left: 50%; margin: auto 0; border-right: 320px solid yellow; border-top: 180px solid transparent; border-bottom: 180px solid transparent; } .curtain.slide .panel-up { transform: translateY(calc(-100% - 1px)); } .curtain.slide .panel-down { transform: translateY(calc(100% + 1px)); } .curtain.slide .panel-left { transform: translateX(calc(-100% - 1px)); } .curtain.slide .panel-right { transform: translateX(calc(100% + 1px)); } .play { -webkit-appearance: none; appearance: none; position: absolute; top: 0; left: 0; bottom: 0; right: 0; margin: auto; display: flex; justify-content: center; align-items: center; width: 90px; height: 90px; border-radius: 50%; cursor: pointer; border: 9px solid; background: transparent; filter: drop-shadow(3px 3px 3px #000000b3); animation: rotate 700ms linear forwards; border-color: red transparent red transparent; filter: drop-shadow(3px 3px 3px rgba(0, 0, 0, 0.7)); color: #303030; } @keyframes rotate { 0% { transform: rotate(0deg); } 99.9% { border-color: red transparent red transparent; pointer-events: none; } 100% { transform: rotate(360deg); border-color: blue; } } .play::before { content: ""; width: 0; height: 0; border-top: 20px solid transparent; border-bottom: 20px solid transparent; border-left: 27px solid; transform: translateX(4px); animation: triangle 700ms linear forwards; } @keyframes triangle { 0% { opacity: 0; } 99.9% { opacity: 0; } 100% { border-left-color: blue; opacity: 1; } } .play:hover { box-shadow: 0 0 0 5px rgba(43, 179, 20, 0.5); } .play:focus { outline: 0; box-shadow: 0 0 0 5px rgba(0, 255, 255, 0.5); } .exit { position: absolute; top: auto; bottom: -47.63px; margin: auto; right: 0; left: 0; width: 47px; height: 47px; cursor: pointer; border-radius: 100%; background: transparent; border: 5px solid red; box-sizing: border-box; opacity: 0; pointer-events: none; clip-path: circle(50%); } .slide .exit { animation: fadeInExit 4s forwards 7.5s; } @keyframes fadeInExit { 99% { pointer-events: none; } 100% { pointer-events: initial; opacity: 1; } } .exit::before, .exit::after { content: ""; background-color: red; width: 47px; height: 5px; position: absolute; top: 0px; left: -5px; right: 0; bottom: 0; margin: auto; } .exit::before { transform: rotate(45deg); } .exit::after { transform: rotate(-45deg); } .hide { display: none; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt; &lt;div class="curtain"&gt; &lt;div class="ratio-keeper"&gt; &lt;div class="wrap hide"&gt; &lt;div class="video video-frame" data-id="CHahce95B1g"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="panel-up"&gt;&lt;/div&gt; &lt;div class="panel-down"&gt;&lt;/div&gt; &lt;div class="panel-left"&gt;&lt;/div&gt; &lt;div class="panel-right"&gt;&lt;/div&gt; &lt;/div&gt; &lt;a href="https://www.google.com/"&gt; &lt;div class="exit"&gt;&lt;/div&gt; &lt;/a&gt; &lt;/div&gt; &lt;button class="play" type="button" aria-label="Open"&gt;&lt;/button&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74171208, "author": "Kokodoko", "author_id": 1083572, "author_profile": "https://Stackoverflow.com/users/1083572", "pm_score": -1, "selected": false, "text": "body {\n margin:0;\n padding:0;\n}\n\ndiv {\n box-sizing:border-box;\n position: absolute;\n width:230px;\n ...
2022/10/23
[ "https://Stackoverflow.com/questions/74170964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17631451/" ]
74,170,988
<p>dpkg --configure -a Setting up realtek-rtl8188eus-dkms (5.3.9~git20220829.4ba8e08-0parrot1) ... Removing old realtek-rtl8188eus-5.3.9~git20220829.4ba8e08 DKMS files... Deprecated feature: REMAKE_INITRD (/var/lib/dkms/realtek-rtl8188eus/5.3.9~git20220829.4ba8e08/source/dkms.conf) Deprecated feature: REMAKE_INITRD (/var/lib/dkms/realtek-rtl8188eus/5.3.9~git20220829.4ba8e08/source/dkms.conf) Module realtek-rtl8188eus-5.3.9~git20220829.4ba8e08 for kernel 5.18.0-14parrot1-amd64 (x86_64). Before uninstall, this module version was ACTIVE on this kernel.</p> <p>8188eu.ko:</p> <ul> <li>Uninstallation <ul> <li>Deleting from: /lib/modules/5.18.0-14parrot1-amd64/updates/dkms/</li> </ul> </li> <li>Original module <ul> <li>No original module was found for this module on this kernel.</li> <li>Use the dkms install command to reinstall any previous module version. depmod.... Deleting module realtek-rtl8188eus-5.3.9~git20220829.4ba8e08 completely from the DKMS tree. Loading new realtek-rtl8188eus-5.3.9~git20220829.4ba8e08 DKMS files... Deprecated feature: REMAKE_INITRD (/usr/src/realtek-rtl8188eus-5.3.9~git20220829.4ba8e08/dkms.conf) Building for 6.0.0-2parrot1-amd64 Building initial module for 6.0.0-2parrot1-amd64 Deprecated feature: REMAKE_INITRD (/var/lib/dkms/realtek-rtl8188eus/5.3.9~git20220829.4ba8e08/source/dkms.conf) Error! Bad return status for module build on kernel: 6.0.0-2parrot1-amd64 (x86_64) Consult /var/lib/dkms/realtek-rtl8188eus/5.3.9~git20220829.4ba8e08/build/make.log for more information. dpkg: error processing package realtek-rtl8188eus-dkms (--configure): installed realtek-rtl8188eus-dkms package post-installation script subprocess returned error exit status 10 Errors were encountered while processing: realtek-rtl8188eus-dkms</li> </ul> </li> </ul> <p>VERSION ID5.1 VERSION 5.1 Electro Ara VERSION CODENAME=ara 6.0.0-2parrot1-amd64</p> <p>any ideas for trouble shoot</p>
[ { "answer_id": 74239654, "author": "Moaaz Mahrous", "author_id": 11676040, "author_profile": "https://Stackoverflow.com/users/11676040", "pm_score": 0, "selected": false, "text": "sudo rm -rf /usr/src/realtek-rtl8*\n" } ]
2022/10/23
[ "https://Stackoverflow.com/questions/74170988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20314294/" ]
74,171,007
<blockquote> <p>In this Exercise, you will sum the value of a string. Complete the recursive function</p> <pre><code>def sumString(st): </code></pre> <p>This function accepts a string as a parameter and sums the ASCII value for each character whose ASCII value is an even number.</p> </blockquote> <p>I know how to sum all the values but the even numbers part is challenging.</p> <pre><code>def sumString(st): if not st: return 0 else: return ord(st[0]+sumString(st[1:])] </code></pre> <p>I tried something but i am just confused at this point.</p> <pre><code>def sumString(st): if not st: return 0 t=[ord(st[0]),sumString(st[1:])] for item in t: if item%2==0: return item+t </code></pre>
[ { "answer_id": 74171141, "author": "SollyBunny", "author_id": 7483019, "author_profile": "https://Stackoverflow.com/users/7483019", "pm_score": 0, "selected": false, "text": "TypeError: unsupported operand type(s) for +: 'int' and 'list' " }, { "answer_id": 74171153, "author"...
2022/10/23
[ "https://Stackoverflow.com/questions/74171007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20199724/" ]
74,171,009
<p>In this custom-made function, I try to calculate the area of a circle. So if the user inputs not an integer as the <strong>Count of circles</strong> I want to go back again to <strong>Count of Circle</strong> and I can't figure out how I should do it. <em>same goes for</em> <em><strong>Value of angle</strong></em></p> <p>'''def circlearea (r): print (&quot;Calculating Area Of A Circle&quot;) radius = r print (&quot;Radius Is &quot;, radius) pi = 22/7</p> <pre><code># Count Of Circles Section circleLoop = 1 while circleLoop == 1: circles = input(&quot;Count Of Circle: &quot;) if type(circles) is not int: circles = int(circles) circleLoop = 2 else : print (323) circleLoop = 1 # Value Of Angle Section angleLoop = 1 while angleLoop == 1: angle = input(&quot;The Value Of Angle: &quot;) if angle is int or float: angle = float(angle) break else : print (False) print (&quot;Invalid Angle Please Try Again !!&quot;) area = pi*radius**2*(angle/360)*circles print (&quot;Area Of This Circle Is: &quot;, area)''' </code></pre>
[ { "answer_id": 74171074, "author": "Muhammad Akhlaq Mahar", "author_id": 17416783, "author_profile": "https://Stackoverflow.com/users/17416783", "pm_score": 3, "selected": true, "text": "# Count Of Circles Section \ncircleLoop = 1\nwhile circleLoop == 1:\n\n circles = input(\"Count Of...
2022/10/23
[ "https://Stackoverflow.com/questions/74171009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20124691/" ]
74,171,020
<p>I need help with the Google Sheet formula. I am trying to combine the array formula with vlookup and import range to get specific values from three columns from two different sheet</p> <p>For example, if you write c15, it will look for this specific value in the first or the second sheet. When finding it, it will get the value from the chosen columns and write it in the new sheet. The formula works perfectly with one file, but I want the formula to vlookup within the two sheets</p> <p>This is the formula</p> <pre><code>=ArrayFormula(VLOOKUP(C4,IMPORT RANGE(&quot;URL&quot;,&quot;Autoparts!A:AC&quot;),{5,29,10},0)) </code></pre> <p><code>C4</code> is the cell that has the value I'm looking for. <code>{5,29,10}</code> These are the columns where to look for the needed values.</p> <p>Any help is appreciated.</p>
[ { "answer_id": 74171727, "author": "Osm", "author_id": 19529694, "author_profile": "https://Stackoverflow.com/users/19529694", "pm_score": 1, "selected": false, "text": "{}" }, { "answer_id": 74173597, "author": "player0", "author_id": 5632629, "author_profile": "http...
2022/10/23
[ "https://Stackoverflow.com/questions/74171020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20314075/" ]
74,171,043
<p>I am new to programming, learning HTML CSS. I have a flowing img out of my div which is the .team-main. It affects the width of the other sections. How can I stop this? so my sections do not cover the page horizontally because of this. Can somebody help me fix this please?</p> <p>this is the ss of the background color: <a href="https://i.stack.imgur.com/7Lnf1.png" rel="nofollow noreferrer">Not fitting background color</a></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>#team { width: 100%; display: flex; justify-content: center; align-items: center; flex-direction: column; background-color: #f8f9fa; margin-top: 5rem; } .team-main { width: 100vw; height: 800px; align-items: center; text-align: center; } .team-title h1 { margin-bottom: 1rem; font-size: 40px; } .team-title p { color: #6c757d; font-style: italic; font-size: larger; text-align: center; } .team-member p { color: #6c757d; font-size: large; font-weight: 100; margin: 0.4rem 0 1rem; } .team-members { width: 100%; display: flex; justify-content: center; align-items: center; text-align: center; margin: 3rem 5rem 5rem; } .team-members-middle { text-align: center; width: 50%; margin: auto; color: #6c757d; } .team-member { width: 100%; } .team-member img { height: 220px; width: 220px; margin: 1rem 7rem; border-radius: 50%; border: 8px solid #d4d5d7; } .team-member .member { display: flex; justify-content: center; align-items: center; height: 40px; width: 40px; border-radius: 50%; background-color: #111212; } .team-member .member i { font-size: 16px; color: white; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;section id="team"&gt; &lt;div class="team-main"&gt; &lt;div class="team-title"&gt; &lt;h1 id="team"&gt;OUR AMAZING TEAM&lt;/h1&gt; &lt;p&gt;Lorem ipsum dolor sit amet consectetur.&lt;/p&gt; &lt;/div&gt; &lt;div class="team-members"&gt; &lt;div class="team-member"&gt; &lt;img src="https://startbootstrap.github.io/startbootstrap-agency/assets/img/team/1.jpg" alt="" /&gt; &lt;h2&gt;Parveen Anand&lt;/h2&gt; &lt;p&gt;Lead Designer&lt;/p&gt; &lt;div class="member"&gt;&lt;a href=""&gt;&lt;i class="fa-brands fa-twitter"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="member"&gt;&lt;a href=""&gt;&lt;i class="fa-brands fa-facebook-f"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="member"&gt;&lt;a href=""&gt;&lt;i class="fa-brands fa-linkedin-in"&gt;&lt;/i&gt;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="team-member"&gt; &lt;img src="https://startbootstrap.github.io/startbootstrap-agency/assets/img/team/2.jpg" alt="" /&gt; &lt;h2&gt;Diana Petersen&lt;/h2&gt; &lt;p&gt;Lead Marketer&lt;/p&gt; &lt;div class="member"&gt;&lt;a href=""&gt;&lt;i class="fa-brands fa-twitter"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="member"&gt;&lt;a href=""&gt;&lt;i class="fa-brands fa-facebook-f"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="member"&gt;&lt;a href=""&gt;&lt;i class="fa-brands fa-linkedin-in"&gt;&lt;/i&gt;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="team-member"&gt; &lt;img src="https://startbootstrap.github.io/startbootstrap-agency/assets/img/team/3.jpg" alt="" /&gt; &lt;h2&gt;Larry Parker&lt;/h2&gt; &lt;p&gt;Lead Developer&lt;/p&gt; &lt;div class="member"&gt;&lt;a href=""&gt;&lt;i class="fa-brands fa-twitter"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="member"&gt;&lt;a href=""&gt;&lt;i class="fa-brands fa-facebook-f"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="member"&gt;&lt;a href=""&gt;&lt;i class="fa-brands fa-linkedin-in"&gt;&lt;/i&gt;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p class="team-members-middle"&gt; Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aut eaque, laboriosam veritatis, quos non quis ad perspiciatis, totam corporis ea, alias ut unde. &lt;/p&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p><a href="https://codepen.io/mizginyildirak/pen/ZERzOVx" rel="nofollow noreferrer">https://codepen.io/mizginyildirak/pen/ZERzOVx</a></p>
[ { "answer_id": 74171727, "author": "Osm", "author_id": 19529694, "author_profile": "https://Stackoverflow.com/users/19529694", "pm_score": 1, "selected": false, "text": "{}" }, { "answer_id": 74173597, "author": "player0", "author_id": 5632629, "author_profile": "http...
2022/10/23
[ "https://Stackoverflow.com/questions/74171043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20225949/" ]
74,171,058
<pre><code>%matplotlib inline import matplotlib.pyplot as plt import numpy as np import random import seaborn as sns def input_test_scores(): #input for number of students studentnumber=int(input('Enter number of students')) #input for number of tests per student numberoftests=int(input('enter number of tests per student')) #empty list to store scores score=[] for i in range(studentnumber): #empty list for each students name and scores studentlist=[] for j in range(numberoftests): #input for test score print(&quot;Enter score for test &quot;, j+1, &quot;:&quot;) #add students score to their list studentlist.append(int(input())) #add student list to score list to create a 2d list score.append(studentlist) return score def summarize_test_scores(score): mean=[] for data in score: m=sum(data)/len(data) mean.append(m) grade=[] for x in mean: if x &gt;=90: grade.append('A') elif x &gt;=80: grade.append('B') elif x &gt;=70: grade.append('C') elif x &gt;=60: grade.append('D') else: grade.append('F') print(&quot;MEAN GRADE&quot;) for i in range(len(score)): print(f'{mean[i]:.2f} {grade[i]}') #rolls = [random.randrange(1, 7) for i in range(600)] #values, frequencies = np.unique(rolls, return_counts=True) title = f'Student Grades {len(grade):,} Times' sns.set_style('whitegrid') axes = sns.barplot(x=mean, y=grade, palette='bright') score=input_test_scores () summarize_test_scores(score) </code></pre> <p>This code is supposed to ask input for number of students, number of tests per student, and grades for each test, and then display number of students pet letter grade in a bar chart, displaying each letter even if no students earned that grade. Right now everything words except the bar chart displays grades letter on the y axis and grade mean on the x. What do I need to change?</p>
[ { "answer_id": 74171435, "author": "ThatOneCoder", "author_id": 15942680, "author_profile": "https://Stackoverflow.com/users/15942680", "pm_score": 0, "selected": false, "text": "axes = sns.barplot(x=mean, y=grade, palette='bright')\n" }, { "answer_id": 74171525, "author": "e...
2022/10/23
[ "https://Stackoverflow.com/questions/74171058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20314324/" ]
74,171,081
<p>I have a <code>m by n</code> matrix in matlab and want to find the indices (row, column) of each antidiagonal elements. For example for a <code>4x3</code> matrix, I would like to have the following indices:</p> <pre><code>antidiag1 = (1,1) antidiag2 = (2,1) , (1,2) antidiag3 = (3,1) , (2,2), (1,3) antidiag4 = (4,1) , (3,2), (2,3) antidiag5 = (4,2) , (3,3) antidiag3 = (4,3) </code></pre> <p>in the above example <code>(m,n)=(row, column)</code>. To show what I mean by anti-diagonal elements see the below matrix in which red lines are anti-diagonals</p> <p><a href="https://i.stack.imgur.com/DuwIw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DuwIw.png" alt="enter image description here" /></a></p> <p>How to find the indices?</p>
[ { "answer_id": 74171388, "author": "Cris Luengo", "author_id": 7328782, "author_profile": "https://Stackoverflow.com/users/7328782", "pm_score": 1, "selected": false, "text": "out = diag( flip(in, 2), k );\n" }, { "answer_id": 74176153, "author": "John BG", "author_id": 9...
2022/10/23
[ "https://Stackoverflow.com/questions/74171081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2983136/" ]
74,171,123
<p>I want to write a calculator program. My goal is to replace multiple list items(with datatype <code>str</code>) by one(<code>int</code>). I've tried the <code>.insert()</code> method, but it creates a new inner list and places it at the end of the main list.</p> <p><em>Something like this:</em></p> <pre class="lang-py prettyprint-override"><code>input_list = ['4','5','6','+','8','7','4'] #expected result output_list = [456, '+', 874] #actual result input_list = ['4','5','6','+','8','7','4',['4','5','6']] </code></pre> <p>I also tried extend method and also without success.</p> <p><strong>My code:</strong></p> <pre class="lang-py prettyprint-override"><code>num = &quot;&quot; start = &quot;&quot; for x in range(len(list)): if list[x].isdigit() == True: if start == &quot;&quot;: start = x num += list[x] continue else: num += list[x] continue else: num = int(num) list.insert(num,list[start:x]) num = &quot;&quot; start = &quot;&quot; continue </code></pre>
[ { "answer_id": 74171176, "author": "Catalina", "author_id": 11624756, "author_profile": "https://Stackoverflow.com/users/11624756", "pm_score": 0, "selected": false, "text": "list.insert(num,list[start:x])" }, { "answer_id": 74171195, "author": "S.B", "author_id": 1394452...
2022/10/23
[ "https://Stackoverflow.com/questions/74171123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19944047/" ]
74,171,171
<p>I was wondering how you could print coloured text in a cross platform manner in C. I have looked at all the other answers on the forum, but none of them work during my testing (on Windows). For C++, I have the working code in <strong>Fig 1</strong>, however when converting the code to C and assigning the strings to a variable I get the error <code>\u001b is not a valid universal character</code> (<strong>Fig 2</strong>).</p> <p><strong>Fig 1</strong></p> <pre class="lang-cpp prettyprint-override"><code>namespace Fore { const std::string BLACK = &quot;\u001b[30m&quot;; // Rest of code is not included since it is just a repetition of the above code with background and style ANSI codes as well. </code></pre> <p><strong>Fig 2</strong></p> <p><a href="https://i.stack.imgur.com/JXsfi.png" rel="nofollow noreferrer">Image here since I don't have enough reputation to embed images yet.</a></p>
[ { "answer_id": 74171176, "author": "Catalina", "author_id": 11624756, "author_profile": "https://Stackoverflow.com/users/11624756", "pm_score": 0, "selected": false, "text": "list.insert(num,list[start:x])" }, { "answer_id": 74171195, "author": "S.B", "author_id": 1394452...
2022/10/23
[ "https://Stackoverflow.com/questions/74171171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20314241/" ]
74,171,177
<p>I have a link on my collection page on a Shopify store.</p> <p>the link does look like this:</p> <p>/collections/all?filter.p.tag=animal</p> <p>I want to grab the current active Filters and print them again under the H1 Heading.</p> <p>But I <strong>HAVE TO</strong> grab only everything after &quot;tag=&quot;</p> <p>So ignore the rest of the URL and also anything coming from things like &quot;sort_by&quot; or &quot;?fbclid=IwAR2didTPblablabla&quot;</p> <p>So just everything after &quot;tag=&quot;</p> <p>How this can be done?</p>
[ { "answer_id": 74171256, "author": "Remco Kersten", "author_id": 13029349, "author_profile": "https://Stackoverflow.com/users/13029349", "pm_score": 0, "selected": false, "text": "window.location.href.split(\"tag=\")[1]\n" }, { "answer_id": 74171297, "author": "Spyros Argalia...
2022/10/23
[ "https://Stackoverflow.com/questions/74171177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11274386/" ]
74,171,193
<p>I have read the code but did not find the default pool type of ThreadPoolTaskExecutor. what is the default thread pool of ThreadPoolTaskExecutor? newFixedThreadPool or newCachedThreadPool?</p>
[ { "answer_id": 74171256, "author": "Remco Kersten", "author_id": 13029349, "author_profile": "https://Stackoverflow.com/users/13029349", "pm_score": 0, "selected": false, "text": "window.location.href.split(\"tag=\")[1]\n" }, { "answer_id": 74171297, "author": "Spyros Argalia...
2022/10/23
[ "https://Stackoverflow.com/questions/74171193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2628868/" ]
74,171,204
<p>Pretty new to C#.</p> <p>I want to read the user input from a combo box and use the selected currencies in a method which converts one to another. The output isn't in console, it's on a Windows form.</p> <p>This is my combo box input read code:</p> <pre><code>public void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { double first = comboBox1.SelectedIndex; } public void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { double second = comboBox2.SelectedIndex; } </code></pre> <p>And this is my code that uses the selected indexes and converts them:</p> <pre><code>internal class Currencies { public double[] Convert(double[] currencies, int amount) { double[] convertedAmount = new double[currencies.Length]; if (Converter.comboBox1.first == HRK &amp;&amp; Converter.comboBox2.second == EURO) { int exchangeRate1 = 1; double exchangeRate2 = 7.4; for (int i = 0; i &lt; currencies.Length; i++) { convertedAmount[i] = amount * exchangeRate1 / exchangeRate2; } } else if (Converter.comboBox1.first == EURO &amp;&amp; Converter.comboBox2.seocnd == HRK) { int exchangeRate1 = 1; double exchangeRate2 = 7.4; for (int i = 0; i &lt; currencies.Length; i++) { convertedAmount[i] = amount * exchangeRate1 / exchangeRate2; } } else { throw new NotSupportedException(); } return convertedAmount; } } </code></pre> <p>Why doesn't the method let me use the variables &quot;first&quot; and &quot;second&quot; where I stored the selected indexes to convert the currencies?</p>
[ { "answer_id": 74171400, "author": "edu", "author_id": 18170845, "author_profile": "https://Stackoverflow.com/users/18170845", "pm_score": -1, "selected": false, "text": "string SelectedIted {get; set;}" }, { "answer_id": 74173573, "author": "Blac Clack", "author_id": 197...
2022/10/23
[ "https://Stackoverflow.com/questions/74171204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17349296/" ]
74,171,261
<p>I'm trying to learn Riverpod with clean architecture.</p> <p>I have following set/chain of providers:</p> <pre><code>final databaseFutureProvider = FutureProvider&lt;Database&gt;((ref) async { final db = await DatabaseHelper().createDatabase(); // this is async because 'openDatabase' of sqflite is async return db; }); final toDoDatasourceProvider = Provider&lt;ToDoDatasource&gt;((ref) { final db = ref.watch(databaseFutureProvider); // problem is here!! return ToDoDatasourceImpl(db: db); }); final toDoRepositoryProvider = Provider&lt;ToDoRepository&gt;((ref) { final ds = ref.watch(toDoDatasourceProvider); return ToDoRepositoryImpl(ds); }); </code></pre> <p>I am probably missing some small things or doing it completely wrong. How to properly provide DB (that is async in its nature)?</p>
[ { "answer_id": 74172935, "author": "Mohammed Alfateh", "author_id": 13111345, "author_profile": "https://Stackoverflow.com/users/13111345", "pm_score": 2, "selected": true, "text": "ToDoRepository" }, { "answer_id": 74173226, "author": "Ruble", "author_id": 17991131, ...
2022/10/23
[ "https://Stackoverflow.com/questions/74171261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1448545/" ]
74,171,322
<p>I have a question regarding the combination of SwiftUI and MVVM.</p> <p>Before we start, I have read some posts discussing whether the combination of SwiftUI and MVVM is necessary. But I don't want to discuss this here, as it has been covered elsewhere. I just want to know if it is possible and, if yes, how. :)</p> <p>So here comes the code. I tried to add the ViewModel Layer in between the updated Object class that contains a number that should be updated when a button is pressed. The problem is that as soon as I put the ViewModel Layer in between, the UI does not automatically update when the button is pressed.</p> <p><strong>View</strong>:</p> <pre><code> struct ContentView: View { @ObservedObject var viewModel = ViewModel() @ObservedObject var numberStorage = NumberStorage() var body: some View { VStack { // Text(&quot;\(viewModel.getNumberObject().number)&quot;) // .padding() // Button(&quot;IncreaseNumber&quot;) { // viewModel.increaseNumber() // } Text(&quot;\(numberStorage.getNumberObject().number)&quot;) .padding() Button(&quot;IncreaseNumber&quot;) { numberStorage.increaseNumber() } } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } </code></pre> <p><strong>ViewModel</strong>:</p> <pre><code> class ViewModel: ObservableObject { @Published var number: NumberStorage init() { self.number = NumberStorage() } func increaseNumber() { self.number.increaseNumber() } func getNumberObject() -&gt; NumberObject { self.number.getNumberObject() } } </code></pre> <p><strong>Model</strong>:</p> <pre><code> class NumberStorage:ObservableObject { @Published var numberObject: NumberObject init() { numberObject = NumberObject() } public func getNumberObject() -&gt; NumberObject { return self.numberObject } public func increaseNumber() { self.numberObject.number+=1 } } struct NumberObject: Identifiable { let id = UUID() var number = 0 } ``` Looking forward to your feedback! </code></pre>
[ { "answer_id": 74172119, "author": "ibrahimyilmaz", "author_id": 2696626, "author_profile": "https://Stackoverflow.com/users/2696626", "pm_score": 1, "selected": false, "text": "objectWillChange" }, { "answer_id": 74172152, "author": "dillon-mce", "author_id": 11601631, ...
2022/10/23
[ "https://Stackoverflow.com/questions/74171322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16929076/" ]
74,171,338
<p>I have ansible playbook with 10 tasks. order of the tasks differs based on use case so I have to create extraVar.yml file for each use case and extraVar.yml will have order of the tasks defined. how to do that.</p> <p>Example:</p> <p>playbook:</p> <pre><code>tasks: - name task1 - name task2 - name task3 </code></pre> <p>extravar.yml</p> <pre><code>#order of tasks task3 task1 task2 </code></pre>
[ { "answer_id": 74171549, "author": "Chris Doyle", "author_id": 1212401, "author_profile": "https://Stackoverflow.com/users/1212401", "pm_score": 2, "selected": false, "text": "---\ntasks:\n - task2\n - task3\n - task1\n" }, { "answer_id": 74180387, "author": "Vladimir Botk...
2022/10/23
[ "https://Stackoverflow.com/questions/74171338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17314281/" ]
74,171,378
<p>Here are two flex divs:</p> <pre><code>&lt;div style=&quot;display:flex&quot;&gt; &lt;div class=&quot;content&quot;&gt;Content&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>How to increase the height if first block if content is not fit inside?</p> <p>I tried:</p> <pre><code>.content { flex: 1; height: 100%; } </code></pre>
[ { "answer_id": 74171549, "author": "Chris Doyle", "author_id": 1212401, "author_profile": "https://Stackoverflow.com/users/1212401", "pm_score": 2, "selected": false, "text": "---\ntasks:\n - task2\n - task3\n - task1\n" }, { "answer_id": 74180387, "author": "Vladimir Botk...
2022/10/23
[ "https://Stackoverflow.com/questions/74171378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20313606/" ]
74,171,391
<p>I am new to Django and I'd need some help for a project I have.</p> <p>I am currently building the API using Django-Rest-Framework and I would like to have a view which returns a weekly list of exercises. I am not sure how i could make it so the queried objects change weekly...</p> <p>atm I've created a custom Manager which retrieves a random amount of exercises from the exercise db</p> <p>Models.py</p> <pre><code>class ExerciseManager(models.Manager): def random(self, amount=20): random_exercises = [] exercises = Exercise.objects.all() for i in range(amount): random_exercises.append(random.choice(exercises)) return random_exercises class Exercise(models.Model): name = models.CharField(max_length=100, unique=True) objects = ExerciseManager() def __str__(self): return f&quot;{self.name}&quot; </code></pre> <p>views.py</p> <pre><code>@api_view(['GET']) def exercise_list(request): exercises = Exercise.objects.random() serializer = ExerciseSerializer(exercises, many=True) return Response(serializer.data) </code></pre>
[ { "answer_id": 74171549, "author": "Chris Doyle", "author_id": 1212401, "author_profile": "https://Stackoverflow.com/users/1212401", "pm_score": 2, "selected": false, "text": "---\ntasks:\n - task2\n - task3\n - task1\n" }, { "answer_id": 74180387, "author": "Vladimir Botk...
2022/10/23
[ "https://Stackoverflow.com/questions/74171391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12921396/" ]
74,171,395
<p>I am trying to insert timestamp into json data into a column called 'conversations' of type &quot;jsonb&quot;</p> <p>this is what I want the data to look like-</p> <pre><code>{ &quot;sender&quot;: &quot;John&quot;, &quot;message&quot;: &quot;Issue&quot;, &quot;msgAt&quot;: &quot;2022-11-11&quot;} </code></pre> <p>Below is my attempt at the above,which is not the correct format for the function NOW()</p> <pre><code> INSERT INTO ticket_data(conversations) VALUES('{&quot;sender&quot;:&quot;John&quot;,&quot;message&quot;:&quot;Issue&quot;,&quot;msgAt&quot;:NOW()}'); </code></pre> <p>Any help is appreciated!</p>
[ { "answer_id": 74171633, "author": "jian", "author_id": 15603477, "author_profile": "https://Stackoverflow.com/users/15603477", "pm_score": 0, "selected": false, "text": "select ('{\"sender\":\"John\",\"message\":\"Issue\",' || '\"msgAt\":'|| '\"' || ( now()::date) ||'\"' ||'}')::json;\n...
2022/10/23
[ "https://Stackoverflow.com/questions/74171395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18213666/" ]
74,171,420
<p>I am attempting to create a probability density function of <strong>times</strong> from an array of Timestamp tuples. I do not care about the date aspect of the timestamp and I would like to use only the hour and minute fields of the timestamp. I do not mind switching to R or Julia if need be since the time data types in Python seem to be restricting this. I attempted setting all the dates to 00:00 but that did not work. In the end I want a pdf of the first tuple values and then a pdf of the difference between each tuple 2nd and 1st value. Can someone please give direction or a solution?</p> <p><a href="https://i.stack.imgur.com/1FNrb.png" rel="nofollow noreferrer">Snapshot of array</a></p>
[ { "answer_id": 74171633, "author": "jian", "author_id": 15603477, "author_profile": "https://Stackoverflow.com/users/15603477", "pm_score": 0, "selected": false, "text": "select ('{\"sender\":\"John\",\"message\":\"Issue\",' || '\"msgAt\":'|| '\"' || ( now()::date) ||'\"' ||'}')::json;\n...
2022/10/23
[ "https://Stackoverflow.com/questions/74171420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14552636/" ]
74,171,427
<p>So the template of my code looks like this :</p> <pre><code>class Foo: def __init__(self, params): self.params = params #a dictionary def recursive_iteration(self, buffer): if buffer : #do something self.params['new_field'] = &quot;new_value&quot; else : for i in range(2): new_params = self.params new_params['some_field'] = another_value #changing with i Foo(new_params).recursive_iteration(True) </code></pre> <p>The problem I encounter is that when <code>recursive_iteration</code> is called inside another <code>recursive_iteration</code> then there are two <code>self</code> variables that exist within a different (but nested) scope.</p> <p>And during the second iteration of the for loop (i=1): <code>self.params</code> has the field 'new_field' which means the outer scope self was the one modified.</p> <p>Did i just flaw my code and should rework the model ?(I could go functional only but this is partially existing code)</p> <p>My question is : Can I precise which <code>self</code> I want to be modified with regard to their scope?</p> <p>EDIT : The issue comes from the shallow copy of self.params. All the time the same dictionnary is modified. It's not about the scope of the variables. Change <code>new_params = self.params</code> to <code>new_params = self.params.copy()</code> to solve the issue.</p>
[ { "answer_id": 74171633, "author": "jian", "author_id": 15603477, "author_profile": "https://Stackoverflow.com/users/15603477", "pm_score": 0, "selected": false, "text": "select ('{\"sender\":\"John\",\"message\":\"Issue\",' || '\"msgAt\":'|| '\"' || ( now()::date) ||'\"' ||'}')::json;\n...
2022/10/23
[ "https://Stackoverflow.com/questions/74171427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7958491/" ]
74,171,463
<p>I have a pandas dataframe that looks something like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ID</th> <th>Value</th> </tr> </thead> <tbody> <tr> <td>00001</td> <td>value 1</td> </tr> <tr> <td>00001</td> <td>value 2</td> </tr> <tr> <td>00002</td> <td>value 3</td> </tr> <tr> <td>00003</td> <td>value 4</td> </tr> <tr> <td>00004</td> <td>value 5</td> </tr> <tr> <td>00004</td> <td>value 6</td> </tr> </tbody> </table> </div> <p>What I want to do is remove it so that I am left with this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ID</th> <th>Value</th> </tr> </thead> <tbody> <tr> <td>00001</td> <td>value 1</td> </tr> <tr> <td>00002</td> <td>value 3</td> </tr> <tr> <td>00003</td> <td>value 4</td> </tr> <tr> <td>00004</td> <td>value 5</td> </tr> </tbody> </table> </div> <p>What's the best way to achieve this?</p>
[ { "answer_id": 74171633, "author": "jian", "author_id": 15603477, "author_profile": "https://Stackoverflow.com/users/15603477", "pm_score": 0, "selected": false, "text": "select ('{\"sender\":\"John\",\"message\":\"Issue\",' || '\"msgAt\":'|| '\"' || ( now()::date) ||'\"' ||'}')::json;\n...
2022/10/23
[ "https://Stackoverflow.com/questions/74171463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10571121/" ]
74,171,475
<p>im trying to write a code to rotate a unsigend int by number of bit (without knowing how many bits is unsigend int) i write this code -</p> <pre><code>unsigned int left_rottate(unsigned int a, int b){ int temp; int bits_size = size_in_bits()-1; b %= bits_size; while(b &gt; 0){ temp = (a&gt;&gt; bits_size)&amp;1; a = (a &lt;&lt;1) | temp; b--; } return a; } int size_in_bits() { unsigned int x, i = 0; x = ~0u; while ((x &amp; 1) != 0) (i+= 1, x /= 2); return (int) i; } </code></pre> <p>but i dont get the rigth results.</p>
[ { "answer_id": 74171633, "author": "jian", "author_id": 15603477, "author_profile": "https://Stackoverflow.com/users/15603477", "pm_score": 0, "selected": false, "text": "select ('{\"sender\":\"John\",\"message\":\"Issue\",' || '\"msgAt\":'|| '\"' || ( now()::date) ||'\"' ||'}')::json;\n...
2022/10/23
[ "https://Stackoverflow.com/questions/74171475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19111910/" ]
74,171,477
<pre><code>orders = {'U123':{'name':'Sumit Shukla', 'email':'ss@gmail.com', 'phone':8608538199, 'product':['p1', 'p2', 'p5']}, 'U121':{'name':'Ajay', 'email':'aj@gmail.com', 'phone':7708538199, 'product':['p5', 'p2', 'p5']}, 'U124':{'name':'Vijay', 'email':'vj@gmail.com', 'phone':870853819, 'product':['p1', 'p2', 'p3']}, 'U126':{'name':'Rahul', 'email':'rh_gmail.com', 'phone':8607858189, 'product':['p1', 'p5', 'p5']}, 'U183':{'name':'Shree', 'email':'shree@gmail.com', 'phone':8908938159, 'product':['p1', 'p1', 'p1']}, 'U143':{'name':'shivani', 'email':'shivani@gmail', 'phone':855853019, 'product':['p5', 'p2', 'p5']}} </code></pre>
[ { "answer_id": 74171633, "author": "jian", "author_id": 15603477, "author_profile": "https://Stackoverflow.com/users/15603477", "pm_score": 0, "selected": false, "text": "select ('{\"sender\":\"John\",\"message\":\"Issue\",' || '\"msgAt\":'|| '\"' || ( now()::date) ||'\"' ||'}')::json;\n...
2022/10/23
[ "https://Stackoverflow.com/questions/74171477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15289102/" ]
74,171,509
<p>There is probably a term for what I want to do, I will edit my question with the proper term when I find it out.</p> <p>Assume 3 lists:</p> <pre><code>a = [&quot;alpha&quot;, &quot;beta&quot;, gamma&quot;] b = [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;] c = [&quot;one&quot;, &quot;two&quot;, &quot;three&quot; &quot;four&quot;, &quot;five&quot;] </code></pre> <p>My custom base has the following sequence:</p> <pre><code>alpha-a-one, alpha-a-two, ..., alpha-a-five, alpha-b-one, ..., alpha-d-five, beta-a-one, ..., gamma-d-five </code></pre> <p>I want to be able to define <code>num1</code> and <code>num2</code> so that I can calculate addition and subtraction. For example</p> <pre><code>&gt;&gt;&gt; num1 = alpha-b-two &gt;&gt;&gt; num2 = alpha-a-four &gt;&gt;&gt; num1-num2 3 </code></pre> <p>and</p> <pre><code>&gt;&gt;&gt; num = alpha-a-four &gt;&gt;&gt; num+3 alpha-b-two </code></pre> <p>How can I do that? (and what is the term for this?)</p>
[ { "answer_id": 74171633, "author": "jian", "author_id": 15603477, "author_profile": "https://Stackoverflow.com/users/15603477", "pm_score": 0, "selected": false, "text": "select ('{\"sender\":\"John\",\"message\":\"Issue\",' || '\"msgAt\":'|| '\"' || ( now()::date) ||'\"' ||'}')::json;\n...
2022/10/23
[ "https://Stackoverflow.com/questions/74171509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8816055/" ]
74,171,519
<p>I am upload project file to Sub Domain. But In web site,just project files is showing. Project is not execute. How can i resolve this problem ?</p> <p>Subdomain is active.</p> <p><a href="https://i.stack.imgur.com/Dgxwy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Dgxwy.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74614131, "author": "Bayaz", "author_id": 16985277, "author_profile": "https://Stackoverflow.com/users/16985277", "pm_score": 0, "selected": false, "text": ".env" } ]
2022/10/23
[ "https://Stackoverflow.com/questions/74171519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16985277/" ]
74,171,526
<p>I want to convert the following for loop to a list comprehension:</p> <pre><code> for f in src_files.copy(): # Iterate over a list of images if os.path.getsize(os.path.join(SOURCE_DIR, f)) == 0: # Check if filesize is 0 print(&quot;filename is zero length, so removing.&quot;) src_files.remove(f) # Remove corrupted files from list </code></pre> <p>I had a look a various different other list comprehension questions and came up with this:</p> <pre><code>src_files = [f for f in src_files if os.path.getsize(os.path.join(SOURCE_DIR, f)) &gt; 0] </code></pre> <p>So this is working fine but it does not include the print of the else statement. Apparently you have to change the position of the condition if you use an else statement for some reason. So I tried this:</p> <pre><code>src_files = [f if os.path.getsize(os.path.join(SOURCE_DIR, f)) &gt; 0 else print(&quot;filename is zero length, so removing.&quot;) for f in src_files] </code></pre> <p>This does not give me an error but it simply does nothing. The list remains the same as before. I don't get it. Why does the if condition stop working just because I added a print in the else statement?</p> <p>(The reason why I want to rewrite the existing code is because I have an enourmous amount of images - hundreds of gigabytes - that need to be processed and I want to make the code as fast as possible)</p>
[ { "answer_id": 74171651, "author": "Giuseppe La Gualano", "author_id": 20249888, "author_profile": "https://Stackoverflow.com/users/20249888", "pm_score": 0, "selected": false, "text": "good_list = [f for f in src_files if os.path.getsize(os.path.join(SOURCE_DIR, f)) > 0]\n\nprint(*(f\"F...
2022/10/23
[ "https://Stackoverflow.com/questions/74171526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11159734/" ]
74,171,535
<p>I'm having trouble configuring localization in my asp.net 7.0 MVC project. Configuration:</p> <pre><code>.AddLocalization(opts =&gt; opts.ResourcesPath = &quot;Resources&quot;) </code></pre> <p>then</p> <pre><code>CultureInfo[] supportedCultures = new[] { new CultureInfo(&quot;en-US&quot;), new CultureInfo(&quot;bg-BG&quot;) }; mvcBuilder .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix) .AddDataAnnotationsLocalization(); mvcBuilder .Services .Configure&lt;RequestLocalizationOptions&gt;(options =&gt; { options.DefaultRequestCulture = new RequestCulture(culture: &quot;en-US&quot;, uiCulture: &quot;en-US&quot;); options.SupportedCultures = supportedCultures; options.SupportedUICultures = supportedCultures; }); </code></pre> <p>This is called before</p> <pre><code>.AddRazorPages(); </code></pre> <p>And at the end</p> <pre><code>app.UseRequestLocalization(app.Services.GetRequiredService&lt;IOptions&lt;RequestLocalizationOptions&gt;&gt;().Value); </code></pre> <p>I have installed Microsoft.Extensions.Localization nuget. I have two resource files in folder Resources</p> <ul> <li>Controllers.HomeController.bg-BG.resx</li> <li>Controllers.HomeController.en-US.resx</li> </ul> <p>In both resources there is entry &quot;title&quot; with some values Injected IStringLocalizer into HomeController but everytime it returns only &quot;title&quot;, used it like this:</p> <pre><code>this.stringLocalizer[&quot;title&quot;].Value </code></pre> <p>After hours of trial and error I really can't seem to find what's the problem.</p>
[ { "answer_id": 74179081, "author": "Oliver Weichhold", "author_id": 88513, "author_profile": "https://Stackoverflow.com/users/88513", "pm_score": 2, "selected": true, "text": "IStringLocalizer" } ]
2022/10/23
[ "https://Stackoverflow.com/questions/74171535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4591837/" ]
74,171,540
<p>I have the following data stored as lists:</p> <pre><code>List&lt;ArrayList&lt;String&gt;&gt; dummy = new ArrayList&lt;&gt;(); dummy.add(new ArrayList&lt;&gt;(List.of(&quot;1&quot;, &quot;SP1&quot;, &quot;SW1&quot;))); dummy.add(new ArrayList&lt;&gt;(List.of(&quot;2&quot;, &quot;SP1&quot;, &quot;SW2&quot;))); dummy.add(new ArrayList&lt;&gt;(List.of(&quot;3&quot;, &quot;SP2&quot;, &quot;SW1&quot;))); dummy.add(new ArrayList&lt;&gt;(List.of(&quot;4&quot;, &quot;SP2&quot;, &quot;SW2&quot;))); dummy.add(new ArrayList&lt;&gt;(List.of(&quot;5&quot;, &quot;SP2&quot;, &quot;SW1&quot;))); dummy.add(new ArrayList&lt;&gt;(List.of(&quot;6&quot;, &quot;SP1&quot;, &quot;SW1&quot;))); dummy.add(new ArrayList&lt;&gt;(List.of(&quot;7&quot;, &quot;SP3&quot;, &quot;SW2&quot;))); </code></pre> <p>I need to group it as follows</p> <pre><code>SW1-SP1-list{1,6} SW1-SP2-list{3,5} SW2-SP1-list{2} SW2-SP2-list{4} SW2-SP3-list{7} </code></pre> <p>What I have tried is the following:</p> <pre><code>var test = dummy.stream() .collect(Collectors.groupingBy( s -&gt; s.get(2), TreeMap::new, Collectors.groupingBy( s -&gt; s.get(1), Collectors.toList() ) )); </code></pre> <p>But this doesn't give the desired result.</p>
[ { "answer_id": 74171608, "author": "user7", "author_id": 4405757, "author_profile": "https://Stackoverflow.com/users/4405757", "pm_score": 2, "selected": true, "text": "Map<String, Map<String, List<String>>> result = dummy.stream()\n .collect(Collectors.groupingBy(l -> l.get(2),\n...
2022/10/23
[ "https://Stackoverflow.com/questions/74171540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5699246/" ]
74,171,552
<p>I am trying to make a script which convert BUS master .log files into .asc files without bus master. The files are just column adjustment but I am stuck with different time format used in the files' format.</p> <p>Example: 11:29:26:2229 (.log) = 41366.222900 (.asc)</p> <p>Please help me out to understand the .asc file time format.</p>
[ { "answer_id": 74178142, "author": "M. Spiller", "author_id": 8281848, "author_profile": "https://Stackoverflow.com/users/8281848", "pm_score": 1, "selected": false, "text": "date Mon Okt 24 10:01:03 2022\n" } ]
2022/10/23
[ "https://Stackoverflow.com/questions/74171552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12940043/" ]
74,171,567
<p>What I have so far looks like this code below..</p> <pre><code>&lt;thead&gt; &lt;tr&gt; &lt;th&gt;NAME&lt;/th&gt; &lt;th&gt;FIBER&lt;/th&gt; &lt;th&gt;TELEPHONE&lt;/th&gt; &lt;th&gt;COAXIAL&lt;/th&gt; &lt;th&gt;SUBSCRIBER FOC&lt;/th&gt; &lt;th&gt;SUBSCRIBER TLC&lt;/th&gt; &lt;th&gt;SUBSCRIBER CC&lt;/th&gt; &lt;th&gt;REMARKS&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; </code></pre> <p>but I want to achieve this layout..</p> <pre><code>+------+-------+-----------+---------+----------------+---------+ | | | | | SUBSCRIBER | | | NAME | FIBER | TELEPHONE | COAXIAL +-----+-----+----+ REMARKS + | | | | | FOC | TLC | CC | | +------+-------+-----------+---------+-----+-----+----+---------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +------+-------+-----------+---------+-----+-----+----+---------+ </code></pre> <p>is it possible without using the CSS Grid?</p>
[ { "answer_id": 74178142, "author": "M. Spiller", "author_id": 8281848, "author_profile": "https://Stackoverflow.com/users/8281848", "pm_score": 1, "selected": false, "text": "date Mon Okt 24 10:01:03 2022\n" } ]
2022/10/23
[ "https://Stackoverflow.com/questions/74171567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20314670/" ]
74,171,585
<p>I'm using pgsql to find the cage number (cno) that holds the largest number of animals but doesn't have a bird in it.</p> <p>The way I tried to do it is by creating a table that counts the number of animals in each cage (not including those with birds) and then return the ones where the count equals the max value.</p> <pre><code>select temp.cno,temp.size from (select cage.cno,cage.size,count(*) as q from cage,animal where cage.cno = animal.cno and cage.cno not in (select cno from animal where lower(atype)='sheep') group by cage.cno,cage.size) as temp where temp.q = (select max(q) from temp) </code></pre> <p>I'm getting the following error message</p> <pre><code>ERROR: relation &quot;temp&quot; does not exist LINE 7: where temp.q = (select max(q) from temp) </code></pre> <p>Any idea how to overcome this issue? Why isn't temp recognized within the last sub query?</p> <p>Here are the tables</p> <ol> <li><p>cage (<strong>cno</strong>, type, size)</p> </li> <li><p>animal (<strong>aid</strong>, aname, cno, atype)</p> </li> </ol>
[ { "answer_id": 74171872, "author": "forpas", "author_id": 10498828, "author_profile": "https://Stackoverflow.com/users/10498828", "pm_score": 1, "selected": false, "text": "FROM" } ]
2022/10/23
[ "https://Stackoverflow.com/questions/74171585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5740200/" ]
74,171,603
<p>I want to create a model, which is symmetric on two fields. Let's call the model Balance:</p> <pre><code>class Balance (models.Model): payer = models.ForeignKey(auth.User, ...) payee = models.ForeignKey(auth.User, ...) amount = models.DecimalField(...) </code></pre> <p>It should have the following property:</p> <pre><code>balance_forward = Balance.objects.get(payer=USER_1, payee=USER_2) balance_backward = Balance.objects.get(payer=USER_2, payee=USER_1) balance_forward.amount == -1 * balance_backward.amount </code></pre> <p>What is the best way to implement this?</p>
[ { "answer_id": 74172464, "author": "koPytok", "author_id": 8471144, "author_profile": "https://Stackoverflow.com/users/8471144", "pm_score": 1, "selected": true, "text": "class SymmetricPlayersQuerySet (models.query.QuerySet):\n\n def do_swap(self, obj):\n obj.payer, obj.payee ...
2022/10/23
[ "https://Stackoverflow.com/questions/74171603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8471144/" ]
74,171,622
<p>I want to sum two columns that have numerical values and display the results on the third column. I have the script below but that deletes the two columns and display the results on the first column.</p> <p>Any suggestions?</p> <pre><code>function test2() { var ss = SpreadsheetApp.getActiveSheet(); var rng = ss.getRange('E2:F6'); var val = rng.getValues(); for(row=0;row&lt;val.length;row++) { val[row][0] =val[row][0]+val[row][1];; val[row][1] = ''; } rng.setValues(val) } </code></pre>
[ { "answer_id": 74172464, "author": "koPytok", "author_id": 8471144, "author_profile": "https://Stackoverflow.com/users/8471144", "pm_score": 1, "selected": true, "text": "class SymmetricPlayersQuerySet (models.query.QuerySet):\n\n def do_swap(self, obj):\n obj.payer, obj.payee ...
2022/10/23
[ "https://Stackoverflow.com/questions/74171622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20314852/" ]
74,171,638
<p>How can I sort the list of Map the datetime(String) which I declare as String to sort in descending order?</p> <pre><code> final List&lt;Map&lt;String, dynamic&gt;&gt; _allUsers = [ {&quot;name&quot;: &quot;Chan Saw Lin&quot;, &quot;phone&quot;: &quot;0152131113&quot; ,&quot;Clock-In&quot; : &quot;2020-06-30 16:10:05&quot;}, {&quot;name&quot;: &quot;Lee Saw Loy&quot;, &quot;phone&quot;: &quot;0161231346&quot;,&quot;Clock-In&quot; : &quot;2020-07-11 15:39:59&quot;}, {&quot;name&quot;: &quot;Khaw Tong Lin&quot;, &quot;phone&quot;: &quot;0158398109&quot;,&quot;Clock-In&quot; : &quot;2020-08-19 11:10:18&quot;}, {&quot;name&quot;: &quot;Lim Kok Lin&quot;, &quot;phone&quot;: &quot;0168279101&quot;,&quot;Clock-In&quot; : &quot;2020-08-19 11:11:35&quot;}, {&quot;name&quot;: &quot;Low Jun Wei&quot;, &quot;phone&quot;: &quot;0112731912&quot;,&quot;Clock-In&quot; : &quot;2020-08-15 13:00:05&quot;}, {&quot;name&quot;: &quot;Yong Weng Kai&quot;, &quot;phone&quot;: &quot;0172332743&quot;,&quot;Clock-In&quot; : &quot;2020-07-31 18:10:11&quot;}, {&quot;name&quot;: &quot;Jayden Lee&quot;, &quot;phone&quot;: &quot;0191236439&quot;,&quot;Clock-In&quot; : &quot;2020-08-22 08:10:38&quot;}, {&quot;name&quot;: &quot;Kong Kah Yan&quot;, &quot;phone&quot;: &quot;0111931233&quot;,&quot;Clock-In&quot; : &quot;2020-07-11 12:00:00&quot;}, {&quot;name&quot;: &quot;Jasmine Lau&quot;, &quot;phone&quot;: &quot;0162879190&quot;,&quot;Clock-In&quot; : &quot;2020-08-01 12:10:05&quot;}, {&quot;name&quot;: &quot;Chan Saw Lin&quot;, &quot;phone&quot;: &quot;016783239&quot;,&quot;Clock-In&quot; : &quot;2020-08-23 11:59:05&quot;}, ]; </code></pre>
[ { "answer_id": 74171869, "author": "user18309290", "author_id": 18309290, "author_profile": "https://Stackoverflow.com/users/18309290", "pm_score": 1, "selected": false, "text": "_allUsers.sort((a, b) => (b[\"Clock-In\"] as String).compareTo(a[\"Clock-In\"] as String));\n" }, { "...
2022/10/23
[ "https://Stackoverflow.com/questions/74171638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19444732/" ]
74,171,675
<p>I found a tutorial of Python Loop List link - <a href="https://www.w3schools.com/python/python_lists_loop.asp" rel="nofollow noreferrer">https://www.w3schools.com/python/python_lists_loop.asp</a></p> <p>The output of both the &quot;Loop Through a List&quot; example and &quot;Loop Through the Index Numbers&quot; are the same. I just wanted to know the actual difference. it would be great, if anyone could help me out. Here are the 2 code examples (if someone doesn't want to click the link)</p> <ul> <li><p>example 1 (Loop Through a List):</p> <pre><code>thislist = [&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;] for x in thislist: print(x) </code></pre> </li> <li><p>example 2 (Loop Through the Index Numbers):</p> <pre><code>thislist = [&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;] for i in range(len(thislist)): print(thislist[i]) </code></pre> </li> </ul> <p>Thank you! I'm a beginner so don't abuse me :).</p>
[ { "answer_id": 74171869, "author": "user18309290", "author_id": 18309290, "author_profile": "https://Stackoverflow.com/users/18309290", "pm_score": 1, "selected": false, "text": "_allUsers.sort((a, b) => (b[\"Clock-In\"] as String).compareTo(a[\"Clock-In\"] as String));\n" }, { "...
2022/10/23
[ "https://Stackoverflow.com/questions/74171675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19504766/" ]
74,171,694
<p>Im trying to configure a Java Web project in VSCode and want to use Java 8 for a project.</p> <p><a href="https://i.stack.imgur.com/YpGmJ.png" rel="nofollow noreferrer">Configure Java Classpath Window</a></p> <p>The value &quot;Java Version&quot; is set to 19 and i can select other versions but it wont ever get saved. If i press CTRL+S or press the pen button next to the selection, nothing happens. If i come back to this screen after changing it its back to version 19 (which i dont want).</p> <p>Is there another way to change this setting or am i doing something wrong?</p> <p>I installed the Java Extensions Pack already.</p>
[ { "answer_id": 74171869, "author": "user18309290", "author_id": 18309290, "author_profile": "https://Stackoverflow.com/users/18309290", "pm_score": 1, "selected": false, "text": "_allUsers.sort((a, b) => (b[\"Clock-In\"] as String).compareTo(a[\"Clock-In\"] as String));\n" }, { "...
2022/10/23
[ "https://Stackoverflow.com/questions/74171694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12725564/" ]
74,171,741
<p>I'm trying to create a table with : <code>Etudiant::create($request-&gt;all());</code> But actually there is some field that I don't need from the requedt but I need them for another table; So I'm wondering if there is a function or something to add an exception to the <code>-&gt;all()</code></p>
[ { "answer_id": 74171845, "author": "Patricia", "author_id": 3836142, "author_profile": "https://Stackoverflow.com/users/3836142", "pm_score": 1, "selected": false, "text": "$request->only('val1', 'val2', ...);\n" }, { "answer_id": 74172211, "author": "Sumit kumar", "autho...
2022/10/23
[ "https://Stackoverflow.com/questions/74171741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19889813/" ]
74,171,770
<p>I have the following dataset df. For each id, a1-a3 are the values of variable a recorded at time points 1-3. b1-b3 are the values of variable b recorded at time 1-3. c is a time-invariant variable.</p> <p>Here is the codes to create the dataset:</p> <pre><code>id &lt;- c(1, 2, 3) a1 &lt;- c(52, 339, 83) a2 &lt;- c(86, 746, 35) a3 &lt;- c(46, 546, 45) b1 &lt;- c(84, 45, 83) b2 &lt;- c(55, 46, 35) b3 &lt;- c(46, 60, 45) c &lt;- c(30, 20, 50) df &lt;- cbind(id, a1, a2, a3, b1, b2, b3, c) </code></pre> <p>Here is original dataset df</p> <pre><code> id a1 a2 a3 b1 b2 b3 c [1,] 1 52 86 46 84 55 46 30 [2,] 2 339 746 546 45 46 60 20 [3,] 3 83 35 45 83 35 45 50 </code></pre> <p>I want to change it to the long format, i.e., into the following df2</p> <pre><code> time id a b c [1,] 1 1 52 84 30 [2,] 2 1 86 55 30 [3,] 3 1 46 46 30 [4,] 1 2 339 45 20 [5,] 2 2 746 46 20 [6,] 3 2 546 60 20 [7,] 1 3 83 83 50 [8,] 2 3 35 35 50 [9,] 3 3 45 45 50 </code></pre> <p>What is the best way to do that?</p> <p>I tried pivot_longer Function (tidyr Package), but it does not return what I need.</p> <p>Thank you very much for the help!</p>
[ { "answer_id": 74171939, "author": "Rui Barradas", "author_id": 8245406, "author_profile": "https://Stackoverflow.com/users/8245406", "pm_score": 1, "selected": false, "text": "name" }, { "answer_id": 74171980, "author": "jdobres", "author_id": 6436545, "author_profil...
2022/10/23
[ "https://Stackoverflow.com/questions/74171770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18213452/" ]
74,171,796
<p><strong>My code below</strong></p> <pre><code>old = &quot;&quot;&quot; B07K6VMVL5 B071XQ6H38 B0B7F6Q9BH B082KTHRBT B0B78CWZ91 B09T8TJ65B B09K55Z433 &quot;&quot;&quot; duplicate = &quot;&quot;&quot; B0B78CWZ91 B09T8TJ65B B09K55Z433 &quot;&quot;&quot; final = re.sub(r&quot;\b{}\b&quot;.format(duplicate),&quot;&quot;,old) print(final) </code></pre> <p><strong>The final always prints the old variable values.I want the duplicate values to be removed in the old variable</strong></p>
[ { "answer_id": 74171939, "author": "Rui Barradas", "author_id": 8245406, "author_profile": "https://Stackoverflow.com/users/8245406", "pm_score": 1, "selected": false, "text": "name" }, { "answer_id": 74171980, "author": "jdobres", "author_id": 6436545, "author_profil...
2022/10/23
[ "https://Stackoverflow.com/questions/74171796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19791187/" ]
74,171,823
<p>I have the following data:</p> <pre class="lang-elixir prettyprint-override"><code>data = %{ &quot;items&quot; =&gt; [ %{ &quot;countryCode&quot; =&gt; &quot;AF&quot;, &quot;id&quot; =&gt; 32_000_007, &quot;isCountry&quot; =&gt; true, &quot;name&quot; =&gt; &quot;Afghanistan&quot; }, %{ &quot;countryCode&quot; =&gt; &quot;AX&quot;, &quot;id&quot; =&gt; 32_000_008, &quot;isCountry&quot; =&gt; true, &quot;name&quot; =&gt; &quot;ร…land Islands&quot; }, %{ &quot;countryCode&quot; =&gt; &quot;AL&quot;, &quot;id&quot; =&gt; 32_000_009, &quot;isCountry&quot; =&gt; true, &quot;name&quot; =&gt; &quot;Albania&quot; } ], &quot;paging&quot; =&gt; %{&quot;cursors&quot; =&gt; %{}} } </code></pre> <p>When I call this code:</p> <pre class="lang-elixir prettyprint-override"><code>location_id = 32_000_007 Enum.find(data, fn location -&gt; location[&quot;id&quot;] == location_id end) </code></pre> <p>I get the following error:</p> <blockquote> <p>** (FunctionClauseError) no function clause matching in Access.get/3</p> <pre class="lang-elixir prettyprint-override"><code>The following arguments were given to Access.get/3: # 1 {&quot;items&quot;, [...]} # 2 &quot;id&quot; # 3 nil </code></pre> </blockquote> <p>Why do I get this error and how can I extract the item given the id?</p>
[ { "answer_id": 74171939, "author": "Rui Barradas", "author_id": 8245406, "author_profile": "https://Stackoverflow.com/users/8245406", "pm_score": 1, "selected": false, "text": "name" }, { "answer_id": 74171980, "author": "jdobres", "author_id": 6436545, "author_profil...
2022/10/23
[ "https://Stackoverflow.com/questions/74171823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19909428/" ]
74,171,862
<p>I want to zip two lists. For example:</p> <pre class="lang-py prettyprint-override"><code>a = ['a', 'b', 'c', 'd'] b = [0, 2, 1, 4] </code></pre> <p>And I have to left in the list only objects that don't match with <code>0</code>. So for lists <code>a</code> and <code>b</code> I have to get list <code>c</code>:</p> <pre class="lang-py prettyprint-override"><code>c = ['b', 'c', 'd'] </code></pre> <p>How can I do this with python? I tried using loop, but it works too long. Maybe I have to use <code>zip()</code> method, but I don't know exactly how to use it :(</p>
[ { "answer_id": 74171940, "author": "Damzaky", "author_id": 7552340, "author_profile": "https://Stackoverflow.com/users/7552340", "pm_score": 2, "selected": false, "text": "a = ['a', 'b', 'c', 'd']\nb = [0, 2, 1, 4]\n\nc = [x for (x,y) in list(zip(a,b)) if y != 0]\n" }, { "answer_...
2022/10/23
[ "https://Stackoverflow.com/questions/74171862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16494728/" ]
74,171,888
<p>I write this code and got the following result But there is a problem that if we remove the checkboxes and then click button, <strong>the results will</strong> <strong>not be updated!</strong> please help me for complete this program... Thanks :)</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const inputs = document.querySelectorAll(".inputGroup input"); const icons = document.querySelectorAll(".icons i"); let btn = document.getElementById("btn"); btn.addEventListener("click", function (e) { inputs.forEach(function (inputs) { if (inputs.checked === true) { icons.forEach(function(i){ if(inputs.dataset.id === i.getAttribute('class')) { i.style.display = 'block' } }) } }) }); </code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>.icons i { display: none; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt; &lt;title&gt;Document&lt;/title&gt; &lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css" integrity="sha512-xh6O/CkQoPOWDdYTDqeRdPCVd1SpvCA9XXcUnZS2FmJNp1coAFzvtCN9BmamE+4aHK8yyUHUSCcJHgXloTyT2A==" crossorigin="anonymous" referrerpolicy="no-referrer" /&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="inputGroup"&gt; &lt;input data-id="fa fa-user" type="checkbox" id="user"&gt; &lt;label for="user"&gt;user&lt;/label&gt; &lt;input data-id="fa fa-tree" type="checkbox" id="tree"&gt; &lt;label for="tree"&gt;tree&lt;/label&gt; &lt;input data-id="fa fa-lock" type="checkbox" id="lock"&gt; &lt;label for="fa fa-lock"&gt;lock&lt;/label&gt; &lt;button id="btn"&gt;Button&lt;/button&gt; &lt;/div&gt; &lt;div class="icons"&gt; &lt;i class="fa fa-user"&gt;&lt;/i&gt; &lt;i class="fa fa-tree"&gt;&lt;/i&gt; &lt;i class="fa fa-lock"&gt;&lt;/i&gt; &lt;/div&gt; &lt;script src="./app.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74172010, "author": "Apollo79", "author_id": 17797907, "author_profile": "https://Stackoverflow.com/users/17797907", "pm_score": 3, "selected": true, "text": "const inputs = document.querySelectorAll(\".inputGroup input\");\n\n// make icons an array to be able to use the ....
2022/10/23
[ "https://Stackoverflow.com/questions/74171888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19685717/" ]
74,171,907
<p>i want to delete Tuples out of a list if they have the same number...</p> <pre><code>list1 = [(0, 2), (0, 3), (25, 25), (0, 9), (26, 26), (27, 27)] </code></pre> <p>and I need</p> <pre><code>list2 = [(0, 2), (0, 3), (0, 9)] </code></pre> <p>Thanks a lot!</p>
[ { "answer_id": 74171919, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "list2 = [item for item in list1 if item[0] != item[1]]\n" } ]
2022/10/23
[ "https://Stackoverflow.com/questions/74171907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19840540/" ]
74,171,941
<p>I'm tring to create a new dataframe that is a combination of all the different txt with the same id as shown below. I tried to use .protuct but i'have not manage to take into account that it should only be considered for the same id.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">id</th> <th style="text-align: center;">txt</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">1</td> <td style="text-align: center;">A1</td> </tr> <tr> <td style="text-align: left;">1</td> <td style="text-align: center;">A2</td> </tr> <tr> <td style="text-align: left;">1</td> <td style="text-align: center;">A3</td> </tr> <tr> <td style="text-align: left;">2</td> <td style="text-align: center;">A4</td> </tr> <tr> <td style="text-align: left;">2</td> <td style="text-align: center;">A5</td> </tr> </tbody> </table> </div><div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">id</th> <th style="text-align: center;">txt</th> <th style="text-align: right;">txt2</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">1</td> <td style="text-align: center;">A1</td> <td style="text-align: right;">A2</td> </tr> <tr> <td style="text-align: left;">1</td> <td style="text-align: center;">A1</td> <td style="text-align: right;">A3</td> </tr> <tr> <td style="text-align: left;">1</td> <td style="text-align: center;">A2</td> <td style="text-align: right;">A3</td> </tr> <tr> <td style="text-align: left;">2</td> <td style="text-align: center;">A4</td> <td style="text-align: right;">A5</td> </tr> </tbody> </table> </div> <p>Do you have any ideas how to proceed?</p>
[ { "answer_id": 74171919, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "list2 = [item for item in list1 if item[0] != item[1]]\n" } ]
2022/10/23
[ "https://Stackoverflow.com/questions/74171941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20315016/" ]
74,171,957
<p>I have a Access table with records containg a lot of html code pieces. I want to create a form control to edit a retrieved piece of html codes. I know the Text Box control can be used for the job.</p> <p>But <strong>I hope the Text Box control would color the html tags as in VSCode to make the editing job less painful</strong>. No control seems to be available for this.</p> <p>What can I do to creat such a primitive IDE box in Access forms? Thank you!</p>
[ { "answer_id": 74173757, "author": "Olivier Jacot-Descombes", "author_id": 880990, "author_profile": "https://Stackoverflow.com/users/880990", "pm_score": 3, "selected": true, "text": "Text Format" } ]
2022/10/23
[ "https://Stackoverflow.com/questions/74171957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17727069/" ]
74,171,969
<p><a href="https://i.stack.imgur.com/Cqiay.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cqiay.png" alt="enter image description here" /></a></p> <p>Original dates have been given in POSIXct format. I need to convert it to dd-mm-yyyy. Thanks.</p>
[ { "answer_id": 74172035, "author": "br00t", "author_id": 4028717, "author_profile": "https://Stackoverflow.com/users/4028717", "pm_score": 1, "selected": false, "text": "as.POSIXct('02/11/18', format = '%d/%m/%y') |> format('%d-%m-%Y')\n" } ]
2022/10/23
[ "https://Stackoverflow.com/questions/74171969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20075726/" ]
74,171,978
<p>I have a program returns a list with uncertain length of numbers each time, and I want to append the list to dataframe. Each time, I know the column order to append but I don't know the length of the list.</p> <pre><code>df = DataFrame(columns = ['A', 'B', 'C', 'D', 'E', 'F'] </code></pre> <p>If the column order is B, C, D, E, F and the list return 3 numbers (2, 4, 6), then it will be</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>A</th> <th>B</th> <th>C</th> <th>D</th> <th>E</th> <th>F</th> </tr> </thead> <tbody> <tr> <td></td> <td>2</td> <td>4</td> <td>6</td> <td></td> <td></td> </tr> </tbody> </table> </div> <p>If the column order is E, D, C, B, A and the list return 2 numbers (4, 6), then it will be</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>A</th> <th>B</th> <th>C</th> <th>D</th> <th>E</th> <th>F</th> </tr> </thead> <tbody> <tr> <td></td> <td>2</td> <td>4</td> <td>6</td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td>6</td> <td>4</td> <td></td> </tr> </tbody> </table> </div> <p>Again I know the column order but I don't know how many numbers will be returned.</p>
[ { "answer_id": 74172081, "author": "spramuditha", "author_id": 18809515, "author_profile": "https://Stackoverflow.com/users/18809515", "pm_score": 0, "selected": false, "text": "col_names" }, { "answer_id": 74177418, "author": "medium-dimensional", "author_id": 7789963, ...
2022/10/23
[ "https://Stackoverflow.com/questions/74171978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10743957/" ]
74,171,988
<p>please I'm solving one problem (just learning purposes). I'm using <code>useState()</code> hook and then, after some timeout I want add next items into array from remote fetch.</p> <p>My code snippet look like:</p> <pre class="lang-js prettyprint-override"><code>const [tasks, setTasks] = useState([]); const url = 'https://pokeapi.co/api/v2/pokemon?offset=0&amp;limit=5'; // asnynchronous call. Yes, it's possible to use axios as well const fetchData = async () =&gt; { try { let tasksArray = []; await fetch(url) .then((response) =&gt; response.json()) .then((data) =&gt; { data.results.map((task, index) =&gt; { // first letter uppercase const taskName = task.name.charAt(0).toUpperCase() + task.name.slice(1); tasksArray.push({ id: index, name: taskName }); }); }); console.log('Added tasks:' + tasks.length); setTasks(_.isEmpty(tasks) ? tasksArray : [...tasks, tasksArray]); } catch (error) { console.log('error', error); } }; useEffect(() =&gt; { // Add additional example tasks from api after 5 seconds with // fetch fetchData promise setTimeout(fetchData, 5000); }, []); </code></pre> <p>Code works fine with <code>useEffect()</code> hook. But in <code>async</code> function my array is empty when I add some tasks within five seconds and it will be replaced by fetched data and one empty</p> <p>I added <strong>Butter</strong> and <strong>Milk</strong> within 5 seconds to my Shopping list</p> <p><a href="https://i.stack.imgur.com/Jvwl2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jvwl2.png" alt="enter image description here" /></a></p> <p>But after timeout my <code>tasks</code> array will be replaced by remote fetched data.</p> <p><a href="https://i.stack.imgur.com/4zUsa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4zUsa.png" alt="enter image description here" /></a></p> <p>And as you can see, <code>tasks</code> array lenght is 0 (like <code>console.log()</code> says)</p> <p>Please, can you exmplain me, why my tasks array is empty if there exists 2 items before 5 seconds.</p> <p>Of course, I'm adding my tasks to the list normally after hit <code>Enter</code> and <code>handleSubmit</code></p> <pre class="lang-js prettyprint-override"><code>const handleSubmit = (e) =&gt; { e.preventDefault(); //creating new task setTasks([ { id: [...tasks].length === 0 ? 0 : Math.max(...tasks.map((task) =&gt; task.id)) + 1, name: newTask, isFinished: false, }, ...tasks, ]); setNewTask(''); } </code></pre> <p>Thanks for help or explain. It the problem that <code>useEffect</code> is called after rendering? Of this causing <code>async</code> behavior?</p>
[ { "answer_id": 74172081, "author": "spramuditha", "author_id": 18809515, "author_profile": "https://Stackoverflow.com/users/18809515", "pm_score": 0, "selected": false, "text": "col_names" }, { "answer_id": 74177418, "author": "medium-dimensional", "author_id": 7789963, ...
2022/10/23
[ "https://Stackoverflow.com/questions/74171988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1169081/" ]
74,172,014
<p>PS - I am a non tech person but can create basic websites for small personal projects. I was working on a simple website where I needed to add a modal form using HTML/JS (Code below) and when I run it, it does not load the modal form on first click but works fine on the second click onwards. Tried researching but couldnt find anything or couldnt understand a lot of stuff. (The above code was derived from a form tutorial on W3schools)</p> <p><strong>EDIT</strong> - I am using the (fid) variable as I need to call this same function multiple times on the page, hence not using &quot;mybtn&quot; directly in document.getElementById(fid)</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>&lt; script &gt; function myfunc(fid) { var modal = document.getElementById("myModal"); var btn = document.getElementById(fid); var span = document.getElementsByClassName("close")[0]; btn.onclick = function () { modal.style.display = "block"; }; span.onclick = function () { modal.style.display = "none"; }; window.onclick = function (event) { if (event.target == modal) { modal.style.display = "none"; } }; } &lt; /script&gt;</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;a id="myBtn" class="btn" onclick="myfunc('myBtn')"&gt;Enquire Now&lt;/a&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74172081, "author": "spramuditha", "author_id": 18809515, "author_profile": "https://Stackoverflow.com/users/18809515", "pm_score": 0, "selected": false, "text": "col_names" }, { "answer_id": 74177418, "author": "medium-dimensional", "author_id": 7789963, ...
2022/10/23
[ "https://Stackoverflow.com/questions/74172014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20314389/" ]
74,172,021
<p>As an exercise, I wanted to create a useEffect, useState functionality from React.</p> <p>I achieved similar functionality but I don't like this part of the code:</p> <pre><code>function Comp() { let store = new Store(); let [a, setA] = useState(10, store); let [b, setB] = useState(15, store); </code></pre> <p>Basically, each time I create a new &quot;component&quot; I need to create a store. Global store doesn't work because I would need to send additional data when setting new state value ( setValue(value, &quot;KEY&quot;) ).</p> <p>Is there a design pattern or something that I could use to achieve what React does? The only thing that comes to mind is writting sort of a transpiler, but it seems like an overkill and like I am missing something.</p> <p>Link to the sandbox:</p> <p><a href="https://codesandbox.io/s/sweet-artem-wi2imw?file=/src/store.js" rel="nofollow noreferrer">https://codesandbox.io/s/sweet-artem-wi2imw?file=/src/store.js</a></p> <p>EDIT:</p> <p>The question is how to avoid passing the store to each newly created component.</p> <p>EDIT 2:</p> <p>Functionality I want to achieve:</p> <ol> <li>I create a &quot;component&quot;</li> <li>Make use of the useState hook to get [ getter, setter ] = useState(value)</li> <li>Each time a setter is called, the useEffect inside that component should be called, or more precisely it should check with store if it should be called.</li> <li>There would be numerous components, calling setValue(value) from component A should not trigger a callback effect in component B (why global store doesn't work, unless i provide additional arguments on a setter to let the store know which callbacks it should run</li> </ol>
[ { "answer_id": 74172147, "author": "bbbbbbbboat", "author_id": 8428405, "author_profile": "https://Stackoverflow.com/users/8428405", "pm_score": 2, "selected": true, "text": "new Store" }, { "answer_id": 74174525, "author": "urth", "author_id": 7853991, "author_profil...
2022/10/23
[ "https://Stackoverflow.com/questions/74172021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7853991/" ]
74,172,026
<p>I would like to load images dynamically from an images folder. Names in the folder like <em>{company_name}.png</em>. The names are stored in a <em>json</em> file along with other company data like name, type, etc.</p> <pre><code>e.g.: name: meta logo: &quot;./images/meta.png&quot; </code></pre> <p>Is there any way to dynamically load these images like <em>require(<em><strong>changing variable based on the json logo string</strong></em>)</em>.</p> <hr /> <p>I found some solution online like: <a href="https://stackoverflow.com/a/52598171/7990652">https://stackoverflow.com/a/52598171/7990652</a></p> <p>But all the other things are build around the <em>json</em> structure to load all the other data. Is there any way to load everything from a folder one by one based on the provided logo link in the <em>json</em>?</p> <hr /> <p>I also tried to look around for a solution with <strong>babilon require all</strong> plugin, but I found nothing about that.</p> <p><em>P.S. I know there are sevaral threads about this question, but in almost all the threads someone asking &quot;what about if I want to load 100-1000 images?&quot;. That is the case with me too, I would like to load a lot of images, not just up to 10-20 which is complately okay with static .js require list.</em></p>
[ { "answer_id": 74175223, "author": "Abe", "author_id": 10718641, "author_profile": "https://Stackoverflow.com/users/10718641", "pm_score": 0, "selected": false, "text": "require" }, { "answer_id": 74175309, "author": "Fiston Emmanuel", "author_id": 12431576, "author_p...
2022/10/23
[ "https://Stackoverflow.com/questions/74172026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7990652/" ]
74,172,055
<p>I have a sidebar with buttons links that targets div id and URL ends with #id_name. Now I want to render data that matches #id_name in a map loop using this code:</p> <pre><code>&lt;div&gt; {entries.map((item, index) =&gt; { if (asPath.endsWith(`#${item.section}`)) return ( &lt;div id={item.section} key={index}&gt; &lt;h3&gt;{item.title}&lt;/h3&gt; &lt;p&gt;{item.summary}&lt;/p&gt; &lt;/div&gt; ); })} &lt;/div&gt; </code></pre> <p>It works on refresh if #id_name matches item.section but if I click another link nothing happens even if item.section matches #id_name.</p> <p>How can I re-render the map loop without refreshing or leaving the page when #id_name changes?</p>
[ { "answer_id": 74175223, "author": "Abe", "author_id": 10718641, "author_profile": "https://Stackoverflow.com/users/10718641", "pm_score": 0, "selected": false, "text": "require" }, { "answer_id": 74175309, "author": "Fiston Emmanuel", "author_id": 12431576, "author_p...
2022/10/23
[ "https://Stackoverflow.com/questions/74172055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17028009/" ]
74,172,060
<p>I was writing a simple annual salary calculation and I discovered I am unable to start a new line with '$' while using the '\n' escape character.</p> <p>This is what I've been trying to re-work;</p> <pre><code>monthlyPay = 5000 annualPay = monthlyPay * 12 print( &quot;Your annual pay is: \n $&quot;, format(annualPay, ',.2f') ) </code></pre>
[ { "answer_id": 74172103, "author": "essesoul", "author_id": 20222246, "author_profile": "https://Stackoverflow.com/users/20222246", "pm_score": 1, "selected": false, "text": "monthlyPay = 5000\nannualPay = monthlyPay * 12\nprint(\n \"Your annual pay is: \\n $\",\n format(annualPay,...
2022/10/23
[ "https://Stackoverflow.com/questions/74172060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20315193/" ]
74,172,067
<p>Sorry for change the question for I cannot ask for a new one.</p> <p>Original data is</p> <pre><code> D T C &lt;dbl&gt; &lt;dbl&gt; &lt;chr&gt; 1 1 2000 A 2 2 2000 A 3 3 2000 A 4 1 2000 B 5 5 2000 B 6 6 2000 B 7 1 2001 A 8 2 2001 A 9 3 2001 B </code></pre> <p>What I need is</p> <pre><code> D T C count &lt;dbl&gt; &lt;dbl&gt; &lt;chr&gt; &lt;int&gt; 1 1 2000 A 3 2 2 2000 A 3 3 3 2000 A 3 4 1 2000 B 3 5 5 2000 B 3 6 6 2000 B 3 7 1 2001 A 2 8 2 2001 A 2 9 3 2001 B 1 </code></pre> <p>I want count the cell D by_group(T,C)</p> <p>However the answer code</p> <pre><code>sample%&gt;%group_by(T,C) %&gt;% mutate(count = n_distinct(D)) </code></pre> <p>Which count is 5 for all</p>
[ { "answer_id": 74172116, "author": "br00t", "author_id": 4028717, "author_profile": "https://Stackoverflow.com/users/4028717", "pm_score": 0, "selected": false, "text": "df <- structure(list(cty_fips = structure(c(\"01001\", \"01001\", \"01001\", \n ...
2022/10/23
[ "https://Stackoverflow.com/questions/74172067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14807977/" ]
74,172,099
<p>I am trying to use Rx(.net) for a project and I have an issue with how to properly dispose resources that are created during <code>Observable.Create()</code> and emitted with <code>OnNext()</code>. My setup looks like this (shortened to the relevant bits only, hopefully):</p> <pre><code>var obs = Observable.Create&lt;ReactiveRunData&gt;(async (o) =&gt; { if (someCondition) { RunData runData = await CreateRunData(); // RunData is IDisposable, needs to be disposed o.OnNext(runData); } o.OnCompleted(); return Disposable.Empty; }) .Concat(Observable.Empty&lt;RunData&gt;().Delay(TimeSpan.FromSeconds(2))) .Repeat() // Resubscribe indefinitely after source completes .Publish().RefCount() // see http://northhorizon.net/2011/sharing-in-rx/ ; </code></pre> <p>This is my implementation of an observable collection that's infinite and produces an item (of type <code>RunData</code>) every 2 seconds.</p> <p>Then I do the actual reactive stuff by transforming the IObservable stream using all kinds of operators:</p> <pre><code>var final = obs .Select(runData =&gt; ...) // lots of other operations .Select(tuple =&gt; (tuple.runData, tuple.result));` </code></pre> <p>The final observable returns a tuple <code>(RunData, Result)</code>.</p> <p>When subscribing to that observable, at the end I explicitly dispose of the <code>RunData</code> instances, like so:</p> <pre><code>final.Subscribe( async (tuple) =&gt; { var (runData, result) = tuple; try { // ... do something with result and runData, await some stuff, ... } catch (Exception e) { // error handling } finally { // dispose of runData runData.Dispose(); } }, (Exception e) =&gt; { // error handling }); </code></pre> <p>I suspect this implementation is leaky in various ways, such as when exceptions are thrown from different places, in some cases of which I believe the RunData instance won't get disposed, but is just gone, replaced by an exception travelling through the pipe.</p> <p>I believe I'd also run into problems if I would add a second subscriber to my observable, right? I don't need more than one subscriber, but that also makes me question my implementation.</p> <p>I feel like the whole idea of passing data that needs to be disposed by subscribers is wrong, but I couldn't come up with a better way. I tried using <code>Observable.Using()</code>, but afaik that only disposes the resource when the sequence ends, which in my case is never. And I really need an infinite sequence because I want to be able to use functionality like <code>Scan()</code> to reference previous data to build intermediate data structures over time.</p> <p>I also tried using the callback that is returned from the lambda of <code>Observable.Create()</code> but that fires as soon as Observable.Create() is done and not after the subscriber is done, so that led to race conditions (but I'm not even sure if I understood that correctly, RX + async is tricky).</p> <p>So... how can I implement this properly?</p> <p>For some background info, <code>RunData</code> includes (among other things) a DB transaction and an Autofac <code>LifetimeScope</code>, both of which I want to use throughout the pipeline, and both of which need to be disposed at the end, after the subscriber is done.</p>
[ { "answer_id": 74173464, "author": "Perfect28", "author_id": 3655779, "author_profile": "https://Stackoverflow.com/users/3655779", "pm_score": 1, "selected": false, "text": "Observable\n .FromAsync<MemoryStream>(async => Task.FromResult(new MemoryStream()))\n .Select(d => Observabl...
2022/10/23
[ "https://Stackoverflow.com/questions/74172099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/184619/" ]
74,172,113
<p>I have an array that containts elements out of words. I want to have a sorted list at the end. How do I do this in python? Thanks</p> <p>Eg:</p> <pre><code>SETACTION = &quot;forever&quot;, &quot;for one and&quot;, &quot;for two&quot; </code></pre> <p>=&gt;</p> <pre><code>SETACTION = &quot;for one and&quot;, &quot;for two&quot;, &quot;forever&quot; </code></pre>
[ { "answer_id": 74173464, "author": "Perfect28", "author_id": 3655779, "author_profile": "https://Stackoverflow.com/users/3655779", "pm_score": 1, "selected": false, "text": "Observable\n .FromAsync<MemoryStream>(async => Task.FromResult(new MemoryStream()))\n .Select(d => Observabl...
2022/10/23
[ "https://Stackoverflow.com/questions/74172113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4475647/" ]
74,172,121
<p>I have the following data frame:</p> <pre><code>df = { 'name': ['A', 'A', 'B', 'B', 'B', 'C', 'C'], 'name_ID' : [1, 1, 2, 2, 2, 3, 3], 'score' : [400, 500, 3000, 1000, 4000, 600, 750], 'score_number' : [1, 2, 1, 2, 3, 1, 2] } df = pd.DataFrame(df) </code></pre> <p>Note that the df is grouped by <code>name</code> / <code>name_ID</code>. <code>names</code> can have n scores, e.g. <code>A</code> has 2 scores, whereas <code>B</code> has 3 scores. I want an additional column, that indicates the first score per <code>name</code> / <code>name_ID</code>. The <code>reference_score</code> for the first scores of a name should be NaN. Like this:</p> <p><a href="https://i.stack.imgur.com/osJYI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/osJYI.png" alt="enter image description here" /></a></p> <p>I have tried: <code>df_v2['first_fund'] =df_v2['fund_size'].groupby(df_v2['firm_ID']).first()</code>, also with <code>.nth</code> but it didn't work.</p> <p>Thanks in advance.</p>
[ { "answer_id": 74172189, "author": "Ynjxsjmh", "author_id": 10315163, "author_profile": "https://Stackoverflow.com/users/10315163", "pm_score": 3, "selected": true, "text": "groupby.transform" }, { "answer_id": 74172238, "author": "Andrej Kesely", "author_id": 10035985, ...
2022/10/23
[ "https://Stackoverflow.com/questions/74172121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13936100/" ]
74,172,129
<p>I have a DataFrame with daily values and I am building out a forecast using various methods predicting the values for the next two weeks.</p> <p>As a base, naive, forecast I want to simply say the value today is the best forcast for the next two weeks e.g.:</p> <ul> <li>the value on <code>01-Jan-2012</code> is <code>100</code>, then I would like the forecast for <code>02-Jan-2012</code> to <code>15-Jan-2022</code> to be <code>100</code></li> <li>the value on <code>02-Jan-2012</code> is <code>110</code>, then I would like the forecast for <code>03-Jan-2012</code> to <code>16-Jan-2022</code> to be <code>110</code></li> <li>etc</li> </ul> <p>This method can then be compared to the other forecasts to see whether they add value over a naive approach.</p> <p>To backtest this model how can I do this? I have a few years worth of data in a DataFrame, and I want to do something like below. Reading online, I can only find 1 day persistence help whereby simply using something like <code>df.shift(1)</code> does the job.</p> <pre><code>Pseudocode: get the first row from the DataFrame extract the date from the index extract the value from the column propogate forward this value for the next fourteen days save these forecast dates and forecast values get the second row from the DataFrame extract the date from the index extract the value from the column propogate forward this value for the next fourteen days save these forecast dates and forecast values REPEAT... </code></pre> <p>However, I've read that iterating over rows is advised against and it is better to use something like pandas <code>apply</code> to 'vectorize' the data but I am not sure how to do this. I was thinking of writing a function to predict the next 14 days then using the <code>apply</code> method to call this function, but not sure how to do so or if this is the best way.</p> <p>I've also read that numpy is very good for these sorts of problems, but again, am not too familiar.</p> <p>I've set up a sqlite database so I can store forecasts in there if that helps.</p>
[ { "answer_id": 74246444, "author": "Horace", "author_id": 9162021, "author_profile": "https://Stackoverflow.com/users/9162021", "pm_score": 0, "selected": false, "text": "df = pd.DataFrame(\n dict(date=[\"2012-01-01\", \"2012-01-02\", \"2012-01-03\"], a=[50, 100, 200])\n)\n\ndf = df.a...
2022/10/23
[ "https://Stackoverflow.com/questions/74172129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10885908/" ]
74,172,158
<p>All Lisp developers seem to know what an S-Expression is. But can anybody explain this for non Lisp developers?</p> <p>There is already a Wikipedia entry (<a href="https://en.wikipedia.org/wiki/S-expression" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/S-expression</a>). But that is not really helpful if you don't want to go deeply into detail.</p> <p>What is an S-Expression? What can I express with an S-Expression? For what purpose uses Lisp normally S-Expressions? Are S-Expressions only relevant for Lisp developers?</p>
[ { "answer_id": 74172453, "author": "Kaz", "author_id": 1250772, "author_profile": "https://Stackoverflow.com/users/1250772", "pm_score": 2, "selected": false, "text": "0" }, { "answer_id": 74172551, "author": "Silvio Mayolo", "author_id": 2288659, "author_profile": "h...
2022/10/23
[ "https://Stackoverflow.com/questions/74172158", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19446851/" ]
74,172,159
<p>Using Node, Express and Mongoose, I'm trying to insert data into MongoDB through a POST method. The fields I'm trying to insert has a phone field on which I'm trying to assign a validation that will check if it has minimum ten digits. Otherwise, it'll throw validation error message. While inserting the data, it is being saved even though the phone field has less than ten digits. Why is this happening? And how to solve it? Please be advised, it is happening in case of inserting a data to MongoDB.</p> <p>Here's the Mongoose model:</p> <pre><code>const mongoose = require('mongoose'); const validator = require('validator'); const schema = new mongoose.Schema({ name: { type: String, required: true, minLength: [2, 'Name should contain at least two characters!'], trim: true }, email: { type: String, required: true, trim: true, validate(value) { if (!validator.isEmail(value)) throw new Error('Invalid email!'); } }, phone: { type: Number, required: true, min: [10, 'Phone number should contain at least ten digits!'], trim: true }, message: { type: String, required: true, minLength: [3, 'Message should contain at least three characters!'], trim: true }, date: { type: Date, required: true, default: Date.now } }); const RdwMessage = new mongoose.model('RdwMessage', schema); module.exports = RdwMessage; </code></pre> <p>Here's the route to insert the data through POST:</p> <pre><code>app.post('/contact', async (req, res) =&gt; { try { const doc = new RdwMessage(req.body); await doc.save(); res.status(201).render('index'); } catch (error) { res.status(404).send(`Failed to submit message with the following error: ${error}`); } }); </code></pre>
[ { "answer_id": 74172453, "author": "Kaz", "author_id": 1250772, "author_profile": "https://Stackoverflow.com/users/1250772", "pm_score": 2, "selected": false, "text": "0" }, { "answer_id": 74172551, "author": "Silvio Mayolo", "author_id": 2288659, "author_profile": "h...
2022/10/23
[ "https://Stackoverflow.com/questions/74172159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/423017/" ]
74,172,197
<p>I have a Terraform codebase which deploys a private EKS cluster, a bastion host and other AWS services. I have also added a few security groups to the in Terraform. One of the security groups allows inbound traffic from my Home IP to the bastion host so that i can SSH onto that node. This security group is called <code>bastionSG</code>, and that works fine also.</p> <p>However, initially I am unable to run kubectl from my bastion host, which is the node I use to carry out my kubernetes development on against the EKS cluster nodes. The reason is because my EKS cluster is a private and only allows communication from nodes in the same VPC and i need to add a security group that allows the communication from my bastion host to the <code>cluster control plane</code> which is where my security group bastionSG comes in.</p> <p>So my routine now is once Terraform deploys everything, I then find the automatic generated EKS security group and add my <code>bastionSG</code> as an inbound rule to it through the AWS Console (UI) as shown in the image below.</p> <p><a href="https://i.stack.imgur.com/7Dv2d.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7Dv2d.png" alt="enter image description here" /></a></p> <p>I would like to NOT have to do this through the UI, as i am already using Terraform to deploy my entire infrastructure.</p> <p>I know i can query an existing security group like this</p> <pre><code>data &quot;aws_security_group&quot; &quot;selectedSG&quot; { id = var.security_group_id } </code></pre> <p>In this case, lets say <code>selectedSG</code> is the security group creared by EKS once terraform is completed the apply process. I would like to then add an inbound rule of <code>bastionSG</code> to it without it ovewriting the others it's added automatically.</p> <p><strong>UPDATE: &gt; EKS NODE GROUP</strong></p> <pre><code>resource &quot;aws_eks_node_group&quot; &quot;flmd_node_group&quot; { cluster_name = var.cluster_name node_group_name = var.node_group_name node_role_arn = var.node_pool_role_arn subnet_ids = [var.flmd_private_subnet_id] instance_types = [&quot;t2.small&quot;] scaling_config { desired_size = 3 max_size = 3 min_size = 3 } update_config { max_unavailable = 1 } remote_access { ec2_ssh_key = &quot;MyPemFile&quot; source_security_group_ids = [ var.allow_tls_id, var.allow_http_id, var.allow_ssh_id, var.bastionSG_id ] } tags = { &quot;Name&quot; = &quot;flmd-eks-node&quot; } } </code></pre> <p>As shown above, the EKS node group has the bastionSG security group in it. which i expect to allow the connection from my bastion host to the EKS control plane.</p> <p><strong>EKS Cluster</strong></p> <pre><code>resource &quot;aws_eks_cluster&quot; &quot;flmd_cluster&quot; { name = var.cluster_name role_arn = var.role_arn vpc_config { subnet_ids =[var.flmd_private_subnet_id, var.flmd_public_subnet_id, var.flmd_public_subnet_2_id] endpoint_private_access = true endpoint_public_access = false security_group_ids = [ var.bastionSG_id] } } </code></pre> <p><code>bastionSG_id</code> is an output of the security group created below which is passed into the code above as a variable.</p> <p><strong>BastionSG security group</strong></p> <pre><code>resource &quot;aws_security_group&quot; &quot;bastionSG&quot; { name = &quot;Home to bastion&quot; description = &quot;Allow SSH - Home to Bastion&quot; vpc_id = var.vpc_id ingress { description = &quot;Home to bastion&quot; from_port = 22 to_port = 22 protocol = &quot;tcp&quot; cidr_blocks = [&lt;MY HOME IP address&gt;] } egress { from_port = 0 to_port = 0 protocol = &quot;-1&quot; cidr_blocks = [&quot;0.0.0.0/0&quot;] ipv6_cidr_blocks = [&quot;::/0&quot;] } tags = { Name = &quot;Home to bastion&quot; } } </code></pre>
[ { "answer_id": 74172453, "author": "Kaz", "author_id": 1250772, "author_profile": "https://Stackoverflow.com/users/1250772", "pm_score": 2, "selected": false, "text": "0" }, { "answer_id": 74172551, "author": "Silvio Mayolo", "author_id": 2288659, "author_profile": "h...
2022/10/23
[ "https://Stackoverflow.com/questions/74172197", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5351206/" ]
74,172,200
<p>I have the below serializer:</p> <pre class="lang-py prettyprint-override"><code>class OrderItemResponseSerializer(serializers.ModelSerializer): prepack_qty = serializers.SerializerMethodField() product_description = serializers.SerializerMethodField() class Meta: model = OrderItem fields = ( &quot;product&quot;, &quot;qty_ordered&quot;, &quot;qty_approved&quot;, &quot;status&quot;, &quot;prepack_qty&quot;, &quot;product_description&quot; ) def get_prepack_qty(self, obj): return obj.product.prepack_quantity def get_product_description(self, obj): return obj.product.product_description </code></pre> <p>When I make a get request to <code>/orders</code>, I make a lot of SQL queries to the database because different orders may contain the same product. How can I cache the result of <code>get_prepack_qty</code> and get_product_description methods? I tried to use <code>@cached_property</code> this way:</p> <pre class="lang-py prettyprint-override"><code>class OrderItem(models.Model): ... @cached_property def item_product_description(self): return self.product.product_description </code></pre> <p>But the number of requests to the database remained the same.</p>
[ { "answer_id": 74173164, "author": "Javad", "author_id": 11833435, "author_profile": "https://Stackoverflow.com/users/11833435", "pm_score": 2, "selected": true, "text": " ...\n @cached_property\n def item_product_description(self):\n return self.product.product_descripti...
2022/10/23
[ "https://Stackoverflow.com/questions/74172200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17108842/" ]
74,172,229
<p>The React component library should provide a provision to the consuming project to pass configuration file that the component library will use (either during build / runtime)</p> <p>The configuration file might contain primary, secondary Colors, typography details. (Similiar to how Tailwind has tailwind.config.js)</p> <p>How do I create this in React JS ?</p> <p>Here is the component library that I've built so far: <a href="https://github.com/fyndreact/nitrozen" rel="nofollow noreferrer">https://github.com/fyndreact/nitrozen</a></p> <p>Any kind of direction would really help.</p>
[ { "answer_id": 74214555, "author": "Vadim Rogov", "author_id": 14136174, "author_profile": "https://Stackoverflow.com/users/14136174", "pm_score": 1, "selected": false, "text": "my-app/\nโ”œโ”€ node_modules/\nโ”‚ โ”œโ”€ myLib/\nโ”‚ โ”‚ โ”œโ”€ index.js\nโ”œโ”€ src/\nโ”‚ โ”œโ”€ index.css\nโ”‚ โ”œโ”€ index.js\nโ”œโ”€ myLib...
2022/10/23
[ "https://Stackoverflow.com/questions/74172229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8389274/" ]
74,172,274
<p>I've always been puzzled why I cannot create files in $HOME directory using user_data when using an aws_instance resource. Even a simple &quot;touch a.txt&quot; in user_data would not create the file.</p> <p>I have worked around this by creating files in other directories (e.g. /etc/some_file.txt) instead. But I am really curious what's the reason behind this &amp; if there is a way to create files in $HOME with user_data.</p> <p>Thank you.</p> <p>----- 1st edit ----- Sample code:</p> <pre><code>resource &quot;aws_instance&quot; &quot;ubuntu&quot; { ami = var.ubuntu_ami instance_type = var.ubuntu_instance_type subnet_id = aws_subnet.ubuntu_subnet.id associate_public_ip_address = &quot;true&quot; key_name = var.key_name vpc_security_group_ids = [aws_security_group.standard_sg.id] user_data = &lt;&lt;-BOOTSTRAP #!/bin/bash touch /etc/1.txt # this file is created in /etc/1.txt touch 2.txt # 2.txt is not created in $HOME/2.txt BOOTSTRAP tags = { Name = &quot;${var.project}_eks_master_${count.index + 1}&quot; } } </code></pre>
[ { "answer_id": 74214555, "author": "Vadim Rogov", "author_id": 14136174, "author_profile": "https://Stackoverflow.com/users/14136174", "pm_score": 1, "selected": false, "text": "my-app/\nโ”œโ”€ node_modules/\nโ”‚ โ”œโ”€ myLib/\nโ”‚ โ”‚ โ”œโ”€ index.js\nโ”œโ”€ src/\nโ”‚ โ”œโ”€ index.css\nโ”‚ โ”œโ”€ index.js\nโ”œโ”€ myLib...
2022/10/23
[ "https://Stackoverflow.com/questions/74172274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15589282/" ]
74,172,293
<p>At the most basic of understanding, I've been trying to match the route and the <em>form</em> action. I think that I am doing it right but I wonder why does the error keeps on showing ? I may have missed something anywhere but I just really couldn't find it. Please help. In a very tight schedule, I need to complete this project by tuesday</p> <p>P.S : when i submit the form it goes to this address <a href="http://127.0.0.1:8000/profile/edit/1" rel="nofollow noreferrer">http://127.0.0.1:8000/profile/edit/1</a> .</p> <p>Form</p> <pre><code>&lt;x-layout&gt; &lt;x-setting heading=&quot;Edit Staff Profile&quot;&gt; &lt;div class=&quot;flex flex-col&quot;&gt; &lt;form method=&quot;POST&quot; action=&quot;/profile/edit/{{$profil-&gt;id}}&quot; enctype=&quot;multipart/form-data&quot;&gt; @csrf &lt;div class=&quot;mb-6&quot;&gt; &lt;label class=&quot;block mb-2 uppercase font-bold text-sm text-gray-700&quot; for=&quot;images&quot;&gt; Profile photo &lt;/label&gt; &lt;input type=&quot;file&quot; name=&quot;images&quot;&gt; &lt;/div&gt; </code></pre> <p>Route</p> <pre><code>Route::get('profile', [UserController::class, 'index'])-&gt;middleware('auth')-&gt;name('profile'); Route::get('profile/edit/{id}', [UserController::class, 'show'])-&gt;middleware('auth'); Route::post('profile/edit/{id}', [UserController::class, 'update'])-&gt;middleware('auth'); </code></pre> <p>UserController</p> <pre><code>&lt;?php namespace App\Http\Controllers; use App\Models\User; use App\Models\Profile; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; class UserController extends Controller { public function index() { $id = Auth::user()-&gt;id; $info = User::where('id', $id)-&gt;first(); return view('profile', compact('info')); } // public function create() // { // return view('staffrecord.create'); // } public function store() { $attributes = request()-&gt;validate([ 'name' =&gt; 'required|max:255', 'username' =&gt; 'required|min:3|max:255|unique:users,username', 'email' =&gt; 'required|email|max:255|unique:users,email', 'password' =&gt; 'required|min:7|max:255', ]); if (auth()-&gt;attempt($attributes)) { return redirect('/')-&gt;with('success', 'Your account has been created.'); } return redirect('/profile')-&gt;with('errors', 'Authentication failed.'); } public function show($id) { $profil = User::findOrFail($id); return view('staffrecord.edit', compact('profil')); } public function edit() { $id = Auth::user()-&gt;id; $profil = Profile::findOrFail($id); return view('staffrecord.edit', compact('profil')); } public function update(Request $request, $id) { $data = Profile::findOrFail($id); $data-&gt;staff_id = $request-&gt;staff_id; $data-&gt;name = $request-&gt;name; $data-&gt;gender = $request-&gt;gender; $data-&gt;address = $request-&gt;address; $data-&gt;email = $request-&gt;email; $data-&gt;phonenumber = $request-&gt;phonenumber; $data-&gt;department = $request-&gt;department; $data-&gt;save(); return redirect('/')-&gt;route('profile'); } } </code></pre>
[ { "answer_id": 74214555, "author": "Vadim Rogov", "author_id": 14136174, "author_profile": "https://Stackoverflow.com/users/14136174", "pm_score": 1, "selected": false, "text": "my-app/\nโ”œโ”€ node_modules/\nโ”‚ โ”œโ”€ myLib/\nโ”‚ โ”‚ โ”œโ”€ index.js\nโ”œโ”€ src/\nโ”‚ โ”œโ”€ index.css\nโ”‚ โ”œโ”€ index.js\nโ”œโ”€ myLib...
2022/10/23
[ "https://Stackoverflow.com/questions/74172293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20134724/" ]
74,172,308
<p>How can append each column with one fixed one dimensional array in a dataframe?</p> <pre><code>df = pd.DataFrame([ ['234', '434', '471', '4744', '477'], ['2.4', '2.4', '2.4'], ]) df.columns = ['col 1', 'col 2', 'col 3', 'col 4', 'col 5'] df col 1 col 2 col 3 col 4 col 5 234 434 473 4744 477 2.4 2.4 2.4 2.4 2.4 oneD_array = [1, 0, 0, 1, 2, 3] </code></pre> <p>how can I add my <code>oneD_array</code> to the each column of given dataframe <code>df</code>.</p> <p><strong>expected output</strong></p> <pre><code>df col 1 col 2 col 3 col 4 col 5 234 434 473 4744 477 2.4 2.4 2.4 2.4 2.4 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 </code></pre>
[ { "answer_id": 74214555, "author": "Vadim Rogov", "author_id": 14136174, "author_profile": "https://Stackoverflow.com/users/14136174", "pm_score": 1, "selected": false, "text": "my-app/\nโ”œโ”€ node_modules/\nโ”‚ โ”œโ”€ myLib/\nโ”‚ โ”‚ โ”œโ”€ index.js\nโ”œโ”€ src/\nโ”‚ โ”œโ”€ index.css\nโ”‚ โ”œโ”€ index.js\nโ”œโ”€ myLib...
2022/10/23
[ "https://Stackoverflow.com/questions/74172308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17289097/" ]
74,172,437
<p>How to use linear-gradient text in react native mobile apps (android apps)? no expo and I want to make text color in linear-gradient how can I do? is it possible if yes than how and if no than how popular apps use linear-gradient text they also use react native in their tech stack tired tired to give color style to color linear-gradient but it didn't work</p> <pre><code>background: linear-gradient(90.35deg, #33DFDF 10.9%, #0047FF 25.48%, #00A3FF 40.06%, #044AFF 54.65%, #FA00FF 69.23%, #D90AFB 83.81%); </code></pre> <h1>my code</h1> <pre><code>//import liraries import React from 'react'; import { Image, Text, View, TouchableOpacity } from 'react-native'; import WrapperContainer from '../../Components/WrapperContainer'; import imagePath from '../../constatns/imagePath'; import strings from '../../constatns/lang'; import navigationStrings from '../../constatns/navigationStrings'; import colors from '../../styles/colors'; import styles from './styles'; import LinearGradient from 'react-native-linear-gradient'; import MaskedView from '@react-native-masked-view/masked-view'; const TermsCondition = ({ navigation }) =&gt; { return ( &lt;WrapperContainer containerStyle={{ alignItems: 'center' }}&gt; &lt;Image resizeMode='contain' style={styles.logoStyle} source={imagePath.icLogo} /&gt; &lt;Text style={styles.headingStyle}&gt;{strings.WELCOME_TO_ourapp}&lt;/Text&gt; &lt;Text style={styles.descStyle}&gt;{strings.READ_OUR} &lt;Text style={{ color: colors.lightBlue }}&gt;{strings.PRIVACY_POLICY}&lt;/Text&gt; {strings.TAP_AGREE_AND_CONTINUE_TO_CEEPT_THE} &lt;Text style={{ color: colors.lightBlue }}&gt;{strings.TERMS_OF_SERVICE} &lt;/Text&gt;&lt;/Text&gt; &lt;TouchableOpacity onPress={() =&gt; navigation.navigate(navigationStrings.PHONE_NUMBER)} activeOpacity={0.7}&gt; &lt;Text style={styles.agreeStyle}&gt;{strings.AGREE_AND_CONTINUE}&lt;/Text&gt; &lt;/TouchableOpacity&gt; &lt;/WrapperContainer&gt; ); }; export default TermsCondition; </code></pre>
[ { "answer_id": 74176690, "author": "Asher Azriel Ginting", "author_id": 19295102, "author_profile": "https://Stackoverflow.com/users/19295102", "pm_score": 2, "selected": false, "text": "react-native-linear-gradient" }, { "answer_id": 74179563, "author": "Oussama Mg", "au...
2022/10/23
[ "https://Stackoverflow.com/questions/74172437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20659824/" ]
74,172,466
<p>I'm trying to extract data from several 1,000 XML files and compose a single df from it.</p> <p>The code I have so far is for a single XML extraction.</p> <pre><code>from lxml import etree import pandas as pd serial = [&quot;S1.xml&quot;] content = serial.encode('utf-8') doc = etree.XML(content) targets = doc.xpath('/reiXmlPrenos') data = [] for target in targets: data.append(target.xpath(&quot;./@A&quot;)[0]) data.append(target.xpath(&quot;./@z&quot;)[0]) columns = ['A', 'Z'] pd.DataFrame([data],columns=columns) </code></pre> <p>The XML file looks like this:</p> <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; standalone=&quot;no&quot;?&gt; &lt;reiXmlPrenos&gt; &lt;Qf&gt;255340&lt;/Qf&gt; &lt;Qp&gt;597451&lt;/Qp&gt; &lt;CO2&gt;126660&lt;/CO2&gt; &lt;A&gt;2362.8&lt;/A&gt; &lt;Ht&gt;0.336&lt;/Ht&gt; &lt;f0&gt;0.59&lt;/f0&gt; &lt;z&gt;0.105891&lt;/z&gt; &lt;/reiXmlPrenos&gt; </code></pre> <p>For the final df I'd like for it to look like this:</p> <pre><code> A z S1.xml 2362 0.105891 S2.xml ... ... ... </code></pre> <p>The error that i'm getting is</p> <pre><code>line 16, in &lt;module&gt; content = serial.encode('utf-8') AttributeError: 'list' object has no attribute 'encode' </code></pre> <p>Can you please find me the error that i'm making and then to expand the code, so it could load all xml files in the same folder?</p>
[ { "answer_id": 74172847, "author": "LMC", "author_id": 2834978, "author_profile": "https://Stackoverflow.com/users/2834978", "pm_score": 3, "selected": true, "text": "from lxml import etree\nimport pandas as pd\n\nserial = [\"tmp.xml\", \"S2.xml\"]\ncolumns = [\"file\",'A', 'Z']\n\nall_d...
2022/10/23
[ "https://Stackoverflow.com/questions/74172466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3579151/" ]
74,172,479
<p>i'm working on a Laravel/Livewire project</p> <p>there are some products and services in this platform that user can order them.</p> <p>the price of these products and services are changeable by their attributes . like size,color,quality and....</p> <p>and i made a Many To Many relation between products and attributes.</p> <p>but a can't handle it in my view where user should select that attributes before ordering</p> <p>and my for each loop return wrong data . and i get this error :</p> <p>Trying to get property 'pivot' of non-object .</p> <p>my migration :</p> <pre><code> public function up() { Schema::create('attr_product', function (Blueprint $table) { $table-&gt;foreignId('attr_id')-&gt;constrained(); $table-&gt;foreignId('product_id')-&gt;constrained(); $table-&gt;string('value')-&gt;nullable(); $table-&gt;string('price')-&gt;nullable(); $table-&gt;timestamps(); }); } </code></pre> <p>product model :</p> <pre><code>public function attr(){ return $this-&gt;belongsToMany(Attr::class)-&gt;withPivot(['value','price'])-&gt;withTimestamps(); } </code></pre> <p>attr model:</p> <pre><code>public function product(){ return $this-&gt;belongsToMany(Product::class)-&gt;withPivot(['value','price'])-&gt;withTimestamps(); } </code></pre> <p>my controller :</p> <pre><code> class SingleProduct extends Component { public $product; public function mount($id){ $this-&gt;product=Product::with('attr')-&gt;findOrFail($id); } public function render() { return view('livewire.front.product.single-product')-&gt;extends('layouts.Default')-&gt;section('content'); } } </code></pre> <p>my loop in blade :</p> <pre><code> @foreach($product-&gt;attr as $attr) &lt;div class=&quot;col-lg-4 col-sm-6 mt-3&quot;&gt; &lt;h6 class=&quot;mb-2 text-black&quot;&gt;{{$attr-&gt;title}}&lt;/h6&gt; &lt;select class=&quot;custom-select shadow-none&quot;&gt; @foreach($attr as $av) &lt;option value=&quot;{{$av-&gt;pivot-&gt;price}}&quot;&gt;{{$av-&gt;pivot-&gt;value}}&lt;/option&gt; @endforeach &lt;/select&gt; &lt;/div&gt; @endforeach </code></pre>
[ { "answer_id": 74172590, "author": "didene tahi", "author_id": 7263394, "author_profile": "https://Stackoverflow.com/users/7263394", "pm_score": -1, "selected": false, "text": "withPivot" }, { "answer_id": 74177169, "author": "raimondsL", "author_id": 4354065, "author...
2022/10/23
[ "https://Stackoverflow.com/questions/74172479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15346826/" ]
74,172,483
<p>It is my first question because I can't find solution for my easy problem (i guess). I don't know why my div is changing its position when it should rotate around itself. How can i resolve a problem of this type? I found some similar questions but about different location of their divs that don't point me to the answer.</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>* { box-sizing: border-box; margin: 0; padding: 0; } body { font-family: sans-serif; font-size: 30px; color: white; background-color: #333; overflow: hidden; } .square { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); height: 400px; width: 400px; background-color: gold; border: 3px solid black; animation: square 4s ease-in-out .5s infinite; animation-direction: alternate; transition: transform 2s; } @keyframes square { from { top: 20%; background-color: aquamarine; transform: rotate(0deg); } to { top: 80%; background-color: sandybrown; transform: rotate(360deg); } }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="square"&gt;&lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74172590, "author": "didene tahi", "author_id": 7263394, "author_profile": "https://Stackoverflow.com/users/7263394", "pm_score": -1, "selected": false, "text": "withPivot" }, { "answer_id": 74177169, "author": "raimondsL", "author_id": 4354065, "author...
2022/10/23
[ "https://Stackoverflow.com/questions/74172483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17339490/" ]
74,172,484
<p>I want to divide the sum value in aggfun by 2 .</p> <p>i want to this result :-</p> <p><a href="https://i.stack.imgur.com/uitId.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uitId.png" alt="enter image description here" /></a></p> <p>import pandas as pd</p> <pre><code>#create DataFrame df = pd.DataFrame({'team': ['A', 'B','B', 'B','A', 'A','A', 'B',], 'points_for': ['18', '22', '19', '14', '14', '11', '20', '28'], 'points_against': ['aa','bb','aa','bb','aa','bb','aa','bb']}) df2 = pd.pivot_table(df, values='points_for', index='team', columns='points_against', aggfunc=sum) df2 </code></pre> <p><a href="https://i.stack.imgur.com/HoaEF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HoaEF.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74172590, "author": "didene tahi", "author_id": 7263394, "author_profile": "https://Stackoverflow.com/users/7263394", "pm_score": -1, "selected": false, "text": "withPivot" }, { "answer_id": 74177169, "author": "raimondsL", "author_id": 4354065, "author...
2022/10/23
[ "https://Stackoverflow.com/questions/74172484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16609351/" ]
74,172,496
<p>Given the charset = &quot;abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890&quot;, how can I increment a string like following:</p> <p>aabbcde -&gt; aabbcdf -&gt; aabbcdg -&gt; ... -&gt; aabbcd0 -&gt; aabbcea</p> <p>I would like a snippet in Python. Thank you!</p>
[ { "answer_id": 74172599, "author": "SZA", "author_id": 20315509, "author_profile": "https://Stackoverflow.com/users/20315509", "pm_score": 0, "selected": false, "text": "for character in charset:\n print(\"aabbc\" + character)\n" }, { "answer_id": 74172608, "author": ...
2022/10/23
[ "https://Stackoverflow.com/questions/74172496", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14926026/" ]
74,172,505
<pre><code>&gt; lsblk -o NAME,LABEL,FSTYPE,MOUNTPOINT,SIZE,TYPE -x NAME NAME LABEL FSTYPE MOUNTPOINT SIZE TYPE nvme0n1 894.3G disk nvme0n1p1 [SWAP] 4G part nvme0n1p2 1G part nvme0n1p3 root /home/cg/root 889.3G part </code></pre> <p>I need the output of this command in csv format, but all the methods I've tried so far don't handle the empty values correctly, thus generating bad rows like these I got with sed:</p> <pre><code>&gt; lsblk -o NAME,LABEL,FSTYPE,MOUNTPOINT,SIZE,TYPE -x NAME | sed -E 's/ +/,/g' NAME,LABEL,FSTYPE,MOUNTPOINT,SIZE,TYPE nvme0n1,894.3G,disk nvme0n1p1,[SWAP],4G,part nvme0n1p2,1G,part nvme0n1p3,root,/home/cg/root,889.3G,part </code></pre> <p>Any idea how to add the extra commas for the empty fields?</p> <pre><code>NAME,LABEL,FSTYPE,MOUNTPOINT,SIZE,TYPE nvme0n1,,,,894.3G,disk </code></pre>
[ { "answer_id": 74172842, "author": "Ljm Dullaart", "author_id": 6908895, "author_profile": "https://Stackoverflow.com/users/6908895", "pm_score": 1, "selected": false, "text": "lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT,LABEL -x NAME | awk '{ print $1,\";\",$6,\";\",$4,\";\",$5,\";\",$2...
2022/10/23
[ "https://Stackoverflow.com/questions/74172505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/983550/" ]
74,172,508
<p>I can't find a way to add the month in a long format dataframe. For example for each country, and each year I would like to have 12 values, once by month. And the value of total_points (which will be NaN) will be the same as the last one. It means that my column month should be range(1,13) for each country and each year.</p> <pre><code>country_full year month rank rank_date total_points Zimbabwe 2021 8 108 2021-08-12 1171.88 Zimbabwe 2021 10 108 2021-09-12 1171.88 Zimbabwe 2022 01 108 2022-01-12 1171.88 Germany 1994 01 10 1994-01-10 1171.88 Germany 1994 02 10 1994-02-09 1327.8 Germany 1994 04 10 1994-04-07 1459.9 </code></pre> <p>The desired output would be :</p> <pre><code>country_full year month rank rank_date total_points Zimbabwe 2021 8 108 2021-08-12 1171.88 Zimbabwe 2021 9 108 2021-08-12 1171.88 Zimbabwe 2021 10 108 2021-10-12 1171.88 Zimbabwe 2021 11 108 2021-11-12 1171.88 Zimbabwe 2021 12 108 2021-12-12 1171.88 Zimbabwe 2022 01 108 2022-01-12 1171.88 Germany 1994 01 10 1994-01-10 1171.88 Germany 1994 02 10 1994-02-10 1327.8 Germany 1994 03 10 1994-03-09 1459.9 Germany 1994 04 10 1994-03-07 1459.9 </code></pre> <p>For each country and each year having 12 months. And the missing values for the total point column will be the one from the last month.</p> <p>Any idea of how we can do that with pandas ?</p>
[ { "answer_id": 74173028, "author": "Nuri TaลŸ", "author_id": 19255749, "author_profile": "https://Stackoverflow.com/users/19255749", "pm_score": 2, "selected": false, "text": "rank_date" }, { "answer_id": 74173356, "author": "Rabinzel", "author_id": 15521392, "author_p...
2022/10/23
[ "https://Stackoverflow.com/questions/74172508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16334769/" ]
74,172,509
<p>I have simple <code>TextField</code> widget that auto expands to a new line if the string width was almost near of max screen width.</p> <p>Here is the code:</p> <pre><code> TextEditingController textController = TextEditingController(); TextField( controller: textController, textInputAction: TextInputAction.done, maxLines:null , expands: true, maxLength: 200, ) </code></pre> <p><strong>Question</strong>: How can I detect the new line in <code>textController.text</code>?</p> <p>E.g., we have the following sentence:</p> <blockquote> <p>The universe is the greatest mystery known to the<br /> human race</p> </blockquote> <p>Notice that between <code>'the'</code> and <code>'human'</code> there is a new line.</p> <p>I tried to output <code>textController.text</code> but there was nothing found like <code>\n</code> because the new line comes based on <code>UI</code> <code>rendering</code>.</p> <p>How do I know that in code?</p>
[ { "answer_id": 74173028, "author": "Nuri TaลŸ", "author_id": 19255749, "author_profile": "https://Stackoverflow.com/users/19255749", "pm_score": 2, "selected": false, "text": "rank_date" }, { "answer_id": 74173356, "author": "Rabinzel", "author_id": 15521392, "author_p...
2022/10/23
[ "https://Stackoverflow.com/questions/74172509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16213673/" ]
74,172,529
<p>I've an object showing genres with their counts. It looks like this.</p> <pre><code>const totalGenresWatchedCount = { &quot;Comedy&quot;: 3, &quot;Romance&quot;: 2, &quot;Adventure&quot;: 1, &quot;Science Fiction&quot;: 1, &quot;Action&quot;: 2, &quot;Drama&quot;: 1, &quot;Family&quot;: 1, &quot;Crime&quot;: 1, &quot;Thriller&quot;: 1 } </code></pre> <p>I also have another array containing all the genres listed.</p> <pre><code>const totalUniqueGenresWatched = [&quot;Comedy&quot;, &quot;Romance&quot;, &quot;Adventure&quot;, &quot;Science Fiction&quot;, &quot;Action&quot;]. </code></pre> <p>What I want to achieve is get all the genre and the count printed together. Ive tried with the this code.</p> <pre><code>totalUniqueGenresWatched.map((genre) =&gt; { return ( &lt;p&gt; {genre} - {totalGenresWatchedCount.genre} &lt;/p&gt; ); }) </code></pre> <p>I cant seem to print the object value from the genre key, if I remove the first genre VS Code IntelliSense predicts that the key is not even getting used. Am i missing anything?</p>
[ { "answer_id": 74172675, "author": "damonholden", "author_id": 17670742, "author_profile": "https://Stackoverflow.com/users/17670742", "pm_score": -1, "selected": false, "text": "Object.entries()" }, { "answer_id": 74172942, "author": "O.Malmgren", "author_id": 6035706, ...
2022/10/23
[ "https://Stackoverflow.com/questions/74172529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10566758/" ]
74,172,589
<p>I would like to get the indices of maximum values.</p> <p>Eg:</p> <pre><code>[ [ [0.1 0.3 0.6], [0.0 0.4 0.1] ], [ [0.9 0.2 0.6], [0.8 0.1 0.5] ] ] </code></pre> <p>I would like to get <code>[[0,0,2], [0,1,1], [1,0,0], [1,1,0]]</code>. How do I do that in the easiest way in Tensorflow?</p>
[ { "answer_id": 74173290, "author": "V.M", "author_id": 8143158, "author_profile": "https://Stackoverflow.com/users/8143158", "pm_score": 0, "selected": false, "text": "#argmax will give the index but not in the format you want\n\nmax_index = tf.reshape(tf.math.argmax(a, -1),(-1, 1))\nmax...
2022/10/23
[ "https://Stackoverflow.com/questions/74172589", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8466343/" ]
74,172,612
<p>is there any formula to break a line from a specific text? e.g.</p> <blockquote> <p>Q.1 This is Question number one? Ans. True</p> </blockquote> <blockquote> <p>Q.2 This is Question number Two? Ans. false</p> </blockquote> <p>i have above text where first part is Question and the second part is Answer. This text is in a cell and i want a formula to break the line from &quot;Ans.&quot; text to next line without overwriting the text in the next line.</p> <p><strong>output should look like this</strong>:</p> <p>Q.1 This is Question number one?</p> <p>Ans. True</p> <p>Q.2 This is Question number Two?</p> <p>Ans. false</p>
[ { "answer_id": 74172775, "author": "Ike", "author_id": 16578424, "author_profile": "https://Stackoverflow.com/users/16578424", "pm_score": 2, "selected": false, "text": "=SUBSTITUTE(A1,\" Ans.\", CHAR(10) & \"Ans.\")" }, { "answer_id": 74172797, "author": "Mayukh Bhattacharya...
2022/10/23
[ "https://Stackoverflow.com/questions/74172612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12722751/" ]
74,172,640
<p><code>Node.js</code> 16.14.2, <code>npm</code> 8.19.2.</p> <p>I am trying to run a simple <code>Node.js</code> script that imports <code>OrbitDB</code>. Here is the script:</p> <p><em><code>hello_orbitdb.js</code></em></p> <pre><code>// import the package const OrbitDB = require('orbit-db'); </code></pre> <p>Here is how I am trying to run it, and the error I am getting:</p> <pre><code>$ node hello_orbitdb.js node:internal/modules/cjs/loader:488 throw e; ^ Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './cid' is not defined by &quot;exports&quot; in /node_modules/multiformats/package.json at new NodeError (node:internal/errors:371:5) at throwExportsNotFound (node:internal/modules/esm/resolve:453:9) at packageExportsResolve (node:internal/modules/esm/resolve:671:7) at resolveExports (node:internal/modules/cjs/loader:482:36) at Function.Module._findPath (node:internal/modules/cjs/loader:522:31) at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27) at Function.Module._load (node:internal/modules/cjs/loader:778:27) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.&lt;anonymous&gt; (/node_modules/orbit-db/src/orbit-db-address.js:3:17) { code: 'ERR_PACKAGE_PATH_NOT_EXPORTED' } </code></pre> <p>So I took a look at <code>/node_modules/orbit-db/src/orbit-db-address.js</code> and here is how it starts:</p> <pre><code>'use strict' const path = require('path') const { CID } = require('multiformats/cid') </code></pre> <p><strong>How can I correct this error?</strong></p> <p>In my <code>node_modules</code> folder, there are</p> <pre><code> &quot;name&quot;: &quot;orbit-db&quot;, &quot;version&quot;: &quot;0.28.7&quot;, </code></pre> <p>and</p> <pre><code> &quot;name&quot;: &quot;multiformats&quot;, &quot;version&quot;: &quot;10.0.2&quot;, </code></pre>
[ { "answer_id": 74231081, "author": "Alaindeseine", "author_id": 8807231, "author_profile": "https://Stackoverflow.com/users/8807231", "pm_score": 2, "selected": false, "text": "npm install" }, { "answer_id": 74249991, "author": "morganney", "author_id": 258174, "autho...
2022/10/23
[ "https://Stackoverflow.com/questions/74172640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/784980/" ]
74,172,643
<p>Im trying to pass arguments thro Navigator.pushNamed but i get this error</p> <p>type 'RouteSettings' is not a subtype of type 'String' in type cast</p> <p>here is the Navigator</p> <pre><code>onTap: (){ Navigator.pushNamed(context, &quot;ProductDetScreen&quot;,arguments: ProductModelsvar.id); }, </code></pre> <p>and this is where i get them in the second page</p> <pre><code>final productProviders = Provider.of&lt;productProvider&gt;(context); final productId = ModalRoute.of(context)!.settings as String; final getCurrentProduct=productProviders.findProductById(productId); </code></pre>
[ { "answer_id": 74231081, "author": "Alaindeseine", "author_id": 8807231, "author_profile": "https://Stackoverflow.com/users/8807231", "pm_score": 2, "selected": false, "text": "npm install" }, { "answer_id": 74249991, "author": "morganney", "author_id": 258174, "autho...
2022/10/23
[ "https://Stackoverflow.com/questions/74172643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17755642/" ]
74,172,660
<p>I want to match the value in cell <code>A2</code> of my sheet to a header value on a different sheet and post back the matched column</p> <p>I have a dropdown of sheet names in cell <code>F5</code> on a sheet called Filter_Maker</p> <p>I need to reference this cell value as the sheet name in a match formula to the cell value in <code>A2</code></p> <p>I am trying</p> <pre><code>=MATCH($A2,indirect(&quot;'&quot;Filter_Maker!F5&quot;'!$A1:$H1&quot;),0) </code></pre> <p>I am getting Formula parse error</p> <p>Thanks for any assistance on this</p>
[ { "answer_id": 74231081, "author": "Alaindeseine", "author_id": 8807231, "author_profile": "https://Stackoverflow.com/users/8807231", "pm_score": 2, "selected": false, "text": "npm install" }, { "answer_id": 74249991, "author": "morganney", "author_id": 258174, "autho...
2022/10/23
[ "https://Stackoverflow.com/questions/74172660", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9301989/" ]
74,172,695
<p>I don't understand what the difference is betwee</p> <p><code>const arrCopy = arr;</code></p> <p>and</p> <p><code>const arrCopy = [...arr];</code></p>
[ { "answer_id": 74172713, "author": "Daniel A. White", "author_id": 23528, "author_profile": "https://Stackoverflow.com/users/23528", "pm_score": 1, "selected": false, "text": "const arr = [1, 2, 3];\nconst anotherArr = arr;\nconsole.log(arr === anotherArr);\nconst copyArr = [...arr];\nco...
2022/10/23
[ "https://Stackoverflow.com/questions/74172695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20315641/" ]
74,172,721
<p>I had been given this problem to write a code which will get a line of numbers on the input and will separate them into odd and even.</p> <blockquote> <p>You get a line with natural numbers on the input. Sort them and write out the odd ones separately, the even ones separately</p> </blockquote> <p>This is where had I gone so far, but I have mainly I think problem with separating and including the with the numbers from the input.</p> <p><strong>Input: 8 11 4 3 7 2 6 13 5 12</strong></p> <p><strong>even: 6 4 2 6 12</strong></p> <p><strong>odd: 11 3 7 13 5</strong></p> <pre><code>a=[] for i in range(1,100): b=int(input().split()) a.append(b) even=[] odd=[] for j in a: if(j%2==0): even.append(j) else: odd.append(j) print(&quot;The even list:&quot;,even) print(&quot;The odd list:&quot;,odd) </code></pre>
[ { "answer_id": 74172771, "author": "Speezy", "author_id": 20315450, "author_profile": "https://Stackoverflow.com/users/20315450", "pm_score": 0, "selected": false, "text": "def separator(lst):\n\n odd = []\n even = []\n\n for i in lst:\n if i % 2 == 0:\n even.a...
2022/10/23
[ "https://Stackoverflow.com/questions/74172721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20243069/" ]
74,172,722
<p>I got a spark data frame (Scala) with many rows, which has a column which is a dictionary (a Json string) of the following format:</p> <pre><code>[{&quot;ID1&quot;:111,&quot;ID2&quot;:2,&quot;value&quot;:&quot;Z&quot;}, {&quot;ID1&quot;:222,&quot;ID2&quot;:3,&quot;value&quot;:&quot;A&quot;}, {&quot;ID1&quot;:333,&quot;ID2&quot;:4,&quot;value&quot;:&quot;Z&quot;}, {&quot;ID1&quot;:444,&quot;ID2&quot;:5,&quot;value&quot;:&quot;B&quot;}, {&quot;ID1&quot;:555,&quot;ID2&quot;:6,&quot;value&quot;:&quot;Z&quot;}, {&quot;ID1&quot;:666,&quot;ID2&quot;:7,&quot;value&quot;:&quot;Z&quot;}, {&quot;ID1&quot;:777,&quot;ID2&quot;:8,&quot;value&quot;:&quot;A&quot;}] </code></pre> <p>I want to filter the dataframe, so it remains only with rows that contains a specific combination, for example ID1 = 111, ID2 = 2, value = Z. Note: not all rows may have all of the keys, for example, a row might not have the combination &quot;ID1 = 111&quot;.</p> <p>How can it be done efficiently in Scala spark? Thanks!</p>
[ { "answer_id": 74172771, "author": "Speezy", "author_id": 20315450, "author_profile": "https://Stackoverflow.com/users/20315450", "pm_score": 0, "selected": false, "text": "def separator(lst):\n\n odd = []\n even = []\n\n for i in lst:\n if i % 2 == 0:\n even.a...
2022/10/23
[ "https://Stackoverflow.com/questions/74172722", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13315786/" ]
74,172,727
<p>I have an array of nested objects like below and constructing a tab.</p> <p><a href="https://i.stack.imgur.com/wMJvF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wMJvF.png" alt="enter image description here" /></a></p> <ol> <li>For all the elements key has been given, but even though it is asking key is missing (snapshot provided). Why?</li> </ol> <p><a href="https://i.stack.imgur.com/wykA2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wykA2.png" alt="enter image description here" /></a></p> <ol start="2"> <li>When I click on parent element all the three parent-child are getting expanded, how to restrict to only clicked parent node?</li> </ol> <pre class="lang-js prettyprint-override"><code>export const tabData = [ { id: 1, name:&quot;Population&quot;, col: [ { ItemCode: 1001, ItemName: &quot;MalePopulation&quot; }, { ItemCode: 1002, ItemName: &quot;FemalePopulation&quot; }, { ItemCode: 1003, ItemName: &quot;TotalPopulation&quot; }, ], }, { id: 2, name:&quot;Poverty&quot;, col: [ { ItemCode: 1004, ItemName: &quot;RuralRationShops&quot; }, { ItemCode: 1005, ItemName: &quot;UrbanRationShops&quot; }, { ItemCode: 1006, ItemName: &quot;TotalRationShops&quot; }, ], }, { id: 3, name:&quot;Agriculture&quot;, col: [ { ItemCode: 1007, ItemName: &quot;AgriculturalLand&quot; }, { ItemCode: 1008, ItemName: &quot;NonAgriculturalLand&quot; }, { ItemCode: 1009, ItemName: &quot;TotalLand&quot; }, ], }, ]; </code></pre> <pre class="lang-js prettyprint-override"><code>const [open, setOpen] = useState(false); function clickHandler1(e) { setOpen(!open); } &lt;div className=&quot;h-42 overflow-y-auto&quot;&gt; {Object.keys(tabdata).map(function (keyName, keyIndex) { // console.log(keyName); // console.log(tabdata[keyName]); const col1 = tabdata[keyName].col; return ( &lt;&gt; &lt;label key={keyIndex} className=&quot;flex flex-row&quot;&gt; &lt;button key={keyIndex} onClick={(e) =&gt; { clickHandler1(e); }} className=&quot;flex flex-row&quot; &gt; &lt;BiArrowFromTop /&gt; {tabdata[keyName].name} &lt;/button&gt; &lt;/label&gt; {Object.keys(col1).map(function (keyName1, keyIndex1) { return ( &lt;&gt; {open &amp;&amp; ( &lt;lable key={col1[keyName1].ItemCode} className=&quot;flex flex-row px-6&quot;&gt; &lt;Link key={col1[keyName1].ItemCode} // href={`gismappage/Year=${yrId}/Chapter=${chpId}/ItemCode=${col1[keyName1].ItemCode}`}&gt; this static goes to ...slug page href={`gismappage?paths=${yrId}/${chpId}/${col1[keyName1].ItemCode}`}&gt; &lt;input name=&quot;itm&quot; key={col1[keyName1].ItemCode} type=&quot;radio&quot; onClick={() =&gt; clickhandler2(col1[keyName1].ItemCode) } /&gt; &lt;/Link&gt; {col1[keyName1].ItemName} &lt;/lable&gt; )} &lt;/&gt; ); })} &lt;/&gt; ); })} &lt;/div&gt; </code></pre>
[ { "answer_id": 74172771, "author": "Speezy", "author_id": 20315450, "author_profile": "https://Stackoverflow.com/users/20315450", "pm_score": 0, "selected": false, "text": "def separator(lst):\n\n odd = []\n even = []\n\n for i in lst:\n if i % 2 == 0:\n even.a...
2022/10/23
[ "https://Stackoverflow.com/questions/74172727", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15405522/" ]
74,172,740
<p>I need to detect the language the user is using to include the correct file using PHP if elseif or else like this:</p> <p>users are comming from:</p> <pre><code>example.com/EN/nice-title-url-from-database-slug example.com/DE/nice-title-url-from-database-slug example.com/ES/nice-title-url-from-database-slug </code></pre> <p>the php I need is something like this:</p> <p>PHP document.location.toString().split(...) etc detect the url paths</p> <pre><code>if url path &lt;starts with /DE/&gt; include de.php elseif url &lt;path starts with /EN/&gt; include en.php else url &lt;path starts with /ES/&gt; include es.php </code></pre> <p>so what I need is to detect the url after the domain (/ES/ or /EN/ or /DE/)</p> <p>Any idea how to achieve this?</p>
[ { "answer_id": 74172781, "author": "timor33244", "author_id": 20315516, "author_profile": "https://Stackoverflow.com/users/20315516", "pm_score": 1, "selected": false, "text": "$check = \"example.com/EN/\";\nif (substr($url, 0, strlen($check)) === $check) { ... }\n" }, { "answer_...
2022/10/23
[ "https://Stackoverflow.com/questions/74172740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20307883/" ]
74,172,768
<p>I tried to find codes online about rising events in my PySimpleGUI program by simple keyboard clicks like <code>ENTER</code> or <code>Ctrl+A</code> for instance but I couldn't just find any about it, I went to the documentation of PySimpleGUI and didn't shut my tap without learning a thing.</p> <p>Here is a simple code i wrote:</p> <pre><code>import PySimpleGUI as sg layout = [[sg.I(key='In'), sg.B('Ok')],[sg.T(enable_events=True,key='T')]] win=sg.Window(&quot;Keyboard Events&quot;, layout) while True: event, value= win.read() #close event if event == sg.WIN_CLOSED: break #greeting evnt if event in ('Ok'): #( 'OK', 'KEYBOARD ENTER EVENT'): msg = &quot;Hello &quot;+value['In'] # message to show user win['T'].update(msg) # show user message win['In'].update(&quot;&quot;) # clear input field after submitting win.close() </code></pre> <p>What should I say to PySimpleGUI for let it run <code>#greeting event</code> when I press the <code>ENTER</code> key? Can someone help me please? Thanks guys!</p>
[ { "answer_id": 74172781, "author": "timor33244", "author_id": 20315516, "author_profile": "https://Stackoverflow.com/users/20315516", "pm_score": 1, "selected": false, "text": "$check = \"example.com/EN/\";\nif (substr($url, 0, strlen($check)) === $check) { ... }\n" }, { "answer_...
2022/10/23
[ "https://Stackoverflow.com/questions/74172768", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,172,800
<p>I want to iterate through a column and if that column value meets some criteria it changes another column value.</p> <pre><code>cycleNum = 0 first = 0 for entry in df1['Ns']: if entry &lt; first: cycleNum = cycleNum +1 df1['cycleNumber'] = cycleNum first = 0 else: df1['cycleNumber'] = cycleNum first = entry </code></pre> <p>So I want <code>cycleNumber</code> column value to change for that row only. It seems at the minute that it changes the value for every row every time its ran.</p> <p>I am thinking it should be something like</p> <pre><code>df1['cycleNumber', ROW] = cycleNum </code></pre> <p>but cant fugure how to assert that specific row.</p>
[ { "answer_id": 74172781, "author": "timor33244", "author_id": 20315516, "author_profile": "https://Stackoverflow.com/users/20315516", "pm_score": 1, "selected": false, "text": "$check = \"example.com/EN/\";\nif (substr($url, 0, strlen($check)) === $check) { ... }\n" }, { "answer_...
2022/10/23
[ "https://Stackoverflow.com/questions/74172800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15059399/" ]
74,172,803
<p>I have a tree with the most frequent letters at the top of the tree and I am trying to find the path to a node so I can turn a message into binary. In this program if I go left, I add 0 to <code>path</code> and, if I go right, I add 1 to the <code>path</code> until I find the node. But I have to go straight to the desired node which is not possible. The only thing I could think of is removing the last character or <code>path</code> if a node has no children, but it does not work if a node has grandchildren. Can someone help me on how to approach this? Thanks!</p> <pre class="lang-java prettyprint-override"><code> // global variables String path; int mark; // encodes a message to binary String encoder(char data) { path = &quot;&quot;; mark = 0; findPath(root, data); return path; } // finds the path to a node void findPath(TNode node, char data) { if(node.data == data) { mark = 1; return; } if(mark==0 &amp;&amp; node.left != null) { path += 0; findPath(node.left, data); } if(mark==0 &amp;&amp; node.right != null) { path += 1; findPath(node.right, data); } if(mark==0 &amp;&amp; node.left == null || node.right == null) { path = path.substring(0, path.length() - 1); } } </code></pre>
[ { "answer_id": 74172781, "author": "timor33244", "author_id": 20315516, "author_profile": "https://Stackoverflow.com/users/20315516", "pm_score": 1, "selected": false, "text": "$check = \"example.com/EN/\";\nif (substr($url, 0, strlen($check)) === $check) { ... }\n" }, { "answer_...
2022/10/23
[ "https://Stackoverflow.com/questions/74172803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15627884/" ]
74,172,806
<p>I have a simple data generation question. I would request for any kind of help with the code in R or Python. I am pasting the table first.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: center;">Total</th> <th style="text-align: center;">Num1_betw_1_to_4</th> <th style="text-align: center;">Num2_betw_1_to_3</th> <th style="text-align: center;">Num3_betw_1_to_3</th> </tr> </thead> <tbody> <tr> <td style="text-align: center;">9</td> <td style="text-align: center;">3</td> <td style="text-align: center;">3</td> <td style="text-align: center;">3</td> </tr> <tr> <td style="text-align: center;">7</td> <td style="text-align: center;">1</td> <td style="text-align: center;">3</td> <td style="text-align: center;">3</td> </tr> <tr> <td style="text-align: center;">9</td> <td style="text-align: center;">4</td> <td style="text-align: center;">3</td> <td style="text-align: center;">2</td> </tr> <tr> <td style="text-align: center;">9</td> <td style="text-align: center;">3</td> <td style="text-align: center;">3</td> <td style="text-align: center;">3</td> </tr> <tr> <td style="text-align: center;">5</td> <td style="text-align: center;">2</td> <td style="text-align: center;">2</td> <td style="text-align: center;">1</td> </tr> <tr> <td style="text-align: center;">7</td> <td style="text-align: center;">3</td> <td style="text-align: center;">2</td> <td style="text-align: center;">2</td> </tr> <tr> <td style="text-align: center;">9</td> <td style="text-align: center;">3</td> <td style="text-align: center;">3</td> <td style="text-align: center;">3</td> </tr> <tr> <td style="text-align: center;">7</td> <td style="text-align: center;">2</td> <td style="text-align: center;">3</td> <td style="text-align: center;">2</td> </tr> <tr> <td style="text-align: center;">5</td> <td style="text-align: center;"></td> <td style="text-align: center;"></td> <td style="text-align: center;"></td> </tr> <tr> <td style="text-align: center;">6</td> <td style="text-align: center;"></td> <td style="text-align: center;"></td> <td style="text-align: center;"></td> </tr> <tr> <td style="text-align: center;">2</td> <td style="text-align: center;"></td> <td style="text-align: center;"></td> <td style="text-align: center;"></td> </tr> <tr> <td style="text-align: center;">4</td> <td style="text-align: center;"></td> <td style="text-align: center;"></td> <td style="text-align: center;"></td> </tr> <tr> <td style="text-align: center;">9</td> <td style="text-align: center;"></td> <td style="text-align: center;"></td> <td style="text-align: center;"></td> </tr> </tbody> </table> </div> <p>In the above table, first column values are given. Now I want to generate 3 values in column 2, 3 and 4 which sum up to value in column 1 for each row. But each of the column 2, 3 and 4 have some predefined data ranges like: column 2 value must lie between 1 and 4, column 3 value must lie between 1 and 3, and, column 4 value must lie between 1 and 3.</p> <p>I have printed first 8 rows for your understanding. In real case, only &quot;Total&quot; column values will be given and remaining 3 columns will be blank for which values have to be generated.</p> <p>Any help would be appreciated with the code.</p>
[ { "answer_id": 74172894, "author": "Fares_Hassen", "author_id": 20310974, "author_profile": "https://Stackoverflow.com/users/20310974", "pm_score": 1, "selected": false, "text": "import random\nnum = 20\ntemp=0\nres = []\nwhile temp != 20:\n res.append(random.randint(0,num))\n ...
2022/10/23
[ "https://Stackoverflow.com/questions/74172806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5874100/" ]
74,172,831
<p>i have a destroy function</p> <pre><code>app.delete('/delete/items/:id', async(req, res) =&gt; { const id = req.params.id; items.destroy({ where:{ id: id } }).then(res =&gt; { res.status(200).json(&quot;Items deleted&quot;) }).catch(err =&gt; { res.status(500).json(&quot;Can't delete Items&quot;) }) }) </code></pre> <p>the delete is working but it keeps returning the &quot;Can't delete items&quot; <a href="https://i.stack.imgur.com/xtIEl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xtIEl.png" alt="POSTMAN" /></a></p> <p><a href="https://i.stack.imgur.com/NaLQZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NaLQZ.png" alt="Database" /></a></p>
[ { "answer_id": 74173329, "author": "Bagus", "author_id": 19926941, "author_profile": "https://Stackoverflow.com/users/19926941", "pm_score": 0, "selected": false, "text": "app.delete(\"/delete/items/:id\", async (req, res) => {\n try {\n const { id } = req.params;\n const find = a...
2022/10/23
[ "https://Stackoverflow.com/questions/74172831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19727735/" ]
74,172,859
<p>I have the following case</p> <pre><code> template&lt;typename Class&gt; concept has_member = requires (Class t) { // How can I write only either of the following conditions be satisfied? {t.isInterface() }-&gt;std::same_as&lt;bool&gt;; // or {t.canInterface() }-&gt;std::same_as&lt;bool&gt;; // or // ... more conditions! }; struct A { bool isInterface() const { return true; } }; struct B { bool canInterface() const { return true; } }; void foo(const has_member auto&amp; A_or_B) { // do something } int main() { foo(A{}); // should work foo(B{}); // should work } </code></pre> <p>Like I mentioned in the comments, I would like to logically or the requirements (<strong>in a single <code>concepts</code></strong>), so that the class A and B can be passed to the doSomething().</p> <p>As per my knowledge, the the current concept is checking all the requirements, that means a logical and. If I take it apart to different concepts everything works, but I would need more concepts to be written tosatify the intention.</p> <p>Is it possoble to combne into one? something like pseudocode</p> <pre><code>template&lt;typename Class&gt; concept has_member = requires (Class t) { {t.isInterface() }-&gt;std::same_as&lt;bool&gt; || {t.canInterface() }-&gt;std::same_as&lt;bool&gt;; // ... }; </code></pre>
[ { "answer_id": 74172892, "author": "JeJo", "author_id": 9609840, "author_profile": "https://Stackoverflow.com/users/9609840", "pm_score": 3, "selected": true, "text": "requires" }, { "answer_id": 74172933, "author": "Nicol Bolas", "author_id": 734069, "author_profile"...
2022/10/23
[ "https://Stackoverflow.com/questions/74172859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12285865/" ]
74,172,860
<p>I recently modified one of adi1090x's rofi scripts to fit singular rofi theme, and I can't seem to find out why it isn't working. The entire code is listed below:</p> <pre><code>#!/usr/bin/env bash ## Music Player Controls # Import Current Theme dir=&quot;~/.config/polybar/cuts/scripts/rofi&quot; theme=&quot;$dir/mpd.rasi&quot; # Elements status=&quot;`mpc status`&quot; if [[ -z &quot;$status&quot; ]]; then prompt='Offline' mesg=&quot;MPD is Offline&quot; else prompt=&quot;`mpc -f &quot;%artist%&quot; current`&quot; mesg=&quot;`mpc -f &quot;%title%&quot; current` :: `mpc status | grep &quot;#&quot; | awk '{print $3}'`&quot; fi if [[ ${status} == *&quot;[playing]&quot;* ]]; then option_1=&quot;๎ฆฎ Pause&quot; else option_1=&quot;๎ฆบ Play&quot; fi option_2=&quot;๎ง  Stop&quot; option_3=&quot;๎ง˜ Previous&quot; option_4=&quot;๎ง™ Next&quot; option_5=&quot;๎ง… Repeat&quot; option_6=&quot;๎ง– Random&quot; # Toggle Actions active='' urgent='' # Repeat if [[ ${status} == *&quot;repeat: on&quot;* ]]; then active=&quot;-a 4&quot; elif [[ ${status} == *&quot;repeat: off&quot;* ]]; then urgent=&quot;-u 4&quot; else option_5=&quot;๎จ’ Parsing Error&quot; fi # Random if [[ ${status} == *&quot;random: on&quot;* ]]; then [ -n &quot;$active&quot; ] &amp;&amp; active+=&quot;,5&quot; || active=&quot;-a 5&quot; elif [[ ${status} == *&quot;random: off&quot;* ]]; then [ -n &quot;$urgent&quot; ] &amp;&amp; urgent+=&quot;,5&quot; || urgent=&quot;-u 5&quot; else option_6=&quot;๎จ’ Parsing Error&quot; fi #Finally, the actual command. rofi_cmd() { rofi \ -dmenu \ -p &quot;$prompt&quot; \ -mesg &quot;$mesg&quot; \ ${active} ${urgent} \ -markup-rows \ -theme &quot;$theme&quot; \ } # Pass variables to rofi dmenu run_rofi() { echo -e &quot;$option_1\n$option_2\n$option_3\n$option_4\n$option_5\n$option_6&quot; | rofi_cmd } # Execute Command run_cmd() { if [[ &quot;$1&quot; == '--opt1' ]]; then mpc -q toggle &amp;&amp; notify-send -u low -t 1000 &quot;๎ฆจ `mpc current`&quot; elif [[ &quot;$1&quot; == '--opt2' ]]; then mpc -q stop elif [[ &quot;$1&quot; == '--opt3' ]]; then mpc -q prev &amp;&amp; notify-send -u low -t 1000 &quot;๎ฆจ `mpc current`&quot; elif [[ &quot;$1&quot; == '--opt4' ]]; then mpc -q next &amp;&amp; notify-send -u low -t 1000 &quot;๎ฆจ `mpc current`&quot; elif [[ &quot;$1&quot; == '--opt5' ]]; then mpc -q repeat elif [[ &quot;$1&quot; == '--opt6' ]]; then mpc -q random fi } # Actions chosen=&quot;$(run_rofi)&quot; case ${chosen} in $option_1) run_cmd --opt1 ;; $option_2) run_cmd --opt2 ;; $option_3) run_cmd --opt3 ;; $option_4) run_cmd --opt4 ;; $option_5) run_cmd --opt5 ;; $option_6) run_cmd --opt6 ;; esac </code></pre> <p>When ran it displays <code>/home/chaossys/.config/polybar/cuts/scripts/mpd.sh: line 107: syntax error: unexpected end of file</code> which as far as I'm aware means there's a missing bracket and/or quote end, or missing fi, but i can't seem to find it.</p> <p>Any and all help is appreciated.</p>
[ { "answer_id": 74172892, "author": "JeJo", "author_id": 9609840, "author_profile": "https://Stackoverflow.com/users/9609840", "pm_score": 3, "selected": true, "text": "requires" }, { "answer_id": 74172933, "author": "Nicol Bolas", "author_id": 734069, "author_profile"...
2022/10/23
[ "https://Stackoverflow.com/questions/74172860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20315783/" ]
74,172,886
<pre><code>public function update_room_detail(Request $request) { $request-&gt;validate([ 'room_type' =&gt; 'required', ]); if($images = $request-&gt;file('room_image')) { foreach($images as $item): $var = date_create(); $time = date_format($var, 'YmdHis'); $imageName = $time.'-'.$item-&gt;getClientOriginalName(); $item-&gt;move(public_path().'/assets/images/room', $imageName); $arr[] = $imageName; endforeach; $image = implode(&quot;|&quot;, $arr); } else { unset($image); } RoomDetail::where('id',$request-&gt;room_id)-&gt;update([ 'room_type' =&gt; $request-&gt;room_type, 'room_image' =&gt; $image, ]); Alert::success('Success', 'Rooms details updated!'); return redirect()-&gt;route('admin.manage-room'); } </code></pre> <p>In the above code I am trying to update image in database table. When I click on submit button then it show <code>Undefined variable: image</code> and when I use <code>$image=''</code> in else part instead of <code>unset($image)</code> then blank image name save. So, How can I solve this issue please help me? Please help me.</p> <p>Thank You</p>
[ { "answer_id": 74172949, "author": "Peppermintology", "author_id": 281278, "author_profile": "https://Stackoverflow.com/users/281278", "pm_score": 1, "selected": false, "text": "unset()" }, { "answer_id": 74173389, "author": "Sumit kumar", "author_id": 11545457, "auth...
2022/10/23
[ "https://Stackoverflow.com/questions/74172886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15667645/" ]
74,172,887
<p>I am developing image classification models in the Jupyter notebook environment. After getting my model to work with the CPU, I am trying to use the latest TensorFlow Docker image supported for Jupyter &amp; GPU (<a href="https://www.tensorflow.org/install/docker" rel="nofollow noreferrer">tensorflow/tensorflow:latest-gpu-py3-jupyter</a>) so I can take advantage of my GPU for training. The GPU configuration is not the problem (<code>nvidia-smi</code> command shows the GPU is available), but I'm now stuck on what I should do with my image data pipeline setup.</p> <p>I have folders containing images with the following structure:</p> <pre><code>my_folder โ”‚ โ””โ”€โ”€โ”€Training โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€Class_A โ”‚ โ”‚ 01234.jpg โ”‚ โ”‚ 56789.jpg โ”‚ โ”‚ ... โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€Class_B โ”‚ โ”‚ 01234.jpg โ”‚ โ”‚ 56789.jpg โ”‚ โ”‚ ... โ”‚ โ””โ”€โ”€โ”€Validation โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€Class_A โ”‚ โ”‚ 01234.jpg โ”‚ โ”‚ 56789.jpg โ”‚ โ”‚ ... โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€Class_B โ”‚ โ”‚ 01234.jpg โ”‚ โ”‚ 56789.jpg โ”‚ โ”‚ ... </code></pre> <pre><code>path_training = 'my_folder/Training/' path_validation = 'my_folder/Validation/' image_size = (90, 90) </code></pre> <p>With tensorflow == 2.6.2, I can easily load in my training/validation image datasets with the following code:</p> <pre><code>train_ds = tf.keras.preprocessing.image_dataset_from_directory(path_training, seed=1993, image_size = image_size) val_ds = tf.keras.preprocessing.image_dataset_from_directory(path_validation, seed=1993, image_size = image_size) </code></pre> <p>However, it became apparent that this command does not work when using the Docker image:</p> <blockquote> <p>----&gt; 3 train_ds = tf.keras.preprocessing.image_dataset_from_directory(path_training, 4 seed=1993, 5 image_size = image_size)</p> <p>AttributeError: module 'tensorflow_core.keras.preprocessing' has no attribute 'image_dataset_from_directory'</p> </blockquote> <p>So I discovered the tensorflow version of the Docker image is 2.1.0, and that attribute is not listed in the API, which leaves me this option:</p> <pre><code># Read in all image files and split into training/validation sets (tensorflow-gpu 2.1.0) train_ds = tf.keras.preprocessing.image.load_img(path_training, target_size = image_size) val_ds = tf.keras.preprocessing.image.load_img(path_validation, target_size = image_size) </code></pre> <p>As might be expected, the <a href="https://www.tensorflow.org/versions/r2.1/api_docs/python/tf/keras/preprocessing/image/load_img" rel="nofollow noreferrer">load_img()</a> command from TensorFlow 2.1.0 does not read in directories, like image_dataset_from_directory() does.</p> <blockquote> <p>IsADirectoryError: [Errno 21] Is a directory: 'my_folder/Training/'</p> </blockquote> <p>I'm not sure what the best or easiest path forward would be here, as I'm not very familiar with building Docker images. Would it be better to build a Dockerfile based on TensorFlow's latest official tensorflow-GPU &amp; Jupyter Docker image so I can utilize <code>tf.keras.preprocessing.image_dataset_from_directory()</code> or should I just make do with this pre-built Docker image and load my image data with <code>tf.keras.preprocessing.image.load_img()</code> by looping through files in the directory path and creating training/validation image datasets this way? For the latter approach, I searched and found <a href="https://www.programcreek.com/python/example/89223/keras.preprocessing.image.load_img" rel="nofollow noreferrer">some similar examples</a>, notably this example code:</p> <pre><code>def get_data(dir): X_train, Y_train = [], [] X_test, Y_test = [], [] subfolders = sorted([file.path for file in os.scandir(dir) if file.is_dir()]) for idx, folder in enumerate(subfolders): for file in sorted(os.listdir(folder)): img = load_img(folder+&quot;/&quot;+file, color_mode='grayscale') img = img_to_array(img).astype('float32')/255 img = img.reshape(img.shape[0], img.shape[1],1) if idx &lt; 35: X_train.append(img) Y_train.append(idx) else: X_test.append(img) Y_test.append(idx-35) X_train = np.array(X_train) X_test = np.array(X_test) Y_train = np.array(Y_train) Y_test = np.array(Y_test) return (X_train, Y_train), (X_test, Y_test) </code></pre>
[ { "answer_id": 74172949, "author": "Peppermintology", "author_id": 281278, "author_profile": "https://Stackoverflow.com/users/281278", "pm_score": 1, "selected": false, "text": "unset()" }, { "answer_id": 74173389, "author": "Sumit kumar", "author_id": 11545457, "auth...
2022/10/23
[ "https://Stackoverflow.com/questions/74172887", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13296253/" ]
74,172,891
<p>i have a question that goes with:</p> <blockquote> <p>In Java, if we divide two integers, the result is another integer, but the result might not be correct. For example, 4/2 = 2, but 5/2 = 2.5 but in Java the result would be 2 when both 5 and 2 values are stored as integer values. The program should check if the numbers the result of the division is the same when the values are both integers and when they are floats.</p> </blockquote> <p>So that I spend over 1 hour to figure this q but i have a problem with the ending part. What it meant in this part: &quot;The program should check if the numbers the result of the division is the same when the values are both integers and when they are floats.&quot;</p> <pre><code>import java.util.Scanner; class StartUp2{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); System.out.println(&quot;Please type the first number that you want be devided: &quot;); int a = sc.nextInt(); float b = a; System.out.println(&quot;Please type another number that you want to devide with:&quot;); int c = sc.nextInt(); float d = c; } } </code></pre>
[ { "answer_id": 74172949, "author": "Peppermintology", "author_id": 281278, "author_profile": "https://Stackoverflow.com/users/281278", "pm_score": 1, "selected": false, "text": "unset()" }, { "answer_id": 74173389, "author": "Sumit kumar", "author_id": 11545457, "auth...
2022/10/23
[ "https://Stackoverflow.com/questions/74172891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20315537/" ]
74,172,895
<p>I'm trying to send mail from rediffmail using nodemailer Here's the code snippet</p> <pre><code>var transporter = nodemailer.createTransport({ host: &quot;smtp.rediffmail.com&quot;, // hostname port:25, secureConnection: false, secure: false, tls: { ciphers: &quot;SSLv3&quot;, }, auth: { user: process.env.MAILADDRESS, pass: process.env.MAILPASS, }, }); var mailOptions = { from: process.env.MAILADDRESS, to: email, subject: &quot;Sending using Node.js&quot;, html: &quot;&lt;h1&gt;hoohaa&lt;/h1&gt;That was eafefesy!&quot;, }; transporter.sendMail(mailOptions, (err, info) =&gt; { if (err) { console.log(err); } else { console.log( `Password recovery Email sent to ${email} : ${info.response}` ); }} </code></pre> <p>and the error which I get is :</p> <blockquote> <p>{ errno: -4039, code: 'ESOCKET', syscall: 'connect', address: '202.137.235.17', port: 25, command: 'CONN' }</p> </blockquote>
[ { "answer_id": 74172949, "author": "Peppermintology", "author_id": 281278, "author_profile": "https://Stackoverflow.com/users/281278", "pm_score": 1, "selected": false, "text": "unset()" }, { "answer_id": 74173389, "author": "Sumit kumar", "author_id": 11545457, "auth...
2022/10/23
[ "https://Stackoverflow.com/questions/74172895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13460396/" ]
74,172,940
<p>my code:</p> <pre><code>fib1 = 1 fib2 = 1 n = int(input('N =')) for i in range(2,n): c = fib1 + fib2 fib1 = fib2 fib2 = c print(c) </code></pre> <p>answer:</p> <pre><code>N = &gt;&gt;&gt; 10 2 3 5 8 13 21 34 55 </code></pre>
[ { "answer_id": 74172972, "author": "azro", "author_id": 7212686, "author_profile": "https://Stackoverflow.com/users/7212686", "pm_score": 3, "selected": true, "text": "print" }, { "answer_id": 74172981, "author": "Khoi Nguyen", "author_id": 18489845, "author_profile":...
2022/10/23
[ "https://Stackoverflow.com/questions/74172940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15589443/" ]