qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,457,669
<p>I am trying to scrape the current gas prices in a German city by using the IMPORTHTML-function in Google Sheets. The function seems to work, at least the data is being imported into my sheet. When taking a closer look, one recognizes, that the data inserted into the sheet differs from the current data displayed on the webpage I am scraping.</p> <p>This is the function I inserted into my Google sheet:<code>=IMPORTHTML(&quot;https://www.benzinpreis.de/aktuell/super_e5/deutschland/nordrhein-westfalen/koeln/koeln/koeln&quot;; &quot;table&quot;;4)</code></p> <p>I took a screenshot of the differing values:</p> <p><img src="https://i.stack.imgur.com/5ZaUW.jpg" alt="Screenshot of differing values" /></p> <p>Does anyone have an idea where I made a mistake?</p>
[ { "answer_id": 74529332, "author": "Anthony S", "author_id": 19917207, "author_profile": "https://Stackoverflow.com/users/19917207", "pm_score": 1, "selected": true, "text": "ImportJSON" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20499727/" ]
74,457,680
<p>I currently have a <code>.csv</code> data file with contents like:</p> <pre><code>Name Fruit Qty Tauwen Apple 32 Tauewn Pear 09 Wikfae Apple 09 Moigaw Pear 16 </code></pre> <p>I want to use R to insert the missing &quot;Pear&quot; for &quot;Wikfae&quot; with corresponding Qty as 0, and missing &quot;Apple&quot; for &quot;Moigaw&quot; with corresponding Qty as 0. So the output table I want is:</p> <pre><code>Name Fruit Qty Tauwen Apple 32 Tauewn Pear 09 Wikfae Apple 09 Wikfae Peak 0 #Added line Moigaw Pear 16 Moigaw Apple 0 #Added line </code></pre> <p>I don't even know where to begin. A <code>tidyverse</code>-based solution would be most useful for me.</p>
[ { "answer_id": 74457806, "author": "harre", "author_id": 4786466, "author_profile": "https://Stackoverflow.com/users/4786466", "pm_score": 3, "selected": true, "text": "complete" }, { "answer_id": 74457856, "author": "Shawn Hemelstrand", "author_id": 16631565, "author_profile": "https://Stackoverflow.com/users/16631565", "pm_score": 1, "selected": false, "text": "add_row" }, { "answer_id": 74458131, "author": "TarJae", "author_id": 13321647, "author_profile": "https://Stackoverflow.com/users/13321647", "pm_score": 1, "selected": false, "text": "library(dplyr)\nlibrary(tidyr)\n\ndf %>% \n group_by(Name) %>% \n summarise(cur_data()[seq(2),]) %>% \n ungroup() %>% \n mutate(Fruit = if(first(Fruit) == \"Pear\") replace(Fruit, is.na(Fruit), \"Apple\") \n else replace(Fruit), is.na(Fruit), first(Fruit)) %>% \n mutate(Qty = replace_na(Qty, 0)) %>% \n select(Name, Fruit, Qty)\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12801482/" ]
74,457,710
<p>When I use the bootstrap to content layout, if the picture is on the left, it seems to be adaptive. If I put the picture on the right, it is different from the original. How can I control it?</p> <pre><code>&lt;div class=&quot;about&quot; id=&quot;about&quot;&gt; &lt;div class=&quot;container&quot;&gt; &lt;h1 class=&quot;text-center&quot;&gt;About Me&lt;/h1&gt; &lt;div class=&quot;row&quot;&gt; &lt;div class=&quot;col-lg-4 col-md-4 col-sm-12&quot;&gt; &lt;img src=&quot;img/120.png&quot; class=&quot;img-fluid&quot;&gt; &lt;/div&gt; &lt;div class=&quot;col-lg-8 col-md-8 col-sm-12 desc&quot;&gt; &lt;h3&gt;D.John&lt;/h3&gt; &lt;p&gt; ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;about&quot; id=&quot;about&quot;&gt; &lt;div class=&quot;container&quot;&gt; &lt;h1 class=&quot;text-center&quot;&gt;About Me&lt;/h1&gt; &lt;div class=&quot;row&quot;&gt; &lt;div class=&quot;col-lg-4 col-md-4 col-sm-12 &quot;&gt; &lt;h3&gt;D.John&lt;/h3&gt; &lt;p&gt; ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p><a href="https://i.stack.imgur.com/b2lGK.png" rel="nofollow noreferrer">As you can see here it effects images.</a></p> <pre class="lang-css prettyprint-override"><code>.about{ margin: 4em 0; padding: 1em; position: relative; } .about h1{ color:#F97300; margin: 2em; } .about img{ height: 100%; width: 100%; border-radius: 50% } .about span{ display: block; color: #888; position: absolute; left: 115px; } .about .desc{ padding: 2em; border-left:4px solid #10828C; } .about .desc h3{ color: #10828C; } .about .desc p{ line-height:2; color:#888; } </code></pre> <p>If I put the picture on the right, it is different from the original - how can I control this behaviour?</p>
[ { "answer_id": 74457806, "author": "harre", "author_id": 4786466, "author_profile": "https://Stackoverflow.com/users/4786466", "pm_score": 3, "selected": true, "text": "complete" }, { "answer_id": 74457856, "author": "Shawn Hemelstrand", "author_id": 16631565, "author_profile": "https://Stackoverflow.com/users/16631565", "pm_score": 1, "selected": false, "text": "add_row" }, { "answer_id": 74458131, "author": "TarJae", "author_id": 13321647, "author_profile": "https://Stackoverflow.com/users/13321647", "pm_score": 1, "selected": false, "text": "library(dplyr)\nlibrary(tidyr)\n\ndf %>% \n group_by(Name) %>% \n summarise(cur_data()[seq(2),]) %>% \n ungroup() %>% \n mutate(Fruit = if(first(Fruit) == \"Pear\") replace(Fruit, is.na(Fruit), \"Apple\") \n else replace(Fruit), is.na(Fruit), first(Fruit)) %>% \n mutate(Qty = replace_na(Qty, 0)) %>% \n select(Name, Fruit, Qty)\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19748741/" ]
74,457,726
<p>I am trying to validate an onchange but can't seem to get it working.</p> <p>Essentially, I want to test that if the input matches the regex then we present a message under the input.</p> <p>I am unsure where to put the validator, I wondered if anyone could point me in the right direction</p> <p>Here is a sandbox.</p> <p><a href="https://codesandbox.io/s/blazing-hooks-gni5jy?file=/src/components/Dashboard/Dashboard.js" rel="nofollow noreferrer">https://codesandbox.io/s/blazing-hooks-gni5jy?file=/src/components/Dashboard/Dashboard.js</a></p> <pre><code>const Dashboard = () =&gt; { const [number, setNumber] = useState(null); // const [isValid, setIsValid] = useState(false); // const validator = (value) =&gt; { // if (!value) return false; // const re = /\b\d{5}\b/g; // return re.test(value.trim()); // }; const onChangeHandler = (event) =&gt; { const value = event.target.value; setNumber(value); }; return ( &lt;div&gt; &lt;input value={number || &quot;&quot;} onChange={onChangeHandler} /&gt; {/* {isValid ? &lt;p&gt;is valid&lt;/p&gt; : null} */} &lt;/div&gt; ); }; export default Dashboard; </code></pre>
[ { "answer_id": 74457806, "author": "harre", "author_id": 4786466, "author_profile": "https://Stackoverflow.com/users/4786466", "pm_score": 3, "selected": true, "text": "complete" }, { "answer_id": 74457856, "author": "Shawn Hemelstrand", "author_id": 16631565, "author_profile": "https://Stackoverflow.com/users/16631565", "pm_score": 1, "selected": false, "text": "add_row" }, { "answer_id": 74458131, "author": "TarJae", "author_id": 13321647, "author_profile": "https://Stackoverflow.com/users/13321647", "pm_score": 1, "selected": false, "text": "library(dplyr)\nlibrary(tidyr)\n\ndf %>% \n group_by(Name) %>% \n summarise(cur_data()[seq(2),]) %>% \n ungroup() %>% \n mutate(Fruit = if(first(Fruit) == \"Pear\") replace(Fruit, is.na(Fruit), \"Apple\") \n else replace(Fruit), is.na(Fruit), first(Fruit)) %>% \n mutate(Qty = replace_na(Qty, 0)) %>% \n select(Name, Fruit, Qty)\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19932692/" ]
74,457,775
<p>I'd like to scrape news headline, link of news and picture of that news.</p> <p><a href="https://i.stack.imgur.com/sBS3N.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sBS3N.jpg" alt="enter image description here" /></a></p> <p>I try to use web scraping following as below. but It's only headline code and It is not work.</p> <pre><code>import requests import pandas as pd from bs4 import BeautifulSoup nbc_business = &quot;https://news.mongabay.com/list/environment&quot; res = requests.get(nbc_business, verify=False) soup = BeautifulSoup(res.content, 'html.parser') headlines = soup.find_all('h2',{'class':'post-title-news'}) len(headlines) for i in range(len(headlines)): print(headlines[i].text) </code></pre> <p>Please recommend it to me.</p>
[ { "answer_id": 74457966, "author": "Charles Han", "author_id": 11514907, "author_profile": "https://Stackoverflow.com/users/11514907", "pm_score": 1, "selected": false, "text": "nbc_business = \"https://news.mongabay.com/list/environment\"\nres = requests.get(nbc_business, verify=False, headers={'User-Agent':'Mozilla/5.0'})\n\nsoup = BeautifulSoup(res.content, 'html.parser')\n\nheadlines = soup.find_all('h2', class_='post-title-news')\nprint(len(headlines))\nfor i in range(len(headlines)):\n print(headlines[i].text)\n" }, { "answer_id": 74458168, "author": "Klas Š.", "author_id": 9288580, "author_profile": "https://Stackoverflow.com/users/9288580", "pm_score": 0, "selected": false, "text": "<h2>" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18361460/" ]
74,457,778
<p>I am trying to delete an item from filtered list but it is not getting updated.</p> <p>I am able to delete item without filtering.</p> <p>html</p> <pre><code>&lt;div class=&quot;search-hero&quot;&gt; &lt;input class=&quot;form-control&quot; type=&quot;text&quot; name=&quot;search&quot; [(ngModel)]=&quot;searchText&quot; autocomplete=&quot;off&quot; placeholder=&quot;&amp;#61442; Start searching for a hero by id or name or country&quot; /&gt; &lt;/div&gt; &lt;table class=&quot;table table-striped&quot;&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Id&lt;/th&gt; &lt;th&gt;Hero Name&lt;/th&gt; &lt;th&gt;Country&lt;/th&gt; &lt;th&gt;Delete&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr *ngFor=&quot;let hero of heroes | filter: searchText; let index = index&quot;&gt; &lt;td&gt;{{ hero.id }}&lt;/td&gt; &lt;td&gt;{{ hero.name }}&lt;/td&gt; &lt;td&gt;{{ hero.country }}&lt;/td&gt; &lt;td (click)=&quot;onDelete(index)&quot;&gt;&lt;button&gt;Delete&lt;/button&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>Ts file:</p> <pre><code>searchText; heroes = [ { id: 11, name: 'Mr. Nice', country: 'India' }, { id: 12, name: 'Narco', country: 'USA' }, { id: 13, name: 'Bombasto', country: 'UK' }, { id: 14, name: 'Celeritas', country: 'Canada' }, { id: 15, name: 'Magneta', country: 'Russia' }, { id: 16, name: 'RubberMan', country: 'China' }, { id: 17, name: 'Dynama', country: 'Germany' }, { id: 18, name: 'Dr IQ', country: 'Hong Kong' }, { id: 19, name: 'Magma', country: 'South Africa' }, { id: 20, name: 'Tornado', country: 'Sri Lanka' }, ]; onDelete(index) { this.heroes.splice(index, 1); console.log('deleted'); } </code></pre> <p>UI is not updating only when something is searched in the searchbar.</p> <p>Here is the reproducible example <a href="https://stackblitz.com/edit/angular-search-filter-izxdvr?file=app%2Fapp.component.html,app%2Fapp.component.ts" rel="nofollow noreferrer">link</a></p> <p>Thanks!</p>
[ { "answer_id": 74457966, "author": "Charles Han", "author_id": 11514907, "author_profile": "https://Stackoverflow.com/users/11514907", "pm_score": 1, "selected": false, "text": "nbc_business = \"https://news.mongabay.com/list/environment\"\nres = requests.get(nbc_business, verify=False, headers={'User-Agent':'Mozilla/5.0'})\n\nsoup = BeautifulSoup(res.content, 'html.parser')\n\nheadlines = soup.find_all('h2', class_='post-title-news')\nprint(len(headlines))\nfor i in range(len(headlines)):\n print(headlines[i].text)\n" }, { "answer_id": 74458168, "author": "Klas Š.", "author_id": 9288580, "author_profile": "https://Stackoverflow.com/users/9288580", "pm_score": 0, "selected": false, "text": "<h2>" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12708549/" ]
74,457,790
<p>I created a HelloWorld macOS SwiftUI project and I am seeing the option of <strong>EnterFullScreen</strong> in <strong>View</strong> menu, so how can I remove this option and disable it from bace in SwiftUI?</p> <pre><code> @main struct testApp: App { var body: some Scene { WindowGroup { ContentView() } } } </code></pre> <p><a href="https://i.stack.imgur.com/xAo2o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xAo2o.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74458516, "author": "ScottM", "author_id": 1326518, "author_profile": "https://Stackoverflow.com/users/1326518", "pm_score": 0, "selected": false, "text": "struct TestApp: App {\n var body: some Scene {\n WindowGroup {\n ContentView()\n .frame(maxWidth: 400, maxHeight: 500)\n }\n .windowResizability(.contentSize)\n }\n}\n" }, { "answer_id": 74458617, "author": "Joakim Danielson", "author_id": 9223839, "author_profile": "https://Stackoverflow.com/users/9223839", "pm_score": 2, "selected": true, "text": "UserDefaults" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20027993/" ]
74,457,811
<p>I want to loop through an array of objects to get a specific id and then render its data in a component in react, why it cannot be mapped, what is wrong here?</p> <pre><code>const projectData = projects.find(element =&gt; { return element.id === projectId; }); return ( {projectData.map(project =&gt; { return &lt;ProjectData key={project.id} {...project}&gt;&lt;/ProjectData&gt;; })} ) </code></pre>
[ { "answer_id": 74457837, "author": "Sachila Ranawaka", "author_id": 6428638, "author_profile": "https://Stackoverflow.com/users/6428638", "pm_score": 3, "selected": true, "text": "find" }, { "answer_id": 74457908, "author": "Bikas Lin", "author_id": 17582798, "author_profile": "https://Stackoverflow.com/users/17582798", "pm_score": 0, "selected": false, "text": "find()" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18892774/" ]
74,457,840
<p>I need to pass a unique pointer to a derived template class to a function that takes a unique base template class, like this:</p> <pre><code>template &lt;typename T&gt; class Base {}; template &lt;typename T&gt; class Derived : public Base&lt;T&gt; {}; template &lt;typename T&gt; void foo(std::unique_ptr&lt;Base&lt;T&gt;&gt;){} //or template &lt;typename T&gt; class MyClass{ public: MyClass(std::unique_ptr&lt;Base&lt;T&gt;&gt; arg) : _arg(std::move(arg)) {} private: std::unique_ptr&lt;Base&lt;T&gt;&gt; _arg; }; int main() { auto b = make_unique&lt;Derived&lt;int&gt;&gt;(); foo(std::move(b)); MyClass mc(std::move(b)) } </code></pre> <p>Why is this not working and how can I fix it?</p> <p>I get an error:</p> <pre><code>'void foo1&lt;T&gt;(std::unique_ptr&lt;Base&lt;T&gt;,std::default_delete&lt;Base&lt;T&gt;&gt;&gt;)': cannot convert argument 1 from 'std::unique_ptr&lt;Derived&lt;int&gt;,std::default_delete&lt;Derived&lt;int&gt;&gt;&gt;' to 'std::unique_ptr&lt;Base&lt;T&gt;,std::default_delete&lt;Base&lt;T&gt;&gt;&gt;' </code></pre> <p>but it work</p> <pre><code>auto derived = std::make_unique&lt;Derived&lt;int&gt;&gt;(); std::unique_ptr&lt;Base&lt;int&gt;&gt; base = std::move(derived); </code></pre>
[ { "answer_id": 74458224, "author": "Caleth", "author_id": 2610810, "author_profile": "https://Stackoverflow.com/users/2610810", "pm_score": 2, "selected": false, "text": "<int>" }, { "answer_id": 74458559, "author": "user17732522", "author_id": 17732522, "author_profile": "https://Stackoverflow.com/users/17732522", "pm_score": 0, "selected": false, "text": "T" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20518079/" ]
74,457,868
<p>What I'm trying to achieve is:</p> <ol> <li>Building simple <code>react app</code> - the template is <code>create react app</code></li> <li>Copying output file (main.*.js)</li> <li>Pasting it in another <code>react app</code></li> <li><code>Importing</code> render function to render the first app into the second one</li> </ol> <p>Simple react app code:</p> <pre><code>interface Props { greeting: string; } export module AppModule { export const sendGreetings = ({ greeting }: Props) =&gt; { return `Hello ${greeting}`; }; } </code></pre> <p>Builder file code:</p> <pre><code>!function(){&quot;use strict&quot;;var n;(n||(n={})).sendGreetings=function(n){var e=n.greeting;return&quot;Hello &quot;.concat(e)}}(); </code></pre> <p>Trying to import this file into another app I get this error:</p> <pre><code>File 'c:/vscode/test-react-app/test-sc-react/src/main.783e0281.js' is not a module.ts(2306) </code></pre> <p>Which is obvious. I changed the output file manually to:</p> <pre><code>export function initApp(){&quot;use strict&quot;;var n;(n||(n={})).sendGreetings=function(n){var e=n.greeting;return&quot;Hello &quot;.concat(e)}}; </code></pre> <p>It works but the only function that I'm able to access is <code>initApp</code> but not <code>sendGreetings</code></p> <p>I've been struggling with this for a while now and I would really appreciate any helpful suggestions</p>
[ { "answer_id": 74578250, "author": "Rohit Khandelwal", "author_id": 15220748, "author_profile": "https://Stackoverflow.com/users/15220748", "pm_score": 0, "selected": false, "text": "window.addEventListener" }, { "answer_id": 74585398, "author": "sultan", "author_id": 2236855, "author_profile": "https://Stackoverflow.com/users/2236855", "pm_score": 0, "selected": false, "text": "<iframe src='path-to-your-app.html'/>\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8688902/" ]
74,457,884
<p>I have a div that contains text, but there is empty space around them by default. Setting the width to min-content solves this, but it means that each word will be on a separate line. If there is space for more than 1 word on 1 line, I need the words to stay be on one line.</p> <p>Here is what things look like with without <code>width: min-content</code>:</p> <p><a href="https://i.stack.imgur.com/5qsM4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5qsM4.png" alt="enter image description here" /></a></p> <p>As you can see, there is space around this for some reason and I can't figure out why. It's just a grid item/flex item and no css a part from font size and line height.</p>
[ { "answer_id": 74578250, "author": "Rohit Khandelwal", "author_id": 15220748, "author_profile": "https://Stackoverflow.com/users/15220748", "pm_score": 0, "selected": false, "text": "window.addEventListener" }, { "answer_id": 74585398, "author": "sultan", "author_id": 2236855, "author_profile": "https://Stackoverflow.com/users/2236855", "pm_score": 0, "selected": false, "text": "<iframe src='path-to-your-app.html'/>\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12744338/" ]
74,457,895
<p>When task switch happens in an OS, how to decide which registers should be preserved?</p> <p>Is this purely decided by hardware architecture? Or also involve the OS implementation?</p> <p>I once did some naïve implementation on ARM architecture that preserve all the R1 ~ R15 registers (if I remember it correctly). But that seems too much.</p> <p>I also tried the x86 hardware task switching support, the TSS segment covers a lot of registers which doesn't have good performance as well.</p> <p>I guess the design philosophy of an OS, especially the implementation of a <strong>task state</strong> should decide this. But I am not sure if there's any best practice or conventions. Or other factors.</p>
[ { "answer_id": 74578250, "author": "Rohit Khandelwal", "author_id": 15220748, "author_profile": "https://Stackoverflow.com/users/15220748", "pm_score": 0, "selected": false, "text": "window.addEventListener" }, { "answer_id": 74585398, "author": "sultan", "author_id": 2236855, "author_profile": "https://Stackoverflow.com/users/2236855", "pm_score": 0, "selected": false, "text": "<iframe src='path-to-your-app.html'/>\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/264052/" ]
74,457,932
<p>Here my Goal is to display a google sheet range as a table in my site.</p> <p>The default range for <strong>rangeB</strong> to be displayed in table is <strong>&quot;P6:R34&quot;</strong> ;</p> <p>But when times up it should be <strong>&quot;P5:R34&quot;</strong></p> <p>So I wrote my code But it's giving below error.</p> <pre><code>TypeError: range.getDisplayValues is not a function (line 31, file &quot;Code&quot;) </code></pre> <p>What went wrong (or) how to combine these ranges in App Script ..?</p> <p><strong>Code.gs</strong></p> <pre><code>function doGet() { template = HtmlService.createTemplateFromFile('Index.html'); return template.evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME) .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL); } var now = new Date().getTime() ; var d = new Date(); var year = d.getFullYear(); var month = d.getMonth(); var date = d.getDate(); var ctdr = new Date(year, month, date, 14, 13, 00).getTime(); distance = ctdr - now; var spreadsheetId = '1jH0y-PknkZXH7KqjPBWDv98kkBnndGt_GIbdUh_1nRM'; var sheet = SpreadsheetApp.openById(spreadsheetId).getSheetByName(&quot;LNW&quot;) ; rangeA = sheet.getRange(&quot;P4:R4&quot;) ; rangeB = sheet.getRange(&quot;P6:R34&quot;) ; range = [rangeA, rangeB] ; if (distance &lt; 0) { rangeB = sheet.getRange(&quot;P5:R34&quot;) ; } var dataValues = range.getDisplayValues() .map(row =&gt; row.map(value =&gt; value.replace(/\n/g, `&lt;br/&gt;`) ) ); </code></pre> <p><strong>Index.html</strong></p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;base target=&quot;_top&quot;&gt; &lt;/head&gt; &lt;style&gt; table, tbody, tr, th, td { text-align:center; font-family: Arial, sans-serif; font-size: 14.5px ; border-collapse: collapse; margin : auto ; } th { background-color: #f5f5f5 ; padding : 6px ; } &lt;/style&gt; &lt;body&gt; &lt;table cellpadding=&quot;12px&quot; &gt; &lt;? var tableData = dataValues ?&gt; &lt;? for(var i = 0; i &lt; tableData.length; i++) { ?&gt; &lt;? if(i == 0) { ?&gt; &lt;tr&gt; &lt;? for(var j = 0; j &lt; tableData[i].length; j++) { ?&gt; &lt;th&gt; &lt;?!= tableData[i][j] ?&gt;&lt;/th&gt; &lt;? } ?&gt; &lt;/tr&gt; &lt;? } else { ?&gt; &lt;tr&gt; &lt;? for(var j = 0; j &lt; tableData[i].length; j++) { ?&gt; &lt;td&gt; &lt;?!= tableData[i][j] ?&gt;&lt;/td&gt; &lt;? } ?&gt; &lt;/tr&gt; &lt;? } ?&gt; &lt;? } ?&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
[ { "answer_id": 74458106, "author": "rrandrei", "author_id": 1704076, "author_profile": "https://Stackoverflow.com/users/1704076", "pm_score": 1, "selected": false, "text": "range = [rangeA, rangeB] ; \nvar dataValues = range.getDisplayValues()\n.map(row => row.map(value =>\n value.replace(/\\n/g, `<br/>`)\n )\n );\n" }, { "answer_id": 74458117, "author": "idfurw", "author_id": 16125139, "author_profile": "https://Stackoverflow.com/users/16125139", "pm_score": 3, "selected": true, "text": "range" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20018193/" ]
74,457,941
<p>I need somehow store Georgian letters and their pronunciation, and later return the pronunciation for a givven letter. The easiest way to do that in my project is to use an object with the letters as property name and pronunciations as corresponding values.</p> <pre><code>const letters = { ბ: 'b', დ: 'd', ს: 's', წ: 'ts', // and so on } </code></pre> <p>because later I can get the pronunciation this way: <code>return letters[georgianLetter] || &quot;&quot;</code></p> <p>I know any string could be used as a key for an object. But is it a bad practice to use non-latin letters for key names?</p> <p>I have no idea how else I can implement this and still keep the code simple. I tried to use an array:</p> <pre><code>const letters = [ ['ბ', 'b'], ['დ', 'd'], ['ს', 's'], ['წ', 'ts'], // and so on ] </code></pre> <p>and then get the value like this:</p> <pre><code>return letters.find(item =&gt; item[0] === georgianLetter)[1] || &quot;&quot; </code></pre> <p>but it's a bit more complex solution and objects are preferred in this case since they make code shorter and cleaner.</p>
[ { "answer_id": 74458016, "author": "Thomas Zimmermann", "author_id": 13527621, "author_profile": "https://Stackoverflow.com/users/13527621", "pm_score": 3, "selected": true, "text": "Map" }, { "answer_id": 74458082, "author": "T.J. Crowder", "author_id": 157247, "author_profile": "https://Stackoverflow.com/users/157247", "pm_score": 2, "selected": false, "text": "-" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20395932/" ]
74,457,994
<p>---These columns in v_array has counts in it but when i run this code ,its returns zero counts for all columns , where is my mistake ,please help me in it ----</p> <pre><code> set serveroutput on declare type t_list is table of varchar(50) index by PLS_INTEGER; r_emp t_list; type e_list is varray(4) of varchar(50); v_array e_list; begin v_array:=e_list('CLAIRTY_ID','SERV_ACCT_NUMBER','BB_ACQUISITION_TYPE','ONT_ACQ_TYPE'); for i in 1..4 loop select sum(case when v_array(i) is null then 1 else 0 end) into r_emp(i) from SZ_GOODS_DETAIL; dbms_output.put_line( r_emp(i)); end loop; end; --------------output-------------------- 0 0 0 0 PL/SQL procedure successfully completed. </code></pre>
[ { "answer_id": 74458213, "author": "Littlefoot", "author_id": 9097906, "author_profile": "https://Stackoverflow.com/users/9097906", "pm_score": 0, "selected": false, "text": "SQL> SELECT * FROM sz_goods_detail;\n\n ID NAME\n---------- -------------------\n 1 CLAIRTY_ID\n 2 CLAIRTY_ID\n 3 BB_ACQUISITION_TYPE\n\nSQL> SET SERVEROUTPUT ON\n" }, { "answer_id": 74458621, "author": "Alex Poole", "author_id": 266304, "author_profile": "https://Stackoverflow.com/users/266304", "pm_score": 1, "selected": false, "text": "select sum(case when v_array(i) is null then 1 else 0 end) into r_emp(i) from SZ_GOODS_DETAIL;\n" }, { "answer_id": 74458762, "author": "MT0", "author_id": 1509264, "author_profile": "https://Stackoverflow.com/users/1509264", "pm_score": 0, "selected": false, "text": "DECLARE\n r_emp SYS.ODCINUMBERLIST := SYS.ODCINUMBERLIST();\n v_array SYS.ODCIVARCHAR2LIST := SYS.ODCIVARCHAR2LIST(\n 'CLAIRTY_ID','SERV_ACCT_NUMBER','BB_ACQUISITION_TYPE','ONT_ACQ_TYPE'\n );\nBEGIN\n DBMS_OUTPUT.ENABLE;\n FOR i IN 1..v_array.COUNT LOOP\n r_emp.EXTEND;\n EXECUTE IMMEDIATE\n 'SELECT SUM(CASE WHEN \"' || v_array(i) || '\" IS NULL THEN 1 ELSE 0 END) FROM SZ_GOODS_DETAIL'\n INTO r_emp(i);\n dbms_output.put_line(v_array(i) || ': ' || r_emp(i));\n END LOOP;\nEND;\n/\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16825853/" ]
74,458,044
<p>I'm using WSO2 API Manager 4.1.0, ad I configurated a Key Manager of type WSO2 Identity Server. When I go to my application, to generate the token, I have the following exception: <a href="https://pastebin.com/rjfxLiAA" rel="nofollow noreferrer">https://pastebin.com/rjfxLiAA</a></p> <pre><code>Error occurred while executing SubscriberKeyMgtClient. org.wso2.carbon.apimgt.api.APIManagementException: Key Manager IS not configured </code></pre> <p>The IS is not beeing contacted, I have the same error stopping it, so it's only an apim error. With the same APIM versione I can contact keycloak for example. I'm running in server mode, openjdk 11</p>
[ { "answer_id": 74458213, "author": "Littlefoot", "author_id": 9097906, "author_profile": "https://Stackoverflow.com/users/9097906", "pm_score": 0, "selected": false, "text": "SQL> SELECT * FROM sz_goods_detail;\n\n ID NAME\n---------- -------------------\n 1 CLAIRTY_ID\n 2 CLAIRTY_ID\n 3 BB_ACQUISITION_TYPE\n\nSQL> SET SERVEROUTPUT ON\n" }, { "answer_id": 74458621, "author": "Alex Poole", "author_id": 266304, "author_profile": "https://Stackoverflow.com/users/266304", "pm_score": 1, "selected": false, "text": "select sum(case when v_array(i) is null then 1 else 0 end) into r_emp(i) from SZ_GOODS_DETAIL;\n" }, { "answer_id": 74458762, "author": "MT0", "author_id": 1509264, "author_profile": "https://Stackoverflow.com/users/1509264", "pm_score": 0, "selected": false, "text": "DECLARE\n r_emp SYS.ODCINUMBERLIST := SYS.ODCINUMBERLIST();\n v_array SYS.ODCIVARCHAR2LIST := SYS.ODCIVARCHAR2LIST(\n 'CLAIRTY_ID','SERV_ACCT_NUMBER','BB_ACQUISITION_TYPE','ONT_ACQ_TYPE'\n );\nBEGIN\n DBMS_OUTPUT.ENABLE;\n FOR i IN 1..v_array.COUNT LOOP\n r_emp.EXTEND;\n EXECUTE IMMEDIATE\n 'SELECT SUM(CASE WHEN \"' || v_array(i) || '\" IS NULL THEN 1 ELSE 0 END) FROM SZ_GOODS_DETAIL'\n INTO r_emp(i);\n dbms_output.put_line(v_array(i) || ': ' || r_emp(i));\n END LOOP;\nEND;\n/\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5919369/" ]
74,458,055
<p>Im trying to run two functions; one being a 'reload page' and the other a 'copy to clipboard'. I have tried all the options on this page:</p> <p><a href="https://stackoverflow.com/questions/38744932/how-to-call-multiple-functions-with-click-in-vue/74457630?noredirect=1#comment131439691_74457630">How to call multiple functions with @click in vue?</a></p> <p>but none seem to work for me. Can anyone give me any pointers here? Any help is appreciated.</p> <pre><code>&lt;button @click=&quot;reloadPage(); copytheURL(URLcopyaddress);&quot;&gt;Copy&lt;/button&gt; methods: { //reloads the page reloadPage() { window.location.reload(); }, //copy to clipboard async copytheURL(s) { await navigator.clipboard.writeText(s); alert(&quot;URL Copied!&quot;); }, }, </code></pre>
[ { "answer_id": 74458213, "author": "Littlefoot", "author_id": 9097906, "author_profile": "https://Stackoverflow.com/users/9097906", "pm_score": 0, "selected": false, "text": "SQL> SELECT * FROM sz_goods_detail;\n\n ID NAME\n---------- -------------------\n 1 CLAIRTY_ID\n 2 CLAIRTY_ID\n 3 BB_ACQUISITION_TYPE\n\nSQL> SET SERVEROUTPUT ON\n" }, { "answer_id": 74458621, "author": "Alex Poole", "author_id": 266304, "author_profile": "https://Stackoverflow.com/users/266304", "pm_score": 1, "selected": false, "text": "select sum(case when v_array(i) is null then 1 else 0 end) into r_emp(i) from SZ_GOODS_DETAIL;\n" }, { "answer_id": 74458762, "author": "MT0", "author_id": 1509264, "author_profile": "https://Stackoverflow.com/users/1509264", "pm_score": 0, "selected": false, "text": "DECLARE\n r_emp SYS.ODCINUMBERLIST := SYS.ODCINUMBERLIST();\n v_array SYS.ODCIVARCHAR2LIST := SYS.ODCIVARCHAR2LIST(\n 'CLAIRTY_ID','SERV_ACCT_NUMBER','BB_ACQUISITION_TYPE','ONT_ACQ_TYPE'\n );\nBEGIN\n DBMS_OUTPUT.ENABLE;\n FOR i IN 1..v_array.COUNT LOOP\n r_emp.EXTEND;\n EXECUTE IMMEDIATE\n 'SELECT SUM(CASE WHEN \"' || v_array(i) || '\" IS NULL THEN 1 ELSE 0 END) FROM SZ_GOODS_DETAIL'\n INTO r_emp(i);\n dbms_output.put_line(v_array(i) || ': ' || r_emp(i));\n END LOOP;\nEND;\n/\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20340686/" ]
74,458,068
<p>Need to fill the data accrding to the stage and last stage is the maximum date</p> <p>Input:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>RecordID</th> <th>ChangeDate</th> <th>Stage</th> </tr> </thead> <tbody> <tr> <td>17764</td> <td>31-08-2021</td> <td>New</td> </tr> <tr> <td>17764</td> <td>02-09-2021</td> <td>inprogress</td> </tr> <tr> <td>17764</td> <td>05-09-2021</td> <td>won</td> </tr> <tr> <td>70382</td> <td>04-01-2022</td> <td>new</td> </tr> <tr> <td>70382</td> <td>06-01-2022</td> <td>hold</td> </tr> <tr> <td>70382</td> <td>07-01-2022</td> <td>lost</td> </tr> </tbody> </table> </div> <p>Expceted output:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>RecordID</th> <th>ChangeDate</th> <th>Stage</th> </tr> </thead> <tbody> <tr> <td>17764</td> <td>31-08-2021</td> <td>New</td> </tr> <tr> <td>17764</td> <td>01-09-2021</td> <td>New</td> </tr> <tr> <td>17764</td> <td>02-09-2021</td> <td>inprogress</td> </tr> <tr> <td>17764</td> <td>03-09-2021</td> <td>inprogress</td> </tr> <tr> <td>17764</td> <td>04-09-2021</td> <td>inprogress</td> </tr> <tr> <td>17764</td> <td>05-09-2021</td> <td>won</td> </tr> <tr> <td>70382</td> <td>04-01-2022</td> <td>new</td> </tr> <tr> <td>70382</td> <td>05-01-2022</td> <td>new</td> </tr> <tr> <td>70382</td> <td>06-01-2022</td> <td>hold</td> </tr> <tr> <td>70382</td> <td>07-01-2022</td> <td>lost</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74458769, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 2, "selected": false, "text": "groupby.resample" }, { "answer_id": 74459263, "author": "sammywemmy", "author_id": 7175713, "author_profile": "https://Stackoverflow.com/users/7175713", "pm_score": 2, "selected": true, "text": "# pip install pyjanitor\nimport pandas as pd\nimport janitor\n\n# build a list of new dates\nnew_dates = {'ChangeDate': lambda df: pd.date_range(df.min(), df.max(), freq='1D')}\n\ndf.complete(new_dates, by = 'RecordID').ffill()\nOut[70]: \n RecordID ChangeDate Stage\n0 17764 2021-08-31 New\n1 17764 2021-09-01 New\n2 17764 2021-09-02 inprogress\n3 17764 2021-09-03 inprogress\n4 17764 2021-09-04 inprogress\n5 17764 2021-09-05 won\n6 70382 2022-01-04 new\n7 70382 2022-01-05 new\n8 70382 2022-01-06 hold\n9 70382 2022-01-07 lost\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6733745/" ]
74,458,073
<p>So I've been formatting this form and it looks ok on Desktop now. But I need it to change when it's on mobile. It's two elements, one image and one form, side by side. I need them to change to top and bottom when on mobile. Probably a @media query CSS?</p> <p>I've tried using percentages for widths, but the image size isn't changing and the form component either ends up overlapping it, or it gets cut off... <a href="https://i.stack.imgur.com/p1IRQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p1IRQ.png" alt="Desktop" /></a> <a href="https://i.stack.imgur.com/T3LQd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/T3LQd.png" alt="Mobile" /></a></p> <p>HTML Code:</p> <pre><code> &lt;head&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;/assets/signup.css&quot;&gt; &lt;/head&gt; &lt;!-- Begin Mailchimp Signup Form --&gt; &lt;div id=&quot;mc_embed_signup&quot;&gt; &lt;div id=&quot;image&quot;&gt;&lt;img src=&quot;images/genesis.gif&quot;&gt;&lt;/div&gt; &lt;form action=&quot;https://opipets.us17.list-manage.com/subscribe/post?u=3fa8d83aedc08e2a8814c787c&amp;amp;id=27f9c81072&amp;amp;v_id=4140&amp;amp;f_id=00bb56e0f0&quot; method=&quot;post&quot; id=&quot;mc-embedded-subscribe-form&quot; name=&quot;mc-embedded-subscribe-form&quot; class=&quot;validate&quot; target=&quot;_blank&quot; novalidate&gt; &lt;div id=&quot;mc_embed_signup_scroll&quot;&gt; &lt;h2&gt;Join our Whitelist&lt;/h2&gt; &lt;div class=&quot;mc-field-group&quot;&gt; &lt;label for=&quot;mce-EMAIL&quot;&gt;Email &lt;/label&gt; &lt;input type=&quot;email&quot; value=&quot;&quot; name=&quot;EMAIL&quot; class=&quot;required email&quot; id=&quot;mce-EMAIL&quot; required&gt; &lt;span id=&quot;mce-EMAIL-HELPERTEXT&quot; class=&quot;helper_text&quot;&gt;&lt;/span&gt; &lt;/div&gt; &lt;div id=&quot;mergeRow-gdpr&quot; class=&quot;mergeRow gdpr-mergeRow content__gdprBlock mc-field-group&quot;&gt; &lt;div class=&quot;content__gdpr&quot;&gt; &lt;span&gt; &lt;fieldset class=&quot;mc_fieldset gdprRequired mc-field-group&quot; name=&quot;interestgroup_field&quot;&gt; &lt;label class=&quot;checkbox subfield&quot; for=&quot;gdpr_90860&quot;&gt;&lt;input type=&quot;checkbox&quot; id=&quot;gdpr_90860&quot; name=&quot;gdpr[90860]&quot; value=&quot;Y&quot; class=&quot;av-checkbox gdpr&quot;&gt;&lt;/label&gt; &lt;/fieldset&gt; &lt;p&gt;&lt;b&gt;I agree to receive communications from Opis Group Ltd&lt;/b&gt;&lt;/p&gt; &lt;/span&gt; &lt;br&gt; &lt;p&gt;Your privacy is our policy. Occasionally, we'll contact you about our products and services, and other content that may be of interest. You can unsubscribe at any time.&lt;/p&gt; &lt;p&gt;We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. &lt;/p&gt; &lt;br&gt; &lt;p&gt;&lt;a href=&quot;https://mailchimp.com/legal/terms&quot; target=&quot;_blank&quot;&gt;Learn more about Mailchimp's privacy practices here.&lt;/a&gt;&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div hidden=&quot;true&quot;&gt;&lt;input type=&quot;hidden&quot; name=&quot;tags&quot; value=&quot;6456416,6456520&quot;&gt;&lt;/div&gt; &lt;div id=&quot;mce-responses&quot; class=&quot;clear&quot;&gt; &lt;div class=&quot;response&quot; id=&quot;mce-error-response&quot; style=&quot;display:none&quot;&gt;&lt;/div&gt; &lt;div class=&quot;response&quot; id=&quot;mce-success-response&quot; style=&quot;display:none&quot;&gt;&lt;/div&gt; &lt;/div&gt; &lt;!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups--&gt; &lt;div style=&quot;position: absolute; left: -5000px;&quot; aria-hidden=&quot;true&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;b_3fa8d83aedc08e2a8814c787c_27f9c81072&quot; tabindex=&quot;-1&quot; value=&quot;&quot;&gt;&lt;/div&gt; &lt;div class=&quot;clear&quot;&gt;&lt;input type=&quot;submit&quot; value=&quot;Subscribe&quot; name=&quot;subscribe&quot; id=&quot;mc-embedded-subscribe&quot; class=&quot;button&quot;&gt;&lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;script type='text/javascript' src='//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js'&gt;&lt;/script&gt;&lt;script type='text/javascript'&gt;(function($) {window.fnames = new Array(); window.ftypes = new Array();fnames[0]='EMAIL';ftypes[0]='email';}(jQuery));var $mcj = jQuery.noConflict(true);&lt;/script&gt; &lt;!--End mc_embed_signup--&gt; </code></pre> <p>CSS Code:</p> <pre><code>@font-face { font-family: museo-sans; src: url(/fonts/museosans_300.otf) format(&quot;opentype&quot;); font-display: auto; font-style: normal; font-weight: 300; font-stretch: normal } @font-face { font-family: museo-sans-bold; src: url(/fonts/museosans_700.otf) format(&quot;opentype&quot;); font-display: auto; font-style: normal; font-weight: 700; font-stretch: normal } @font-face { font-family: bwstretch; src: url(/fonts/BWSTRETCH-BLACK.OTF) format(&quot;opentype&quot;); font-display: auto; font-style: normal; font-weight: 800; font-stretch: normal } a { font-family: museo-sans-bold; color: #ffc860; } h2 { font-family: bwstretch; text-align: center; text-transform: uppercase; font-size: 3vh !important; } body { font-size: 1.5vh; background-color: #191f43; font-family: museo-sans; color: #191f43; } #mc_embed_signup { width: 90% overflow: auto; height: 90%; display: flex; align-items: center; justify-content: center; vertical-align: middle; position: absolute; top: 50%; left: 50%; margin-right: -50%; transform: translate(-50%, -50%); color: #191f43; } div.mc-field-group { width: 90% overflow: auto; } div.mc-field-group label { font-size: 2vh; font-family: museo-sans-bold; width: auto; } div.mc-field-group input { font-size: 1.5vh; font-family: museo-sans-bold; width: 90%; color: #191f43; border: 0; height: 30px; border-radius: 5px; padding-left: 10px; padding-bottom: 10px; padding-top: 10px; margin-left: 10px; } #image { max-width:30% overflow: auto; background-color: #191f43; } #content__gdpr { display: flex; justify-content: center; align-items: center; } #mc_embed_signup { width: 90%; background-color: #191f43; color: #ffc860; font-family: museo-sans; } #mc-embedded-subscribe-form input[type=checkbox]{ display: flex; width: auto; margin-right: 0px; margin-left: -15px; margin-top: -2px; } #mergeRow-gdpr { margin-top: 20px; font-size: 1.5vh; } #mergeRow-gdpr fieldset label { font-weight: normal; } #mc-embedded-subscribe-form .mc_fieldset { border:none; min-height: 0px; padding-bottom:0px; } input.button { color: #191f43; background-color: #ffc860; padding-top: 10px; padding-bottom: 10px; padding-left: 45px; padding-right: 45px; font-family: bwstretch; text-transform: uppercase; font-size: 1.5em; border: 0; border-radius: 40px; } span { display: flex; align-items: center; } </code></pre>
[ { "answer_id": 74458325, "author": "compuGreen", "author_id": 20291198, "author_profile": "https://Stackoverflow.com/users/20291198", "pm_score": 1, "selected": false, "text": "@media (max-width: 768px) {\n h2{\n background-color: #ffc860;\n }\n}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19112300/" ]
74,458,089
<p>For a uni assignment, we have been given a line of Haskell code which shows:</p> <pre><code>newtype TC a = TC ([Id] -&gt; Either TypeError ([Id], a)) </code></pre> <p>Firstly, <code>TypeError</code> is something which needs to be implemented by us for the assignment so I can't post the data declaration here, but my question is this. How do I read the code above? What is the <code>a</code> right after the <code>newtype TC</code>? I also don't understand how <code>TC</code> is being reused to the right of the equals sign.</p> <p>I think <code>a</code> here is a type variable since <code>newtype</code> works similarly to data. I don't know how knowing this will help my understanding.</p>
[ { "answer_id": 74458446, "author": "leftaroundabout", "author_id": 745903, "author_profile": "https://Stackoverflow.com/users/745903", "pm_score": 4, "selected": true, "text": "a" }, { "answer_id": 74467982, "author": "Iceland_jack", "author_id": 165806, "author_profile": "https://Stackoverflow.com/users/165806", "pm_score": 0, "selected": false, "text": "{-# Language DerivingVia #-}\n{-# Language StandaloneKindSignatures #-}\n\nimport Control.Applicative (Alternative)\nimport Control.Monad (MonadPlus)\nimport Control.Monad.Except (ExceptT(..), Except)\nimport Control.Monad.Fix (MonadFix)\nimport Control.Monad.State (StateT(..), MonadState)\nimport Data.Functor.Identity (Identity(..))\nimport Data.Kind (Type)\n\ntype TC :: Type -> Type\nnewtype TC a = MkTC ([Id] -> Either TypeError (a, [Id]))\n deriving\n ( Functor, Applicative, Alterantive\n , Monad, MonadPlus, MonadState [Id], MonadFix\n )\n via StateT [Id] (Except TypeError)\n\n-- Alternative and MonadPlus rely on these\ninstance Semigroup TypeError ..\ninstance Monoid TypeError ..\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19866923/" ]
74,458,097
<p>I'm new to react so pardon any mistake. I want to update user profile picture but i dont know how can i make a clickable image(<code>variable name -&gt;&quot;avatar&quot; in code</code>) which previews and then update(in database also), if we click save.</p> <p>Can someone help me adding a clickable image that previews and updates the from and database as well. <strong>If we cannot make clickable image, a separate button for upload and save will also be fine.</strong> Let me know if you want more info about code. the code i have:</p> <pre><code>import React from 'react'; import ProfileBanner from '../ProfileBanner'; import coverSrc from 'assets/img/generic/4.jpg'; //import avatar from 'assets/img/team/2.jpg'; import { Col, Row } from 'react-bootstrap'; import ProfileSettings from './ProfileSettings'; //import ExperiencesSettings from './ExperiencesSettings'; //import EducationSettings from './EducationSettings'; //import AccountSettings from './AccountSettings'; import BillingSettings from './BillingSettings'; import ChangePassword from './ChangePassword'; import DangerZone from './DangerZone'; import axios from 'axios'; import Cookies from 'universal-cookie'; import { useEffect ,useState,useRef} from 'react'; import { toast } from 'react-toastify'; const Settings = () =&gt; { const [formData, setFormData] = useState({ avatar: '', }); //const { avatar} = formData; const cookies = new Cookies(); const user_id = cookies.get('xyz'); useEffect(async () =&gt; { //e.preventDefault(); const config = { headers: { &quot;Content-Type&quot;: &quot;application/json&quot;, }, }; try { const { data } = await axios.post( `/api/auth/ImageRetrieve`, { user_id }, config ); setFormData({ avatar:data.link }); } catch (error) { toast.success('Something went wrong', { theme: 'colored' }); } }, []); return ( &lt;&gt; &lt;ProfileBanner&gt; &lt;div&gt; &lt;ProfileBanner.Header coverSrc={coverSrc} avatar={formData.avatar} className=&quot;mb-8&quot; /&gt; &lt;/div&gt; &lt;/ProfileBanner&gt; &lt;Row className=&quot;g-3&quot;&gt; &lt;Col lg={8}&gt; &lt;ProfileSettings /&gt; {/*&lt;ExperiencesSettings /&gt; &lt;EducationSettings /&gt;}*/} &lt;br&gt;&lt;/br&gt; &lt;ChangePassword /&gt; &lt;/Col&gt; &lt;Col lg={4}&gt; &lt;div className=&quot;sticky-sidebar&quot;&gt; {/* &lt;AccountSettings /&gt;*/} &lt;BillingSettings /&gt; &lt;DangerZone /&gt; &lt;/div&gt; &lt;/Col&gt; &lt;/Row&gt; &lt;/&gt; ); }; export default Settings; </code></pre>
[ { "answer_id": 74458438, "author": "Yosi Leibman", "author_id": 9162901, "author_profile": "https://Stackoverflow.com/users/9162901", "pm_score": 2, "selected": false, "text": "onClick" }, { "answer_id": 74584376, "author": "codinn.dev", "author_id": 15755662, "author_profile": "https://Stackoverflow.com/users/15755662", "pm_score": 0, "selected": false, "text": " const [selectedAvatar, setSelectedAvatar] = useState();\n const [formData, setFormData] = useState({\n avatar: '',\n });\n\n useEffect(() => {\n if (!selectedAvatar) {\n setFormData({...formData, avatar: ''});\n return;\n }\n\n const objectUrl = URL.createObjectURL(selectedAvatar);\n \n //DB call to save objectUrl into the DB\n\n setFormData({...formData, avatar: objectUrl});\n \n return () => URL.revokeObjectURL(objectUrl);\n }, [selectedAvatar]);\n\n const onSelectFile = e => {\n if (!e.target.files || !e.target.files.length) {\n setSelectedAvatar('');\n return;\n }\n\n setSelectedAvatar(e.target.files[0]);\n }\n\n return (\n <div>\n <input type='file' onChange={onSelectFile} />\n {!!selectedAvatar && <div> \n <ProfileBanner.Header\n coverSrc={coverSrc}\n avatar={formData.avatar}\n className=\"mb-8\"\n /> \n </div> \n }\n </div>\n )\n \n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20206343/" ]
74,458,109
<pre><code>Uncaught SyntaxError: &quot;[object Object]&quot; is not valid JSON at JSON.parse (&lt;anonymous&gt;) vendors~main.chunk.js:32926 The above error occurred in the &lt;Home&gt; component: at Home (http://localhost:3000/static/js/main.chunk.js:1640:99) at RenderedRoute (http://localhost:3000/static/js/vendors~main.chunk.js:131876:5) at Routes (http://localhost:3000/static/js/vendors~main.chunk.js:132298:5) at App at Router (http://localhost:3000/static/js/vendors~main.chunk.js:132236:15) at BrowserRouter (http://localhost:3000/static/js/vendors~main.chunk.js:130557:5) Consider adding an error boundary to your tree to customize error handling behavior. Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries. console.&lt;computed&gt; @ vendors~main.chunk.js:32926 localhost/:1 Uncaught (in promise) SyntaxError: &quot;[object Object]&quot; is not valid JSON at JSON.parse (&lt;anonymous&gt;) at Home (main.chunk.js:1643:72) VM23:2 Uncaught ReferenceError: process is not defined **CODE** </code></pre> <p>const Home = () =&gt; { const scrollRef = useRef(null); const userInfo = localStorage.getItem('user') !== 'undefined' ? JSON.parse(localStorage.getItem('user')) : localStorage.clear(); useEffect(() =&gt; { const query = userQuery(userInfo?.sub);</p> <pre><code> client.fetch(query).then((data) =&gt; { setUser(data[0]); }) }, []); useEffect(()=&gt;{ scrollRef.current.scrollTo(0, 0); },[]) </code></pre>
[ { "answer_id": 74458186, "author": "Naman Agrawal", "author_id": 14599596, "author_profile": "https://Stackoverflow.com/users/14599596", "pm_score": 1, "selected": false, "text": "JSON.stringify(data)" }, { "answer_id": 74458757, "author": "Kartoos", "author_id": 7801965, "author_profile": "https://Stackoverflow.com/users/7801965", "pm_score": 0, "selected": false, "text": "\"[object Object]\"" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17910989/" ]
74,458,116
<p>I am trying to use a tab bar in order to use different views. On some of those views I have a list of items and I wish that list to be .searchable. If I go to each of the views and search it works like a charm, but when I embed that in the tabbed view the list becomes non-responsive to click but it responds to scroll gesture.</p> <p>I will expand the idea with code that I have and screenshots, but I am pretty sure that the problem resides in how I'm implementing the combination of the tab bar view and the views that have the searchable modifier:</p> <p><a href="https://i.stack.imgur.com/qaXYk.png" rel="nofollow noreferrer">This code works well</a></p> <pre><code>import SwiftUI struct ClientListView: View { @ObservedObject var viewModel = ClientFeedViewModel() @State var searchText: String @State private var showingSheet = false @State private var showList = false var clients: [Client] { if searchText.count &gt; 2 { return searchText.isEmpty ? viewModel.clients : viewModel.search(withText: searchText) } return viewModel.clients } init(){ searchText = &quot;&quot; } var body: some View { NavigationView { List(clients) { client in NavigationLink(destination: { }, label: { VStack { Text(client.clientName) } }) .listRowSeparator(.hidden) } .searchable(text: $searchText) .listStyle(.plain) } } } struct ClientListView_Previews: PreviewProvider { static var previews: some View { ClientListView() } } </code></pre> <p>The problem starts when I do this and implement the ClientListView in a tab bar view like this: <a href="https://i.stack.imgur.com/GJBaB.png" rel="nofollow noreferrer">Tab bar with different views not working searchable modifier</a></p> <p>This is the code of the Tab Bar View:</p> <pre><code>import SwiftUI struct MainTabView: View { @EnvironmentObject var viewModel: AuthViewModel @Binding var selectedIndex: Int var body: some View { NavigationView { VStack { TabView(selection: $selectedIndex) { ClientListView() .onTapGesture { selectedIndex = 0 } .tabItem { Label(&quot;Clients&quot;, systemImage: &quot;list.bullet&quot;) }.tag(0) ProjectListView() .onTapGesture { selectedIndex = 1 } .tabItem { Image(systemName: &quot;person&quot;) Label(&quot;Projects&quot;, systemImage: &quot;list.dash&quot;) }.tag(1) TaskListView() .tabItem { Image(systemName: &quot;person&quot;) Label(&quot;Tasks&quot;, systemImage: &quot;list.dash&quot;) }.tag(2) .onTapGesture { selectedIndex = 2 } ClientListView() .tabItem { Label(&quot;Settings&quot;, systemImage: &quot;gear&quot;) }.tag(3) .onTapGesture { selectedIndex = 3 } } .navigationTitle(tabTitle) } .toolbar { ToolbarItem(placement: .navigationBarLeading) { Image(&quot;logo_silueta&quot;) .resizable() .scaledToFit() .frame(width: 30, height: 30) } ToolbarItem(placement: .navigationBarTrailing) { Button(action: { viewModel.signOut() }, label: { Text(&quot;logout&quot;) }) } } .navigationBarTitleDisplayMode(.inline) } } var tabTitle: String { switch selectedIndex { case 0: return &quot;Clients&quot; case 1: return &quot;Projects&quot; case 2: return &quot;Tasks&quot; case 3: return &quot;Settings&quot; default: return &quot;&quot; } } } struct MainTabView_Previews: PreviewProvider { static var previews: some View { MainTabView(selectedIndex: .constant(0)) } } </code></pre> <p>Navigation on the tabbed view works and displays the different names on the tab bar title, but when I click cancel or x button of the search bar, it doesn't work and also the list becomes unclickable</p> <p>So far I haven't been able to find where the problem is but I am assuming its because the tab bar view is messing up with the searchable property</p>
[ { "answer_id": 74458186, "author": "Naman Agrawal", "author_id": 14599596, "author_profile": "https://Stackoverflow.com/users/14599596", "pm_score": 1, "selected": false, "text": "JSON.stringify(data)" }, { "answer_id": 74458757, "author": "Kartoos", "author_id": 7801965, "author_profile": "https://Stackoverflow.com/users/7801965", "pm_score": 0, "selected": false, "text": "\"[object Object]\"" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14534481/" ]
74,458,143
<p>This will probably be a very simple question for anyone who knows the world of VBA, but I am a complete beginner and I have been dealing with the following (albeit trivial) problem for several days and I am unable to solve it</p> <p>I'm drawing a data set from another excel so I never know how big the resulting table will be. I need to sum the values in the columns into a row and dynamically expand the formula for the sum in the row to the last filled column. I am able to find the yellow field, but I have no idea how use VBA to dynamicly populate the formula into the red fields.</p> <p>I know my attempt to autofill below is not and will not work, but I couldn't think of anything else.</p> <p>Thanks for any tips</p> <pre class="lang-vb prettyprint-override"><code>Sub IN7() lr = Cells.Find(&quot;*&quot;, Cells(1, 1), xlFormulas, xlPart, xlByRows, xlPrevious, False).Row lc = Cells.Find(&quot;*&quot;, Cells(1, 1), xlFormulas, xlPart, xlByColumns, xlPrevious, False).Column Range(&quot;B&quot; &amp; (lr + 2)).Value = &quot;=sum(B2:B&quot; &amp; lr &amp; &quot;)&quot; Range(&quot;B&quot; &amp; (lr + 2)&quot;).AutoFill Range(&quot;B&quot; &amp; (lr + 2)&quot; &amp; lc) End Sub </code></pre> <p><img src="https://i.stack.imgur.com/MgGLK.png" alt="Example" /></p>
[ { "answer_id": 74458729, "author": "Edoardo", "author_id": 20518389, "author_profile": "https://Stackoverflow.com/users/20518389", "pm_score": 0, "selected": false, "text": "Sub SumAllColumns()\n\n Dim a As Integer\n\n Range(\"B7\").Select\n ActiveCell.FormulaR1C1 = \"=+SUM(R[-5]C:R[-2]C)\"\n Range(\"B7\").Select\n\n a = Sheet1.UsedRange.Columns.Count\n\n Selection.AutoFill Destination:=Selection.Resize(1, a - 1)\n\nEnd Sub\n" }, { "answer_id": 74458792, "author": "MikeWasos", "author_id": 19894419, "author_profile": "https://Stackoverflow.com/users/19894419", "pm_score": 0, "selected": false, "text": "lr = Cells(Rows.Count, 1).End(xlUp).Row 'goes to the last row and then goes up to the last row with any value\nlc = Cells(1, Columns.Count).End(xltoLeft).Column 'goes to the last column and then goes left to the last column with any value\n" }, { "answer_id": 74458841, "author": "VBasic2008", "author_id": 9814069, "author_profile": "https://Stackoverflow.com/users/9814069", "pm_score": 1, "selected": false, "text": "Option Explicit\n\nSub AddTotals()\n\n ' Reference the worksheet.\n Dim ws As Worksheet: Set ws = ActiveSheet ' improve!\n \n ' Calculate the last row and column.\n Dim lr As Long\n lr = ws.Cells.Find(\"*\", ws.Cells(1), xlFormulas, xlPart, xlByRows, xlPrevious, False).Row\n Dim lc As Long\n lc = ws.Cells.Find(\"*\", ws.Cells(1), xlFormulas, xlPart, xlByColumns, xlPrevious, False).Column\n \n ' Reference the first column range.\n Dim fcrg As Range: Set fcrg = ws.Range(\"B2\", ws.Cells(lr, \"B\"))\n ' Write the address of the first column range to a string variable.\n ' Lock the rows with '(, 0)' so the formula will work for all columns.\n Dim fcrgAddress As String: fcrgAddress = fcrg.Address(, 0)\n\n ' Reference the first sum cell.\n Dim cell As Range: Set cell = ws.Cells(lr + 2, \"B\")\n ' Calculate the number of columns.\n Dim cCount As Long: cCount = lc - cell.Column + 1\n ' Reference the sum row range.\n Dim srrg As Range: Set srrg = cell.Resize(, cCount)\n \n ' Write the formula to the sum row range.\n srrg.Formula = \"=SUM(\" & fcrgAddress & \")\"\n\nEnd Sub\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20517974/" ]
74,458,165
<p>I have a data frame in R (R Shiny) that I want to sort based on a column that contains a mix of pure numerical (1, 3, 4, ...) values as well as 'numerical-string' (2a, 2b1, 2b2, 2c, ...) values.</p> <p>The data frame I have is:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Column A</th> <th>Column B</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Value 1</td> </tr> <tr> <td>3</td> <td>Value 3</td> </tr> <tr> <td>2a</td> <td>Value 2a</td> </tr> <tr> <td>4</td> <td>Value 4</td> </tr> <tr> <td>2b1</td> <td>Value 2b1</td> </tr> <tr> <td>2c</td> <td>Value 2c</td> </tr> <tr> <td>2b2</td> <td>Value 2b2</td> </tr> </tbody> </table> </div> <p>I want this sorted like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Column A</th> <th>Column B</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Value 1</td> </tr> <tr> <td>2a</td> <td>Value 2a</td> </tr> <tr> <td>2b1</td> <td>Value 2b1</td> </tr> <tr> <td>2b2</td> <td>Value 2b2</td> </tr> <tr> <td>2c</td> <td>Value 2c</td> </tr> <tr> <td>3</td> <td>Value 3</td> </tr> <tr> <td>4</td> <td>Value 4</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74458729, "author": "Edoardo", "author_id": 20518389, "author_profile": "https://Stackoverflow.com/users/20518389", "pm_score": 0, "selected": false, "text": "Sub SumAllColumns()\n\n Dim a As Integer\n\n Range(\"B7\").Select\n ActiveCell.FormulaR1C1 = \"=+SUM(R[-5]C:R[-2]C)\"\n Range(\"B7\").Select\n\n a = Sheet1.UsedRange.Columns.Count\n\n Selection.AutoFill Destination:=Selection.Resize(1, a - 1)\n\nEnd Sub\n" }, { "answer_id": 74458792, "author": "MikeWasos", "author_id": 19894419, "author_profile": "https://Stackoverflow.com/users/19894419", "pm_score": 0, "selected": false, "text": "lr = Cells(Rows.Count, 1).End(xlUp).Row 'goes to the last row and then goes up to the last row with any value\nlc = Cells(1, Columns.Count).End(xltoLeft).Column 'goes to the last column and then goes left to the last column with any value\n" }, { "answer_id": 74458841, "author": "VBasic2008", "author_id": 9814069, "author_profile": "https://Stackoverflow.com/users/9814069", "pm_score": 1, "selected": false, "text": "Option Explicit\n\nSub AddTotals()\n\n ' Reference the worksheet.\n Dim ws As Worksheet: Set ws = ActiveSheet ' improve!\n \n ' Calculate the last row and column.\n Dim lr As Long\n lr = ws.Cells.Find(\"*\", ws.Cells(1), xlFormulas, xlPart, xlByRows, xlPrevious, False).Row\n Dim lc As Long\n lc = ws.Cells.Find(\"*\", ws.Cells(1), xlFormulas, xlPart, xlByColumns, xlPrevious, False).Column\n \n ' Reference the first column range.\n Dim fcrg As Range: Set fcrg = ws.Range(\"B2\", ws.Cells(lr, \"B\"))\n ' Write the address of the first column range to a string variable.\n ' Lock the rows with '(, 0)' so the formula will work for all columns.\n Dim fcrgAddress As String: fcrgAddress = fcrg.Address(, 0)\n\n ' Reference the first sum cell.\n Dim cell As Range: Set cell = ws.Cells(lr + 2, \"B\")\n ' Calculate the number of columns.\n Dim cCount As Long: cCount = lc - cell.Column + 1\n ' Reference the sum row range.\n Dim srrg As Range: Set srrg = cell.Resize(, cCount)\n \n ' Write the formula to the sum row range.\n srrg.Formula = \"=SUM(\" & fcrgAddress & \")\"\n\nEnd Sub\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20518406/" ]
74,458,195
<p>I'm trying to fetch 'all posts' using Redux. I should be getting an empty array but instead, I'm getting undefined. Here's my reducer:</p> <pre><code>export default (posts = [], action) =&gt; { switch ((action.type)) { case &quot;FETCH_ALL&quot;: return action.payload; case &quot;CREATE&quot;: return posts; default: return posts; } }; </code></pre> <p>Action</p> <pre><code> export const getPosts = () =&gt; async (dispatch) =&gt; { try { const { data } = await api.fetchPosts(); dispatch({ type: &quot;FETCH_ALL&quot;, payload: data }); } catch (error) { console.log(error.message) } }; </code></pre> <p>Posts.js component</p> <pre><code>import { useSelector } from &quot;react-redux&quot;; import Post from &quot;./Post/Post&quot;; import useStyles from &quot;./styles&quot;; const Posts = () =&gt; { const posts = useSelector((state)=&gt;state.posts) console.log(posts) const classes = useStyles(); return ( &lt;&gt; &lt;h1&gt;Posts&lt;/h1&gt; &lt;Post /&gt; &lt;/&gt; ); }; export default Posts; </code></pre>
[ { "answer_id": 74458278, "author": "Arrow", "author_id": 13953455, "author_profile": "https://Stackoverflow.com/users/13953455", "pm_score": 0, "selected": false, "text": "export default (posts = [], action) => {\n switch ((action.type)) {\n case \"FETCH_ALL\":\n return {posts: action.payload};\n case \"CREATE\":\n return posts;\n\n default:\n return posts;\n }\n}; \n" }, { "answer_id": 74458404, "author": "Siva Nagendra Kumar Vepada", "author_id": 5589427, "author_profile": "https://Stackoverflow.com/users/5589427", "pm_score": 3, "selected": true, "text": " const posts = useSelector((state)=>state);\n" }, { "answer_id": 74458439, "author": "Ken Ha", "author_id": 8647785, "author_profile": "https://Stackoverflow.com/users/8647785", "pm_score": 0, "selected": false, "text": "switch ((action.type))" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16604189/" ]
74,458,246
<p>I am using Cassandra database as final storage and mongodb as temporary storage of the application.The Working Flow of this database is that data will be stored in mongodb for only 3 days and data will be stored in cassandra after one day of data stored in mongodb. In this application I used upsert operation as possible and also avoided read first then write strategy because of considering maximum performance availability of databases. This application handles more than 400 000 data in short time intervals. So performance and availability of databases should be considered.</p> <p>Let me describe the structure of data going to store, it is a messaging application so the status of messages coming lately through some webhooks and this status and message should be stored in a single table.The intention behind storing in a single table is nothing only considering speed of data accessing. Note that some time the status will come after deleting it’s message from mongodb (after 3 days) and understand that there is no indication to identify it is a status of new message or old message (deleted one). Cassandra database “created_datetime” is used as a clustering key and this clustering key is only available with messages not with its status , that’s why using two databases in this application.There are three statuses for a message.</p> <p>I listed below what are the activities performing the application based on this data management. The message details upsert into collection in mongodb. The status will be upserted into the same collection in mongodb. It will happen after some time. Maybe it will take longer than three days for some messages. Data copied into cassandra database after one day - (Using upsert operation). The status coming in late (after one day) should be updated in the cassandra database also. The status coming after three days should be updated in the cassandra database also. To update these status in the Cassandra database , I would want to read the message details from the Cassandra database first and then update them by collecting the clustering key. Note that read first then write strategy avoids maximum as described earlier , but here no other solution i could find and also this kind of status (late about three days) will be less considering other status.And delete these status from mongodb after completing the updation to cassandra database. Delete all messages from the mongodb which were created three days ago.</p> <p><strong>In short</strong> Table Schema</p> <p>Message_id | Sent_dt | Status | Status_dt Message_id | Sent _dt - Available on sending Message to provider</p> <p>Message_id | Status | Status_dt - Available on receiving Status from provider</p> <p>In Cassandra Sent_dt is the clustering key and is mandatory for updating a record.</p> <p>Introduced intermediate MongoDB as follows:</p> <p>Message stored and updated with Status on MongoDB Live reporting done from MongoDB to UI Records are copied from MongoDB to Cassandra on Sent_dt+24 hours Records on MongoDB are deleted on Sent_dt+72 hours. How to handle “Status” updates for Records with:</p> <p>Sent_dt between 24 and 72 hours? (Already copied to Cassandra) Sent_dt more than 72 hours? (Already deleted from MongoDB) Is there any alternative design for the scenario? I am consuming data from Kafka only.</p> <ul> <li>Alternative solution for this database management.</li> <li>Any suggestions for improvement.</li> </ul>
[ { "answer_id": 74475726, "author": "Madhavan", "author_id": 10410162, "author_profile": "https://Stackoverflow.com/users/10410162", "pm_score": 1, "selected": false, "text": "CREATE TABLE IF NOT EXISTS keyspace_name.table_name (\n partition_key1 cql_data_type,\n ...\n created_date cql_data_type,\n status text,\n ...\n PRIMARY KEY((partition_keys), created_date)\n) WITH CLUSTERING ORDER BY (created_date ASC|DESC)\n AND default_time_to_live = <desired_days_in_seconds>;\n" }, { "answer_id": 74580515, "author": "Madhavan", "author_id": 10410162, "author_profile": "https://Stackoverflow.com/users/10410162", "pm_score": 0, "selected": false, "text": "token@cqlsh:ks1> create table db_mgmt(msg_id text,status text,status_dt date,sent_dt date,primary key (msg_id ));\n\ntoken@cqlsh:ks1> insert into db_mgmt(msg_id,sent_dt,status,status_dt) values ('unique_id','2022-11-27','INIT','2022-11-27');\n\ntoken@cqlsh:ks1> select * from db_mgmt ;\n\n msg_id | sent_dt | status | status_dt\n-----------+------------+--------+------------\n unique_id | 2022-11-27 | INIT | 2022-11-27\n\n(1 rows)\n\ntoken@cqlsh:ks1> update db_mgmt SET status = 'IN PROGRESS', status_dt = '2022-11-28' WHERE msg_id = 'unique_id';\n\ntoken@cqlsh:ks1> select * from db_mgmt ;\n\n msg_id | sent_dt | status | status_dt\n-----------+------------+-------------+------------\n unique_id | 2022-11-27 | IN PROGRESS | 2022-11-28\n\n(1 rows)\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20149599/" ]
74,458,247
<p>I'm new to Vue 3 (cli) and I'm not at all comfortable with front-end technology, so I'm having a hard time understanding the information I'm reading.</p> <p>I succeeded in creating a registration/login interface with an api and JWT. The user information needs to be persisted everywhere in the project I'm doing to train myself, so I configured axios in my store.</p> <pre><code>store/index.js import { createStore } from 'vuex' import axios from 'axios'; const api = axios.create({ baseURL: 'http://127.0.0.1:7000' }); let user = localStorage.getItem('user'); if(null === user) { user = {uuid: '', token: ''}; } else { try { user = JSON.parse(user); api.defaults.headers.common['Authorization'] = 'Bearer ' + user.token; } catch (e) { user = {uuid: '', token: ''}; } } export default createStore({ state: { status: '', user: user, userInfos: {}, }, mutations: { [...] }, getters: { }, actions: { [...] }, modules: { } }) </code></pre> <p>I would like to be able to use api from my components. I have had several approaches:</p> <p>1 - I have imported axios into my component, but this is not correct at all, as I will need axios in all my components.</p> <p>2 - I've looked at different documentations that explain how to configure axios globally, but no two are the same and I couldn't get anything to work.</p> <p>3 - I've tried calling api through strangenesses like this.$store.api in my methods, but obviously this is abused.</p> <p>Can anyone help me understand what is the right way to use axios from my components and from the store with only one configuration? Knowing that I need to be able to keep my headers up to date for authentication with the Bearer Token (a mutation updates it in the store at user login).</p> <pre><code>main.js import { createApp } from 'vue' import App from './App.vue' import router from './router' import store from './store' import 'bootstrap/dist/css/bootstrap.css' import 'bootstrap/dist/js/bootstrap.js' import { library } from '@fortawesome/fontawesome-svg-core' import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' import { faMedal } from '@fortawesome/free-solid-svg-icons' import { faLaptopMedical } from '@fortawesome/free-solid-svg-icons' import { faCookieBite } from '@fortawesome/free-solid-svg-icons' import { faCoins } from '@fortawesome/free-solid-svg-icons' import { faHourglassStart } from '@fortawesome/free-solid-svg-icons' import { faUpRightFromSquare } from '@fortawesome/free-solid-svg-icons' import { faInfo } from '@fortawesome/free-solid-svg-icons' import { faGears } from '@fortawesome/free-solid-svg-icons' library.add( faMedal, faCoins, faLaptopMedical, faCookieBite, faHourglassStart, faUpRightFromSquare, faInfo, faGears ); createApp(App) .component('font-awesome-icon', FontAwesomeIcon) .use(store) .use(router) .mount('#app') </code></pre> <p>Thank you very much for your help.</p>
[ { "answer_id": 74475726, "author": "Madhavan", "author_id": 10410162, "author_profile": "https://Stackoverflow.com/users/10410162", "pm_score": 1, "selected": false, "text": "CREATE TABLE IF NOT EXISTS keyspace_name.table_name (\n partition_key1 cql_data_type,\n ...\n created_date cql_data_type,\n status text,\n ...\n PRIMARY KEY((partition_keys), created_date)\n) WITH CLUSTERING ORDER BY (created_date ASC|DESC)\n AND default_time_to_live = <desired_days_in_seconds>;\n" }, { "answer_id": 74580515, "author": "Madhavan", "author_id": 10410162, "author_profile": "https://Stackoverflow.com/users/10410162", "pm_score": 0, "selected": false, "text": "token@cqlsh:ks1> create table db_mgmt(msg_id text,status text,status_dt date,sent_dt date,primary key (msg_id ));\n\ntoken@cqlsh:ks1> insert into db_mgmt(msg_id,sent_dt,status,status_dt) values ('unique_id','2022-11-27','INIT','2022-11-27');\n\ntoken@cqlsh:ks1> select * from db_mgmt ;\n\n msg_id | sent_dt | status | status_dt\n-----------+------------+--------+------------\n unique_id | 2022-11-27 | INIT | 2022-11-27\n\n(1 rows)\n\ntoken@cqlsh:ks1> update db_mgmt SET status = 'IN PROGRESS', status_dt = '2022-11-28' WHERE msg_id = 'unique_id';\n\ntoken@cqlsh:ks1> select * from db_mgmt ;\n\n msg_id | sent_dt | status | status_dt\n-----------+------------+-------------+------------\n unique_id | 2022-11-27 | IN PROGRESS | 2022-11-28\n\n(1 rows)\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8631623/" ]
74,458,282
<p>Say I have two flat lists of strings:</p> <pre><code>a = [&quot;today&quot;, &quot;I&quot;, &quot;want&quot;, &quot;to&quot;, &quot;eat&quot;, &quot;some&quot;, &quot;cake.&quot;] b = [&quot;to&quot;, &quot;da&quot;, &quot;y&quot;, &quot;I&quot;, &quot;wa&quot;, &quot;nt&quot;, &quot;to&quot;, &quot;ea&quot;, &quot;t&quot;, &quot;some&quot;, &quot;ca&quot;, &quot;ke&quot;, &quot;.&quot;] </code></pre> <p>Where in list <code>b</code> some strings (not all) of list <code>a</code> are split into multiple substrings. Note that the substrings in <code>b</code> that correspond to the strings in <code>a</code> are adjacent and in the same order, as in the example above.</p> <p>I want to obtain a list <code>c</code> where the substrings in <code>b</code> that correspond to a single string in <code>a</code> are put together in a sublist:</p> <pre><code>c = [[&quot;to&quot;, &quot;da&quot;, &quot;y&quot;], [&quot;I&quot;], [&quot;wa&quot;, &quot;nt&quot;], [&quot;to&quot;], [&quot;ea&quot;, &quot;t&quot;], [&quot;some&quot;], [&quot;ca&quot;, &quot;ke&quot;, &quot;.&quot;]] </code></pre> <p>Unfortunately I don't have any code to share since I don't know how to approach this problem.</p> <p>Thanks!</p>
[ { "answer_id": 74458649, "author": "Ben. S.", "author_id": 12261629, "author_profile": "https://Stackoverflow.com/users/12261629", "pm_score": 3, "selected": true, "text": "a = [\"today\", \"I\", \"want\", \"to\", \"eat\", \"some\", \"cake.\"]\nb = [\"to\", \"da\", \"y\", \"I\", \"wa\", \"nt\", \"to\", \"ea\", \"t\", \"some\", \"ca\", \"ke\", \".\"]\nc = []\n\nfor element in a:\n temp_list = []\n while \"\".join(temp_list) != element:\n temp_list.append(b.pop(0))\n c.append(temp_list)\n" }, { "answer_id": 74462494, "author": "blhsing", "author_id": 6890912, "author_profile": "https://Stackoverflow.com/users/6890912", "pm_score": 0, "selected": false, "text": "b" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12607108/" ]
74,458,303
<ol> <li>Ask for the size of an array;</li> <li>Create a one-dimensional array;</li> <li>Fill arrays with a random number between -6 and 6;</li> <li>Calculate and display the average value of all numbers in an array;</li> <li>Find and display the largest number from an array.</li> </ol> <p>I'm new to C and can't solve the task. If it's possible can you guys help or give some hints</p> <pre><code>#include &lt;stdio.h&gt; int main() { int size=0; int arr[size]; printf(&quot;input size of array &quot;); scanf(&quot;%d&quot;,&amp;size); printf(&quot;\none - dimensional of array: &quot;); for(int i=0;i&lt;size;i++){ scanf(&quot;%d&quot;,&amp;arr[i]); } printf(&quot;\nThe array is &quot;); for(int i=0;i&lt;size;i++){ printf(&quot;%d&quot;,arr[i]); } return 0; } </code></pre>
[ { "answer_id": 74458598, "author": "Károly Szabó", "author_id": 6804632, "author_profile": "https://Stackoverflow.com/users/6804632", "pm_score": -1, "selected": false, "text": "int size=0; \nprintf(\"input size of array \"); \nscanf(\"%d\",&size);\nint arr[size];\n" }, { "answer_id": 74458739, "author": "Dancchi", "author_id": 18064255, "author_profile": "https://Stackoverflow.com/users/18064255", "pm_score": 2, "selected": true, "text": "#include <stdio.h> \nint main() \n{ \n int max = INT_MIN; //variable to get the maximum number in the array\n int avg = 0, sum = 0;\n int size=0; \n\n //Ask for size of the Array before initializing\n //Use do-while loop to ensure that the number entered is valid\n printf(\"input size of array \"); \n do{\n scanf(\"%d\", &size);\n }while(size < 0); \n\n //Create the Array\n int arr[size];\n\n printf(\"\\none - dimensional of array: \"); \n\n //Use rand(), to get a random number between 0 and INT_MAX\n //Then modulo the value of the random int by 13 to scale the value between [0, 12]\n //subtract by 6 to get a range of [-6,6]\n for(int i=0;i<size;i++){ \n int random = rand();\n random = random % 13;\n random = random - 6;\n arr[i] = random; \n } \n\n printf(\"\\nThe array is \"); \n for(int i=0;i<size;i++){ \n printf(\"%d\",arr[i]); \n } \n\n //Get average of all elements, and the element with the maximum value\n for(int i=0;i<size;i++){ \n if(max < arr[i])\n max = arr[i];\n ums += arr[i]; \n } \n avg = sum/size;\n\n printf(\"\\nAverage: %d\", avg);\n printf(\"\\nMaximum: %d\", max);\n return 0; \n}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19444133/" ]
74,458,360
<p>I'm writing my first Django app - blog. When creating Post model I'm asked to create publish and created fields with timezone import.</p> <pre><code>publish = models.DateTimeField(default=timezone.now) created = models.DateTimeField(auto_now_add=True) </code></pre> <p>It's explained that &quot;By using auto_now_add, the date will be saved automatically when creating an object&quot; and &quot;timezone.now returns the current datetime in a timezone-aware format&quot;.</p> <p>So it seems to me that they both same job. Why not use default=timezone.now in both fields? What's the difference? It's my first question so sorry in advance if I made some mistakes.</p>
[ { "answer_id": 74458598, "author": "Károly Szabó", "author_id": 6804632, "author_profile": "https://Stackoverflow.com/users/6804632", "pm_score": -1, "selected": false, "text": "int size=0; \nprintf(\"input size of array \"); \nscanf(\"%d\",&size);\nint arr[size];\n" }, { "answer_id": 74458739, "author": "Dancchi", "author_id": 18064255, "author_profile": "https://Stackoverflow.com/users/18064255", "pm_score": 2, "selected": true, "text": "#include <stdio.h> \nint main() \n{ \n int max = INT_MIN; //variable to get the maximum number in the array\n int avg = 0, sum = 0;\n int size=0; \n\n //Ask for size of the Array before initializing\n //Use do-while loop to ensure that the number entered is valid\n printf(\"input size of array \"); \n do{\n scanf(\"%d\", &size);\n }while(size < 0); \n\n //Create the Array\n int arr[size];\n\n printf(\"\\none - dimensional of array: \"); \n\n //Use rand(), to get a random number between 0 and INT_MAX\n //Then modulo the value of the random int by 13 to scale the value between [0, 12]\n //subtract by 6 to get a range of [-6,6]\n for(int i=0;i<size;i++){ \n int random = rand();\n random = random % 13;\n random = random - 6;\n arr[i] = random; \n } \n\n printf(\"\\nThe array is \"); \n for(int i=0;i<size;i++){ \n printf(\"%d\",arr[i]); \n } \n\n //Get average of all elements, and the element with the maximum value\n for(int i=0;i<size;i++){ \n if(max < arr[i])\n max = arr[i];\n ums += arr[i]; \n } \n avg = sum/size;\n\n printf(\"\\nAverage: %d\", avg);\n printf(\"\\nMaximum: %d\", max);\n return 0; \n}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11939828/" ]
74,458,377
<p>I'm on creating a mobile app with flutter. At first, I have to connect to bluetooth. after connecting to a specific device I have to redirect to the next page which is the home page. This screen doesn't show any information for the device but I have to recieve data via bluetooth in this screen. I do something like this :</p> <pre><code> if (snapshot.data == BluetoothDeviceState.connected) { WidgetsBinding.instance.addPostFrameCallback( (_) { Navigator.of(context).push(MaterialPageRoute( builder: (context) =&gt; MainScreen())); BluetoothServiceList(device: d); BluetoothDeviceStateHandler( device: d, ); }, ); return ElevatedButton( child: const Text('CONNECTED'), onPressed: () { Navigator.of(context).push(MaterialPageRoute( builder: (context) =&gt; MainScreen())); BluetoothServiceList(device: d); BluetoothDeviceStateHandler( device: d, ); }); } </code></pre> <p>the two functions <code> BluetoothServiceList</code> and <code>BluetoothDeviceStateHandler</code> existed in another screen but I shouldn't show this screen anymore.</p> <p>all the functions should be executed in this class without showing anything. I want just to display alerts while recieving data from the other device.</p> <pre><code>class MainScreen extends StatelessWidget { const MainScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: Scaffold( body: new Stack( children: &lt;Widget&gt;[ new Container( decoration: new BoxDecoration( image: new DecorationImage( image: new AssetImage(&quot;assets/Fond.png&quot;), fit: BoxFit.cover, ), ), ), Align( alignment: Alignment.bottomLeft, child: FloatingActionButton( onPressed: () {}, child: Image.asset('assets/Alerte notif.png'), elevation: 30, ), ), Align( alignment: Alignment.bottomRight, child: FloatingActionButton( onPressed: () {}, child: Image.asset('assets/Panneau distance rouge.png'), elevation: 15, ), ), Align( alignment: Alignment.bottomCenter, child: TextButton( onPressed: () {}, child: (Image.asset( 'assets/camion2.png', height: 200, width: 500, )), ), ), ], )), ); } } </code></pre> <p>Anyone here can help me please ? I want to know if my logic is right and iof there are solutions for what I'm thinking about.</p>
[ { "answer_id": 74458598, "author": "Károly Szabó", "author_id": 6804632, "author_profile": "https://Stackoverflow.com/users/6804632", "pm_score": -1, "selected": false, "text": "int size=0; \nprintf(\"input size of array \"); \nscanf(\"%d\",&size);\nint arr[size];\n" }, { "answer_id": 74458739, "author": "Dancchi", "author_id": 18064255, "author_profile": "https://Stackoverflow.com/users/18064255", "pm_score": 2, "selected": true, "text": "#include <stdio.h> \nint main() \n{ \n int max = INT_MIN; //variable to get the maximum number in the array\n int avg = 0, sum = 0;\n int size=0; \n\n //Ask for size of the Array before initializing\n //Use do-while loop to ensure that the number entered is valid\n printf(\"input size of array \"); \n do{\n scanf(\"%d\", &size);\n }while(size < 0); \n\n //Create the Array\n int arr[size];\n\n printf(\"\\none - dimensional of array: \"); \n\n //Use rand(), to get a random number between 0 and INT_MAX\n //Then modulo the value of the random int by 13 to scale the value between [0, 12]\n //subtract by 6 to get a range of [-6,6]\n for(int i=0;i<size;i++){ \n int random = rand();\n random = random % 13;\n random = random - 6;\n arr[i] = random; \n } \n\n printf(\"\\nThe array is \"); \n for(int i=0;i<size;i++){ \n printf(\"%d\",arr[i]); \n } \n\n //Get average of all elements, and the element with the maximum value\n for(int i=0;i<size;i++){ \n if(max < arr[i])\n max = arr[i];\n ums += arr[i]; \n } \n avg = sum/size;\n\n printf(\"\\nAverage: %d\", avg);\n printf(\"\\nMaximum: %d\", max);\n return 0; \n}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20285309/" ]
74,458,405
<p>I made this script that let me change the letter on hover of the specific letter.</p> <p>I would like to be able to hover a letter, change it to <code>A</code> and as soon as the <code>mouseleave</code> event is called, the letter change back to the original letter.</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 toLetterize = document.querySelectorAll( ".change p" ); console.log(toLetterize); toLetterize.forEach(function (letterized) { const letters = letterized.innerHTML; var nHTML = ""; for (var letter of letters) { nHTML += "&lt;u&gt;" + letter + "&lt;/u&gt;"; } letterized.innerHTML = nHTML; document.querySelectorAll("u").forEach(function (hoveredLetter) { hoveredLetter.addEventListener("mouseenter", function (e) { console.log("hovered") hoveredLetter.innerHTML = nextLetter(hoveredLetter.innerText); }); hoveredLetter.addEventListener("mouseleave", function (e) { console.log("leaving" + nextLetter(hoveredLetter.innerText)) hoveredLetter.innerHTML = nextLetter(hoveredLetter.innerText); }); }); }); function nextLetter(ch) { console.log(ch); if (!ch.match(/[a-z]/i)) { return "A"; } else if (ch === "A") { return ch; } return String.fromCharCode(ch); }</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>div{ font-family: monospace; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="change"&gt; &lt;p&gt; The colours of the binding (chosen by me) will be white letters on a blue field – the Greek flag though really of Bavarian origin and imported with the dynasty. Yet in a special way they symbolise the myth well – the white islands scattered over the sea.&lt;/p&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74458663, "author": "Diego D", "author_id": 1221208, "author_profile": "https://Stackoverflow.com/users/1221208", "pm_score": 3, "selected": true, "text": "e.target" }, { "answer_id": 74461157, "author": "Yogi", "author_id": 943435, "author_profile": "https://Stackoverflow.com/users/943435", "pm_score": 2, "selected": false, "text": ".change p span::before {\n content: attr(data-char);\n}\n.change p span:hover::before {\n content: \"A\";\n}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9011747/" ]
74,458,421
<p>I am trying to get all the committed files on an Azure Build Pipeline. This is the yaml script I'm using:</p> <pre><code>trigger: branches: include: - swagger_dev paths: include: - swagger_dev/swaggers/*.yaml variables: CLIENT_CREDENTIALS: $(ClientCredentials) steps: - powershell: | echo &quot;$(Build.SourceVersion)&quot; echo &quot;$(git diff-tree --no-commit-id --diff-filter=d --name-only -r $(Build.SourceVersion))&quot; </code></pre> <p>When I commit one or more files, the Pipeline correctly echoes the Build.SourceVersion but then echoes an empty output for the git command: <a href="https://i.stack.imgur.com/1kDIP.png" rel="nofollow noreferrer">pipeline log</a></p> <p>How is that possible? I am currently on a branch called swagger_dev and the committed files are in the directory swagger_dev/swaggers. Maybe I should add those informations to the diff-tree command?</p>
[ { "answer_id": 74458663, "author": "Diego D", "author_id": 1221208, "author_profile": "https://Stackoverflow.com/users/1221208", "pm_score": 3, "selected": true, "text": "e.target" }, { "answer_id": 74461157, "author": "Yogi", "author_id": 943435, "author_profile": "https://Stackoverflow.com/users/943435", "pm_score": 2, "selected": false, "text": ".change p span::before {\n content: attr(data-char);\n}\n.change p span:hover::before {\n content: \"A\";\n}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19949216/" ]
74,458,452
<p>In a viewModel, it may be desirable to have a <code>String</code> property that equals a user-defined value, or a localisable string resource if this user-defined value is null or empty. For example, in an application about pets, a user could name their dog <code>&quot;Pepper&quot;</code>. But, if no name has been provided, then it is feasible to default to a localisable string, <code>&quot;Dog&quot;</code> via a resource - <code>R.strings.dog_title</code>.</p> <p>The issue is that the string resource, <code>R.strings.dog_title</code>, is of type <code>Int</code>, whereas the user-defined name is of type <code>String</code>, and a <code>Text</code> composable only takes <code>String</code> or <code>AnnotatedString</code> as a parameter.</p> <p>This leads to an awkward choice between missing out on testability by placing logic in the view, or injecting the application context into the viewModel to get the string value from the string resource - both of which I'm wanting to avoid.</p> <p>My current approach involves passing both values via the <code>uiState</code>, and then checking the name, before defaulting to the string resource:</p> <pre class="lang-kotlin prettyprint-override"><code>// UISTATE data class ViewUiState ( val string: String? = null, @StringRes val stringRes: Int, ) // VIEWMODEL val uiState = mutableStateOf(ViewUiState(stringRes = 0)) private set // In the ViewModel, we might get the type of pet currently being shown (e.g. 'Dog') ... uiState.value = uiState.copy(stringRes = R.string.dog_title) ... // COMPOSE SCREEN val uiState by viewModel.uiState if (!uiState.string.isNullOrEmpty()) { Text(uiState.string) } else { Text(stringResource(uiState.stringResId)) } </code></pre> <p>The only issue with this approach is that I now miss out on unit testing the null check, as the logic no longer lives in the viewModel.</p> <p>To keep the logic in the viewModel, it is possible to inject the context and then get the string value using <code>getString(R.strings.dog_title)</code>. However, its always felt better practice to avoid injecting the context wherever possible.</p>
[ { "answer_id": 74460937, "author": "Mobin Yardim", "author_id": 8810290, "author_profile": "https://Stackoverflow.com/users/8810290", "pm_score": 3, "selected": true, "text": "sealed class ViewUiState() {\n class Default(val stringResId: Int) : ViewUiState()\n class UserValue(val string: String) : ViewUiState()\n}\n" }, { "answer_id": 74464985, "author": "Vahid Garousi", "author_id": 5909910, "author_profile": "https://Stackoverflow.com/users/5909910", "pm_score": 1, "selected": false, "text": "\nsealed class UiText {\n data class DynamicString(val value: String) : UiText()\n class StringResource(\n @StringRes val resId: Int,\n vararg val args: Any\n ) : UiText()\n\n @Composable\n fun asString(): String {\n return when (this) {\n is DynamicString -> value\n is StringResource -> stringResource(resId, *args)\n }\n }\n\n fun asString(context: Context): String {\n return when (this) {\n is DynamicString -> value\n is StringResource -> context.getString(resId, *args)\n }\n }\n\n companion object {\n fun unknownError(): UiText {\n return StringResource(R.string.error_unknown)\n }\n }\n}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12333099/" ]
74,458,469
<p>Search View shows blank after entering a space.</p> <p>Duplicate question - <a href="https://stackoverflow.com/questions/44535177/">click</a> , but using recycler view doesn't suit me. Are there other options.</p> <p>I will be very glad if you help!</p> <p>I am filtering now:</p> <pre><code>mySearchView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { adapter.getFilter().filter(s); } }); </code></pre>
[ { "answer_id": 74460937, "author": "Mobin Yardim", "author_id": 8810290, "author_profile": "https://Stackoverflow.com/users/8810290", "pm_score": 3, "selected": true, "text": "sealed class ViewUiState() {\n class Default(val stringResId: Int) : ViewUiState()\n class UserValue(val string: String) : ViewUiState()\n}\n" }, { "answer_id": 74464985, "author": "Vahid Garousi", "author_id": 5909910, "author_profile": "https://Stackoverflow.com/users/5909910", "pm_score": 1, "selected": false, "text": "\nsealed class UiText {\n data class DynamicString(val value: String) : UiText()\n class StringResource(\n @StringRes val resId: Int,\n vararg val args: Any\n ) : UiText()\n\n @Composable\n fun asString(): String {\n return when (this) {\n is DynamicString -> value\n is StringResource -> stringResource(resId, *args)\n }\n }\n\n fun asString(context: Context): String {\n return when (this) {\n is DynamicString -> value\n is StringResource -> context.getString(resId, *args)\n }\n }\n\n companion object {\n fun unknownError(): UiText {\n return StringResource(R.string.error_unknown)\n }\n }\n}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19652986/" ]
74,458,474
<p>I am displaying treeview. tree nodes are showing with icons plus and minus. These icons are showing above the text? how to align node icon and node text in the same line? please find my sandbox: <a href="https://codesandbox.io/s/shy-snow-nfce4i" rel="nofollow noreferrer">https://codesandbox.io/s/shy-snow-nfce4i</a></p> <p>thanks</p>
[ { "answer_id": 74458793, "author": "Dmitriy Zhiganov", "author_id": 13730174, "author_profile": "https://Stackoverflow.com/users/13730174", "pm_score": 0, "selected": false, "text": "before" }, { "answer_id": 74458870, "author": "Moldovan Andrei", "author_id": 6814509, "author_profile": "https://Stackoverflow.com/users/6814509", "pm_score": 1, "selected": false, "text": " const StyledLI = styled.li`\n list-style-type: none;\n `;\n" }, { "answer_id": 74459008, "author": "George Chond", "author_id": 17730652, "author_profile": "https://Stackoverflow.com/users/17730652", "pm_score": 3, "selected": true, "text": "::marker" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17037420/" ]
74,458,608
<p>I have a dataframe <code>df</code> of the following format:</p> <pre><code> team1 team2 score1 score2 0 1 2 1 0 1 3 4 3 0 2 1 3 1 1 3 2 4 0 2 4 1 2 3 2 </code></pre> <p>What I want to do is to create a <code>new</code> column that will return rolling average of the <code>score1</code> column of last 3 games but only when the two teams from <code>team1</code> and <code>team2</code> are matching.</p> <p>Expected output:</p> <pre><code> team1 team2 score1 score2 new 0 1 2 1 0 1 1 3 4 3 0 3 2 1 3 1 1 1 3 2 4 0 2 0 4 1 2 3 2 2 </code></pre> <p>I was able to calculate walking average for all games for each team separately like that:</p> <pre><code>df['new'] = df.groupby('team1')['score1'].transform(lambda x: x.rolling(3, min_periods=1).mean() </code></pre> <p>but cannot find a sensible way to expand that to match two teams.</p> <p>I tried the code below that returns... something, but definitely not what I need.</p> <pre><code>df['new'] = df.groupby(['team1','team2'])['score1'].transform(lambda x: x.rolling(3, min_periods=1).mean() </code></pre> <p>I suppose this could be done with apply() but I want to avoid it due to performace issues.</p>
[ { "answer_id": 74458793, "author": "Dmitriy Zhiganov", "author_id": 13730174, "author_profile": "https://Stackoverflow.com/users/13730174", "pm_score": 0, "selected": false, "text": "before" }, { "answer_id": 74458870, "author": "Moldovan Andrei", "author_id": 6814509, "author_profile": "https://Stackoverflow.com/users/6814509", "pm_score": 1, "selected": false, "text": " const StyledLI = styled.li`\n list-style-type: none;\n `;\n" }, { "answer_id": 74459008, "author": "George Chond", "author_id": 17730652, "author_profile": "https://Stackoverflow.com/users/17730652", "pm_score": 3, "selected": true, "text": "::marker" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19135414/" ]
74,458,635
<p>I have a user table like this,</p> <pre><code>name week_no year_no fb 5 2021 twitter 1 2022 twitter 2 2022 twitter 3 2022 twitter 7 2022 youtube 21 2022 </code></pre> <p>I want to find the names of users who login &gt;= 3 consecutive weeks in the same year. The week numbers will be unique for each year. For example, in the above table we can see that user <code>twitter</code> is logged in <code>week_no: 1, 2, 3</code> in the same year <code>2022</code> thereby satisfying the condition that I am looking for.</p> <p>The output I am looking for,</p> <pre><code>name year_no twitter 2022 </code></pre> <p>You can create the sample table using,</p> <pre><code>CREATE TABLE test ( name varchar(20), week_no int, year_no int ); INSERT INTO test (name, week_no, year_no) VALUES ('fb', 5, 2021), ('twitter', 1, 2022), ('twitter', 2, 2022), ('twitter', 3, 2022), ('twitter', 7, 2022), ('youtube', 21, 2022); </code></pre> <p>I am new to SQL language and I read that group by can achieve that, can someone help in what function/query we have to use to achieve the same.</p> <pre><code>select * from test group by year_no, name; </code></pre> <p>Thank you for any help in advance.</p>
[ { "answer_id": 74459197, "author": "Ergest Basha", "author_id": 16461952, "author_profile": "https://Stackoverflow.com/users/16461952", "pm_score": 3, "selected": true, "text": "SELECT t1.name,t1.year_no\nFROM test t1\nINNER JOIN test t2 ON t1.name=t2.name AND t1.year_no=t2.year_no\nINNER JOIN test t3 ON t1.name=t3.name AND t1.year_no=t3.year_no\nWHERE t2.week_no = t1.week_no + 1 \nAND t3.week_no = t1.week_no + 2 \n" }, { "answer_id": 74459314, "author": "jian", "author_id": 15603477, "author_profile": "https://Stackoverflow.com/users/15603477", "pm_score": 1, "selected": false, "text": "WITH cte AS (\n SELECT\n name,\n week_no,\n year_no,\n lag(week_no) OVER (PARTITION BY name,\n year_no ORDER BY year_no,\n week_no) AS lag,\n lead(week_no) OVER (PARTITION BY name,\n year_no ORDER BY year_no,\n week_no) AS lead\n FROM\n testuser\n)\nSELECT DISTINCT\n name,\n year_no\nFROM\n cte\nWHERE\n lead + lag = 2 * week_no;\n\n \n" }, { "answer_id": 74459407, "author": "ahmed", "author_id": 12705912, "author_profile": "https://Stackoverflow.com/users/12705912", "pm_score": 2, "selected": false, "text": "SELECT name, year_no\nFROM\n(\n SELECT *, \n week_no -\n ROW_NUMBER() OVER (PARTITION by name, year_no ORDER BY week_no) grp\n FROM test\n) T\nGROUP BY name, year_no, grp\nHAVING COUNT(*) >= 3\nORDER BY name, year_no\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11816060/" ]
74,458,658
<p>I have been trying for several days to deploy a Symfony site. All the files are well in the public folder with the .htaccess, I only need the dependencies for the site to be functional. The problem is that when I run the command</p> <pre><code>php composer.phar update </code></pre> <p><a href="https://i.stack.imgur.com/S1LOT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S1LOT.png" alt="Serveur ssh error" /></a></p> <p>I get several error messages concerning my version of PHP. The host is hostinger. I know the problem comes from the composer.json file and the version of the bundles but I don't know how to solve the problem.</p> <p>Thanks</p> <p><a href="https://i.stack.imgur.com/XOAJ1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XOAJ1.png" alt="composer.json" /></a></p>
[ { "answer_id": 74459197, "author": "Ergest Basha", "author_id": 16461952, "author_profile": "https://Stackoverflow.com/users/16461952", "pm_score": 3, "selected": true, "text": "SELECT t1.name,t1.year_no\nFROM test t1\nINNER JOIN test t2 ON t1.name=t2.name AND t1.year_no=t2.year_no\nINNER JOIN test t3 ON t1.name=t3.name AND t1.year_no=t3.year_no\nWHERE t2.week_no = t1.week_no + 1 \nAND t3.week_no = t1.week_no + 2 \n" }, { "answer_id": 74459314, "author": "jian", "author_id": 15603477, "author_profile": "https://Stackoverflow.com/users/15603477", "pm_score": 1, "selected": false, "text": "WITH cte AS (\n SELECT\n name,\n week_no,\n year_no,\n lag(week_no) OVER (PARTITION BY name,\n year_no ORDER BY year_no,\n week_no) AS lag,\n lead(week_no) OVER (PARTITION BY name,\n year_no ORDER BY year_no,\n week_no) AS lead\n FROM\n testuser\n)\nSELECT DISTINCT\n name,\n year_no\nFROM\n cte\nWHERE\n lead + lag = 2 * week_no;\n\n \n" }, { "answer_id": 74459407, "author": "ahmed", "author_id": 12705912, "author_profile": "https://Stackoverflow.com/users/12705912", "pm_score": 2, "selected": false, "text": "SELECT name, year_no\nFROM\n(\n SELECT *, \n week_no -\n ROW_NUMBER() OVER (PARTITION by name, year_no ORDER BY week_no) grp\n FROM test\n) T\nGROUP BY name, year_no, grp\nHAVING COUNT(*) >= 3\nORDER BY name, year_no\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19195226/" ]
74,458,661
<p>I have the following dataset and I would like to calculate the adjusted r-squared based on this dataset. I have the formula for adjusted R-Squared &quot;Adjusted R2 = 1 – [(1-R2)*(n-1)/(n-k-1)]&quot;.</p> <p>where:</p> <p>R2: The R-Squared</p> <p>n: is the number of observations, in this case, &quot;DV.obs&quot;</p> <p>k: is the number of predictor variables, in this case, &quot;nParam&quot; (where its either 0,1,2,3)</p> <p>the R code to calculate it is the following, where it is grouped by &quot;ITER&quot;, iterations, we have 4 iterations.So the idea is to calculate adjusted R-Squared based on the iterations(4) iteration 1, the nParam should only be 0, iteration 2, the nParam should only be 1, etc, instead of choosing every nParam in the dataset, since the nParam is exactly the same for each iteration.</p> <p>The output should be only 4 rows ( for every iteration, as its grouped by(ITER)) and 2 columns (R2, and adjusted R-Squared) and not for every row in the data. i hope i have explained myself well.</p> <pre><code>library(dplyr) ff &lt;- df %&gt;% group_by(ITER) %&gt;% summarise( Rsq = cor(x= DV.obs, y = DV.sim)^2, adjRsq = 1 - ((1-Rsq)*(length(DV.obs)-1)/(length(DV.obs)- nParam - 1 )) ) ff </code></pre> <p>however, this formula will go through every predictor variable(nParam),</p> <pre><code>df&lt;-structure(list(CASE = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), ITER = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L), nParam = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L ), DV.obs = c(0.101483807, 0.069196694, 0.053869542, 0.043831971, 0.030330271, 0.023612088, 0.01978679, 0.014310351, 0.01164389, 0.007267871, 0.004536453, 0.002873573, 0.002408037, 0.001417053, 0.001136154, 0.101483807, 0.069196694, 0.053869542, 0.043831971, 0.030330271, 0.023612088, 0.01978679, 0.014310351, 0.01164389, 0.007267871, 0.004536453, 0.002873573, 0.002408037, 0.001417053, 0.001136154, 0.101483807, 0.069196694, 0.053869542, 0.043831971, 0.030330271, 0.023612088, 0.01978679, 0.014310351, 0.01164389, 0.007267871, 0.004536453, 0.002873573, 0.002408037, 0.001417053, 0.001136154, 0.101483807, 0.069196694, 0.053869542, 0.043831971, 0.030330271, 0.023612088, 0.01978679, 0.014310351, 0.01164389, 0.007267871, 0.004536453, 0.002873573, 0.002408037, 0.001417053, 0.001136154, 0.000116054, 0.003829787, 0.01206963, 0.02088975, 0.027388781, 0.03423598, 0.037833661, 0.037369438, 0.035164408, 0.034584139, 0.02947776, 0.023210831, 0.014622821, 0.009632495, 0.006731141, 0.0027853, 0.000116054, 0.003829787, 0.01206963, 0.02088975, 0.027388781, 0.03423598, 0.037833661, 0.037369438, 0.035164408, 0.034584139, 0.02947776, 0.023210831, 0.014622821, 0.009632495, 0.006731141, 0.0027853, 0.000116054, 0.003829787, 0.01206963, 0.02088975, 0.027388781, 0.03423598, 0.037833661, 0.037369438, 0.035164408, 0.034584139, 0.02947776, 0.023210831, 0.014622821, 0.009632495, 0.006731141, 0.0027853, 0.000116054, 0.003829787, 0.01206963, 0.02088975, 0.027388781, 0.03423598, 0.037833661, 0.037369438, 0.035164408, 0.034584139, 0.02947776, 0.023210831, 0.014622821, 0.009632495, 0.006731141, 0.0027853 ), DV.sim = c(0, 0.0889808909410658, 0.0947484349571132, 0.0798169790285827, 0.0574006922793388, 0.0505799935506284, 0.0468774569150804, 0.0417447990739346, 0.0375742405164242, 0.0306761993989349, 0.0251120797996223, 0.0205737193532288, 0.0168649279846251, 0.0138327510148287, 0.0113531698574871, 0, 0.0829660195227578, 0.0876380159497916, 0.0723450386112931, 0.0464863987773657, 0.0380595525625348, 0.0343245102453232, 0.0307144539731741, 0.0283392784461379, 0.0245820489723981, 0.0214487023548782, 0.0187365858632326, 0.0163729577744008, 0.0143107050991059, 0.0125108672587574, 0, 0.0762191578459362, 0.0737615750578683, 0.0549565160764756, 0.0280085518714786, 0.0206076781625301, 0.0172540310333669, 0.0134899928846955, 0.0108952926749736, 0.00728254194885496, 0.00491441482789815, 0.00332488210681827, 0.00225250494349749, 0.00152820673925803, 0.00103880306820386, 0, 0.0329456788891303, 0.0365534415712808, 0.03318406650424, 0.0278133129626513, 0.0238151342895627, 0.0205330317793787, 0.0155563822799921, 0.0119589968463779, 0.0072024345056713, 0.00437676923945547, 0.00266755578568207, 0.00162810577310623, 0.000994532813206324, 0.000607859854716811, 0, 0.00238890872602278, 0.02000716184065, 0.0509446502289174, 0.0907202677155637, 0.173563302880525, 0.223891823887825, 0.2226231635499, 0.19175603264451, 0.168494781267643, 0.150974664176703, 0.136206244819164, 0.111464575245381, 0.0913691590994598, 0.0749306779146197, 0.0504548476848009, 0, 0.00141190656836649, 0.0124264488774641, 0.0328390336436031, 0.0603613019163447, 0.123470497330427, 0.172404586815834, 0.178024356626272, 0.151606226187945, 0.130227694458962, 0.117105708281994, 0.107832603356838, 0.0935153502613309, 0.081651206263304, 0.0713645335614684, 0.0545446672743561, 0, 0.00122455342249632, 0.00957195676775054, 0.0233009280455857, 0.0398901057214595, 0.069490838356018, 0.0753487069702148, 0.0619427798080445, 0.0388082119899989, 0.0282194718351961, 0.0223033058814705, 0.0181158699408174, 0.012206885059923, 0.00828045272134247, 0.00562572468560191, 0.00260434861259537, 0, 0.00337575118759914, 0.0123247819279197, 0.0212808990854769, 0.0292664165479362, 0.0407316533482074, 0.0457373328155279, 0.0440263413557409, 0.0350818961969019, 0.0268987657874823, 0.0206920115460456, 0.0160182394650579, 0.00970028643496338, 0.00590740063816313, 0.00360522091817113, 0.00134665597468616)), row.names = c(NA, 124L), class = &quot;data.frame&quot;) </code></pre>
[ { "answer_id": 74459197, "author": "Ergest Basha", "author_id": 16461952, "author_profile": "https://Stackoverflow.com/users/16461952", "pm_score": 3, "selected": true, "text": "SELECT t1.name,t1.year_no\nFROM test t1\nINNER JOIN test t2 ON t1.name=t2.name AND t1.year_no=t2.year_no\nINNER JOIN test t3 ON t1.name=t3.name AND t1.year_no=t3.year_no\nWHERE t2.week_no = t1.week_no + 1 \nAND t3.week_no = t1.week_no + 2 \n" }, { "answer_id": 74459314, "author": "jian", "author_id": 15603477, "author_profile": "https://Stackoverflow.com/users/15603477", "pm_score": 1, "selected": false, "text": "WITH cte AS (\n SELECT\n name,\n week_no,\n year_no,\n lag(week_no) OVER (PARTITION BY name,\n year_no ORDER BY year_no,\n week_no) AS lag,\n lead(week_no) OVER (PARTITION BY name,\n year_no ORDER BY year_no,\n week_no) AS lead\n FROM\n testuser\n)\nSELECT DISTINCT\n name,\n year_no\nFROM\n cte\nWHERE\n lead + lag = 2 * week_no;\n\n \n" }, { "answer_id": 74459407, "author": "ahmed", "author_id": 12705912, "author_profile": "https://Stackoverflow.com/users/12705912", "pm_score": 2, "selected": false, "text": "SELECT name, year_no\nFROM\n(\n SELECT *, \n week_no -\n ROW_NUMBER() OVER (PARTITION by name, year_no ORDER BY week_no) grp\n FROM test\n) T\nGROUP BY name, year_no, grp\nHAVING COUNT(*) >= 3\nORDER BY name, year_no\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18135188/" ]
74,458,685
<p>I have a string:</p> <pre class="lang-r prettyprint-override"><code>a = c(&quot;112 271 [X];313 179 [X];125 162;123 131 [X];124 107&quot;) </code></pre> <p>I want to first split it by semicolon <code>;</code></p> <pre><code>b = as.list(strsplit(a, &quot;;&quot;)[[1]]) &gt; b [[1]] [1] &quot;112 271 [X]&quot; [[2]] [1] &quot;313 179 [X]&quot; [[3]] [1] &quot;125 162&quot; [[4]] [1] &quot;123 131 [X]&quot; [[5]] [1] &quot;124 107&quot; </code></pre> <p>then I want to split <code>b</code> by <code>space</code>, and save the result as a 3-column data frame.</p> <p>The result looks like:</p> <pre><code> A B C 1 112 271 [X] 2 313 179 [X] 3 125 162 4 123 131 [X] 5 124 107 </code></pre> <p>I don't know how to do it. Thanks for your help.</p>
[ { "answer_id": 74458797, "author": "zx8754", "author_id": 680068, "author_profile": "https://Stackoverflow.com/users/680068", "pm_score": 4, "selected": true, "text": "data.table::fread(gsub(\";\", \"\\n\", a, fixed = TRUE),\n fill = TRUE,\n col.names = LETTERS[1:3])\n# A B C\n# 1: 112 271 [X]\n# 2: 313 179 [X]\n# 3: 125 162 \n# 4: 123 131 [X]\n# 5: 124 107 \n" }, { "answer_id": 74459694, "author": "Chris Ruehlemann", "author_id": 8039978, "author_profile": "https://Stackoverflow.com/users/8039978", "pm_score": 3, "selected": false, "text": "tidyverse" }, { "answer_id": 74459718, "author": "ThomasIsCoding", "author_id": 12158757, "author_profile": "https://Stackoverflow.com/users/12158757", "pm_score": 3, "selected": false, "text": "read.table" }, { "answer_id": 74459814, "author": "Captain Hat", "author_id": 4676560, "author_profile": "https://Stackoverflow.com/users/4676560", "pm_score": 2, "selected": false, "text": "stringr::str_split()" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6023565/" ]
74,458,691
<p>I want to execute .bash script using <code>OS Process Sampler</code> via Jmeter 5.5</p> <p>My requirements are:</p> <pre><code>1 Navigate to the specific path: C:\app\docs\release 2 execute as: ./no_longer_duplicate.bash dwtikz895261 6565 3 dwtikz895261 should be fetched as variable </code></pre> <p>what I tried is: <a href="https://i.stack.imgur.com/VGJX9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VGJX9.png" alt="enter image description here" /></a></p> <p>What I get is: <a href="https://i.stack.imgur.com/0dtAn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0dtAn.png" alt="enter image description here" /></a></p> <p>Any help is appreciated</p>
[ { "answer_id": 74507281, "author": "vlatko606", "author_id": 5210482, "author_profile": "https://Stackoverflow.com/users/5210482", "pm_score": 1, "selected": true, "text": "OS Process Sampler" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5210482/" ]
74,458,693
<h1>I am trying to make ListView for my app. when I add listview, listview is not visible or showing.</h1> <h2>INFO</h2> <p>Flutter version: 3.3.8 Engine revision 857bd6b74c Dart version 2.18.4 DevTools version 2.15.0</p> <pre class="lang-dart prettyprint-override"><code> Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.grey[100], body: Container( padding: const EdgeInsets.only(left: 20, top: 50), child: Column( children: &lt;Widget&gt;[ Container( padding: const EdgeInsets.all(0), child: Column( children: [ Expanded( child: ListView( shrinkWrap: true, children: &lt;Widget&gt;[ Expanded( child: Column( children: [ Container( decoration: BoxDecoration( image: const DecorationImage( image: NetworkImage(&quot;...&quot;), ), borderRadius: BorderRadius.circular(20.0) ), ), const Text(&quot;Pineapple&quot;) ], ), ) ], ), ) ], ), ) ], ) ) ); } </code></pre>
[ { "answer_id": 74507281, "author": "vlatko606", "author_id": 5210482, "author_profile": "https://Stackoverflow.com/users/5210482", "pm_score": 1, "selected": true, "text": "OS Process Sampler" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18234747/" ]
74,458,696
<p>I am using PySpark and I want to get the first status order by Date but only if there consecutive status, because the status can be more than once, but not more than one in a row. Here is my example of what i have:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>status</th> <th>created_when</th> <th>GP</th> </tr> </thead> <tbody> <tr> <td>A</td> <td>2022-10-10</td> <td>A1</td> </tr> <tr> <td>B</td> <td>2022-10-12</td> <td>A1</td> </tr> <tr> <td>B</td> <td>2022-10-13</td> <td>A1</td> </tr> <tr> <td>C</td> <td>2022-10-13</td> <td>A1</td> </tr> <tr> <td>C</td> <td>2022-10-14</td> <td>A1</td> </tr> <tr> <td>B</td> <td>2022-12-15</td> <td>A1</td> </tr> <tr> <td>C</td> <td>2022-12-16</td> <td>A1</td> </tr> <tr> <td>D</td> <td>2022-12-17</td> <td>A1</td> </tr> <tr> <td>A</td> <td>2022-12-18</td> <td>A1</td> </tr> </tbody> </table> </div> <p>This is what I need:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>status</th> <th>created_when</th> <th>GP</th> </tr> </thead> <tbody> <tr> <td>A</td> <td>2022-10-10</td> <td>A1</td> </tr> <tr> <td>B</td> <td>2022-10-12</td> <td>A1</td> </tr> <tr> <td>C</td> <td>2022-10-13</td> <td>A1</td> </tr> <tr> <td>B</td> <td>2022-12-15</td> <td>A1</td> </tr> <tr> <td>C</td> <td>2022-12-16</td> <td>A1</td> </tr> <tr> <td>D</td> <td>2022-12-17</td> <td>A1</td> </tr> <tr> <td>A</td> <td>2022-12-18</td> <td>A1</td> </tr> </tbody> </table> </div> <p>I think something like but dont know how to implement either:</p> <pre><code>when(row[status] == row[status] + 1) then row[status] </code></pre> <p>Thank you for you help</p>
[ { "answer_id": 74507281, "author": "vlatko606", "author_id": 5210482, "author_profile": "https://Stackoverflow.com/users/5210482", "pm_score": 1, "selected": true, "text": "OS Process Sampler" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13846900/" ]
74,458,711
<pre><code>&lt;button id=&quot;btn-id&quot; class=&quot;navbar-toggler&quot; type=&quot;button&quot; data-toggle=&quot;collapse&quot; data-target=&quot;#bs-navbar-collapse-1&quot;&gt; &lt;span class=&quot;navbar-toggler-icon&quot;&gt;&lt;/span&gt; &lt;span class=&quot;navbar-toggler-icon&quot;&gt;&lt;/span&gt; &lt;span class=&quot;navbar-toggler-icon&quot;&gt;&lt;/span&gt; &lt;/button&gt; &lt;a href=&quot;#&quot; class=&quot;navbar-brand&quot;&gt;MyBrand&lt;/a&gt; &lt;!-- Collect the nav links, forms, and other contents for toggling --&gt; &lt;div class=&quot;collapse navbar-collapse&quot; id=&quot;bs-navbar-collapse-1&quot;&gt; &lt;ul class=&quot;nav navbar-nav navbar-right&quot;&gt; &lt;li class=&quot;nav-item&quot;&gt;&lt;a class=&quot;nav-link&quot; href=&quot;#&quot;&gt;Sports&lt;/a&gt;&lt;/li&gt; &lt;li class=&quot;nav-item&quot;&gt;&lt;a class=&quot;nav-link&quot; href=&quot;#&quot;&gt;Activities&lt;/a&gt;&lt;/li&gt; &lt;li class=&quot;nav-item&quot;&gt;&lt;a class=&quot;nav-link&quot; href=&quot;#&quot;&gt;Contact Us&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>I can get this error:</p> <p>The 'data-target' attribute value should be the id of the tag for toggling elements like navigation links, forms, and other contents</p> <p>I need a solution for this error.</p>
[ { "answer_id": 74507281, "author": "vlatko606", "author_id": 5210482, "author_profile": "https://Stackoverflow.com/users/5210482", "pm_score": 1, "selected": true, "text": "OS Process Sampler" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20518738/" ]
74,458,720
<p>I am trying to send an email through telnet using a SMTP server through Telnet</p> <p>For AUTH PLAIN authentication I can use this string that is the username and password combined (ex: dGhpc0lzTXlVc2VybmFtZVRoaXNJc015UGFzc3dvcmQ=)</p> <p>Now I need to use AUTH LOGIN to authenticate instead of AUTH PLAIN, which means I need the username and password separated.</p> <p>My question is: How can I &quot;divide&quot; this string? Or, is there a way to find out the username and password if I authenticated through LOGIN PLAIN so that I can later use it in AUTH LOGIN?</p>
[ { "answer_id": 74507281, "author": "vlatko606", "author_id": 5210482, "author_profile": "https://Stackoverflow.com/users/5210482", "pm_score": 1, "selected": true, "text": "OS Process Sampler" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14990708/" ]
74,458,789
<p>I'm developing a note-taking app (Android app) that uses Firebase, So I intend to add Firebase Authentication. I created the app on Firebase console.</p> <p>I'm taking an error, as you can see at the image down below:</p> <p><img src="https://i.stack.imgur.com/ghX2m.png" alt="This is the error message" /></p> <p>I tried some fixes, that I found at Stack Overflow.</p> <pre class="lang-dart prettyprint-override"><code>void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); runApp(const MyApp()); } </code></pre> <p>This is the main function in <code>main.dart</code></p> <p>I guess I'm missing a spot. But I can't find it.</p> <p>How can I solve this problem?</p>
[ { "answer_id": 74460161, "author": "OutdatedGuy", "author_id": 15428718, "author_profile": "https://Stackoverflow.com/users/15428718", "pm_score": 1, "selected": false, "text": "Firebase.initializeApp();\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458789", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20518550/" ]
74,458,800
<p>According to this document</p> <p><a href="https://i.stack.imgur.com/58Gm0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/58Gm0.png" alt="enter image description here" /></a></p> <p>I need to send downlink of type <code>080100ff</code> to open the supply of the socket.</p> <p>However, I can not send <code>080100ff</code> since I got this error <code>The payload field is not a valid hexadecimal payload in upper case.</code></p> <p>Here is my so far works in python</p> <p>'080100ff'.encode('utf-8').hex() -&gt; 3038303130306666</p> <p>I can send it now, but I think it is incorrectly hex encoded because the device is not turned on</p>
[ { "answer_id": 74459054, "author": "Anthony B.", "author_id": 19408037, "author_profile": "https://Stackoverflow.com/users/19408037", "pm_score": 2, "selected": true, "text": "bytes.fromhex('080100ff')\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10003538/" ]
74,458,818
<p>I want a colour for container but getting error while using colour.</p> <p>My code:</p> <pre><code>Container( color:Colors.red, width: 50, height: 50, decoration: BoxDecoration( borderRadius: BorderRadius.circular(50) ) ), </code></pre>
[ { "answer_id": 74458855, "author": "VincentDR", "author_id": 19540575, "author_profile": "https://Stackoverflow.com/users/19540575", "pm_score": 2, "selected": false, "text": "Container(\n width: 50,\n height: 50,\n decoration: BoxDecoration(\n color:Colors.red,\n borderRadius: BorderRadius.circular(50)\n )\n),\n" }, { "answer_id": 74458891, "author": "ariga", "author_id": 20384182, "author_profile": "https://Stackoverflow.com/users/20384182", "pm_score": 2, "selected": false, "text": "Container( \n width: 50, \n height: 50, \n decoration: BoxDecoration(color: Color.red)\n)\n" }, { "answer_id": 74460145, "author": "Vignesh KM", "author_id": 4646166, "author_profile": "https://Stackoverflow.com/users/4646166", "pm_score": 0, "selected": false, "text": "Column(\n children: [\n Container(\n padding: EdgeInsets.all(10),\n color: Colors.green,\n child: Text('test'),\n ),\n SizedBox(height: 10),\n Container(\n padding: EdgeInsets.all(10),\n decoration: BoxDecoration(\n color: Colors.green,\n borderRadius: BorderRadius.circular(10),\n ),\n child: Text('test'),\n )\n ],\n)\n" }, { "answer_id": 74462988, "author": "Gabi Mangili", "author_id": 17863939, "author_profile": "https://Stackoverflow.com/users/17863939", "pm_score": 0, "selected": false, "text": "Container(\n width: 50,\n height: 50,\n decoration: BoxDecoration(\n borderRadius: BorderRadius.circular(50),\n color: Colors.red\n )\n),\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19842804/" ]
74,458,848
<p>The target is to detect superstring in a set of arrays. In this case it should be 'bal' but I get 'lbal'.</p> <pre><code> const arr = [ ['g', 'l', 'o', 'b', 'a', 'l'], ['b','a','l','l'] ] const res = argv.reduce((acc, val) =&gt; acc.filter(elem =&gt; val.includes(elem))) </code></pre> <p>This function just gives ALL duplicates(items that are presented in any array) when I need only the most long duplicate sequence. Any suggestions?</p>
[ { "answer_id": 74458921, "author": "R4ncid", "author_id": 14326899, "author_profile": "https://Stackoverflow.com/users/14326899", "pm_score": 2, "selected": false, "text": "const arr = [\n ['a', 'b', 'm'],\n ['g', 'o', 'a', 'b'],\n ['w', 'o', 'u', 'k', 'a', 'b']\n ]\n\nconst countTimes = data => data.flat().reduce((res, v) => {\n \n return {\n ...res,\n [v]: (res[v] || 0 ) + 1\n }\n\n}, {})\n\n\nconst duplicates = data => Object.entries(countTimes(data))\n.filter(([v, n]) => n > 1)\n.map(([v, n]) => v)\n\n console.log(countTimes(arr))\n console.log(duplicates(arr) )" }, { "answer_id": 74458922, "author": "Wimanicesir", "author_id": 9568358, "author_profile": "https://Stackoverflow.com/users/9568358", "pm_score": 2, "selected": true, "text": " const original = [\n ['a', 'b', 'm'],\n ['g', 'o', 'a', 'b'],\n ['w', 'o', 'u', 'k', 'a', 'b']\n ]\n \n \n // The easiest is to split up between unique results and duplicates\n let uniqueValues = []\n let duplicates = []\n \n // Now we're going to loop every array\n original.forEach((arr) => {\n // Loop every value inside the array\n arr.forEach((value) => {\n // Check if we had this value already\n if (!uniqueValues.includes(value)) {\n uniqueValues.push(value)\n } else {\n duplicates.push(value)\n }\n })\n })\n \nconsole.log('Duplicates: ', duplicates)\n\n// If you want remove the duplicates from the duplicates, use set\n\nlet uniqueDuplicates = [...new Set(duplicates)]\n\nconsole.log('Unique duplicates: ', uniqueDuplicates)" }, { "answer_id": 74458926, "author": "wjatek", "author_id": 4636502, "author_profile": "https://Stackoverflow.com/users/4636502", "pm_score": 1, "selected": false, "text": "const arr = [\n ['a', 'b', 'm'],\n ['g', 'o', 'a', 'b'],\n ['w', 'o', 'u', 'k', 'a', 'b']\n]\n\nconst arr2 = arr.flat() // ['a', 'b', 'm', 'g', 'o', 'a', 'b', 'w', 'o', 'u', 'k', 'a', 'b']\n\nconst hasDuplicates = new Set(arr2).size !== arr2.length\n" }, { "answer_id": 74458940, "author": "aleEspinosaM", "author_id": 12393723, "author_profile": "https://Stackoverflow.com/users/12393723", "pm_score": 1, "selected": false, "text": "function findDuplicates(data) {\n const map = {};\n data.forEach((row) => {\n row.forEach((item) => {\n if (!map[item]) {\n map[item] = 1;\n } else [map[item]++];\n });\n });\n return map;\n}\n" }, { "answer_id": 74458950, "author": "gog", "author_id": 3494774, "author_profile": "https://Stackoverflow.com/users/3494774", "pm_score": 1, "selected": false, "text": "collections.Counter" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12808136/" ]
74,458,861
<p>I have a function:</p> <pre><code>my_function(arg1 integer, arg2 text, arg3, text); </code></pre> <p>I have a view my_view that returns as a row: (arg1, arg2, arg3);</p> <p>I can call my_function() with the row from the view as I would do explicitely:</p> <pre><code>select my_function(arg1 , arg2, arg3) from my_view; </code></pre> <p>but I would like to do it somehow as mass-assignment:</p> <pre><code>select my_function(my_view.*) from my_view; </code></pre> <p>or</p> <pre><code>select my_function(my_view) from my_view </code></pre> <p>Is there any function that can do transformation for me to be able to do this call this way? Reason is I plan to have some 20-50 attributes and so writing long expression is not comfortable.</p>
[ { "answer_id": 74459303, "author": "puchal", "author_id": 9730358, "author_profile": "https://Stackoverflow.com/users/9730358", "pm_score": 0, "selected": false, "text": "CREATE VIEW my_view AS\nSELECT \n 1 AS foo, \n 2 AS bar,\n 'hello' AS world\nUNION ALL\nSELECT\n 10 AS foo, \n 22 AS bar,\n 'hello' AS world;\n\nCREATE FUNCTION my_function(view_row my_view)\nRETURNS int\n LANGUAGE sql\nAS $function$\n SELECT view_row.foo * view_row.bar\n$function$\n;\n\nSELECT my_function(my_view) FROM my_view;\n" }, { "answer_id": 74459499, "author": "Zegarek", "author_id": 5298879, "author_profile": "https://Stackoverflow.com/users/5298879", "pm_score": 1, "selected": false, "text": "select my_function('my_view');" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20518824/" ]
74,458,897
<p><a href="https://i.stack.imgur.com/OFqW1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OFqW1.png" alt="enter image description here" /></a> how to add numbers near the icon in android jetapck compose, i have attached snap below like that.please help me to solve the problem.</p>
[ { "answer_id": 74459303, "author": "puchal", "author_id": 9730358, "author_profile": "https://Stackoverflow.com/users/9730358", "pm_score": 0, "selected": false, "text": "CREATE VIEW my_view AS\nSELECT \n 1 AS foo, \n 2 AS bar,\n 'hello' AS world\nUNION ALL\nSELECT\n 10 AS foo, \n 22 AS bar,\n 'hello' AS world;\n\nCREATE FUNCTION my_function(view_row my_view)\nRETURNS int\n LANGUAGE sql\nAS $function$\n SELECT view_row.foo * view_row.bar\n$function$\n;\n\nSELECT my_function(my_view) FROM my_view;\n" }, { "answer_id": 74459499, "author": "Zegarek", "author_id": 5298879, "author_profile": "https://Stackoverflow.com/users/5298879", "pm_score": 1, "selected": false, "text": "select my_function('my_view');" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20108370/" ]
74,458,917
<p>I try to create a view which contains calculated data from others table. However, I have this error message: <code>[42701] ERROR: column &quot;id&quot; specified more than once</code>.</p> <p>My SQL script:</p> <pre><code>CREATE VIEW dashboard_view AS SELECT c.libelle_commune AS &quot;commune&quot;, count(bv.id) AS &quot;total_bv&quot;, count(rsb.id) AS &quot;bv_saisis&quot;, count(bv.id) - count(rsb.id) AS &quot;bv_en_attente&quot;, count(rsb.id) / count(bv.id) * 100 AS &quot;pourcentage_saisie&quot;, count(rsb_t.id) AS &quot;bv_transmis_sie2&quot;, count(rsb_t.id) / count(bv.id) * 100 AS &quot;pourcentage_transmission&quot;, d.id, c.id FROM commune &quot;c&quot; JOIN departement &quot;d&quot; ON d.id = c.departement_id JOIN bureau_de_vote &quot;bv&quot; ON bv.commune_id = c.id LEFT JOIN scrutin_bureau &quot;sb&quot; ON sb.bureau_de_vote_id = bv.id LEFT JOIN resultat_scrutin_bureau &quot;rsb&quot; ON rsb.scrutin_bureau_id = sb.id LEFT JOIN resultat_scrutin_bureau &quot;rsb_t&quot; ON ( rsb_t.scrutin_bureau_id = sb.id AND rsb_t.etat_id = (SELECT id FROM etat WHERE code = 'transmission') ) JOIN election ON sb.election_id = election.id GROUP BY c.id, d.id; </code></pre>
[ { "answer_id": 74459303, "author": "puchal", "author_id": 9730358, "author_profile": "https://Stackoverflow.com/users/9730358", "pm_score": 0, "selected": false, "text": "CREATE VIEW my_view AS\nSELECT \n 1 AS foo, \n 2 AS bar,\n 'hello' AS world\nUNION ALL\nSELECT\n 10 AS foo, \n 22 AS bar,\n 'hello' AS world;\n\nCREATE FUNCTION my_function(view_row my_view)\nRETURNS int\n LANGUAGE sql\nAS $function$\n SELECT view_row.foo * view_row.bar\n$function$\n;\n\nSELECT my_function(my_view) FROM my_view;\n" }, { "answer_id": 74459499, "author": "Zegarek", "author_id": 5298879, "author_profile": "https://Stackoverflow.com/users/5298879", "pm_score": 1, "selected": false, "text": "select my_function('my_view');" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458917", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7380356/" ]
74,458,945
<p>I am new to Dart and Flutter.</p> <p>In dart what is the difference between using ? and ! for null-able types?</p> <pre><code>validator: ((value) { if (value?.isEmpty) { return &quot;Field is required&quot;; } return null; }), validator: ((value) { if (value!.isEmpty) { return &quot;Field is required&quot;; } return null; }), </code></pre> <p>Thanks in advance!</p>
[ { "answer_id": 74459105, "author": "VincentDR", "author_id": 19540575, "author_profile": "https://Stackoverflow.com/users/19540575", "pm_score": 2, "selected": false, "text": "String? test;\nif (test?.isEmpty == true) { // And is not null, but you don't need to check it\n // If null, will never pass there but without error\n}\n" }, { "answer_id": 74459296, "author": "hasan karaman", "author_id": 11544943, "author_profile": "https://Stackoverflow.com/users/11544943", "pm_score": 2, "selected": false, "text": "String? carName; // initialized to null by default\nint? value = 36; // initialized to non-null\nvalue = null; // can be re-assigned to null\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2250108/" ]
74,458,948
<p>I have a Question. I have 2 Dto Object and one Model.</p> <p>What i'm trying todo is map the <em><strong>AssetDTO</strong></em> to the <em><strong>Asset Model</strong></em> using <em>Automapper</em>.</p> <p>I have no clue on how to accomplish this.</p> <pre><code> public class AssetDTO { public string Code { get; set; } public string CodeType { get; set; } public List&lt;MetricDataDTO&gt; Data { get; set; } } public class MetricDataDTO { public string Value{ get; set; } public string Flow { get; set; } } </code></pre> <p>I have one model that look like this.</p> <pre><code> public class Asset { public string Code { get; set; } public string CodeType { get; set; } public string Value{ get; set; } public string Flow { get; set; } } </code></pre> <p>I tryed setting up the mapping with automapper but without any luck :( Hope anyone can help me out,Thanks in advance!!</p>
[ { "answer_id": 74459105, "author": "VincentDR", "author_id": 19540575, "author_profile": "https://Stackoverflow.com/users/19540575", "pm_score": 2, "selected": false, "text": "String? test;\nif (test?.isEmpty == true) { // And is not null, but you don't need to check it\n // If null, will never pass there but without error\n}\n" }, { "answer_id": 74459296, "author": "hasan karaman", "author_id": 11544943, "author_profile": "https://Stackoverflow.com/users/11544943", "pm_score": 2, "selected": false, "text": "String? carName; // initialized to null by default\nint? value = 36; // initialized to non-null\nvalue = null; // can be re-assigned to null\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20518729/" ]
74,458,966
<p>I have a product category called Cable, and I want to grab all posts assigned to this category and output the title of said posts. This category is from the custom taxonomy 'Category' that woo-commerce adds, I'm not sure if that makes things harder? but I haven't found a solution yet.</p> <p>Could anyone assist with this?</p> <p><a href="https://i.stack.imgur.com/H7U6Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H7U6Y.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74459255, "author": "zillionera_dev", "author_id": 15306153, "author_profile": "https://Stackoverflow.com/users/15306153", "pm_score": 1, "selected": false, "text": "WP_Query()" }, { "answer_id": 74459275, "author": "Krunal Bhimajiyani", "author_id": 19587288, "author_profile": "https://Stackoverflow.com/users/19587288", "pm_score": 3, "selected": true, "text": "add_shortcode( 'specific_category_posts', 'kb_get_posts' );\nfunction kb_get_posts() {\n\n $query = new WP_Query(\n array(\n 'post_type' => 'product',\n 'post_status' => 'publish',\n 'posts_per_page' => -1,\n 'tax_query' => array(\n array(\n 'taxonomy' => 'product_cat',\n 'field' => 'term_id',\n 'terms' => array( '18' ), //Your custom category id\n ),\n ),\n )\n);\n\nif ( $query->have_posts() ) {\n while ( $query->have_posts() ) {\n $query->the_post();\n echo '<h2>' . get_the_title() . '</h2>';\n }\n}\nwp_reset_postdata();\n}\n" }, { "answer_id": 74459292, "author": "Mark Tendly", "author_id": 20500301, "author_profile": "https://Stackoverflow.com/users/20500301", "pm_score": 1, "selected": false, "text": "<?php\n global $post;\n $args = array( 'numberposts' => 10, 'category_name' => 'cable' );\n $posts = get_posts( $args );\n foreach( $posts as $post ): setup_postdata($post); \n?>\n\n<div> \n <?php \n the_title(); \n the_excerpt(); ?>\n</div>\n\n<?php endforeach; ?>\n" }, { "answer_id": 74459917, "author": "Gaurav Mittal", "author_id": 4101349, "author_profile": "https://Stackoverflow.com/users/4101349", "pm_score": 1, "selected": false, "text": "add_shortcode( 'pi_cable_posts', 'pi_posts' );\nfunction pi_posts() {\n$pi_query = new WP_Query(\narray(\n 'post_type' => 'product',\n 'post_status' => 'publish',\n 'posts_per_page' => -1, //--1 for unlimited and number to limit\n 'tax_query' => array(\n array(\n 'taxonomy' => 'product_cat',\n 'field' => 'term_id',\n 'terms' => array( 'YOUR ID HERE' ), //ADD YOUR ID HERE\n ),\n ),\n));\n\nif ( $pi_query ->have_posts() ) {\necho '<ul>';\nwhile ( $pi_query ->have_posts() ) {\n $pi_query ->the_post();\n echo '<li><h2><a href=\"'.get_the_permalink().'\">' . get_the_title() . '</h2></li>';\n}\necho '</ul>';\n}\nwp_reset_postdata();}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8529928/" ]
74,458,971
<p>I always used <code>UIScreen.main.bounds.size</code> to get the screen size on iOS and worked fine.</p> <p>Now (in iOS 16, I believe) when I try to access the screen size with the &quot;main&quot; instance of UIScreen a warning is displayed:</p> <p><em>&quot;main' will be deprecated in a future version of iOS: Use a UIScreen instance found through context instead: i.e, view.window.windowScene.screen</em></p> <p>So my question is: What is the correct way to get the screen size? for simplicity let's imagine we are on the iPhone with, consequently, only one screen available. Thank you</p>
[ { "answer_id": 74459255, "author": "zillionera_dev", "author_id": 15306153, "author_profile": "https://Stackoverflow.com/users/15306153", "pm_score": 1, "selected": false, "text": "WP_Query()" }, { "answer_id": 74459275, "author": "Krunal Bhimajiyani", "author_id": 19587288, "author_profile": "https://Stackoverflow.com/users/19587288", "pm_score": 3, "selected": true, "text": "add_shortcode( 'specific_category_posts', 'kb_get_posts' );\nfunction kb_get_posts() {\n\n $query = new WP_Query(\n array(\n 'post_type' => 'product',\n 'post_status' => 'publish',\n 'posts_per_page' => -1,\n 'tax_query' => array(\n array(\n 'taxonomy' => 'product_cat',\n 'field' => 'term_id',\n 'terms' => array( '18' ), //Your custom category id\n ),\n ),\n )\n);\n\nif ( $query->have_posts() ) {\n while ( $query->have_posts() ) {\n $query->the_post();\n echo '<h2>' . get_the_title() . '</h2>';\n }\n}\nwp_reset_postdata();\n}\n" }, { "answer_id": 74459292, "author": "Mark Tendly", "author_id": 20500301, "author_profile": "https://Stackoverflow.com/users/20500301", "pm_score": 1, "selected": false, "text": "<?php\n global $post;\n $args = array( 'numberposts' => 10, 'category_name' => 'cable' );\n $posts = get_posts( $args );\n foreach( $posts as $post ): setup_postdata($post); \n?>\n\n<div> \n <?php \n the_title(); \n the_excerpt(); ?>\n</div>\n\n<?php endforeach; ?>\n" }, { "answer_id": 74459917, "author": "Gaurav Mittal", "author_id": 4101349, "author_profile": "https://Stackoverflow.com/users/4101349", "pm_score": 1, "selected": false, "text": "add_shortcode( 'pi_cable_posts', 'pi_posts' );\nfunction pi_posts() {\n$pi_query = new WP_Query(\narray(\n 'post_type' => 'product',\n 'post_status' => 'publish',\n 'posts_per_page' => -1, //--1 for unlimited and number to limit\n 'tax_query' => array(\n array(\n 'taxonomy' => 'product_cat',\n 'field' => 'term_id',\n 'terms' => array( 'YOUR ID HERE' ), //ADD YOUR ID HERE\n ),\n ),\n));\n\nif ( $pi_query ->have_posts() ) {\necho '<ul>';\nwhile ( $pi_query ->have_posts() ) {\n $pi_query ->the_post();\n echo '<li><h2><a href=\"'.get_the_permalink().'\">' . get_the_title() . '</h2></li>';\n}\necho '</ul>';\n}\nwp_reset_postdata();}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/288683/" ]
74,458,993
<p>I have a standard router typing.</p> <pre><code>type Routes = '/' | '/achievements' | ... ; </code></pre> <p>This allows you to understand which routers are in the project. But now I have the task to make an array containing all the routers.</p> <pre><code>const allRoutes: Routes[] = ['/', '/achievements']; </code></pre> <p>If any router is missing, it should get an error. This array must always contain all routers. How can it be done?</p> <p>I can't figure out how to require the array to contain the entire enumeration of routers.</p> <p><strong>UPDATE</strong></p> <p>My types are described in the file d.ts. So I cannot declare the construct</p> <pre><code>const ROUTES = ['/', '/achievements'] as const </code></pre> <p>and export it there</p>
[ { "answer_id": 74459327, "author": "wjatek", "author_id": 4636502, "author_profile": "https://Stackoverflow.com/users/4636502", "pm_score": 3, "selected": true, "text": "const ROUTES = ['/', '/achievements'] as const\n\ntype RoutesTuple = typeof ROUTES\n\ntype Routes = RoutesTuple[number]\n\nconst allRoutes: RoutesTuple = ['/', '/achievements']\n" }, { "answer_id": 74459869, "author": "Dimava", "author_id": 5734961, "author_profile": "https://Stackoverflow.com/users/5734961", "pm_score": 0, "selected": false, "text": "\ntype Routes = 'a' | 'b' | 'c'\n\nconst usedRoutes = ['a', 'b', 'd']\n\nfunction ensureArrayHasEvery<T>() {\n return function <A extends readonly T[]>(a: NoInfer<ArrayWithEvery<A, T>> | A & [never]) {\n return a;\n }\n}\n\n\nlet x = ensureArrayHasEvery<Routes>()\n// ^?\nlet y = x(['a', 'b', \"c\"])\n// ^? ['a']\nlet z = x(['a'])\n// ^? Argument of type '[\"a\"]' is not assignable to parameter of type '[\"a\", \"b\" | \"c\"]\n\n\ntype ArrayWithEvery<A extends readonly any[], V> = [V] extends [A[number]] ? A : [...A, Exclude<V, A[number]>]\n\ntype NoInfer<A> = [A][A extends any ? 0 : never]\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74458993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17572785/" ]
74,459,034
<p>I have a problem in clicking in a select element using cypress. This is the element to click: <a href="https://i.stack.imgur.com/Te3Zb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Te3Zb.png" alt="enter image description here" /></a></p> <p>And i receive this error. <code>cy.click()</code> cannot be called on a <code>&lt;select&gt;</code> element. Use the <code>cy.select()</code> command instead to change the value.</p> <p>This is my code:</p> <pre class="lang-js prettyprint-override"><code>cy.get('[name^=shopveg]').click() </code></pre> <p>After searching some people advise using the trigger command. Changed the code to:</p> <pre class="lang-js prettyprint-override"><code>cy.get('[name^=shopveg]').trigger('click') </code></pre> <p>The step pass in the cypress execution but the click was not executed.</p>
[ { "answer_id": 74466487, "author": "Grainger", "author_id": 20487878, "author_profile": "https://Stackoverflow.com/users/20487878", "pm_score": 2, "selected": false, "text": ".select()" }, { "answer_id": 74479498, "author": "agoff", "author_id": 11625850, "author_profile": "https://Stackoverflow.com/users/11625850", "pm_score": 0, "selected": false, "text": "cy.each()" }, { "answer_id": 74481739, "author": "TesterDick", "author_id": 18366749, "author_profile": "https://Stackoverflow.com/users/18366749", "pm_score": 1, "selected": false, "text": "npm install cypress-real-events\n// or\nyarn add cypress-real-events\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12720326/" ]
74,459,046
<p>I have following <code>package.json</code> scripts section:</p> <pre><code>&quot;watch&quot;: &quot;?&quot;, &quot;build&quot;: &quot;npm run build:compactor &amp;&amp; npm run build:generator &amp;&amp; npm run build:cleaner&quot;, &quot;build:lambda&quot;: &quot;npm run build:compactor:lambda &amp;&amp; npm run build:generator:lambda &amp;&amp; npm run build:cleaner:lambda&quot;, &quot;build:compactor&quot;: &quot;tsc -p src/compactor&quot;, &quot;build:generator&quot;: &quot;tsc -p src/generator&quot;, &quot;build:cleaner&quot;: &quot;tsc -p src/cleaner&quot;, &quot;build:compactor:lambda&quot;: &quot;npm run build:compactor &amp;&amp; cp package.json ./dist-compactor/package.json &amp;&amp; cd ./dist-compactor &amp;&amp; npm install --production &amp;&amp; zip -r ../dist-compactor.zip *&quot;, &quot;build:generator:lambda&quot;: &quot;npm run build:generator &amp;&amp; cp package.json ./dist-generator/package.json &amp;&amp; cd ./dist-generator &amp;&amp; npm install --production &amp;&amp; zip -r ../dist-compactor.zip *&quot;, &quot;build:cleaner:lambda&quot;: &quot;npm run build:cleaner &amp;&amp; cp package.json ./dist-cleaner/package.json &amp;&amp; cd ./dist-cleaner &amp;&amp; npm install --production &amp;&amp; zip -r ../dist-compactor.zip *&quot;, </code></pre> <p>My project consists of 3 subproject. It has main <code>tsconfig.json</code> file and then 3 configs which extend first one.</p> <p>Standard <code>tsc -w</code> will ignore existing nested configuration.</p> <p>One option would be to concurrently run <code>tsc -p src/&lt;project&gt; -w</code> 3 times but maybe <code>tsc</code> has something built in already?</p>
[ { "answer_id": 74466487, "author": "Grainger", "author_id": 20487878, "author_profile": "https://Stackoverflow.com/users/20487878", "pm_score": 2, "selected": false, "text": ".select()" }, { "answer_id": 74479498, "author": "agoff", "author_id": 11625850, "author_profile": "https://Stackoverflow.com/users/11625850", "pm_score": 0, "selected": false, "text": "cy.each()" }, { "answer_id": 74481739, "author": "TesterDick", "author_id": 18366749, "author_profile": "https://Stackoverflow.com/users/18366749", "pm_score": 1, "selected": false, "text": "npm install cypress-real-events\n// or\nyarn add cypress-real-events\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12334270/" ]
74,459,051
<p>I have two data frames. <code>df1</code> has some NAs in a column that I'm interested in, and <code>df2</code> has this same column but with the values I need. I want to fill those values in df1 according to the rownames (the rownames in df2 are found in df1).</p> <p>For example, df1 would be something like this:</p> <pre><code> Age Gender Patient_1 NA Male # Has NA Patient_3 30 Male Patient_66 45 Female Patient_10 NA Female # Has NA Patient_11 67 Female Patient_23 NA Male # Has NA </code></pre> <p>and df2 contains the same information but only for the samples that have <strong>NA</strong> in the age column in df1:</p> <pre><code> Age Gender Patient_1 59 Male Patient_10 80 Female Patient_23 21 Male </code></pre> <p>Now how do I fill those Age values, from df2 to df1, for each sample?</p> <p>I tried this:</p> <pre><code>for(i in 1:length(df1$Age)){ if(rownames(df1)[i] == rownames(df2)[i]){ df1$Age[[i]] = df2$Age[[i]] } } </code></pre> <p>That didn't work as it filled only a subset of the values for some reason, some values are still NA in df1.</p>
[ { "answer_id": 74459294, "author": "SamR", "author_id": 12545041, "author_profile": "https://Stackoverflow.com/users/12545041", "pm_score": 2, "selected": false, "text": "dplyr" }, { "answer_id": 74459309, "author": "mmrabe", "author_id": 19618092, "author_profile": "https://Stackoverflow.com/users/19618092", "pm_score": 4, "selected": true, "text": "df2" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17945841/" ]
74,459,055
<p>So i have the below table, and i cant figure out why the first two table rows in the first table are appearing as if they were in the same row. Cant find a reason anywhere. I want them to appear as they you would expect, on top of one another in a column. Am i missing something here? <a href="https://jsfiddle.net/b4j2e1vq/" rel="nofollow noreferrer">https://jsfiddle.net/b4j2e1vq/</a></p> <pre><code>&lt;html&gt; &lt;div class=&quot;page&quot;&gt; &lt;div class=&quot;container&quot;&gt; &lt;header&gt; &lt;script src=&quot;./jScript.js&quot; async&gt;&lt;/script&gt; &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;./styleSheet.css&quot;&gt; &lt;h1&gt; Energy saving calculator&lt;/h1&gt; &lt;/header&gt; &lt;body&gt; &lt;section class=&quot;savingCalc&quot; id=&quot;paperTowelCalc&quot; &gt; &lt;table&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td rowspan=&quot;3&quot;&gt;Total Paper Towel Cost per annum&lt;/td&gt; &lt;td rowspan=&quot;3&quot;&gt;&lt;input type=&quot;number&quot; class=&quot;handDryerModelInput&quot; id=&quot;papTowelCost&quot; value=&quot;0&quot;&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan=&quot;3&quot;&gt;Energy cost saving per annum by switching&lt;/td&gt; &lt;td rowspan=&quot;3&quot;&gt;&lt;input type=&quot;number&quot; class=&quot;handDryerModelInput&quot; id=&quot;costSaveSwitch&quot; value=&quot;0&quot;&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;table class=&quot;table&quot;&gt; &lt;tr&gt; &lt;td&gt;&lt;label for=&quot;handDryPDayInp&quot;&gt;Number of hand dries/day*&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type=&quot;number&quot; class=&quot;handDryerModelInput&quot; id=&quot;handDryPDayInp&quot; value=&quot;0&quot;&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label for=&quot;daysOpenInp&quot;&gt;Days per annum washroom is open&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type=&quot;number&quot; class=&quot;handDryerModelInput&quot; id=&quot;daysOpenInp&quot; value=&quot;0&quot;&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label for=&quot;costPerTowel&quot;&gt;Cost per towel&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type=&quot;number&quot; class=&quot;handDryerModelInput&quot; id=&quot;costPerTowel&quot; value=&quot;0&quot;&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label for=&quot;dispenserReplaceNum&quot;&gt;Number of dispensers to be replaced &lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type=&quot;number&quot; class=&quot;handDryerModelInput&quot; id=&quot;dispenserReplaceNum&quot; value=&quot;0&quot;&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/section&gt; &lt;/body&gt; &lt;/div&gt; &lt;/div&gt; &lt;/html&gt;``` </code></pre>
[ { "answer_id": 74459294, "author": "SamR", "author_id": 12545041, "author_profile": "https://Stackoverflow.com/users/12545041", "pm_score": 2, "selected": false, "text": "dplyr" }, { "answer_id": 74459309, "author": "mmrabe", "author_id": 19618092, "author_profile": "https://Stackoverflow.com/users/19618092", "pm_score": 4, "selected": true, "text": "df2" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11254577/" ]
74,459,060
<p>I am trying to create a set of dynamic HTML tables using JS.</p> <p>I am taking in data from an array of objects, in the following format:</p> <pre><code>const formPages = [ { &quot;name&quot;: &quot;page1&quot;, &quot;response&quot;: [ { &quot;question&quot;: &quot;Question 1&quot;, &quot;response&quot;: &quot;Hello!&quot; }, { &quot;question&quot;: &quot;Question 2&quot;, &quot;response&quot;: &quot;Hello again!&quot; } ] }, { &quot;name&quot;: &quot;page2&quot;, &quot;response&quot;: [ { &quot;question&quot;: &quot;Question 3&quot;, &quot;response&quot;: &quot;Bye!&quot; }, { &quot;question&quot;: &quot;Question 4&quot;, &quot;response&quot;: &quot;Bye again!&quot; } ] } ] </code></pre> <p>I need to output a table for each page in the following format:</p> <p><strong>Page 1</strong></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Question</th> <th>Response</th> </tr> </thead> <tbody> <tr> <td>Question 1</td> <td>Hello!</td> </tr> <tr> <td>Question 2</td> <td>Hello Again!</td> </tr> </tbody> </table> </div> <p><strong>Page 2</strong></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Question</th> <th>Response</th> </tr> </thead> <tbody> <tr> <td>Question 3</td> <td>Bye!</td> </tr> <tr> <td>Question 4</td> <td>Bye Again!</td> </tr> </tbody> </table> </div> <p>I know we need to loop over the array of objects, dynamically rendering the HTML to output those two tables.</p> <p>Don't have much experience with table HTML, so some help here would be great!</p> <p>Thanks in advance!</p>
[ { "answer_id": 74459294, "author": "SamR", "author_id": 12545041, "author_profile": "https://Stackoverflow.com/users/12545041", "pm_score": 2, "selected": false, "text": "dplyr" }, { "answer_id": 74459309, "author": "mmrabe", "author_id": 19618092, "author_profile": "https://Stackoverflow.com/users/19618092", "pm_score": 4, "selected": true, "text": "df2" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17880316/" ]
74,459,067
<p>I want to split a string on the first capital letter in a group.</p> <p>For example, <code>FooBARBaz</code> should become <code>Foo BAR Baz</code>.</p> <p>I've come up with:</p> <pre class="lang-js prettyprint-override"><code>str.replace(/[A-Z][a-z]+/g, ' $&amp;') .replace(/[A-Z]+/g, ' $&amp;') .replace(/\s+/g, ' ') .trim(); </code></pre> <p>Can anyone suggest a cleaner solution?</p>
[ { "answer_id": 74459234, "author": "gog", "author_id": 3494774, "author_profile": "https://Stackoverflow.com/users/3494774", "pm_score": 2, "selected": false, "text": "m = 'FooBARBazAB'.match(/([A-Z](?=[A-Z]|$))+|[A-Z][^A-Z]*/g)\n\nconsole.log(m)" }, { "answer_id": 74461084, "author": "Peter Seliger", "author_id": 2627243, "author_profile": "https://Stackoverflow.com/users/2627243", "pm_score": 3, "selected": true, "text": "/([A-Z][a-z]+)/g" }, { "answer_id": 74462223, "author": "Rohìt Jíndal", "author_id": 4116300, "author_profile": "https://Stackoverflow.com/users/4116300", "pm_score": 2, "selected": false, "text": "replacer" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2741954/" ]
74,459,096
<p>I've made a <code>tk.Toplevel</code> class to get a date from the user. After the user clicked the date, the window is closing and the date should return to the mainprocess. When the <code>tk.Toplevel</code> is closed I've got the date, but also an error: <code>\_tkinter.TclError: bad window path name &quot;.!kalender.!dateentry.!toplevel&quot;</code> What did I do wrong?</p> <pre><code>class Kalender(tk.Toplevel): def __init__(self, parent, date=''): Toplevel.__init__(self, parent) # Fenster mittig zentrieren x = (self.winfo_screenwidth() // 2) - (100 // 2) y = (self.winfo_screenheight() // 2) - (50 // 2) self.grab_set() self.geometry('{}x{}+{}+{}'.format(180, 90, x, y)) self.attributes('-toolwindow', True) self.title('Datum auswählen') self.resizable(width=False, height=False) self.date = None self.sel = StringVar() self.cal = DateEntry(self, font=&quot;Arial 14&quot;, selectmode='day', locale='de_DE', date_pattern=&quot;dd.mm.y &quot;, textvariable=self.sel) self.cal.bind(&quot;&lt;&lt;DateEntrySelected&gt;&gt;&quot;, self.close_window) self.cal.set_date(date) self.cal.grid(row=0, column=0, padx=10, pady=10, sticky=W+E) self.focus_set() def close_window(self, e): self.date = self.cal.get() self.destroy() def show(self): self.deiconify() self.wm_protocol(&quot;WM_DELETE_WINDOW&quot;, self.close_window) self.wait_window() return self.date cal = Kalender(main_window, d).show() </code></pre> <p>I've got the following error:</p> <pre><code>Exception in Tkinter callback Traceback (most recent call last): File &quot;B:\Python 310\lib\tkinter\__init__.py&quot;, line 1921, in __call__ return self.func(*args) File &quot;B:\Python 310\lib\site-packages\tkcalendar\dateentry.py&quot;, line 301, in _select self._top_cal.withdraw() File &quot;B:\Python 310\lib\tkinter\__init__.py&quot;, line 2269, in wm_withdraw return self.tk.call('wm', 'withdraw', self._w) _tkinter.TclError: bad window path name &quot;.!kalender.!dateentry.!toplevel&quot; </code></pre> <p>It seems, that tkinter tries to call the kalender.dateentry after it has been destroyed.</p>
[ { "answer_id": 74459805, "author": "oskros", "author_id": 9490769, "author_profile": "https://Stackoverflow.com/users/9490769", "pm_score": 0, "selected": false, "text": "tkcalendar" }, { "answer_id": 74461082, "author": "acw1668", "author_id": 5317403, "author_profile": "https://Stackoverflow.com/users/5317403", "pm_score": 1, "selected": false, "text": "self.close_window()" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20518006/" ]
74,459,107
<p>Related:</p> <blockquote> <p><a href="https://stackoverflow.com/questions/39572884/how-to-convert-from-string-to-array">How to convert from string to array?</a></p> </blockquote> <p>This is a follow-up question. How would I make a list of all the digits in this number (currently as a string)?</p> <pre><code>&quot;123&quot; -&gt; [1,2,3] </code></pre> <p>There are no delimiters here so how should I go about doing this?</p> <p>Note as of now I am using the latest version of Julia, <a href="https://github.com/JuliaLang/julia/" rel="nofollow noreferrer">v1.8.3</a> so <code>parse</code> doesn't seem to work in the other question's answers. Error when I use <code>parse()</code>:</p> <pre><code>ERROR: LoadError: MethodError: no method matching parse(::SubString{String}) Closest candidates are: parse(::Type{T}, ::AbstractString) where T&lt;:Complex at parse.jl:381 parse(::Type{Sockets.IPAddr}, ::AbstractString) at ~/usr/share/julia/stdlib/v1.8/Sockets/src/IPAddr.jl:246 parse(::Type{T}, ::AbstractChar; base) where T&lt;:Integer at parse.jl:40 ... Stacktrace: [1] iterate @ ./generator.jl:47 [inlined] [2] _collect @ ./array.jl:807 [inlined] [3] collect_similar @ ./array.jl:716 [inlined] [4] map @ ./abstractarray.jl:2933 [inlined] [5] top-level scope @ ~/proc/self/fd/0:1 in expression starting at /proc/self/fd/0:1 exit status 1 </code></pre>
[ { "answer_id": 74459520, "author": "Shayan", "author_id": 11747148, "author_profile": "https://Stackoverflow.com/users/11747148", "pm_score": 3, "selected": true, "text": "function str2vec(s::String)\n return map(x->parse(Int,x), split(s,\"\"))\nend\n" }, { "answer_id": 74467114, "author": "Sundar R", "author_id": 8127, "author_profile": "https://Stackoverflow.com/users/8127", "pm_score": 1, "selected": false, "text": "digits" }, { "answer_id": 74472260, "author": "DNF", "author_id": 2749865, "author_profile": "https://Stackoverflow.com/users/2749865", "pm_score": 1, "selected": false, "text": "Iterators.map" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17698532/" ]
74,459,125
<p>i want to work with the variable &quot;sets&quot; after the function has been called.</p> <p>How can i do this?</p> <pre><code>sets = 0 def search_str(monatsabrechnung, d1): with open(monatsabrechnung, 'r') as file: content = file.read() if lastDay == heute and ja == 1: sets = 1 else: pass search_str(monatsabrechnung, d1) print(sets) </code></pre>
[ { "answer_id": 74459267, "author": "Akshay Sehgal", "author_id": 4755954, "author_profile": "https://Stackoverflow.com/users/4755954", "pm_score": 2, "selected": true, "text": "sets" }, { "answer_id": 74459273, "author": "Matthias", "author_id": 1209921, "author_profile": "https://Stackoverflow.com/users/1209921", "pm_score": 0, "selected": false, "text": "sets" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20229777/" ]
74,459,134
<p>I am working on my flutter project where I want to use sharedpreferences. Look at the code below:</p> <pre><code>Future&lt;String?&gt; getCredentials() async { final localStorage = await SharedPreferences.getInstance(); final email = localStorage.getString('email'); final password = localStorage.getString('password'); return email, password; } </code></pre> <p>This is my getCredentials funtion I want this function to return email and password as different parameters but dart doesn't allow me can you please help me How can I do it?</p> <p>Whole SharedPreference Code:</p> <pre><code>import 'package:shared_preferences/shared_preferences.dart'; class sharedPreference { Future&lt;String?&gt; saveCredentials({ required String email, required String password, }) async { final localStorage = await SharedPreferences.getInstance(); await localStorage.setString('email', email); await localStorage.setString('password', password); } Future&lt;String?&gt; getCredentials() async { final localStorage = await SharedPreferences.getInstance(); final email = localStorage.getString('email'); final password = localStorage.getString('password'); return email, password; } } </code></pre>
[ { "answer_id": 74459184, "author": "Irfan Ganatra", "author_id": 18817235, "author_profile": "https://Stackoverflow.com/users/18817235", "pm_score": 0, "selected": false, "text": "Future<Map<String,dynamic>> getCredentials() async {\n final localStorage = await SharedPreferences.getInstance();\n final email = localStorage.getString('email');\n final password = localStorage.getString('password');\n return {\n'email':email,\n'password':password\n\n};\n}\n" }, { "answer_id": 74459363, "author": "LacticWhale", "author_id": 11962301, "author_profile": "https://Stackoverflow.com/users/11962301", "pm_score": 3, "selected": true, "text": "class Credentials {\n Credentials(this.email, this.passwordHash);\n\n final String email;\n final String passwordHash;\n}\n\nFuture<Credentials> getCredentials() async {\n final localStorage = await SharedPreferences.getInstance();\n final email = localStorage.getString('email');\n final passwordHash = localStorage.getString('passwordHash');\n return Credentials(email, passwordHash));\n}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10535413/" ]
74,459,145
<p>Is basically a mathematical question, would like to know what would be a good solution.</p> <p>Problem: I have 25 images placed in one line. I want the images to fade out in the order. That is the first image should be completely opaque and last image should be completely transparent. I have placed all these images in an order inside one parent.</p> <p>My solution: I am just providing a fixed number that iterates itself for the alpha.</p> <p>What I am looking for: a formula so that this &quot;fixed&quot; number can be dynamically changed by number of images present.</p> <pre><code>void Start () { int color = 10; //my fixed number foreach (Transform child in transform) { child.gameObject.GetComponent&lt;Image&gt;().color = new Color32(255, 255, 255, (byte) (255 - color)); color += 10; //iterating for the next child } } </code></pre>
[ { "answer_id": 74459184, "author": "Irfan Ganatra", "author_id": 18817235, "author_profile": "https://Stackoverflow.com/users/18817235", "pm_score": 0, "selected": false, "text": "Future<Map<String,dynamic>> getCredentials() async {\n final localStorage = await SharedPreferences.getInstance();\n final email = localStorage.getString('email');\n final password = localStorage.getString('password');\n return {\n'email':email,\n'password':password\n\n};\n}\n" }, { "answer_id": 74459363, "author": "LacticWhale", "author_id": 11962301, "author_profile": "https://Stackoverflow.com/users/11962301", "pm_score": 3, "selected": true, "text": "class Credentials {\n Credentials(this.email, this.passwordHash);\n\n final String email;\n final String passwordHash;\n}\n\nFuture<Credentials> getCredentials() async {\n final localStorage = await SharedPreferences.getInstance();\n final email = localStorage.getString('email');\n final passwordHash = localStorage.getString('passwordHash');\n return Credentials(email, passwordHash));\n}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17561671/" ]
74,459,163
<pre><code> UPDATE work_info as info1 SET info1.status_id = 1 WHERE info1.info_id IN( SELECT info2.info_id FROM work_info as info2 WHERE info2.info_id IN ( SELECT MAX(info3.info_id) FROM work_info as info3 GROUP BY info3.user_license_id) AND info2.status_id = 5) </code></pre> <p>Getting this error #1093 - You can't specify target table 'info1' for update in FROM clause</p>
[ { "answer_id": 74459222, "author": "Nahume", "author_id": 11988032, "author_profile": "https://Stackoverflow.com/users/11988032", "pm_score": 0, "selected": false, "text": "UPDATE table SET a=value WHERE x IN\n (SELECT x FROM table WHERE condition);\n" }, { "answer_id": 74459566, "author": "Akina", "author_id": 10138734, "author_profile": "https://Stackoverflow.com/users/10138734", "pm_score": 2, "selected": false, "text": "UPDATE work_info as info1\nJOIN work_info as info2 USING (info_id)\nJOIN ( SELECT MAX(info_id) info_id\n FROM work_info\n GROUP BY user_license_id \n ) as info3 USING (info_id)\nSET info1.status_id = 1\nWHERE info2.status_id = 5;\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1321511/" ]
74,459,169
<p>Suppose I have a Numpy array of a bunch of coordinates [x, y]. I want to filter this array. <br> For all coordinates in the array with a same x-value, I want to keep only one coordinate: <br>The coordinate with the maximum for the y.<br> What is the most efficient or Pythonic way to do this. I will explain with an example below.</p> <pre><code>coord_arr= array([[10,5], [11,6], [12,6], [10,1], [11,0],[12,2]]) </code></pre> <p>[10, 5] and [10,1] have the same x-value: x=10<br> maximum for y-values: <br>max(5,1) = 5<br> So I only keep coordinate [10,5]</p> <p>Same procedure for x=11 and x=12<br> So I finally end up with:</p> <pre><code>filtered_coord_arr= array([[10,5],[11,6],[12,6]]) </code></pre> <p>I have a solution by converting to a list and using list comprehension (see below).<br> But I am looking for a more efficient and elegant solution. <br>(The actual arrays are much larger than in this example.)<br> My solution:</p> <pre><code>coord_list = coord_arr.tolist() x_set = set([coord[0] for coord in coord_list]) coord_max_y_list= [] for x in x_set: compare_list=[coord for coord in coord_list if coord[0]==x] coord_max = compare_list[compare_list.index(max([coord[1] for coord[1] in compare_list]))] coord_max_y_list.append(coord_max) filtered_coord_arr= np.array(coord_max_y_list) </code></pre>
[ { "answer_id": 74460932, "author": "vipul prajapati", "author_id": 20510562, "author_profile": "https://Stackoverflow.com/users/20510562", "pm_score": 0, "selected": false, "text": "coord_arr= np.array([[10, 5], [11, 6], [12, 6], [13,7], [10,1], [10,7],[12,2], [13,0]])\n\ndf = pd.DataFrame(coord_arr,columns=['a','b'])\ndf = df.groupby(['a']).agg({'b': ['max']})\ndf.columns = ['b']\ndf = df.reset_index()\nfiltered_coord_arr = np.array(df)\n\nfiltered_coord_arr\n" }, { "answer_id": 74461388, "author": "amirhm", "author_id": 4529589, "author_profile": "https://Stackoverflow.com/users/4529589", "pm_score": 3, "selected": true, "text": "np.array([[x, max(coord[coord[:,0] == x][:,1])] for x in set(coord[:,0])])\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6835645/" ]
74,459,179
<p>TypeScript experts!</p> <p>I'm writing a flexible TypeScript function which accepts both type of arguments: class A and B. A and B are independent and not an inherited. However, I need to deny the ambiguous usage of the function called with the union type <code>A | B</code>. Is there any way to declare this in TypeScript? Note: The function must be a very single function but not separated functions for each usages.</p> <pre class="lang-js prettyprint-override"><code>class A {/* snip */} class B {/* snip */} let a:A = new A(); fn(a); // definitive usage is OK let b:B = new B(); fn(b); // definitive usage is OK let c:(A|B) = somecondition ? new A() : new B(); fn(c); // ambiguous usage should throw TypeScript compilation error here. </code></pre> <hr /> <p>Edited: Thank you for answers! I'm sorry but the case above was not the exact correct case. I need a function which accepts a collection of multiple arguments with a rest parameter as below:</p> <pre class="lang-js prettyprint-override"><code>class A {/* snip */} class B {/* snip */} let a:A = new A(); let b:B = new B(); let c:(A|B) = somecondition ? new A() : new B(); interface Fn { (...args: V[]) =&gt; void; } const fn: Fn = (...args) =&gt; {/* snip */}; fn(a); // single definitive usage is OK fn(b); // single definitive usage is OK fn(a, b, a, b); // multiple definitive usage is still OK fn(c); // ambiguous usage should throw TypeScript compilation error here. </code></pre>
[ { "answer_id": 74459307, "author": "Radu Diță", "author_id": 2054602, "author_profile": "https://Stackoverflow.com/users/2054602", "pm_score": 0, "selected": false, "text": "A | B" }, { "answer_id": 74459401, "author": "Tobias S.", "author_id": 8613630, "author_profile": "https://Stackoverflow.com/users/8613630", "pm_score": 2, "selected": true, "text": "A" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8128932/" ]
74,459,187
<p>I have this <code>Dockerfile</code> where I want to build a spring boot project with gradle then run it but the build takes up to 100 seconds to finish but in my local machine it builds fast. I'm sure it's a caching issue but I don't know how to speed it up and I'm kind of new to Docker</p> <pre><code>FROM gradle:7.5.1-jdk11-alpine AS build COPY --chown=gradle:gradle . /home/gradle/src WORKDIR /home/gradle/src RUN gradle clean build --no-daemon FROM openjdk:11.0.11-jre-slim-buster EXPOSE 8080 RUN mkdir /app COPY --from=build /home/gradle/src/build/libs/*.jar /app/demo.jar ENTRYPOINT [&quot;java&quot;, &quot;-jar&quot;, &quot;/app/demo.jar&quot;] </code></pre>
[ { "answer_id": 74459307, "author": "Radu Diță", "author_id": 2054602, "author_profile": "https://Stackoverflow.com/users/2054602", "pm_score": 0, "selected": false, "text": "A | B" }, { "answer_id": 74459401, "author": "Tobias S.", "author_id": 8613630, "author_profile": "https://Stackoverflow.com/users/8613630", "pm_score": 2, "selected": true, "text": "A" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16644396/" ]
74,459,195
<pre><code>Script works in Firefox, but in Safari and Chrome console it doesn't and shows error &quot;Cannot access to uninitialized variable&quot; in passLeft.textContent = &quot;&quot; line. Script is generating the password after pressing button in html script. I need this line to reset the output field every time after the button is pressed. const characters = [&quot;A&quot;,&quot;B&quot;,&quot;C&quot;,&quot;D&quot;,&quot;E&quot;,&quot;F&quot;,&quot;G&quot;,&quot;H&quot;,&quot;I&quot;,&quot;J&quot;,&quot;K&quot;,&quot;L&quot;,&quot;M&quot;,&quot;N&quot;,&quot;O&quot;,&quot;P&quot;,&quot;Q&quot;,&quot;R&quot;,&quot;S&quot;,&quot;T&quot;,&quot;U&quot;,&quot;V&quot;,&quot;W&quot;,&quot;X&quot;,&quot;Y&quot;,&quot;Z&quot;,&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;,&quot;f&quot;,&quot;g&quot;,&quot;h&quot;,&quot;i&quot;,&quot;j&quot;,&quot;k&quot;,&quot;l&quot;,&quot;m&quot;,&quot;n&quot;,&quot;o&quot;,&quot;p&quot;,&quot;q&quot;,&quot;r&quot;,&quot;s&quot;,&quot;t&quot;,&quot;u&quot;,&quot;v&quot;,&quot;w&quot;,&quot;x&quot;,&quot;y&quot;,&quot;z&quot;, &quot;0&quot;, &quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;, &quot;5&quot;, &quot;6&quot;, &quot;7&quot;, &quot;8&quot;, &quot;9&quot;,&quot;~&quot;,&quot;`&quot;,&quot;!&quot;,&quot;@&quot;,&quot;#&quot;,&quot;$&quot;,&quot;%&quot;,&quot;^&quot;,&quot;&amp;&quot;,&quot;*&quot;,&quot;(&quot;,&quot;)&quot;,&quot;_&quot;,&quot;-&quot;,&quot;+&quot;,&quot;=&quot;,&quot;{&quot;,&quot;[&quot;,&quot;}&quot;,&quot;]&quot;,&quot;,&quot;,&quot;|&quot;,&quot;:&quot;,&quot;;&quot;,&quot;&lt;&quot;,&quot;&gt;&quot;,&quot;.&quot;,&quot;?&quot;, &quot;/&quot;]; let passLeft = document.getElementById(&quot;outputLeft&quot;) let passRight = document.getElementById(&quot;outputRight&quot;) passLeft.textContent = &quot;*****&quot; passRight.textContent = &quot;*****&quot; function generatePassword() { passLeft.textContent = &quot;&quot; passRight.textContent = &quot;&quot; for (let i = 0; i &lt; 16; i++) { let l = Math.floor(Math.random() * characters.length) // calls random array cell passLeft.textContent += characters[l] } for (let i = 0; i &lt; 16; i++) { let l = Math.floor(Math.random() * characters.length) // calls random array cell passRight.textContent += characters[l] } } </code></pre> <p>What ever value i put in passLeft.textContent = &quot;&quot; line, after pressing the button the error is the same:&quot;Cannot access uninitialized variable.&quot; The error happens in Safari and Chrome, but in Firefox everything works ok.</p> <p>This is my HTML file:</p> <pre><code>&lt;head&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css&quot;&gt; &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.googleapis.com&quot;&gt; &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.gstatic.com&quot; crossorigin&gt; &lt;link href=&quot;https://fonts.googleapis.com/css2?family=Karla:wght@200;400;800&amp;display=swap&quot; rel=&quot;stylesheet&quot;&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;index.css&quot;&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Generate a &lt;div class=&quot;rnd&quot;&gt;random password&lt;/div&gt;&lt;/h1&gt; &lt;p&gt; Never use insecure password again.&lt;/p&gt; &lt;button onclick=&quot;generatePassword()&quot;&gt;Generate passwords&lt;/button&gt; &lt;hr&gt; &lt;div class=&quot;container&quot;&gt; &lt;div id=&quot;outputLeft&quot; class=&quot;output&quot;&gt;&lt;/div&gt; &lt;div id=&quot;outputRight&quot; class=&quot;output&quot;&gt;&lt;/div&gt; &lt;/div&gt; &lt;script src=&quot;index.js&quot;&gt;&lt;/script&gt; &lt;/body&gt; </code></pre> <p><a href="https://i.stack.imgur.com/V91LO.png" rel="nofollow noreferrer">full error stack screeshot</a></p>
[ { "answer_id": 74459446, "author": "John Paul Grefaldo", "author_id": 7006983, "author_profile": "https://Stackoverflow.com/users/7006983", "pm_score": 1, "selected": false, "text": "ID" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20308882/" ]
74,459,232
<p>So I was <strong>writing a weather app program which tells you based on your input what things u should do</strong> but someone how the error is as shown in the image.kindly excuse me for such a question actually I am just a beginner so I needed a help! I thought for the Winter input it will show me Wear a cool Jacket but instead it should me Wear cap.I don't know whats's the issue kindly help.</p> <p><a href="https://i.stack.imgur.com/8oJyy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8oJyy.png" alt="Error Which I am facing" /></a></p> <pre><code>// Question: // Write a weather app if Summer=&gt;Wear Cap Winter=&gt;Wear a cool Jacket Rainy=&gt; Oh! You need to carry an Umbrella // GuideLines console.log(&quot;Welcome to the Weather app \n&quot;) console.log(&quot;Kindly Tell What Kind of weather you are experiencing \n&quot;) console.log(&quot;Type: Rainy or rainy if raining \n&quot;) console.log(&quot;Type: Summer or summer if it is hot summer \n&quot;) console.log(&quot;Type: Winter or winter if it is cool freezy winter \n&quot;) // Taking Input let weather = (prompt(&quot;What Kind of weather you are experiencing?&quot;)) // Conditions if(weather===&quot;Summer&quot; || &quot;summer&quot;){ console.log(&quot;Wear Cap&quot;) } else if(weather ===&quot;Winter&quot; || weather==&quot;winter&quot;){ console.log(&quot;Wear a cool Jacket&quot;) }else if (weather=== &quot;Rainy&quot; || &quot;rainy&quot;){ console.log(&quot;Oh! You need to carry an Umbrella&quot;) }else { console.log(&quot;Hmm! It seems an invalid input. Kindly read the Guidelines&quot;) } </code></pre> <p>I thought for the Winter input it will show me Wear a cool Jacket but instead it should me Wear cap. I don't know whats's the issue kindly help</p>
[ { "answer_id": 74459328, "author": "YSFKBDY", "author_id": 6166703, "author_profile": "https://Stackoverflow.com/users/6166703", "pm_score": 2, "selected": false, "text": "if(weather == \"Summer\" || weather == \"summer\"){\n console.log(\"Wear Cap\")\n} else if(weather == \"Winter\" || weather == \"winter\"){\n console.log(\"Wear a cool Jacket\")\n} else if (weather == \"Rainy\" || weather == \"rainy\"){\n console.log(\"Oh! You need to carry an Umbrella\")\n} else {\n console.log(\"Hmm! It seems an invalid input. Kindly read the Guidelines\")\n}\n" }, { "answer_id": 74460612, "author": "Peter Seliger", "author_id": 2627243, "author_profile": "https://Stackoverflow.com/users/2627243", "pm_score": 1, "selected": false, "text": "trim" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20026645/" ]
74,459,253
<p>I'm using Python 3.10 and I'm trying to subtract two time values from each other. Now I have tried bunch of ways to do that but getting errors.</p> <pre><code>day_time = timezone.now() day_name = day_time.strftime(&quot;%Y-%m-%d %H:%M:%S&quot;) end_Time = datetime.strptime(latest_slots.end_hour, '%Y-%m-%d %H:%M:%S') print(end_Time- day_name) </code></pre> <p><strong>error:</strong> <code>TypeError: unsupported operand type(s) for -: 'str' and 'str'</code></p> <p>I also tried:</p> <pre><code>day_time = timezone.now() end_Time = datetime.strptime(latest_slots.end_hour, '%Y-%m-%d %H:%M:%S') print(end_Time- day_time) </code></pre> <p><strong>error:</strong> <code>TypeError: can't subtract offset-naive and offset-aware datetimes</code></p> <p>And this as well:</p> <pre><code>day_time = timezone.now() end_Time = datetime.strptime(latest_slots.end_hour, '%Y-%m-%d %H:%M:%S.000000.00+00') print(end_Time- day_time) </code></pre> <p><strong>error:</strong> <code>ValueError: time data '2022-11-27 00:00:00' does not match format '%Y-%m-%d %H:%M:%S.000000.00+00'</code></p>
[ { "answer_id": 74459328, "author": "YSFKBDY", "author_id": 6166703, "author_profile": "https://Stackoverflow.com/users/6166703", "pm_score": 2, "selected": false, "text": "if(weather == \"Summer\" || weather == \"summer\"){\n console.log(\"Wear Cap\")\n} else if(weather == \"Winter\" || weather == \"winter\"){\n console.log(\"Wear a cool Jacket\")\n} else if (weather == \"Rainy\" || weather == \"rainy\"){\n console.log(\"Oh! You need to carry an Umbrella\")\n} else {\n console.log(\"Hmm! It seems an invalid input. Kindly read the Guidelines\")\n}\n" }, { "answer_id": 74460612, "author": "Peter Seliger", "author_id": 2627243, "author_profile": "https://Stackoverflow.com/users/2627243", "pm_score": 1, "selected": false, "text": "trim" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20286415/" ]
74,459,254
<p>I am trying to connect a device to be provisioned using Azure IoT.</p> <p>I have tried creating certificates in multiple ways following multiple tutorials on Azure SDK github and Azure documentation.</p> <p>I am using a sample program <code>prov_dev_client_ll_x509_sample</code> found <a href="https://github.com/Azure/azure-iot-sdk-c/tree/main/provisioning_client/samples/prov_dev_client_ll_x509_sample" rel="nofollow noreferrer">here</a> and modified only the <code>id_scope</code>, <code>registration_id</code>, <code>x509certificate</code> and <code>x509privatekey</code>.</p> <p>Here are the logs from the program.</p> <pre><code>Provisioning API Version: 1.9.1 Iothub API Version: 1.9.1 -&gt; 12:35:15 CONNECT | VER: 4 | KEEPALIVE: 0 | FLAGS: 130 | USERNAME: XXX&amp;ClientVersion=1.9.1 | CLEAN: 1 &lt;- 12:35:15 CONNACK | SESSION_PRESENT: false | RETURN_CODE: 0x0 -&gt; 12:35:15 SUBSCRIBE | PACKET_ID: 1 | TOPIC_NAME: $dps/registrations/res/# | QOS: 1 Provisioning Status: PROV_DEVICE_REG_STATUS_CONNECTED &lt;- 12:35:15 SUBACK | PACKET_ID: 1 | RETURN_CODE: 1 -&gt; 12:35:15 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $dps/registrations/PUT/iotdps-register/?$rid=1 | PAYLOAD_LEN: 33 &lt;- 12:35:15 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_LEAST_ONCE | TOPIC_NAME: $dps/registrations/res/202/?$rid=1&amp;retry-after=3 | PACKET_ID: 2 | PAYLOAD_LEN: 94 -&gt; 12:35:15 PUBACK | PACKET_ID: 2 Provisioning Status: PROV_DEVICE_REG_STATUS_ASSIGNING -&gt; 12:35:18 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $dps/registrations/GET/iotdps-get-operationstatus/?$rid=2&amp;operationId=XXX | PAYLOAD_LEN: 33 &lt;- 12:35:18 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_LEAST_ONCE | TOPIC_NAME: $dps/registrations/res/200/?$rid=2 | PACKET_ID: 2 | PAYLOAD_LEN: 539 -&gt; 12:35:18 PUBACK | PACKET_ID: 2 Error: Time:Wed Nov 16 12:35:18 2022 File:XXX/provisioning_client/src/prov_device_ll_client.c Func:prov_transport_process_json_reply Line:665 Provisioning Failure: OperationId: XXX - Date: 2022-11-16T10:35:16.1700914Z - Msg: {&quot;Message&quot;:&quot;ErrorCode:IotHubUnauthorizedAccess;Unauthorized&quot;,&quot;ExceptionMessage&quot;:&quot;Tracking ID:88b6478739ba4e5aa031400ff6df0078-G:0-TimeStamp:11/16/2022 10:35:15&quot;} Error: Time:Wed Nov 16 12:35:18 2022 File:XXX/provisioning_client/src/prov_transport_mqtt_common.c Func:prov_transport_common_mqtt_dowork Line:979 Unable to process registration reply. Error: Time:Wed Nov 16 12:35:18 2022 File:XXX/provisioning_client/src/prov_device_ll_client.c Func:on_transport_registration_data Line:777 Failure retrieving data from the provisioning service Failure encountered on registration PROV_DEVICE_RESULT_DEV_AUTH_ERROR -&gt; 12:35:18 DISCONNECT registration failed! </code></pre> <p>It seems that the requests at first return success as seen by <code>$dps/registrations/res/200/?$rid=2</code> but the error message does not provide much insight to the problem. Has anyone encountered this error?</p>
[ { "answer_id": 74459328, "author": "YSFKBDY", "author_id": 6166703, "author_profile": "https://Stackoverflow.com/users/6166703", "pm_score": 2, "selected": false, "text": "if(weather == \"Summer\" || weather == \"summer\"){\n console.log(\"Wear Cap\")\n} else if(weather == \"Winter\" || weather == \"winter\"){\n console.log(\"Wear a cool Jacket\")\n} else if (weather == \"Rainy\" || weather == \"rainy\"){\n console.log(\"Oh! You need to carry an Umbrella\")\n} else {\n console.log(\"Hmm! It seems an invalid input. Kindly read the Guidelines\")\n}\n" }, { "answer_id": 74460612, "author": "Peter Seliger", "author_id": 2627243, "author_profile": "https://Stackoverflow.com/users/2627243", "pm_score": 1, "selected": false, "text": "trim" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14984008/" ]
74,459,264
<p>I want to make the player face the cursor in a 3d game, to do so I added this code to the player</p> <pre><code>void Update() { Vector3 objectPos = cam.WorldToScreenPoint(transform.position); mousePos.x = mousePos.x - objectPos.x; mousePos.y = mousePos.y - objectPos.y; float angle = Mathf.Atan2(mousePos.y, mousePos.x) * Mathf.Rad2Deg; transform.rotation = Quaternion.Euler(new Vector3(0, 90- angle, 0)); } </code></pre> <p>This works when the camera is facing the player but as I turn around the player it does not follow the cursor anymore. When I stop (for example the camera now is behind the player or at the left) the player rotates facing the wrong position.</p>
[ { "answer_id": 74459328, "author": "YSFKBDY", "author_id": 6166703, "author_profile": "https://Stackoverflow.com/users/6166703", "pm_score": 2, "selected": false, "text": "if(weather == \"Summer\" || weather == \"summer\"){\n console.log(\"Wear Cap\")\n} else if(weather == \"Winter\" || weather == \"winter\"){\n console.log(\"Wear a cool Jacket\")\n} else if (weather == \"Rainy\" || weather == \"rainy\"){\n console.log(\"Oh! You need to carry an Umbrella\")\n} else {\n console.log(\"Hmm! It seems an invalid input. Kindly read the Guidelines\")\n}\n" }, { "answer_id": 74460612, "author": "Peter Seliger", "author_id": 2627243, "author_profile": "https://Stackoverflow.com/users/2627243", "pm_score": 1, "selected": false, "text": "trim" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19728542/" ]
74,459,297
<p>I am trying to implement a basic date picker inside a dialog exactly as described in the documentation but it does not show the calendar icon correctly. Here is how it looks like: <a href="https://i.stack.imgur.com/McjSl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/McjSl.png" alt="datepicker-problem" /></a></p> <p>Here is the html template code for the dialog:</p> <pre><code>&lt;div class=&quot;dialog-header&quot;&gt; &lt;button mat-icon-button tabindex=&quot;-1&quot; (click)=&quot;cancel()&quot;&gt; &lt;mat-icon&gt;close&lt;/mat-icon&gt; &lt;/button&gt; &lt;/div&gt; &lt;div mat-dialog-content&gt; &lt;mat-form-field appearance=&quot;fill&quot;&gt; &lt;mat-label&gt;Choose a date&lt;/mat-label&gt; &lt;input matInput [matDatepicker]=&quot;picker&quot; /&gt; &lt;mat-hint&gt;MM/DD/YYYY&lt;/mat-hint&gt; &lt;mat-datepicker-toggle matIconSuffix [for]=&quot;picker&quot;&gt;&lt;/mat-datepicker-toggle&gt; &lt;mat-datepicker #picker&gt;&lt;/mat-datepicker&gt; &lt;/mat-form-field&gt; &lt;/div&gt; </code></pre> <p>And here is the css code:</p> <pre><code>:host { display: flex; flex-direction: column; height: 100%; } .dialog-header { display: flex; flex-direction: row; margin: -10px -10px 10px; &amp; &gt; h1 { margin: auto 0; } &amp; &gt; .mat-icon-button { margin-left: auto; margin-bottom: auto; } } .mat-dialog-content { width: 100%; display: flex; max-height: unset; } </code></pre> <p>I have already tried to remove almost all CSS of all container components but it does not matter, the datepicker is always displayed with this broken layout. I also have no global styles or anything else that could cause this, so I am completely clueless about what is going on here.</p>
[ { "answer_id": 74459529, "author": "Chris", "author_id": 11425760, "author_profile": "https://Stackoverflow.com/users/11425760", "pm_score": 0, "selected": false, "text": "matIconSuffix" }, { "answer_id": 74459541, "author": "TotallyNewb", "author_id": 4550158, "author_profile": "https://Stackoverflow.com/users/4550158", "pm_score": 1, "selected": false, "text": "matSuffix" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11425760/" ]
74,459,300
<p>I have a Radio list tile in which I am setting the gender(male, female and other). Initially, the list tile is checked on 'male'. can I put it to be initially unchecked so the user can check it by himself?</p> <pre><code>Container( width: 400 height: 200 RadioListTile&lt;Gender?&gt;( title: Text( radioLabel == Gender.man ? 'MR.': radioLabel ==Gender.women ? 'Ms.': 'other', ), value: radioLabel, groupValue: widget.Gender.value, onChanged: (Gender? value) { if (value != null) { setState(() { widget.Gender.value = value; }); } }, ), ) </code></pre>
[ { "answer_id": 74459529, "author": "Chris", "author_id": 11425760, "author_profile": "https://Stackoverflow.com/users/11425760", "pm_score": 0, "selected": false, "text": "matIconSuffix" }, { "answer_id": 74459541, "author": "TotallyNewb", "author_id": 4550158, "author_profile": "https://Stackoverflow.com/users/4550158", "pm_score": 1, "selected": false, "text": "matSuffix" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20503995/" ]
74,459,320
<p>The example below uses <a href="https://docs.gitlab.com/ee/ci/yaml/#needs" rel="nofollow noreferrer"><code>needs</code></a> to start the second_job after the first_job. However, second_job no longer has access to the artefact of the pre_job. Obviously we could add <code>needs: [pre_job, first_job]</code>, but there are multiple jobs in the <code>.pre</code> stage and we want to download all of their artifacts (without knowing which jobs are run exactly).</p> <p>Is there a setting, where <code>needs</code> only affects the job order, but not the artifact downloading?</p> <pre class="lang-yaml prettyprint-override"><code>pre_job: stage: .pre script: - touch pre.txt artifacts: paths: - pre.txt first_job: stage: check script: - touch first.txt artifacts: paths: - first.txt second_job: stage: check script: - cat pre.txt needs: - first_job </code></pre>
[ { "answer_id": 74483343, "author": "Benjamin", "author_id": 14406845, "author_profile": "https://Stackoverflow.com/users/14406845", "pm_score": 1, "selected": false, "text": "second_job:\n stage: check\n script:\n - cat pre.txt\n needs:\n - job: first_job\n artifacts: true\n - job: pre_job\n artifacts: true\n optional: true\n - job: other_pre_job\n artifacts: true\n optional: true\n - job: another_pre_job\n artifacts: true\n optional: true\n ... <etc> ...\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2135504/" ]
74,459,330
<p>I have two csv files with 200 columns each. The two files have the exact same numbers in rows and columns. I want to compare each columns separately.</p> <p>The idea would be to compare column 1 value of file &quot;a&quot; to column 1 value of file &quot;b&quot; and check the difference and so on for all the numbers in the column (there are 100 rows) and write out a number that in how many cases were the difference more than 3.</p> <p>I would like to repeat the same for all the columns.</p> <pre><code>import pandas as pd df=pd.read_csv('a.csv') de=pd.read_csv('b.csv') </code></pre>
[ { "answer_id": 74483343, "author": "Benjamin", "author_id": 14406845, "author_profile": "https://Stackoverflow.com/users/14406845", "pm_score": 1, "selected": false, "text": "second_job:\n stage: check\n script:\n - cat pre.txt\n needs:\n - job: first_job\n artifacts: true\n - job: pre_job\n artifacts: true\n optional: true\n - job: other_pre_job\n artifacts: true\n optional: true\n - job: another_pre_job\n artifacts: true\n optional: true\n ... <etc> ...\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20293646/" ]
74,459,338
<p>hi i'm new to python and i was working on a mini project but i have this problem with some of my list output where i and array instead of float in my list tried to convert it using astype(float) but still nothing changed here is my code :</p> <pre><code>import numpy as np import scipy.stats as st import numpy.random as rd from IPython.display import Markdown, display import pandas as pd service=['essence','gasoil','lavage','vidange'] #list of services prob=[0.5, 0.25, 0.16, 0.09] #probability of the services (50%,25%,16%,9%) λ = 2 #avrege cars per minute n=1440 #simulation for 1440 minute model=st.poisson(λ) #essence and gasoil simulation e ,g , σ = 2.12,1.99, 0.1 #'e'/'g' is the avrege time of pumping essence and gasoil / 'σ' is the gap m=1 model_e=st.norm(e, σ) model_g=st.norm(g, σ) #code J=30 #simulation for 1 mounth d=[] # a list for conversion #the list of different servvices essence=[] gasoil=[] vidange=[] lavage=[] for j in range(J): c=0 #the number of cars in a day simulation=model.rvs(n) for i in range(n): c +=simulation[i] #calculating the number of cars in eache day commandes=rd.choice(service, c, p=prob) d= commandes.tolist() #commandes is ndarray i need to transform it to list in order to use &quot;count&quot; simulation_e=model_e.rvs(m) simulation_e=simulation_e.astype(float) # treid to use astype(float) to convert array to list but did't work simulation_e=simulation_e*d.count('essence') essence.append(simulation_e) gasoil.append(d.count('gasoil')*model_g.rvs(m)) vidange.append(d.count('vidange')) lavage.append(d.count('lavage')) print(essence) print(&quot;\n&quot;) print(gasoil) print(&quot;\n&quot;) print(vidange) </code></pre> <p>this is the result that i get whene runing my code the array tag is always there in my list</p> <pre><code>[array([3049.02567421]), array([3115.46971158]), array([3057.74798456]), array([3169.46760693]), array([2993.79610725]), array([3075.71865925]), array([3204.53370577]), array([3129.65493394]), array([2975.22631282]), array([2945.63018474]), array([2843.09430445]), array([3314.12357151]), array([2796.23558937]), array([3123.59352839]), array([2983.00360539]), array([2883.79955281]), array([3056.7536885]), array([2556.95916304]), array([3050.10908716]), array([3226.86445445]), array([3282.64925171]), array([2922.09414665]), array([3127.7556254]), array([2901.03020042]), array([3186.59201801]), array([3100.92830043]), array([2920.10972545]), array([3279.21261218]), array([3189.59323404]), array([3120.11085555])] [array([1339.12703414]), array([1354.32216511]), array([1467.59247591]), array([1331.76259858]), array([1397.63279282]), array([1452.76958164]), array([1444.76437058]), array([1301.58913082]), array([1361.35320908]), array([1467.51667652]), array([1572.44383252]), array([1252.75929698]), array([1434.85771546]), array([1487.10124071]), array([1334.69536144]), array([1499.65478204]), array([1513.6470695]), array([1531.20406829]), array([1402.24883398]), array([1464.77013383]), array([1566.69506967]), array([1341.01313426]), array([1364.15290992]), array([1477.4313931]), array([1564.68352222]), array([1622.30631325]), array([1340.63426348]), array([1423.24463625]), array([1577.83964284]), array([1533.9487886])] [268, 247, 260, 246, 276, 263, 284, 270, 265, 280, 279, 244, 281, 247, 283, 257, 248, 241, 259, 240, 250, 237, 273, 273, 288, 256, 272, 254, 259, 279] </code></pre>
[ { "answer_id": 74483343, "author": "Benjamin", "author_id": 14406845, "author_profile": "https://Stackoverflow.com/users/14406845", "pm_score": 1, "selected": false, "text": "second_job:\n stage: check\n script:\n - cat pre.txt\n needs:\n - job: first_job\n artifacts: true\n - job: pre_job\n artifacts: true\n optional: true\n - job: other_pre_job\n artifacts: true\n optional: true\n - job: another_pre_job\n artifacts: true\n optional: true\n ... <etc> ...\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20517737/" ]
74,459,349
<p>I have a gcs bucket where there are multiple folders. I need to upload a file that is in my local to a particular folder in the GCS bucket. I am using the below code where it only uploads in the bucket directly but not in a folder of that bucket.</p> <pre><code>from google.cloud import storage def upload_to_bucket(destination_blob_name, path_to_file, bucket_name): &quot;&quot;&quot; Upload data to a bucket&quot;&quot;&quot; # Explicitly use service account credentials by specifying the private key # file. storage_client = storage.Client.from_service_account_json( 'service_account.json') bucket = storage_client.get_bucket(bucket_name) blob = bucket.blob(destination_blob_name) blob.upload_from_filename(path_to_file) return blob.public_url print(upload_to_bucket('hello_world.py', 'hello_world.py', 'gcs_bucket_name')) </code></pre> <p>Folder structure:</p> <pre><code>gcs_bucket_name folder_1 folder_2 </code></pre> <p>Can anyone tell me how to upload into a folder of GCS bucket?</p>
[ { "answer_id": 74459684, "author": "M. F. Bostanci", "author_id": 10812937, "author_profile": "https://Stackoverflow.com/users/10812937", "pm_score": 0, "selected": false, "text": "blob = bucket.blob(destination_blob_name)" }, { "answer_id": 74459728, "author": "Ferregina", "author_id": 12265927, "author_profile": "https://Stackoverflow.com/users/12265927", "pm_score": 2, "selected": true, "text": "destination_blob_name" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9798210/" ]
74,459,369
<p>I have a dataframe below and I want to insert a new row under shop with values, how do I do that ?</p> <pre><code>values = 0.2, park, false df1 = number variable values 1 NaN bank True 2 3.0 shop False 3 0.5 market True 4 NaN government True 5 1.0 hotel true </code></pre>
[ { "answer_id": 74459635, "author": "Sondre Gjengedal-Eide", "author_id": 9271598, "author_profile": "https://Stackoverflow.com/users/9271598", "pm_score": 0, "selected": false, "text": "df.loc[]" }, { "answer_id": 74461053, "author": "Harsha Biyani", "author_id": 3457761, "author_profile": "https://Stackoverflow.com/users/3457761", "pm_score": 1, "selected": false, "text": "import pandas as pd\n\ndf = pd.DataFrame({'number': [float('NaN'), 3.0, 0.5, float('NaN'), 1.0], 'variable':['bank','shop','market','government','hotel'], 'values':[True, False, True, True, True]})\nprint(\"----- ORIGINAL ------\")\nprint(df)\nshop_index = df.reset_index()['variable'].tolist().index('shop') \ninsert = pd.DataFrame({\"number\": 0.2, \"variable\": \"park\", \"values\": False}, index=[shop_index+1])\n\ndf2 = pd.concat([df.iloc[:shop_index+1], insert, df.iloc[shop_index+1:]]).reset_index(drop=True)\nprint(\"----- AFTER INSERT ------\")\nprint(df2)\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20479479/" ]
74,459,380
<p>I am trying to create a set of columns from a list taking a string from another column.</p> <p>I have found a temporary solution in <a href="https://www.stackoverflow.com/">this post</a> but it only creates one column if, for example, I have in String1 &quot;I have a dog and a cat&quot;.</p> <pre><code>In [7]: df[&quot;animal&quot;] = df[&quot;String1&quot;].map(lambda s: next((animal for animal in search_list if animal in s), &quot;other&quot;)) ...: In [8]: df Out[8]: weight String1 animal 0 70 Labrador is a dog dog 1 10 Abyssinian is a cat cat 2 65 German Shepard is a dog dog 3 1 pigeon is a bird other </code></pre> <p>How could I create two columns, like ['animal_1'] and ['animal_2'] to have both &quot;dog&quot; (in ['animal_1']) and &quot;cat&quot; in ['animal_2']?</p> <p>Desired output would be like below:</p> <pre><code> weight String1 animal_1 animal_2 0 70 Labrador is a dog dog 1 10 Abyssinian is a cat cat 2 65 German Shepard is a dog dog 3 1 pigeon is a bird other 4 30 I have a dog and a cat dog cat </code></pre>
[ { "answer_id": 74459635, "author": "Sondre Gjengedal-Eide", "author_id": 9271598, "author_profile": "https://Stackoverflow.com/users/9271598", "pm_score": 0, "selected": false, "text": "df.loc[]" }, { "answer_id": 74461053, "author": "Harsha Biyani", "author_id": 3457761, "author_profile": "https://Stackoverflow.com/users/3457761", "pm_score": 1, "selected": false, "text": "import pandas as pd\n\ndf = pd.DataFrame({'number': [float('NaN'), 3.0, 0.5, float('NaN'), 1.0], 'variable':['bank','shop','market','government','hotel'], 'values':[True, False, True, True, True]})\nprint(\"----- ORIGINAL ------\")\nprint(df)\nshop_index = df.reset_index()['variable'].tolist().index('shop') \ninsert = pd.DataFrame({\"number\": 0.2, \"variable\": \"park\", \"values\": False}, index=[shop_index+1])\n\ndf2 = pd.concat([df.iloc[:shop_index+1], insert, df.iloc[shop_index+1:]]).reset_index(drop=True)\nprint(\"----- AFTER INSERT ------\")\nprint(df2)\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11845900/" ]
74,459,402
<p>I have a pandas data frame like this:</p> <p><a href="https://i.stack.imgur.com/sFFMx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sFFMx.png" alt="Original data set" /></a></p> <p>and I need to convert it into the below:</p> <p><a href="https://i.stack.imgur.com/aliPo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aliPo.png" alt="Output data set " /></a></p> <p>So, the unique values in column 'camps' part of the original data set, gets turned into columns with values 0 and 1 for each id. How can I achieve this using Pandas or anything else in Python? Any help is greatly appreciated. Thanks</p> <p>Below is the code to create the original data set:</p> <pre><code>import pandas as pd cust = {'id': [212175, 286170, 361739, 297438, 415712, 415777, 261700, 314624, 170365, 333254], 'camps': [':_Camp1_CC SC_Statemt_CCSTMT', ':_Camp1_CC SC_Statemt_CCSTMT', ':_Camp1_Free_DS0742203H_BD03', ':_Camp1_Over_EO3982112A_BD07', ':_Camp1_Over_EO4022202A_BD16', ':_Camp1_Over_EO4022202A_BD16', ':_Camp1_AS07_DS0722204H_DD02', ':_Camp1_AS07_DS0722204H_DD02', ':_Camp1_AS07_DS0722204H_DD02', ':_Camp1_AS07_DS0722204H_DD02']} cust_df = pd.DataFrame(cust) </code></pre>
[ { "answer_id": 74459459, "author": "Ka Hung Au Yeung", "author_id": 8090506, "author_profile": "https://Stackoverflow.com/users/8090506", "pm_score": 1, "selected": false, "text": "pd.get_dummies()\n" }, { "answer_id": 74459754, "author": "PaulS", "author_id": 11564487, "author_profile": "https://Stackoverflow.com/users/11564487", "pm_score": 3, "selected": true, "text": "pd.crosstab" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9003900/" ]
74,459,440
<p>I have a table called addresses, it has a column name <code>user_ids</code> which is an array of the users who have that same address. When I request to <code>/api/addresses</code> what it returns is <code>{id:1,name:&quot;lorem&quot;, user_ids:[1,2]}</code>. I want it to return the users instead of their ids</p> <h1>this is the addresses model</h1> <pre><code> &lt;?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class Address extends Model { use HasFactory; protected $fillable = [ 'coordinates', 'title', 'description', 'user_ids', ]; protected $appends = ['user_ids']; protected $casts = [ 'user_ids' =&gt; 'array', ]; public function users() { return $this-&gt;belongsToMany(User::class,&quot;addresses&quot;); } } </code></pre> <h1>this is the create_table_addresses</h1> <pre><code>&lt;?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('addresses', function (Blueprint $table) { $table-&gt;id(); $table-&gt;string('coordinates'); $table-&gt;string('title'); $table-&gt;string('description'); $table-&gt;json(&quot;user_ids&quot;); $table-&gt;timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('addresses'); } }; </code></pre> <h1>addresses controller</h1> <pre><code>&lt;?php namespace App\Http\Controllers; use App\Http\Requests\StoreAddressRequest; use App\Http\Requests\UpdateAddressRequest; use App\Models\Address; class AddressController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { return Address::with('users')-&gt;get(); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \App\Http\Requests\StoreAddressRequest $request * @return \Illuminate\Http\Response */ public function store(StoreAddressRequest $request) { $address = Address::create($request-&gt;validated()); return response()-&gt;json($address, 201); } /** * Display the specified resource. * * @param \App\Models\Address $address * @return \Illuminate\Http\Response */ public function show(Address $address) { return $address; } /** * Show the form for editing the specified resource. * * @param \App\Models\Address $address * @return \Illuminate\Http\Response */ public function edit(Address $address) { // } /** * Update the specified resource in storage. * * @param \App\Http\Requests\UpdateAddressRequest $request * @param \App\Models\Address $address * @return \Illuminate\Http\Response */ public function update(UpdateAddressRequest $request, Address $address) { $address-&gt;update($request-&gt;validated()); return response()-&gt;json($address, 200); } /** * Remove the specified resource from storage. * * @param \App\Models\Address $address * @return \Illuminate\Http\Response */ public function destroy(Address $address) { $address-&gt;delete(); return response()-&gt;json(null, 204); } } </code></pre>
[ { "answer_id": 74459459, "author": "Ka Hung Au Yeung", "author_id": 8090506, "author_profile": "https://Stackoverflow.com/users/8090506", "pm_score": 1, "selected": false, "text": "pd.get_dummies()\n" }, { "answer_id": 74459754, "author": "PaulS", "author_id": 11564487, "author_profile": "https://Stackoverflow.com/users/11564487", "pm_score": 3, "selected": true, "text": "pd.crosstab" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20519044/" ]
74,459,453
<p>i have a table of employees with empnum,name, age , date of join.</p> <p>I need to find out count of records for the last 90 days , group by age. How can a write a query in TSQL.</p>
[ { "answer_id": 74459459, "author": "Ka Hung Au Yeung", "author_id": 8090506, "author_profile": "https://Stackoverflow.com/users/8090506", "pm_score": 1, "selected": false, "text": "pd.get_dummies()\n" }, { "answer_id": 74459754, "author": "PaulS", "author_id": 11564487, "author_profile": "https://Stackoverflow.com/users/11564487", "pm_score": 3, "selected": true, "text": "pd.crosstab" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2882218/" ]
74,459,462
<p>I am wondering why C++ does not perform RVO to <code>std::optional&lt;T&gt;</code> when returning <code>T</code>. I.e.,</p> <pre class="lang-cpp prettyprint-override"><code>struct Bar {}; std::optional&lt;Bar&gt; get_bar() { return Bar{}; // move ctor of Bar called here // instead of performing RVO } Bar get_bar2() { return Bar{}; // NO move ctor called // RVO performed } std::optional&lt;Bar&gt; get_bar_rvo() { std::optional&lt;Bar&gt; opt; opt.emplace(); return opt; // NO move ctor called // ROV performed } </code></pre> <p>In this above case, <code>get_bar2</code> performs RVO while <code>get_bar</code> does not.</p> <p>With a little bit more <em>hint</em>, the compiler is able to optimize <code>get_bar_rvo</code>, but the code get longer and annoying.</p> <p>From <a href="https://en.cppreference.com/w/cpp/language/copy_elision" rel="nofollow noreferrer">the reference</a>, I understand that <code>get_bar</code> does not meet the requirement of &quot;Mandatory elision of copy/move operations&quot;</p> <blockquote> <p>In the initialization of an object, when the initializer expression is a prvalue of the same class type (ignoring cv-qualification) as the variable type:</p> </blockquote> <p>Since <code>std::optional&lt;T&gt;</code> and <code>T</code> are <em>not</em> the same class type, so RVO is not mandatory.</p> <p>However, I <em>think</em> that performing RVO to <code>std::optional&lt;T&gt;</code> should be very easy and would be very useful, without the need to manually write the longer code as <code>get_bar_rvo</code>.<br /> Why my compile fails to recognize and optimize the <code>get_bar</code> just like <code>get_bar2</code>?</p> <p>Environments: MacOS</p> <pre><code>Apple clang version 13.1.6 (clang-1316.0.21.2.5) Target: arm64-apple-darwin21.6.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin </code></pre> <p>Compiled with <code>-std=c++17 -O3</code></p>
[ { "answer_id": 74460041, "author": "Nelfeal", "author_id": 3854570, "author_profile": "https://Stackoverflow.com/users/3854570", "pm_score": 3, "selected": true, "text": "get_bar_rvo" }, { "answer_id": 74460393, "author": "n. m.", "author_id": 775806, "author_profile": "https://Stackoverflow.com/users/775806", "pm_score": 1, "selected": false, "text": "get_bar()" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7974971/" ]
74,459,465
<p>I'm working on a responsive website. I want the nav to fly in from left on small screens. For testing I added a click listener which adds and removes the class &quot;.sidenav&quot; to the nav.</p> <p>Screen bigger than 800px:</p> <ul> <li>There is enough space for the nav so it is shown since beginning. For testing the click also works and you see the nav expanding with a smooth transition.</li> </ul> <p>Screen smaller than 800px:</p> <ul> <li>There is not enough space for the nav so it is hidden. When clicking the nav is shown but without a transition.</li> </ul> <p>Where is the mistake?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;Title&lt;/title&gt; &lt;style&gt; html { height: 100%; } body { display: grid; height: 100%; margin: 0; grid-template-rows: 5rem 1fr 5rem; } header { grid-area: 1 / 1 / span 1 / span 1; background-color: aqua; } nav { background-color: lightblue; position: fixed; top: 5rem; width: 0; display: none; transition: width 2s; } main { grid-area: 2 / 1 / span 1 / span 1; } .sidenav { display: unset; width: 20rem; } footer { grid-area: 3 / 1 / span 1 / span 1; background-color: chartreuse; } @media screen and (min-width: 800px) { body { grid-template-rows: 5rem 1fr 5rem; grid-template-columns: 10rem 1fr; } header { grid-area: 1 / 1 / span 1 / span 2; } nav { grid-area: 2 / 1 / span 1 / span 1; display: unset; width: 10rem; } main { grid-area: 2 / 2 / span 1 / span 2; } footer { grid-area: 3 / 1 / span 1 / span 2; } } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;header&gt;Header&lt;/header&gt; &lt;nav&gt;Navigation&lt;/nav&gt; &lt;main&gt;Main&lt;/main&gt; &lt;footer&gt;Footer&lt;/footer&gt; &lt;script&gt; window.onclick = () =&gt; { let classList = document.getElementsByTagName('nav')[0].classList; if (classList.contains('sidenav')) { classList.remove('sidenav') } else { classList.add('sidenav') } } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74459778, "author": "Franco Gabriel", "author_id": 19499461, "author_profile": "https://Stackoverflow.com/users/19499461", "pm_score": 1, "selected": false, "text": "display: none" }, { "answer_id": 74473993, "author": "Ero Stefano", "author_id": 5356628, "author_profile": "https://Stackoverflow.com/users/5356628", "pm_score": 1, "selected": true, "text": "display: none;" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5356628/" ]
74,459,546
<p>In older versions of ASP.Net core you had the startup.cs file where you would do a lot of the work including reading and setting the application environment then based on that you could read different version of the appsettings.json file. In the new ASP.Net Core 7 they got rid of Startup.cs and greatly streamlined the program.cs files. Now I can't figure out how to read the environment and then pass Entity Framework 7 my connection string. Looking around all the answers I find don't apply to version 7 or tell you to undo all the work in 7 by remaking the entire Startup.cs file. How are we supposed to inject the connection string based off the environment in .Net 7?</p> <p>I do have the code to read from the base appsettings.json file and that works, there is also a section to read the environment but it get setup AFTER the DbContext injection. Here is my program.cs file and I am just lost on what needs to be updated. I looked at the microsoft docs but did not see anything applying to environements and injection of the string.</p> <pre><code>var builder = WebApplication.CreateBuilder(args); //Add Services (builder.Services.AddScoped&lt;IService, Service&gt;(); builder.Services.AddScoped&lt;INavigationHelper, NavigationHelper&gt;(); builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme).AddMicrosoftIdentityWebApp(builder.Configuration.GetSection(&quot;AzureAd&quot;)); builder.Services.AddAuthorization(options =&gt; { options.FallbackPolicy = options.DefaultPolicy; }); builder.Services.AddControllersWithViews(options =&gt; { var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); options.Filters.Add(new AuthorizeFilter(policy)); }); builder.Services.AddRazorPages().AddMicrosoftIdentityUI(); builder.Services.AddDbContext&lt;SiteDbContext&gt;(options =&gt; options.UseSqlServer(builder.Configuration.GetConnectionString(&quot;Database&quot;))); var app = builder.Build(); if (!app.Environment.IsDevelopment()) { app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.MapRazorPages(); app.MapControllers(); app.Run(); </code></pre> <p>appsettings.json:</p> <pre><code>{ &quot;AzureAd&quot;: { &quot;Instance&quot;: &quot;https://login.microsoftonline.com/&quot;, &quot;Domain&quot;: &quot;&quot;, &quot;TenantId&quot;: &quot;&quot;, &quot;ClientId&quot;: &quot;&quot;, &quot;CallbackPath&quot;: &quot;&quot;, &quot;ClientSecret&quot;: &quot;Client secret from app-registration. Check user secrets/azure portal.&quot;, &quot;ClientCertificates&quot;: [ ] }, &quot;Logging&quot;: { &quot;LogLevel&quot;: { &quot;Default&quot;: &quot;Information&quot;, &quot;Microsoft.AspNetCore&quot;: &quot;Warning&quot; } }, &quot;AllowedHosts&quot;: &quot;*&quot;, &quot;ConnectionStrings&quot;: { &quot;Database&quot;: &quot;&quot; } } </code></pre> <p>appsettings.development.json</p> <pre><code>{ &quot;Logging&quot;: { &quot;LogLevel&quot;: { &quot;Default&quot;: &quot;Information&quot;, &quot;Microsoft.AspNetCore&quot;: &quot;Warning&quot; }, &quot;ConnectionStrings&quot;: { &quot;Database&quot;: &quot;&quot; } } } </code></pre>
[ { "answer_id": 74460144, "author": "Shiham Samsudeen", "author_id": 6488792, "author_profile": "https://Stackoverflow.com/users/6488792", "pm_score": 0, "selected": false, "text": "using Microsoft.Extensions.Configuration;\n\nvar builder = WebApplication.CreateBuilder(args);\n\n// Add services to the container.\n\n var config = new ConfigurationBuilder()\n .AddJsonFile(\"appsettings.json\")\n .AddJsonFile($\"appsettings.{builder.Environment.EnvironmentName}.json\", optional: true)\n .Build();\n\nvar defaultConnectionString = config.GetConnectionString(\"Default\");\n\n\nConsole.WriteLine($\"Default ConnectionString: {defaultConnectionString}\");\n\n" }, { "answer_id": 74460234, "author": "Neil W", "author_id": 2936204, "author_profile": "https://Stackoverflow.com/users/2936204", "pm_score": 1, "selected": false, "text": "builder.Configuration.GetConnectionString(\"Database\")\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2911737/" ]
74,459,547
<p>Assume I have a form on <code>index.php</code> and it points to <code>test.php</code> which process the data submitted.</p> <p><code>index.php</code> looks like the below:</p> <pre><code>&lt;form action=&quot;test.php&quot;&gt;&lt;/form&gt; </code></pre> <p>It should cause an error if <code>test.php</code> looks like the below:</p> <p>( As you can see, there is already an output <code>Nice</code> being sent before the <code>header ()</code> )</p> <pre><code>echo 'Nice'; header ( &quot;Location: https://example.com&quot; ); </code></pre> <p>But what if I put it inside a function and call the function?</p> <pre><code>echo 'Nice'; function process () { header ( &quot;Location: https://example.com&quot; ); } process (); </code></pre> <p>Would it works in this case since it's inside a function, and would it cause an error?</p>
[ { "answer_id": 74459578, "author": "Diego D", "author_id": 1221208, "author_profile": "https://Stackoverflow.com/users/1221208", "pm_score": 2, "selected": false, "text": "header ( \"Location: https://example.com\" );\necho 'Nice';\n" }, { "answer_id": 74459668, "author": "IMSoP", "author_id": 157957, "author_profile": "https://Stackoverflow.com/users/157957", "pm_score": 0, "selected": false, "text": "header()" }, { "answer_id": 74459757, "author": "Neo", "author_id": 405238, "author_profile": "https://Stackoverflow.com/users/405238", "pm_score": 1, "selected": true, "text": "header ( \"Location: https://example.com\" );\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20454874/" ]
74,459,561
<p>I have three &lt;div class= emploBox &quot;&gt; and each has a button. Buttons do not have unique names. How can I find this particular button? I want to use class=cutTooLongTest and test 'automated tester' but I don't know how. wants to find the button marked in yellow.</p> <p><a href="https://i.stack.imgur.com/hDktc.png" rel="nofollow noreferrer">enter image description here</a></p> <p>I have no idea for a solution</p>
[ { "answer_id": 74459578, "author": "Diego D", "author_id": 1221208, "author_profile": "https://Stackoverflow.com/users/1221208", "pm_score": 2, "selected": false, "text": "header ( \"Location: https://example.com\" );\necho 'Nice';\n" }, { "answer_id": 74459668, "author": "IMSoP", "author_id": 157957, "author_profile": "https://Stackoverflow.com/users/157957", "pm_score": 0, "selected": false, "text": "header()" }, { "answer_id": 74459757, "author": "Neo", "author_id": 405238, "author_profile": "https://Stackoverflow.com/users/405238", "pm_score": 1, "selected": true, "text": "header ( \"Location: https://example.com\" );\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12200351/" ]
74,459,573
<p>I am implementing a Hexagonal Architecture with Domain Driven Design.</p> <p>I have a Value object called &quot;Address&quot; that has a &quot;validate()&quot; method. I would like to have a default validation provider for the address that is within my domain, but also allow external users to provide an overridden validator.</p> <p>So I created an AddressValidationAdapter interface that can be implemented by the outside world in &quot;dependency inversion&quot; manner.</p> <p>My question is - what is the best way to call my AddressValidationAdapter from within my Address class ?</p> <ul> <li>Do I need to add it as a dependency in its constructor ?</li> <li>Should I use some sort of global / static context ?</li> <li>Should I use event driven approach where I post a &quot;ValidationEvent&quot; within my domain and subscribe to a validation success notif ?</li> <li>Should I create a Service that orchestrates everything ? (Seems not very DDD like)</li> </ul> <p>Thank you very much for your thoughts. Best Regards Alex</p>
[ { "answer_id": 74459578, "author": "Diego D", "author_id": 1221208, "author_profile": "https://Stackoverflow.com/users/1221208", "pm_score": 2, "selected": false, "text": "header ( \"Location: https://example.com\" );\necho 'Nice';\n" }, { "answer_id": 74459668, "author": "IMSoP", "author_id": 157957, "author_profile": "https://Stackoverflow.com/users/157957", "pm_score": 0, "selected": false, "text": "header()" }, { "answer_id": 74459757, "author": "Neo", "author_id": 405238, "author_profile": "https://Stackoverflow.com/users/405238", "pm_score": 1, "selected": true, "text": "header ( \"Location: https://example.com\" );\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2599657/" ]
74,459,594
<p>I want to show the image title above the image after redirecting to user profile. I upload an image with a title and it only shows the image with the tags and user. I tried by adding the code in show.html.haml below but the title doesn't show at all. What I am doing wrong?</p> <p>photos_controller.rb</p> <pre><code>class PhotosController &lt; ApplicationController def create @user = User.find(params[:user_id]) if params[:photo][:title] == &quot;&quot; flash[:alert] = &quot;Please enter an image title&quot; redirect_to :back elsif params[:photo][:image] == nil flash[:alert] = &quot;Please upload a photo&quot; redirect_to :back else @photo = Photo.create(photo_params) @photo.user_id = @user.id @photo.save flash[:notice] = &quot;Successfully uploaded a photo&quot; redirect_to user_path(@user) end end def new @user = User.find(params[:user_id]) @photo = Photo.create() end private def photo_params params.require(:photo).permit(:image, :title) end end </code></pre> <p>photo.rb</p> <pre><code>class Photo&lt;ActiveRecord::Base belongs_to :user has_many :tags has_attached_file :image, :styles =&gt; { :medium =&gt; &quot;300x300&gt;&quot;, :thumb =&gt; &quot;100x100&gt;&quot; } validates_attachment_content_type :image, :content_type =&gt; /\Aimage\/.*\Z/ validates :title, :presence =&gt; true end </code></pre> <p>20150318211456_photos_table.rb</p> <pre><code>class PhotosTable &lt; ActiveRecord::Migration def change create_table :photos do |photons| photons.column :user_id, :integer photons.column :title, :string photons.timestamps end end end </code></pre> <p>new.html.haml</p> <pre><code>%h1 Add a Photo = form_for Photo.new(), :url =&gt; user_photos_path, :html =&gt; {:multipart =&gt; true} do |form| = form.label :title = form.text_field :title %br %br = form.file_field :image %br %br %br = form.submit 'Upload', class: &quot;btn btn-primary btn-lg&quot; </code></pre> <p>show.html.haml</p> <pre><code>= link_to @user_photos_path do = @photo.title = image_tag @photo.image.url = image_tag @photo.image.url(:thumb) </code></pre>
[ { "answer_id": 74459578, "author": "Diego D", "author_id": 1221208, "author_profile": "https://Stackoverflow.com/users/1221208", "pm_score": 2, "selected": false, "text": "header ( \"Location: https://example.com\" );\necho 'Nice';\n" }, { "answer_id": 74459668, "author": "IMSoP", "author_id": 157957, "author_profile": "https://Stackoverflow.com/users/157957", "pm_score": 0, "selected": false, "text": "header()" }, { "answer_id": 74459757, "author": "Neo", "author_id": 405238, "author_profile": "https://Stackoverflow.com/users/405238", "pm_score": 1, "selected": true, "text": "header ( \"Location: https://example.com\" );\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11353686/" ]
74,459,602
<p>I'm using a loop and a nested loop, and i need the outer loop to stop whenever the second reaches a certain value.</p> <pre><code>for first in range(0,10): for second in range(0,10): print(first + second) </code></pre> <p>But i want it to skip to the next 'first' value if the second value is odd.</p> <p>I tried to do something like this:</p> <pre><code>odd = [1,3,5,7,9] for first in range(0,10): for second in range(0.10): if second in odd: continue </code></pre> <p>But it won't work.</p>
[ { "answer_id": 74459578, "author": "Diego D", "author_id": 1221208, "author_profile": "https://Stackoverflow.com/users/1221208", "pm_score": 2, "selected": false, "text": "header ( \"Location: https://example.com\" );\necho 'Nice';\n" }, { "answer_id": 74459668, "author": "IMSoP", "author_id": 157957, "author_profile": "https://Stackoverflow.com/users/157957", "pm_score": 0, "selected": false, "text": "header()" }, { "answer_id": 74459757, "author": "Neo", "author_id": 405238, "author_profile": "https://Stackoverflow.com/users/405238", "pm_score": 1, "selected": true, "text": "header ( \"Location: https://example.com\" );\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20489654/" ]
74,459,626
<p>I would like to exclude some worksheets from my loop in Excel VBA.</p> <p>I used the following hint: <a href="https://superuser.com/questions/1299900/exclude-sheets-when-looping-through-sheets">https://superuser.com/questions/1299900/exclude-sheets-when-looping-through-sheets</a></p> <p>My code looks like this:</p> <pre><code> Dim ws As Worksheet Set ws = Application.Worksheets.Count For i = 1 To a If ws.Name &lt;&gt; &quot;BoQ&quot; And ws.Name &lt;&gt; &quot;Sign Off Sheet&quot; And ws.Name &lt;&gt; &quot;PIANOI&quot; Then Worksheets(i).Cells(46, 14).Formula = &quot;=Frontsheet!J10&quot; Worksheets(i).Cells(46, 16).Formula = &quot;=Frontsheet!J9&quot; End If Next </code></pre> <p>But I am getting an error:</p> <p>Type mismatch</p> <p>tried to solve it by using this hint:</p> <p><a href="https://stackoverflow.com/questions/66308439/vba-compile-error-type-mismatch-looping-with-sheet-function">VBA Compile Error Type Mismatch - Looping with Sheet Function</a></p> <p>but in vain.</p> <p>How can I exclude some worksheets here?</p>
[ { "answer_id": 74459657, "author": "Rory", "author_id": 3611989, "author_profile": "https://Stackoverflow.com/users/3611989", "pm_score": 3, "selected": true, "text": "ws" }, { "answer_id": 74460430, "author": "freeflow", "author_id": 7177346, "author_profile": "https://Stackoverflow.com/users/7177346", "pm_score": 1, "selected": false, "text": "Option Explicit\n\n' Put the following in the module where you keep global variables\nConst ExcludeNames As String = \"BoQ,Sign Off Sheet,PIANOI\"\n\n' use this function to create the ArrayList of names you wish to exclude\n' ArrayList requires a reference to mscorlib\nPublic Function SetupExcludedWorksheets(ByVal ipStringOfNames As String) As ArrayList\n\n Dim myName As Variant\n Dim myExcludes As ArrayList\n Set myExcludes = New ArrayList\n \n For Each myName In ipStringOfNames.Split(\",\")\n myExcludes.Add myName\n Next\n \n Set SetupExcludedWorksheets = myExcludes(excludeNames)\n \nEnd Function\n\n' in your setup routines include the following lines\nDim myExcludes As ArrayList\nSet myExcludes = SetupExcludedWorksheets(ExcludeNames)\n\n' Your code now becomes\nDim ws As Worksheet\n\nFor Each ws In ActiveWorkbook.Worksheets\n If Not myExcludes.contains(ws.Name) Then\n ws.Cells(46, 14).Formula = \"=Frontsheet!J10\"\n ws.Cells(46, 16).Formula = \"=Frontsheet!J9\"\n End If\nNext\n" }, { "answer_id": 74463143, "author": "VBasic2008", "author_id": 9814069, "author_profile": "https://Stackoverflow.com/users/9814069", "pm_score": 0, "selected": false, "text": "Sub CopyFormulae()\n \n Const WORKSHEET_EXCLUSIONS_LIST As String _\n = \"BoQ,Sign Off Sheet,PIANOI\" ' maybe you want to add 'Frontsheet'?\n\n Dim WorksheetExclusions() As String\n WorksheetExclusions = Split(WORKSHEET_EXCLUSIONS_LIST, \",\")\n \n Dim wb As Workbook: Set wb = ThisWorkbook ' workbook containing this code\n \n Dim ws As Worksheet\n \n For Each ws In wb.Worksheets\n With ws\n If IsError(Application.Match(.Name, WorksheetExclusions, 0)) Then\n .Range(\"N46\").Formula = \"=Frontsheet!J10\"\n .Range(\"P46\").Formula = \"=Frontsheet!J9\"\n 'Else ' is found in the WorksheetExclusions array; do nothing\n End If\n End With\n Next ws\n\n MsgBox \"Formulae copied.\", vbInformation\n\nEnd Sub\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6694814/" ]
74,459,661
<p>I have a Flutter app with <code>GetX</code> Controllers. The app has 6 screens and every screen has its <code>GetxController</code>.</p> <p>Screens 1 and 2 are for the login system, while screens 3 to 6 are for the app content.</p> <p>After logging in the user can go forward and back between screens 3-4-5, but when he reaches screen 6 he can only go to Screen 3 and all the previous stacks must be deleted (so he cannot go back).</p> <p><code>1st problem</code>: if I do a <code>Get.offAll(() =&gt; const Screen3())</code> from the Screen 6, the Controller for Screen3 gets deleted and nothing works anymore. I workaround (don't know if that word exists! :D) by marking <code>Controller3</code> as permanent via</p> <p><code>Get.put(Controller3(), permanent: true)</code></p> <p>But here comes the</p> <p><code>2nd problem</code>: if the user presses the <code>logout</code> button (that is present only in Screen 3), this time I need the <code>Controller3</code> to be deleted. This time, calling <code>Get.offAll</code> doesn't delete the controller, nor calling <code>Get.delete&lt;Controller3&gt;()</code>, since it says</p> <blockquote> <p>&quot;Controller3&quot; has been marked as permanent, SmartManagement is not authorized to delete it.</p> </blockquote> <p>I'm stuck in this situation and I really don't know what to do</p>
[ { "answer_id": 74459657, "author": "Rory", "author_id": 3611989, "author_profile": "https://Stackoverflow.com/users/3611989", "pm_score": 3, "selected": true, "text": "ws" }, { "answer_id": 74460430, "author": "freeflow", "author_id": 7177346, "author_profile": "https://Stackoverflow.com/users/7177346", "pm_score": 1, "selected": false, "text": "Option Explicit\n\n' Put the following in the module where you keep global variables\nConst ExcludeNames As String = \"BoQ,Sign Off Sheet,PIANOI\"\n\n' use this function to create the ArrayList of names you wish to exclude\n' ArrayList requires a reference to mscorlib\nPublic Function SetupExcludedWorksheets(ByVal ipStringOfNames As String) As ArrayList\n\n Dim myName As Variant\n Dim myExcludes As ArrayList\n Set myExcludes = New ArrayList\n \n For Each myName In ipStringOfNames.Split(\",\")\n myExcludes.Add myName\n Next\n \n Set SetupExcludedWorksheets = myExcludes(excludeNames)\n \nEnd Function\n\n' in your setup routines include the following lines\nDim myExcludes As ArrayList\nSet myExcludes = SetupExcludedWorksheets(ExcludeNames)\n\n' Your code now becomes\nDim ws As Worksheet\n\nFor Each ws In ActiveWorkbook.Worksheets\n If Not myExcludes.contains(ws.Name) Then\n ws.Cells(46, 14).Formula = \"=Frontsheet!J10\"\n ws.Cells(46, 16).Formula = \"=Frontsheet!J9\"\n End If\nNext\n" }, { "answer_id": 74463143, "author": "VBasic2008", "author_id": 9814069, "author_profile": "https://Stackoverflow.com/users/9814069", "pm_score": 0, "selected": false, "text": "Sub CopyFormulae()\n \n Const WORKSHEET_EXCLUSIONS_LIST As String _\n = \"BoQ,Sign Off Sheet,PIANOI\" ' maybe you want to add 'Frontsheet'?\n\n Dim WorksheetExclusions() As String\n WorksheetExclusions = Split(WORKSHEET_EXCLUSIONS_LIST, \",\")\n \n Dim wb As Workbook: Set wb = ThisWorkbook ' workbook containing this code\n \n Dim ws As Worksheet\n \n For Each ws In wb.Worksheets\n With ws\n If IsError(Application.Match(.Name, WorksheetExclusions, 0)) Then\n .Range(\"N46\").Formula = \"=Frontsheet!J10\"\n .Range(\"P46\").Formula = \"=Frontsheet!J9\"\n 'Else ' is found in the WorksheetExclusions array; do nothing\n End If\n End With\n Next ws\n\n MsgBox \"Formulae copied.\", vbInformation\n\nEnd Sub\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74459661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6326261/" ]