qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,271,381
<pre><code> &lt;div style=&quot;text-align: left;margin-left: 10px;flex-grow: 1;&quot;&gt; &lt;div [innerHtml]=&quot;secureHtml(control.data.text)&quot; *ngIf=&quot;mode!=Mode.MODE_EDITABLE&quot; (click)=&quot;handleClick()&quot;&gt;&lt;/div&gt; &lt;app-inline-ckeditor [(text)]=&quot;control.data.text&quot; [mode]=&quot;mode&quot; *ngIf=&quot;control&amp;&amp;mode==Mode.MODE_EDITABLE&quot;&gt;&lt;/app-inline-ckeditor&gt; &lt;/div&gt; </code></pre> <p>click on the div with innerHtml doesn't trigger click event</p>
[ { "answer_id": 74271400, "author": "zephryl", "author_id": 17303805, "author_profile": "https://Stackoverflow.com/users/17303805", "pm_score": 3, "selected": true, "text": "tidyr::fill()" }, { "answer_id": 74271497, "author": "KaiLi", "author_id": 13866098, "author_pr...
2022/11/01
[ "https://Stackoverflow.com/questions/74271381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7615037/" ]
74,271,412
<p>This is the Error shows in the style:</p> <pre><code>&lt;Button style = </code></pre> <pre><code>No overload matches this call. Overload 1 of 3, '(props: { href : string; } &amp; { children?: React Node; classes?: Partial&lt;Button Classes&gt; | undefined; color?: &quot;primary&quot; | &quot;secondary&quot; | &quot;error&quot; | &quot;warning&quot; | &quot;info&quot; | &quot;success&quot; | &quot;inherit&quot; | undefined; 9 more ; variant?: &quot;text&quot; | 2 more | undefined; } &amp; Omit&lt;&gt; &amp; Common Props &amp; Omit&lt;&gt;): Element', gave the following error. </code></pre> <p>And this is the Code</p> <pre><code>import React from 'react' import { Button } from '@mui/material' type Props = { title: string type?: string style?: React.CSSProperties onClick?: (args: any) =&gt; void; isActive?: boolean } const ButtonComponent = (props: Props) =&gt; { const styleButton = (type: string, isActive: boolean) =&gt; { if (type === 'tabButton') return { width: '200px', height: '40px', padding: '10px 20px', borderRadius: '20px', fontSize: '16px', fontFamily: 'Open Sans', fontWeight: isActive? '700':'400', color: isActive? '#FFFFFF': '#161F29', background: isActive?'#161F29':'rgba(255, 255, 255, 0.5)', border: '1px solid rgba(22, 31, 41, 0.5)', textTransform: 'capitalize' } return ( &lt;div&gt; &lt;Button style = {styleButton(props.type || '', props.isActive || false)} onClick= {props.onClick } &gt; {props.title} &lt;/Button&gt; &lt;/div&gt; ) } export default ButtonComponent; ButtonComponent.defaultProps = { title: &quot;&quot;, type: &quot;&quot;, style: {}, onClick: () =&gt; null, isActive: false } </code></pre>
[ { "answer_id": 74271567, "author": "dilusha_dasanayaka", "author_id": 4156974, "author_profile": "https://Stackoverflow.com/users/4156974", "pm_score": 1, "selected": false, "text": "textTransform" }, { "answer_id": 74272458, "author": "mubin khan", "author_id": 11365038,...
2022/11/01
[ "https://Stackoverflow.com/questions/74271412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18157403/" ]
74,271,418
<p>I'm pretty new at Power BI (so forgive my rough terminology), and I'm trying to create a bar chart from some existing financial data. Specifically, I'd like to know how to transform my data. I've looked at DAX and python, and can't quite figure out the right commands.</p> <p>My existing table looks like the following. The set of categories are arbitrary (not known up front, so can't be hardcoded), same with the set of years.</p> <pre><code>Category 2002 2003 2004 2005 A $10 $75 $75 $75 B $75 $59 $75 $79 C $15 $32 $13 $5 B $23 $12 $75 $7 C $17 $88 $75 $15 </code></pre> <p>And I want my output table to have the number of rows as the number of <em>unique</em> categories, totaling up the dollar amounts for each year.</p> <pre><code>Category 2002 2003 2004 2005 A $10 $75 $75 $75 B $98 $71 $150 $86 C $32 $120 $88 $20 </code></pre> <p>What's the best way to roll up the data this way? I intend to use the resulting table to make a composite bar chart, one bar per year.</p> <p>Thank you!</p>
[ { "answer_id": 74272574, "author": "Ozan Sen", "author_id": 19469088, "author_profile": "https://Stackoverflow.com/users/19469088", "pm_score": 1, "selected": false, "text": "let\n Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText(\"i45WclTSUTI0ABLmpkhErE60khOMb2...
2022/11/01
[ "https://Stackoverflow.com/questions/74271418", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4019700/" ]
74,271,419
<p>I have a datatable with a column &quot;year&quot; and a column &quot;country&quot;. Each country can appear more than one year, ranging from 1900 to 2021. How to select only countries that appear in all the year (1900 to 2021)?</p> <p>This is my code in selecting which is the earliest and latest year:</p> <pre><code>SELECT MIN(year) AS EarliestYear, MAX(year) AS LatestYear FROM owid_energy_data; </code></pre>
[ { "answer_id": 74271521, "author": "Extreme_Tough", "author_id": 2691327, "author_profile": "https://Stackoverflow.com/users/2691327", "pm_score": 1, "selected": false, "text": "SELECT country, count(year) from owid_energy_data\nGROUP BY country HAVING count(year)= 2021 - 1900 + 1 ;\n" ...
2022/11/01
[ "https://Stackoverflow.com/questions/74271419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20378251/" ]
74,271,433
<p>How to do iterations in HiveQL? if there is no way to implement a loop, is there a GOTO kind of statement?</p> <p>I need to perform execution four times with four parameter values, one iteration for each. Is there way to do this without using script?</p>
[ { "answer_id": 74271521, "author": "Extreme_Tough", "author_id": 2691327, "author_profile": "https://Stackoverflow.com/users/2691327", "pm_score": 1, "selected": false, "text": "SELECT country, count(year) from owid_energy_data\nGROUP BY country HAVING count(year)= 2021 - 1900 + 1 ;\n" ...
2022/11/01
[ "https://Stackoverflow.com/questions/74271433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3044949/" ]
74,271,442
<p>Is it easy for people to find &quot;public&quot; google sheets/docs?</p> <p>Context: Storing some semi-sensitive data (individual user info, of non-sensitive nature) for an app beta-test in google sheets. Planning to migrate to some DB in the future, but for now, just using JavaScript to pull the data directly from the google sheets (since there are visualizations being dynamically updated by the sheets).</p>
[ { "answer_id": 74272246, "author": "PatrickdC", "author_id": 18703712, "author_profile": "https://Stackoverflow.com/users/18703712", "pm_score": 1, "selected": false, "text": "General Access" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74271442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12634149/" ]
74,271,449
<p>I am trying to add image for buttons in flutter like below the image. Here i have used ElevatedButton. So How to set background image for the ElevatedButton. I do not know how to add image for it. If anyone know please help to find the solution.</p> <pre><code> child:SingleChildScrollView( child: Wrap( alignment: WrapAlignment.center, runSpacing: 20.0, // Or more spacing: 20, // Or more children: [ const SizedBox( height: 520, ), SizedBox( width: double.infinity, // &lt;-- Your width height: 50, // &lt;-- Your height ), SizedBox( height: 50, // &lt;-- Your height child: ElevatedButton( onPressed: () { onSignIn(context); }, style: ElevatedButton.styleFrom( primary: Color(0xff557de3), shape: StadiumBorder() ), child: const Text( &quot;GMAIL&quot;, style: TextStyle( color: Colors.white, fontSize: 13, fontWeight: FontWeight.bold ), ), ), ), SizedBox( height: 50, // &lt;-- Your height child: ElevatedButton( onPressed: () { //validateForm(); }, style: ElevatedButton.styleFrom( primary: Color(0xff557de3), shape: StadiumBorder() ), child: const Text( &quot;Phone&quot;, style: TextStyle( color: Colors.white, fontSize: 13, fontWeight: FontWeight.bold ), ), ),// Button ), ], ), ), </code></pre>
[ { "answer_id": 74271503, "author": "Sulaymon Ne'matov", "author_id": 16884434, "author_profile": "https://Stackoverflow.com/users/16884434", "pm_score": 1, "selected": false, "text": "ElevatedButton(\n onPressed: () {},\n child: Image.asset('your_asset_path')\n)\n" }, { "answer...
2022/11/01
[ "https://Stackoverflow.com/questions/74271449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19099386/" ]
74,271,484
<p>What are the differences between these two and which one should I use?</p> <pre><code>await JsRuntime.InvokeVoidAsync() await JsRuntime.InvokeAsync()` </code></pre>
[ { "answer_id": 74272037, "author": "AlirezaK", "author_id": 4444757, "author_profile": "https://Stackoverflow.com/users/4444757", "pm_score": 1, "selected": false, "text": "InvokeVoidAsync" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74271484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11392971/" ]
74,271,488
<p>I'm a beginner at coding, and I'm studying JS. I'd like to know how to write a function inside a switch in this code below (if possible), turning the code smaller.</p> <p>I tried to place the funtion for each operation inside of the switch, but it never worked. Help me to improve my code. Thank you!</p> <pre><code>//Calculator of Basic Operations function addition(a, b) { return (a + b); } function subtraction(a, b) { return (a - b); } function multiplication(a, b) { return (a * b); } function division(a, b) { return (a / b); } console.log('Choose the number for the operation you want to use.'); console.log('1 - Addition'); console.log('2 - Subtraction'); console.log('3 - Multiplication'); console.log('4 - Division'); let calcAB = prompt('Operation: '); switch (calcAB) { case '1': a = Number(prompt('Enter the value for A: ')); b = Number(prompt('Enter the value for B: ')); console.log(`The addition result is &quot;${addition(a, b)}&quot;`); break; case '2': a = Number(prompt('Enter the value for A: ')); b = Number(prompt('Enter the value for B: ')); console.log(`The subtraction result is &quot;${subtraction(a, b)}&quot;`); break; case '3': a = Number(prompt('Enter the value for A: ')); b = Number(prompt('Enter the value for B: ')); console.log(`The multiplication result is &quot;${multiplication(a, b)}&quot;`); break; case '4': a = Number(prompt('Enter the value for A (dividend): ')); b = Number(prompt('Enter the value for B (divisor): ')); console.log(`The division result is &quot;${division(a, b)}&quot;`); break; } </code></pre>
[ { "answer_id": 74271528, "author": "CertainPerformance", "author_id": 9515207, "author_profile": "https://Stackoverflow.com/users/9515207", "pm_score": 1, "selected": false, "text": "(dividend)" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74271488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20275859/" ]
74,271,509
<p>I am attempting to query multiple columns in order to display the heaviest ship for each builder/company name.</p> <p><a href="https://i.stack.imgur.com/XZqYs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XZqYs.png" alt="enter image description here" /></a></p> <p>When using my above query I instead receive the results for every ships weight instead of the heaviest ship for each builder. I have spent a few hours trying to discern what is needed to cause the builder column to be distinct.</p>
[ { "answer_id": 74271528, "author": "CertainPerformance", "author_id": 9515207, "author_profile": "https://Stackoverflow.com/users/9515207", "pm_score": 1, "selected": false, "text": "(dividend)" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74271509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20384646/" ]
74,271,510
<p>I have just started my <code>Typo3</code> journey. I want to put 2 <code>content elements</code> side-by-side (in one row). Can anyone tell how is it possible. Because whenever I place any <code>content element</code>, it is displayed as a block and fill the entire <code>row</code>. <strong>Thank you for your time and consideration :)</strong></p>
[ { "answer_id": 74271528, "author": "CertainPerformance", "author_id": 9515207, "author_profile": "https://Stackoverflow.com/users/9515207", "pm_score": 1, "selected": false, "text": "(dividend)" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74271510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17755028/" ]
74,271,513
<p>I'm need to implement Times New Roman Font in my flutter project. I tried google_font packege but in that i didn't find any font.</p> <p>Can anyone please help on this.</p> <p>Thanks in Advance.</p>
[ { "answer_id": 74271528, "author": "CertainPerformance", "author_id": 9515207, "author_profile": "https://Stackoverflow.com/users/9515207", "pm_score": 1, "selected": false, "text": "(dividend)" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74271513", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14240187/" ]
74,271,525
<p>I want to return asset count as per type and also want to concatenate asset ids. I am using <code>FOR XML</code> and path which works fairly good but as soon as I add where clause, it does not work as expected.</p> <p>This is my table schema and query:</p> <pre><code>CREATE TABLE [dbo].[Asset] ( [AssetSeqNumber] [bigint] NULL, [AssetType] [varchar](100) NULL ) ON [PRIMARY] GO INSERT [dbo].[Asset] ([AssetSeqNumber], [AssetType]) VALUES (1, N'Tree') INSERT [dbo].[Asset] ([AssetSeqNumber], [AssetType]) VALUES (2, N'Tree') INSERT [dbo].[Asset] ([AssetSeqNumber], [AssetType]) VALUES (3, N'Tree') INSERT [dbo].[Asset] ([AssetSeqNumber], [AssetType]) VALUES (4, N'Barbecue') INSERT [dbo].[Asset] ([AssetSeqNumber], [AssetType]) VALUES (5, N'Bridge') INSERT [dbo].[Asset] ([AssetSeqNumber], [AssetType]) VALUES (101, N'Tree') INSERT [dbo].[Asset] ([AssetSeqNumber], [AssetType]) VALUES (102, N'Tree') GO </code></pre> <p>Query:</p> <pre><code>SELECT AssetType, COUNT(AssetSeqNumber) AS count, STUFF((SELECT DISTINCT ',' + CAST(AssetSeqNumber AS varchar(100)) FROM Asset WHERE AssetType = a.AssetType FOR XML PATH ('')), 1, 1, '') AS AssetIds FROM Asset AS a WHERE a.AssetSeqNumber IN (1, 2, 3, 4, 5) GROUP BY AssetType </code></pre> <p><a href="https://i.stack.imgur.com/1oo1B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1oo1B.png" alt="enter image description here" /></a></p> <p>This query return result for ids which are not in the where condition (i.e. 101,102). I understand it is because inner query check asset types but I can't figure out how to show expected result.</p> <p>Note: I am using SQL Server 2019 (v15.0.2095.3 (X64))</p>
[ { "answer_id": 74271882, "author": "ahmed", "author_id": 12705912, "author_profile": "https://Stackoverflow.com/users/12705912", "pm_score": 3, "selected": true, "text": "STUFF" }, { "answer_id": 74271885, "author": "RF1991", "author_id": 14799981, "author_profile": "...
2022/11/01
[ "https://Stackoverflow.com/questions/74271525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1225616/" ]
74,271,587
<p>Here is the function:</p> <pre><code>void printArray(const char arr[][3], int rows, int cols) { // rows == 3 &amp;&amp; cols == 3 is currently a placeholder. I have to confirm whether these are // actually correct. if (rows == 3 &amp;&amp; cols == 3 &amp;&amp; rows &gt; 0 &amp;&amp; cols &gt; 0 &amp;&amp; rows &lt;= SIZE &amp;&amp; cols &lt;= SIZE) { for (int i = 0; i &lt; rows; i++) { for (int j = 0; j &lt; cols; j++) { cout &lt;&lt; arr[i][j]; } cout &lt;&lt; '\n'; } } } </code></pre> <p>I need to figure out if the rows parameter inputted into the equation is actually correct. To do this, I need to calculate the size of the const char array from within the function.</p> <p>I have tried adding the following to the if statement:</p> <p>rows == sizeof(arr)/sizeof(arr[0]) cols == sizeof(arr[0])/sizeof(arr[0][0])</p> <p>rows == sizeof(arr)/sizeof(arr[0]) cols == sizeof(arr[0])</p> <p>None of these have worked. Please advise many thanks.</p>
[ { "answer_id": 74271727, "author": "paddy", "author_id": 1553090, "author_profile": "https://Stackoverflow.com/users/1553090", "pm_score": 1, "selected": false, "text": "arr" }, { "answer_id": 74271735, "author": "Pepijn Kramer", "author_id": 16649550, "author_profile...
2022/11/01
[ "https://Stackoverflow.com/questions/74271587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16982551/" ]
74,271,610
<p>I need to hide the text that got out the div, I've tried <code>overflow: hidden;</code> but it doesn't works... I also need to when the text reach the end, i.e., is seen <code>&lt;a href=&quot;'#&quot;&gt;link8&lt;/a&gt; some text 3!....&lt;br&gt;&lt;br&gt;</code> it get back to the start <code>&lt;a href=&quot;'#&quot;&gt;link1&lt;/a&gt; some text...&lt;br&gt;&lt;br&gt;</code> I have no idea how to try the form, I don't know much about CSS...</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>#container { position: fixed; font-size: 20px; transition: .2s; margin-top: 10px; transition: margin 1s; } #box:hover #container{ overflow: hidden; margin-top: -3500px; transition: margin 400s linear; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;div style="background-color: rgb(162, 0, 255); height: 400px;" id="box"&gt; &lt;div id="container"&gt; &lt;a href="'#"&gt;link1&lt;/a&gt; some text...&lt;br&gt;&lt;br&gt; &lt;a href="'#"&gt;link2&lt;/a&gt; some more text 2....&lt;br&gt;&lt;br&gt; &lt;a href="'#"&gt;link3&lt;/a&gt; some text 3....&lt;br&gt;&lt;br&gt; &lt;a href="'#"&gt;link4&lt;/a&gt; some text 3....&lt;br&gt;&lt;br&gt; &lt;a href="'#"&gt;link5&lt;/a&gt; some text 3....&lt;br&gt;&lt;br&gt; &lt;a href="'#"&gt;link6&lt;/a&gt; some text 3....&lt;br&gt;&lt;br&gt; &lt;a href="'#"&gt;link7&lt;/a&gt; some text 3....&lt;br&gt;&lt;br&gt; &lt;a href="'#"&gt;link8&lt;/a&gt; some text 3!....&lt;br&gt;&lt;br&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74271727, "author": "paddy", "author_id": 1553090, "author_profile": "https://Stackoverflow.com/users/1553090", "pm_score": 1, "selected": false, "text": "arr" }, { "answer_id": 74271735, "author": "Pepijn Kramer", "author_id": 16649550, "author_profile...
2022/11/01
[ "https://Stackoverflow.com/questions/74271610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/800123/" ]
74,271,623
<p>DynamoDB tables can be truncated via AWS console, but I'd like to do this in a script. All the answers I saw on S.O. regarding this topic involved 'scans' and similar stuff that I didn't completely understand. I'm wondering if there is a simple directive that I can use to accomplish this truncation. Thanks !</p>
[ { "answer_id": 74272707, "author": "Jatin Mehrotra", "author_id": 13126651, "author_profile": "https://Stackoverflow.com/users/13126651", "pm_score": 1, "selected": false, "text": "dynamodump wipe-data --throughput 5 --table your-table --region eu-west-1\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74271623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1224363/" ]
74,271,629
<p>I have an excel file where I wish to make comparisons to two columns. I am trying to create a third column that is based off a conditional lookup.</p> <p>Column1 has input data, Column2 has output data, and Column3 is where I wish to store results from a lookup table. Both have times in them as well. The four conditions I have are the following:</p> <ol> <li>No input, No Output, Result is &quot;Result One&quot;</li> <li>No Input, Output is less than 5 days and 20 hours, Result is &quot;Result Two&quot;</li> <li>Input is less than 24 weeks, Output is less than 24 weeks, (But both are greater than one week) Result is &quot;Result Three&quot;</li> <li>Input is less than one week, Output is less than one week, Result is &quot;Result Four&quot;</li> </ol> <p>Thus this is how it would be:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Column1</th> <th>Column2</th> <th>Column3</th> </tr> </thead> <tbody> <tr> <td>No Input</td> <td>No Output</td> <td>Result One</td> </tr> <tr> <td>No Input</td> <td>Output 4d02h</td> <td>Result Two</td> </tr> <tr> <td>Input 23w4d</td> <td>Output 22w3d</td> <td>Result Three</td> </tr> <tr> <td>Input 3d01h</td> <td>Input 2d22h</td> <td>Result Four</td> </tr> </tbody> </table> </div> <p>I have tried creating a lookup table and using the concat feature on Column1 and Column2. This works for &quot;Result One&quot; but for the others they are inequalities and thus I'm not entirely sure on how to do them.</p>
[ { "answer_id": 74366892, "author": "Kevin", "author_id": 20443243, "author_profile": "https://Stackoverflow.com/users/20443243", "pm_score": 2, "selected": false, "text": "Column1/Week = IFERROR(RIGHT(LEFT(A2, SEARCH(\"w\", A2)-1), LEN(LEFT(A2, SEARCH(\"w\", A2)-1)) - MAX(IF(ISNUMBER(MID...
2022/11/01
[ "https://Stackoverflow.com/questions/74271629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16472597/" ]
74,271,638
<p>I am trying to scale my SVG down width 0.5 and then draw a line from positive to negative coordinates, but it seems that it renders only to x:0 and y:0.</p> <p>Does SVG.jsnot support drawing with negative coordinates, or am I doing something wrong here?</p> <p>My code:</p> <pre><code>const designerDiv = document.getElementById('designerDiv') var draw = SVG().addTo(designerDiv).attr({width: '100%', height: '100%'}) draw.rect(100, 100).attr({ fill: '#f06' }) draw.scale(0.5, 0.5, 0, 0) draw.line(-100, -100, 100, 100).stroke({ width: 3, color: '#000' }) draw.line(-100, 100, 100, -100).stroke({ width: 3, color: '#000' }) </code></pre> <p>My outcome: <a href="https://i.stack.imgur.com/fVlOL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fVlOL.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74271741, "author": "Sli4o", "author_id": 12185026, "author_profile": "https://Stackoverflow.com/users/12185026", "pm_score": 3, "selected": true, "text": "const designerDiv = document.getElementById('designerDiv')\nvar draw = SVG().addTo(designerDiv).attr({width: '100%', ...
2022/11/01
[ "https://Stackoverflow.com/questions/74271638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8093702/" ]
74,271,644
<p>I have a simple HTML login form:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const passwordField = document.querySelector("#password"); const eyeIcon = document.querySelector("#eye"); eye.addEventListener("click", function() { this.classList.toggle("fa-eye-slash"); const type = passwordField.getAttribute("type") === "password" ? "text" : "password"; passwordField.setAttribute("type", type); })</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://kit.fontawesome.com/6d0b0e6586.js" crossorigin="anonymous"&gt;&lt;/script&gt; &lt;link href="https://fonts.googleapis.com/css2?family=Raleway:wght@200;400;500;600&amp;display=swap" rel="stylesheet"&gt; &lt;div id="login-flow"&gt; &lt;section&gt; &lt;h1&gt;Welcome back.&lt;/h1&gt; &lt;form action="#" method="post"&gt; &lt;label for="email"&gt;Email&lt;/label&gt; &lt;input type="email" id="email" name="email" placeholder="Email" required&gt; &lt;label for="password"&gt;Password&lt;/label&gt; &lt;div class="password-container"&gt; &lt;input type="password" name="password" id="password" placeholder="Password" required&gt; &lt;i class="fa-solid fa-eye" id="eye"&gt;&lt;/i&gt; &lt;/div&gt; &lt;!--pass-toggle--&gt; &lt;button type="button" name="btn" id="btn-login"&gt;Login&lt;/button&gt; &lt;/form&gt; &lt;div class="form-footer"&gt; &lt;p&gt;Don't have an account? Create one &lt;a href="register.html"&gt;here&lt;/a&gt;.&lt;/p&gt; &lt;/div&gt; &lt;/section&gt; &lt;/div&gt;&lt;!--login-flow--&gt;</code></pre> </div> </div> </p> <p>Everything works great <em>except</em> the icon toggle. There are no warnings and the password input field changes between password and text in the console but the icon does not change. Interestingly, if I add the <code>fa-eye-slash</code> class to the <code>&lt;i&gt;</code> in <code>.password-container</code>, and <code>this.classList.toggle</code> to <code>fa-eye</code>, it works perfectly. It’s just that the icons are reversed. Why won’t it work as is?</p>
[ { "answer_id": 74271741, "author": "Sli4o", "author_id": 12185026, "author_profile": "https://Stackoverflow.com/users/12185026", "pm_score": 3, "selected": true, "text": "const designerDiv = document.getElementById('designerDiv')\nvar draw = SVG().addTo(designerDiv).attr({width: '100%', ...
2022/11/01
[ "https://Stackoverflow.com/questions/74271644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14842298/" ]
74,271,648
<p>I have two dataframes like:</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>A B 1 2 3 4 5 6</code></pre> </div> </div> </p> <p>df2:</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>C D 7 8 9 10 2 3 4 5</code></pre> </div> </div> </p> <p>I wish to combine these dataframes one after the other like the following:</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>A B C D 1 2 3 4 5 6 7 8 9 10 2 3 4 5</code></pre> </div> </div> </p> <p>I have tried using concat and join but it doesnt give me this desired output.</p> <p>Thanks</p>
[ { "answer_id": 74271741, "author": "Sli4o", "author_id": 12185026, "author_profile": "https://Stackoverflow.com/users/12185026", "pm_score": 3, "selected": true, "text": "const designerDiv = document.getElementById('designerDiv')\nvar draw = SVG().addTo(designerDiv).attr({width: '100%', ...
2022/11/01
[ "https://Stackoverflow.com/questions/74271648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9580869/" ]
74,271,658
<p>I mostly work with SQL. I don't know how to convert this SQL query to Oracle. Can anyone tell me how to convert this?</p> <pre><code> DECLARE @START_YEAR INT,@MONTH INT, @END_YR INT SELECT @START_YEAR = 2010, @END_YR = 2010, @MONTH = 1 WHILE ( @START_YEAR &lt;= @END_YR) BEGIN WHILE ( @MONTH &lt;= 12) BEGIN PRINT 'INSERT INTO dbo.Mem_TXN ([VALUE] ,[BEGIN_DATE] ,[END_DATE] ,[CREATED_BY] ,[CREATED_DATE] ,[MODIFIED_BY] ,[MODIFIED_DATE]) VALUES (''RGLR'' ,''' + cast( Convert(date, DATEADD(MONTH, @MONTH - 1, DATEADD(YEAR, @START_YEAR - 1900, 0))) AS varchar) + ''' ,''' + cast( Convert(date,DATEADD(MONTH, @MONTH, DATEADD(YEAR, @START_YEAR - 1900, -1))) AS VARCHAR) + ''' ,''admin'' ,' +FORMAT(GETDATE(), 'yyyy-mm-dd hh:mm')+ ' ,''admin'' ,' +FORMAT(GETDATE(), 'yyyy-mm-dd hh:mm')+ ' ,0); ' SET @MONTH = @MONTH + 1 END SET @MONTH = 1 SET @START_YEAR = @START_YEAR + 1 END </code></pre> <p>This SQL query for used to generate the SQL <strong>INPUT</strong> statement. When I tried to manually convert this SQL query, I got a syntax error. Is it possible to convert the SQL query using a converter tool because I don't have enough time to learn Oracle in order to modify this SQL query? Thank you in advance.</p>
[ { "answer_id": 74271741, "author": "Sli4o", "author_id": 12185026, "author_profile": "https://Stackoverflow.com/users/12185026", "pm_score": 3, "selected": true, "text": "const designerDiv = document.getElementById('designerDiv')\nvar draw = SVG().addTo(designerDiv).attr({width: '100%', ...
2022/11/01
[ "https://Stackoverflow.com/questions/74271658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14381274/" ]
74,271,681
<p>la=[&quot;ngsir&quot;,&quot;raise&quot;,&quot;kajggf&quot;,&quot;kajggsdda&quot;,&quot;kajgg&quot;,&quot;kajggkjabfkafku&quot;,&quot;kajgg&quot;,&quot;asakfaflg&quot;,&quot;as&quot;,&quot;sfowih&quot;,&quot;akjfglff&quot;]</p> <p>lb=[&quot;raise&quot;,&quot;kajggf&quot;,&quot;kajggkjabfkafku&quot;,&quot;cvsk&quot;,&quot;kajgg&quot;,&quot;asakfaflg&quot;,&quot;as&quot;,&quot;sfowih&quot;,&quot;akjfglff&quot;,&quot;kajggsdda&quot;,&quot;kajgg&quot;]</p> <p>print(&quot;team A:\t\t\t team B:&quot;) for i in range(11): print(la[i]+&quot;\t\t\t&quot;+lb[i])</p> <p>i was expecting the two lists to be align, but got</p> <p>team A: team B: rohit raise raise kajggf kajggf kajggkjabfkafku kajggsdda rohit kajgg kajgg kajggkjabfkafku asakfaflg kajgg as asakfaflg sfowih as akjfglff sfowih kajggsdda akjfglff kajgg</p> <p>instead, how can i align them</p>
[ { "answer_id": 74271747, "author": "William Stuart", "author_id": 13125683, "author_profile": "https://Stackoverflow.com/users/13125683", "pm_score": 2, "selected": false, "text": "la=[\"ngsir\",\"raise\",\"kajggf\",\"kajggsdda\",\"kajgg\",\"kajggkjabfkafku\",\"kajgg\",\"asakfaflg\",\"as...
2022/11/01
[ "https://Stackoverflow.com/questions/74271681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20384799/" ]
74,271,720
<p>I have a JSON response (bellow) and I need to parse this -</p> <pre><code>[ { &quot;id&quot;:123, &quot;name&quot;:&quot;Fahim Rahman&quot;, &quot;age&quot;:25, &quot;friends&quot;:[ { &quot;firstName&quot;: &quot;Imtiaz&quot;, &quot;lastName&quot;: &quot;Khan&quot;, &quot;avatar_url&quot;: null } ], &quot;groups&quot;:{ &quot;xcet&quot;:{ &quot;name&quot;:&quot;xcek cert etsh tnhg&quot;, &quot;createdDate&quot;:&quot;2022-10-31T10:00:48Z&quot; }, &quot;juyt&quot;:{ &quot;name&quot;:&quot;jfd uyt you to&quot;, &quot;createdDate&quot;:&quot;2021-09-13T10:00:00Z&quot; }, &quot;some random key&quot;:{ &quot;name&quot;: &quot;some name&quot;, &quot;createdDate&quot;:&quot;2026-03-27T10:00:00Z&quot; } } } ] </code></pre> <p>To parse this in my code I've created this model. I can not able to parse the groups as that is not a list but an object -</p> <pre><code> import ObjectMapper class Person: BaseObject { @objc dynamic var ID: Int = -1 @objc dynamic var name: String = &quot;&quot; @objc dynamic var age: Int = -1 var friendsList = List&lt;Friends&gt;() override func mapping(map: ObjectMapper.Map) { ID &lt;- map[&quot;id&quot;] name &lt;- map[&quot;name&quot;] age &lt;- map[&quot;age&quot;] friendsList &lt;- map[&quot;friends&quot;] } } class Friends: BaseObject { @objc dynamic var firstName: String = &quot;&quot; @objc dynamic var lastName: String = &quot;&quot; @objc dynamic var avatarURL: String = &quot;&quot; override func mapping(map: ObjectMapper.Map) { firstName &lt;- map[&quot;firstName&quot;] lastName &lt;- map[&quot;name&quot;] avatarURL &lt;- map[&quot;avatar_url&quot;] } } </code></pre> <p>I know it's a bad JSON. The groups should be on the list instead of the nested objects but unfortunately, I'm getting this response.</p> <p>Here in the response of groups, the number of nested objects is dynamic and the key of the nested object is also dynamic. Thus I can not able to parse this as friends attribute.</p> <p>So my question is, how can I map the &quot;groups&quot;?</p>
[ { "answer_id": 74271782, "author": "Ahsan Mehmood", "author_id": 19748796, "author_profile": "https://Stackoverflow.com/users/19748796", "pm_score": 0, "selected": false, "text": "// MARK: - Welcome7Element\nstruct Welcome7Element {\n let id: Int\n let name: String\n let age: In...
2022/11/01
[ "https://Stackoverflow.com/questions/74271720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8733843/" ]
74,271,728
<p>I have a column that is currently in dollars and my prof wants us to convert it so that it's showin inn 10,000's (for example 150000 will be 15, 30000 will be 3, 15000 will be 1.5). I was able to convert it but I don't know how to get it to only show the decimal if it's necessary (like the 15000 being 1.5). Does anyone know how I can get it to show whole numbers unless it's like 1.5?</p> <pre><code>medianIncome1 = (housing['medianIncome'].astype(float)/10000).astype(str) </code></pre> <p>If I use the astype(np.int64) it shows the whole number but if I don't it puts a bunch of decimals, if i use the round() i get the 0</p>
[ { "answer_id": 74271782, "author": "Ahsan Mehmood", "author_id": 19748796, "author_profile": "https://Stackoverflow.com/users/19748796", "pm_score": 0, "selected": false, "text": "// MARK: - Welcome7Element\nstruct Welcome7Element {\n let id: Int\n let name: String\n let age: In...
2022/11/01
[ "https://Stackoverflow.com/questions/74271728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17609282/" ]
74,271,734
<p>I'm getting errors in my flutter app after an upgrade to flutter 3.3.6. The named parameters which throws errors as 'aren't defined' : elevation, color, shape</p> <p>The snippet where i get the errors is listed below :</p> <pre><code>return ButtonTheme( minWidth: 110, child: RaisedButton( elevation: 0, child: isLoading ? _buildLoadingIndicatorWithColor(textColor) : Text( text, style: TextStyle( color: textColor, fontWeight: FontWeight.bold, fontSize: 16), ), color: communityColor, onPressed: onPressed, shape: new RoundedRectangleBorder( borderRadius: BorderRadius.circular(borderRadius))), ); </code></pre> <p>}</p> <p>Here is another snippet where a similar error appears and the textColor parameter throws the same error :</p> <pre><code>return ButtonTheme( minWidth: minWidth, height: height, child: FlatButton( textColor: Colors.black87, child: this.child, onPressed: this.onPressed, ), ); </code></pre> <p>Here is the one related to materialTapTargetSize:</p> <pre><code>hasText ? TextButton( style: TextButton.styleFrom( materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), onPressed: _cancelSearch, child: OBText(localizationService.user_search__cancel), ) : const SizedBox( width: 15.0, ) </code></pre> <p>As per the following documentation I read <a href="https://docs.flutter.dev/release/breaking-changes/buttons" rel="nofollow noreferrer">https://docs.flutter.dev/release/breaking-changes/buttons</a>, there are changes that are needed to make it work. Help appreciated as I'm very new to flutter and a beginner to programming</p>
[ { "answer_id": 74271782, "author": "Ahsan Mehmood", "author_id": 19748796, "author_profile": "https://Stackoverflow.com/users/19748796", "pm_score": 0, "selected": false, "text": "// MARK: - Welcome7Element\nstruct Welcome7Element {\n let id: Int\n let name: String\n let age: In...
2022/11/01
[ "https://Stackoverflow.com/questions/74271734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9359102/" ]
74,271,765
<p>I got this simple example which was highly related to my doubt, so I am using this as my example. So here in the link we can see there is a simple Yup validation schema. So when we type in something inside email field, the console log inside the email validation is getting printed which is obviously fine. But even when we type something inside the name field also the console is getting printed.</p> <p><strong>Validation Schema</strong></p> <pre><code>const schema = yup.object({ name: yup.string().required(), email: yup.string().test('is-jimmy', '${path} is not Jimmy', function (value) { return new Promise((res, rej) =&gt; { console.log('firing async validation') setTimeout(() =&gt; res(value !== &quot;foo@bar.com&quot;)) }) }) }) </code></pre> <p><strong>Example</strong> - <a href="https://stackblitz.com/edit/yup-async-validation-test?file=index.js" rel="nofollow noreferrer">https://stackblitz.com/edit/yup-async-validation-test?file=index.js</a></p> <p>Please suggest me a solution to get rid of this issue, so that the console have to print only when I type inside the email field.</p> <p><strong>Alternate solution ?</strong> - Is there any method to add more than 1 validation schemas in Formik to avoid this issue ?</p> <pre><code> // like this &lt;Formik validationSchema = [userValidationSchema,emailSchema] /&gt; </code></pre>
[ { "answer_id": 74271782, "author": "Ahsan Mehmood", "author_id": 19748796, "author_profile": "https://Stackoverflow.com/users/19748796", "pm_score": 0, "selected": false, "text": "// MARK: - Welcome7Element\nstruct Welcome7Element {\n let id: Int\n let name: String\n let age: In...
2022/11/01
[ "https://Stackoverflow.com/questions/74271765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17030676/" ]
74,271,791
<p>I want to check if user has internet connection and want it to be dynamic. Customisable messages will be shown to user according to it.</p> <pre><code>ElevatedButton( onPressed: () async { ans = await InternetConnectionChecker().hasConnection; print(ans); }, child: const Text('Fetch Data'), ), </code></pre> <p>I can check it when clicked on the button by the user but I want it to be automatic when user hops on the home page. I tried putting</p> <pre><code>ans = await InternetConnectionChecker().hasConnection; print(ans); </code></pre> <p>in initState but it doesn't work. Any suggestions as to how should I improve it?</p> <p>EDIT : I tried the first solution and on click of a button I get all the results perfectly</p> <pre><code>onPressed: () async { var connectivityResult = await (Connectivity().checkConnectivity()); var subscription = Connectivity() .onConnectivityChanged .listen((ConnectivityResult result) { print(&quot;Changed to $result&quot;); }); if (connectivityResult == ConnectivityResult.mobile) { // I am connected to a mobile network. print(&quot;Mobile&quot;); } else if (connectivityResult == ConnectivityResult.wifi) { // I am connected to a wifi network. print(&quot;Wifi&quot;); } }, </code></pre> <p>It shows none when no internet is there. To mobile when connected to mobile hotspot and wifi when connected to wifi network. But my issue still remains that I want to check internet connection when a user comes to my home page. I tried this :</p> <pre><code> var subscription; @override initState() async { super.initState(); print(&quot;hlo&quot;); var connectivityResult = await (Connectivity().checkConnectivity()); var subscription = Connectivity() .onConnectivityChanged .listen((ConnectivityResult result) { print(&quot;Changed to $result&quot;); }); } </code></pre> <p>But this doesn't work. What am I dooing wrong? Can i improve this?</p>
[ { "answer_id": 74271816, "author": "Mahesh", "author_id": 10791086, "author_profile": "https://Stackoverflow.com/users/10791086", "pm_score": 3, "selected": true, "text": "import 'package:connectivity_plus/connectivity_plus.dart';\n\nvar connectivityResult = await (Connectivity().checkCo...
2022/11/01
[ "https://Stackoverflow.com/questions/74271791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17879169/" ]
74,271,826
<p>I made two components and I want to send a props after connecting these components by Link. I'm working on it without using redux, but I found a way to send props and made a code, but the value doesn't come out because I think the method is wrong. I'd appreciate it if you let me know thanks.</p> <p><strong>SingUp.jsx:</strong> This is the component I'm trying to send a prop. I checked that the value comes out well if I put the value in the input tag. So I think you just need to check the link tag part! I only sent the <code>email</code> value and put <code>email</code> in props to check it</p> <pre><code>import React, { useState } from 'react' import { Link } from 'react-router-dom'; import styled from 'styled-components'; import SignUpEmailInput from '../components/SingUp/SignUpEmailInput'; import SignUpLoginButton from '../components/SingUp/SignUpLoginButton'; import SignUpNameInpu from '../components/SingUp/SignUpNameInpu'; import SignUpPassInput from '../components/SingUp/SignUpPassInput'; import SignUpUserInput from '../components/SingUp/SignUpUserInput'; const SignUpWrap = styled.div` flex-direction: column; display: flex; position: relative; z-index: 0; margin-bottom: calc(-100vh + 0px); color: rgb(38,38,38); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 18px; ` function SignUp() { const [email, setEmail] = useState(&quot;&quot;); const [name, setName] = useState(&quot;&quot;); const [userName, setUserName] = useState(&quot;&quot;); const [passWord, setPassWord] = useState(&quot;&quot;); return ( &lt;SignUpWrap&gt; &lt;div&gt; &lt;SignUpEmailInput email={email} setEmail={setEmail}/&gt; &lt;/div&gt; &lt;div&gt; &lt;SignUpNameInpu name={name} setName={setName}/&gt; &lt;/div&gt; &lt;div&gt; &lt;SignUpUserInput userName={userName} setUserName={setUserName} /&gt; &lt;/div&gt; &lt;div&gt; &lt;SignUpPassInput passWord={passWord} setPassWord={setPassWord}/&gt; &lt;/div&gt; &lt;div &gt; {/* I used Link here */} &lt;Link to={{pathname:'/birthday', state:{email:email}}} style={{textDecoration : 'none' ,color: 'inherit'}}&gt; &lt;div&gt; &lt;SignUpLoginButton email={email} name={name} userName={userName} passWord={passWord}/&gt; &lt;/div&gt; &lt;/Link&gt; &lt;/div&gt; &lt;/SignUpWrap&gt; ) } export default SignUp; </code></pre> <p><strong>Birthday.jsx:</strong></p> <p>This is the component that I want to receive a prop. I checked that the two components are moved through Link. Can I also know how to get a props value here? I want to check if it went well through console.log</p> <pre><code>import React, { useState } from 'react' function Birthday({email, name, userName, passWord}) { console.log(location.state.email) return ( &lt;&gt; Hi &lt;/&gt; ) } export default Birthday; </code></pre>
[ { "answer_id": 74271816, "author": "Mahesh", "author_id": 10791086, "author_profile": "https://Stackoverflow.com/users/10791086", "pm_score": 3, "selected": true, "text": "import 'package:connectivity_plus/connectivity_plus.dart';\n\nvar connectivityResult = await (Connectivity().checkCo...
2022/11/01
[ "https://Stackoverflow.com/questions/74271826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20108310/" ]
74,271,854
<p>I am new to Python and I have troubles understanding the difference between 'int' and 'numpy.int64'.</p> <p><strong>Below is the question:</strong></p> <p>I would need to complete the function explore_data to return a tuple, t, with the following elements.</p> <pre><code>t[0] - tuple - the shape of df t[1] - pd.DataFrame - the first five rows of df t[2] - dict - mapping year (int) to the number of films released that year (int) The input df is a pd.DataFrame with the following columns: 'film_id' - unique integer associated with a film 'film_name' - the name of a film 'actor' - the name of an actor who starred in the film 'year' - the year which the film was released Each row in df indicates an instance of an actor starring in a film, so it is possible that there will be multiple rows with the same 'film_name' and 'film_id'. </code></pre> <p><strong>My approach to this question:</strong></p> <pre><code>import pandas as pd, numpy as np def explore_data(df): res = list() res.append(df.shape) res.append(df.head()) gb = df.groupby('year').size() gb = gb.to_frame().reset_index().rename(columns = {0: 'Number'}) d ={} for idx in range(len(gb)): y = gb['year'][idx] num = gb['Number'][idx] d[y] = num res.append(d) res = tuple(res) return res </code></pre> <p>However, I am facing the error: <a href="https://i.stack.imgur.com/0DTdN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0DTdN.png" alt="enter image description here" /></a></p> <p>Could someone please help to advise on the issue? Thank you!</p>
[ { "answer_id": 74271816, "author": "Mahesh", "author_id": 10791086, "author_profile": "https://Stackoverflow.com/users/10791086", "pm_score": 3, "selected": true, "text": "import 'package:connectivity_plus/connectivity_plus.dart';\n\nvar connectivityResult = await (Connectivity().checkCo...
2022/11/01
[ "https://Stackoverflow.com/questions/74271854", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20384893/" ]
74,271,856
<p>I am creating div inside div tag on button click, It is created and shown on UI , but I am unable to get the unique value inserted in dynamic created div. I always get the first value. Code sample:</p> <pre><code>&lt;div id=&quot;row-list-outer&quot;&gt; &lt;/div&gt; </code></pre> <p>Dynamically adding code sample, This code runs on each click</p> <pre><code> $(&quot;#row-list-outer&quot;).append(` &lt;div class=&quot;row g-3&quot;&gt; &lt;div&gt; &lt;input type=&quot;text&quot; id=&quot;salesPersonName&quot; placeholder=&quot;Name&quot;&gt; &lt;/div&gt; &lt;/div&gt;) </code></pre> <p>Now input element is created on click, but If I enter a value in 2nd row input, or 3rd row input etc. Then How I get those values in the same order as they are inserted. For example if the user enters in first row input, then it should be stored on index 0 in array, similarly, if user enters in 1 row, 2nd row, then it should be inserted on array at index 1, 2 respectively</p>
[ { "answer_id": 74271816, "author": "Mahesh", "author_id": 10791086, "author_profile": "https://Stackoverflow.com/users/10791086", "pm_score": 3, "selected": true, "text": "import 'package:connectivity_plus/connectivity_plus.dart';\n\nvar connectivityResult = await (Connectivity().checkCo...
2022/11/01
[ "https://Stackoverflow.com/questions/74271856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14484656/" ]
74,271,865
<p>I want to know if there is a simple way to save list of lists in a file to import it later again like the same list of lists. No matter the size of it.</p> <pre><code>List_lists=[[&quot;a&quot;,1,2,3,4],[&quot;b&quot;,1,2,3,4],[&quot;c&quot;,1,2,3,4],.....] </code></pre> <p>Also i want to know is there is a way to throw a list with the first element in each list (in this case &quot;a&quot;, &quot;b&quot;). Giving as a result:</p> <pre><code>first_column=[[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,......] </code></pre> <p>Thanks for all the help.</p>
[ { "answer_id": 74271957, "author": "SmartCoder", "author_id": 16897514, "author_profile": "https://Stackoverflow.com/users/16897514", "pm_score": -1, "selected": false, "text": "zip()" }, { "answer_id": 74272062, "author": "George", "author_id": 20345563, "author_prof...
2022/11/01
[ "https://Stackoverflow.com/questions/74271865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18655289/" ]
74,271,897
<p>My code was working fine but suddenly design is not visible, errors are:-<br /> java.lang.NullPointerException at android.content.res.Resources_Theme_Delegate.obtainStyledAttributes(Resources_Theme_Delegate.java:74) at android.content.res.Resources$Theme.obtainStyledAttributes(Resources.java:1610) at android.content.Context.obtainStyledAttributes(Context.java:817) at android.widget.TextView.setTextAppearance(TextView.java:3910) at androidx.appcompat.widget.AppCompatTextView.setTextAppearance(AppCompatTextView.java:211) at android.widget.TextView.setTextAppearance(TextView.java:3899) at androidx.core.widget.TextViewCompat.setTextAppearance(TextViewCompat.java:289) at com.google.android.material.tabs.TabLayout$TabView.update(TabLayout.java:2745) at com.google.android.material.tabs.TabLayout$TabView.setTab(TabLayout.java:2686) at com.google.android.material.tabs.TabLayout.createTabView(TabLayout.java:1657) at com.google.android.material.tabs.TabLayout.newTab(TabLayout.java:952) at com.google.android.material.tabs.TabLayout.addTabFromItemView(TabLayout.java:820) at com.google.android.material.tabs.TabLayout.addViewInternal(TabLayout.java:1707) at com.google.android.material.tabs.TabLayout.addView(TabLayout.java:1697) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1131) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1130) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1130) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1130) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088) at android.view.LayoutInflater.inflate(LayoutInflater.java:686) at android.view.LayoutInflater.inflate(LayoutInflater.java:505) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:363) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:436) at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:121) at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:741) at com.android.tools.idea.rendering.RenderTask.lambda$inflate$8(RenderTask.java:897) at com.android.tools.idea.rendering.RenderExecutor$runAsyncActionWithTimeout$2.run(RenderExecutor.kt:187) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829)</p>
[ { "answer_id": 74271957, "author": "SmartCoder", "author_id": 16897514, "author_profile": "https://Stackoverflow.com/users/16897514", "pm_score": -1, "selected": false, "text": "zip()" }, { "answer_id": 74272062, "author": "George", "author_id": 20345563, "author_prof...
2022/11/01
[ "https://Stackoverflow.com/questions/74271897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19473208/" ]
74,271,940
<p>This is my code to retrieve the image from the database and show it to the user.</p> <p>Then It will open on another blank tab and view.</p> <p>Now I want to know, rather than viewing the attachment on another tab, I want to download the file from the controller.</p> <p>How to download the file?</p> <p>Here is my code in HTML</p> <pre><code> @Html.ActionLink(item.File_Name, &quot;PaymentAttachmentView&quot;, &quot;TaskMains&quot;, new { id = item.Id }, new { @target = &quot;_blank&quot; }) </code></pre> <p>This is my code in the controller</p> <pre><code>public ActionResult RetrieveTaskImage(int id) { var q = from c in db.TaskFiles where c.Id == id select c.Attachment; var type = from t in db.TaskFiles where t.Id == id select t.File_Name; string fileType = type.First().ToString(); string ext = Path.GetExtension(fileType); byte[] cover = q.First(); if (cover != null) { if (ext == &quot;.pdf&quot;) { return File(cover, &quot;application/pdf&quot;); } else { return File(cover, &quot;image/jpg&quot;); } } else { return null; } } </code></pre>
[ { "answer_id": 74271957, "author": "SmartCoder", "author_id": 16897514, "author_profile": "https://Stackoverflow.com/users/16897514", "pm_score": -1, "selected": false, "text": "zip()" }, { "answer_id": 74272062, "author": "George", "author_id": 20345563, "author_prof...
2022/11/01
[ "https://Stackoverflow.com/questions/74271940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17961431/" ]
74,271,947
<p>Consider the following Applicative context f. I have a list of functions wrapped around this context F = f [a -&gt; a] and a list of values wrapped around the same context i.e. V = f [a]. Now I want to apply the functions in F to the values in V. How can this be achieved?</p> <p>I have tried the following :</p> <pre><code>1. (F &lt;*&gt;) &lt;*&gt; V 2. (V &lt;*&gt;) (F &lt;*&gt;) </code></pre> <p>But for some reason the types won't match.</p>
[ { "answer_id": 74271957, "author": "SmartCoder", "author_id": 16897514, "author_profile": "https://Stackoverflow.com/users/16897514", "pm_score": -1, "selected": false, "text": "zip()" }, { "answer_id": 74272062, "author": "George", "author_id": 20345563, "author_prof...
2022/11/01
[ "https://Stackoverflow.com/questions/74271947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14184317/" ]
74,271,983
<p>I want to set <code>Iscandidate</code> to true if <code>user role === &quot;candidate&quot;</code> and same for comapny if <code>userrole === &quot;company&quot;</code> and other should be false . I am saving <code>isCandidate</code> and <code>isCompany</code> as true and false in DB , if one is true the other should be false but I am not getting desired output.</p> <p>What I am trying is :</p> <pre><code> console.log(&quot;signin card&quot;); const [phoneNumber, setPhoneNumber] = useState(&quot;&quot;); const [isCompany, setIsCompany] = useState(null); const [isCandidate, setIsCandidate] = useState(null); const body = { phoneNumber, isCandidate, isCompany, }; const onSubmitHandler = async () =&gt; { if (userRole === &quot;candidate&quot;) { console.log(userRole); setIsCandidate(true); setIsCompany(false); } if (userRole === &quot;company&quot;) { console.log(userRole); setIsCandidate(false); setIsCompany(true); } console.log(&quot;body : &quot;, body); const res = await axios.post( &quot;http://localhost:8000/user-role/recorded&quot;, body ); const otpRes = await axios.get( `https://2factor.in/API/V1/b3014f3e-2e06-11ea-9fa5-0200cd936042/SMS/+91${phoneNumber}/AUTOGEN3` ); console.log(&quot;res = &quot;, res); console.log(&quot;otp = &quot;, otpRes); }; const onChangeHandler = (e) =&gt; { setPhoneNumber(e.target.value); }; return ( &lt;&gt; &lt;div className=&quot;modal&quot; id=&quot;signInCard&quot; tabIndex=&quot;-1&quot; aria-hidden=&quot;true&quot; style={{ position: &quot;fixed&quot;, top: &quot;0%&quot;, left: &quot;50%&quot;, width: &quot;100%&quot;, height: &quot;100%&quot;, overflowX: &quot;hidden&quot;, overflowY: &quot;auto&quot;, transform: &quot;translateX(-50%)&quot;, zIndex: &quot;1055&quot;, }} &gt; &lt;div className=&quot;modal-dialog modal-dialog-centered&quot; style={{ width: &quot;20%&quot; }} &gt; &lt;div className=&quot;modal-content&quot;&gt; &lt;div className=&quot;modal-body p-5&quot;&gt; &lt;div className=&quot;position-absolute end-0 top-0 p-3&quot;&gt; &lt;button type=&quot;button&quot; className=&quot;btn-close&quot; data-bs-dismiss=&quot;modal&quot; aria-label=&quot;Close&quot; &gt;&lt;/button&gt; &lt;/div&gt; &lt;div className=&quot;auth-content&quot;&gt; &lt;div className=&quot;w-100&quot;&gt; &lt;div className=&quot;text-center mb-4&quot;&gt; &lt;h5&gt;Sign In as {userRole}&lt;/h5&gt; &lt;p className=&quot;text-muted&quot;&gt;&lt;/p&gt; &lt;/div&gt; &lt;form onSubmit={(e) =&gt; { onSubmitHandler(); }} className=&quot;auth-form&quot; &gt; &lt;div className=&quot;input-group mb-3&quot;&gt; {/* &lt;label for=&quot;usernameInput&quot; className=&quot;form-label&quot;&gt;Phone No.&lt;/label&gt; */} &lt;div className=&quot;input-group-prepend&quot;&gt; &lt;span className=&quot;input-group-text&quot; id=&quot;basic-addon1&quot;&gt; +91 &lt;/span&gt; &lt;/div&gt; &lt;input type=&quot;number&quot; name=&quot;phoneNumber&quot; className=&quot;form-control&quot; id=&quot;usernameInput&quot; placeholder=&quot;Enter your phone no.&quot; aria-label=&quot;number&quot; aria-describedby=&quot;basic-addon1&quot; onChange={onChangeHandler} value={phoneNumber} /&gt; &lt;span className=&quot;text-danger&quot;&gt;&lt;/span&gt; &lt;/div&gt; &lt;div className=&quot;text-center&quot;&gt; &lt;a href=&quot;#otpModal&quot; data-bs-toggle=&quot;modal&quot;&gt; &lt;button type=&quot;submit&quot; className=&quot;btn btn-primary w-100&quot; onClick={onSubmitHandler} &gt; Sign In &lt;/button&gt; &lt;/a&gt; {/* &lt;a href=&quot;#otpModal&quot; className=&quot;form-text user_sign&quot; data-bs-toggle=&quot;modal&quot; &gt; Candidate &lt;/a&gt; */} &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Please help while saving into Db I am getting <code>null</code></p>
[ { "answer_id": 74271957, "author": "SmartCoder", "author_id": 16897514, "author_profile": "https://Stackoverflow.com/users/16897514", "pm_score": -1, "selected": false, "text": "zip()" }, { "answer_id": 74272062, "author": "George", "author_id": 20345563, "author_prof...
2022/11/01
[ "https://Stackoverflow.com/questions/74271983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20269527/" ]
74,271,994
<p>so I have a generic function that calls a web service and converts it to whatever type you call the function with. However if you call CallUrl&lt;SomeValue[]&gt; - I don't want to return null, I want to return an empty list. I'm currently returning DefaultOrEmpty() - where that looks like:</p> <pre class="lang-cs prettyprint-override"><code>private static T DefaultOrEmpty&lt;T&gt;() { return typeof(T).IsArray ? (T)(object)Array.CreateInstance(typeof(T).GetElementType()!, 0) : default; } </code></pre> <p>which works, but seems ridiculously complicated - is there a cleaner way to write this function?</p>
[ { "answer_id": 74272307, "author": "41686d6564 stands w. Palestine", "author_id": 8967612, "author_profile": "https://Stackoverflow.com/users/8967612", "pm_score": 2, "selected": false, "text": "private static T DefaultOrEmpty<T>()\n{\n return typeof(T).IsArray\n ? (T)Activator....
2022/11/01
[ "https://Stackoverflow.com/questions/74271994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2446374/" ]
74,272,010
<pre><code>def check(val, list=[]): list.append(val) return list list1=check(&quot;a&quot;) list2=check(&quot;b&quot;,[]) list3=check(&quot;c&quot;) </code></pre> <p>If I run <code>list1</code> and check the output it shows <code>[&quot;a&quot;]</code></p> <p>But, If I run <code>list1</code>, <code>list2</code> and <code>list3</code> in one cell and check for list1 it shows <code>['a','c']</code>, can someone please explain why is it so?</p>
[ { "answer_id": 74272079, "author": "ChamRun", "author_id": 14761615, "author_profile": "https://Stackoverflow.com/users/14761615", "pm_score": 2, "selected": false, "text": "def check(val, values=None):\n if values is None:\n values = []\n values.append(val)\n return valu...
2022/11/01
[ "https://Stackoverflow.com/questions/74272010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7057029/" ]
74,272,086
<p>My log file looks like this:</p> <pre><code>01-Nov-2022 10:13:36 CDOTCEM CLI: USER=root COMMAND=configure_system_firewall no 01-Nov-2022 10:13:38 CDOTCEM sudo: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/usr/sbin/iptables --policy OUTPUT ACCEPT 01-Nov-2022 10:13:38 CDOTCEM sudo: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/usr/sbin/iptables --policy INPUT ACCEPT 01-Nov-2022 10:13:38 CDOTCEM sudo: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/usr/sbin/iptables -F 01-Nov-2022 10:13:38 CDOTCEM sudo: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/usr/sbin/iptables-save 01-Nov-2022 10:14:21 CDOTCEM CLI: USER=root COMMAND=configure_system_ntp_server 192.168.1.98 12.1.4.2 01-Nov-2022 10:14:21 CDOTCEM sudo: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/bin/rm /tmp/1.dmp 01-Nov-2022 10:14:21 CDOTCEM sudo: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/bin/rm /tmp/1.dmp 01-Nov-2022 10:14:26 CDOTCEM CLI: USER=root COMMAND=configure_system_apply_configuration 01-Nov-2022 10:14:29 CDOTCEM sudo: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/sbin/reboot 01-Nov-2022 10:14:29 CDOTCEM sshd[27216]: pam_unix(sshd:session): session closed for user root 01-Nov-2022 10:14:29 CDOTCEM sshd[27216]: pam_warn(sshd:setcred): function=[pam_sm_setcred] service=[sshd] terminal=[ssh] user=[root] ruser=[&lt;unknown&gt;] rhost=[192.168.2 01-Nov-2022 10:14:57 CDOTCEM: SELF-TEST Passed 01-Nov-2022 10:15:19 CDOTCEM ipsec_starter[12235]: Starting strongSwan 5.7.2-nistpqc IPsec [starter]... 01-Nov-2022 10:15:20 CDOTCEM ipsec_starter[12306]: charon (12310) started after 820 ms 01-Nov-2022 10:28:13 CDOTCEM: SELF-TEST Passed 31-Oct-2022 10:31:07 CDOTCEM ipsec_starter[7199]: Starting strongSwan 5.7.2-nistpqc IPsec [starter]... 31-Oct-2022 10:31:07 CDOTCEM ipsec_starter[7273]: charon (7278) started after 520 ms 31-Oct-2022 11:58:50 CDOTCEM sshd[13011]: PAM unable to dlopen(/lib/security/pam_cracklib.so): /lib/security/pam_cracklib.so: cannot open shared object file: No such fi 31-Oct-2022 11:58:50 CDOTCEM sshd[13011]: PAM adding faulty module: /lib/security/pam_cracklib.so 31-Oct-2022 11:58:50 CDOTCEM sshd[13011]: PAM _pam_init_handlers: no default config /etc/pam.d/other 31-Oct-2022 11:58:53 CDOTCEM sshd[13057]: pam_warn(sshd:auth): function=[pam_sm_authenticate] service=[sshd] terminal=[ssh] user=[root] ruser=[&lt;unknown&gt;] rhost=[192.168 31-Oct-2022 11:58:53 CDOTCEM sshd[13057]: pam_unix(sshd:account): account root has password changed in future </code></pre> <p>I want to print logs that are in between two dates specified by user. The log file is not sorted. Kindly suggest any way. awk command is not working correctly</p> <p>I tried using awk command but it is giving wrong output</p> <pre><code>awk '$0&gt;=from&amp;&amp;$0&lt;=to' from=&quot;$start date&quot; to=&quot;$end_date&quot; auditfile </code></pre> <p>It gives wrong output if file is not sorted.</p>
[ { "answer_id": 74272079, "author": "ChamRun", "author_id": 14761615, "author_profile": "https://Stackoverflow.com/users/14761615", "pm_score": 2, "selected": false, "text": "def check(val, values=None):\n if values is None:\n values = []\n values.append(val)\n return valu...
2022/11/01
[ "https://Stackoverflow.com/questions/74272086", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20385117/" ]
74,272,117
<p>Hi I have read a lot about this argument, but don't get right solution how can change preferred network in android 5+ pragmatically. just allow phone to used 3g only is it possible if yes then plz suggest me any code or any path!!</p>
[ { "answer_id": 74274210, "author": "Top4o", "author_id": 8929068, "author_profile": "https://Stackoverflow.com/users/8929068", "pm_score": 0, "selected": false, "text": "try{\n Intent intent = new Intent(\"android.intent.action.MAIN\");\n intent.setClassName(\"com.android.settings\...
2022/11/01
[ "https://Stackoverflow.com/questions/74272117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20117842/" ]
74,272,120
<p>I wrote a <strong>WPF</strong> program where I want to <strong>change</strong> the <strong>background color</strong> of the main window using the <strong>settings window</strong>. Project requirements: 1- The settings window should be able to save the colors in a variable and display those colors again the moment the settings window is opened again. 2- The background color of the main window should be perfectly Binding to the colors in the settings window, which will be applied immediately when changes are made.</p> <p><a href="https://www.mediafire.com/file/pahxjaohom8frev/RectChangeColor.zip/file" rel="nofollow noreferrer">My WPF Project</a></p> <p>I tried several methods including: 1- I defined a global variable of type LinearGradientBrush in the code behind the main window. 2- I defined a global variable of type LinearGradientBrush in the app.xaml file.</p> <p>But none of these methods worked properly</p>
[ { "answer_id": 74272685, "author": "Denis Schaf", "author_id": 8463053, "author_profile": "https://Stackoverflow.com/users/8463053", "pm_score": -1, "selected": false, "text": "properties.settings.default.yourColor = newBackgroundColor;\nproperties.settings.default.save();\n" }, { ...
2022/11/01
[ "https://Stackoverflow.com/questions/74272120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3202916/" ]
74,272,138
<p>What is the best way to merge array contents from JavaScript objects sharing a key in common?</p> <p>How can array in the example below be reorganized into output? Here, all value keys (whether an array or not) are merged into all objects sharing the same name key.</p> <pre class="lang-js prettyprint-override"><code>const array = [ { brand: ['Adidas', 'Nike'] color: ['red'] }, { brand: ['Puma', 'Nike'], size: ['31', '32'] } ] /* Expect output [{ brand: ['Adidas', 'Puma', 'Nike'], size: ['31', '32'] color: ['red'] }] */ </code></pre>
[ { "answer_id": 74272685, "author": "Denis Schaf", "author_id": 8463053, "author_profile": "https://Stackoverflow.com/users/8463053", "pm_score": -1, "selected": false, "text": "properties.settings.default.yourColor = newBackgroundColor;\nproperties.settings.default.save();\n" }, { ...
2022/11/01
[ "https://Stackoverflow.com/questions/74272138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17580343/" ]
74,272,161
<p>I write #define macros</p> <p>I want to have a function or a macro that prints its name when I give it a value</p> <p>for example :</p> <p>`</p> <pre><code>#define ten 10 string printName(int value); int main() { cout&lt;&lt;printName(10); } </code></pre> <p>`</p> <pre><code>output : ten </code></pre> <p>A solution or code sample</p>
[ { "answer_id": 74272250, "author": "John3136", "author_id": 857132, "author_profile": "https://Stackoverflow.com/users/857132", "pm_score": 1, "selected": false, "text": "#define ten 10\n#define xxx 10\n\nstring printName(int value);\nint main()\n{\n cout<<printName(10);\n}\n" }, ...
2022/11/01
[ "https://Stackoverflow.com/questions/74272161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20385160/" ]
74,272,163
<p>I have two sets of data. Both are saved in a states.I want to update the rowsData inside the data1 state based on the values in data2 state. The &quot;row&quot; value in the data2 object refers to the &quot;id&quot; of rowsData in the data1 state and columns in the data2 refers to any data beside id in the rowsData object in data1. I want to pick &quot;row&quot; and &quot;column&quot; from data2 and cahnge the respective data inside rowsData in data1.</p> <pre><code>let tableData = { columnsDef: [ { title: &quot;id&quot;,field: &quot;id&quot;,className: &quot;header-style&quot; }, { title: &quot;First_name&quot;, field: &quot;First_name&quot;, className: &quot;header-style&quot; }, { title: &quot;Last_name&quot;, field: &quot;Last_name&quot;, className: &quot;header-style&quot; }, { title: &quot;Email&quot;, field: &quot;Email&quot;, className: &quot;header-style&quot; }, ], rowsData:[ { id: &quot;1&quot;, First_name: &quot;Donald&quot;, Last_name: &quot;OConnell&quot;, Email: &quot;DOCONNEL&quot; }, { id: &quot;2&quot;, First_name: &quot;Douglas&quot;, Last_name: &quot;Grant&quot;, Email: &quot;DGRANT&quot; }, { id: &quot;3&quot;, First_name: &quot;Jennifer&quot;, Last_name: &quot;Whalen&quot;, Email: &quot;JWHALEN&quot; }, { id: &quot;4&quot;, First_name: &quot;Michael&quot;, Last_name: &quot;Hartstein&quot;, Email: &quot;MHARTSTE&quot; }, { id: &quot;5&quot;, First_name: &quot;Pat&quot;, Last_name: &quot;Fay&quot;, Email: &quot;PFAY&quot; }, { id: &quot;6&quot;, First_name: &quot;Susan&quot;, Last_name: &quot;Mavris&quot;, Email: &quot;SMAVRIS&quot; }, { id: &quot;7&quot;, First_name: &quot;Hermann&quot;, Last_name: &quot;Baer&quot;, Email: &quot;HBAER&quot; } ], file: [ { file: { path: &quot;dummy_data_3 .csv&quot;}} ], } let updatedTableData = [ { &quot;row&quot;: 2, &quot;column&quot;: &quot;Email&quot;, &quot;oldValue&quot;: &quot;DGRANT&quot;, &quot;newValue&quot;: &quot;DGRANT UPDATED&quot; }, { &quot;row&quot;: 6, &quot;column&quot;: &quot;First_name&quot;, &quot;oldValue&quot;: &quot;Susan&quot;, &quot;newValue&quot;: &quot;SUSAN UPDATED&quot; }, { &quot;row&quot;: 4, &quot;column&quot;: &quot;Last_name&quot;, &quot;oldValue&quot;: &quot;Hartstein&quot;, &quot;newValue&quot;: &quot;Hartstein UPDATED&quot; } ] const [data1, setData1] = useState(tableData) const [data2, setData2] = useState(updatedTableData) </code></pre> <p>Here is the codesandbox link for the issue.</p> <p><a href="https://codesandbox.io/s/reverent-firefly-r87huj?file=/src/App.js" rel="nofollow noreferrer">https://codesandbox.io/s/reverent-firefly-r87huj?file=/src/App.js</a></p>
[ { "answer_id": 74272250, "author": "John3136", "author_id": 857132, "author_profile": "https://Stackoverflow.com/users/857132", "pm_score": 1, "selected": false, "text": "#define ten 10\n#define xxx 10\n\nstring printName(int value);\nint main()\n{\n cout<<printName(10);\n}\n" }, ...
2022/11/01
[ "https://Stackoverflow.com/questions/74272163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8033563/" ]
74,272,191
<p>This comes out as undefined. Why is this?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var possibleKeyCodes = [ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90 ]; console.log(possibleKeyCodes[0].key);</code></pre> </div> </div> </p> <p>I expected it to give me a key name as a string. It just gave me an <code>undefined</code>.</p>
[ { "answer_id": 74272235, "author": "Manos Kounelakis", "author_id": 7180331, "author_profile": "https://Stackoverflow.com/users/7180331", "pm_score": 1, "selected": true, "text": "var possibleKeyCodes = [ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,...
2022/11/01
[ "https://Stackoverflow.com/questions/74272191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19825140/" ]
74,272,210
<p>I have following dictionary</p> <pre><code> { &quot;match_1&quot;:{ &quot;home_team&quot;:2, &quot;away_team&quot;:1 }, &quot;match_2&quot;:{ &quot;home_team&quot;:1, &quot;away_team&quot;:2 }, &quot;match_3&quot;:{ &quot;home_team&quot;:1, &quot;away_team&quot;:4} } </code></pre> <p>I want to sum home team and away team goals and find which team won in aggregate if both have same score result is draw. I tried converting to <code>tuple</code> and used <code>max</code> with <code>lambda</code> but it fails when result score is same.</p> <p>required output for current question: <code>winner! away team</code></p> <p>if same goals in all matches in aggregate: <code>Draw</code></p>
[ { "answer_id": 74272235, "author": "Manos Kounelakis", "author_id": 7180331, "author_profile": "https://Stackoverflow.com/users/7180331", "pm_score": 1, "selected": true, "text": "var possibleKeyCodes = [ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,...
2022/11/01
[ "https://Stackoverflow.com/questions/74272210", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14689289/" ]
74,272,248
<p>I was trying to split a Gerrit relation chain into independent commits because their changes are in separate sections of the project.</p> <pre><code>main -- A -- B main -- A \__ B </code></pre> <p>I didn't know what commands to use, so I tried pushing Commit B with the same Change ID in a fresh git repo on tip of main (i.e. <code>git reset --hard origin/main</code>). On Commit B's review, the relation chain doesn't have Commit A (expected), however Commit A's review still shows Commit B in its chain and with &quot;Not Current&quot;, so it probably wasn't the correct way to do it.</p> <p>How can I fix this so Commit A's relation chain doesn't show Commit B?</p>
[ { "answer_id": 74272235, "author": "Manos Kounelakis", "author_id": 7180331, "author_profile": "https://Stackoverflow.com/users/7180331", "pm_score": 1, "selected": true, "text": "var possibleKeyCodes = [ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,...
2022/11/01
[ "https://Stackoverflow.com/questions/74272248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17851340/" ]
74,272,256
<p>We have an application that does lot of data heavy work on the server for a multi-tenant workspace.</p> <p>Here are the things that it do :</p> <ol> <li>It loads data from files from different file format.</li> <li>Execute idempotence rules based on the logic defined.</li> <li>Execute processing logic like adding discount based on country for users / calculating tax amount etc.. These are specific to each tenant.</li> <li>Generate refreshed data for bulk edit.</li> </ol> <p>Now after these processing is done, the Tenant will go the the Interface, do some bulk edit overrides to users, and finally download them as some format.</p> <p><strong>We have tried a lot of solutions before like :</strong></p> <ul> <li>Doing it in one SQL database where each tenant is separated with tenant id</li> <li>Doing it in Azure blobs.</li> <li>Loading it from file system files.</li> </ul> <p>But none has given performance. So what is presently designed is :</p> <ul> <li>We have a Central database which keeps track of all the databases of Customers.</li> <li>We have a number of Database Elastic Pools in Azure.</li> <li>When a new tenant comes in, we create a Database, Do all the processing for the users and notify the user to do manual job.</li> <li>When they have downloaded all the data we keep the Database for future.</li> </ul> <p>Now, as you know, Elastic Pools has a limit of number of databases, which led us to create multiple Elastic pools, and eventually keeping on increasing the Azure Cost immensely, while 90% of the databases are not in use at a given point of time. We already have more than 10 elastic pools each consisting of 500 databases.</p> <p><em><strong>Proposed Changes:</strong></em></p> <p>As gradually we are incurring more and more cost to our Azure account, we are thinking how to reduce this.</p> <p><strong>What I was proposing is :</strong></p> <ol> <li>We create one Elastic Pool, which has 500 database limit with enough DTU.</li> <li>In this pool, we will create blank databases.</li> <li>When a customer comes in, the data is loaded on any of the blank databases.</li> <li>It does all the calculations, and notify the tenant for manual job.</li> <li>When manual job is done, we keep the database for next 7 days.</li> <li>After 7 days, we backup the database in Azure Blob, and do the cleanup job on the database.</li> <li>Finally, if the same customer comes in again, we restore the backup on a blank database and continue. (This step might take 15 - 20 mins to setup, but it is fine for us.. but if we can reduce it would be even better)</li> </ol> <p>What do you think best suited for this kind of problem ?</p> <p><strong>Our objective is how to reduce Azure cost, and also providing best solution to our customers</strong>. Please help on any architecture that you think would be best suited in this scenario.</p> <p>Each customer can have millions of Record ... we see customers having 50 -100 GB of databases even... and also with different workloads for each tenant.</p>
[ { "answer_id": 74437462, "author": "Francesco Mantovani", "author_id": 4652358, "author_profile": "https://Stackoverflow.com/users/4652358", "pm_score": 1, "selected": false, "text": "master" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74272256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/255575/" ]
74,272,257
<p>I'm new in Python and I've been trying to create csv file and save each result in a new row. The results consist of several rows and each line should be captured in csv. However, my csv file separate each letter into new row. I also need to add new key values for the filename, but I dont know how to get the image filename (input is images). I used the search bar searching for similar case/recommended solution but still stumped. Thanks in advance.</p> <pre><code>with open('glaresss_result.csv','wt') as f: f.write(&quot;,&quot;.join(res1.keys()) + &quot;\n&quot;) for imgpath in glob.glob(os.path.join(TARGET_DIR, &quot;*.png&quot;)): res1,res = send_request_qcglare(imgpath) for row in zip(*res1.values()): f.write(&quot;,&quot;.join(str(n) for n in row) + &quot;\n&quot;) f.close() </code></pre> <p>dictionary <code>res1</code> printed during the iteration returns:</p> <pre><code>{'glare': 'Passed', 'brightness': 'Passed'} </code></pre> <p>The results should be like this (got 3 rows):</p> <ul> <li><strong>glare brightness</strong></li> <li>Passed Passed</li> <li>Passed Passed</li> <li>Passed. Passed</li> </ul> <p>But the current output looks like this:</p> <p><a href="https://i.stack.imgur.com/k54vs.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k54vs.jpg" alt="Current output in csv" /></a></p>
[ { "answer_id": 74272613, "author": "Rabinzel", "author_id": 15521392, "author_profile": "https://Stackoverflow.com/users/15521392", "pm_score": 2, "selected": true, "text": "w" }, { "answer_id": 74272748, "author": "Luca Furrer", "author_id": 12189626, "author_profile...
2022/11/01
[ "https://Stackoverflow.com/questions/74272257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19937408/" ]
74,272,259
<p>So.. im working on this loop:</p> <pre><code>stuff_so_far = [intl_pt] for i in range(0, num_pts - 1): rdm = random.randint(0, len(points_in_code) - 1) a = (stuff_so_far[i][0] + points_in_code[rdm][0]) // 2 b = (stuff_so_far[i][1] + points_in_code[rdm][1]) // 2 stuff_so_far.append((a, b)) </code></pre> <p>Basically what i want to achive is to get a random index for &quot;points_in_code&quot; every time the code loops. It is doing that now, but what i want to know is, how do i make it not randomly repeat a number? As in, if in the first iteration of the loop rdm gets set to 1, and then in the second iteration of the loop rdm gets set to 3, and in some cases, rdm can be set to 1 again in the third itertion. How do i make it not be 1 again (as long as the loop is still going)?</p> <p>Ive tried everything i know and searched online but i found nothing, how do i make that happen without altering my code too much? (im new to programming) I know each time i call random.randint(), i am creating a single random number, it does not magically change to a new random not used before number everytime the loop iterates.</p>
[ { "answer_id": 74272359, "author": "mousetail", "author_id": 6333444, "author_profile": "https://Stackoverflow.com/users/6333444", "pm_score": 1, "selected": false, "text": "random.sample" }, { "answer_id": 74272386, "author": "Anubhav Sharma", "author_id": 13719128, ...
2022/11/01
[ "https://Stackoverflow.com/questions/74272259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20218118/" ]
74,272,261
<p>I have a <code>json</code> file with about 1,200,000 records. I want to read this file with <code>pyspark</code> as :</p> <pre class="lang-py prettyprint-override"><code>spark.read.option(&quot;multiline&quot;,&quot;true&quot;).json('file.json') </code></pre> <p>But it causes this error:</p> <blockquote> <p>AnalysisException: Unable to infer schema for JSON. It must be specified manually.</p> </blockquote> <p>When I create a <code>json</code> file with a smaller record count in the main file, this code can read the file.</p> <p>I can read this <code>json</code> file with <code>pandas</code>, when I set the <code>encoding</code> to <code>utf-8-sig</code>:</p> <pre class="lang-py prettyprint-override"><code>pd.read_json(&quot;file.json&quot;, encoding = 'utf-8-sig') </code></pre> <p>How can I solve this problem?</p>
[ { "answer_id": 74272359, "author": "mousetail", "author_id": 6333444, "author_profile": "https://Stackoverflow.com/users/6333444", "pm_score": 1, "selected": false, "text": "random.sample" }, { "answer_id": 74272386, "author": "Anubhav Sharma", "author_id": 13719128, ...
2022/11/01
[ "https://Stackoverflow.com/questions/74272261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/806160/" ]
74,272,295
<p>Given a String like this: String secret = “H)86(e,@€l:-;l?,;5o” they ask me to make a new String with only the letters (and spaces if they are) to reveal a secret message….</p> <p>I tried with a for loop and the charAt method, but it didn’t work… ideas? I would appreciate plain explanation as I’m noob on programming. Thanks!!</p>
[ { "answer_id": 74272387, "author": "Tan Sang", "author_id": 10297961, "author_profile": "https://Stackoverflow.com/users/10297961", "pm_score": 0, "selected": false, "text": "\"[a-zA-Z ]*\"" }, { "answer_id": 74272440, "author": "Christoph Dahlen", "author_id": 20370596, ...
2022/11/01
[ "https://Stackoverflow.com/questions/74272295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19136113/" ]
74,272,363
<pre class="lang-py prettyprint-override"><code>a = [1,4,7,5,9,3,5] b = [3,7,6,5,4,9,7] c = [] for i in range(len(a)-1): if a[i] &lt; b[i]: c.append(b[i]) </code></pre> <p>I have the simple code above.</p> <p>Since <code>len(a) = 7</code>. The for loop should run 7-1 =6 times. I want to check is <code>a[i]</code> is less than <code>b[i]</code>. If this is true, then it should print the <code>b[i]</code> value in the new list <code>c</code>. However, when I run this code there is nothing in the output. I knew something was wrong with this code before running it but I can't figure out what.</p> <p>Could someone out what is wrong? Thanks</p> <p>I tried to amend the for loop.</p>
[ { "answer_id": 74272431, "author": "Will", "author_id": 20384800, "author_profile": "https://Stackoverflow.com/users/20384800", "pm_score": 1, "selected": false, "text": "print(c)" }, { "answer_id": 74272498, "author": "Alex Liao", "author_id": 19896305, "author_profi...
2022/11/01
[ "https://Stackoverflow.com/questions/74272363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20369114/" ]
74,272,398
<p><strong>I want to pass this SupplierItemModal.jsx component (id) value into the CreateSupplierItemModal.jsx componet</strong></p> <p><a href="https://i.stack.imgur.com/29xAE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/29xAE.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74272431, "author": "Will", "author_id": 20384800, "author_profile": "https://Stackoverflow.com/users/20384800", "pm_score": 1, "selected": false, "text": "print(c)" }, { "answer_id": 74272498, "author": "Alex Liao", "author_id": 19896305, "author_profi...
2022/11/01
[ "https://Stackoverflow.com/questions/74272398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20163879/" ]
74,272,410
<p>I want to store some information with my new custom table in Wordpress website, whenever admin create update or delete any post or page that time some information store my custom table. Below my custom table operations</p> <p>Operations: id,User_id,operation_type,table_name,row_id,operation_at,created_at,updated_at.</p> <p>user_id (post_author) operation_type (add/update/delete etc), table_name (which table add/update/delete), row_id (post r page own id), operation_at (that time when admin add/update/delete), created_at (operations table current time), updated_at (operations current time),</p> <p>how can implement this code?</p> <p>Thanks</p>
[ { "answer_id": 74272431, "author": "Will", "author_id": 20384800, "author_profile": "https://Stackoverflow.com/users/20384800", "pm_score": 1, "selected": false, "text": "print(c)" }, { "answer_id": 74272498, "author": "Alex Liao", "author_id": 19896305, "author_profi...
2022/11/01
[ "https://Stackoverflow.com/questions/74272410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20385283/" ]
74,272,413
<p>I want to open my app by tap on a app widget. So.</p> <pre><code>remote_views.setOnClickPendingIntent( R.id.layout, PendingIntent.getActivity( context, 0, new Intent( context, Main.class ).setFlags( Intent.FLAG_ACTIVITY_NEW_TASK ), PendingIntent.FLAG_IMMUTABLE ) ); </code></pre> <p>But I want to open existing app and keep back stack. If I remove <code>Intent.FLAG_ACTIVITY_NEW_TASK</code> then on new Android I get:</p> <blockquote> <p>java.lang.RuntimeException: Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag.</p> </blockquote> <p>I can set in manifest file</p> <pre><code> &lt;activity android:name=&quot;.Main&quot; android:launchMode=&quot;singleInstance&quot; android:exported=&quot;true&quot; &gt; </code></pre> <p>and open existing activity but lost back stack in addition then press Home button and launch the app again by icon then back stack lost too.</p> <p>So, is it possible?</p>
[ { "answer_id": 74273172, "author": "Style-7", "author_id": 9057721, "author_profile": "https://Stackoverflow.com/users/9057721", "pm_score": 0, "selected": false, "text": "android:launchMode=\"singleTop\"" }, { "answer_id": 74277213, "author": "David Wasser", "author_id":...
2022/11/01
[ "https://Stackoverflow.com/questions/74272413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9057721/" ]
74,272,451
<p><strong>i have an input called id and i want to specify the button path for that id example:</strong></p> <blockquote> <p>in my blade file</p> </blockquote> <pre><code>&lt;div class=&quot;modal-body&quot;&gt; &lt;lable for=&quot;&quot;&gt;ID:&lt;/lable&gt;&lt;br/&gt; &lt;input type=&quot;text&quot; name=&quot;id&quot; placeholder=&quot;Enter the product name&quot; required&gt;&lt;br/&gt; &lt;/div&gt; &lt;div class=&quot;modal-footer&quot;&gt; &lt;button type=&quot;button&quot; class=&quot;btn btn-secondary&quot; data-dismiss=&quot;modal&quot;&gt;Close&lt;/button&gt; &lt;button type=&quot;button&quot; onclick=&quot;location.href='/produtos/editar/{{$id}}';&quot; class=&quot;btn btn-primary&quot; &gt;Save changes&lt;/button&gt; &lt;/div&gt; </code></pre> <blockquote> <p>Now my controler.php</p> </blockquote> <pre><code>public function update(Request $request, $id){ $produto=Produto::findOrFail($id); $produto-&gt;update([ 'id'=&gt;$request-&gt;id, 'Nome'=&gt;$request-&gt;nome, 'custo'=&gt;$request-&gt;custo, 'preco'=&gt;$request-&gt;preco, 'quantidade'=&gt;$request-&gt;quantidade, 'Marca'=&gt;$request-&gt;marcas, 'Voltagem'=&gt;$request-&gt;Voltagem, 'Descricao'=&gt;$request-&gt;Descricao, ]); return &quot; Produto Atualizado com Sucesso!&quot;; } </code></pre> <blockquote> <p>now in routes file</p> </blockquote> <pre><code>Route::get('/produtos/editar/{id}', 'App\Http\Controllers\ProdutosController@edit'); Route::post('/produtos/editar/{id}', 'App\Http\Controllers\ProdutosController@update')-&gt;name('alterar_produto'); </code></pre> <p>Being able to get the input value and put it along the route to the file</p>
[ { "answer_id": 74273172, "author": "Style-7", "author_id": 9057721, "author_profile": "https://Stackoverflow.com/users/9057721", "pm_score": 0, "selected": false, "text": "android:launchMode=\"singleTop\"" }, { "answer_id": 74277213, "author": "David Wasser", "author_id":...
2022/11/01
[ "https://Stackoverflow.com/questions/74272451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19273133/" ]
74,272,481
<p>I want to schedule notifications as an alarm that should trigger on different time on the same day. Whenever i am Scheduling multiple notifications, Alarm Only fires the latest notification and discard all the previous schedules. I am Using Alarm Manager with Flutter Local notification. Also this is all happening in background.</p> <p>I have tried Android Alarm Manager android_alarm_manager_plus plugin and Flutter local notifications to schedule multiple notifications on the same day.</p>
[ { "answer_id": 74273172, "author": "Style-7", "author_id": 9057721, "author_profile": "https://Stackoverflow.com/users/9057721", "pm_score": 0, "selected": false, "text": "android:launchMode=\"singleTop\"" }, { "answer_id": 74277213, "author": "David Wasser", "author_id":...
2022/11/01
[ "https://Stackoverflow.com/questions/74272481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13804995/" ]
74,272,595
<p>admin.py:</p> <pre><code>admin.site.register(models.User) admin.site.register(models.Teacher) admin.site.register(models.Student) admin.site.register(models.CourseCategory) admin.site.register(models.Course) admin.site.register(models.Chapter) admin.site.register(models.Section) admin.site.register(models.StudentCourseEnrollment) admin.site.register(models.CourseRating) </code></pre> <p>settings.py:</p> <pre><code>DATABASES = { 'default': { 'ENGINE': 'Django.DB.backends.MySQL, 'NAME': 'LMSAPI', 'USER':'admin', 'PASSWORD':'12341234', 'HOST':'mydb.cvijitliru7b.ap-northeast-1.rds.amazonaws.com', 'PORT':'3306', 'CHARSET': 'utf8', } </code></pre> <p>and this is the error <a href="https://i.stack.imgur.com/xOT6C.png" rel="nofollow noreferrer">enter image description here</a></p> <p>Error traceback:</p> <pre><code> TypeError at /admin/login/ can only concatenate str (not &quot;NoneType&quot;) to str Request Method: GET Request URL: http://127.0.0.1:8000/admin/login/?next=/admin/ Django Version: 4.1.2 Exception Type: TypeError Exception Value: can only concatenate str (not &quot;NoneType&quot;) to str Exception Location: C:\Users\DIDAM\Desktop\venv\Lib\site-packages\botocore\auth.py, line 371, in signature Raised during: Django.contrib.admin.sites.login Python Executable: C:\Users\DIDAM\Desktop\venv\Scripts\python.exe Python Version: 3.11.0 Python Path: ['C:\\Users\\DIDAM\\Desktop\\heroku_lms_api', 'C:\\Python311\\python311.zip', 'C:\\Python311\\DLLs', 'C:\\Python311\\Lib', 'C:\\Python311', 'C:\\Users\\DIDAM\\Desktop\\venv', 'C:\\Users\\DIDAM\\Desktop\\venv\\Lib\\site-packages', 'C:\\Users\\DIDAM\\Desktop\\venv\\Lib\\site-packages\\win32', 'C:\\Users\\DIDAM\\Desktop\\venv\\Lib\\site-packages\\win32\\lib', 'C:\\Users\\DIDAM\\Desktop\\venv\\Lib\\site-packages\\Pythonwin'] Server time: Tue, 01 Nov 2022 06:48:59 +0000 </code></pre>
[ { "answer_id": 74273172, "author": "Style-7", "author_id": 9057721, "author_profile": "https://Stackoverflow.com/users/9057721", "pm_score": 0, "selected": false, "text": "android:launchMode=\"singleTop\"" }, { "answer_id": 74277213, "author": "David Wasser", "author_id":...
2022/11/01
[ "https://Stackoverflow.com/questions/74272595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18563151/" ]
74,272,600
<p>This <em>should</em> be easy :)</p> <p>Can anyone assist with the syntax required for <em>AzureResourceManagerTemplateDeployment@3</em> task to assign a value in <em>overrideParameters</em> where the ARM template parameters file is expecting array?</p> <p>Example:</p> <p>The ARM template parameters file, expects an array:</p> <pre><code>&quot;my-ssis-ir_publicIPs&quot;: { &quot;type&quot;: &quot;array&quot;, &quot;defaultValue&quot;: [ &quot;/subscriptions/XXXXX/resourceGroups/my-rg/providers/Microsoft.Network/publicIPAddresses/my-01-ssisir-pip&quot;, &quot;/subscriptions/XXXXX/resourceGroups/my-rg/providers/Microsoft.Network/publicIPAddresses/my-02-ssisir-pip&quot; ] }, </code></pre> <p>AzureResourceManagerTemplateDeployment@3 code task - showing the attempt to use overrideParameters to provide override values for my-ssis-ir_publicIPs with hard coded values representing two public ips as an array:</p> <pre><code>- task: AzureResourceManagerTemplateDeployment@3 displayName: 'ARM Template deployment: Resource Group scope' inputs: azureResourceManagerConnection: ${{ parameters.azureResourceManagerConnection }} subscriptionId: ${{ parameters.subscriptionId }} resourceGroupName: ${{ parameters.resourceGroupName }} location: '${{ parameters.location }}' csmFile: '$(Build.SourcesDirectory)/${{parameters.squadName}}/$(Build.Repository.Name)/${{parameters.buildId}}/ARMTemplateForFactory.json' csmParametersFile: '$(Build.SourcesDirectory)/${{parameters.squadName}}/$(Build.Repository.Name)/${{parameters.buildId}}/ARMTemplateParametersForFactory.json' overrideParameters: -my-ssis-ir_publicIPs ['/subscriptions/XXXXX/resourceGroups/my-rg/providers/Microsoft.Network/publicIPAddresses/my-01-ssisir-pip','/subscriptions/XXXXX/resourceGroups/my-rg/providers/Microsoft.Network/publicIPAddresses/my-02-ssisir-pip'] </code></pre> <p>Most of my efforts result errors indicating that a string is being passed in to the parameter, where Array is expected.</p> <p>I have tried a number of options such as - setting parameters in the yml file</p> <pre><code>parameters: - name: my-ssis-ir_publicIPs type: object default: - '/subscriptions/XXXXX/resourceGroups/my-rg/providers/Microsoft.Network/publicIPAddresses/my-01-ssisir-pip' - '/subscriptions/XXXXX/resourceGroups/my-rg/providers/Microsoft.Network/publicIPAddresses/my-02-ssisir-pip' </code></pre> <p>And then have tried to assign the parameter:</p> <pre><code>overrideParameters: -my-ssis-ir_publicIPs ${{ convertToJson(parameters.my-ssis-ir_publicIPs) }} </code></pre> <p>Obviously, I will need to be using parameters, passed into the yaml file, but am first trying to get this to work by learning the syntax at the point the override is being applied.</p>
[ { "answer_id": 74272856, "author": "Maytham Fahmi", "author_id": 3088349, "author_profile": "https://Stackoverflow.com/users/3088349", "pm_score": 1, "selected": true, "text": "overrideParameters" }, { "answer_id": 74286241, "author": "SuttyHoo", "author_id": 9152608, ...
2022/11/01
[ "https://Stackoverflow.com/questions/74272600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9152608/" ]
74,272,652
<p>While writing a spark dataframe using write method to a csv file, the csv file is getting populated as &quot;&quot; for null strings</p> <pre><code>101|abc|&quot;&quot;|555 102|&quot;&quot;|xyz|743 </code></pre> <p>Using the below code:</p> <pre class="lang-scala prettyprint-override"><code>dataFrame .coalesce(16) .write .format(&quot;csv&quot;) .option(&quot;delimiter&quot;, &quot;|&quot;) .option(&quot;treatEmptyValuesAsNulls&quot;, &quot;true&quot;) .option(&quot;nullValue&quot;, null) .option(&quot;emptyValue&quot;, null) .mode(SaveMode.Overwrite) .save(path) </code></pre> <p>Expected output:</p> <pre><code>101|abc|null|555 102|null|xyz|743 </code></pre> <p>Spark version 3.2 and Scala version 2.1</p>
[ { "answer_id": 74272800, "author": "Pritish", "author_id": 10622280, "author_profile": "https://Stackoverflow.com/users/10622280", "pm_score": 1, "selected": false, "text": "\"null\"" }, { "answer_id": 74273969, "author": "Ikshwaku Baruah", "author_id": 20279597, "aut...
2022/11/01
[ "https://Stackoverflow.com/questions/74272652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20279597/" ]
74,272,667
<p>I would like to see all the code text on the left when I open PyCharm. I don't like that the code is all placed in the center. I would like to move it to the left. How can I?</p> <p>There are no spaces before the code. It happens to all PyCharm files. The same files, if imported into another editor, have the code positioned on the left and there is no space.</p> <p><a href="https://i.stack.imgur.com/ZU1fS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZU1fS.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/08Qsw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/08Qsw.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74273955, "author": "m4r10", "author_id": 8452671, "author_profile": "https://Stackoverflow.com/users/8452671", "pm_score": 3, "selected": true, "text": "View > Appearance > Exit Distraction free mode" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74272667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18313765/" ]
74,272,713
<p>I am trying to run openCV in C++ and capture the camera input.</p> <p>The program looks like this:</p> <pre><code>#include &lt;iostream&gt; #include &lt;sstream&gt; #include &lt;new&gt; #include &lt;string&gt; #include &lt;sstream&gt; #include &lt;opencv2/opencv.hpp&gt; #include &lt;opencv2/core.hpp&gt; #include &lt;opencv2/imgcodecs.hpp&gt; #include &lt;opencv2/highgui.hpp&gt; #define INPUT_WIDTH 3264 #define INPUT_HEIGHT 2464 #define DISPLAY_WIDTH 640 #define DISPLAY_HEIGHT 480 #define CAMERA_FRAMERATE 21/1 #define FLIP 2 void DisplayVersion() { std::cout &lt;&lt; &quot;OpenCV version: &quot; &lt;&lt; cv::getVersionMajor() &lt;&lt; &quot;.&quot; &lt;&lt; cv::getVersionMinor() &lt;&lt; &quot;.&quot; &lt;&lt; cv::getVersionRevision() &lt;&lt; std::endl; } int main(int argc, const char** argv) { DisplayVersion(); std::stringstream ss; ss &lt;&lt; &quot;nvarguscamerasrc ! video/x-raw(memory:NVMM), width=3264, height=2464, format=NV12, framerate=21/1 ! nvvidconv flip-method=2 ! video/x-raw, width=480, height=680, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink&quot;; //ss &lt;&lt; &quot;nvarguscamerasrc ! video/x-raw(memory:NVMM), width=&quot; &lt;&lt; INPUT_WIDTH &lt;&lt; //&quot;, height=&quot; &lt;&lt; INPUT_HEIGHT &lt;&lt; //&quot;, format=NV12, framerate=&quot; &lt;&lt; CAMERA_FRAMERATE &lt;&lt; //&quot; ! nvvidconv flip-method=&quot; &lt;&lt; FLIP &lt;&lt; //&quot; ! video/x-raw, width=&quot; &lt;&lt; DISPLAY_WIDTH &lt;&lt; //&quot;, height=&quot; &lt;&lt; DISPLAY_HEIGHT &lt;&lt; //&quot;, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink&quot;; cv::VideoCapture video; video.open(ss.str()); if (!video.isOpened()) { std::cout &lt;&lt; &quot;Unable to get video from the camera!&quot; &lt;&lt; std::endl; return -1; } std::cout &lt;&lt; &quot;Got here!&quot; &lt;&lt; std::endl; cv::Mat frame; while (video.read(frame)) { cv::imshow(&quot;Video feed&quot;, frame); if (cv::waitKey(25) &gt;= 0) { break; } } std::cout &lt;&lt; &quot;Finished!&quot; &lt;&lt; std::endl; return 0; } </code></pre> <p>When running this code I get the following outout:</p> <pre><code>OpenCV version: 4.6.0 nvbuf_utils: Could not get EGL display connection Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute:751 Failed to create CaptureSession [ WARN:0@0.269] global /tmp/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp (1405) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1 Got here! Finished! </code></pre> <p>If I run the other commented command to video.open() I get this output:</p> <pre><code>OpenCV version: 4.6.0 nvbuf_utils: Could not get EGL display connection Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute:751 Failed to create CaptureSession </code></pre> <p>I'm currently running this from headless mode on a jetson nano.</p> <p>I also know that OpenCV and xlaunch works because I can use mjpeg streamer from my laptop and successfully stream my laptop camera output to my jetson nano by using <code>video.open(http://laptop-ip:laptop-port/);</code> and that works correctly (OpenCV is able to display a live video feed using xlaunch just fine).</p> <p>I think this command is telling me my camera is successfully installed:</p> <pre><code>$ v4l2-ctl -d /dev/video0 --list-formats-ext ioctl: VIDIOC_ENUM_FMT Index : 0 Type : Video Capture Pixel Format: 'RG10' Name : 10-bit Bayer RGRG/GBGB Size: Discrete 3264x2464 Interval: Discrete 0.048s (21.000 fps) Size: Discrete 3264x1848 Interval: Discrete 0.036s (28.000 fps) Size: Discrete 1920x1080 Interval: Discrete 0.033s (30.000 fps) Size: Discrete 1640x1232 Interval: Discrete 0.033s (30.000 fps) Size: Discrete 1280x720 Interval: Discrete 0.017s (60.000 fps) </code></pre> <p>Any help would be much appreciated</p>
[ { "answer_id": 74273955, "author": "m4r10", "author_id": 8452671, "author_profile": "https://Stackoverflow.com/users/8452671", "pm_score": 3, "selected": true, "text": "View > Appearance > Exit Distraction free mode" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74272713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19142373/" ]
74,272,716
<p>I am trying to deploy my Django application on Heroku but although the logs show that the build is successful and despite successful deployment the application still shows an internal server error; and this is true with debug set to either true or false. Here are the files that I think are important( also I am using the cloudinary api for this project and I am not sure if that would be the problem; anyway I still decided to include my configuration of the same herein):</p> <p>My Procfile:</p> <pre><code> web gunicorn MkusdaRegister.wsgi --log-file - </code></pre> <p>My last build log</p> <pre><code> -----&gt; Building on the Heroku-22 stack -----&gt; Using buildpack: heroku/python -----&gt; Python app detected -----&gt; Using Python version specified in runtime.txt ! ! A Python security update is available! Upgrade as soon as possible to: python-3.10.8 ! See: https://devcenter.heroku.com/articles/python-runtimes ! -----&gt; No change in requirements detected, installing from cache -----&gt; Using cached install of python-3.10.7 -----&gt; Installing pip 22.2.2, setuptools 63.4.3 and wheel 0.37.1 -----&gt; Installing SQLite3 -----&gt; Installing requirements with pip -----&gt; $ python manage.py collectstatic --noinput 185 static files copied to '/tmp/build_f409c0b9/static'. -----&gt; Discovering process types Procfile declares types -&gt; web -----&gt; Compressing... Done: 44.4M -----&gt; Launching... Released v16 https://mkusda-events.herokuapp.com/ deployed to Heroku Starting November 28th, 2022, free Heroku Dynos, free Heroku Postgres, and free Heroku Data for Redis® will no longer be available. If you have apps using any of these resources, you must upgrade to paid plans by this date to ensure your apps continue to run and to retain your data. For students, we will announce a new program by the end of September. Learn more at https://blog.heroku.com/next-chapter </code></pre> <p>My settings.py file:</p> <pre><code> import os from pathlib import Path import cloudinary import cloudinary.uploader import cloudinary.api # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = ['my-app.herokuapp.com', '127.0.0.1'] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'Accounts', 'Events', 'cloudinary' ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'MkusdaRegister.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'MkusdaRegister.wsgi.application' # Database # https://docs.djangoproject.com/en/4.1/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': str(os.path.join(BASE_DIR, 'db.sqlite3')), } } AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_TZ = True STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_URL = 'static/' cloudinary.config( cloud_name= &quot;myCloudName&quot;, api_key = &quot;myKey&quot;, api_secret = &quot;myAPIsecret&quot;, secure = True ) AUTH_USER_MODEL = 'Accounts.User' DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' </code></pre> <p>My project/urls.py file:</p> <pre><code> from django.contrib import admin from django.urls import path, include from django.conf import settings from django.conf.urls.static import static urlpatterns = [ path('admin/', admin.site.urls), path('Accounts/', include('Accounts.urls')), path('Events/', include('Events.urls')) ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT) </code></pre> <p>If anyone needs to see anymore of my code then just let me know; I'd really use help on this one.</p>
[ { "answer_id": 74272890, "author": "Ajay K", "author_id": 10782096, "author_profile": "https://Stackoverflow.com/users/10782096", "pm_score": 0, "selected": false, "text": "Base url to serve media files\nMEDIA_URL = '/media/'\n# Path where media is stored\nMEDIA_ROOT = os.path.join(BASE_...
2022/11/01
[ "https://Stackoverflow.com/questions/74272716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15990057/" ]
74,272,764
<p>I have a router component in my <code>index.js</code> file and it seems to not work properly.</p> <p>Here's what I've tried:</p> <h3>index.js</h3> <pre><code>import React from &quot;react&quot;; import ReactDOM from &quot;react-dom/client&quot;; import &quot;./index.css&quot;; import App from &quot;./App&quot;; // import reportWebVitals from &quot;./reportWebVitals&quot;; import { BrowserRouter } from &quot;react-router-dom&quot;; const root = ReactDOM.createRoot(document.getElementById(&quot;root&quot;)); root.render( &lt;BrowserRouter&gt; &lt;App /&gt; &lt;/BrowserRouter&gt; ); </code></pre> <h3>app.jsx</h3> <pre><code>import logo from './logo.svg'; import './App.css'; function App() { return ( &lt;div className=&quot;App&quot;&gt; &lt;header className=&quot;App-header&quot;&gt; &lt;img src={logo} className=&quot;App-logo&quot; alt=&quot;logo&quot; /&gt; &lt;p&gt; Edit &lt;code&gt;src/App.js&lt;/code&gt; and save to reload. &lt;/p&gt; &lt;a className=&quot;App-link&quot; href=&quot;https://reactjs.org&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; &gt; Learn React &lt;/a&gt; &lt;/header&gt; &lt;/div&gt; ); } export default App; </code></pre> <p>The screen is blank and the console gives me this error</p> <pre><code>Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons: 1. You might have mismatching versions of React and the renderer (such as React DOM) 2. You might be breaking the Rules of Hooks 3. You might have more than one copy of React in the same app See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem. </code></pre> <p>I'm following this tutorial: <a href="https://blog.logrocket.com/react-router-v6/" rel="nofollow noreferrer">https://blog.logrocket.com/react-router-v6/</a>. Using <code>react-router</code> version 6</p>
[ { "answer_id": 74272890, "author": "Ajay K", "author_id": 10782096, "author_profile": "https://Stackoverflow.com/users/10782096", "pm_score": 0, "selected": false, "text": "Base url to serve media files\nMEDIA_URL = '/media/'\n# Path where media is stored\nMEDIA_ROOT = os.path.join(BASE_...
2022/11/01
[ "https://Stackoverflow.com/questions/74272764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19126215/" ]
74,272,778
<p>Inside my &quot;characters&quot; component I have a form with a textfield, and button. -&gt; <a href="https://i.stack.imgur.com/pSNEK.png#" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pSNEK.png#" alt="enter image description here" /></a></p> <p>When I click the button it registers, and enters the function but I have no idea how to grab the current input text and use it in the called async function.</p> <p><strong>HTML:</strong> <a href="https://i.stack.imgur.com/DMF8w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DMF8w.png" alt="enter image description here" /></a></p> <p><strong>TS:</strong> <a href="https://i.stack.imgur.com/B6jfp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B6jfp.png" alt="enter image description here" /></a></p> <p>Sadly getting the promptText does not work. I have the feeling I am missing a core concept of angular here, but even after extensive search, no luck.</p> <p>Thanks in advance!</p>
[ { "answer_id": 74273444, "author": "Đỗ văn Thắng", "author_id": 11303128, "author_profile": "https://Stackoverflow.com/users/11303128", "pm_score": 2, "selected": true, "text": "const promptTxt = document.getElementById('prompt-txtbox') as HTMLInputElement;\n console.log(promptTxt...
2022/11/01
[ "https://Stackoverflow.com/questions/74272778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7967793/" ]
74,272,834
<p>I have an inline-block element and would like to centre the text next to it. I had already tried negative margin on the span (box) element but this changed the whole content (box and text).</p> <p><strong>MY code</strong></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>fieldset { max-width: 350px; margin: 0 auto; padding:1px; display: flex; justify-content: space-around; align-items: center; } .legend-item-box { display: inline-block; height: 16px; width: 30px; margin-right: 5px; margin-left: 0; border: 1px solid #999; } .a { background:#8DD3C7; } .b { background:#FFFFB3; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;fieldset&gt; &lt;legend&gt;Legend:&lt;/legend&gt; &lt;div class="legend-item-container"&gt; &lt;span class="a legend-item-box"&gt;&lt;/span&gt;Legend a &lt;/div&gt; &lt;div&gt; &lt;span class="b legend-item-box"&gt;&lt;/span&gt; Legend b &lt;/div&gt; &lt;/fieldset&gt;</code></pre> </div> </div> </p> <p>Many thanks in advance! Max</p>
[ { "answer_id": 74273444, "author": "Đỗ văn Thắng", "author_id": 11303128, "author_profile": "https://Stackoverflow.com/users/11303128", "pm_score": 2, "selected": true, "text": "const promptTxt = document.getElementById('prompt-txtbox') as HTMLInputElement;\n console.log(promptTxt...
2022/11/01
[ "https://Stackoverflow.com/questions/74272834", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18066399/" ]
74,272,874
<p>looking at <a href="https://en.cppreference.com/w/cpp/utility/functional/ref" rel="nofollow noreferrer">std::ref and std::cref</a>, the way I think it works is having two prototypes</p> <pre><code>template&lt; class T &gt; std::reference_wrapper&lt;const T&gt; cref( const T&amp; t ) noexcept; template&lt; class T &gt; void cref( const T&amp;&amp; ) = delete; </code></pre> <p>and the <code>T&amp;&amp;</code> template function is deleted.</p> <p>But when I imitate this with a similar variadic template function, the compilation is successful if atleast one argument satisfies the condition. So now I don't understand how or why this (does not?) works.</p> <pre><code>template&lt;typename ... Ts&gt; void foo(const Ts&amp; ... ts) { } template&lt;typename ... Ts&gt; void foo(const Ts&amp;&amp; ...) = delete; int main(){ std::string a{&quot;sss&quot;}; foo&lt;std::string&gt;(a); //foo&lt;std::string&gt;(&quot;sss&quot;); error, deleted foo foo&lt;std::string, std::string&gt;(a, &quot;sss&quot;); // I was expecting error here //foo&lt;std::string, std::string&gt;(&quot;aaaa&quot;, &quot;sss&quot;); error, deleted foo foo&lt;std::string, std::string, std::string&gt;(a, &quot;aaa&quot;, &quot;sss&quot;); // I was expecting error here } </code></pre> <p>This seems to be the case with clang, gcc and also msvc <a href="https://godbolt.org/z/8cboT48En" rel="nofollow noreferrer">https://godbolt.org/z/8cboT48En</a></p>
[ { "answer_id": 74273050, "author": "GAVD", "author_id": 4983082, "author_profile": "https://Stackoverflow.com/users/4983082", "pm_score": 0, "selected": false, "text": "template<typename ... Ts, std::enable_if_t<(!std::is_lvalue_reference<Ts>::value && ...), int> = 0>\nvoid foo(const Ts&...
2022/11/01
[ "https://Stackoverflow.com/questions/74272874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2689696/" ]
74,272,885
<p>I am trying validate phone number. The expected valid phone numbers are +1 1234567890 , +123 1234567890, +1 1234534 etc. No brackets and white space after the country code. I wrote regex something like below. But not working as expected. Any help would be appreciated.</p> <pre><code>public class ValidatePhoneNumbers { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub checkNumber(&quot;+5555555555&quot;);// not a valid checkNumber(&quot;+123 1234567890&quot;);//should be valid checkNumber(&quot;+1 1234567890&quot;);//should be valid checkNumber(&quot;+1 12345678905555&quot;);//should not be valid } protected static void checkNumber(String number) { System.out.println(number + &quot; : &quot; + ( Pattern.matches(&quot;\\+\\d{1,3}[ ] [0-9]{1,10}$&quot;, number) ? &quot;valid&quot; : &quot;invalid&quot; ) ); } } </code></pre>
[ { "answer_id": 74273042, "author": "Anubhav Sharma", "author_id": 13719128, "author_profile": "https://Stackoverflow.com/users/13719128", "pm_score": 1, "selected": false, "text": "public static void main(String[] args) {\n // TODO Auto-generated method stub\n \n ...
2022/11/01
[ "https://Stackoverflow.com/questions/74272885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5178586/" ]
74,272,887
<p>search from url</p> <p>if a normal search can be done like this</p> <p><a href="http://www.google.com/search?q=search_here" rel="nofollow noreferrer">www.google.com/search?q=search_here</a></p> <p>how do i search here !? search from url with picture url in google lens</p> <p><a href="https://i.stack.imgur.com/29WoY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/29WoY.png" alt="search from url with picture url in google lens" /></a></p> <p>enable search with image url, from the url in the same place that appears in the image</p> <p><a href="https://i.stack.imgur.com/lg3h3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lg3h3.png" alt="search from url with picture url" /></a></p> <p>help me pls... TnT</p>
[ { "answer_id": 74340935, "author": "user9372816", "author_id": 9372816, "author_profile": "https://Stackoverflow.com/users/9372816", "pm_score": 1, "selected": false, "text": "https://lens.google.com/uploadbyurl?url=<image_url>\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74272887", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20385742/" ]
74,272,925
<p>I want to get my contacts from my phone and save them into firebase. The following code works if all I wanted to do is save the contact name, mainly because the name cannot be empty in the phone but a problem arises when the nested value contact.phones is null or empty (shown below as &quot;//works if I remove this&quot;).</p> <p>Currently, if the phone field is empty, it throws a &quot;StateError (Bad state: No element)&quot; error.</p> <p>Also, note that contacts.phone (result.phones after the attempt to remove the elements) is a list so I need to grab the first one.</p> <p>I have tried to remove those elements from the list but that also sufferers from the same problem, the code to remove the empty phone fields fails for the same reason on this line.</p> <pre><code>if (![&quot;&quot;, null, false, 0].contains(contact.phones?.first)) </code></pre> <p>What is the correct way to remove elements from a list where the nested element is null or empty?</p> <pre><code> import '../../backend/backend.dart'; import '../../flutter_flow/flutter_flow_theme.dart'; import '../../flutter_flow/flutter_flow_util.dart'; import 'index.dart'; // Imports other custom actions import 'package:flutter/material.dart'; import 'package:contacts_service/contacts_service.dart'; Future syncContactstoFirebase(String? userID) async { List&lt;Contact&gt; contacts = await ContactsService.getContacts(); List result = []; for (var contact in contacts) { if (![&quot;&quot;, null, false, 0].contains(contact.phones?.first)) { result.add(contact); } } final instance = FirebaseFirestore.instance; CollectionReference collection = instance.collection('users').doc(userID).collection('contacts'); late Map&lt;String, dynamic&gt; data; if (result != null) data = { 'contacts': contacts .map((k) =&gt; { 'name ': k.displayName, 'phone': k.phones?.first.value //works if I remove this .toString() .replaceAll(new RegExp(r&quot;\s\b|\b\s&quot;), &quot;&quot;) .replaceAll(new RegExp(r'[^\w\s]+'), '') }) .toList(), }; return collection .doc() .set(data) .then((value) =&gt; print(&quot;Contacts Updated&quot;)) .catchError((error) =&gt; print(&quot;Failed to update Contacts: $error&quot;)); } </code></pre> <p>EDIT: See note below.</p> <p>Is there a way to handle more than one nested element so for instance the mapping code becomes:-</p> <pre><code> if (result != null) data = { 'contacts': contacts .map((k) =&gt; { 'name ': k.displayName, 'phone': k.phones?.first.value, 'email': k.email?.value ///////ADDED THIS//////// .toString() .replaceAll(new RegExp(r&quot;\s\b|\b\s&quot;), &quot;&quot;) .replaceAll(new RegExp(r'[^\w\s]+'), '') }) .toList(), }; </code></pre>
[ { "answer_id": 74340935, "author": "user9372816", "author_id": 9372816, "author_profile": "https://Stackoverflow.com/users/9372816", "pm_score": 1, "selected": false, "text": "https://lens.google.com/uploadbyurl?url=<image_url>\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74272925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2818170/" ]
74,272,931
<pre><code>#include&lt;stdio.h&gt; #include&lt;conio.h&gt; int main() { int Dividend,divisor; printf(&quot;Checking Divisiblity of 1st number with 2nd number \n\n&quot;) ; printf(&quot;Enter Number \n&quot;) ; scanf(&quot;%d&quot;,&amp;Dividend); printf(&quot;Enter Divisor = &quot;); scanf(&quot;%d&quot;,&amp;divisor) ; if(Dividend % divisor == 0) { printf(&quot;Number %d is divisible by %d&quot;,Dividend,divisor) ; } else { printf(&quot;Number %d is not divisible by %d&quot;,Dividend,divisor) ; } getch(); return 0; } </code></pre> <p>Above is my code that i have written in C ;</p> <p>on running this program . Only on first execution of scanf function if i give two input space seperated , the second input is going on right variable . and on hitting enter i am getting result . I am not understanding how is this happing .</p>
[ { "answer_id": 74272983, "author": "Igor", "author_id": 17005821, "author_profile": "https://Stackoverflow.com/users/17005821", "pm_score": 1, "selected": false, "text": "scanf" }, { "answer_id": 74272990, "author": "hyde", "author_id": 1717300, "author_profile": "htt...
2022/11/01
[ "https://Stackoverflow.com/questions/74272931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19859895/" ]
74,272,949
<p>example image data :<a href="https://i.stack.imgur.com/UGpQd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UGpQd.png" alt=" []" /></a></p> <p>when the js responds, the data has already been ordered by example image response js :<a href="https://i.stack.imgur.com/GMnKJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GMnKJ.png" alt=" []" /></a></p> <p>example controller and query :</p> <pre><code>$query = Verifikasi_tte::join('surat_ttes', 'surat_ttes.id', '=', 'verifikasi_ttes.surat_tte_id') -&gt;join('users', 'users.id', '=', 'surat_ttes.user_id') -&gt;join('jenis_surat_ttes', 'jenis_surat_ttes.id', '=', 'surat_ttes.jenis_surat_tte_id') -&gt;select('surat_ttes.id','surat_ttes.klasifikasi','surat_ttes.no_surat','surat_ttes.tgl_surat','surat_ttes.created_at', 'jenis_surat_ttes.nama_jenis_surat','users.name','verifikasi_ttes.surat_tte_id','verifikasi_ttes.status') -&gt;orderBy('surat_ttes.id','DESC')-&gt;get(); return Datatables::of($query) </code></pre> <p>example view in ajax datables :</p> <pre><code>&lt;script type=&quot;text/javascript&quot;&gt; $(function (e) { $('#data-table').DataTable({ pageLength: 10, processing: true, serverSide: true, stateSave: true, ajax: &quot;{{ url ('/verifikasi/data') }}&quot;, columns: [ {data: 'name', name: 'name'}, {data: 'nama_jenis_surat', name: 'nama_jenis_surat'}, {data: 'no_surat', name: 'no_surat'}, {data: 'dates', name: 'dates'}, {data: 'status', name: 'status'}, {data: 'action', name: 'action', orderable: false, searchable: false} ] }); }); &lt;/script&gt; </code></pre> <p>is there something wrong with my controller?</p>
[ { "answer_id": 74272983, "author": "Igor", "author_id": 17005821, "author_profile": "https://Stackoverflow.com/users/17005821", "pm_score": 1, "selected": false, "text": "scanf" }, { "answer_id": 74272990, "author": "hyde", "author_id": 1717300, "author_profile": "htt...
2022/11/01
[ "https://Stackoverflow.com/questions/74272949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9679203/" ]
74,272,954
<p>here is the logic, to get the data from the internet , when loading is not complete show a <code>progressbar</code> widget and when the loading is complete show the complete widget tree with text fields, pictures etc</p> <p>firstly in the <code>mainscreen</code> i check if the data is downloaded form firebase</p> <pre><code>Future&lt;void&gt; getCurrentDriverInfo() async { // doublenotification++; currentFirebaseUser = FirebaseAuth.instance.currentUser!; await driversRef .child(currentFirebaseUser!.uid) .once() .then((DatabaseEvent databaseEvent) { if (databaseEvent.snapshot.value != null) { driversInformation = Drivers.fromSnapshot(databaseEvent.snapshot); } }); ScaffoldMessenger.of(context) .showSnackBar(SnackBar(content: Text(&quot;Driver detail downloaded&quot;))); Provider.of&lt;AppData&gt;(context, listen: false).getDriverDetailsDownload(true); } </code></pre> <p>This is the provider class</p> <pre><code>class AppData extends ChangeNotifier { bool driverDetaildownloaded = false; void getDriverDetailsDownload(bool driverDetaildownload) { driverDetaildownloaded = driverDetaildownload; print(&quot;Driverdownload&quot; + driverDetaildownload.toString()); notifyListeners(); } </code></pre> <p>Now inthis cass i want to check if the data is not downloaded then show just the progress bar and when the data is downloaded close the progress bar and show the widget tree</p> <pre><code>class ProfileTabPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.black87, body: SafeArea( child: Provider.of&lt;AppData&gt;(context, listen: false) .driverDetaildownloaded ? Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( driversInformation!.name!, style: TextStyle( fontSize: 65.0, color: Colors.white, fontWeight: FontWeight.bold, fontFamily: 'Signatra', ), ), ] ) : Center(child: CircularProgressIndicator()), ), ); } } </code></pre> <p>However the <code>CircularProgressIndicator()</code> doesn't close and load the widgets. whats wrong ?</p>
[ { "answer_id": 74272983, "author": "Igor", "author_id": 17005821, "author_profile": "https://Stackoverflow.com/users/17005821", "pm_score": 1, "selected": false, "text": "scanf" }, { "answer_id": 74272990, "author": "hyde", "author_id": 1717300, "author_profile": "htt...
2022/11/01
[ "https://Stackoverflow.com/questions/74272954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17523373/" ]
74,272,973
<p>I have align-items: stretch flexbox and inside this flexbox I have image and some text content. text content is static and I need height of img to be as same as height of text content. When I use different imgs with different aspect ratio I see different height on each img but I want the height of all images to be same. *Please test snippet in fullscreen mode to see the problem</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>.card { display: flex; flex-direction: row; align-items: stretch; box-shadow: 0 0 20px 0px rgba(0, 0, 0, 0.1); margin: 20px; } .title { align-items: center; display: flex; flex-wrap: wrap; font-size: 1.25rem; font-weight: 700; letter-spacing: 0.0125em; line-height: 1.93rem; word-break: break-all; } .title img { object-fit: cover; width: 150px; height: 100%; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="card"&gt; &lt;div class="title"&gt; &lt;img src="https://s3-alpha-sig.figma.com/img/b579/835c/2b73668d5d42b127f5ed4e206c9c6576?Expires=1668384000&amp;Signature=DoZ8O~AWDj6UhiZgP-5njh0zCqIk0ahZTAqvBVDjvyibc0seggNTv9lBjN-Xhkr6g0oiPnKyfGrqyhzfuPYN-S0T132EdQjEp1LH8FpNHmgBm1SyYVoxMQhnyCcsAF762M6~7lQ5SBqsujpbdmxwee6MChnRRrp706gkHXUYml3Mjd3kR7EsqViVjm39GTyW9DEPIer-qFBTQkILSGrkKjM-9zTitycyzO6c9no0PpclhAqpeeta0sz1JxmsSz7tVHQI9CoDLXWc0epbY7zcnhPqOKYqGkGf2~IS0S46x01CSvTDYIWj0dTt-vma4nOavEWShJhKBXwyjyk5VbQoHQ__&amp;Key-Pair-Id=APKAINTVSUGEWH5XD5UA" alt="alt" /&gt; &lt;/div&gt; &lt;div class="content"&gt; &lt;p class="text-caption grey3--text"&gt;2day ago&lt;/p&gt; &lt;p class="text-subtitle-1 grey5--text font-weight-medium"&gt;some title&lt;/p&gt; &lt;p class="ellipsis"&gt; Lorem ipsum dolor sit amet consectetur adipisicing elit. Id beatae quia fugiat, minima eos fuga amet tenetur neque officia optio nulla voluptatem ducimus dolores, cum animi tempore veritatis libero repellat. Lorem ipsum dolor sit amet consectetur adipisicing elit. Id beatae quia fugiat, minima eos fuga amet tenetur neque officia optio &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="card"&gt; &lt;div class="title"&gt; &lt;img src="https://s3-alpha-sig.figma.com/img/bb5a/75f4/c083c0a5a79974bd94152c99b0f0d213?Expires=1668384000&amp;Signature=Um5O0ddvXIROx5txgjSCEF1HcQVv2n6PVHdV81zu1KfaqIZUQw3qZDDgdBAjpnSPJ35-taxYHPLFlhV~tIPoxtJMlXFbJpihC6XIKaiyBUyuXJEicoLCm9fKm5UwbbFLJRU63MSHEDJWVYh8sTxAFaAEwNX~XoVgkfgN0c6ozOdImLOc0G8Hs3WYnDiURZ8jglC25XJRb9uPj7hiiL6tdCOWinA2F9uyLGtSxKHi~RU6ESMKgWOGpavQdeJ5M~iIRpkge2Ka2ySerfZh4184XLTxO8EUG-cin-lW7ncGcjiqLtDIXyt2PyQptpTIENAPMH7dSn1TvvpzjFbadavvnQ__&amp;Key-Pair-Id=APKAINTVSUGEWH5XD5UA" alt="alt" /&gt; &lt;/div&gt; &lt;div class="content"&gt; &lt;p class="text-caption grey3--text"&gt;2day ago&lt;/p&gt; &lt;p class="text-subtitle-1 grey5--text font-weight-medium"&gt;some title&lt;/p&gt; &lt;p class="ellipsis"&gt; Lorem ipsum dolor sit amet consectetur adipisicing elit. Id beatae quia fugiat, minima eos fuga amet tenetur neque officia optio nulla voluptatem ducimus dolores, cum animi tempore veritatis libero repellat. Lorem ipsum dolor sit amet consectetur adipisicing elit. Id beatae quia fugiat, minima eos fuga amet tenetur neque officia optio &lt;/p&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74272983, "author": "Igor", "author_id": 17005821, "author_profile": "https://Stackoverflow.com/users/17005821", "pm_score": 1, "selected": false, "text": "scanf" }, { "answer_id": 74272990, "author": "hyde", "author_id": 1717300, "author_profile": "htt...
2022/11/01
[ "https://Stackoverflow.com/questions/74272973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6426012/" ]
74,272,979
<p>Would it be possible to array the following conditions?</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Column A</th> <th>Column BI</th> <th>Column BK</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>10</td> <td>20</td> </tr> <tr> <td>1</td> <td>10</td> <td></td> </tr> <tr> <td>2</td> <td>100</td> <td>20</td> </tr> <tr> <td>2</td> <td>-30</td> <td></td> </tr> <tr> <td>2</td> <td>-50</td> <td></td> </tr> </tbody> </table> </div> <p>I previosly asked for the formula to sum if the value in column A are the same, which I got it but I still need to drag it down on every rows.</p> <p><code>=IF(A2=A1,&quot;&quot;,SUMIFS(B$2:B$12,A$2:A$12,A2)) </code></p> <p>Which the results will appear as I wanted:</p> <pre><code>ID Value Sum 1 5 15 1 10 blank 2 5 30 2 10 blank 2 15 blank 3 10 35 3 10 blank 3 15 blank </code></pre> <p>I also, got the solution where for the array:</p> <pre><code>=arrayformula(if(len(A2:A),ifna(vlookup(row(A2:A),query({row(A2:B),A2:B},&quot;select min(Col1),sum(Col3) where Col2 is not null group by Col2&quot;),2,false)),)) </code></pre> <p>But it only seems to work if I only have 2 columns of data (A and B), but my data is far apart. I tried to adjust the formula, but it doesn't seems to work correctly.</p>
[ { "answer_id": 74272983, "author": "Igor", "author_id": 17005821, "author_profile": "https://Stackoverflow.com/users/17005821", "pm_score": 1, "selected": false, "text": "scanf" }, { "answer_id": 74272990, "author": "hyde", "author_id": 1717300, "author_profile": "htt...
2022/11/01
[ "https://Stackoverflow.com/questions/74272979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18610085/" ]
74,273,003
<p>I have two json file, One is Courses and another one is instructor. Courses and instructor are matched with _id. Now what I want is when an instructor details is send, all courses of that particular instructor is also send in the response. How may I suppose to do that?</p> <p>Instructor JSON data</p> <pre><code>let instructorData = [ { _id: 1, name: &quot;superman&quot;, courses: [1,3], },{ _id: 2, name: &quot;batman&quot;, courses: [2], } ]; module.exports = { instructorData: instructorData, }; </code></pre> <p>Courses JSON data</p> <pre><code>let coursesData = [ { _id: 1, name: &quot;DC&quot;, instructor: { _id:1 }, },{ _id: 2, name: &quot;Marvel&quot;, instructor: { _id:2 }, },{ _id: 3, name: &quot;DC vs Marvel&quot;, instructor: { _id:1 }, }, ]; module.exports = { coursesData: coursesData, }; </code></pre> <p>for Instructor 1 here I have 2 courses. How may I find/iterate the 2 courses?</p> <p>For example when I am getting an instructor I want it like:</p> <pre><code>{ name: &quot;superman&quot;, courses: [{name: &quot;DC&quot;},{name: &quot;DC vs Marvel&quot;}] } </code></pre>
[ { "answer_id": 74272983, "author": "Igor", "author_id": 17005821, "author_profile": "https://Stackoverflow.com/users/17005821", "pm_score": 1, "selected": false, "text": "scanf" }, { "answer_id": 74272990, "author": "hyde", "author_id": 1717300, "author_profile": "htt...
2022/11/01
[ "https://Stackoverflow.com/questions/74273003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17818994/" ]
74,273,015
<p>My question arose when implementing some sorts of graph visualization with JavaFX. There are 2 classes called <code>Vertex</code> and <code>Edge</code>, with each edge connecting 2 (possibly the same) vertices. Every vertex that has self-loops (edges having the same start and end vertices) stores a <code>DoubleProperty</code> for the preferred angle of its self-loops. This angle is computed from the the positions of this vertex and all its neighbors. However, as the graph is constructed dynamically, neighbors of a vertex may change, resulting in a dynamic list of dependencies, so I have to modify the dependendies of the <code>DoubleBinding</code> to which the angle is bound.</p> <p>However, the <code>getDependencies</code> method in the <code>DoubleBinding</code> created by <code>Bindings.createDoubleBinding</code> only returns an immutable copy:</p> <pre class="lang-java prettyprint-override"><code>@Override public ObservableList&lt;?&gt; getDependencies() { return ((dependencies == null) || (dependencies.length == 0))? FXCollections.emptyObservableList() : (dependencies.length == 1)? FXCollections.singletonObservableList(dependencies[0]) : new ImmutableObservableList&lt;Observable&gt;(dependencies); } </code></pre> <p>And although the <code>DoubleBinding</code> class has an <code>bind</code> method that seems to satisfy my need, it is protected:</p> <pre class="lang-java prettyprint-override"><code>protected final void bind(Observable... dependencies) { if ((dependencies != null) &amp;&amp; (dependencies.length &gt; 0)) { if (observer == null) { observer = new BindingHelperObserver(this); } for (final Observable dep : dependencies) { dep.addListener(observer); } } } </code></pre> <p>So is there any way that I can modify the dependencies at any time without defining my own <code>DoubleBinding</code>, or can I solve my problem without touching the dependencies?</p>
[ { "answer_id": 74273392, "author": "Joel", "author_id": 20346502, "author_profile": "https://Stackoverflow.com/users/20346502", "pm_score": 0, "selected": false, "text": "class MuatableDependenciesDoubleBinding extends DoubleBinding {\n\n private Callable<Double> func;\n private Observ...
2022/11/01
[ "https://Stackoverflow.com/questions/74273015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14393370/" ]
74,273,023
<p>So I am using default django authentication where its taking username and a password for signup. And I have 5 users registered right now.</p> <p>Now I need 2 features in my user model</p> <ul> <li>Facebook/gmail login</li> <li>Email verification</li> </ul> <p>The problem is I dont wanna loose my existing users and their records. The tutorials and methods I can find on internet all starts from scratch. Any idea how can I approach this?</p> <p>in my views.py</p> <pre><code>from django.shortcuts import render from django.views import generic from django.contrib.auth.forms import UserCreationForm from django.urls import reverse_lazy class UserRegistrationView(generic.CreateView): form_class = UserCreationForm template_name = 'registration/registration.html' success_url = reverse_lazy('login') </code></pre> <p>urls.py</p> <pre><code>from django.urls import path from .views import UserRegistrationView urlpatterns = [ path('register/',UserRegistrationView.as_view(),name='register'), ] </code></pre>
[ { "answer_id": 74273392, "author": "Joel", "author_id": 20346502, "author_profile": "https://Stackoverflow.com/users/20346502", "pm_score": 0, "selected": false, "text": "class MuatableDependenciesDoubleBinding extends DoubleBinding {\n\n private Callable<Double> func;\n private Observ...
2022/11/01
[ "https://Stackoverflow.com/questions/74273023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19618883/" ]
74,273,029
<p>I'm running a Unit test In my application's Controller and I'm getting a NullPointerException. Here are the details.</p> <p>The Controller:</p> <pre><code>@RestController @CrossOrigin @RequestMapping(&quot;/api/users&quot;) public class UserMigrationController { UserService userService; @Value(&quot;${SOURCE_DNS}&quot;) private String sourceDns; @Autowired public UserMigrationController(UserRepository userRepository, DocumentRepository documentRepository) { userService = new UserService(userRepository, documentRepository); } @GetMapping(value = &quot;/getUsers&quot;, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity&lt;List&lt;UserData&gt;&gt; getUsersForList() throws Exception { List&lt;UsersData&gt; usersDataList = UserService.getUsersForList(); return new ResponseEntity&lt;&gt;(usersDataList, HttpStatus.OK); } } </code></pre> <p>The UserData is just a simple</p> <pre><code>public record UserData(String id, String name) { } </code></pre> <p>And here is my test class:</p> <pre><code>@AutoConfigureMockMvc class UserMigrationControllerTest { @Autowired private MockMvc mockMvc; @MockBean private UserService userService; @BeforeEach void setup() { MockitoAnnotations.openMocks(this); } @Test void should_get_users_for_list() throws Exception { String id = &quot;id&quot;; String name = &quot;name&quot;; UserData userData = new UserData(id, name); List&lt;UserData&gt; response = new ArrayList&lt;&gt;(); response.add(userData); when(userService.getUsersForList()) .thenReturn(response); mockMvc.perform( MockMvcRequestBuilders.get(&quot;/api/users/getUsers&quot;) .contentType(MediaType.APPLICATION_JSON) .accept(&quot;application/json&quot;)) .andExpect(MockMvcResultMatchers.status().isOk()); } </code></pre> <p>As I can see, all annotations are in the right place. But when I run a test, I get NullPointerException like this:</p> <pre><code>Cannot invoke &quot;com.package.usersapi.service.UserService.getUsersForList()&quot; because &quot;this.userService&quot; is null </code></pre>
[ { "answer_id": 74273392, "author": "Joel", "author_id": 20346502, "author_profile": "https://Stackoverflow.com/users/20346502", "pm_score": 0, "selected": false, "text": "class MuatableDependenciesDoubleBinding extends DoubleBinding {\n\n private Callable<Double> func;\n private Observ...
2022/11/01
[ "https://Stackoverflow.com/questions/74273029", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18170566/" ]
74,273,046
<p>I have a file named 1.txt and it contains below 3 URLs, each of them following a http link, which I want to change them using sed command. The link could be regard as a string without space.</p> <pre><code> URL1: https://i.stack.imgur.com/Zw5ZK.png URL2: https://i.stack.imgur.com/cT8Pv.png URL3: https://i.stack.imgur.com/L3Syn.png </code></pre> <p>My purpose is to use something like below to replce those 3 links from command line, like:</p> <pre><code>sed **** 1.txt https://abc/1.png https://abc/2.png https://abc/3.png </code></pre> <p>After the command executes, the new content of 1.txt would be:</p> <pre><code> URL1: https://abc/1.png URL2: https://abc/2.png URL3: https://abc/3.png </code></pre>
[ { "answer_id": 74273392, "author": "Joel", "author_id": 20346502, "author_profile": "https://Stackoverflow.com/users/20346502", "pm_score": 0, "selected": false, "text": "class MuatableDependenciesDoubleBinding extends DoubleBinding {\n\n private Callable<Double> func;\n private Observ...
2022/11/01
[ "https://Stackoverflow.com/questions/74273046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1319802/" ]
74,273,082
<p>I have products two types: simple and configurable:</p> <pre><code>&quot;products&quot; : [ { &quot;type&quot;: &quot;simple&quot;, &quot;id&quot;: 1, &quot;sku&quot;: &quot;s1&quot;, &quot;title&quot;: &quot;Product 1&quot;, &quot;regular_price&quot;: { &quot;currency&quot;: &quot;USD&quot;, &quot;value&quot;: 27.12 }, &quot;image&quot;: &quot;/images/1.png&quot;, &quot;brand&quot;: 9 }, { &quot;type&quot;: &quot;configurable&quot;, &quot;id&quot;: 2, &quot;sku&quot;: &quot;c1&quot;, &quot;title&quot;: &quot;Product 2&quot;, &quot;regular_price&quot;: { &quot;currency&quot;: &quot;USD&quot;, &quot;value&quot;: 54.21 }, &quot;image&quot;: &quot;/images/conf/default.png&quot;, &quot;configurable_options&quot;: [ { &quot;attribute_id&quot;: 93, &quot;attribute_code&quot;: &quot;color&quot;, &quot;label&quot;: &quot;Color&quot;, &quot;values&quot;: [ { &quot;label&quot;: &quot;Red&quot;, &quot;value_index&quot;: 931, &quot;value&quot;: &quot;#ff0000&quot; }, { &quot;label&quot;: &quot;Blue&quot;, &quot;value_index&quot;: 932, &quot;value&quot;: &quot;#0000ff&quot; }, { &quot;label&quot;: &quot;Black&quot;, &quot;value_index&quot;: 933, &quot;value&quot;: &quot;#000&quot; } ] }, { &quot;attribute_code&quot;: &quot;size&quot;, &quot;attribute_id&quot;: 144, &quot;position&quot;: 0, &quot;id&quot;: 2, &quot;label&quot;: &quot;Size&quot;, &quot;values&quot;: [ { &quot;label&quot;: &quot;M&quot;, &quot;value_index&quot;: 1441, &quot;value&quot;: 1 }, { &quot;label&quot;: &quot;L&quot;, &quot;value_index&quot;: 1442, &quot;value&quot;: 2 } ] } ], &quot;variants&quot;: [ { &quot;attributes&quot;: [ { &quot;code&quot;: &quot;color&quot;, &quot;value_index&quot;: 931 }, { &quot;code&quot;: &quot;size&quot;, &quot;value_index&quot;: 1441 } ], &quot;product&quot;: { &quot;id&quot;: 2001, &quot;sku&quot;: &quot;c1-red-m&quot;, &quot;image&quot;: &quot;/image/conf/red.png&quot; } }, { &quot;attributes&quot;: [ { &quot;code&quot;: &quot;color&quot;, &quot;value_index&quot;: 931 }, { &quot;code&quot;: &quot;size&quot;, &quot;value_index&quot;: 1442 } ], &quot;product&quot;: { &quot;id&quot;: 2002, &quot;sku&quot;: &quot;c1-red-l&quot;, &quot;image&quot;: &quot;/image/conf/red.png&quot; } }, { &quot;attributes&quot;: [ { &quot;code&quot;: &quot;color&quot;, &quot;value_index&quot;: 932 }, { &quot;code&quot;: &quot;size&quot;, &quot;value_index&quot;: 1441 } ], &quot;product&quot;: { &quot;id&quot;: 2003, &quot;sku&quot;: &quot;c1-blue-m&quot;, &quot;image&quot;: &quot;/image/conf/blue.png&quot; } }, { &quot;attributes&quot;: [ { &quot;code&quot;: &quot;color&quot;, &quot;value_index&quot;: 933 }, { &quot;code&quot;: &quot;size&quot;, &quot;value_index&quot;: 1442 } ], &quot;product&quot;: { &quot;id&quot;: 2004, &quot;sku&quot;: &quot;c1-black-l&quot;, &quot;image&quot;: &quot;/image/conf/black.png&quot; } } ], &quot;brand&quot;: 1 } ] </code></pre> <p>The above data I get with <strong>actions (Vuex)</strong></p> <pre><code>GET_PRODUCTS_FROM_API({ commit }) { return axios('http://localhost:8080/products', { method: 'GET', }) .then((products) =&gt; { commit('SET_PRODUCTS_TO_STATE', products.data); return products; }) .catch((e) =&gt; { console.log(e); return e; }); } </code></pre> <p>then I <strong>mutate</strong> the data:</p> <pre><code>SET_PRODUCTS_TO_STATE: (state, products) =&gt; { state.products = products } </code></pre> <p>and get from in <strong>getters</strong></p> <pre><code>PRODUCTS(state) { return state.products = state.products.map((product) =&gt; { const brand = state.brands.find((b) =&gt; b.id === product.brand) return {...product, brandName: brand?.title || 'no brand'} }) } </code></pre> <p>after which i get the data in the component</p> <p>At the moment I'm stuck on how to render the color and size attributes of a configurable product. Tell me how to do it right? Do I need to write logic in vuex or parent component?</p> <p>I tried to push data from parent component to child. But it stopped there again. I also tried to separate the color and size attributes separately using getters.</p>
[ { "answer_id": 74273392, "author": "Joel", "author_id": 20346502, "author_profile": "https://Stackoverflow.com/users/20346502", "pm_score": 0, "selected": false, "text": "class MuatableDependenciesDoubleBinding extends DoubleBinding {\n\n private Callable<Double> func;\n private Observ...
2022/11/01
[ "https://Stackoverflow.com/questions/74273082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20299863/" ]
74,273,087
<p>I have a specific question about the usage of generics in Kotlin.</p> <p>I want to create a function which takes a generic <code>T</code> as an argument. It uses that to assign <code>name</code> from one of the classes: <code>Class1</code> or <code>Class2</code> to the local variable <code>testString</code>.</p> <p>Unfortunately this is only possible when I check the type of the argument with the if conditions.</p> <p>This leads to duplicate code. If I try to avoid that and use Line 12 I get this error during compile time: <code>Unresolved reference: name</code></p> <p>Is it possible in Kotlin to avoid the if conditions and use the testString assignment only once when the classes you are going to use have the same property with the same name?</p> <p>Code:</p> <pre><code>fun main() { val class1 = Class1(&quot;Foo1&quot;) val class2 = Class2(&quot;Foo2&quot;) } class Class1(val name: String) class Class2(val name: String) fun &lt;T&gt; doStuff(classOneOrTwo: T) { var testString: String testString = classOneOrTwo.name //not working: Unresolved reference: name if (classOneOrTwo is Class1) { testString = classOneOrTwo.name } if (classOneOrTwo is Class2) { testString = classOneOrTwo.name } } </code></pre>
[ { "answer_id": 74273344, "author": "z.y", "author_id": 19023745, "author_profile": "https://Stackoverflow.com/users/19023745", "pm_score": 2, "selected": false, "text": "Class1" }, { "answer_id": 74273351, "author": "Sweeper", "author_id": 5133585, "author_profile": "...
2022/11/01
[ "https://Stackoverflow.com/questions/74273087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8551103/" ]
74,273,109
<pre><code>import sys import numpy as np import pandas as pd sys.path.insert(0, sys.argv[2]) sys.path.insert(1, sys.argv[3]) from training import CustomerSegmentation class TestCustomerSegmentation: dataset = pd.read_csv( sys.path.pop(1), parse_dates=[&quot;InvoiceDate&quot;], ) </code></pre> <p>then by giving command line arguments:</p> <p><code>python3 -m pytest test_training.py &quot;customer-segmentation-v1&quot; &quot;customer-segmentation-v1/customer_data.csv&quot;</code></p> <p>it gives an error:</p> <p>ERROR: not found: /customer-segmentation-v1/customer_data.csv (no name '/customer-segmentation-v1/customer_data.csv' in any of [])</p> <p>I want my test class to read the csv data file that is present on the path given as command line argument.</p>
[ { "answer_id": 74273344, "author": "z.y", "author_id": 19023745, "author_profile": "https://Stackoverflow.com/users/19023745", "pm_score": 2, "selected": false, "text": "Class1" }, { "answer_id": 74273351, "author": "Sweeper", "author_id": 5133585, "author_profile": "...
2022/11/01
[ "https://Stackoverflow.com/questions/74273109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18230955/" ]
74,273,112
<p>I found in Python there are two ways to represent the dimension of a '1D' array, namely (p, ) and (p, 1), in which 'p' is number of elements in an array. How can I determine if an argument is the former case or the latter case? The following is an example:</p> <pre><code>import numpy as np x = np.array([1, 2, 3]) print(x.shape) # (3,) x2 = np.random.rand(3, 1) print(x2.shape) # (3, 1) </code></pre> <p>If I use 'shape[1] to detect whether the argument has the second dimension, there will be an error since the argument might be the first case. How can I determine the argument is the former case without having an error?</p>
[ { "answer_id": 74273344, "author": "z.y", "author_id": 19023745, "author_profile": "https://Stackoverflow.com/users/19023745", "pm_score": 2, "selected": false, "text": "Class1" }, { "answer_id": 74273351, "author": "Sweeper", "author_id": 5133585, "author_profile": "...
2022/11/01
[ "https://Stackoverflow.com/questions/74273112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8378256/" ]
74,273,190
<p>I need to run single java files independently in Intellij IDEA or vscode. Currently, when I run a single program both IDEs checks for other files.</p> <p>For example, in the given image, I need to run ReversingString program only, but it doesn't run it and asks me to correct error in other java files.</p> <p>How can I run a single file while ignoring other files. I checked answers to other similar questions here like editing run configuration but nothing is working.</p> <p>I want all files in this folder to be independent/separate from each other.</p> <p><a href="https://i.stack.imgur.com/3w6XF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3w6XF.png" alt="Error" /></a></p>
[ { "answer_id": 74273344, "author": "z.y", "author_id": 19023745, "author_profile": "https://Stackoverflow.com/users/19023745", "pm_score": 2, "selected": false, "text": "Class1" }, { "answer_id": 74273351, "author": "Sweeper", "author_id": 5133585, "author_profile": "...
2022/11/01
[ "https://Stackoverflow.com/questions/74273190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15932971/" ]
74,273,198
<p>This code block prints &quot;not contains&quot; and i don't know why, can somebody help me ?</p> <pre><code>private static final int[] YEARS = new int[] { 1881, 1893, 1900, 1910, 1919, 1923, 1930, 1932, 1934, 1938 }; public static void main(String[] args) { int year = 1919; System.out.println(YEARS); if (Arrays.asList(YEARS).contains(year)) { System.out.println(&quot;Contains&quot;); } else { System.out.println(&quot;Not contains&quot;); } // Write your code here below } </code></pre> <p>}</p>
[ { "answer_id": 74273344, "author": "z.y", "author_id": 19023745, "author_profile": "https://Stackoverflow.com/users/19023745", "pm_score": 2, "selected": false, "text": "Class1" }, { "answer_id": 74273351, "author": "Sweeper", "author_id": 5133585, "author_profile": "...
2022/11/01
[ "https://Stackoverflow.com/questions/74273198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6454302/" ]
74,273,215
<p>I need to know how do I execute line(s) of code after every callback function has ended.</p> <p>I'm using <a href="https://www.npmjs.com/package/rcon" rel="nofollow noreferrer">rcon</a> package to send a rcon command to a Half-Life Dedicated Server(HLDS) hosting Counter Strike 1.6 server and get the response back. Problem is sometimes the response is divided into parts(I think its due to connection with UDP, TCP doesn't work). First I used res.send() in conn.on() with event 'response' callback function but I got error saying can't send HTTP headers. I got to know about res.write(), it can save what I need and then use res.send() later. But I don't know where is the proper place in post I can use res.send() after all 'response' has come back. I tried using the command after conn.connect() and other places but it hasn't worked.</p> <pre><code>const express = require('express'); var Rcon = require('rcon'); const app = express(); const port = 3000; app.use(express.urlencoded({extended: true})); app.get(&quot;/&quot;, function(req,res){ res.sendFile(__dirname + &quot;/index.html&quot;); }); app.post(&quot;/&quot;, function(req, res) { var resp = &quot;&quot;; var ip = req.body.serverip; var pass = req.body.pass; var command = req.body.command; var options = { tcp: false, challenge: true }; var conn = new Rcon(ip, 27015, pass, options); conn.on('auth', function () { // You must wait until this event is fired before sending any commands, // otherwise those commands will fail. console.log(&quot;Authenticated&quot;); console.log(&quot;Sending command:&quot; + command); conn.send(command); }); res.setHeader(&quot;Content-Type&quot;, &quot;text/html; charset=UTF-8&quot;); res.write(&quot;&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;body&gt;&quot;) conn.on('response', function(str) { console.log(&quot;Response: &quot;+str); res.write(str); }); conn.on('error', function (err) { console.log(&quot;Error: &quot; + err); }); conn.on('end', function () { console.log(&quot;Connection closed&quot;); process.exit(); }); conn.connect(); res.end(&quot;Done&lt;/body&gt;&lt;/html&gt;&quot;); }); app.listen(port, function(){ console.log(&quot;Server is listening on port &quot; +port); }); }); </code></pre>
[ { "answer_id": 74273344, "author": "z.y", "author_id": 19023745, "author_profile": "https://Stackoverflow.com/users/19023745", "pm_score": 2, "selected": false, "text": "Class1" }, { "answer_id": 74273351, "author": "Sweeper", "author_id": 5133585, "author_profile": "...
2022/11/01
[ "https://Stackoverflow.com/questions/74273215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20385858/" ]
74,273,270
<p>I am new to Ansible and tried to formulate the following task:</p> <ul> <li>get a setup script via curl</li> <li>run it with sudo</li> <li>afterwards, install node.js with apt</li> </ul> <pre class="lang-yaml prettyprint-override"><code>- name: Install Node become: true command: &quot;curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash - &amp;&amp; sudo apt-get install -y nodejs&quot; tags: install_node </code></pre> <p>While the command can be run from the command line, it fails with the following error when I run it with Ansible - why is that?</p> <pre class="lang-none prettyprint-override"><code>TASK [Install Node] *********************************************** fatal: [ai-training]: FAILED! =&gt; {&quot;changed&quot;: true, &quot;cmd&quot;: [&quot;curl&quot;, &quot;-fsSL&quot;, &quot;https://deb.nodesource.com/setup_19.x&quot;, &quot;|&quot;, &quot;sudo&quot;, &quot;-E&quot;, &quot;bash&quot;, &quot;-&quot;, &quot;&amp;&amp;&quot;, &quot;sudo&quot;, &quot;apt-get&quot;, &quot;install&quot;, &quot;-y&quot;, &quot;nodejs&quot;], &quot;delta&quot;: &quot;0:00:00.012434&quot;, &quot;end&quot;: &quot;2022-11-01 08:24:51.941143&quot;, &quot;msg&quot;: &quot;non-zero return code&quot;, &quot;rc&quot;: 2, &quot;start&quot;: &quot;2022-11-01 08:24:51.928709&quot;, &quot;stderr&quot;: &quot;curl: option -: is unknown\ncurl: try 'curl --help' or 'curl --manual' for more information&quot;, &quot;stderr_lines&quot;: [&quot;curl: option -: is unknown&quot;, &quot;curl: try 'curl --help' or 'curl --manual' for more information&quot;], &quot;stdout&quot;: &quot;&quot;, &quot;stdout_lines&quot;: []} </code></pre> <p>Trying the alternative command with <code>wget</code> gives a similar error:</p> <pre class="lang-bash prettyprint-override"><code>wget -qO- https://deb.nodesource.com/setup_12.x \ | sudo -E bash - &amp;&amp; sudo apt-get install -y nodejs </code></pre> <pre class="lang-none prettyprint-override"><code>fatal: [ai-training]: FAILED! =&gt; {&quot;changed&quot;: true, &quot;cmd&quot;: [&quot;wget&quot;, &quot;-qO-&quot;, &quot;https://deb.nodesource.com/setup_12.x&quot;, &quot;|&quot;, &quot;sudo&quot;, &quot;-E&quot;, &quot;bash&quot;, &quot;-&quot;, &quot;&amp;&amp;&quot;, &quot;sudo&quot;, &quot;apt-get&quot;, &quot;install&quot;, &quot;-y&quot;, &quot;nodejs&quot;], &quot;delta&quot;: &quot;0:00:00.007153&quot;, &quot;end&quot;: &quot;2022-11-01 13:06:08.298278&quot;, &quot;msg&quot;: &quot;non-zero return code&quot;, &quot;rc&quot;: 2, &quot;start&quot;: &quot;2022-11-01 13:06:08.291125&quot;, &quot;stderr&quot;: &quot;wget: invalid option -- 'y'\nUsage: wget [OPTION]... [URL]...\n\nTry `wget --help' for more options.&quot;, &quot;stderr_lines&quot;: [&quot;wget: invalid option -- 'y'&quot;, &quot;Usage: wget [OPTION]... [URL]...&quot;, &quot;&quot;, &quot;Try `wget --help' for more options.&quot;], &quot;stdout&quot;: &quot;&quot;, &quot;stdout_lines&quot;: []} </code></pre>
[ { "answer_id": 74273344, "author": "z.y", "author_id": 19023745, "author_profile": "https://Stackoverflow.com/users/19023745", "pm_score": 2, "selected": false, "text": "Class1" }, { "answer_id": 74273351, "author": "Sweeper", "author_id": 5133585, "author_profile": "...
2022/11/01
[ "https://Stackoverflow.com/questions/74273270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/626537/" ]
74,273,324
<p>I have column in a df with a size range with different sizeformats.</p> <pre><code>artikelkleurnummer size 6725 0161810ZWA B080 6726 0161810ZWA B085 6727 0161810ZWA B090 6728 0161810ZWA B095 6729 0161810ZWA B100 </code></pre> <p>in the sizerange are also these other size formats like XS - XXL, 36-50 , 36/38 - 52/54, ONE, XS/S - XL/XXL, 363-545</p> <p>I have tried to get the prefix '0' out of all sizes with start with a letter in range (A:K). For exemple: Want to change B080 into B80. B100 stays B100.</p> <p>steps: 1 look for items in column ['size'] with first letter of string in range (A:K), 2 if True change second position in string into ''</p> <p>for range I use:</p> <pre><code>from string import ascii_letters def range_alpha(start_letter, end_letter): return ascii_letters[ascii_letters.index(start_letter):ascii_letters.index(end_letter) + 1] </code></pre> <p>then I've tried a for loop</p> <pre><code>for items in df['size']: if df.loc[df['size'].str[0] in range_alpha('A','K'): df.loc[df['size'].str[1] == '' </code></pre> <p>message</p> <pre><code>SyntaxError: unexpected EOF while parsing </code></pre> <p>what's wrong?</p>
[ { "answer_id": 74273564, "author": "backed by", "author_id": 15029097, "author_profile": "https://Stackoverflow.com/users/15029097", "pm_score": 0, "selected": false, "text": "sizes = [{\"size\": \"B080\"},{\"size\": \"B085\"},{\"size\": \"B090\"},{\"size\": \"B095\"},{\"size\": \"B100\"...
2022/11/01
[ "https://Stackoverflow.com/questions/74273324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18786453/" ]
74,273,359
<p>I have a txt file with the following content:</p> <pre><code>ID1;ID2;TIME;VALUE 1000;100;012021;12 1000;100;022021;4129 1000;100;032021;128 1000;100;042021;412 1000;100;052021;12818 1000;120;022021;4129 1000;100;062021;546 1000;100;072021;86 1000;120;052021;12818 1000;100;082021;754 1000;100;092021;2633 1000;100;102021;571 1000;120;092021;2633 1000;100;112021;2233 1000;100;122021;571 1000;120;012021;12 1000;120;032021;128 1000;120;042021;412 1000;120;062021;546 1000;120;072021;86 1000;120;082021;754 1000;120;102021;571 1000;120;112021;2233 1000;120;122021;571 1000;100;012022;12 1000;100;022022;4129 1000;120;022022;4129 1000;120;032022;128 1000;120;042022;412 1000;100;032022;128 1000;100;042022;412 1000;100;052022;12818 1000;100;062022;546 1000;100;072022;86 1000;100;082022;754 1000;120;072022;86 1000;120;082022;754 1000;120;092022;2633 1000;120;102022;571 1000;100;092022;2633 1000;100;102022;571 1000;100;112022;2233 1000;100;122022;571 1000;120;012022;12 1000;120;052022;12818 1000;120;062022;546 1000;120;112022;2233 1000;120;122022;571 </code></pre> <p>I need to make aggregates of time (half year, total year), using the items from column time, which have the same ID1, ID2 and sum up the values.</p> <p>The output should look like this: <a href="https://i.stack.imgur.com/xvG9z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xvG9z.png" alt="enter image description here" /></a></p> <p>I would appreciate your help! This is what I have so far for half year: #already sorted by time</p> <pre><code>data=open(&quot;file.txt&quot;).readlines() count = 0 for line in data: count += 1 for n in range(count - 1, len(data), 6): subList = [data[n:n + 6]] break </code></pre>
[ { "answer_id": 74274444, "author": "shunty", "author_id": 197962, "author_profile": "https://Stackoverflow.com/users/197962", "pm_score": 1, "selected": false, "text": " dd = defaultdict(lambda: [])\n rows = [elems for elems in [line.strip().split(';') for line in data[1:]]]\n f...
2022/11/01
[ "https://Stackoverflow.com/questions/74273359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15835454/" ]
74,273,367
<p>I tried to calculate age from datepicker but into that datepicker I added sharedpreference.And to calculate age I got &quot;dropdownValueBirthday&quot; equal to &quot; birthday&quot; .Then display null . How I fix this error? But birthday display nicely I want calculate age from birthday and should display age as duration.</p> <p>image</p> <p><a href="https://i.stack.imgur.com/sDmkX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sDmkX.png" alt="enter image description here" /></a></p> <p><strong>duration is still null</strong></p> <p>code</p> <pre><code> void initState() { super.initState(); dropdownValueBirthday = birthday.first; checkValueBirthday(); } //age String age = &quot;&quot;; DateDuration? duration; //date picker //date picker DateTime? selectedDate; DateTime now = new DateTime.now(); void showDatePicker() { DateTime mindate = DateTime(now.year - 2, now.month, now.day - 29); DateTime maxdate = DateTime(now.year - 1, now.month, now.day); showCupertinoModalPopup( context: context, builder: (BuildContext builder) { return Container( height: MediaQuery.of(context).copyWith().size.height * 0.25, color: Colors.white, child: CupertinoDatePicker( mode: CupertinoDatePickerMode.date, initialDateTime: mindate, onDateTimeChanged: (valueBirth) { if (valueBirth != selectedDate) { setState(() { selectedDate = valueBirth; dropdownValueBirthday = '${selectedDate?.year}/${selectedDate?.month}/${selectedDate?.day} '; calAge(); }); } }, maximumDate: maxdate, minimumDate: mindate, ), ); }); } void calAge() { DateTime birthday = DateTime.parse(dropdownValueBirthday!); setState(() { duration = AgeCalculator.age(birthday); }); // print('Your age is $duration'); } String? dropdownValueBirthday; List&lt;String&gt; birthday = [ 'Birthday', ]; checkValueBirthday() { _getDataBirthday(); } _saveDataBirthday(String dropdownValueBirthdayShared) async { SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); sharedPreferences.setString(&quot;dataBirthday&quot;, dropdownValueBirthdayShared); } _getDataBirthday() async { SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); dropdownValueBirthday = sharedPreferences.getString(&quot;dataBirthday&quot;) ?? birthday.first; setState(() {}); } </code></pre> <p>widget code</p> <pre><code> child: GestureDetector( onTap: (showDatePicker), child: SizedBox( width: 110.0, height: 25.0, child: DecoratedBox( decoration: BoxDecoration( borderRadius: BorderRadius.circular(12), color: Colors.white, ), child: Center( child: Text( selectedDate == null ? (dropdownValueBirthday ?? birthday.first) : '${selectedDate?.year}/${selectedDate?.month}/${selectedDate?.day} ', style: const TextStyle( fontSize: 16, fontWeight: FontWeight.w500), ), ), ), ), ), </code></pre> <p>print <a href="https://i.stack.imgur.com/VbzA7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VbzA7.png" alt="enter image description here" /></a></p> <p>new error <a href="https://i.stack.imgur.com/hMiAZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hMiAZ.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74273397, "author": "My Car", "author_id": 16124033, "author_profile": "https://Stackoverflow.com/users/16124033", "pm_score": 1, "selected": false, "text": " void initState() {\n super.initState();\n dropdownValueBirthday = birthday.first;\n checkValueBirthday()...
2022/11/01
[ "https://Stackoverflow.com/questions/74273367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20000775/" ]
74,273,410
<p>I am following rust tutorials online, and I found that some websites are using <code>cargo build</code> command while others are using <code>anchor build</code> command to build the project.</p> <p>What is the difference between these two commands?</p>
[ { "answer_id": 74333294, "author": "Yilmaz", "author_id": 10262805, "author_profile": "https://Stackoverflow.com/users/10262805", "pm_score": 2, "selected": true, "text": "Cargo" }, { "answer_id": 74394595, "author": "Jon C", "author_id": 16310679, "author_profile": "...
2022/11/01
[ "https://Stackoverflow.com/questions/74273410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16925281/" ]
74,273,417
<p>I have a list of sentences, I need to add new line character and save in text file as the following format. Note: I don't need new line character I want to keep in the given string format. I just want to keep \n and not get new line in text file list:['Hi','I am xyz'] String Format:'Hi\nI am xyz' If someone knows please let me know.</p>
[ { "answer_id": 74273888, "author": "LITzman", "author_id": 18877953, "author_profile": "https://Stackoverflow.com/users/18877953", "pm_score": 0, "selected": false, "text": "\\n" }, { "answer_id": 74274531, "author": "Maciej Gol", "author_id": 1338158, "author_profile...
2022/11/01
[ "https://Stackoverflow.com/questions/74273417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16982262/" ]
74,273,442
<p>I have 2 flat arrays which are Leaders and Members. These arrays are populated while incrementing ids.</p> <p>I would like to associate one leader id with a sequence of consecutive ids in the members array. If there are too many leaders and not enough consecutive sequences of members, relate the remaining leader to <code>null</code>.</p> <p>Example:</p> <pre><code>$leaders = [1,4,8,13]; $members = [2,3,5,6,7,9,10,11,12]; </code></pre> <p>This is the result I want</p> <pre><code>$leaders = [ 1 =&gt; [2,3], 4 =&gt; [5,6,7], 8 =&gt; [9,10,11,12], 13 =&gt; null ]; </code></pre>
[ { "answer_id": 74273888, "author": "LITzman", "author_id": 18877953, "author_profile": "https://Stackoverflow.com/users/18877953", "pm_score": 0, "selected": false, "text": "\\n" }, { "answer_id": 74274531, "author": "Maciej Gol", "author_id": 1338158, "author_profile...
2022/11/01
[ "https://Stackoverflow.com/questions/74273442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12135469/" ]
74,273,515
<p>In theory it should be as easy as :</p> <pre class="lang-js prettyprint-override"><code>//targetCanvas is a canvas node //app is instance of PIXI.Application targetCanvas.drawImage(app.view, 0, 0); </code></pre> <p>But, trust me, It doesn't work!</p> <p>Sometime (yes, I said sometime) it does work if I add some delay before copying the image into the <code>targetCanvas</code>. ... So, I wonder if there is an asynchronous process happening when PIXI is rendering... but I can not find this information in PIXI's documentation.</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>var loadImage = async function(imgPath) { return new Promise((resolve, reject) =&gt; { var img = document.createElement("img"); img.onload = ()=&gt; { resolve(img); } img.src = imgPath; }) } var canvasTag = document.querySelector("#canvasVideo"); var canvasCtx = canvasTag.getContext("2d"); var canvasResult = document.querySelector("#canvasResult"); var canvasResultCtx = canvasResult.getContext("2d"); var canvasWidth = canvasTag.width; var canvasHeight = canvasTag.height; var canvasWidth = 320; var canvasHeight = 240; const app = new PIXI.Application({ view: document.querySelector("#glCanvas"), transparent: true, width: canvasWidth, height: canvasHeight }); const container = new PIXI.Container(); const renderer = PIXI.autoDetectRenderer(); app.stage.addChild(container); (async ()=&gt; { var imgTag = await loadImage("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAA5FBMVEX71DP///8AAAAUFRgAABb/2DT/2jT/3DX70yn70h3/3TX70RX70iT70y0AABURExj710T96J/+8cb84oT20DL//ff844n/+ur+9NL++OMLDxj85I784Hj72lr+997//vr966383mz96aPXti6ZgibvyjH97ru6nioACRfDpSj+8sn+9NT72VAdHBlDOxzqxjFwYCEsKBpNQx07MgxfURNzYReMeCR9ayJfUh/83nEnIQiskSOBbRoRDgONdxzUsystJgk9NhwhHxmwlikvKhpzYiFHPA4dGAa+oCZSRhA0LAtCOA1YRGDzAAANp0lEQVR4nO2dWVvbuhaGlcFTbIUMzkASAxkhDE1LobsQIC3sckrP//8/R3EmD5IsWXKw6fkuekEfxXq9pLWWZA0gl7garXZtUu3W+06lYgMA7ErF6fea3cGk3Wok/3iQ5I+32oOmU7FMw7AsXYcQbAQh1HXLMkwDOPXB+WGSlUiKsFWr9qFpWF4urKCOQE2nW2slVJMkCFuTZgWZLQItwGkYdm+SBKV0wovupWnoPHQea5qVblt2heQS1no6n+0wttR7Nan+RyLheR1VT4BuI9Rge+fyqiWL8LArB28DqXePJNVMDmHNMeXhrSHNy4mUukkgbFV1Q6TvkQQNqyrBuQoTHtYNKwG8lSyjLswoSHjUl948/dLNnmDGI0R42DeTaJ5BxjshOwoQtnoJ22/HWBeIkLEJj7t74nMZjerxvgknMDn/gpMF48aOeISHl8Ze+ZYynHguJxZhdw8OJixodvdEeAH220B3ssDFPgib72LAleKYkZfwyH4vA65kVXgzck7CwTsacCVoDhIkbDj7d6FhGX2u2MhD2Nb3F+Np0rkcDgfhifneaBtB8yQJwl5qAJHMnnTCxuX7+tCgLIc1GWckPITp6II76ZAxbLARXiQyTSEmaLBNrTIR1tLUBXcymYYbLITpcaIBMblUBsLUAiLEqgzCFAMixOgULpJwkGZAFsQowpQDMvTFCMJJ2gGjPSqdMKVhwi+T/qGKStjOAiBCpGY3NMKjbAACaNEmxSmEjahFBqkRBJQxMYXwMm3JNlm6E4fwLl3DJbqsOj9hNQ1TMuwih0USYUbc6E4maSxFIGxkpw9upBMG/QRCJ4OEBG+DJ8xYJ1zJwCfhWMLMdcKV8LkNlhBkJdT7BfEwmL/VsxQJvbKabITn2WyjS+FCBoYwe250K1w7Df+pmdU2uhSmnYYIszJkIijsT0OEl9n0oxvByyjCkyzGeq+M4LRNgPA4w25mLXhMJexm2c2sZHVphC1xN6OoWqmkqcr+CgZltiiEPdFGqiqnv34Wrj59G3JWVVGH3z5dFX7+OgWqYB30OpnwUNCEivbyXCx2Dg46xfL1UOMoqQ2vy25B9O9cE7Sj34g+wr6YCZXxdbFTWKtTHrEbQx2VtwUPip/GYoj6HYlQMNgrs6tiwaPiZ1ZE9bOvYPlqJoboC/teQrFeqIwPOoWCH5GtoWp+wELh7ErMinofTyjoSLXrciGg4ogFURsVgwXPPvF04rDMQyxhXciEmHoixGG0LZQhriDTuyHK6053hC2hfE2ZFQ/CFT27ju6K2qezcMGDolhXtBoYwqpQOqP9wlgC2WIaVVFlii/I2IcJsqoYQkEThjrh2ohRFdWuMSZEKgsaMUw4ESJUn7CWiO6J2F7oFvwmlNsYtRChIzQuVL504lVUfSAQdp5F6gOgEyQUS9iIligcXNGbqXaFcVCrd7MQaqbbgLEh7AqFChUXKtYVpfYn5IKJBTmyPoz0boBQLCPVvuPdxbKiL1TCFyLh2XexqK/7CWtikxcaLhiuCR9opiB2w2VIFCM0zn2Egikpua0VOtR4oV0TPNTy3cxE6rTNa1aEx2ImJDsaRPgv1Yb/UggZUj6adC+hYCMl5CWrxtaxKSXtDrF5M+RDdK1DIpDQSIFySiEsjiklx+QOXCieCtqw5yEUnJ6heERUUTohpSDVCzNI3xG2BaeBU0poXGwJxcJ9RCstUwnLybXS9QDDJawIfqugehp6fvlMIRRL2zbfMJaEwvPA1Gjxs0Qpqf1MLlqspxWB8MDJFZnwjDqU1T4T071CUbhW7leaJaHYBM1SJXLgpifQlJS984VmfCbpzTWhaDdEFf2HPESgxm1KDy7+Izq9D2BlRSg2BbWqKNmZRrQ1m1xQ1JUiGS2XUDBlc0XMTaLGQMRxFz0XYtQycQOik2wRFY2yBDFZEB0eulpGRETYl/DlntSfDjqRRc/w1hfNu13Bvkso5bOvhp+Kip4xU79h303nWYIJ3dQUyPjuC0i+5qBIGzqtZGO7sAw/A9yYD4TT7rVU3MxucR7t8dU55t2wfA5gkXGOCE/kLE7AfbgoR854L4V5NweCM95bWQNE2JS0wEQNtdNOh+kzoDLuBPtw8UWOCZdZDRCc7PZIm/uHQh3W1Bkl7n7Esti3NY+ggwgl/RaS9uKtafGZuaWps+ei983MZQEu8zbQkLjMSxt+WTMelMs3NntXUuzv5XUD6BS/cK3iiJDVAHKCxVqK9nJddPVryDcyKA1/rQpen4ouNvHJbIELuUv1FG08/T0d2tzVVDR7iEqOpfIt52qAjLzbLwVpvwUpMmpAUjhMq6wJqGZ/vSVNVhWIziSmXHoXiE/SpFp6Hdxle113lOAdkJa0pVPQAZfvXYdkBS9B5b3rkLA+PmEFRE8zZFt/A+HHb6X/J8y6Kn9BPPzoOU0fyPhqkWLBHuh9bEK9+ReMDz/4GF+vfvh5mpME5tpSJaMGJH1cS6uMCyC6qzLlMlug8cH7YQNIWC+UYkE73vdD6XPvrM/lfrD7/ZB7wlSxGb7OJyF1yv3tW+8iwgFnR1TA17y8T5g8D57l87yI1gkiPOcLF0vAfH7xDlZU7tGDZ3wPNtrc62lWgPwvU1ylW/fBQy5Edz0N30J9ewWYv9+3u9HmqwfnuVYO69zr2tSH9XPyr/slVBebB1P3UQW0XtfGNX4abx6Uf9snojLcPPaRp9h6bSLXMm/1dIt4sz9vo+xe7JTnqcv9a9xrhEufd4jyP7vjpdj322dyxan1GmHOvM3eEuZf9+NulPEWkM+Hb9Z5c2Y16nSH+IdjVVBseSyY58um3C2IMfZbaKMd4n84I3AMqbMdIGfX3+634F0Wpb3tEPNT4V0RdKlDz8M4m8x2zwzvAEqxHz1PlbaOEKvSqfdt8plwt++Je++a4n2v+c/JuVSl5OkR+QfOd7nasB5v/6HX26AgvEjIjOrY2x++8j7Fs/+Qfw/pNktc6UnCIWRhlX77HsJ97pBnD2mMfcClB9/TfyykOxwV3Poewb1Xz7cPOMakqXrje37+diw3bvhcDNIp98/79nIfx5hwCyKiaCyvqWqzN/+Pj/jbiHUseqZCCPHHVBKjOn4I/PQTvy/zn6nAO5WxkhJ4z8jd/S6JM6pgFPzd2xjOenOll9DZJmoIMf9nqgr1R0W1Q3yxAMGGTOx8GiXYUJHu5/yLvLe/V5oF22dcwO1ZWBvCmEv2S5gKoSoNYxlSVaaYN8adyqwUOmMo7taZQOjfGvJpyHcUqaJqw6d73E89xYq04XOiYu+V1X7jquVCLoDGZkpVs6cPj/ifmcdLJTBnfcXeaOkb3gT0NhoCVaVk5oqC/ns4xzXOlaYxU149FyaMvR1YscMu1aPXh/nQLmnqktTdUKG4GysQmqaNZ6dPr5Syj3EH2NYAQyjwIVENO/hgVf97+zD/PZ0uhjN7NlxMp9OXp9uvUaXeYk+SGLhzE0WOVtAWUZWNo1HsFAl/9qXQhuCIlhpHIqNO70nC3jNoRY4RVlR82Igtns19Qene24LlnSOszsgekV+nIuNN7xG0Ms+CVoihkVu3tkhySz4LWvw8byXSqbJIdMLAZ0LpZ7KHRnbcenwRHGXSzmSXcb6CNruNpqBorojOhhgNCqGMuxEUDTcCYtRIqAO6sgJ3BAfvt5CxfAiNYufYYUKEvr4I3xqApNPvt5BxKtZSqrbgbawPQwkzINF3lMi7Z0ZBIyJ2yNupDPMB77iQSCjxriA0fFiMaEOHdeN8WijSJiL9kQJLKPe+JzR0txej2x8kupun6ViVOM8avIIFSyj9XjlkypIynM5HDzdvr1/vH/OPf17fbh5GL2jYKJMOCUIMTvhPidwN6A550ZjXJVK01YBY+lMY7137+HfnZff+QxsLg/vjRTbXfpsXzIQZvYe0imX5W++SzeB9wBDy3Qecvetkee90zuUG2UI08ZcB0whzvSxFRatH5CATZuk2S5KXiSBswKwgQnBMxqAQ5g4zEhWh0aJQ0Aizktvg7+NmIszVsoBIjBMshLlJ+hHNGh0hgjB3knZE8ySCIIow7YiRgNGE6UaMBmQgTDMiAyALYXrdjRmc/Y1LmNKgAc1zlsozEaKxVPoSOGhRAz0nYe4Ipm1IrANaqsZPmGtcpmswZTmUZDsWIRovpikPN+vRFeYmzFVT0xkhS5SIQZhrp6Qz6jo9145PmGs4aWiphkOYVZNAmIaWCslzTlIIc0eV9/WpFsBO3UskzOW672hGaOK+LskmzLXBe5nRsnkNGI/wvcwIzfAn7KQIc4f7d6rQdEKLEBIkRCMquN+maoGI6RjphLnjqrG/+K8Tvg0mSojif93cD6NuNrlivDTCXK51twdG3ewxjpMSIEQup5cwI+KL52BkESI71o3kfI5l1YXsJ4UQMVYtI4n4CA2rKtD/JBIiTRzpjVU3nbjxwS85hKhDdnWJ0QP9Vlew+20lixDpvGdIgdQNq8czxI2QREIUIWs99PZF+iRE5Xs11kkmJkklXKrdrJhWLEpEZ1a6MUYPdEknRGpN6rZhWDyU0DKMSnMiHBowSoJwqVat2jdMI9KaEOqWYer9ai0JuqWSInTVap80HYBAEakOPUs7EJduIbOZVsVpDs6TgnOVKOFKjVa7dtKt9/pOZSOnX+8OJucXLQkRPUr/A5yNC0f3lG+mAAAAAElFTkSuQmCC"); canvasCtx.drawImage(imgTag, 0, 0, canvasWidth, canvasHeight); var bgSprite = PIXI.Sprite.from(imgTag); app.stage.addChild(bgSprite); canvasResultCtx.drawImage(document.querySelector("#glCanvas"), 0, 0); })()</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt; &lt;script src="https://pixijs.download/release/pixi.js"&gt;&lt;/script&gt; &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"&gt;&lt;/script&gt; &lt;title&gt;Document&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;canvas id="canvasVideo" width="320" height="240" autoplay&gt;&lt;/canvas&gt; &lt;canvas id="glCanvas" width="320" height="240" autoplay&gt;&lt;/canvas&gt; &lt;canvas id="canvasResult" width="320" height="240" autoplay&gt;&lt;/canvas&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p> <p><code>canvasVideo</code> (left) is normal canvas with 2d context. <code>glCanvas</code> (middle) is a PIXI's view <code>canvasResult</code> (right) is a normal canvas where a PIXI view should be copied into.</p> <p>We don't have any problem copying canvas into PIXI. (except the CORS prevents the webGL renders the image correctly) But, as you can see, the third canvas is blank. I wonder if there is any solution to this issue... without using PIXI's ticker or setTimeout?</p>
[ { "answer_id": 74273859, "author": "Kokodoko", "author_id": 1083572, "author_profile": "https://Stackoverflow.com/users/1083572", "pm_score": 1, "selected": false, "text": "requestAnimationFrame" }, { "answer_id": 74274949, "author": "Eduardo Páez Rubio", "author_id": 288...
2022/11/01
[ "https://Stackoverflow.com/questions/74273515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9895070/" ]
74,273,529
<h2>Issue</h2> <p>I am experiencing a weird behaviour with a <code>UITextView</code> which is inside a <code>UIStackView</code> with a defined spacing of <code>0</code>. The <code>UITextView</code> is used to display a message inside a chat bubble. When the message is only one line, the <code>UITextView</code> expands and adds a bottom spacing/padding of about <code>2.3 px</code>. Looking at the view hierarchy, the text itself is a <code>_UITextLayoutFragmentView</code> which is inside a <code>_UITextLayoutCanvasView</code>. It appears that this canvas view is drawn too big, causing the spacing.</p> <p>The following images are from the view hierarchy with a one line message where the issue appears and from a message with two lines, where the issue is not appearing: <a href="https://imgur.com/a/nvrNYZM" rel="nofollow noreferrer">https://imgur.com/a/nvrNYZM</a> (Link since I cannot post images on Stackoverflow yet).</p> <h2>What I tried</h2> <p>I already set the <code>UITextView</code> insets with:</p> <pre><code>messageTextView.textContainerInset = .zero messageTextView.textContainer.lineFragmentPadding = .zero messageTextView.contentInset = .zero </code></pre> <p>which removed the normal padding the <code>UITextView</code> has (using <a href="https://stackoverflow.com/questions/746670/how-to-lose-margin-padding-in-uitextview">this answer/thread</a>).</p> <p>My initial thought was that the <code>messageTextView</code> has a minimum height specified somewhere, which causes the view to expand when the text inside (one line) does not fill the minimum height. However I don't know if thats correct or if there's even a possibility to change a minimum height. Shrinking the font size creates a bigger spacing.</p> <p>The chat bubble uses <code>UIStackViews</code> to automatically adjust its size to the contents. Before changing to a <code>UITextView</code> we used an <code>UILabel</code> which worked fine and did not create any spacing.</p> <p>Has anybody experienced a similar issue?</p>
[ { "answer_id": 74273859, "author": "Kokodoko", "author_id": 1083572, "author_profile": "https://Stackoverflow.com/users/1083572", "pm_score": 1, "selected": false, "text": "requestAnimationFrame" }, { "answer_id": 74274949, "author": "Eduardo Páez Rubio", "author_id": 288...
2022/11/01
[ "https://Stackoverflow.com/questions/74273529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14203442/" ]
74,273,539
<p>I have a string which has several words in it, and I have to check if the first character is the same as the previous word last character. I've been told to use the the words built in function.</p> <p>Here is what I've done:</p> <pre><code>validGame1 :: [String] -&gt; Bool validGame1 [] = True validGame1 [x] = True validGame1 (a:b:xs) |last a == head b = validGame1 (b:xs) |otherwise = False </code></pre> <p>but i'm getting exceptions when the input should be True</p> <p>example : validGame &quot;bread door room mad&quot; (this should be True but it throws an exception) validGame &quot;bread car room mad&quot; (this should be False and it works well)</p>
[ { "answer_id": 74273619, "author": "Noughtmare", "author_id": 15207568, "author_profile": "https://Stackoverflow.com/users/15207568", "pm_score": 3, "selected": true, "text": "words" }, { "answer_id": 74279862, "author": "Chris", "author_id": 15261315, "author_profile...
2022/11/01
[ "https://Stackoverflow.com/questions/74273539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20386169/" ]
74,273,549
<pre><code> $test = [ 0 =&gt; [ 'type' =&gt; 'separator', 'data' =&gt; 'separator1' ], 1 =&gt; [ 'type' =&gt; 'image', 'data' =&gt; 'image1url' ], 3 =&gt; [ 'type' =&gt; 'separator', 'data' =&gt; 'separator2' ], 4 =&gt; [ 'type' =&gt; 'video', 'data' =&gt; 'video1url' ], 5 =&gt; [ 'type' =&gt; 'image', 'data' =&gt; 'image3url' ], ]; </code></pre> <p>I have an array that has multiple arrays in it. I need to separate the array into multiple arrays like the example below.</p> <pre><code> $array1 = [ 0 =&gt; [ 'type' =&gt; 'separator', 'data' =&gt; 'separator1' ], 1 =&gt; [ 'type' =&gt; 'image', 'data' =&gt; 'image1url' ], ]; $array2 = [ 0 =&gt; [ 'type' =&gt; 'separator', 'data' =&gt; 'separator2' ], 1 =&gt; [ 'type' =&gt; 'video', 'data' =&gt; 'video1url' ], 2 =&gt; [ 'type' =&gt; 'image', 'data' =&gt; 'image3url' ], ]; </code></pre> <p>Is there any way to do such thing? Please consider that the item-count between separators can be changed.</p> <p>I tried to do it using a foreach but didn't succeed.</p>
[ { "answer_id": 74273714, "author": "Saleh Hashemi", "author_id": 1926454, "author_profile": "https://Stackoverflow.com/users/1926454", "pm_score": 0, "selected": false, "text": " ${'array' . $counter} = 'your array';\n" }, { "answer_id": 74273732, "author": "Bl457Xor", "a...
2022/11/01
[ "https://Stackoverflow.com/questions/74273549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14253057/" ]
74,273,550
<p>I have a midx file that has a format the same as an XML file.</p> <p>I am reading this file as:</p> <pre><code>f = open('visus8.midx', 'r') regexCommand = re.compile(&quot;/\/(\S\w*)*.JPG/im&quot;) for line in f: matches = regexCommand.findall(str(line)) print(matches) </code></pre> <p>The file has</p> <pre><code>&lt;dataset url=&quot;/home/siddharth/Desktop/testing/VisusSlamFiles/idx/0000.idx&quot; color=&quot;#f4be4bff&quot; quad=&quot;0 365.189 5614.56 5.9402e-14 5617.89 3728.26 331.293 3920.91&quot; filenames=&quot;/home/siddharth/Desktop/testing/DJI_0726.JPG&quot; q=&quot;0.036175 -0.998922 0.024509 -0.015672&quot; t=&quot;-2.536858 -5.009510 91.514963&quot; lat=&quot;35.944029617344619&quot; lon=&quot;-90.450638476132283&quot; alt=&quot;91.672617112396139&quot; /&gt; </code></pre> <p>as one of the tags and I want to extract</p> <pre><code>/home/siddharth/Desktop/testing/DJI_0726.JPG </code></pre> <p>from filenames = &quot;&quot;</p> <p>I am not able to do that can you please where my regex is wrong or something else is wrong !!</p> <p>This is hald of the midx file that I am sharing here:</p> <pre><code>&lt;dataset typename=&quot;IdxMultipleDataset&quot; logic_box=&quot;0 7252 0 8683&quot; physic_box=&quot;0.24874641550219023 0.24875126191231167 0.6071205757248886 0.6071264043899676&quot;&gt; &lt;slam width=&quot;5472&quot; height=&quot;3648&quot; dtype=&quot;uint8[3]&quot; calibration=&quot;4256.023438 2735.799316 1824.087646&quot; /&gt; &lt;field name='voronoi'&gt;&lt;code&gt; output=voronoi()&lt;/code&gt; &lt;/field&gt; &lt;translate x=&quot;0.24874641550219023&quot; y=&quot;0.60712057572488864&quot;&gt; &lt;scale x=&quot;6.6824682454607912e-10&quot; y=&quot;6.6824682454607912e-10&quot;&gt; &lt;translate x=&quot;-0&quot; y=&quot;-5.9402018165207208e-14&quot;&gt; &lt;svg width=&quot;1048&quot; height=&quot;1254&quot; viewBox=&quot;0 0 7252 8683&quot;&gt; &lt;g stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; fill=&quot;#ffff00&quot; fill-opacity=&quot;0.3&quot;&gt; &lt;poi point=&quot;2710.006104,2372.072998&quot; /&gt; &lt;poi point=&quot;2795.450439,3354.056396&quot; /&gt; &lt;poi point=&quot;2846.955566,4015.307861&quot; /&gt; &lt;poi point=&quot;2914.414307,4897.018555&quot; /&gt; &lt;poi point=&quot;3015.048584,6234.411133&quot; /&gt; &lt;poi point=&quot;4570.675293,6449.748047&quot; /&gt; &lt;poi point=&quot;4437.736328,4984.978027&quot; /&gt; &lt;poi point=&quot;4387.470703,4050.677002&quot; /&gt; &lt;/g&gt; &lt;/svg&gt; &lt;dataset url=&quot;/home/siddharth/Desktop/testing/VisusSlamFiles/idx/0000.idx&quot; color=&quot;#f4be4bff&quot; quad=&quot;0 365.189 5614.56 5.9402e-14 5617.89 3728.26 331.293 3920.91&quot; filenames=&quot;/home/siddharth/Desktop/testing/DJI_0726.JPG&quot; q=&quot;0.036175 -0.998922 0.024509 -0.015672&quot; t=&quot;-2.536858 -5.009510 91.514963&quot; lat=&quot;35.944029617344619&quot; lon=&quot;-90.450638476132283&quot; alt=&quot;91.672617112396139&quot; /&gt; </code></pre> <p>Thank you</p>
[ { "answer_id": 74273714, "author": "Saleh Hashemi", "author_id": 1926454, "author_profile": "https://Stackoverflow.com/users/1926454", "pm_score": 0, "selected": false, "text": " ${'array' . $counter} = 'your array';\n" }, { "answer_id": 74273732, "author": "Bl457Xor", "a...
2022/11/01
[ "https://Stackoverflow.com/questions/74273550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19126462/" ]
74,273,567
<p>The f method is a time-consuming operation, and it may be called in several places, and the time is not certain. I hope that the f method can be executed in the order of calling, and then execute the next time.</p> <p>For example, A and B differ by 1 second to call the f method, and it takes 5 seconds to complete the execution of the f method. I hope that the f will be executed for the second time after 5 seconds.</p> <p>code:</p> <pre><code>import 'dart:async'; void main() { StreamController&lt;int&gt; controller = StreamController(); StreamSubscription streamSubscription = controller.stream.listen((event) async { await f(event); }); controller.add(5); controller.add(3); controller.add(1); } Future&lt;void&gt; f(int duration) async { await Future.delayed(Duration(seconds: duration)); print('$duration'); } </code></pre> <p>output: 1 3 5</p> <p>the result i want: 5 3 1 How can I modify the code, or what other api to use</p>
[ { "answer_id": 74273714, "author": "Saleh Hashemi", "author_id": 1926454, "author_profile": "https://Stackoverflow.com/users/1926454", "pm_score": 0, "selected": false, "text": " ${'array' . $counter} = 'your array';\n" }, { "answer_id": 74273732, "author": "Bl457Xor", "a...
2022/11/01
[ "https://Stackoverflow.com/questions/74273567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8324792/" ]