qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,156,679
<p>How to make sure that the shields.io badge points to the site, and do that using reference-style markdown links.</p> <p>This works fine</p> <pre><code>[![](https://img.shields.io/badge/code%20style-black-black.svg?style=for-the-badge&amp;labelColor=gray)][http://github.com/psf/black] </code></pre> <p>[<img src="https://img.shields.io/badge/code%20style-black-black.svg?style=for-the-badge&amp;labelColor=gray" alt="" />][http://github.com/psf/black]</p> <p>This doesn't works</p> <pre><code>![]([black-shield])[black] [black]: http://github.com/psf/black [black-shield]: https://img.shields.io/badge/code%20style-black-black.svg?style=for-the-badge&amp;labelColor=gray </code></pre>
[ { "answer_id": 74156684, "author": "Nestoro", "author_id": 7941160, "author_profile": "https://Stackoverflow.com/users/7941160", "pm_score": 2, "selected": false, "text": "splitted" }, { "answer_id": 74156949, "author": "epascarello", "author_id": 14104, "author_profi...
2022/10/21
[ "https://Stackoverflow.com/questions/74156679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9292995/" ]
74,156,767
<p>I have a link in a web app that uses mailto: to launch an email (with default values for To, Subject, and Body). That said, when this link is clicked by an end user, it opens with whatever default Email app they have setup in Windows. All of my end users have Outlook, and some have (likely unintentionally) selected values other than Outlook as their default Email app. This became apparent, this morning, when one of my end users complained and I found their default Email app was simply Chrome.</p> <p>Is there a way to force the mailto: command to launch Outlook despite the end users default Email app value?</p>
[ { "answer_id": 74156684, "author": "Nestoro", "author_id": 7941160, "author_profile": "https://Stackoverflow.com/users/7941160", "pm_score": 2, "selected": false, "text": "splitted" }, { "answer_id": 74156949, "author": "epascarello", "author_id": 14104, "author_profi...
2022/10/21
[ "https://Stackoverflow.com/questions/74156767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20302983/" ]
74,156,768
<p>I'm new to angular and using angular FormControl and facing some issue as below.</p> <p>I just have a input text with required validator. Based on input entered by user and if the text is valid, I want to enable one button. if input text is invalid, I want to disable button.</p> <p>When running this, disabled button is never getting enabled. Please check and let me know some suggestions.</p> <p>Here is my code. I'm using angular reactive forms.</p> <p>sample.html:</p> <pre><code>&lt;label for=&quot;name&quot;&gt;Name: &lt;/label&gt; &lt;input type=&quot;text&quot; [formControl]=&quot;userName&quot; required&gt; &lt;p&gt;Value: {{ userName.value }}&lt;/p&gt; &lt;button disabled=&quot;(userName.value === '')&quot;&gt;{{ userName.value }}&lt;/button&gt; </code></pre> <p>Sample.component.ts</p> <pre><code>import { Component } from '@angular/core'; import { FormControl } from '@angular/forms'; import { NgModule } from '@angular/core'; @Component({ }) export class SampleComponent { userName = new FormControl('') ngOnInit(): void { console.log(&quot;entered&quot;) console.log(this.userName.getRawValue()); } } </code></pre>
[ { "answer_id": 74156684, "author": "Nestoro", "author_id": 7941160, "author_profile": "https://Stackoverflow.com/users/7941160", "pm_score": 2, "selected": false, "text": "splitted" }, { "answer_id": 74156949, "author": "epascarello", "author_id": 14104, "author_profi...
2022/10/21
[ "https://Stackoverflow.com/questions/74156768", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17581716/" ]
74,156,796
<p>I have a MySQL data table which stores metadata for client transactions. I am writing a query to extract a number out of the metadata column, which is essentially a JSON stored as a string.</p> <p>I am trying to find 'clients' and extract the first number after clients. The data can be stored in several different ways; see the examples below:</p> <ul> <li><code>...&quot;type\&quot;:\&quot;temp\&quot;,\&quot;typeOther\&quot;:\&quot;\&quot;,\&quot;clients\&quot;:\&quot;2\&quot;,\&quot;hours\&quot;:\&quot;5\&quot;,\...</code></li> <li><code>...&quot;id\&quot;:31457,\&quot;clients\&quot;:2,\&quot;cancel\&quot;:false\...</code></li> </ul> <p>I've tried the following Regexp:</p> <ul> <li><code>(?&lt;=clients.....)[0-9]+</code></li> <li><code>(?&lt;=clients...)[0-9]*(?=[[^:digit:]])</code></li> </ul> <p>And I've tried the following json_extract, but it returned a null value:</p> <ul> <li><code>json_extract(rd.meta, '$.clients')</code></li> </ul> <p>The regexp functions do work, <strong>but</strong> the first one only works on the first example, while the second only works on the second example.</p> <p>What regexp should I use such that it's dynamic and will pull the number nested between two non-word char sets after 'clients'?</p>
[ { "answer_id": 74156684, "author": "Nestoro", "author_id": 7941160, "author_profile": "https://Stackoverflow.com/users/7941160", "pm_score": 2, "selected": false, "text": "splitted" }, { "answer_id": 74156949, "author": "epascarello", "author_id": 14104, "author_profi...
2022/10/21
[ "https://Stackoverflow.com/questions/74156796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20302969/" ]
74,156,808
<p>have getting confused in getting the value from the Tkinter() Entry Field. I have this kind of code...</p> <pre><code> def login(): root_login = Tk() root_login.title(&quot;Login&quot;) root_login.geometry(&quot;400x400&quot;) label_text_name = Label(root_login, text=&quot;Type mail your :&quot;) label_text_name.pack() label_text_name.place(x=25, y=50) label_text_token = Label(root_login, text=&quot;Type Pasword :&quot; ) label_text_token.pack() label_text_token.place(x=58, y=150) input_text_email = Entry(root_login, width=30) input_text_email.pack() input_text_email.place(x=150, y=50) input_text_token = Entry(root_login, width=30) input_text_token.pack() input_text_token.place(x=150, y=150) e1 = Entry(root_login) e1.pack() btn_login = Button(root_login,command=after_login, text=&quot;Login&quot;, height=1, width=10 ) btn_login.pack() btn_login.place(x=50, y=250) def after_login(): var = e1.get() messagebox.showinfo(var1) </code></pre> <p>but i get a error !</p> <p>var = e1.get() NameError: name 'e1' is not defined</p>
[ { "answer_id": 74162577, "author": "van Thielen", "author_id": 5204804, "author_profile": "https://Stackoverflow.com/users/5204804", "pm_score": 0, "selected": false, "text": "def login():\nroot_login = Tk()\nroot_login.title(\"Login\")\nroot_login.geometry(\"400x400\")\n\nlabel_text_nam...
2022/10/21
[ "https://Stackoverflow.com/questions/74156808", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5204804/" ]
74,156,810
<p>This is my code:</p> <pre><code>score &lt;- tapply(exams$writing.score , list(exams$gender, exams$race.ethnicity ) , mean) plot1 &lt;- barplot(score , beside = TRUE , main = &quot;Comparison of Writing Score&quot; , col = c(&quot;red&quot;, &quot;lightyellow&quot;) , xlab = &quot;Race Ethnicity Group&quot; , ylab = &quot;Average Writing Score&quot; , legend.text = c(&quot;Female&quot;, &quot;Male&quot;) , args.legend = list(x = &quot;topright&quot;) ) </code></pre> <p><a href="https://i.stack.imgur.com/d072r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d072r.png" alt="enter image description here" /></a></p> <p>As I want to make the box: Female and Male smaller so it does not hide the bar behind. How can I make the legend box smaller? I tried to move it to the top right of the chart, but I do not think it moves.</p>
[ { "answer_id": 74156888, "author": "Quinten", "author_id": 14282714, "author_profile": "https://Stackoverflow.com/users/14282714", "pm_score": 2, "selected": false, "text": "cex" }, { "answer_id": 74157302, "author": "AndrewGB", "author_id": 15293191, "author_profile"...
2022/10/21
[ "https://Stackoverflow.com/questions/74156810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20244241/" ]
74,156,813
<p>It's evening here in Nigeria and I am facing a problem while studying JUnit 5 Repeated tests:</p> <pre><code>@RepeatedTest(value=4, name= &quot;{displayName} running: {currentRepetition}/{totalRepetitions}&quot;) @DisplayName(”RepeatedTest”) void repeatedTest() { //removed for brevity. } </code></pre> <p>In the above code, unlike the other placeholders, {displayName} isn't resolved. Why please?</p>
[ { "answer_id": 74156888, "author": "Quinten", "author_id": 14282714, "author_profile": "https://Stackoverflow.com/users/14282714", "pm_score": 2, "selected": false, "text": "cex" }, { "answer_id": 74157302, "author": "AndrewGB", "author_id": 15293191, "author_profile"...
2022/10/21
[ "https://Stackoverflow.com/questions/74156813", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14448394/" ]
74,156,840
<p>I want to place the &quot;Page Unfound&quot; text underneath the 404 text so that they stack sort of on top of one and other. Thanks for the help !</p> <p>Here is the code</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;style&gt; body { margin: 0; font-family: Arial, Helvetica, sans-serif; } .shell { height: 95vh; justify-content: center; display: flex; flex-direction: row; flex-basis: auto; margin: 5px 20px; align-items: center; flex-wrap: wrap; color: #D32F2F; text-align: center; } .bigtext { font-size: 96px; } .smalltext { font-size: 24px; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="shell"&gt; &lt;div class="bigtext"&gt;404&lt;/div&gt; &lt;div class="smalltext"&gt;Page Unfound&lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74156888, "author": "Quinten", "author_id": 14282714, "author_profile": "https://Stackoverflow.com/users/14282714", "pm_score": 2, "selected": false, "text": "cex" }, { "answer_id": 74157302, "author": "AndrewGB", "author_id": 15293191, "author_profile"...
2022/10/21
[ "https://Stackoverflow.com/questions/74156840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,156,873
<p>Let's say I have following piece of code, defining a structure and a union:</p> <pre class="lang-c prettyprint-override"><code>struct Foo { int i; float f; }; union Bar { struct Foo foo; char buf[10]; }; </code></pre> <p>Is it safe to assign pointer to object of type <code>struct Foo</code> in place of pointer to type <code>union Bar</code> and subsequently use it as such:</p> <pre class="lang-c prettyprint-override"><code>struct Foo fooVar; union Bar* barPtrVar = (union Bar*) &amp;fooVar; bar-&gt;foo.i = 1000; bar-&gt;foo.f = 0.5f; </code></pre> <p>as long as we are sure that only the <code>foo</code> member of the <code>union Bar</code> is used?</p> <p>I remember that in C, pointer to the struct is the same as pointer to it's first member and as such they can be sometimes interchangeable, so though similar logic might apply here.</p>
[ { "answer_id": 74156948, "author": "dbush", "author_id": 1687119, "author_profile": "https://Stackoverflow.com/users/1687119", "pm_score": 2, "selected": false, "text": "buf" }, { "answer_id": 74158871, "author": "Ian Abbott", "author_id": 5264491, "author_profile": "...
2022/10/21
[ "https://Stackoverflow.com/questions/74156873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12350041/" ]
74,156,894
<p>I have a Pyspark dataframe of transactions by customer which feeds into a dashboard. For each rolling 12 month time period, I want to calculate whether a customer is 'New' (never before purchased), 'Retained' (made a purchase in the 12 months before the start of the current time period <strong>and</strong> purchased in the current time period), or 'Reactivated' (made a purchase <strong>prior to</strong> the previous 12 months, didn't purchase in the previous 12 months, and purchased in the current month).</p> <p><strong>Clarification of 'current time period':</strong> If current period is the Rolling 12 Months to the end of September 2022, any purchase from October 2021 to September 2022 falls into the 'current' time period. Purchases from October 2020 to September 2021 fall into the 'previous 12 months', and purchases from September 2020 and earlier are 'prior to the previous 12 months'.</p> <p>input:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>customer_id</th> <th>transaction_id</th> <th>transaction_date</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1</td> <td>2019-JAN-10</td> </tr> <tr> <td>1</td> <td>2</td> <td>2019-DEC-15</td> </tr> <tr> <td>1</td> <td>3</td> <td>2022-SEP-07</td> </tr> </tbody> </table> </div> <p>intermediate:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>customer_id</th> <th>txn_id</th> <th>txn_date</th> <th>period</th> <th>txn_current</th> <th>txn_prev_12m</th> <th>txn_prior_prev_12m</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1</td> <td>2019-JAN-10</td> <td>SEP 2022</td> <td>0</td> <td>0</td> <td>1</td> </tr> <tr> <td>1</td> <td>2</td> <td>2019-DEC-15</td> <td>SEP 2022</td> <td>0</td> <td>0</td> <td>1</td> </tr> <tr> <td>1</td> <td>3</td> <td>2022-SEP-07</td> <td>SEP 2022</td> <td>1</td> <td>0</td> <td>0</td> </tr> </tbody> </table> </div> <p>final:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>customer_id</th> <th>txn_period</th> <th>txn_current</th> <th>txn_prev_12m</th> <th>txn_prior_prev_12m</th> <th>status</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>SEP 2022</td> <td>1</td> <td>0</td> <td>2</td> <td>Reactivated</td> </tr> </tbody> </table> </div> <p>My current solution loops through each required evaluation period (Jan 2022, Feb 2022, Mar 2022, etc.), classifying the customer status for that period. This step, however, takes hours to process because it has to loop through dozens of different time periods over a dataframe with millions of rows.</p> <p>I feel like I'm missing something obvious, but how can I calculate this without looping through each time period and checking whether each individual transaction falls within the bounds of that time period?</p>
[ { "answer_id": 74156948, "author": "dbush", "author_id": 1687119, "author_profile": "https://Stackoverflow.com/users/1687119", "pm_score": 2, "selected": false, "text": "buf" }, { "answer_id": 74158871, "author": "Ian Abbott", "author_id": 5264491, "author_profile": "...
2022/10/21
[ "https://Stackoverflow.com/questions/74156894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14043706/" ]
74,156,904
<p>I'm really new to databases in general but could use some advice. I have a database that has about 6000 records (and growing but not crazy amounts). I'd like to build an API so that I can retrieve a property's price history, but have been advised I need a unique ID but I'm not so sure. Can anyone advise?</p> <p>DB looks like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">address</th> <th style="text-align: center;">price</th> <th style="text-align: right;">date_created</th> <th style="text-align: right;">status</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">Address one, main street</td> <td style="text-align: center;">£150,000</td> <td style="text-align: right;">13/10/2022</td> <td style="text-align: right;">new data</td> </tr> <tr> <td style="text-align: left;">Address one, main street</td> <td style="text-align: center;">£140,000</td> <td style="text-align: right;">16/10/2022</td> <td style="text-align: right;">update data</td> </tr> <tr> <td style="text-align: left;">Address two, side road</td> <td style="text-align: center;">£350,000</td> <td style="text-align: right;">13/10/2022</td> <td style="text-align: right;">new data</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74157341, "author": "Valeriu Ciuca", "author_id": 4527645, "author_profile": "https://Stackoverflow.com/users/4527645", "pm_score": 2, "selected": false, "text": "primary key" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74156904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5968663/" ]
74,156,907
<p>I don't have a deep knowledge in SQL programming language. I'm doing a project in SQL to alter a VIEW and I need to nest a CASE statement beyond 10 levels. This is my code.</p> <pre><code>SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER view [dbo].[AO_VW_CONSULTA_CONTABIL_ATIVO_V3] as SELECT T.TPCODPRD, T.TPDESCR, E.EXCTADB, E.EXCTACR, E.EXCODHIS, E.EXCODAGE, E.EXNROPER, E.EXNRPARC, E.EXCNTRL, E.EXVLRMOV, E.EXRELATO, E.EXUSUARIO, E.EXNRBOL, E.EXCODCCUS, E.EXTPLNC, C.CLNOMECLI, E.EXDTMOV AS DATAMOV, O.OPCODPROD, O.OPCODCNV AS CODIGO, CASE WHEN O.OPCODPROD = '000001' THEN 'CDC-CONSIGNACOES' WHEN O.OPCODPROD = '000002' THEN 'CDC-FINANCIAMENTOS' WHEN O.OPCODPROD = '000003' THEN 'MICROCREDITO' WHEN O.OPCODPROD = '000004' THEN 'CDC-CONSIGNACAO INSS' WHEN O.OPCODPROD = '000006' THEN 'CDC - REFINANCIAMENT' WHEN O.OPCODPROD = '000008' THEN 'CDC - RENEGOCIA€ÇO' WHEN O.OPCODPROD = '000009' THEN 'CDC - RENEG BOLETO' WHEN O.OPCODPROD = '000010' THEN 'CDC-CONSIG SABEMI' WHEN O.OPCODPROD = '000011' THEN 'CDC - REFIN INSS' WHEN O.OPCODPROD = '000012' THEN 'CDC-CONS AUT' WHEN O.OPCODPROD = '000015' THEN 'CDC-CONSIGNACOES' WHEN O.OPCODPROD = '000016' THEN 'REFIN MICROCREDITO' WHEN O.OPCODPROD = '000017' THEN 'CDC-COMPRA DIV INSS' WHEN O.OPCODPROD = '000021' THEN 'OP DFV' WHEN O.OPCODPROD = '000022' THEN 'CDC-CONSI PRIVADO' WHEN O.OPCODPROD = '000023' THEN 'CDC - REFIN PRIVADO' WHEN O.OPCODPROD = '000024' THEN 'MULTIPLAS LIBERAÇÕES' WHEN O.OPCODPROD = '000025' THEN 'PORTABILIDADE' WHEN O.OPCODPROD = '000026' THEN 'REFINANCIAMENTO MULT. LIBERAÇÕES' ELSE 'PRODUTO NÃO RECONHECIDO' END AS DESCRICAO FROM dbh.FI_AT_ATIVO.dbo.ECONT E WITH(NOLOCK) JOIN dbh.FI_AT_ATIVO.dbo.COPER O WITH(NOLOCK) ON E.EXNROPER = O.OPNROPER JOIN dbh.FI_AT_ATIVO.dbo.CCLIE C WITH(NOLOCK) ON O.OPCODCLI = C.CLCODCLI JOIN dbh.FI_AT_aTIVO.DBO.VIEW_TPROD T WITH(NOLOCK) ON O.OPCODPROD = T.TPCODPRD WHERE E.EXCTADB &lt;&gt; E.EXCTACR AND ( E.EXCTADB like '7.%' OR E.EXCTADB like '8.%' OR E.EXCTACR like '7.%' OR E.EXCTACR like '8.%' ) AND E.EXRELATO IN ('01','03','04','02','05','06','07','08','09','10','11','12','13','14','15') GO </code></pre> <p>When I execute, it doesn't say there are errors, but when I select the top 1000 header to visualize the view, it gives me this message <em>&quot;case statements may only be nested to level 10&quot;</em>.</p> <p>Can someone explain to me why is this happening? Because before this project I've tried to do a CASE statement with more than 10 levels before and it worked.</p>
[ { "answer_id": 74157341, "author": "Valeriu Ciuca", "author_id": 4527645, "author_profile": "https://Stackoverflow.com/users/4527645", "pm_score": 2, "selected": false, "text": "primary key" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74156907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19497952/" ]
74,156,920
<p>I am trying to use an S3 bucket to redirect from one website to another. The redirect from &quot;http://example.com&quot; works, but I can't get the redirect from &quot;https://example.com&quot;, &quot;http://www.example.com&quot; or &quot;https://www.example.com&quot; to work.</p> <p>I have an S3 bucket called &quot;example.com&quot;. I then created a Cloudfront distribution, attached the custom SSL certificate, and added &quot;example.com&quot; and &quot;www.example.com&quot; as Alternate Domain Names.</p> <p>I'm getting this access denied message: <a href="https://i.stack.imgur.com/cUTbO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cUTbO.png" alt="enter image description here" /></a></p> <p>I'm assuming that I am not doing something correctly on the policy settings for the S3 bucket. Any guidance?</p> <p>I am using the following bucket policy: <a href="https://i.stack.imgur.com/vmI41.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vmI41.png" alt="enter image description here" /></a></p> <p>I am not currently using the &quot;Access Control List&quot;.</p>
[ { "answer_id": 74157341, "author": "Valeriu Ciuca", "author_id": 4527645, "author_profile": "https://Stackoverflow.com/users/4527645", "pm_score": 2, "selected": false, "text": "primary key" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74156920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14356737/" ]
74,156,960
<p>Every time I try to run python file in vs code terminal shows me that white line without any respond , I checked path option when installed python and reinstalled vs code but nothing worked</p> <p><a href="https://i.stack.imgur.com/daCCu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/daCCu.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74157341, "author": "Valeriu Ciuca", "author_id": 4527645, "author_profile": "https://Stackoverflow.com/users/4527645", "pm_score": 2, "selected": false, "text": "primary key" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74156960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15408188/" ]
74,156,968
<p>in selenium I just creating web element list to learn that, in cypress I use .each() method to iterate in same-named elements but Some times I just need to know the same-named elements number to use this number somewhere else.</p> <p>How can I do that in cypress?</p>
[ { "answer_id": 74157341, "author": "Valeriu Ciuca", "author_id": 4527645, "author_profile": "https://Stackoverflow.com/users/4527645", "pm_score": 2, "selected": false, "text": "primary key" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74156968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18520216/" ]
74,156,991
<p>i have this table</p> <p><a href="https://i.stack.imgur.com/rohqR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rohqR.png" alt="enter image description here" /></a></p> <p>i want echo only the row with red rectangle by condition color1. Basically what i want is if color1=yellow then print row.</p> <p>Im working on a widget that rotate news, and if the news has a flag &quot;yellow&quot; then show it else nothing, or show next with color &quot;blue&quot; if exist. I have a working javascript that will rotate the news.</p> <p>My code ist like this, i dont know what i doing wrong, can you help me?</p> <pre><code> $id = $_GET['color1']; $stmt = $connect-&gt;prepare('SELECT * FROM quicknews WHERE id = :color1'); $stmt-&gt;execute(array(':color1' =&gt; $id)); $row = $stmt-&gt;fetch(); $id = $row['color1']; $news1 = $row['news1']; $url1 = $row['url1']; if ($row['color1'] == yellow) { echo &quot;&lt;div id='contentA' style='text-align:center; vertical-align:top; margin-bottom:0px;display:none'&gt;&lt;a href='$url1' style='text-decoration:none; text-align:center'&gt;$news1&lt;/a&gt;&lt;/div&gt;&quot;; echo &quot;&lt;div id='displayArea' style='text-align:center; vertical-align:top; margin-bottom:0px'&gt;&lt;/div&gt;&quot;; } </code></pre>
[ { "answer_id": 74157490, "author": "Jamie Sayers", "author_id": 7286012, "author_profile": "https://Stackoverflow.com/users/7286012", "pm_score": 1, "selected": false, "text": "$id = $_GET['color1'];\n$stmt = $connect->prepare('SELECT * FROM quicknews WHERE id = :color1');\n$stmt->execut...
2022/10/21
[ "https://Stackoverflow.com/questions/74156991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1872522/" ]
74,156,992
<p>Tapestry 5.4.5 using <a href="http://jasonday.github.io/printThis/" rel="nofollow noreferrer">printThis.js 2.0</a></p> <p>When using the print function we are getting unwanted href URL's included in the printed page. Adding class=&quot;hidden-print&quot; to the &lt;t:eventlink&gt; causes the entire element to be omitted. We want the image/text for the eventlink to be included.</p> <p>When upgrading to Tapestry 5.4.5, we went with using Bootstrap's modals. The problem we are having seems to be related to this and the fact the modals are triggered with the eventlinks.</p> <p>This is the result we want <a href="https://i.stack.imgur.com/1bbYE.png" rel="nofollow noreferrer">Browser view</a></p> <p>This is what we are getting <a href="https://i.stack.imgur.com/eqy0X.png" rel="nofollow noreferrer">Resulting PDF</a></p> <p>This was the print result under Tapestry 5.3 when we were using <a href="https://github.com/got5/tapestry5-jquery" rel="nofollow noreferrer">Tapestry 5 jQuery dialogajaxlink</a> for the modals <a href="https://i.stack.imgur.com/fUTvF.png" rel="nofollow noreferrer">Tapestry 5.3 result with dialogajaxlink</a></p> <p>We opted to go with the Bootstrap modals when upgrading to Tapestry 5.4.5 as we were having issues with the dialogajaxlinks causing &quot;flashing&quot; on page render when the dialoglinks are used in conjunction with grids.</p> <p>This is the current .tml code <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;div class="container-fluid"&gt; &lt;t:zone t:id="studentDetailZone"&gt; &lt;div class="col-lg-12 col-md-12"&gt; &lt;t:print t:contentClientId="\#studentDetailZone" t:heading="CCP - Student Detail" /&gt; &lt;t:pagelink page="highered/lea/indexsummary" class="btn btn-ssdt"&gt;Return to Summary&lt;/t:pagelink&gt; &lt;t:delegate to="studentDetails" /&gt; &lt;t:pagelink page="highered/lea/indexsummary" class="btn btn-ssdt btn-last"&gt;Return to Summary&lt;/t:pagelink&gt; &lt;/div&gt; &lt;/t:zone&gt; &lt;/div&gt; &lt;t:block t:id="studentDetails"&gt; &lt;div class="studentBanner"&gt; &lt;div class="detailDisplay"&gt; &lt;table class="table table-hover"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;SSID&lt;/th&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;HEI&lt;/th&gt; &lt;th&gt;Year&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;${currentStudent.stateStudentId}&lt;/td&gt; &lt;t:if test="hasStuIdentityRole()"&gt; &lt;td&gt;${currentStudent.name?.fullName}&lt;/td&gt; &lt;p:else&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;/p:else&gt; &lt;/t:if&gt; &lt;td&gt;${currentHEI.nameAndIrn}&lt;/td&gt; &lt;td&gt;${currentStudent.schoolYear.year}&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="detailDisplay"&gt; &lt;h5&gt;Higher Education Reported Data&lt;/h5&gt; &lt;t:grid class="table table-hover table-striped" source="heiCourses" row="heiCourse" t:mixins="DisableGridSort, GridDecorator" t:include="${includeColumns}" t:add="flag, audit, actions" t:reorder="${reorderColumns}" t:rowClass="prop:currentClass"&gt; &lt;p:flagHeader&gt;&lt;/p:flagHeader&gt; &lt;p:actionsHeader&gt;&lt;/p:actionsHeader&gt; &lt;p:courseIdHeader&gt;Higher Ed Courses&lt;/p:courseIdHeader&gt; &lt;p:rosterDateHeader&gt;Enrollment &lt;br/&gt; as Of&lt;/p:rosterDateHeader&gt; &lt;p:creditHoursHeader&gt;Credit &lt;br/&gt; Hours &lt;/p:creditHoursHeader&gt; &lt;p:deliveryMethodHeader&gt;Dlvry &lt;br/&gt; Mthd&lt;/p:deliveryMethodHeader&gt; &lt;p:alternativeCreditHourPaymentHeader&gt;On Alt&lt;br/&gt;Pay&lt;/p:alternativeCreditHourPaymentHeader&gt; &lt;p:escalatedHeader&gt;Esclt&lt;/p:escalatedHeader&gt; &lt;p:dateRangeHeader&gt;Course Dates&lt;/p:dateRangeHeader&gt; &lt;p:subjectHeader&gt;HEI Subj&lt;/p:subjectHeader&gt; &lt;p:campusCodecampusCodeHeader&gt;Campus&lt;br/&gt; Code&lt;/p:campusCodecampusCodeHeader&gt; &lt;p:lastModifiedDateHeader&gt;Last Updated&lt;/p:lastModifiedDateHeader&gt; &lt;p:auditHeader&gt;&lt;/p:auditHeader&gt; &lt;p:flagCell&gt; &lt;t:zone t:id="statusZone" id="modalStatusZone"&gt; &lt;t:eventlink event="showCourse" context="heiCourse.id" async="true"&gt;&lt;img src="${asset:img}/${statusIcon}" title="${statusTitle}" alt=""/&gt;&lt;/t:eventlink&gt; &lt;/t:zone&gt; &lt;/p:flagCell&gt; &lt;p:actionsCell&gt; &lt;div class="btn-group row-flex"&gt; &lt;t:if test="heiCourse.active"&gt; &lt;t:if test="principalIsOde()" negate="true"&gt; &lt;t:if test="allowEscalationCancelation()"&gt; &lt;t:actionlink t:id="cancelEscalation" t:mixins="ClickOnce" id="cancelEscalation" context="heiCourse.id" class="btn btn-ssdt" &gt;Cancel Escalation&lt;/t:actionlink&gt; &lt;p:else&gt; &lt;t:if test="heiCourse.isReviewableByLEA()"&gt; &lt;t:if test="hasUpdateAccess()"&gt; &lt;div class="addComment" &gt; &lt;t:pagelink page="highered/lea/reviewstudent" context="heiCourse.id" class="btn btn-ssdt grid-btn"&gt;Review&lt;/t:pagelink&gt; &lt;/div&gt; &lt;div class="reviewNoError"&gt; &lt;t:if test="${isSplitPayment()}" negate="true"&gt; &lt;t:actionlink t:id="reviewNoErrors" t:mixins="ClickOnce" id="reviewNoErrors" context="heiCourse.id" class="btn btn-ssdt grid-btn"&gt;Approve&lt;/t:actionlink&gt; &lt;/t:if&gt; &lt;/div&gt; &lt;/t:if&gt; &lt;p:else&gt; &lt;div class="legal"&gt; &lt;p&gt;${heiCourse.getNonReviewableText()}&lt;/p&gt; &lt;/div&gt; &lt;/p:else&gt; &lt;/t:if&gt; &lt;/p:else&gt; &lt;/t:if&gt; &lt;/t:if&gt; &lt;/t:if&gt; &lt;t:if test="allowOverride()"&gt; &lt;div class="addComment" &gt; &lt;t:pagelink page="highered/lea/overridestudent" context="heiCourse.id" class="btn btn-ssdt grid-btn"&gt;Add Override&lt;/t:pagelink&gt; &lt;/div&gt; &lt;/t:if&gt; &lt;/div&gt; &lt;/p:actionsCell&gt; &lt;p:courseIdCell&gt; &lt;t:zone t:id="courseZone" id="modalCourseZone"&gt; &lt;t:eventlink event="showCourse" context="heiCourse.id" async="true"&gt;${heiCourse.courseId} - ${heiCourse.course}&lt;/t:eventlink&gt; &lt;/t:zone&gt; &lt;/p:courseIdCell&gt; &lt;p:rosterDateCell&gt;&lt;t:output value="heiCourse.rosterDate?.time" format="dateFormat" /&gt;&lt;/p:rosterDateCell&gt; &lt;p:creditHoursCell&gt; &lt;t:any t:id="creditHours" title="${heiCourse.creditHourType}"&gt; ${heiCourse.creditHours} ${heiCourse.creditHourType?.code} &lt;/t:any&gt; &lt;/p:creditHoursCell&gt; &lt;p:deliveryMethodCell&gt; &lt;t:any t:id="deliveryMethod" title="${heiCourse.deliveryMethod?.displayText}"&gt; ${heiCourse.deliveryMethod?.value} &lt;/t:any&gt; &lt;/p:deliveryMethodCell&gt; &lt;p:alternativeCreditHourPaymentCell&gt;${altPayDisplay}&lt;/p:alternativeCreditHourPaymentCell&gt; &lt;p:escalatedCell&gt;${escalationDisplay}&lt;/p:escalatedCell&gt; &lt;p:dateRangeCell&gt;${relationshipDateRangeDisplay()}&lt;/p:dateRangeCell&gt; &lt;p:campusCodecampusCodeCell&gt; &lt;t:any t:id="campusCode" title="${heiCourse.campusCode?.campusName}"&gt;${heiCourse.campusCode?.campusCode}&lt;/t:any&gt; &lt;/p:campusCodecampusCodeCell&gt; &lt;p:lastModifiedDateCell&gt;&lt;t:output value="heiCourse.lastModifiedDate" format="dateFormat" /&gt;&lt;/p:lastModifiedDateCell&gt; &lt;p:auditCell&gt; &lt;t:zone t:id="auditZone" id="modalAuditZone"&gt; &lt;t:eventlink event="showAudits" context="heiCourse.id" async="true"&gt;&lt;img src="${asset:img/triangle-icon-16x16.png}" title="Audit History"/&gt;&lt;/t:eventlink&gt; &lt;/t:zone&gt; &lt;/p:auditCell&gt; &lt;/t:grid&gt; &lt;t:if test="hasPaymentData()"&gt; &lt;h5&gt;LEA Payment Responsibility&lt;/h5&gt; &lt;t:grid class="table table-hover table-striped" source="heiPayments" row="heiPayment" t:mixins="DisableGridSort, GridDecorator" include="reportingAgency.irn, fundingCode, reviewCode, splitCredit, alternatePaymentAgreement, leaCreditCount, leaPercentOfTime, heiCreditCount, inLeaOnRosterDate, sentReasonReported, sentPercentOfTime, leaReportedPSCourse, leaStartDate, county, responsibleLea.irn " t:add="course" t:reorder="course, reportingAgency.irn" t:rowClass="prop:paymentClass"&gt; &lt;p:courseHeader&gt;Higher Ed Course&lt;/p:courseHeader&gt; &lt;p:reportingAgencyirnHeader&gt;Reporting &lt;br/&gt;LEA&lt;/p:reportingAgencyirnHeader&gt; &lt;p:fundingCodeHeader&gt;Pmt by Reporting LEA&lt;/p:fundingCodeHeader&gt; &lt;p:reviewCodeHeader&gt; &lt;t:any t:id="reviewCodeHeaderTip" title="Click on course above to see the current review status on course"&gt; Review Code&lt;br/&gt;as of &lt;br/&gt;${latestPaymentUpdate} &lt;/t:any&gt; &lt;/p:reviewCodeHeader&gt; &lt;p:splitCreditHeader&gt;Pmt&lt;br/&gt;Split&lt;/p:splitCreditHeader&gt; &lt;p:alternatePaymentAgreementHeader&gt;Alt&lt;br/&gt;Pay&lt;br/&gt;Rptd&lt;/p:alternatePaymentAgreementHeader&gt; &lt;p:leaCreditCountHeader&gt;Paying LEA Credits&lt;/p:leaCreditCountHeader&gt; &lt;p:heiCreditCountHeader&gt;HEI Total Credits&lt;/p:heiCreditCountHeader&gt; &lt;p:responsibleLeairnHeader&gt;Original HEI Reported LEA&lt;/p:responsibleLeairnHeader&gt; &lt;p:courseCell&gt;${paymentCourseDisplay}&lt;/p:courseCell&gt; &lt;p:reportingAgencyirnCell&gt; &lt;t:any t:id="paymentReportingLea" title="${heiPayment.reportingAgency.name}"&gt;${heiPayment.reportingAgency.irn}&lt;/t:any&gt; &lt;/p:reportingAgencyirnCell&gt; &lt;p:splitCreditCell&gt;${splitCreditDisplay}&lt;/p:splitCreditCell&gt; &lt;p:alternatePaymentAgreementCell&gt;${alternatePaymentDisplay}&lt;/p:alternatePaymentAgreementCell&gt; &lt;p:inLeaOnRosterDateCell&gt;${inLeaOnRosterDateDisplay}&lt;/p:inLeaOnRosterDateCell&gt; &lt;p:sentReasonReportedCell&gt;${sentReasonReportedDisplay}&lt;/p:sentReasonReportedCell&gt; &lt;p:leaReportedPSCourseCell&gt;${leaReportedPSCourseDisplay}&lt;/p:leaReportedPSCourseCell&gt; &lt;p:leaStartDateCell&gt;&lt;t:output value="heiPayment.leaStartDate?.time" format="dateFormat" /&gt;&lt;/p:leaStartDateCell&gt; &lt;p:responsibleLeairnCell&gt; &lt;t:any t:id="paymentResponsibleLea" title="${heiPayment.responsibleLea.name}"&gt;${heiPayment.responsibleLea.irn}&lt;/t:any&gt; &lt;/p:responsibleLeairnCell&gt; &lt;/t:grid&gt; &lt;p:else&gt; &lt;h5 class="well well-small"&gt;No Payment Responsibility Data&lt;/h5&gt; &lt;/p:else&gt; &lt;/t:if&gt; &lt;t:if test="hasLeaCourses()"&gt; &lt;h5&gt;K12 Reported Data&lt;/h5&gt; &lt;t:grid class="table table-hover table-striped" source="leaCourses" row="leaCourse" t:mixins="DisableGridSort" include="localClassroomCode, scheduleCode, subject, creditHours, buildingIrn, locationIrn"&gt; &lt;p:localClassroomCodeHeader&gt;EMIS Reported Courses&lt;/p:localClassroomCodeHeader&gt; &lt;p:scheduleCodeHeader&gt;Course&lt;br/&gt; Schedule&lt;/p:scheduleCodeHeader&gt; &lt;p:subjectHeader&gt;K12 Subject&lt;/p:subjectHeader&gt; &lt;p:creditHoursHeader&gt;HS&lt;br/&gt;Credits&lt;/p:creditHoursHeader&gt; &lt;p:buildingIrnHeader&gt;Building &lt;br/&gt; IRN&lt;/p:buildingIrnHeader&gt; &lt;p:scheduleCodeCell&gt;${leaCourse.scheduleCode?.description}&lt;/p:scheduleCodeCell&gt; &lt;p:subjectCell&gt;${subjectDisplay}&lt;/p:subjectCell&gt; &lt;p:locationIrnCell&gt;${locationDisplay}&lt;/p:locationIrnCell&gt; &lt;/t:grid&gt; &lt;/t:if&gt; &lt;/div&gt; &lt;/t:block&gt; &lt;t:zone t:id="auditDetailZone" id="modalAuditDetailZone"&gt; &lt;div class="modal fade" id="${auditModalId}" tabindex="-1" role="dialog" aria-hidden="true"&gt; &lt;div class="modal-dialog modal-lg" role="document"&gt; &lt;div class="modal-content"&gt; &lt;div class="modal-header"&gt; &lt;h5 class="modal-title"&gt;Audit Details&lt;/h5&gt; &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt; &lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt; &lt;/button&gt; &lt;/div&gt; &lt;div id="auditDetailBody" class="modal-body"&gt; &lt;t:print t:contentClientId="\#auditDetailBody" t:heading="CCP Student - Audit Detail"/&gt; &lt;t:auditDisplay t:source="auditJournals"/&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/t:zone&gt; &lt;t:zone t:id="courseDetailZone" id="modalCourseDetailZone"&gt; &lt;div class="modal fade" id="${courseModalId}" tabindex="-1" role="dialog" aria-hidden="true"&gt; &lt;div class="modal-dialog modal-xl" role="document"&gt; &lt;div class="modal-content"&gt; &lt;div class="modal-header"&gt; &lt;h5 class="modal-title"&gt;Course Details&lt;/h5&gt; &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt; &lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt; &lt;/button&gt; &lt;/div&gt; &lt;div class="modal-body"&gt; &lt;t:print t:contentClientId="\#courseDetailModal" t:heading="Course Details"/&gt; &lt;a href="https://wiki.ssdt-ohio.org/x/poDaB#LEACourses-courseDetail" target="_blank" class="pull-right help-link"&gt;Help&lt;/a&gt; &lt;t:LeaCourseDetail t:source="currentRelationship" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/t:zone&gt;</code></pre> </div> </div> </p> <p>I tried using printThis.js with the debug feature set to true, but was not having any luck. My javascript skills are very slim which I'm sure is not helping with the debug option.</p> <p>As stated before, trying to add the hidden-print css class causes too much to be hidden. Using the following, the image is not included in the resulting PDF nor the link text.</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;t:zone t:id="statusZone" id="modalStatusZone"&gt; &lt;t:eventlink event="showCourse" context="heiCourse.id" async="true" class="hidden-print"&gt; &lt;img src="${asset:img}/${statusIcon}" title="${statusTitle}" alt=""/&gt; &lt;/t:eventlink&gt; &lt;/t:zone&gt; &lt;t:zone t:id="courseZone" id="modalCourseZone"&gt; &lt;t:eventlink event="showCourse" context="heiCourse.id" async="true" class="hidden-print"&gt; ${heiCourse.courseId} - ${heiCourse.course} &lt;/t:eventlink&gt; &lt;/t:zone&gt;</code></pre> </div> </div> </p> <p><a href="https://i.stack.imgur.com/GclUs.png" rel="nofollow noreferrer">PDF result using hidden-print css class</a></p>
[ { "answer_id": 74366738, "author": "Spark43502", "author_id": 18772945, "author_profile": "https://Stackoverflow.com/users/18772945", "pm_score": 0, "selected": false, "text": "<t:zone t:id=\"statusZone\" id=\"modalStatusZone\">\n <t:eventlink event=\"showCourse\" context=\"heiCourse....
2022/10/21
[ "https://Stackoverflow.com/questions/74156992", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18772945/" ]
74,157,010
<p>I've two groups of multiple choice questions: a and b, each group contains 3 questions, so I've 6 columns - a1, a2, a3, b1, b2, b3. I try to create matrix of answers like a1xb1 - 1 answer, a1xb2 - 3 answers, etc. So, I hope to get a new table, where a1:a3 will be as columns and b1:b3 will be as rows and get number of crossings.</p> <p>How could I change the code below to get a new df with the number of crossings between 6 questions? The result of the code differs from what I hope to get.</p> <p>The table I'd like to get (yellow means number of crossings)</p> <p><a href="https://i.stack.imgur.com/ZkEgS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZkEgS.png" alt="enter image description here" /></a></p> <pre><code>library(tidyverse) library(dplyr) a1 &lt;- c(&quot;x1&quot;, NA, &quot;x1&quot;, NA, &quot;x1&quot;) a2 &lt;- c(NA, &quot;x2&quot;, &quot;x2&quot;, &quot;x2&quot;, NA) a3 &lt;- c(NA, &quot;x3&quot;, NA, &quot;x3&quot;, NA) b1 &lt;- c(&quot;y1&quot;, &quot;y1&quot;, NA, &quot;y1&quot;, NA) b2 &lt;- c(&quot;y2&quot;, NA, &quot;y2&quot;, NA, &quot;y2&quot;) b3 &lt;- c(&quot;y3&quot;, NA, &quot;y3&quot;, &quot;y3&quot;, NA) testdf1 &lt;- data.frame(cbind(a1, a2, a3, b1, b2, b3)) testdf2 &lt;- testdf1 %&gt;% pivot_longer(cols = -c(b1:b3)) %&gt;% group_by(b1, b2, b3, value) %&gt;% summarise(N=n()) %&gt;% ungroup() %&gt;% drop_na() %&gt;% pivot_wider(names_from = c(&quot;b1&quot;, &quot;b2&quot;, &quot;b3&quot;), values_from = &quot;N&quot;) </code></pre>
[ { "answer_id": 74157111, "author": "onyambu", "author_id": 8380272, "author_profile": "https://Stackoverflow.com/users/8380272", "pm_score": 2, "selected": false, "text": "crossprod" }, { "answer_id": 74157304, "author": "jay.sf", "author_id": 6574038, "author_profile...
2022/10/21
[ "https://Stackoverflow.com/questions/74157010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14346995/" ]
74,157,052
<p>i want to change 10 to 5 in index 0 and column name 'x'. my code is:</p> <pre><code>mydata = {'x' : [10, 50, 18, 32, 47, 20], 'y' : ['12', '11', 'N/A', '13', '15', 'N/A']} df1 = pd.DataFrame(mydata) df1['x'][df1['x'] == 10] = 5 </code></pre> <p>and i got:</p> <pre><code>C:\Users\T\AppData\Local\Temp\ipykernel_2260\1154778325.py:1: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy df1['x'][df1['x'] == 10] = 5 </code></pre> <p>its work, but with this warning</p>
[ { "answer_id": 74157098, "author": "Tim Roberts", "author_id": 1883316, "author_profile": "https://Stackoverflow.com/users/1883316", "pm_score": 2, "selected": true, "text": "loc" }, { "answer_id": 74157125, "author": "alphamu", "author_id": 10215873, "author_profile"...
2022/10/21
[ "https://Stackoverflow.com/questions/74157052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18282659/" ]
74,157,060
<p>I am requesting access token from Microsoft Graph using this procedure:</p> <ol> <li>I request access to the following scopes:</li> </ol> <p><code>User.Read.All openid profile email offline_access https://outlook.office.com/IMAP.AccessAsUser.All https://outlook.office.com/POP.AccessAsUser.All https://outlook.office.com/SMTP.Send</code></p> <ol start="2"> <li><p>After the consent screen in web browser, the redirection occurs and the codes are sent to temporary localhost web server running on user's PC.</p> </li> <li><p>The <code>code</code> received is exchanged for <strong>access_token</strong> and <strong>refresh_token</strong></p> </li> <li><p>When I try to query Microsoft Graph for user's profile I query:</p> </li> </ol> <p>GET <code>https://graph.microsoft.com/v1.0/me</code></p> <p>Header of the GET request contains:</p> <p><code>Authorization: Bearer token-here-all-in-one-line</code></p> <p>But I get the resulting JSON:</p> <p><code>&quot;InvalidAuthenticationToken&quot;</code></p> <p><code>&quot;CompactToken parsing failed with error code: 8004920A&quot;</code></p> <p>I would normally assume the token is not correct, but I tested the same token from C++ app and a small PHP app, and I always test the same error. To be sure that it is not the wrong token, I deliberately modify it to a wrong token and then I get:</p> <p><code>&quot;CompactToken parsing failed with error code: 80049217&quot;</code></p> <p>After googling - <code>8004920A</code> means &quot;token rejected&quot; (the error I have problem with) and <code>80049217</code> means &quot;malformed token&quot; so that is consistent with me deliberately inserting false data as token.</p> <p>So I would assume that the token is correct but Microsoft Graph rejects it to query user profile information which is consented and approved.</p> <p>I have tested the token on IMAP and SMTP access and there it works - mails are sent and received, so the <code>access_token</code> is definitely good.</p> <p>Any ideas why Microsoft Graph rejects my attempt to query user profile?</p> <p>Do I need to enable something when registering application in AzureAD portal?</p> <p>I am doing this from C++ or from PHP so I don't think the code is of relevance here.</p>
[ { "answer_id": 74157463, "author": "Nikolay", "author_id": 929187, "author_profile": "https://Stackoverflow.com/users/929187", "pm_score": 2, "selected": false, "text": "openid profile email offline_access" }, { "answer_id": 74196934, "author": "Coder12345", "author_id": ...
2022/10/21
[ "https://Stackoverflow.com/questions/74157060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/974700/" ]
74,157,062
<pre class="lang-js prettyprint-override"><code>let paddle1 = { x: 0, y: canvas.height / 2 - PADDLE_HEIGHT / 2, }; let paddle2 = { x: canvas.width - PADDLE_WIDTH, y: canvas.height / 2 - PADDLE_HEIGHT / 2, }; let ball = { x: canvas.width / 2, y: canvas.height / 2, leftorright: Math.round(Math.random()), upordown: Math.round(Math.random()), }; </code></pre> <p>is the paddles &amp; ball and the part I really need help with detecting if the ball hits the paddle. What I was trying to do is check the X and the Y to see if it was between the top of the paddle and the bottom, but it wouldn't work.</p> <pre><code>function checkCollision() { if (ball.x &lt;= 45) { // I tried to check the x and the y here but couldn't figure out how ball.leftorright = 1 } if (ball.x &gt;= canvas.width - 65) { ball.leftorright = 0 } } </code></pre>
[ { "answer_id": 74157131, "author": "ShackER", "author_id": 11205778, "author_profile": "https://Stackoverflow.com/users/11205778", "pm_score": 0, "selected": false, "text": "paddle" }, { "answer_id": 74157224, "author": "GrafiCode", "author_id": 5334486, "author_profi...
2022/10/21
[ "https://Stackoverflow.com/questions/74157062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18668388/" ]
74,157,068
<p>I have a <code>status = 'DRAFT' | 'READY'</code> enum field in my form, is it possible to change validation in <code>zod</code> lib based on value of this field?</p> <pre><code>// validation passed { name: &quot;John&quot;, surname: null, status: &quot;DRAFT&quot; } // validation failed { name: &quot;John&quot;, surname: null, status: &quot;READY&quot; } </code></pre> <p>So esentialy if <code>status === &quot;READY&quot;</code> remove <code>.min(1)</code> from here</p> <pre><code>const schema = z.object({ name: z.string(), surname: z.string().min(1), status: z.enum([&quot;READY&quot;, &quot;DRAFT&quot;]) }); </code></pre>
[ { "answer_id": 74157249, "author": "deithy", "author_id": 11569542, "author_profile": "https://Stackoverflow.com/users/11569542", "pm_score": 0, "selected": false, "text": "const schema = z.union([\n z.object({\n name: z.string(),\n surname: z.string(),\n status: z.literal(\"DR...
2022/10/21
[ "https://Stackoverflow.com/questions/74157068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11569542/" ]
74,157,073
<p>I have a set of shell commands that look like this</p> <pre><code>if check-some-condition $a then; do stuff run-exit-code $a fi </code></pre> <p>where <code>check-some-condition</code> and <code>run-exit-code</code> could be replaced by functions taking a single argument $a, while <code>do stuff</code> is a placeholder for possibly several shell commands. Is it possible to emulate the Lisp functionality of a macro where I could just write</p> <pre><code>(my-macro $a stuff) </code></pre> <p>and have it replaced by the code above? I am using Bash but I can use any other shell if they have features that make this easier. I thought at first of using functions but I don't think I can pass in a block of commands.</p>
[ { "answer_id": 74168614, "author": "Kaz", "author_id": 1250772, "author_profile": "https://Stackoverflow.com/users/1250772", "pm_score": 1, "selected": false, "text": "eval" }, { "answer_id": 74180806, "author": "coredump", "author_id": 124319, "author_profile": "http...
2022/10/21
[ "https://Stackoverflow.com/questions/74157073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5693890/" ]
74,157,121
<p>I'm trying to extract the meeting date / time from meeting invites within Gmail's subject. Below is an example of a subject for a meeting invite:</p> <pre><code>Invitation: Bob / Carol Meeting @ Tue Oct 25, 2022 11:30am - 12pm (CST) (bob@example.org) </code></pre> <p><strong>What I would like to extract:</strong></p> <pre><code>Tue Oct 25, 2022 11:30am - 12pm (CST) </code></pre> <p>I think the pattern could simply start with the space after the &quot;@&quot; and end with the &quot;)&quot;. My Regex is very rusty so would appreciate any help :)</p> <p>Many thanks!</p>
[ { "answer_id": 74168614, "author": "Kaz", "author_id": 1250772, "author_profile": "https://Stackoverflow.com/users/1250772", "pm_score": 1, "selected": false, "text": "eval" }, { "answer_id": 74180806, "author": "coredump", "author_id": 124319, "author_profile": "http...
2022/10/21
[ "https://Stackoverflow.com/questions/74157121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12421758/" ]
74,157,157
<p>I have been dealing an error when trying to learn Google &quot;temporal fusion transformer&quot; algorithm in anaconda spyder 5.1.5. Guys, it is very important for me to solve this error. Somebody should say something. I will be very glad. The example which i use in the link below;</p> <p><a href="https://pytorch-forecasting.readthedocs.io/en/latest/tutorials/stallion.html" rel="nofollow noreferrer">https://pytorch-forecasting.readthedocs.io/en/latest/tutorials/stallion.html</a></p> <p>In example, when i come to run the code which i mention below, i got the error</p> <pre><code>study = optimize_hyperparameters( train_dataloader, val_dataloader, model_path=&quot;optuna_test&quot;, n_trials=200, max_epochs=50, gradient_clip_val_range=(0.01, 1.0), hidden_size_range=(8, 128), hidden_continuous_size_range=(8, 128), attention_head_size_range=(1, 4), learning_rate_range=(0.001, 0.1), dropout_range=(0.1, 0.3), trainer_kwargs=dict(limit_train_batches=30), reduce_on_plateau_patience=4, use_learning_rate_finder=False # use Optuna to find ideal learning rate or use in-built learning rate finder ) </code></pre> <p>Here is the error below</p> <pre><code>A new study created in memory with name: no-name-fe7e21ce-3034-4679-b60a-ee4d5c9a4db5 [W 2022-10-21 19:36:49,382] Trial 0 failed because of the following error: TypeError(&quot;__init__() got an unexpected keyword argument 'weights_summary'&quot;) Traceback (most recent call last): File &quot;C:\Users\omer\anaconda3\lib\site-packages\optuna\study\_optimize.py&quot;, line 196, in _run_trial value_or_values = func(trial) File &quot;C:\Users\omer\anaconda3\lib\site-packages\pytorch_forecasting\models\temporal_fusion_transformer\tuning.py&quot;, line 150, in objective trainer = pl.Trainer( File &quot;C:\Users\omer\anaconda3\lib\site-packages\pytorch_lightning\utilities\argparse.py&quot;, line 345, in insert_env_defaults return fn(self, **kwargs) TypeError: __init__() got an unexpected keyword argument 'weights_summary' Traceback (most recent call last): Input In [3] in &lt;cell line: 1&gt; study = optimize_hyperparameters( File ~\anaconda3\lib\site-packages\pytorch_forecasting\models\temporal_fusion_transformer\tuning.py:217 in optimize_hyperparameters study.optimize(objective, n_trials=n_trials, timeout=timeout) File ~\anaconda3\lib\site-packages\optuna\study\study.py:419 in optimize _optimize( File ~\anaconda3\lib\site-packages\optuna\study\_optimize.py:66 in _optimize _optimize_sequential( File ~\anaconda3\lib\site-packages\optuna\study\_optimize.py:160 in _optimize_sequential frozen_trial = _run_trial(study, func, catch) File ~\anaconda3\lib\site-packages\optuna\study\_optimize.py:234 in _run_trial raise func_err File ~\anaconda3\lib\site-packages\optuna\study\_optimize.py:196 in _run_trial value_or_values = func(trial) File ~\anaconda3\lib\site-packages\pytorch_forecasting\models\temporal_fusion_transformer\tuning.py:150 in objective trainer = pl.Trainer( File ~\anaconda3\lib\site-packages\pytorch_lightning\utilities\argparse.py:345 in insert_env_defaults return fn(self, **kwargs) TypeError: __init__() got an unexpected keyword argument 'weights_summary' </code></pre> <p>What is problem with the code? Is there anyone to help me, please?</p>
[ { "answer_id": 74168614, "author": "Kaz", "author_id": 1250772, "author_profile": "https://Stackoverflow.com/users/1250772", "pm_score": 1, "selected": false, "text": "eval" }, { "answer_id": 74180806, "author": "coredump", "author_id": 124319, "author_profile": "http...
2022/10/21
[ "https://Stackoverflow.com/questions/74157157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20303187/" ]
74,157,175
<p>I learn about Docker for service hosting. I want to split the desired line somehow to obtain a desired token. In case the token corresponds to <code>CONTAINER_ID</code>, I would split the line in spaces and obtain the first token. I do not even know to start this shell pipe, but it seems useful for every SRE developer. :-)</p> <p>I tried the command below:</p> <p><code>docker ps -a | grep -w &lt;image-name&gt; | head -n1 | awk '{print $1;}'</code></p> <p>The output below corresponds to command run <code>docker ps -a</code>.</p> <pre><code>CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0e7e52667c2e sappio-1 &quot;docker-entrypoint.s…&quot; 3 minutes ago Up 3 minutes 0.0.0.0:8080-&gt;8080/tcp, :::8080-&gt;8080/tcp hardcore_panini d9cd1a9d2c37 eclipse-mosquitto:2-openssl &quot;/docker-entrypoint.…&quot; 2 weeks ago Created cedalo_platform_mosquitto_1 96f65f3e8bd8 postgres:14.5 &quot;docker-entrypoint.s…&quot; 3 weeks ago Up 4 hours tests_db bdb51a386349 nginxproxy/nginx-proxy &quot;/app/docker-entrypo…&quot; 5 months ago Created dreamy_bouman </code></pre>
[ { "answer_id": 74168614, "author": "Kaz", "author_id": 1250772, "author_profile": "https://Stackoverflow.com/users/1250772", "pm_score": 1, "selected": false, "text": "eval" }, { "answer_id": 74180806, "author": "coredump", "author_id": 124319, "author_profile": "http...
2022/10/21
[ "https://Stackoverflow.com/questions/74157175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19299349/" ]
74,157,185
<p>I have a problem in HTML, where a lot of elements needs ids. It is very tedious to manually change/set each one. Is there a good way in HTML/JS to generate ids for elements according to a pattern? In the picture below I have the &quot;H1_b&quot; ids that all has to be incremented by 1 so that you get &quot;H2_b&quot; etc...</p> <p>Best regards</p> <p><a href="https://i.stack.imgur.com/sM5i3.png" rel="nofollow noreferrer">Picture of code</a></p>
[ { "answer_id": 74157318, "author": "Shoaib Amin", "author_id": 19580087, "author_profile": "https://Stackoverflow.com/users/19580087", "pm_score": 0, "selected": false, "text": "const generateIdsForTagName = (tagName) => {\n const elems = document.querySelectorAll(tagName)\n elems....
2022/10/21
[ "https://Stackoverflow.com/questions/74157185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13756050/" ]
74,157,216
<p>I am currently working with a list of dictionaries that is stored in rest_list variable after calling the get_rest(rest) function. I would like to return a list of dictionaries where availability == available (all of them in this case). This is the list of dictionaries in the rest_list variable.</p> <pre><code>[{'close_time': '5:00 pm', 'open_time': '8:00 am', 'name': 'Pizza DeVille', 'city': 'Las Vegas', 'availability': 'available'}, {'close_time': '10:00 pm', 'open_time': '9:00 am', 'name': 'Cecil’s', 'city': 'Philadelphia', 'availability': 'available'} </code></pre> <p>The output of the new function should return this (example output):</p> <pre><code>[{'availability': 'available', 'close_time': '5:00 pm', 'city': 'Las Vegas', 'open_time': '8:00 am', 'name': 'Pizza DeVille'}, {'availability': 'available', 'close_time': '10:00 pm', 'city': 'Philadelphia', 'open_time': '9:00 am', 'name': 'Cecil’s'} </code></pre> <p>As you can see it seems to be grabbing the last key-value pair and returning it first and then returning to the top. I can basically get it to print in the same order that it's going in but I have no idea how I would grab the last part first, etc. and not do it in an orderly way.</p> <pre><code>def filter_rest(rest): rest_list = get_rest(rest) #function that gives me first code chunk above new_list = [] for x in rest_list: new_list.append(x) return new_list </code></pre> <p>Lastly, the code above is missing an if statement of sorts so that the list of dictionaries returned only includes those where availability == 'available'. Any tips on including an if statement and getting the function to return in the order shown in the example ouput?</p>
[ { "answer_id": 74157318, "author": "Shoaib Amin", "author_id": 19580087, "author_profile": "https://Stackoverflow.com/users/19580087", "pm_score": 0, "selected": false, "text": "const generateIdsForTagName = (tagName) => {\n const elems = document.querySelectorAll(tagName)\n elems....
2022/10/21
[ "https://Stackoverflow.com/questions/74157216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20134991/" ]
74,157,218
<p>I wanted to extend the Base Abstract User Model within Django to have some other Fields:</p> <pre><code>class Student(AbstractUser): birth = models.DateField(default=datetime.date.today) street = models.CharField(max_length=20) street_number = models.IntegerField(validators=[MinValueValidator(0), MaxValueValidator(99)]) city = models.CharField(max_length=20) province = models.CharField(max_length=20) code = models.IntegerField(validators=[MinValueValidator(0, MaxValueValidator(9999))]) address = str(street) + str(street_number) + str(city) + str(code) + str(province) def __str__(self): return f'Adresse: {self.address}' </code></pre> <p>I added this into my settings.py file:</p> <pre><code>AUTH_USER_MODEL = 'mainApp.Student' </code></pre> <p>But I get an Error saying there is no such table &quot;Student&quot; when trying to load /admin/. I have made all the migrations using:</p> <pre><code>python manage.py makemigrations mainApp python manage.py migrate mainApp </code></pre> <p>Error:</p> <pre><code>OperationalError at /admin/ no such table: mainApp_student </code></pre> <p>If y'all need any more infos, please comment!</p>
[ { "answer_id": 74157318, "author": "Shoaib Amin", "author_id": 19580087, "author_profile": "https://Stackoverflow.com/users/19580087", "pm_score": 0, "selected": false, "text": "const generateIdsForTagName = (tagName) => {\n const elems = document.querySelectorAll(tagName)\n elems....
2022/10/21
[ "https://Stackoverflow.com/questions/74157218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18298825/" ]
74,157,230
<p>I have following very simple implementation in python</p> <pre><code> m = [] l = [] l.append('A') l.append('B') l.append('C') m.append(l) l.clear() print(m) --&gt; this gives empty list. </code></pre> <p>i tried</p> <pre><code> m = [] l = [] n = [] l.append('A') l.append('B') l.append('C') n = l m.append(n) l.clear() print(m) --&gt; this gives empty list too </code></pre> <p>But when i do not clear l, print(m) give me desired list which is ['A','B','C']. Why python clears list m when i clear list l. they are 2 separate variables?</p>
[ { "answer_id": 74157269, "author": "assume_irrational_is_rational", "author_id": 11622508, "author_profile": "https://Stackoverflow.com/users/11622508", "pm_score": 3, "selected": true, "text": "m = []\nl = []\nl.append('A')\nl.append('B')\nl.append('C')\nm.append(l.copy()) -> use list....
2022/10/21
[ "https://Stackoverflow.com/questions/74157230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1028289/" ]
74,157,272
<p>I am trying to make a quiz game that runs over a TCP server/client. Can anyone help me get the server to send the second question after the user enters the answer on the client side? Right now when I enter my first answer, whether its right or wrong the second question is never sent. I included my code below for reference:</p> <p>server</p> <pre><code>from socket import * from random import choice serverPort = 13000 serverSocket = socket(AF_INET, SOCK_STREAM) serverSocket.bind(('', serverPort)) serverSocket.listen(1) correct = 0 print ('The server is ready to receive') fullquiz= [] questions = [] answers = [] with open (&quot;quiz.txt&quot;) as data_file: #this sections opens the quiz file and splits it into questions and answers for line in data_file: data = (line.split(',')) fullquiz += data questions = fullquiz[0::2] #this is the questions list answers = fullquiz[1::2] #this is the answer list while True: connectionSocket, addr = serverSocket.accept() #addresses the server to the socket sentence = connectionSocket.recv(1024) if (correct &lt; 3): a = choice(list(questions)) connectionSocket.send(a.encode()) print(sentence) print(correct) else: connectionSocket.close() </code></pre> <p>client</p> <pre><code>from socket import * serverName = '127.0.0.1' serverPort = 13000 correct = 0 clientSocket = socket(AF_INET, SOCK_STREAM) while True: clientSocket.connect((serverName,serverPort)) sentence = 'client is connected' clientSocket.send(sentence.encode()) while True: if (correct &lt; 3): modifiedSentence = clientSocket.recv(1024) print ('Question: ', modifiedSentence.decode()) answer = input('What is your answer: ') clientSocket.send(answer.encode()) else: clientSocket.close() </code></pre>
[ { "answer_id": 74157269, "author": "assume_irrational_is_rational", "author_id": 11622508, "author_profile": "https://Stackoverflow.com/users/11622508", "pm_score": 3, "selected": true, "text": "m = []\nl = []\nl.append('A')\nl.append('B')\nl.append('C')\nm.append(l.copy()) -> use list....
2022/10/21
[ "https://Stackoverflow.com/questions/74157272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20303299/" ]
74,157,281
<p>I want to to add an eye on my bootstrap input as:</p> <p><a href="https://i.stack.imgur.com/Lin1W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lin1W.png" alt="enter image description here" /></a></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" /&gt; &lt;link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" /&gt; &lt;div class="mb-3"&gt; &lt;label class="form-label" for="current"&gt;Current Password&lt;/label&gt; &lt;input asp-for="ChangePassword.OldPassword" class="form-control" required autofocus /&gt; &lt;button class="btn btn-light shadow-none ms-0" type="button" id="password-addon" tabindex="99"&gt;&lt;i class="fa fa-eye"&gt;&lt;/i&gt;&lt;/button&gt; &lt;span asp-validation-for="ChangePassword.OldPassword" class="text-danger"&gt;&lt;/span&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74157269, "author": "assume_irrational_is_rational", "author_id": 11622508, "author_profile": "https://Stackoverflow.com/users/11622508", "pm_score": 3, "selected": true, "text": "m = []\nl = []\nl.append('A')\nl.append('B')\nl.append('C')\nm.append(l.copy()) -> use list....
2022/10/21
[ "https://Stackoverflow.com/questions/74157281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16090212/" ]
74,157,306
<p>The following code just does not behaves the same way previous to iOS 16 and with iOS 16. The blur effect does not seem to work correctly in iOS 16.</p> <pre><code>class GameScene: SKScene { override func didMove(to view: SKView) { let shapeNode = SKShapeNode(circleOfRadius: 30) shapeNode.fillColor = .green shapeNode.strokeColor = .clear addChild(shapeNode) let blurredShapeNode = SKShapeNode(circleOfRadius: 30) blurredShapeNode.fillColor = .red blurredShapeNode.strokeColor = .clear let effectNode = SKEffectNode() addChild(effectNode) effectNode.addChild(blurredShapeNode) let blurAngle = NSNumber(value: 0) effectNode.filter = CIFilter( name: &quot;CIMotionBlur&quot;, parameters: [kCIInputRadiusKey: 30, kCIInputAngleKey: blurAngle]) } } </code></pre> <p>iOS &lt; 16 looks like :</p> <p><a href="https://i.stack.imgur.com/5Oa1e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5Oa1e.png" alt="iOS 15.5" /></a></p> <p>And iOS 16 looks bad (blur is shifted and stretched)</p> <p><a href="https://i.stack.imgur.com/HCaZe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HCaZe.png" alt="iOS 16 the blur effect is shifted and stretched" /></a></p>
[ { "answer_id": 74157269, "author": "assume_irrational_is_rational", "author_id": 11622508, "author_profile": "https://Stackoverflow.com/users/11622508", "pm_score": 3, "selected": true, "text": "m = []\nl = []\nl.append('A')\nl.append('B')\nl.append('C')\nm.append(l.copy()) -> use list....
2022/10/21
[ "https://Stackoverflow.com/questions/74157306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2679085/" ]
74,157,311
<p>how to change value of the object to an object contains key:value key:value to all models array if there any way please share it with me</p> <pre><code>const hello = [ { brand: &quot;Acura&quot;, models: [ &quot;2.2CL&quot;, &quot;2.3CL&quot;, &quot;3.0CL&quot;, &quot;3.2CL&quot;, &quot;ILX&quot;, &quot;Integra&quot;, &quot;Legend&quot;, &quot;MDX&quot;, &quot;NSX&quot;, &quot;RDX&quot;, &quot;3.5 RL&quot;, &quot;RL&quot;, &quot;RSX&quot;, &quot;SLX&quot;, &quot;2.5TL&quot;, &quot;3.2TL&quot;, &quot;TL&quot;, &quot;TSX&quot;, &quot;Vigor&quot;, &quot;ZDX&quot; ] }, { brand: &quot;Alfa Romeo&quot;, models: [ &quot;164&quot;, &quot;8C Competizione&quot;, &quot;GTV-6&quot;, &quot;Milano&quot;, &quot;Spider&quot; ] }, { brand: &quot;AMC&quot;, models: [ &quot;Alliance&quot;, &quot;Concord&quot;, &quot;Eagle&quot;, &quot;Encore&quot;, &quot;Spirit&quot; ] }, </code></pre> <p>and make it like this for all models {value:&quot;value&quot;, label:&quot;value&quot;},</p> <pre><code>const hello = [ { brand: &quot;Acura&quot;, models: [ {value:&quot;2.2CL&quot;, label:&quot;2.2CL&quot;}, {value:&quot;2.3CL&quot;, label:&quot;2.3CL&quot;}, . </code></pre> <p>and make it like this for all models {value:&quot;value&quot;, label:&quot;value&quot;},and make it like this for all models {value:&quot;value&quot;, label:&quot;value&quot;},and make it like this for all models {value:&quot;value&quot;, label:&quot;value&quot;},</p>
[ { "answer_id": 74157394, "author": "Peterrabbit", "author_id": 18242865, "author_profile": "https://Stackoverflow.com/users/18242865", "pm_score": 3, "selected": true, "text": "const hello = [{\n brand: \"Acura\",\n models: [\n \"2.2CL\",\n \"2.3CL\",\n \"3.0CL\",\n ...
2022/10/21
[ "https://Stackoverflow.com/questions/74157311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16946991/" ]
74,157,344
<p>I have a Django model with a DateField, like so:</p> <pre><code>production_date = models.DateField(null=True, blank=True) </code></pre> <p>I am trying to have that field display as the default Python date format in templates, which looks like &quot;2000-01-01&quot;. But in a Django template it displays as &quot;Jan. 1, 2000.&quot;</p> <p>In a Python shell, the date displays properly:</p> <pre><code>In [4]: resource.production_date Out[4]: datetime.date(2014, 4, 20) In [5]: str(resource.production_date) Out[5]: '2014-04-20' </code></pre> <p>But in the template, when I call production_date, I get the other format.</p> <p>I have many templates that use this value, and many ways the data gets added to the database. So I do not want to go to each template and change the display. I do not want to change the input form because that is not the only way data gets added. I do not want to change my site settings. I just want the field to display the default Python value. How do I accomplish this?</p>
[ { "answer_id": 74157467, "author": "Hashem", "author_id": 18806558, "author_profile": "https://Stackoverflow.com/users/18806558", "pm_score": -1, "selected": false, "text": "{{ birthday|date:\"m, d, Y\" }}\n" }, { "answer_id": 74157516, "author": "Nealium", "author_id": 1...
2022/10/21
[ "https://Stackoverflow.com/questions/74157344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1970300/" ]
74,157,362
<p>I want to be able to get a clean rebase on a branch someone else has worked on using a merge resolve conflict strategy.</p> <ol> <li><p>What's the easiest way to accomplish that?</p> </li> <li><p>Can I reuse their previous conflict resolutions along the way?</p> </li> </ol>
[ { "answer_id": 74160652, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 1, "selected": false, "text": "git rerere" }, { "answer_id": 74201197, "author": "hlovdal", "author_id": 23118, "author_profile": "https...
2022/10/21
[ "https://Stackoverflow.com/questions/74157362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2167582/" ]
74,157,363
<p>Hi I need some help with locating the button on an iframe which I think is within another iFrame. I tried everything<a href="https://i.stack.imgur.com/RTAmz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RTAmz.png" alt="enter image description here" /></a> that I could find but got no success. I can't copy-paste the whole code but have attached the screenshot that explains the tree.</p>
[ { "answer_id": 74157873, "author": "Matheus Leles", "author_id": 17336817, "author_profile": "https://Stackoverflow.com/users/17336817", "pm_score": 0, "selected": false, "text": "iframe = navegador.find_element_by_xpath(\"XpathOf1frame\") \nnavegador.switch_to.frame(iframe)\niframe2 ...
2022/10/21
[ "https://Stackoverflow.com/questions/74157363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11272084/" ]
74,157,365
<p>As a follow up to my previous question <a href="https://stackoverflow.com/questions/74133108/excel-formula-matching-month-and-year-in-dynamic-range/74140012?noredirect=1#comment130927266_74140012">Excel Formula Matching Month and Year in Dynamic Range</a></p> <p>I have a table of bonds and a month/year table below. Everything now works, but I have to duplicate the formula for each new bond I add to the table of bonds.</p> <p>In the bond table the Payment Schedule is created with <code>=TRANSPOSE(EDATE(C4,SEQUENCE(B4,1,6,6)))</code></p> <p>In the month/year table, I create the years with the sequence <code>=TRANSPOSE(SEQUENCE(YEAR(MAX(E3:Z4))-YEAR(MIN(E3:Z4))+1,1,YEAR(MIN(E3:Z4))))</code>, and the cells in the table are created with <code>=IF(OR((MONTH($E$3#)=$B12)*(YEAR($E$3#)=C$11)),$D$3,0)+IF(OR((MONTH($E$4#)=$B12)*(YEAR($E$4#)=C$11)),$D$4,0)</code></p> <p>Is there a way to add additional bond rows without having to duplicate and add the formula in the month/year table as I will eventually exceed the formula max length. I'm trying for a pure function based solution.</p> <p><a href="https://i.stack.imgur.com/kLc1x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kLc1x.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74158609, "author": "P.b", "author_id": 12634230, "author_profile": "https://Stackoverflow.com/users/12634230", "pm_score": 1, "selected": true, "text": "C12" }, { "answer_id": 74162043, "author": "Dattel Klauber", "author_id": 17158703, "author_profile...
2022/10/21
[ "https://Stackoverflow.com/questions/74157365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5494810/" ]
74,157,369
<p>I'm trying to better understand how different methods of declaring strings in c translate to different types of memory allocation.</p> <p>Bus errors occur when attempting to modify <em>some</em> strings, but not others. Whether or not an error occurs clearly depends on the way the string being modified is declared, but I don't feel I have a robust understanding of why. More specifically, I don't understand where actual characters are stored when a string literal is assigned to a char*. Here's a simple test example:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; int main(int argc, char** argv) { int stack_var = 5; char* str1 = &quot;This is a string.&quot;; char str2[17] = &quot;This is a string.&quot;; char* heap_str = malloc(18); strcpy(heap_str, &quot;This is a string.&quot;); printf(&quot;\n addresses: %p, %p, %p, %p, %p&quot;, &amp;stack_var, str1, &amp;str1, str2, heap_str); int option = atoi(argv[1]); if (option == 1) { str1[5] = '\0'; // Bus error } else if (option == 2) { str2[5] = '\0'; // No problem } else if (option==3) { heap_str[5] = '\0'; // No problem } } </code></pre> <p>On an arbitrary run on my computer, here's the address printout: <code>addresses: 0x7ff7be6f585c, 0x10180df66, 0x7ff7be6f5850, 0x7ff7be6f5870, 0x600002129120%</code></p> <p>Although str1, str2, and heap_str all resolve to the same string, the addresses make several differences clear:</p> <ol> <li>str2 points to a sequence of chars stored in the stack.</li> <li>The address of str1 is a location in the stack; str1 is stored in the stack as a pointer, only.</li> <li>The character sequence pointed to by str1 is <em>not</em> in the stack.</li> <li>The character sequence pointed to by str1 doesn't look like it's in the heap, either.</li> </ol> <p>So my question boils down to this: where are the characters pointed to by str1 stored?</p> <p>I'm guessing (hoping) that the answer clarifies why that sequence of characters cannot be modified, while the stack and heap versions of the same can be.</p> <p>I'm new to c, so apologies for any conspicuous naivety. Thanks in advance!</p>
[ { "answer_id": 74157475, "author": "Vlad from Moscow", "author_id": 2877241, "author_profile": "https://Stackoverflow.com/users/2877241", "pm_score": 3, "selected": true, "text": "char* str1 = \"This is a string.\";\n" }, { "answer_id": 74158050, "author": "John Bollinger", ...
2022/10/21
[ "https://Stackoverflow.com/questions/74157369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15479889/" ]
74,157,420
<p>I'm trying to process a folder with audio files through speech to text recognition on MacOS.</p> <p>If I just process one file, it works, but if I feed multiple files, only one file works and throws an error for rest.</p> <p>I thought I could use DispatchGroup, but it still feeds everything at once instead of waiting for each item to be completed.</p> <p>Could someone help me to understand what I'm doing wrong?</p> <pre><code>let recognizer = SFSpeechRecognizer() recognizer?.supportsOnDeviceRecognition = true let group = DispatchGroup() let fd = FileManager.default fd.enumerator(at: url, includingPropertiesForKeys: nil)?.forEach({ (e) in if let url = e as? URL, url.pathExtension == &quot;wav&quot; || url.pathExtension == &quot;aiff&quot; { let request = SFSpeechURLRecognitionRequest(url: url) group.enter() let task = recognizer?.recognitionTask(with: request) { (result, error) in print(&quot;Transcribing \(url.lastPathComponent)&quot;) guard let result = result else { print(&quot;\(url.lastPathComponent): No message&quot;) group.leave() return } while result.isFinal == false { sleep(1) } print(&quot;\(url.lastPathComponent): \(result.bestTranscription.formattedString)&quot;) group.leave() } group.wait() } } group.notify(queue: .main) { print(&quot;Done&quot;) } </code></pre> <p>Update: I tried DispatchQueue, but it transcribes only one file and hangs.</p> <pre><code>let recognizer = SFSpeechRecognizer() recognizer?.supportsOnDeviceRecognition = true let fd = FileManager.default let q = DispatchQueue(label: &quot;serial q&quot;) fd.enumerator(at: url, includingPropertiesForKeys: nil)?.forEach({ (e) in if let url = e as? URL, url.pathExtension == &quot;wav&quot; { let request = SFSpeechURLRecognitionRequest(url: url) q.sync { let task = recognizer?.recognitionTask(with: request) { (result, error) in guard let result = result else { print(&quot;\(url.lastPathComponent): No message&quot;) return } if result.isFinal { print(&quot;\(url.lastPathComponent): \(result.bestTranscription.formattedString)&quot;) } } } } }) print(&quot;Done&quot;) </code></pre>
[ { "answer_id": 74157475, "author": "Vlad from Moscow", "author_id": 2877241, "author_profile": "https://Stackoverflow.com/users/2877241", "pm_score": 3, "selected": true, "text": "char* str1 = \"This is a string.\";\n" }, { "answer_id": 74158050, "author": "John Bollinger", ...
2022/10/21
[ "https://Stackoverflow.com/questions/74157420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5438313/" ]
74,157,427
<p><strong>Background</strong></p> <ul> <li><p>I have a legacy application where I need to return a <code>List&lt;Item&gt;</code></p> </li> <li><p>There are many different Service classes each belonging to an <code>ItemType</code>.</p> </li> <li><p>Each service class calls a few different <code>backend APIs</code> and collects the responses to create a SubType of the <code>Item</code>. So we can say, each service class implementation returns an <code>Item</code></p> </li> <li><p>All backend API access code is using <code>WebClient</code> which returns <code>Mono</code> of some type, and I can <code>zip</code> all <code>Mono</code> within the service to create an <code>Item</code></p> </li> <li><p>The user should be able to look up many different types of items in one call. This requires many backend calls</p> </li> </ul> <p>So for performance sake, I wanted to make this all asynchronous using reactor, so I introduced Spring Reactive code.</p> <p><strong>Problem</strong></p> <p>If my endpoint had to return <code>Flux&lt;Item&gt;</code> then this code work fine, But this is some service code which is used by other legacy code caller. So eventually I want to return the <code>List&lt;Item&gt;</code> but When I try to convert my <code>Flux</code> into the <code>List</code> I get an error</p> <pre><code>&quot;message&quot;: &quot;block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-3&quot;, </code></pre> <p>Here is the service, which is calling a few other service classes.</p> <pre><code>Flux&lt;Item&gt; itemFlux = Flux.fromIterable(searchRequestByItemType.entrySet()) .flatMap(e -&gt; getService(e.getKey()).searchItems(e.getValue())) .subscribeOn(Schedulers.boundedElastic()); Mono&lt;List&lt;Item&gt;&gt; listMono = itemFlux .collectList() .block(); //This line throws error </code></pre> <p>Here is what the above service is calling</p> <pre><code>default Flux&lt;Item&gt; searchItems(List&lt;SingleItemSearchRequest&gt; requests) { return Flux.fromIterable(requests) .flatMap(this::searchItem) .subscribeOn(Schedulers.boundedElastic()); } </code></pre> <p>Here is what a single-item search is which is used by above</p> <pre><code>public Mono&lt;Item&gt; searchItem(SingleItemSearchRequest sisr) { return Mono.zip(backendApi.getItemANameApi(sisr.getItemIdentifiers().getItemId()), sisr.isAddXXXDetails() ?backendApi.getItemAXXXApi(sisr.getItemIdentifiers().getItemId()) :Mono.empty(), sisr.isAddYYYDetails() ?backendApi.getItemAYYYApi(sisr.getItemIdentifiers().getItemId()) :Mono.empty()) .map(tuple3 -&gt; Item.builder() .name(tuple3.getT1()) .xxxDetails(tuple3.getT2()) .yyyDetails(tuple3.getT3()) .build() ); } </code></pre> <p><strong>Sample project to replicate the problem.</strong>.<br /> <a href="https://github.com/mps-learning/spring-reactive-example" rel="nofollow noreferrer">https://github.com/mps-learning/spring-reactive-example</a></p> <p><strong>I’m new to spring reactor, feel free to pinpoint ALL errors in the code.</strong></p> <h1><strong>UPDATE</strong></h1> <p>As per <strong>Patrick Hooijer</strong> Bonus suggestion, updating the <code>Mono.zip</code> entries to always contain some default.</p> <pre><code> @Override public Mono&lt;Item&gt; searchItem(SingleItemSearchRequest sisr) { System.out.println(&quot;\t\tInside &quot; + supportedItem() + &quot; searchItem with thread &quot; + Thread.currentThread().toString()); //TODO: how to make these XXX YYY calls conditionals In clear way? return Mono.zip(getNameDetails(sisr).defaultIfEmpty(&quot;Default Name&quot;), getXXXDetails(sisr).defaultIfEmpty(&quot;Default XXX Details&quot;), getYYYDetails(sisr).defaultIfEmpty(&quot;Default YYY Details&quot;)) .map(tuple3 -&gt; Item.builder() .name(tuple3.getT1()) .xxxDetails(tuple3.getT2()) .yyyDetails(tuple3.getT3()) .build() ); } private Mono&lt;String&gt; getNameDetails(SingleItemSearchRequest sisr) { return mockBackendApi.getItemCNameApi(sisr.getItemIdentifiers().getItemId()); } private Mono&lt;String&gt; getYYYDetails(SingleItemSearchRequest sisr) { return sisr.isAddYYYDetails() ? mockBackendApi.getItemCYYYApi(sisr.getItemIdentifiers().getItemId()) : Mono.empty(); } private Mono&lt;String&gt; getXXXDetails(SingleItemSearchRequest sisr) { return sisr.isAddXXXDetails() ? mockBackendApi.getItemCXXXApi(sisr.getItemIdentifiers().getItemId()) : Mono.empty(); } </code></pre>
[ { "answer_id": 74158132, "author": "Patrick Hooijer", "author_id": 10468291, "author_profile": "https://Stackoverflow.com/users/10468291", "pm_score": 1, "selected": false, "text": ".block()" }, { "answer_id": 74222404, "author": "ThrowableException", "author_id": 9692178...
2022/10/21
[ "https://Stackoverflow.com/questions/74157427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9692178/" ]
74,157,449
<p>I have created the following batch that is supposed to run multiple jest tests:</p> <pre><code>#!/bin/bash echo 'The test will run 10 times per loop. The number of loops are 20.' echo 'Total number of instances that will be run: 200 instances' echo 'Starting in 5 seconds...' sleep 5 for i in {1..20}; do ${1} &amp; ${1} &amp; ${1} &amp; ${1} &amp; ${1} &amp; ${1} &amp; ${1} &amp; ${1} &amp; ${1} &amp; ${1} || (echo 'Failed after $i attempts' &amp;&amp; break); done </code></pre> <p>The ideia is that once I pass the test as a param, it will run like this: <code>npm run test SomeTest.test.ts &amp; npm run test SomeTest.test.ts &amp; npm run test SomeTest.test.ts.</code>With this I will be running the same test at the same time, without having to wait for it to be completed.</p> <p>And I have added it to my package.json like this:</p> <pre><code>&quot;scripts&quot;: { &quot;stress-test&quot;: &quot;./scripts/bash.sh&quot; } </code></pre> <p>The idea is to run like this because I want to run only one test from my .test file that has multiple tests <code>npm run test MyJestTest.test.ts -- -t 'some specific test'</code>. And this command works like a charm when used on the terminal without the bash. But if I try to use it with the bash, it won't work.</p> <pre><code>npm run stress-test -- &quot;npm run test NelnetService.test.ts -- -t 'loan transactions gets loan transactions data'&quot; </code></pre> <p>For some reason it won't accept the <code>-t</code> parameters that I'm adding. The main idea is to execute a specific test multiple times concurrently through a loop.</p> <p>Can anyone help me?</p>
[ { "answer_id": 74158132, "author": "Patrick Hooijer", "author_id": 10468291, "author_profile": "https://Stackoverflow.com/users/10468291", "pm_score": 1, "selected": false, "text": ".block()" }, { "answer_id": 74222404, "author": "ThrowableException", "author_id": 9692178...
2022/10/21
[ "https://Stackoverflow.com/questions/74157449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8402168/" ]
74,157,459
<p>I'm learning promises and I came across this piece of code</p> <pre><code>async function main() { await new Promise((resolve, reject) =&gt; { setTimeout(() =&gt; { console.log(&quot;hello&quot;); resolve(); }, 1000); }); console.log(&quot;world&quot;); } main(); </code></pre> <p>The output this produces is &quot;hello world&quot;.</p> <p>What I'm not able to understand is why the inner console log &quot;console.log(&quot;world&quot;)&quot; is waiting for the promise to resolve.</p> <p>Am I missing something here, it would be nice if I can get some help understanding this or maybe some link to some documentation for further reading.</p> <p>Thanks in advance.</p>
[ { "answer_id": 74157698, "author": "Jaood_xD", "author_id": 18891587, "author_profile": "https://Stackoverflow.com/users/18891587", "pm_score": 0, "selected": false, "text": "await" }, { "answer_id": 74157707, "author": "3tw", "author_id": 16942902, "author_profile": ...
2022/10/21
[ "https://Stackoverflow.com/questions/74157459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9370755/" ]
74,157,469
<p>Entity class</p> <pre><code>@Entity(tableName = &quot;user_table&quot;) data class User( @PrimaryKey(autoGenerate = true) //.... ) { constructor( userID: Int ) : this( userID, //... ) } </code></pre> <p>Dao class</p> <pre><code>@Dao interface UserDao { @Insert(onConflict = IGNORE) fun addUser(user: User): Long //....... } </code></pre> <p>Repository Class</p> <pre><code>class RoomUserRepository(context: Context) { //... suspend fun addUser(user: User): Long = userDao.addUser(user) //... } </code></pre> <p>ViewMode Class</p> <pre><code>class UserViewModel(val context: Application) : AndroidViewModel(context) { //... var userID: Long = 0 fun addUser(user: User) { viewModelScope.launch(Dispatchers.IO) { userID = roomUserRepository.addUser(user) } } //... } </code></pre> <p>SIGN UP Button <code>onclick{}</code></p> <pre><code>clicked = !clicked if (confirmpassword != password) { message = &quot;Incorrect password! please try again&quot; } else if (inputChack(fullname, email, password)) { message = &quot;Information is incomplete&quot; } else { // Create User user.email = email user.fullName = fullname user.password = password userVM.addUser(user) // Create Cart cart.userID = userVM.userID.toInt() cartVM.addCart(cart) Log.d(&quot;user &amp; cart&quot;, &quot;adding users &amp; cart&quot;) } </code></pre> <p>As you can see when the user click on <code>SIGN UP</code> I will Create <code>User &amp; Cart</code> in my database, user creation work fine but when I create cart I have to pass user ID and I am getting it from <code>userID</code> variable you can find it in <code>ViewMode Class</code> the problem is the value is getting <code>cart.userID = userVM.userID.toInt()</code> then it been updated</p> <p>Simply I want <br /> After called <code>userVM.addUser(user)</code> I have to wait until the <code>userID</code> variable get updated (look at ViewMode Class) then I get the updated value <code>cart.userID = userVM.userID.toInt()</code></p>
[ { "answer_id": 74157792, "author": "Muhammed Talha Sağlam", "author_id": 16057905, "author_profile": "https://Stackoverflow.com/users/16057905", "pm_score": 0, "selected": false, "text": "@Insert(onConflict = IGNORE)\nfun addUser(user: User): Long\n" }, { "answer_id": 74158418, ...
2022/10/21
[ "https://Stackoverflow.com/questions/74157469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18823812/" ]
74,157,497
<p>I have implemented the first three letters of the month to full name of the month in get Full Month function it is returned based on three letters . But how to implemented in Dictionary concept Any one simplify modify this code given below code:</p> <pre><code> **public static string getFullMonth(string mthname) { string Mthname = &quot;&quot;; switch (mthname.ToUpper()) { case &quot;JAN&quot;: Mthname =&quot;January&quot;; break; case &quot;FEB&quot;: Mthname = &quot;February&quot;; break; case &quot;MAR&quot;: Mthname = &quot;March&quot;; break; case &quot;APR:&quot;: Mthname = &quot;April&quot;; break; case &quot;MAY&quot;: Mthname = &quot;May&quot;; break; case &quot;JUN&quot;: Mthname = &quot;June&quot;; break; case &quot;JUL&quot;: Mthname = &quot;July&quot;; break; case &quot;AUG&quot;: Mthname = &quot;August&quot;; break; case &quot;SEP&quot;: Mthname = &quot;September&quot;; break; case &quot;OCT&quot;: Mthname = &quot;October&quot;; break; case &quot;NOV&quot;: Mthname = &quot;November&quot;; break; case &quot;DEC&quot;: Mthname = &quot;December&quot;; break; default: Console.WriteLine(&quot;Invalid grade&quot;); break; } return Mthname; }** </code></pre>
[ { "answer_id": 74157553, "author": "codeMonkey", "author_id": 4009972, "author_profile": "https://Stackoverflow.com/users/4009972", "pm_score": 1, "selected": false, "text": "var monthNames = new Dictionary<string, string>\n{\n { \"JAN\", \"January\" },\n { \"FEB\", \"February\" },...
2022/10/21
[ "https://Stackoverflow.com/questions/74157497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20303409/" ]
74,157,498
<p>My book talks about the &quot;dynamic data segment&quot; and &quot;global data segment&quot;. In the below arm code, where is the string &quot;Hello World!&quot; saved, and how is it saved? Is each letter a byte? If so, how does it know where to start and end?</p> <pre><code>.text .global main main: push {lr} ldr r0, =string bl printf mov r0, $0 pop {lr} bx lr .data string: .asciz &quot;Hello World!\n&quot; </code></pre>
[ { "answer_id": 74157668, "author": "Tom V", "author_id": 13001961, "author_profile": "https://Stackoverflow.com/users/13001961", "pm_score": 2, "selected": false, "text": ".data" }, { "answer_id": 74164232, "author": "old_timer", "author_id": 16007, "author_profile": ...
2022/10/21
[ "https://Stackoverflow.com/questions/74157498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10916973/" ]
74,157,506
<p>my application saves local time using OnStart() method and i am using this code below to convert time to &quot;time ago&quot; but when two persons from different time zones this method does not work it always shows <strong>incorrect</strong> time ago</p> <pre><code>private void updateUserStatus(String state) { String lastSeenTime; Calendar calendar = Calendar.getInstance(Locale.ENGLISH); SimpleDateFormat dateFormat = new SimpleDateFormat(&quot;yyyy/MM/dd HH:mm:ss&quot;); lastSeenTime = dateFormat.format(calendar.getTime()); HashMap&lt;String,Object&gt; onlineStatemap = new HashMap&lt;&gt;(); onlineStatemap.put(&quot;lastSeen&quot;, lastSeenTime); onlineStatemap.put(&quot;state&quot;, state); if (firebaseUser != null ) { currentUserID = firebaseAuth.getCurrentUser().getUid(); RootRef.child(&quot;Users&quot;).child(currentUserID).child(&quot;userState&quot;).updateChildren(onlineStatemap); } } private String calculateTime(String lastSeenTT) { SimpleDateFormat sdf = new SimpleDateFormat(&quot;yyyy/MM/dd HH:mm:ss&quot;); try { long time = sdf.parse(lastSeenTT).getTime(); long now = System.currentTimeMillis(); CharSequence ago = DateUtils.getRelativeTimeSpanString(time, now, DateUtils.MINUTE_IN_MILLIS); return ago+&quot;&quot;; } catch (ParseException e) { e.printStackTrace(); } return &quot;&quot;; } String timeAgo = calculateTime(lastSeenTT); </code></pre>
[ { "answer_id": 74157706, "author": "Basil Bourque", "author_id": 642706, "author_profile": "https://Stackoverflow.com/users/642706", "pm_score": 2, "selected": false, "text": "Duration.between ( then , Instant.now() ) \n" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74157506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20112807/" ]
74,157,537
<p>I have a file with positions, 1..16569 (1-based), and a file with feature information, i.e.; gene name etc.... I want to make one data frame based on if the position in dataframe_positions falls into the range specified by dataframe_features$start and dataframe_features$end.</p> <p>I'm going to change the values to save space.</p> <pre><code>df_positions = as.data.frame( chromosome = rep('MT', 10), positions = 1:10, depth = c(rep(6,3), rep(7,3), rep(8,2), rep(10,2), stringsAsFactors = F ) df_features = as.data.frame( chromosome = rep('MT', 10), start = c(1,4), end = c(3,10), feature = c('TRNF', 'RNR1'), stringsAsFactors = F ) </code></pre> <p>This is what I want the data to look like afterwards</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>chromosome</th> <th>positions</th> <th>depth</th> <th>feature</th> </tr> </thead> <tbody> <tr> <td>MT</td> <td>1</td> <td>6</td> <td>TRNF</td> </tr> <tr> <td>MT</td> <td>2</td> <td>6</td> <td>TRNF</td> </tr> <tr> <td>MT</td> <td>3</td> <td>6</td> <td>TRNF</td> </tr> <tr> <td>MT</td> <td>4</td> <td>7</td> <td>RNR1</td> </tr> <tr> <td>MT</td> <td>5</td> <td>7</td> <td>RNR1</td> </tr> <tr> <td>MT</td> <td>6</td> <td>7</td> <td>RNR1</td> </tr> <tr> <td>MT</td> <td>7</td> <td>8</td> <td>RNR1</td> </tr> <tr> <td>MT</td> <td>8</td> <td>8</td> <td>RNR1</td> </tr> <tr> <td>MT</td> <td>9</td> <td>10</td> <td>RNR1</td> </tr> <tr> <td>MT</td> <td>10</td> <td>10</td> <td>RNR1</td> </tr> </tbody> </table> </div> <p>Here is what I have tried</p> <pre><code>x &lt;- df_positions %&gt;% mutate(feature = ifelse(between(df_positions$positions, df_features$start,df_features$end),df_features$feature, '') </code></pre> <p>This doesn't work. I think the dplyr function doesn't know to check each tuple. Is there a way to do this in R? I'm looking into plyr::mapvalues and then probably trying a for loop next.</p> <p>Thanks.</p>
[ { "answer_id": 74158352, "author": "Ctat41", "author_id": 13188556, "author_profile": "https://Stackoverflow.com/users/13188556", "pm_score": 0, "selected": false, "text": "data <- c()\ndata_to_map <- df_positions %>% select(locus) %>% pull()\n\nfor(row in 1:nrow(df_features)){\n\n for(i...
2022/10/21
[ "https://Stackoverflow.com/questions/74157537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13188556/" ]
74,157,557
<p>I want to know if there is a value other than a specific value in a list in python, for example: given a list</p> <pre><code>lst = [0,0,0,0,0,0,0] </code></pre> <p>How can I check if there is a value other than 0 in it like 1 or 2 or 3 or any number other than 0 and its position? Example :</p> <pre><code>lst = [0,0,0,0,1,0,0,0] </code></pre> <p>The check operation should bring a <code>true</code> value saying yes list have value other than 0, that value and its position as 4.</p>
[ { "answer_id": 74157633, "author": "tdelaney", "author_id": 642070, "author_profile": "https://Stackoverflow.com/users/642070", "pm_score": 1, "selected": false, "text": "enumerate" }, { "answer_id": 74157856, "author": "SergFSM", "author_id": 18344512, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74157557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3591986/" ]
74,157,561
<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>exports.postDeleteProduct = (req, res, next) =&gt; { const userId = req.body.userId; User.deleteOne({ _id: userId, userId: req.session.userAuth._id }) .then(() =&gt; { console.log("DESTROYED PRODUCT"); //process reaching here whether the above deleteOne happens or not res.redirect("/users"); }) .catch((err) =&gt; console.log(err)); };</code></pre> </div> </div> </p> <p>Also, the code works great, but for some reason gave this error ONLY ONCE, but then continued working normally.. without me even changing anything.. which is scary. Anyway, here's the error that popped up out of nowhere then disappeared:</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>TypeError: Cannot read properties of undefined (reading '_id')</code></pre> </div> </div> </p> <p>This error showed once, then I restarted nodemon, everything worked great... weird! But it's the reason I'm asking for help, because I think it's something to do with my faulty promise which always executes.</p> <p><strong>A bit more details of what happens when I click delete:</strong></p> <ul> <li>if the condition meets: &quot;DESTROYED PRODUCT&quot; gets logged</li> <li>if the condition does NOT MEET: &quot;DESTROYED PRODUCT&quot; gets logged also</li> </ul>
[ { "answer_id": 74157633, "author": "tdelaney", "author_id": 642070, "author_profile": "https://Stackoverflow.com/users/642070", "pm_score": 1, "selected": false, "text": "enumerate" }, { "answer_id": 74157856, "author": "SergFSM", "author_id": 18344512, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74157561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19577126/" ]
74,157,563
<p>I’d like to build a robot car based on esp32 board that would operate in two modes:</p> <ul> <li>basic remote control with buttons</li> <li>voice control</li> </ul> <p>Ideally, I want to do that through a mobile application (mobile app framework, whether it’s via Bluetooth/WiFi don’t really matter). I’m still new to the topic and all I’ve found are projects connected via already existing solutions like Blynk, Thunkable. Can someone please suggest me the way how can I do that with a custom app? I’m familiar with .NET stack so I was thinking that maybe in Xamarin Forms there’s already existing library to connect to esp32? I’m open to any solution and any suggestion will be appreciated.</p> <p>Many thanks in advance</p>
[ { "answer_id": 74157633, "author": "tdelaney", "author_id": 642070, "author_profile": "https://Stackoverflow.com/users/642070", "pm_score": 1, "selected": false, "text": "enumerate" }, { "answer_id": 74157856, "author": "SergFSM", "author_id": 18344512, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74157563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20273436/" ]
74,157,566
<p>I have the following code</p> <pre><code>printf '\xFF%.s' {1..10} &gt;SomeFile.bin </code></pre> <p>Which lets me write 10 bytes containing 0xFF to a file.</p> <p>But I would like to write a varying number of bytes to that file. However, curly brace sequences do not work with variables.</p> <p>Is there a way to do the same operation using a variable instead of the hardcoded 10 repetitions?</p>
[ { "answer_id": 74157703, "author": "markp-fuso", "author_id": 7366100, "author_profile": "https://Stackoverflow.com/users/7366100", "pm_score": 2, "selected": true, "text": "x=10\nprintf '\\xFF%.s' $(seq $x) > SomeFile.bin\n" }, { "answer_id": 74159144, "author": "M. Nejat Ay...
2022/10/21
[ "https://Stackoverflow.com/questions/74157566", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8833069/" ]
74,157,582
<p>I have been given two lists (wofo and role). One is just words, and the other one tells you if the word has been used as a metaphor in a text or not. The first few entries look like this, if you print them:</p> <p><strong>wofo: Lichtfiguren nachhängt diese Sterne fallen</strong></p> <p><strong>role: Metapher Anker Anker Metapher Metapher</strong></p> <p>(so the words don't have quotation marks - are they still strings?)</p> <p>I am supposed to create two dictionaries. The first one should give the number of times a word has been used as a &quot;Metapher&quot;, the other one how often a word has been used as an &quot;Anker&quot;.</p> <p>My first attempt was this (I basically tried to put both list into one dictionary and then call the elements):</p> <pre><code>lemma_met = {} lemma_ank = {} wofo2 = wofo.split(&quot;\n&quot;) role2 = role.split(&quot;\n&quot;) dicitionary = dict(zip(wofo2, role2)) for elment in wofo: if dicitionary.get(element) == &quot;Metapher&quot;: if element in lemma_met: lemma_met[element] += 1 else: lemma_met[element] = 1 elif dicitionary.get(element) == &quot;Anker&quot;: if element in lemma_ank: lemma_ank[element] += 1 else: lemma_ank[element] = 1 </code></pre> <p>I have also tried this but both only give me empty dicitionary entries:</p> <pre><code>lemma_met = {} lemma_ank = {} for key in wofo: for value in role: if value == &quot;Metapher&quot;: if key in lemma_met: lemma_met[key] += 1 else: lemma_met[key] = 1 elif value == &quot;Anker&quot;: if key in lemma_ank: lemma_ank[key] += 1 else: lemma_ank[key] = 1 </code></pre> <p>Does anyone have an explanation for what I am doing wrong and how I can fix it? Sorry, I am very new to python and writing code in general. Is there an easier way of doing it? Or is there a specific term I can google to find the answer?</p> <p>Sorry, this question has probably been answered somewhere, but I cannot find it. I have been working on this problem for quite a while now.</p> <p>Thank you in advance!</p>
[ { "answer_id": 74157682, "author": "Andrew Ryan", "author_id": 7451892, "author_profile": "https://Stackoverflow.com/users/7451892", "pm_score": 1, "selected": false, "text": "lemma_met = {}\nlemma_ank = {}\n\nwofo2 = wofo.split(\"\\n\") # these may not be separating your strings into li...
2022/10/21
[ "https://Stackoverflow.com/questions/74157582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20199675/" ]
74,157,599
<p>Given the following data.frame <code>df</code>:</p> <pre><code> Typ1 Typ2 1 0 0 1 1 0 </code></pre> <p>And want to replace the values in each column where the value is set to 1 (is there a smarter possibility as the following?):</p> <pre><code>df[&quot;Typ1&quot;][df[&quot;Typ1&quot;] == 1]&lt;-&quot;Typ1&quot; df[&quot;Typ2&quot;][df[&quot;Typ2&quot;] == 1]&lt;-&quot;Typ2&quot; </code></pre> <p>And merge the columns to:</p> <pre><code> Typ &quot;Typ1&quot; &quot;Typ2&quot; &quot;Typ1&quot; </code></pre>
[ { "answer_id": 74157731, "author": "Jilber Urbina", "author_id": 1315767, "author_profile": "https://Stackoverflow.com/users/1315767", "pm_score": 3, "selected": true, "text": "library(tidyr)\ndf %>% \n pivot_longer(Typ1:Typ2, names_to = \"Typ\") %>% \n filter(value == 1) %>% \n selec...
2022/10/21
[ "https://Stackoverflow.com/questions/74157599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7096274/" ]
74,157,605
<p>I have a data frame that looks like this :</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>var</th> </tr> </thead> <tbody> <tr> <td>A_CAT</td> </tr> <tr> <td>B_DOG</td> </tr> <tr> <td>A_CAT</td> </tr> <tr> <td>F_HORSE</td> </tr> <tr> <td>GEORGE_DOG</td> </tr> <tr> <td>HeLeN_CAT</td> </tr> </tbody> </table> </div> <p>and I want to look like this :</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>var</th> <th>var_new</th> </tr> </thead> <tbody> <tr> <td>A_CAT</td> <td>CAT</td> </tr> <tr> <td>B_DOG</td> <td>DOG</td> </tr> <tr> <td>A_CAT</td> <td>CAT</td> </tr> <tr> <td>F_HORSE</td> <td>HORSE</td> </tr> <tr> <td>GEORGE_DOG</td> <td>DOG</td> </tr> <tr> <td>HeLeN_CAT</td> <td>CAT</td> </tr> </tbody> </table> </div> <p>How can I do this in R ?</p> <pre><code>library(tidyverse) var = c(&quot;A_CAT&quot;,&quot;B_DOG&quot;,&quot;A_CAT&quot;,&quot;F_HORSE&quot;,&quot;GEORGE_DOG&quot;,&quot;HeLeN_CAT&quot;) df = tibble(var);df </code></pre>
[ { "answer_id": 74157731, "author": "Jilber Urbina", "author_id": 1315767, "author_profile": "https://Stackoverflow.com/users/1315767", "pm_score": 3, "selected": true, "text": "library(tidyr)\ndf %>% \n pivot_longer(Typ1:Typ2, names_to = \"Typ\") %>% \n filter(value == 1) %>% \n selec...
2022/10/21
[ "https://Stackoverflow.com/questions/74157605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16346449/" ]
74,157,639
<p>I'm writing my first rust program and as expected I'm having problems making the borrow checker happy. Here is what I'm trying to do:</p> <p>I would like to have a function that allocates some array, stores the array in some global data structure, and returns a reference to it. Example:</p> <pre><code>static mut global_data = ... fn f() -&gt; &amp;str { let s = String::new(); global.my_string = s; return &amp;s; }; </code></pre> <p>Is there any way to make something like this work? If not, what is &quot;the rust way&quot;(tm) to get an array and a pointer into it?</p> <p>Alternatively, is there any documentation I could read? The rust book is unfortunately very superficial on most topics.</p>
[ { "answer_id": 74157838, "author": "Aleksander Krauze", "author_id": 13078067, "author_profile": "https://Stackoverflow.com/users/13078067", "pm_score": 2, "selected": false, "text": "Rc" }, { "answer_id": 74159504, "author": "Achim", "author_id": 20303561, "author_pr...
2022/10/21
[ "https://Stackoverflow.com/questions/74157639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20303561/" ]
74,157,643
<p>I'm currently loading multiple variables into my shell (from a <code>.env</code> file) like so:</p> <p><code>eval $(grep '^VAR_1' .env) &amp;&amp; eval $(grep '^VAR_2' .env) &amp;&amp; ...</code></p> <p>I then use them in a script like so: <code>echo $VAR_1</code>.</p> <p>Is there any way to condense this script into something like: <code>eval $(grep ^('VAR_1|VAR_2')) .env</code>? Maybe needs something other than <code>grep</code></p>
[ { "answer_id": 74157780, "author": "anubhava", "author_id": 548225, "author_profile": "https://Stackoverflow.com/users/548225", "pm_score": 2, "selected": true, "text": "grep" }, { "answer_id": 74159036, "author": "M. Nejat Aydin", "author_id": 13809001, "author_profi...
2022/10/21
[ "https://Stackoverflow.com/questions/74157643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1624933/" ]
74,157,663
<p>I am trying to use custom colors for my plot and legends. However, when I run the code below, the legends disappear (see Fig. 1). The legends are present when I do not use custom colors to fill the ellipses (see Fig. 2). I will appreciate any suggestions.</p> <p><strong>Fig. 1:</strong></p> <p><a href="https://i.stack.imgur.com/mwJYd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mwJYd.png" alt="enter image description here" /></a></p> <p><strong>Fig. 2:</strong></p> <p><a href="https://i.stack.imgur.com/cOFxi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cOFxi.png" alt="enter image description here" /></a></p> <pre><code>library(palmerpenguins) library(tidyverse) library(ggplot2) library(ggforce) penguins &lt;- penguins %&gt;% drop_na() penguins %&gt;% head() %&gt;% print() cols &lt;- c(&quot;#0066cc&quot;,&quot;#9933ff&quot;,&quot;#66cc33&quot;) my_color &lt;- rep(&quot;&quot;, nrow(penguins)) cidx &lt;- 0 for (color in unique(penguins$species)){ cidx &lt;- cidx + 1 idx &lt;- which(penguins$species == color) my_color[idx] &lt;- cols[cidx] } p &lt;- penguins %&gt;% ggplot(aes(x = bill_length_mm, y = flipper_length_mm))+ geom_mark_ellipse(aes(fill = I(my_color), alpha = I(0.2)), # geom_mark_ellipse(aes(fill = species), expand = unit(0.5,&quot;mm&quot;), size = 0) + geom_point(color = I(my_color)) plot(p) </code></pre>
[ { "answer_id": 74157824, "author": "Peter", "author_id": 6936545, "author_profile": "https://Stackoverflow.com/users/6936545", "pm_score": 2, "selected": true, "text": "library(palmerpenguins)\nlibrary(ggplot2)\nlibrary(ggforce)\nlibrary(tidyr)\n\npenguins <- \n penguins |> \n drop_na...
2022/10/21
[ "https://Stackoverflow.com/questions/74157663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6524326/" ]
74,157,689
<p>For Bean creation in SpringBoot, we use class annotated with the @Component with some bean creation methods annotated with @Bean annotation. Now, I have always been using @Bean like this:</p> <pre><code>@Bean public func getSome() { return someFunc(param1, param2, param3); } </code></pre> <p>Now, what I saw in some code is this:</p> <pre><code>@Bean public func getSome(Type1 param1, Type2 param2, Type 3 param3) { return someFunc(param1, param2, param3); } </code></pre> <p>So basically, Beans are created when the SpringBoot context loads. What I am confused here is <em><strong>how will SpringBoot pick up the parameters in the bean (the second example)</strong></em> .</p> <p>Can someone please help me understand this ?</p> <p>PS: Please let me know if the question is not clear. :)</p>
[ { "answer_id": 74157824, "author": "Peter", "author_id": 6936545, "author_profile": "https://Stackoverflow.com/users/6936545", "pm_score": 2, "selected": true, "text": "library(palmerpenguins)\nlibrary(ggplot2)\nlibrary(ggforce)\nlibrary(tidyr)\n\npenguins <- \n penguins |> \n drop_na...
2022/10/21
[ "https://Stackoverflow.com/questions/74157689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18034851/" ]
74,157,708
<p>I have 3 links when hovering over which I want a certain text to appear in the background. That is, when I hover the mouse cursor over &quot;Works&quot;, &quot;Works&quot; appears in the background, when I hover over &quot;About&quot;, &quot;About&quot; appears in the background. I don't understand how to do this if I add a second text, they climb on top of each other.</p> <p>I attach my code below (You need to open the whole page to see the result).</p> <p>I will be grateful if you help</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.info { max-width: 1920px; padding: 40px 0 0; margin: 0 auto; } .info__container { display: flex; justify-content: space-evenly; align-items: center; text-decoration: none; list-style-type: none; font-size: 20px; color: #1c1c1c; background-color: #ebebeb; margin: 0; padding-left: 0; height: 150px; width: 100%; position: relative; z-index: 0; overflow: hidden; } .info__text{ width: 60px; z-index: 1; } .info__black-hover { background: #1c1c1c; width: 1920px; height: 0; opacity: 0; visibility: hidden; position: absolute; transition: 0.5s opacity, 0.5s visibility, 0.6s height ease-in; } .info__text:hover~.info__black-hover{ width: 100%; height: 150px; opacity: 1; visibility: visible; background: #1c1c1c; } .info__text_hidden { font-size: 210px; font-family: "Roobert"; letter-spacing: -10px; position: absolute; color: #474747; bottom: -38px; left: 870px; z-index: 1; transform: translateY(70%); transition: all 1.3s ease; } .info__text:hover~.info__text_hidden { visibility: visible; color: #636262; transform: translateY(0%); } .info__text_decoration { font-family: "RoxboughCF-Regular"; position: absolute; left: -185px; bottom: 2px; } .info__number { font-size: 22px; color: #7a7a7a; } .info__link { text-decoration: none; list-style-type: none; color: #1c1c1c; } .info__link:hover { color: white; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;section class="info"&gt; &lt;ul class="info__container"&gt; &lt;li class="info__text"&gt;&lt;span class="info__number"&gt;01&lt;/span&gt;&lt;a class="info__link" href="#"&gt; Works&lt;/a&gt;&lt;/li&gt; &lt;div class="info__text_hidden"&gt;&lt;span class="info__text_decoration"&gt;W&lt;/span&gt;orks&lt;/div&gt; &lt;li class="info__text"&gt;&lt;span class="info__number"&gt;02&lt;/span&gt;&lt;a class="info__link" href="#"&gt; About&lt;/a&gt;&lt;/li&gt; &lt;div class="info__text_hidden"&gt;&lt;span class="info__text_decoration"&gt;A&lt;/span&gt;bout&lt;/div&gt; &lt;li class="info__text"&gt;&lt;span class="info__number"&gt;03&lt;/span&gt;&lt;a class="info__link" href="#"&gt; Contact&lt;/a&gt;&lt;/li&gt; &lt;div class="info__black-hover"&gt;&lt;/div&gt; &lt;/ul&gt; &lt;/section&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74157814, "author": "Nikkkshit", "author_id": 11850259, "author_profile": "https://Stackoverflow.com/users/11850259", "pm_score": 0, "selected": false, "text": "data-attribute" }, { "answer_id": 74157942, "author": "Mr-montasir", "author_id": 16093630, ...
2022/10/21
[ "https://Stackoverflow.com/questions/74157708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20257711/" ]
74,157,727
<p>How do we animate the change to a border that occurs when a class is applied.</p> <p>For example:</p> <pre><code>el-item { border-left: 6px solid red; } el-item.onSelected { border-left: 6px solid blue; } </code></pre> <p>When the <code>onSelected</code> class is added to the <code>el-item</code> element, the border color changes to <code>blue</code>. How do we animate that transition?</p>
[ { "answer_id": 74157986, "author": "sauloduarte", "author_id": 14089223, "author_profile": "https://Stackoverflow.com/users/14089223", "pm_score": 3, "selected": true, "text": ".el-item{\n border-left: 6px solid red;\n transition: all .5s;\n}\n" }, { "answer_id": 74157999, ...
2022/10/21
[ "https://Stackoverflow.com/questions/74157727", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1684269/" ]
74,157,738
<pre><code>section .data yourinputis db &quot;your input is =&quot;,0 len equ $ - yourinputis section .bss msginput resb 10 section .text global _start _start: mov eax,3 ;read syscall mov ebx,2 mov ecx,msginput mov edx,9 ; I don't know that is correct? int 80h mov eax,4 ;write syscall mov ebx,1 mov ecx,yourinputis mov edx,len int 80h mov eax,4 ;write syscall mov ebx,1 mov ecx,msginput mov edx,10 int 80h exit: mov eax,1 ;exit syscall xor ebx,ebx int 80h </code></pre> <p>This code working very well. But It is so terrible bug(for me:(). If I enter an input longer than 10 ---&gt;</p> <pre><code>$./mycode 012345678rm mycode your input is 012345678$rm mycode $ </code></pre> <p>This is happening. And of course &quot;mycode&quot; is not exist right now.</p> <p>What should I do?</p> <p>EDIT:The entered input is correctly printed on the screen. But if you enter a long input, it moves after the 9th character to the shell and runs it.</p> <p>In the example, the &quot;rm mycode&quot; after &quot;012345678&quot; is running in the shell.</p>
[ { "answer_id": 74158227, "author": "Özgür Güzeldereli", "author_id": 12196664, "author_profile": "https://Stackoverflow.com/users/12196664", "pm_score": 0, "selected": false, "text": "0x0a" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74157738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20116043/" ]
74,157,765
<p>I have the following code:</p> <pre><code>listofmodels = [resultmodeldistancearlylife,resultmodeldurationearlylife,resultmodeldistancenavigate,resultmodeldurationnavigate,resultmodeldistancetravel,resultmodeldurationtravel,resultmodeldistancevideo,resultmodeldurationvideo,resultmodeldistancelifestyle,resultmodeldurationlifestyle,resultmodeldistancegrow,resultmodeldurationgrow,resultmodeldistancesleep,resultmodeldurationsleep,resultmodeldistancedemographics,resultmodeldurationdemographics] names = ['resultmodeldistancearlylife','resultmodeldurationearlylife','resultmodeldistancenavigate','resultmodeldurationnavigate','resultmodeldistancetravel','resultmodeldurationtravel','resultmodeldistancevideo','resultmodeldurationvideo','resultmodeldistancelifestyle','resultmodeldurationlifestyle','resultmodeldistancegrow','resultmodeldurationgrow','resultmodeldistancesleep','resultmodeldurationsleep','resultmodeldistancedemographics','resultmodeldurationdemographics'] for i in range(len(listofmodels)): fig, axes = plt.subplots(nrows=2, ncols=2) plt.tight_layout() plt.title(names[i],loc='left') sns.residplot(listofmodels[i].predict(), y, lowess=True, scatter_kws={'alpha': 0.5}, line_kws={'color':'red'}, ax=axes[0,0]) axes[0,0].title.set_text('Residuals vs Fitted Linearity Plot') axes[0,0].set(xlabel='Fitted', ylabel='Residuals') sm.ProbPlot(listofmodels[i].resid).qqplot(line='s', color='#1f77b4', ax=axes[1,0]) axes[1,0].title.set_text('QQ Plot') standardized_resid1 = np.sqrt(np.abs(listofmodels[i].get_influence().resid_studentized_internal)) sns.regplot(listofmodels[i].predict(), standardized_resid1, color='#1f77b4', lowess=True, scatter_kws={'alpha': 0.5}, line_kws={'color':'red'}, ax=axes[0,1]) axes[0,1].title.set_text('Homeodasticity Plot') axes[0,1].set(xlabel='Fitted', ylabel='Standardized Residuals') </code></pre> <p>However, when I run the code, the subplot graph axis labels overlap:</p> <p><a href="https://i.stack.imgur.com/V2wgA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V2wgA.png" alt="enter image description here" /></a></p> <p>The plt.tight_layout() function thus does not seem to be working.</p> <p>Would anybody be able to give me a helping hand? I would be so grateful</p>
[ { "answer_id": 74158041, "author": "Caledonian26", "author_id": 12985497, "author_profile": "https://Stackoverflow.com/users/12985497", "pm_score": 0, "selected": false, "text": "fit.tight_layout(pad=3.2) \n" }, { "answer_id": 74158463, "author": "rioV8", "author_id": 993...
2022/10/21
[ "https://Stackoverflow.com/questions/74157765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12985497/" ]
74,157,767
<p>I have a report to do, so I need to return a date from a <code>datetime</code> column, but it need to come only with the date from the column.</p> <p>I am using the Microsoft SQL Server 2014. I've already tried to use <code>CONVERT(name_of_the_column, GETDATE())</code> but I realised the it only works to return the current datetime from the server.</p> <p>How can I do that?</p>
[ { "answer_id": 74157833, "author": "The Impaler", "author_id": 6436191, "author_profile": "https://Stackoverflow.com/users/6436191", "pm_score": 1, "selected": false, "text": "CONVERT(DATE, <expression>)" }, { "answer_id": 74157853, "author": "Kyle Fox", "author_id": 1648...
2022/10/21
[ "https://Stackoverflow.com/questions/74157767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9986816/" ]
74,157,774
<p>I’m looking for a way to define a Prisma select statement and then use it in multiple places. For example:</p> <pre><code>const userSelect: Prisma.UserSelect = { id: true, name: true, } const user = await prisma.user.findUnique({ where: { id: 1 }, select: userSelect }) const posts = await prisma.post.findMany({ where: { authorId: 1 }, select: { id: true, user: { select: userSelect } } }) </code></pre> <p>However, this isn’t working properly. When using <code>userSelect</code> in the queries, the queries know <code>userSelect</code> is of the expected type <code>Prisma.UserSelect</code>, but they don’t know which fields have actually been selected. This ends up typing both <code>user</code> and <code>posts.user</code> to be <code>{}</code>.</p> <p>A different approach would be to instead write <code>userSelect</code> like this:</p> <pre><code>const userSelect = { id: true, name: true, } as const; </code></pre> <p>That works in the query and correctly types the query result. However, now I lose type safety and autocomplete in the definition of <code>userSelect</code>.</p> <p>Can someone think of a solution that would work correctly in the query select property, the query result, and that would also allow type safety in the definition of the select object?</p>
[ { "answer_id": 74157930, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 2, "selected": true, "text": "satisfies" }, { "answer_id": 74384571, "author": "Min Somai", "author_id": 6445166, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74157774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63825/" ]
74,157,803
<p>I have a variable in dart string and would like to convert it all to seconds or minutes....</p> <pre><code>String x = &quot;2022-09-29T07:26:52.000Z&quot; </code></pre> <p>I want the opposite of this code below</p> <pre><code>final newYearsDay = DateTime.fromMillisecondsSinceEpoch(1640979000000, isUtc:true); print(newYearsDay); // 2022-01-01 10:00:00.000Z </code></pre> <p>I want to be able to get this back to seconds from the current timedate formart</p>
[ { "answer_id": 74157930, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 2, "selected": true, "text": "satisfies" }, { "answer_id": 74384571, "author": "Min Somai", "author_id": 6445166, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74157803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15145056/" ]
74,157,806
<p>Is there an elegant way to achieve this in python 3? It is supposed to flatten the dictionary, while treating list indices like keys and thus including them in the flattening.</p> <p>in:</p> <pre><code>{ &quot;a&quot;: 1, &quot;b&quot;: { &quot;c&quot;: 2 }, &quot;d&quot;: [3,4], &quot;e&quot;: [ { &quot;f&quot;: 5 }, { &quot;g&quot;: 6 } ] } </code></pre> <p>out:</p> <pre><code>{ &quot;a&quot;: 1, &quot;b.c&quot;: 2, &quot;d.0&quot;: 3, &quot;d.1&quot;: 4, &quot;e.0.f&quot;: 5, &quot;e.1.g&quot;: 6 } </code></pre> <p>Background:</p> <ul> <li>We are looking for a way to merge nested dictionaries containing lists</li> <li>The available merge tools seem to always merge lists with either an append strategy or with a replace strategy</li> <li>We however need to merge dicts that are inside lists (as in the example). E.g., the first dict in the list should be merged with the first dict in the list</li> <li>The current approach is to chain like this: <code>flatten -&gt; merge -&gt; unflatten</code>. The question was only about the flatten piece. We have since seen that the unflatten is trickier</li> <li>Optimally, we use already existing robust libraries</li> </ul>
[ { "answer_id": 74157930, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 2, "selected": true, "text": "satisfies" }, { "answer_id": 74384571, "author": "Min Somai", "author_id": 6445166, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74157806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7079439/" ]
74,157,815
<pre><code>df['Example'] = df.groupby('Reference')['Example'].fillna(method='ffill') </code></pre> <p>I may be going about this the wrong way. I've been filling nan's in my dataframe for other columns using the above code. Which has worked great for filling missing information. But then I ran across a problem that wouldn't work on to fill a missing value. The situation I have I'm trying to solve now is this. <s>So I want to fill the blanks on the dept fields only on Beta, but I want to fill them with the Dept value from the line whose Description is Outsource. I've seen several conditional fill na examples but not one that works for my situation. </s> Edited the tables to try and make it less confusing. I wasn't quite expressing properly my issue before. What I'm looking for is if the press field contains beta, then it looks for the line with outsource in it. It uses the dept from outsource to fill the other nans on that invoice that have the same job#. But doesn't fill any other nans.</p> <p>My dataframe:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: center;">Invoice</th> <th style="text-align: center;">Reference</th> <th style="text-align: center;">Press</th> <th style="text-align: center;">Description</th> <th style="text-align: center;">Dept</th> </tr> </thead> <tbody> <tr> <td style="text-align: center;">INV0001</td> <td style="text-align: center;">Job#3045</td> <td style="text-align: center;">Alpha</td> <td style="text-align: center;">Copies</td> <td style="text-align: center;"></td> </tr> <tr> <td style="text-align: center;">INV0001</td> <td style="text-align: center;">Job#3045</td> <td style="text-align: center;">Alpha</td> <td style="text-align: center;">Binding</td> <td style="text-align: center;"></td> </tr> <tr> <td style="text-align: center;">INV0002</td> <td style="text-align: center;">Job#3055</td> <td style="text-align: center;">Beta</td> <td style="text-align: center;">Design</td> <td style="text-align: center;"></td> </tr> <tr> <td style="text-align: center;">INV0002</td> <td style="text-align: center;">Job#3055</td> <td style="text-align: center;">Beta</td> <td style="text-align: center;">Outsource</td> <td style="text-align: center;">Digital</td> </tr> <tr> <td style="text-align: center;">INV0002</td> <td style="text-align: center;">Job#3055</td> <td style="text-align: center;">Beta</td> <td style="text-align: center;">Site Survey</td> <td style="text-align: center;"></td> </tr> <tr> <td style="text-align: center;">INV0002</td> <td style="text-align: center;">Job#3056</td> <td style="text-align: center;">Beta</td> <td style="text-align: center;">Packaging</td> <td style="text-align: center;"></td> </tr> <tr> <td style="text-align: center;">INV0002</td> <td style="text-align: center;">Job#3056</td> <td style="text-align: center;">Beta</td> <td style="text-align: center;">Mounting Brackets</td> <td style="text-align: center;">Sign</td> </tr> <tr> <td style="text-align: center;">INV0002</td> <td style="text-align: center;">Job#3056</td> <td style="text-align: center;">Beta</td> <td style="text-align: center;">Installation</td> <td style="text-align: center;">Sign</td> </tr> <tr> <td style="text-align: center;">INV0003</td> <td style="text-align: center;">Job#3067</td> <td style="text-align: center;">Delta</td> <td style="text-align: center;">Binding</td> <td style="text-align: center;">Bond</td> </tr> <tr> <td style="text-align: center;">INV0004</td> <td style="text-align: center;">Job#3042</td> <td style="text-align: center;">Beta</td> <td style="text-align: center;">Site Survey</td> <td style="text-align: center;"></td> </tr> <tr> <td style="text-align: center;">INV0004</td> <td style="text-align: center;">Job#3042</td> <td style="text-align: center;">Beta</td> <td style="text-align: center;">Outsource</td> <td style="text-align: center;">Color</td> </tr> <tr> <td style="text-align: center;">INV0004</td> <td style="text-align: center;">Job#3042</td> <td style="text-align: center;">Beta</td> <td style="text-align: center;">Design</td> <td style="text-align: center;"></td> </tr> <tr> <td style="text-align: center;">INV0005</td> <td style="text-align: center;">Job#3058</td> <td style="text-align: center;">Ceta</td> <td style="text-align: center;">Installation</td> <td style="text-align: center;">Sign</td> </tr> </tbody> </table> </div> <p>What I want it to look like after fillna:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: center;">Invoice</th> <th style="text-align: center;">Reference</th> <th style="text-align: center;">Press</th> <th style="text-align: center;">Description</th> <th style="text-align: center;">Dept</th> </tr> </thead> <tbody> <tr> <td style="text-align: center;">INV0001</td> <td style="text-align: center;">Job#3045</td> <td style="text-align: center;">Alpha</td> <td style="text-align: center;">Copies</td> <td style="text-align: center;"></td> </tr> <tr> <td style="text-align: center;">INV0001</td> <td style="text-align: center;">Job#3045</td> <td style="text-align: center;">Alpha</td> <td style="text-align: center;">Binding</td> <td style="text-align: center;"></td> </tr> <tr> <td style="text-align: center;">INV0002</td> <td style="text-align: center;">Job#3055</td> <td style="text-align: center;">Beta</td> <td style="text-align: center;">Design</td> <td style="text-align: center;">Digital</td> </tr> <tr> <td style="text-align: center;">INV0002</td> <td style="text-align: center;">Job#3055</td> <td style="text-align: center;">Beta</td> <td style="text-align: center;">Outsource</td> <td style="text-align: center;">Digital</td> </tr> <tr> <td style="text-align: center;">INV0002</td> <td style="text-align: center;">Job#3055</td> <td style="text-align: center;">Beta</td> <td style="text-align: center;">Site Survey</td> <td style="text-align: center;">Digital</td> </tr> <tr> <td style="text-align: center;">INV0002</td> <td style="text-align: center;">Job#3056</td> <td style="text-align: center;">Beta</td> <td style="text-align: center;">Packaging</td> <td style="text-align: center;"></td> </tr> <tr> <td style="text-align: center;">INV0002</td> <td style="text-align: center;">Job#3056</td> <td style="text-align: center;">Beta</td> <td style="text-align: center;">Mounting Brackets</td> <td style="text-align: center;">Sign</td> </tr> <tr> <td style="text-align: center;">INV0002</td> <td style="text-align: center;">Job#3056</td> <td style="text-align: center;">Beta</td> <td style="text-align: center;">Installation</td> <td style="text-align: center;">Sign</td> </tr> <tr> <td style="text-align: center;">INV0003</td> <td style="text-align: center;">Job#3067</td> <td style="text-align: center;">Delta</td> <td style="text-align: center;">Binding</td> <td style="text-align: center;">Bond</td> </tr> <tr> <td style="text-align: center;">INV0004</td> <td style="text-align: center;">Job#3042</td> <td style="text-align: center;">Beta</td> <td style="text-align: center;">Site Survey</td> <td style="text-align: center;">Color</td> </tr> <tr> <td style="text-align: center;">INV0004</td> <td style="text-align: center;">Job#3042</td> <td style="text-align: center;">Beta</td> <td style="text-align: center;">Outsource</td> <td style="text-align: center;">Color</td> </tr> <tr> <td style="text-align: center;">INV0004</td> <td style="text-align: center;">Job#3042</td> <td style="text-align: center;">Beta</td> <td style="text-align: center;">Design</td> <td style="text-align: center;">Color</td> </tr> <tr> <td style="text-align: center;">INV0005</td> <td style="text-align: center;">Job#3058</td> <td style="text-align: center;">Ceta</td> <td style="text-align: center;">Installation</td> <td style="text-align: center;">Sign</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74157930, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 2, "selected": true, "text": "satisfies" }, { "answer_id": 74384571, "author": "Min Somai", "author_id": 6445166, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74157815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20303536/" ]
74,157,829
<p>I have a table of time periods with an active incident in the format:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: center;">Incident_Start</th> <th style="text-align: center;">Incident_End</th> </tr> </thead> <tbody> <tr> <td style="text-align: center;">1/1/2022 01:05</td> <td style="text-align: center;">1/1/2022 03:00</td> </tr> <tr> <td style="text-align: center;">1/2/2022 05:00</td> <td style="text-align: center;">1/5/2022 12:34</td> </tr> <tr> <td style="text-align: center;">2/5/2022 13:00</td> <td style="text-align: center;">2/6/2022 16:22</td> </tr> <tr> <td style="text-align: center;">...</td> <td style="text-align: center;">...</td> </tr> </tbody> </table> </div> <p>I now need to transform this into a table of dates with the total minutes an incident was active during each date like:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: center;">Date</th> <th style="text-align: center;">Incident Minutes</th> </tr> </thead> <tbody> <tr> <td style="text-align: center;">1/1/2022</td> <td style="text-align: center;">115</td> </tr> <tr> <td style="text-align: center;">1/2/2022</td> <td style="text-align: center;">1140</td> </tr> <tr> <td style="text-align: center;">1/3/2022</td> <td style="text-align: center;">1440</td> </tr> <tr> <td style="text-align: center;">1/4/2022</td> <td style="text-align: center;">1440</td> </tr> <tr> <td style="text-align: center;">1/5/2022</td> <td style="text-align: center;">754</td> </tr> <tr> <td style="text-align: center;">1/6/2022</td> <td style="text-align: center;">0</td> </tr> <tr> <td style="text-align: center;">...</td> <td style="text-align: center;">...</td> </tr> </tbody> </table> </div> <p>I am able to do this easily via Python/JavaScript like (in pseudo-code, very naively):</p> <pre><code>dates = [dates between start_date, end_date] for (date in dates): if (impact_periods.filter(start_date &lt;= date &amp;&amp; end_date &gt;= date).length &gt; 0): outage_mins = 1440 else if (impact_periods.filter(start_date &gt;= date &amp;&amp; end_date &lt;= date).length &gt; 0): outage_mins = sum(impact_periods.filter(start_date &gt;= date &amp;&amp; end_date &lt;= date).outage_mins) etc </code></pre> <p>Now I'd like to do this with a SQL query, but I'm not sure how. Obviously, I'll start by creating a date table between the dates I'm interested in:</p> <pre><code>SELECT dd day_start, dd::date + 1 - interval '1 sec' AS day_end FROM generate_series ( 'date_start' :: timestamp, 'date_end' :: timestamp, '1 day' :: interval ) dd </code></pre> <p>But now I'm not sure how to sum the impact mins on each day, taking into account that some incidents may start before the day and end during, or start during the day and end after.</p> <p>Can someone point me in the right direction of how to solve this? Any help is greatly appreciated!</p>
[ { "answer_id": 74157930, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 2, "selected": true, "text": "satisfies" }, { "answer_id": 74384571, "author": "Min Somai", "author_id": 6445166, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74157829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20303451/" ]
74,157,835
<p>I was learning destructuring and got stuck when both the key and value of the object are strings.</p> <p>This is the <code>App.js</code> and here I am destructuring the object, I am getting a syntax error.</p> <p>I have commented the line where I am getting an error</p> <pre><code>import &quot;./styles.css&quot;; const info = { name: &quot;Ankit Singh Chauhan&quot;, standard : 12 , subjects : { sub1 : &quot;Maths&quot; , sub2 : &quot;Science&quot; , sub3 :{ &quot;sub3.1&quot; : &quot;ballleballe&quot; , &quot;sub3.2&quot; : &quot;AdvancePhysics&quot;, } } } export default function App() { const {name ,standard ,subjects} = info ; const {sub1 , sub2 , sub3} = subjects; // const { &quot;sub3.1&quot; , &quot;sub3.2&quot;} = sub3 ; return ( &lt;&gt; &lt;div&gt; &lt;h3&gt; Hi my name is {name} and I study in class {standard} my favourite subjects are {sub1} and {sub2}&lt;/h3&gt; &lt;h1&gt; And the advance one are {sub3[&quot;sub3.1&quot;]} and {sub3.[&quot;sub3.2&quot;]} &lt;/h1&gt; &lt;/div&gt; &lt;/&gt; ); } </code></pre> <p>Can you suggest me some edits?</p>
[ { "answer_id": 74157893, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 2, "selected": true, "text": "const { \"sub3.1\": sub3dot1, \"sub3.2\": sub3dot2 } = sub3;\n" }, { "answer_id": 74158222, "author": "oal...
2022/10/21
[ "https://Stackoverflow.com/questions/74157835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19757319/" ]
74,157,840
<p>Provided that EC2 and RDS are on the same VPC, is there an internal endpoint we need to use to speed up data exchange between the two?</p> <p>Similar to how if MySQL + Apache are on 1 server we would connect using 'localhost' (avoiding TCP/IP).</p>
[ { "answer_id": 74157893, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 2, "selected": true, "text": "const { \"sub3.1\": sub3dot1, \"sub3.2\": sub3dot2 } = sub3;\n" }, { "answer_id": 74158222, "author": "oal...
2022/10/21
[ "https://Stackoverflow.com/questions/74157840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3221100/" ]
74,157,852
<pre><code>&lt;div className={classes.productSection}&gt; {available.map((product)=&gt; (&lt;div key={product.id} className={product.availability? classes.productBox : classes.notavailBox}&gt; &lt;h4&gt;{product.user.companyName}&lt;/h4&gt; &lt;p&gt;{product.user.district}&lt;/p&gt; {product.availability &amp;&amp; &lt;button className={classes.cartButton}&gt;Add&lt;/button&gt; } &lt;/div&gt; ) )} &lt;/div&gt; </code></pre> <p>this is the styling</p> <pre><code>.productSection { display: grid; grid-gap: 1rem; grid-template-columns: 20% 20% 20%; justify-content: center; animation: append-animate .5s linear; margin-bottom: 1rem; } .productBox { white-space: nowrap; border: 1.5px solid gray; padding: 10px; overflow: hidden; border-radius: 12px; } </code></pre> <p>the problem is I couldn't position the button. when using absolute positioning, it is positioned depend on the body not the parent element. I need a button in the right side of the parent div and vertically centered.</p>
[ { "answer_id": 74158091, "author": "Sandu Morari", "author_id": 13381872, "author_profile": "https://Stackoverflow.com/users/13381872", "pm_score": 1, "selected": false, "text": "position: relative;\n" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74157852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18249027/" ]
74,157,876
<p>I have a problem. I want to remove all rows that are not a number in the column <code>['a','b']</code>. I have tried this but my approach does not work very well.</p> <p>Dataframe</p> <pre class="lang-py prettyprint-override"><code> a b c 0 0.1 10 x 1 0.5 5 y 2 10 / 5 60 z 3 9.0 12 w 4 125 a w </code></pre> <p>Code</p> <pre class="lang-py prettyprint-override"><code>import uuid import pandas as pd df = pd.DataFrame( {'a': [0.1,0.5,'10 / 5', 9.0, 125], 'b': [10, 5, 60, 12, 'a'], 'c': ['x', 'y', 'z', 'w', 'w'] }) print(df) df['id'] = df.apply(lambda x: uuid.uuid4().int, axis=1) df_ = df[['a', 'b', 'id']].apply(lambda x: pd.to_numeric(x, errors='coerce')).dropna() df.merge(df_, left_on=['id'], right_on=['id'], how='inner') </code></pre> <p>What I want</p> <pre class="lang-py prettyprint-override"><code> a b c 0 0.1 10 x 1 0.5 5 y 3 9.0 12 w </code></pre>
[ { "answer_id": 74157990, "author": "BENY", "author_id": 7964527, "author_profile": "https://Stackoverflow.com/users/7964527", "pm_score": 3, "selected": true, "text": "out = df[~df[['a', 'b', 'id']].apply(lambda x: pd.to_numeric(x, errors='coerce')).isna().any(1)]\n" }, { "answer...
2022/10/21
[ "https://Stackoverflow.com/questions/74157876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17136258/" ]
74,157,901
<p>Good Afternoon,</p> <p>I am new to sql, but working on a project where they want a random sample of 59 accounts where 67% are new and the other 33% are repeat.</p> <p>Would anyone know of a way to accomplish this? I know i can use Select Top (67) Percent with Ties * from table where reason is new.</p> <p>Is there a way to accomplish both in 1 query?</p>
[ { "answer_id": 74157990, "author": "BENY", "author_id": 7964527, "author_profile": "https://Stackoverflow.com/users/7964527", "pm_score": 3, "selected": true, "text": "out = df[~df[['a', 'b', 'id']].apply(lambda x: pd.to_numeric(x, errors='coerce')).isna().any(1)]\n" }, { "answer...
2022/10/21
[ "https://Stackoverflow.com/questions/74157901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20303714/" ]
74,157,909
<p>I have a lazycolumn with items, and I want to send an event every time one of the items appears on screen. There are examples of events being sent the first time (like here <a href="https://plusmobileapps.com/2022/05/04/lazy-column-view-impressions.html" rel="nofollow noreferrer">https://plusmobileapps.com/2022/05/04/lazy-column-view-impressions.html</a>) but that example doesn't send events on subsequent times the same item reappears (when scrolling up, for example).</p> <p>I know it shouldn't be tied to composition, because there can be multiple recompositions while an item remains on screen. What would be the best approach to solve something like this?</p>
[ { "answer_id": 74665173, "author": "Gabriele Mariotti", "author_id": 2016562, "author_profile": "https://Stackoverflow.com/users/2016562", "pm_score": 1, "selected": false, "text": "LazyListState#layoutInfo" }, { "answer_id": 74665896, "author": "Thracian", "author_id": 5...
2022/10/21
[ "https://Stackoverflow.com/questions/74157909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5760308/" ]
74,157,924
<p>New R user here.</p> <p>I have a dataset for about 400 stations, and I am trying to get standard deviation of p and regression slope for each site.</p> <p>I have used the following to get part of the way there, but I don't know how to approach the last part of the problem to fit a linear regression to each site individually, get the slope of the line, and create another column with the slope of the line for each site.</p> <p>I appreciate any help!</p> <pre><code># Sample df df &lt;- data.frame(site.id=c(&quot;1&quot;, &quot;1&quot;, &quot;2&quot;, &quot;2&quot;, &quot;3&quot;, &quot;3&quot;), year=c(&quot;2019&quot;, &quot;2020&quot;, &quot;2019&quot;, &quot;2020&quot;, &quot;2019&quot;, &quot;2020&quot;), p=c(107, 101, 114, 117, 97, 89) print(df) # Summarize df.sum &lt;- df %&gt;% group_by(site.id) %&gt;% summarise(p.sd=sd(p)) print(df.sum) </code></pre>
[ { "answer_id": 74158260, "author": "br00t", "author_id": 4028717, "author_profile": "https://Stackoverflow.com/users/4028717", "pm_score": 0, "selected": false, "text": "\n# Sample df\ndf <- data.frame(site.id = c(1, 1, 2, 2, 3, 3), \n year = c(2019, 2020, 2019, 2020, 201...
2022/10/21
[ "https://Stackoverflow.com/questions/74157924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20303477/" ]
74,157,933
<p>I have created a maze-solving algorithm like this:</p> <pre><code>#include &lt;stdio.h&gt; // Maze size #define N 6 //define boolean #ifndef MYBOOLEAN_H #define MYBOOLEAN_H #define false 0 #define true 1 typedef int bool; #endif int startX = 0; int startY = 0; //function prototype bool solveMazeUtil(char maze[N][N], int x, int y, char sol[N][N]); int main() { char maze[N][N] = {{'.','#','#','#','#','#'}, {'.','.','.','.','.','#'}, {'#','.','#','#','#','#'}, {'#','.','#','#','#','#'}, {'.','.','.','#','.','G'}, {'#','#','.','.','.','#'}}; mazeGo(maze); return 0; } //print the solution void printSolution(char sol[N][N]) { for (int i = 0; i &lt; N; i++) { for (int j = 0; j &lt; N; j++) printf(&quot; %c &quot;, sol[i][j]); printf(&quot;\n&quot;); } } //checking if in correct path bool isSafe(char maze[N][N], int x, int y) { // if not, return false if (x &gt;= 0 &amp;&amp; x &lt; N &amp;&amp; y &gt;= 0 &amp;&amp; y &lt; N &amp;&amp; maze[x][y] == '.') return true; else return false; } bool mazeGo(char maze[N][N]) { char sol[N][N] = {{'#','#','#','#','#','#'}, {'#','#','#','#','#','#'}, {'#','#','#','#','#','#'}, {'#','#','#','#','#','#'}, {'#','#','#','#','#','#'}, {'#','#','#','#','#','#'}}; if (solveMazeUtil(maze, startX, startY, sol) == false) { printf(&quot;No solution&quot;); return false; } printSolution(sol); return true; } //actual maze solving bool solveMazeUtil(char maze[N][N], int x, int y, char sol[N][N]) { // if (x, y) is goal return true if (maze[x][y] == 'G') { sol[x][y] = '+'; return true; } // Check if maze[x][y] is valid if (isSafe(maze, x, y) == true) { // mark x, y sol[x][y] = '+'; maze[x][y] = '#'; //try move right if (solveMazeUtil(maze, x + 1, y, sol) == '.') sol[x+1][y] = '+'; maze[x+1][y] = '#'; return true; //try move down if (solveMazeUtil(maze, x, y + 1, sol) == '.') sol[x][y+1] = '+'; maze[x][y+1] = '#'; return true; //try move left if (solveMazeUtil(maze, x - 1, y, sol) == '.') sol[x-1][y] = '+'; maze[x-1][y] = '#'; return true; //try move up if (solveMazeUtil(maze, x, y - 1, sol) == '.') sol[x][y-1] = '+'; maze[x][y-1] = '#'; return true; // If none of the above movements work then unmark x, y sol[x][y] = '#'; maze[x][y] = '.'; } return false; } </code></pre> <p>Which should start from (0,0) and end at G, and I'm expecting an output of</p> <pre><code> + # # # # # + + # # # # # + # # # # # + # # # # # + + # + + # # + + + # </code></pre> <p>But getting a result of</p> <pre><code> + # # # # # + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # </code></pre> <p>I've tried to delete the 'return true' in line 101, which makes the program go further but is still not giving the expected output.</p> <p>Can anyone help me determine where I made the mistake?</p>
[ { "answer_id": 74158678, "author": "chqrlie", "author_id": 4593267, "author_profile": "https://Stackoverflow.com/users/4593267", "pm_score": 3, "selected": true, "text": "solveMazeUtil" }, { "answer_id": 74158689, "author": "John Bollinger", "author_id": 2402272, "aut...
2022/10/21
[ "https://Stackoverflow.com/questions/74157933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20133031/" ]
74,157,935
<p>I'm intending to use yt-dlp to download a video and then cut the video down afterward using ffmpeg. But to be able to use ffmpeg I am going to have to know the name of the file that yt-dlp produces. I have read through their documentation but I can't seem to find a way of getting the file name back into my program.</p>
[ { "answer_id": 74158678, "author": "chqrlie", "author_id": 4593267, "author_profile": "https://Stackoverflow.com/users/4593267", "pm_score": 3, "selected": true, "text": "solveMazeUtil" }, { "answer_id": 74158689, "author": "John Bollinger", "author_id": 2402272, "aut...
2022/10/21
[ "https://Stackoverflow.com/questions/74157935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19200783/" ]
74,157,971
<p><em>Hi I am new to robot frame work so in my local library's I have a file which is encapsulated in two directories , i want to access some functions form that file so how can I import that as a library in my robot test suit</em></p> <p><strong>libraries/dir1/dir2/file.py</strong> -- is the file path (in python files)&gt;</p> <p>tried to add it as library with &gt; &quot;&quot;&quot;dir1.dir2.file &quot;&quot;&quot; --but it throws an error &gt;</p>
[ { "answer_id": 74158678, "author": "chqrlie", "author_id": 4593267, "author_profile": "https://Stackoverflow.com/users/4593267", "pm_score": 3, "selected": true, "text": "solveMazeUtil" }, { "answer_id": 74158689, "author": "John Bollinger", "author_id": 2402272, "aut...
2022/10/21
[ "https://Stackoverflow.com/questions/74157971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20303685/" ]
74,157,987
<p>Which code best generates all 3-letter combinations of a given set of letters in Python? I want to output something like this: <code>'AAA', 'AAB', 'AAC', 'AAD', 'AAE', 'AAF', 'AAG', 'AAH', 'AAI', 'AAJ', 'AAK', 'AAL', 'AAM'...'ZZX', 'ZZY', 'ZZZ'</code></p>
[ { "answer_id": 74158037, "author": "vegiv", "author_id": 11109346, "author_profile": "https://Stackoverflow.com/users/11109346", "pm_score": 0, "selected": false, "text": "combinations = []\nletters = ['A','B','C',....,'Z']\nfor letter1 in letters:\n code = ''\n code = code + lette...
2022/10/21
[ "https://Stackoverflow.com/questions/74157987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19154387/" ]
74,157,993
<p>I have a structure with a pointer to something. I was expecting that accessing this pointer via a pointer-to-const-struct to the struct gives me a pointer-to-const-something. But gcc does not produce a warning in this case:</p> <pre><code>#include &lt;stdlib.h&gt; struct S { void* ptr; }; struct S* create(void) { struct S* S = malloc(sizeof(*S)); S-&gt;ptr = malloc(sizeof(int)); return S; } void some_func(void* p); int main(void) { struct S* S = create(); const void* ptr = S-&gt;ptr; const struct S* SC = S; some_func(ptr); // warning as expected some_func(SC-&gt;ptr); // no warning } </code></pre> <p>So is <code>SC-&gt;ptr</code> actually a <code>const void*</code>? I always assumed but now I'm confused. Is there a possibility to get a warning in this case?</p>
[ { "answer_id": 74158049, "author": "Eric Postpischil", "author_id": 298225, "author_profile": "https://Stackoverflow.com/users/298225", "pm_score": 4, "selected": true, "text": "SC->ptr" }, { "answer_id": 74158275, "author": "John Bollinger", "author_id": 2402272, "au...
2022/10/21
[ "https://Stackoverflow.com/questions/74157993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3197530/" ]
74,158,005
<p>so I'm trying to be a clever-a$$ and return a promise from a hook (so I can await the value instead of waiting for the hook to give me the value after its resolved and the hook reruns). I'm attempting something like this, and everything is working until the resolve part. The <code>.then</code> doesnt ever seem to run, which tells me that the resolve I set isn't firing correctly. Here's the code:</p> <pre><code>function App() { const { valPromise } = useSomeHook(); const [state, setState] = React.useState(); React.useEffect(() =&gt; { valPromise.then(r =&gt; { setState(r); }); }, []); if (!state) return 'not resolved yet'; return 'resolved: ' + state; } function useSomeHook() { const [state, setState] = React.useState(); const resolve = React.useRef(); const valPromise = React.useRef(new Promise((res) =&gt; { resolve.current = res; })); React.useEffect(() =&gt; { getValTimeout({ setState }); }, []); React.useEffect(() =&gt; { if (!state) return; resolve.current(state); }, [state]); return { valPromise: valPromise.current, state }; } function getValTimeout({ setState }) { setTimeout(() =&gt; { setState('the val'); }, 1000); } </code></pre> <p>and a working jsfiddle: <a href="https://jsfiddle.net/8a4oxse5/" rel="nofollow noreferrer">https://jsfiddle.net/8a4oxse5/</a></p> <p>I tried something similar (re-assigning the 'resolve' part of the promise constructor) with plain functions, and it seems to work:</p> <pre><code>let resolve; function initPromise() { return new Promise((res) =&gt; { resolve = res; }); } function actionWithTimeout() { setTimeout(() =&gt; { resolve('the val'); }, 2000); } const promise = initPromise(); actionWithTimeout(); promise.then(console.log); </code></pre> <p>jsfiddle: <a href="https://jsfiddle.net/pa1xL025/" rel="nofollow noreferrer">https://jsfiddle.net/pa1xL025/</a></p> <p>which makes me think something is happening with the useRef or with rendering.</p> <p>** update **</p> <p>so it looks like the useRefs are working fine. its the final call to 'res' (or resolve) that doesn't seem to fulfill the promise (promise stays pending). not sure if a reference (the one being returned from the hook) is breaking between renders or something</p>
[ { "answer_id": 74158445, "author": "Giorgi Moniava", "author_id": 3963067, "author_profile": "https://Stackoverflow.com/users/3963067", "pm_score": 3, "selected": true, "text": "const valPromise = React.useRef();\nif (!valPromise.current) {\n valPromise.current = new Promise((res) => ...
2022/10/21
[ "https://Stackoverflow.com/questions/74158005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2939522/" ]
74,158,020
<p>I have four separate sets of data for each of the 4 quarters in the year, the columns are identical within all. What is a python function I can use to combine them into one master data set? Thank you!</p>
[ { "answer_id": 74158075, "author": "vegiv", "author_id": 11109346, "author_profile": "https://Stackoverflow.com/users/11109346", "pm_score": 0, "selected": false, "text": "import pandas as pd\n\nset1 = pd.DataFrame(set1)\nset2 = pd.DataFrame(set2)\nset3 = pd.DataFrame(set3)\nmaster_set =...
2022/10/21
[ "https://Stackoverflow.com/questions/74158020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20187301/" ]
74,158,028
<p>i'm trying to use data property commentsToShow in my html template to limit the amount of data that displays on my webpage</p> <p>this is my template</p> <pre><code>&lt;div v-if=&quot;index &lt; products.length&quot; v-for=&quot;(commentIndex, index) in computedProduct&quot;&gt; &lt;div class=&quot;title pt-4 pb-1&quot;&gt;{{products[index].title}}&lt;/div&gt; &lt;/div&gt; </code></pre> <p>if i add <code>commentsToShow</code> in my for loop i get one product but the computed products doesn't work same way the other way round</p> <p>this my script tag</p> <pre><code>&lt;script&gt; export default { data() { return { commentsToShow: 1, totalComments: 0, }; }, computed: { computedProduct() { let tempRecipes = this.products; if (this.filterPrice !== &quot;true&quot;); } }; &lt;/script&gt; </code></pre> <p>if i change computed property to commentsToShow this the error i get in my console</p> <pre><code>The computed property &quot;commentsToShow&quot; is already defined in data. </code></pre> <p>please how can i get the value of <code>commentToShow</code> in my template</p>
[ { "answer_id": 74158075, "author": "vegiv", "author_id": 11109346, "author_profile": "https://Stackoverflow.com/users/11109346", "pm_score": 0, "selected": false, "text": "import pandas as pd\n\nset1 = pd.DataFrame(set1)\nset2 = pd.DataFrame(set2)\nset3 = pd.DataFrame(set3)\nmaster_set =...
2022/10/21
[ "https://Stackoverflow.com/questions/74158028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18198067/" ]
74,158,054
<p>why is document.getElementById() not working in VS Code?? I keep getting this error: &quot;Uncaught ReferenceError ReferenceError: document is not defined&quot;. I'm new to VS Code but I'm assuming the reason It's not working is that I need to install some extension to make it work. The same code is working on Replit but not VS code. I installed JS(ES6) Snippets, Open-in browser, Live Preview and Live Server. It's very simple 2-line code just to experiment but it's not working. It's driving me crazy!</p> <pre class="lang-js prettyprint-override"><code>let head = document.getElementById('change') head.innerText = 'hello' </code></pre>
[ { "answer_id": 74158133, "author": "mruanova", "author_id": 5490782, "author_profile": "https://Stackoverflow.com/users/5490782", "pm_score": 1, "selected": false, "text": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta http-equiv=\"X-UA-Compatible\" content...
2022/10/21
[ "https://Stackoverflow.com/questions/74158054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20303646/" ]
74,158,063
<p>So, I have this code login.js:</p> <pre><code>function Login() { return ( &lt;div className=&quot;bg-deskbg&quot;&gt; &lt;/div&gt; );} export default Login; </code></pre> <p>and in tailwind.config.js</p> <pre><code>module.exports = { content: [&quot;./pages/**/*.{js,jsx,ts,tsx}&quot;, &quot;./components/**/*.{js,jsx,ts,tsx}&quot;], theme: { fontFamily: { &quot;pacifico&quot;: ['Pacifico', 'cursive'], &quot;righteous&quot;: ['Righteous', 'cursive'], }, extend: { backgroundImage: { 'deskbg' : &quot;url('../public/bg.jpg')&quot;, } }, }, plugins: [], }; </code></pre> <p>I am trying to put the image bg.jpg as a background image but t's not working, what shall I do.</p>
[ { "answer_id": 74158133, "author": "mruanova", "author_id": 5490782, "author_profile": "https://Stackoverflow.com/users/5490782", "pm_score": 1, "selected": false, "text": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta http-equiv=\"X-UA-Compatible\" content...
2022/10/21
[ "https://Stackoverflow.com/questions/74158063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19572505/" ]
74,158,071
<p>I have a list of file names that I need to open, however, the file names contain a hyphen &quot;-&quot; which neither os or Windows 10 naturally recognizes as a negative number. As an example, the list itself gets imported as</p> <pre><code>['-001.000ps.csv', '-100.000ps.csv', '0000.000ps.csv', '0001.000ps.csv', '0002.000ps.csv', '0003.000ps.csv', '0003.500ps.csv', ] </code></pre> <p>where -1 preceeds -100. The positions of -1 and -100 needs to be reversed and I need to preserve the leading zeros and &quot;ps.csv&quot; component because the files are named this way.</p> <p>I attempted some solutions I found on this stackexchange, however, what most people wanted dealt with searching for positive numbers and ordering off of that. For the <a href="https://stackoverflow.com/questions/4836710/is-there-a-built-in-function-for-string-natural-sort">natsort package</a>, what happens is that -1 and -100 are put at the bottom of the list.</p> <p>Converting these strings to ints or floats fails, I guess because ps.csv is inside of the element.</p> <p>I copy pasted the solution from the <a href="https://stackoverflow.com/questions/2545532/python-analog-of-phps-natsort-function-sort-a-list-using-a-natural-order-alg">blogpost referenced here</a> and the same issue occurs. I feel like I'm missing something obvious here, why are the negative numbers not working?</p>
[ { "answer_id": 74158164, "author": "msamsami", "author_id": 13476175, "author_profile": "https://Stackoverflow.com/users/13476175", "pm_score": 1, "selected": false, "text": "a = ['-001.000ps.csv',\n '-100.000ps.csv',\n '0000.000ps.csv',\n '0001.000ps.csv',\n '0002.000ps....
2022/10/21
[ "https://Stackoverflow.com/questions/74158071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14445454/" ]
74,158,072
<p>Use case: wrapping n object arrays in an array to loop over all arrays in one go and filter the objects on a property.</p> <p>Known solutions I want to avoid:</p> <pre><code>[arr1,arr2,arr3] = [arr1,arr2,arr3].map(...) </code></pre> <hr /> <pre><code>[&quot;arr1&quot;,&quot;arr2&quot;,&quot;arr3&quot;].forEach(arrName =&gt; window[arrName] = .....) </code></pre> <hr /> <p>In the code below, why are the arrays not changed outside the forEach - some &quot;pass by reference&quot; issue? How to solve this?</p> <p>Expected result:</p> <pre><code>[{&quot;B&quot;:&quot;b&quot;,&quot;remove&quot;:false},{&quot;C&quot;:&quot;c&quot;}] [{&quot;A&quot;:&quot;a&quot;,&quot;remove&quot;:false},{&quot;C&quot;:&quot;c&quot;,&quot;remove&quot;:false}] [{&quot;B&quot;:&quot;b&quot;,&quot;remove&quot;:false}] </code></pre> <p>Actual result</p> <pre><code>[{&quot;A&quot;:&quot;a&quot;,&quot;remove&quot;:true},{&quot;B&quot;:&quot;b&quot;,&quot;remove&quot;:false},{&quot;C&quot;:&quot;c&quot;}] [{&quot;A&quot;:&quot;a&quot;,&quot;remove&quot;:false},{&quot;B&quot;:&quot;b&quot;,&quot;remove&quot;:true},{&quot;C&quot;:&quot;c&quot;,&quot;remove&quot;:false}] [{&quot;A&quot;:&quot;a&quot;,&quot;remove&quot;:true},{&quot;B&quot;:&quot;b&quot;,&quot;remove&quot;:false},{&quot;C&quot;:&quot;c&quot;,&quot;remove&quot;:true}] </code></pre> <p>How to retain the changes outside the forEach?</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>let arr1 = [ {"A":"a", "remove":true}, {"B":"b", "remove":false}, {"C":"c"} ]; let arr2 = [ {"A":"a", "remove": false}, {"B":"b", "remove": true}, {"C":"c", "remove": false} ]; let arr3 = [ {"A":"a", "remove": true}, {"B":"b", "remove": false}, {"C":"c", "remove": true} ]; [arr1, arr2, arr3] .forEach(arr =&gt; { arr = [...arr.filter(({remove})=&gt; !remove)] console.log(JSON.stringify(arr)); // works }); console.log("---------------"); // check it worked [arr1, arr2, arr3].forEach(arr =&gt; console.log(JSON.stringify(arr)));</code></pre> </div> </div> </p>
[ { "answer_id": 74158164, "author": "msamsami", "author_id": 13476175, "author_profile": "https://Stackoverflow.com/users/13476175", "pm_score": 1, "selected": false, "text": "a = ['-001.000ps.csv',\n '-100.000ps.csv',\n '0000.000ps.csv',\n '0001.000ps.csv',\n '0002.000ps....
2022/10/21
[ "https://Stackoverflow.com/questions/74158072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20303583/" ]
74,158,086
<p>Running the Hugo server with <code>--debug</code> shows all pages loading without any syntax errors, but they aren't displaying properly. I suspect that the site-heading.html file is part (if not all) of the problem. I've no idea how to debug logical errors with HTML code in Hugo.</p> <p>Please point me to resources where I can learn how to debug my Hugo code.</p>
[ { "answer_id": 74158164, "author": "msamsami", "author_id": 13476175, "author_profile": "https://Stackoverflow.com/users/13476175", "pm_score": 1, "selected": false, "text": "a = ['-001.000ps.csv',\n '-100.000ps.csv',\n '0000.000ps.csv',\n '0001.000ps.csv',\n '0002.000ps....
2022/10/21
[ "https://Stackoverflow.com/questions/74158086", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1943612/" ]
74,158,097
<p>I understand how to convert a BGR image to YCrCb format using <code>cvtColor()</code> and separate different channels using <code>split()</code> in OpenCV. However, these channels are displayed as grayscale images:</p> <pre><code>imgYCrCB = cv2.cvtColor(img, cv2.COLOR_BGR2YCrCb) Y, Cr, Cb = cv2.split(imgYCrCB) cv2.imshow(&quot;Y&quot;, Y) cv2.imshow(&quot;Cr&quot;, Cr) cv2.imshow(&quot;Cb&quot;, Cb) cv2.waitKey(0) </code></pre> <p>This code give these results:</p> <p>Gray images:<br /> <a href="https://i.stack.imgur.com/Th9DX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Th9DX.png" alt="enter image description here" /></a></p> <p>I would like to display Cb and Cr channels in color like this image:<br /> <a href="https://i.stack.imgur.com/nRXkW.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nRXkW.jpg" alt="enter image description here" /></a></p> <p>How can I do it?</p>
[ { "answer_id": 74159129, "author": "fmw42", "author_id": 7355741, "author_profile": "https://Stackoverflow.com/users/7355741", "pm_score": 0, "selected": false, "text": "import cv2\nimport numpy as np \n\n# read image\nimg = cv2.imread('barn.jpg')\nhh, ww = img.shape[:2]\n\n# convert to ...
2022/10/21
[ "https://Stackoverflow.com/questions/74158097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10636012/" ]
74,158,101
<p>I have a single database table <code>affiliations</code> in the following format:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>author_id</th> <th>article_id</th> <th>institution</th> <th>publication_date</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1</td> <td>institution_1</td> <td>2010-01-01</td> </tr> <tr> <td>1</td> <td>1</td> <td>institution_2</td> <td>2010-01-01</td> </tr> <tr> <td>1</td> <td>2</td> <td>institution_2</td> <td>2012-01-01</td> </tr> <tr> <td>1</td> <td>3</td> <td>institution_2</td> <td>2014-01-01</td> </tr> <tr> <td>2</td> <td>2</td> <td>institution_3</td> <td>2012-01-01</td> </tr> <tr> <td>2</td> <td>4</td> <td>institution_3</td> <td>2013-01-01</td> </tr> </tbody> </table> </div> <p>My goal is to infer periods of affiliations between a given author and their institutions, by combining publication dates across the author's consecutive articles where the same institution is on those articles and &quot;consecutive&quot; means published consecutively date-wise. For the most recent article of a given author, it is assumed that the author is still affiliated with the institution/s from that article. So for the data above, for example, I'm looking to return something like the following:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>author_id</th> <th>institution</th> <th>start_date</th> <th>end_date</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>institution_1</td> <td>2010-01-01</td> <td>2012-01-01</td> </tr> <tr> <td>1</td> <td>institution_2</td> <td>2010-01-01</td> <td>&lt;current_date&gt;</td> </tr> <tr> <td>2</td> <td>institution_3</td> <td>2012-01-01</td> <td>&lt;current_date&gt;</td> </tr> </tbody> </table> </div> <p>Importantly, an author can be affiliated with more than one institution at the same time, i.e. affiliations can overlap for the same author.</p> <p>I have tried various combinations of leads and partitions in SQL, but one of the issues I'm having is I'm not able to select the next value that is in a different partition (which I think I'll need to do to get the next publication date for a given author on a different article, for example).</p> <p>Does anyone have any suggestions on how I might achieve the above in a fairly efficient manner (bearing in mind this will be part of a CTE in a larger query that involves millions of rows)?</p>
[ { "answer_id": 74159129, "author": "fmw42", "author_id": 7355741, "author_profile": "https://Stackoverflow.com/users/7355741", "pm_score": 0, "selected": false, "text": "import cv2\nimport numpy as np \n\n# read image\nimg = cv2.imread('barn.jpg')\nhh, ww = img.shape[:2]\n\n# convert to ...
2022/10/21
[ "https://Stackoverflow.com/questions/74158101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10855379/" ]
74,158,110
<p>I have two filter function but is possible to be in one line? Check my code:</p> <p>this is work fine but is possible to be on one line?</p>
[ { "answer_id": 74158125, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 2, "selected": false, "text": "Boolean" }, { "answer_id": 74158128, "author": "David", "author_id": 328193, "author_profile": "h...
2022/10/21
[ "https://Stackoverflow.com/questions/74158110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20294615/" ]
74,158,114
<p>I'm reading data from a sensor. The sensor give an array of points (x,y). But as you can see in the image, there is a lot of noise:</p> <p><img src="https://i.stack.imgur.com/tZo9e.png" alt="point cloud with noise" />.</p> <p>I need to clean the data in a way that the data filtered, give a few points . Using something like Median,adjacent averaging, mean of the xy points or an algorithm that removes the noise. I know that there are a bunch of libraries in Python that make the work automatically. All the auto libraries that I found are base on image analysis and I think they do not work for this case because this is different, these are points (x,y) in a dataset.</p> <p>point-cloud noise cleaned:</p> <p><img src="https://i.stack.imgur.com/J6GVc.png" alt="point-cloud noise cleaned" /></p> <p>PD: I wanted to do the median of the points but i got confused when i tried with an bidimensional array (this mean <code>ListOfPoints[[x,y],[x,y],[x,y],[x,y],[x,y],[x,y]]</code>) I didn't know how to make that calculation with <code>for</code> or <code>while</code> to iterate and make the calc. I prefer C#, but if there is a solution in other language without libraries, I would be open to it.</p>
[ { "answer_id": 74158125, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 2, "selected": false, "text": "Boolean" }, { "answer_id": 74158128, "author": "David", "author_id": 328193, "author_profile": "h...
2022/10/21
[ "https://Stackoverflow.com/questions/74158114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9372023/" ]
74,158,140
<p>Given a list of lowercase strings named mystrings, create and return a dictionary whose keys are the unique first characters of the strings and whose values are lists of words beginning with those characters, in the same order that they appear in the list of strings. Ignore case: you can assume that all words are lowercase. A sample list of strings is given below, but your code should work on any list of strings of any length. You do not have to write a function.</p> <p>mystrings = [&quot;banana&quot;, &quot;xylophone&quot;, &quot;duck&quot;, &quot;carriage&quot;, &quot;bandana&quot;, &quot;diamond&quot;, &quot;cardinal&quot;]</p> <p>output is {'b': ['banana', 'bandana'], 'x': ['xylophone'], 'd': ['duck', 'diamond'],</p> <h1>'c': ['carriage', 'cardinal']}</h1> <p>I have tried using a loop but am getting stuck.</p>
[ { "answer_id": 74158176, "author": "David Moruzzi", "author_id": 20287283, "author_profile": "https://Stackoverflow.com/users/20287283", "pm_score": 0, "selected": false, "text": "mystrings_dict = {k: [w for w in mystrings_list if w[0] == k] for k in set([w[0] for w in mystrings_list])}\...
2022/10/21
[ "https://Stackoverflow.com/questions/74158140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20303743/" ]
74,158,145
<p>I'm trying to use Healthchecks UI in my asp.net core application with <code>SqlServer.Storage</code> for history purposes. It works with <code>InMemoryStorage</code> (without history part, of course).</p> <p>So, <code>Startup.cs</code> code is like this:</p> <pre><code>services.AddHealthChecks() .AddHangfire(...) .AddDbContextCheck&lt;...&gt;(&quot;Database&quot;) .AddAzureBlobStorage(...) .AddProcessAllocatedMemoryHealthCheck(...) .AddCheck(...); services .AddHealthChecksUI(settings =&gt; { settings.SetEvaluationTimeInSeconds(...); settings.SetMinimumSecondsBetweenFailureNotifications(...); settings.MaximumHistoryEntriesPerEndpoint(...); }) .AddSqlServerStorage(Configuration.GetConnectionString(&quot;...&quot;)); </code></pre> <p>later, additional configuration is in <code>Configure</code> method</p> <p>Everything works when <code>AddInMemoryStorage</code> is used instead of <code>AddSqlServerStorage</code>. When <code>AddSqlServerStorage</code> is used, app crashes on startup, with</p> <blockquote> <p>SqlException: Invalid object name 'Configurations'.</p> </blockquote> <p>Sure, SQL tables are missing, but I cannot force [migration from <a href="https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/blob/master/src/HealthChecks.UI.SqlServer.Storage/Migrations/20200410110604_initial.cs" rel="nofollow noreferrer">nuget package</a> to be applied to database.</p> <p>Of course, I could copy/paste migration or create tables in database but I would like to skip that because of future changes and keeping code clean.</p> <p>Can someone point me in right direction to solve this? Thanks</p>
[ { "answer_id": 74158176, "author": "David Moruzzi", "author_id": 20287283, "author_profile": "https://Stackoverflow.com/users/20287283", "pm_score": 0, "selected": false, "text": "mystrings_dict = {k: [w for w in mystrings_list if w[0] == k] for k in set([w[0] for w in mystrings_list])}\...
2022/10/21
[ "https://Stackoverflow.com/questions/74158145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6170890/" ]
74,158,161
<p>I need to change the code below to make it so that the <code>while</code> loop will never stop.</p> <p>What do I change?</p> <pre class="lang-py prettyprint-override"><code>count = 0 while (count &lt; 9): print ('The droid count is:', count) count = count + 1 print (&quot;That's all the droids we have!&quot;) </code></pre>
[ { "answer_id": 74158176, "author": "David Moruzzi", "author_id": 20287283, "author_profile": "https://Stackoverflow.com/users/20287283", "pm_score": 0, "selected": false, "text": "mystrings_dict = {k: [w for w in mystrings_list if w[0] == k] for k in set([w[0] for w in mystrings_list])}\...
2022/10/21
[ "https://Stackoverflow.com/questions/74158161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20286638/" ]
74,158,163
<p>So my problem is my discount number is blowing up because an order has a discount for the entire order, but I am making a dataset where there are multiple lines for each order to represent each product in the order. Instead of the discount only applying once to the order, it adds the discount for every line.</p> <p>what is happening</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>order_id</th> <th>product_id</th> <th>quantity</th> <th>amount</th> <th>discount</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>a</td> <td>1</td> <td>5</td> <td>0</td> </tr> <tr> <td>2</td> <td>a</td> <td>1</td> <td>5</td> <td>7</td> </tr> <tr> <td>2</td> <td>b</td> <td>1</td> <td>10</td> <td>7</td> </tr> <tr> <td>3</td> <td>a</td> <td>1</td> <td>5</td> <td>5</td> </tr> <tr> <td>3</td> <td>b</td> <td>1</td> <td>10</td> <td>5</td> </tr> <tr> <td>3</td> <td>c</td> <td>1</td> <td>15</td> <td>5</td> </tr> </tbody> </table> </div> <p>what i want</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>order_id</th> <th>product_id</th> <th>quantity</th> <th>amount</th> <th>discount</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>a</td> <td>1</td> <td>5</td> <td>0</td> </tr> <tr> <td>2</td> <td>a</td> <td>1</td> <td>5</td> <td>7</td> </tr> <tr> <td>2</td> <td>b</td> <td>1</td> <td>10</td> <td>0</td> </tr> <tr> <td>3</td> <td>a</td> <td>1</td> <td>5</td> <td>5</td> </tr> <tr> <td>3</td> <td>b</td> <td>1</td> <td>10</td> <td>0</td> </tr> <tr> <td>3</td> <td>c</td> <td>1</td> <td>15</td> <td>0</td> </tr> </tbody> </table> </div> <p>I just want the discount to be applied once per order, and my join is using order_id so that is why the discount is applying multiple times. I would attach my code, but it's a decent sized CTE</p>
[ { "answer_id": 74158176, "author": "David Moruzzi", "author_id": 20287283, "author_profile": "https://Stackoverflow.com/users/20287283", "pm_score": 0, "selected": false, "text": "mystrings_dict = {k: [w for w in mystrings_list if w[0] == k] for k in set([w[0] for w in mystrings_list])}\...
2022/10/21
[ "https://Stackoverflow.com/questions/74158163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20303825/" ]
74,158,205
<p>I want to show only the emails of my users, this is my controller</p> <pre class="lang-rb prettyprint-override"><code>def all @users = User.all end </code></pre> <p>I am trying to do that using jbuilder, but when I do the request, it does not give nothing</p> <p>just i see nothing, the problem what i have is finding the correct view for jbuilder</p> <p>this is my route:</p> <pre><code>namespace :api do namespace :v1, defaults: { format: :json} do get '/all', to: 'users#all' end end end </code></pre>
[ { "answer_id": 74158176, "author": "David Moruzzi", "author_id": 20287283, "author_profile": "https://Stackoverflow.com/users/20287283", "pm_score": 0, "selected": false, "text": "mystrings_dict = {k: [w for w in mystrings_list if w[0] == k] for k in set([w[0] for w in mystrings_list])}\...
2022/10/21
[ "https://Stackoverflow.com/questions/74158205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16735413/" ]
74,158,213
<p>I want to use JS to change the color of my card when I click the checkbox. My current issue is that I'm not sure how to reference these elements in JS.</p> <pre><code>&lt;body&gt; &lt;div class=&quot;container&quot;&gt; &lt;div class =&quot;card&quot;&gt; &lt;input type=&quot;checkbox&quot; name=&quot;platform&quot; value=&quot;ana&quot; id=&quot;ana&quot;&gt; &lt;label for=&quot;ana&quot;&gt; &lt;div class=&quot;card-image&quot;&gt; &lt;img src=&quot;./images/Ana.png&quot; alt=&quot;Character&quot;&gt; &lt;/div&gt; &lt;div class=&quot;card-body&quot;&gt; &lt;img class=&quot;heroCardRole&quot; src=&quot;./images/Support.svg&quot;&gt; &lt;h2&gt;Ana&lt;/h2&gt; &lt;p&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit. Error laudantium sequi facere mollitia saepe.&lt;/p&gt; &lt;/div&gt; &lt;/label&gt; &lt;/div&gt; &lt;/body&gt; </code></pre>
[ { "answer_id": 74158318, "author": "Shoaib Amin", "author_id": 19580087, "author_profile": "https://Stackoverflow.com/users/19580087", "pm_score": 2, "selected": false, "text": "const checkboxAna = document.querySelector(\"#ana\")\nconst cardBodyAna = document.querySelector(\".card-body\...
2022/10/21
[ "https://Stackoverflow.com/questions/74158213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16933036/" ]
74,158,232
<p>I made a small bash script which gets the current air pressure from a website and writes it into a variable. After the air pressure I would like to add the current date and write everything into a text file. The target should be a kind of CSV file.</p> <p>My problem. I always get a line break between the air pressure and the date. Attempts to remove the line break by sed or tr '\n' have failed.</p> <p>2nd guess from me: wget is done &quot;too late&quot; and echo is already done.</p> <p>So I tried it with &amp;&amp; between all commands. Same result.</p> <p>Operating system is Linux. Where is my thinking error?</p> <p>I can't get any further right now. Thanks in advance.</p> <p>Sven</p> <p>PS.: These are my first attempts with sed. This can be written certainly nicer ;)</p> <pre><code>#!/bin/bash luftdruck=$(wget 'https://www.fg-wetter.de/aktuelle-messwerte/' -O aktuell.html &amp;&amp; cat aktuell.html | grep -A 0 hPa | sed -e 's/&lt;[^&gt;]*&gt;//g' | sed -e '/^-/d' | sed -e '/title/d' | sed -e 's/ hPa//g') datum=$(date) echo -e &quot;${luftdruck} ${datum}&quot; &gt;&gt; ausgabe.txt </code></pre>
[ { "answer_id": 74158313, "author": "Cyrus", "author_id": 3776858, "author_profile": "https://Stackoverflow.com/users/3776858", "pm_score": 2, "selected": false, "text": "sed -e 's/ hPa//g')" }, { "answer_id": 74158970, "author": "Socowi", "author_id": 6770384, "author...
2022/10/21
[ "https://Stackoverflow.com/questions/74158232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15148566/" ]