qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,123,457
<p>I do open a txt file with the below code and getting the following output: ['MUR,MUR,COP,COP,COP,COP,COP']</p> <pre><code># opening the file in read mode my_file = open(&quot;my_txt.txt&quot;, &quot;r&quot;) # reading the file data = my_file.read() # replacing end splitting the text # when newline ('\n') is seen. data_into_list = data.split(&quot;\n&quot;) print(data_into_list) my_file.close() </code></pre> <p>How can I remove the duplicates?</p>
[ { "answer_id": 74123740, "author": "David Heffernan", "author_id": 505088, "author_profile": "https://Stackoverflow.com/users/505088", "pm_score": 4, "selected": true, "text": "Parent.virtFunc" }, { "answer_id": 74132156, "author": "vegat4", "author_id": 18174891, "au...
2022/10/19
[ "https://Stackoverflow.com/questions/74123457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9107254/" ]
74,123,497
<p>I do not wanna set up virtual machine on my macbook. I downloaded Rider on my laptop. However, I cannot see templates like(<a href="https://i.stack.imgur.com/gLXbP.png" rel="nofollow noreferrer">https://i.stack.imgur.com/gLXbP.png</a>). May you help me about it?</p> <p>Thanks from now.</p>
[ { "answer_id": 74123740, "author": "David Heffernan", "author_id": 505088, "author_profile": "https://Stackoverflow.com/users/505088", "pm_score": 4, "selected": true, "text": "Parent.virtFunc" }, { "answer_id": 74132156, "author": "vegat4", "author_id": 18174891, "au...
2022/10/19
[ "https://Stackoverflow.com/questions/74123497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13818089/" ]
74,123,555
<p>There is a class that is like a structure for flags. I.e. it is comprised of flags.<br /> E.g.</p> <pre><code>public class Foo { boolean isA; boolean isB; boolean isC; boolean isD; boolean isE; boolean isX; boolean isY; } </code></pre> <p>I need to check at some point if at least one of the flags is <code>true</code>. Besides a series of <code>if</code> statements e.g.</p> <pre><code>boolean isAnyTrue = false; if(foo.isA) isAnyTrue = true; else if(foo.isB) isAnyTrue = true; else if(foo.isC) isAnyTrue = true; else if(foo.isD) isAnyTrue = true; else if(foo.isE) isAnyTrue = true; else if(foo.isX) isAnyTrue = true; else if(foo.isY) isAnyTrue = true; </code></pre> <p>Or</p> <pre><code>boolean isAnyTrue = foo.isA || foo.isB || foo.isC || foo.isD || foo.isE || foo.isX || foo.isY; </code></pre> <p>Is there any other way to achieve this?</p>
[ { "answer_id": 74123717, "author": "Michał Ziober", "author_id": 51591, "author_profile": "https://Stackoverflow.com/users/51591", "pm_score": 1, "selected": false, "text": "isAnyTrue()" }, { "answer_id": 74123903, "author": "Sanjeet Jagdev", "author_id": 7223898, "au...
2022/10/19
[ "https://Stackoverflow.com/questions/74123555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9055634/" ]
74,123,579
<p>Im currently using laravel 9, laravel dompdf package for export my file , this the pdf file igot , no content at all. the data i pass did not display in the PDF. ::<a href="https://i.stack.imgur.com/lw84A.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lw84A.png" alt="enter image description here" /></a></p> <p>But when I just open it as view , the data pass properly and the css work nice. This is how it looks like : <a href="https://i.stack.imgur.com/9aPUt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9aPUt.png" alt="enter image description here" /></a></p> <p>Here is my code on the View:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot;&gt; &lt;head&gt; &lt;meta charset=&quot;utf-8&quot;&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt; &lt;title&gt;Bootstrap demo&lt;/title&gt; &lt;/head&gt; &lt;style&gt; * { box-sizing: border-box; margin:0; padding:0; } body { background:#DDD; } div.container { max-width: 1350px; margin: 0 auto; overflow: hidden } .upcomming { font-size: 45px; text-transform: uppercase; border-left: 14px solid rgba(255, 235, 59, 0.78); padding-left: 12px; margin: 18px 8px; } .container .item { width: 48%; float: left; padding: 0 20px; background: #fff; overflow: hidden; margin: 10px } .container .item-right, .container .item-left { float: left; padding: 20px } .container .item-right { padding: 79px 0px; margin-right: 20px; width: 25%; position: relative; height: 286px; text-align: center; } .container .item-right .up-border, .container .item-right .down-border { padding: 14px 15px; background-color: #ddd; border-radius: 50%; position: absolute } .container .item-right .up-border { top: -8px; right: -35px; } .container .item-right .down-border { bottom: -13px; right: -35px; } .container .item-right .num { font-size: 50px; color: #111 } .container .item-right .day, .container .item-left .event { color: #555; font-size: 15px; margin-bottom: 9px; } .container .item-right .day { text-align: center; font-size: 25px; } .container .item-left { width: 71%; padding: 34px 0px 19px 46px; border-left: 3px dotted #999; } .container .item-left .title { color: #111; font-size: 34px; margin-bottom: 12px } .container .item-left .sce { margin-top: 5px; display: block } .container .item-left .sce .icon, .container .item-left .sce p, .container .item-left .loc .icon, .container .item-left .loc p{ float: left; word-spacing: 5px; letter-spacing: 1px; color: #888; margin-bottom: 10px; } .container .item-left .sce .icon, .container .item-left .loc .icon { margin-right: 10px; font-size: 20px; color: #666 } .container .item-left .loc {display: block} .fix {clear: both} .container .item .tickets, .booked, .cancel{ color: #fff; padding: 6px 14px; float: right; margin-top: 10px; font-size: 18px; border: none; cursor: pointer } .container .item .tickets {background: #777} .container .item .booked {background: #3D71E9} .container .item .cancel {background: #DF5454} .linethrough {text-decoration: line-through} &lt;/style&gt; &lt;body&gt; &lt;div class=&quot;container&quot;&gt; &lt;h1 class=&quot;upcomming&quot;&gt;Event Tickets&lt;/h1&gt; @php ($i=1) @foreach ($tickets as $key=&gt; $ticket) &lt;div class=&quot;item&quot;&gt; &lt;div class=&quot;item-right&quot;&gt; &lt;h2 class=&quot;num&quot;&gt; {{ $ticket-&gt;ticket_no }}&lt;/h2&gt; &lt;p class=&quot;day&quot;&gt;Ticket No.&lt;/p&gt; &lt;span class=&quot;up-border&quot;&gt;&lt;/span&gt; &lt;span class=&quot;down-border&quot;&gt;&lt;/span&gt; &lt;/div&gt; &lt;!-- end item-right --&gt; &lt;div class=&quot;item-left&quot;&gt; &lt;p class=&quot;event&quot;&gt;{{ $ticket-&gt;GiftGiving-&gt;name }}&lt;/p&gt; &lt;h2 class=&quot;title&quot;&gt;{{ $ticket-&gt;name }}&lt;/h2&gt; &lt;div class=&quot;sce&quot;&gt; &lt;p&gt;{{Carbon\Carbon::parse($ticket-&gt;GiftGiving-&gt;start_at )-&gt;isoFormat('LL') }}&lt;br/&gt; {{ Carbon\Carbon::parse($ticket-&gt;GiftGiving-&gt;start_at )-&gt;isoFormat('h:mm A') }}&lt;/p&gt; &lt;/div&gt; &lt;div class=&quot;fix&quot;&gt;&lt;/div&gt; &lt;div class=&quot;loc&quot;&gt; &lt;p&gt;{{ $ticket-&gt;GiftGiving-&gt;venue }}&lt;/p&gt; &lt;/div&gt; &lt;div class=&quot;fix&quot;&gt;&lt;/div&gt; &lt;button class=&quot;booked&quot;&gt;Batch No. {{ $ticket-&gt;GiftGiving-&gt;batch_no}}&lt;/button&gt; &lt;/div&gt; &lt;!-- end item-right --&gt; &lt;/div&gt; &lt;!-- end item --&gt; &lt;!--Set limitation of printing only 5 ticket per page--&gt; @if ($i % 6 === 0) &lt;div style=&quot;page-break-after: always;&quot;&gt;&lt;/div&gt; @endif @php ($i++) @endforeach &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <pre><code>Controller </code></pre> <pre><code>public function GenerateTicket($code) { # Retrieve the records using $code $GiftGiving = GiftGiving::where('code', $code)-&gt;firstOrFail(); $tickets = GiftGivingBeneficiary::where('gift_giving_id', $GiftGiving-&gt;id)-&gt;get(); # Users can only access their own charity's records if ($GiftGiving-&gt;charitable_organization_id == Auth::user()-&gt;charitable_organization_id) { # Must have at least one beneficiary before generating tickets if ($tickets-&gt;count() &lt; 1) { $toastr = array( 'message' =&gt; 'Gift Giving must have at least one (1) beneficiary first before generating tickets', 'alert-type' =&gt; 'error' ); return redirect()-&gt;back()-&gt;with($toastr); } # Retrieve the last batch no. from the gift giving. $batch_no = $GiftGiving-&gt;batch_no; # Increment Batch no. by +1 $GiftGiving-&gt;update([ 'last_downloaded_by' =&gt; Auth::id(), 'batch_no' =&gt; $batch_no + 1, ]); # Audit Logs Creation $log = new AuditLog; $log-&gt;user_id = Auth::user()-&gt;id; $log-&gt;action_type = 'GENERATE PDF'; $log-&gt;charitable_organization_id = Auth::user()-&gt;charitable_organization_id; $log-&gt;table_name = 'Gift Giving'; $log-&gt;record_id = $GiftGiving-&gt;code; $log-&gt;action = 'Charity Admin generated tickets for the Gift Giving [' . $GiftGiving-&gt;name . '] with batch no. ' . $GiftGiving-&gt;batch_no . '.'; $log-&gt;performed_at = Carbon::now(); $log-&gt;save(); # Send Notification to each user in their Charitable Organizations $users = User::where('charitable_organization_id', Auth::user()-&gt;charitable_organization_id)-&gt;where('status', 'Active')-&gt;get(); foreach ($users as $user) { $notif = new Notification; $notif-&gt;code = Str::uuid()-&gt;toString(); $notif-&gt;user_id = $user-&gt;id; $notif-&gt;category = 'Gift Giving'; $notif-&gt;subject = 'Generated Tickets'; $notif-&gt;message = Auth::user()-&gt;role . ' ' . Auth::user()-&gt;info-&gt;first_name . ' ' . Auth::user()-&gt;info-&gt;last_name . ' has generated tickets for [' . $GiftGiving-&gt;name . '] with batch no. ' . $GiftGiving-&gt;batch_no . '.'; $notif-&gt;icon = 'mdi mdi-ticket'; $notif-&gt;color = 'info'; $notif-&gt;created_at = Carbon::now(); $notif-&gt;save(); } // return view('charity.gifts.generate_ticket', compact('tickets')); $pdf = PDF::loadView('charity.gifts.generate_ticket', compact('tickets')); return $pdf-&gt;download($GiftGiving-&gt;name . ' - No. ' . $GiftGiving-&gt;batch_no . '.pdf'); } else { $toastr = array( 'message' =&gt; 'Users can only access their own charity records.', 'alert-type' =&gt; 'error' ); return redirect()-&gt;back()-&gt;with($toastr); } } </code></pre> <p>Hope somebody can point out what did i miss, thankyou in advance . all suggest/answer are highly appreciated.</p>
[ { "answer_id": 74123717, "author": "Michał Ziober", "author_id": 51591, "author_profile": "https://Stackoverflow.com/users/51591", "pm_score": 1, "selected": false, "text": "isAnyTrue()" }, { "answer_id": 74123903, "author": "Sanjeet Jagdev", "author_id": 7223898, "au...
2022/10/19
[ "https://Stackoverflow.com/questions/74123579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13322128/" ]
74,123,582
<p>I am using Material-UI component, useState hook and NextJS framework.</p> <p>I am mapping someData in my render, the structure of a someData element is :</p> <pre><code>someData[i] : { &quot;id&quot;: number, &quot;name&quot;: string, &quot;surname&quot;: string } </code></pre> <p>My problem is to pass mapped data to Modal (specific to the mapped data).</p> <pre><code>{someData.map((data) =&gt; ( &lt;Grid item key={data.id}&gt; &lt;Card&gt; &lt;CardContent&gt; &lt;Typography&gt; {data.surname} {data.name}'s card. &lt;/Typography&gt; &lt;/CardContent&gt; &lt;Button onClick={() =&gt; { setModalData(data); setOpen(true); }} &gt; Follow &lt;/Button&gt; &lt;Modal open={open} onClose={setOpen(false)} &gt; &lt;Box&gt; &lt;Typography&gt; Follow {modalData.surname} ? &lt;/Typography&gt; &lt;Button onClick={() =&gt; handleFollowSubmit(modalData)}&gt; /*Function declared not important here*/ Yes &lt;/Button&gt; &lt;/Box&gt; &lt;/Modal&gt; &lt;/Card&gt; &lt;/Grid&gt; ))} </code></pre> <p>And the state used here are:</p> <pre><code>const [open, setOpen] = useState(false); // to handle the Modal opening const [modalData, setModalData] = useState(null); // to pass Data to the modal </code></pre> <p>The idea is that you can't pass mapped data to a modal using the mapping, you have to use a State Hook to do so: When you open a modal, you pass the corresponding data through the State Hook.</p> <p>But when I render the webpage I get this error :</p> <blockquote> <p>TypeError: Cannot read properties of null (reading 'surname')</p> </blockquote> <p>Pointing at modalData.surname</p> <p>Any help would be appreciated!</p>
[ { "answer_id": 74123717, "author": "Michał Ziober", "author_id": 51591, "author_profile": "https://Stackoverflow.com/users/51591", "pm_score": 1, "selected": false, "text": "isAnyTrue()" }, { "answer_id": 74123903, "author": "Sanjeet Jagdev", "author_id": 7223898, "au...
2022/10/19
[ "https://Stackoverflow.com/questions/74123582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20164960/" ]
74,123,604
<p>I try to extract the number before some specific text. So I have this long string:</p> <pre><code>verdi = &quot;['a= (&gt;)\n\nFactuur\nVerdi Import Schoolfruit\nFactuur nr; %: 70273 Koopliedenweg 38\nDeb. nr. : 108636 2991 LN BARENDRECHT\nYour VAT nr. : NL851703884B01 Nederland\nFactuur datum : 19-11-21\nAantal Omschrijving Prijs Bedrag\nOrder number : 76372 Loading date : 15-11-21 Incoterm: : FOT\nYour ref. : SCHOOLFRUIT Delivery date :\nWK46\nVerdi Import Schoolfruit\n566 Ananas Crownless 14kg 10 Sweet CR Klasse I € 7,00 € 3.962,00\n706 Appels Royal Gala 13kg 60/65 Generica PL Klasse I € 4,68 € 3.304,08\n598 Peen Waspeen 14x1lkg 200-400 Generica BE Klasse I € 6,30 3.767,40\nOrder number : 76462 Loading date : 18-11-21 Incoterm: : FOT\nYour ref. : SCHOOLFRUIT Delivery date :\nWK47\nD.C, Schoolfruit\n176 Sinaasappels Valencias 15kg 125 Generica UY Klasse I € 6,25 € 1.100,00\n179 Peen Waspeen 14x1kg 200-400 Generica BE Klasse I € 6,30 € 1.127,70\n222 Peen Waspeen 14x1lkg 200-400 Generica BE Klasse I € 6,30 € 1.398,60\n270 Peen Waspeen 14x1ikg 200-400 Generica BE Klasse I € 6,30 € 1.701,00\nZuid\n176 sinaas\n222 wortel\nmidden\n270 wortel\nNoord\n179 wortel\nOrder number : 75674 Loading date : 18-11-21 Incoterm: : FRA\nYour ref. : SCHOOLFRUIT Delivery date :\nWK47\nD.C. Schoolfruit\n400 Rettich Klein x20 10kg 20 GENER DE Klasse I € 4,70 € 1.880,00\n129 Rettich Klein x20 10kg 20 GENER DE Klasse I € 4,70 € 606,30\n48 Rettich Klein x20 10kg 20 GENER IT Klasse I € 4,70 € 225,60\n104 = Rettich Klein x20 10kg 20 GENER IT Klasse I € 4,70 € 488,80\n22 =Rettich Klein x20 10kg 20 Viva IT Klasse I € 4,70 € 103,40\n107 ~=Rettich Klein x20 10kg 20 Viva IT Klasse I € 4,70 € 502,90\n160 Sinaasappels Valencias 15kg 125 ALG ZA Klasse I € 7,50 € 1.200,00\n6 Sinaasappels Valencias 15kg 125 ALG ZA Klasse I € 7,50 € 45,00\n320 Sinaasappels Valencias 15kg 125 FVC ZA Klasse I € 7,50 € 2.400,00\nREGIO\nSINAAS\nMIDDEN: 219\nNOORD: 267\nVerDi Import BV ING Bank N.V. Rotterdam IBAN number: NL17INGB0006959173 aoethe\nKoopliedenweg 38, 2991 LN Barendrecht, The Netherlands SWIFT/BIC: INGBNL2A, VAT number: NL851703884B01\n\na\nTel. +31 (0)1 80 61 88 11, Fax +31 (0)1 80 61 88 25 Chamber of Commerce Rotterdam no. 55424309 VerDi\nE-mail: sales@verdiimport.nl, www.verdiimport.nl Dutch law shall apply. The Rotterdam District Court shall have exclusive jurisdiction.\n\nfrult and wegetadles\n\n \n\x0c', 'a&gt; &gt;)\n\nFactuur\nVerdi Import Schoolfruit\nFactuur nr. : 70273 Koopliedenweg 38\nDeb. nr. : 108636 2991 LN BARENDRECHT\nYour VAT nr. : NL851703884B01 Nederland\nFactuur datum ; 19-11-21\nAantal Omschrijving Prijs Bedrag\nRETTICH:\nZUID: 216\nNOORD: 328\nMIDDEN: 266\nTotaal Colli Totaal Netto Btw Btw Bedrag Totaal Bedrag\n\n \n \n\n€ 23.812,78 € 25.955,93\n\n \n\nBetaling binnen 30 dagen\nAchterstand wordt gemeld bij de kredietverzekeringsmaatschappij\n\nVerDi Import BV ING Bank N.V. Rotterdam IBAN number: NL17INGBO006959173 =\nKoopliedenweg 38, 2991 LN Barendrecht, The Netherlands SWIFT/BIC: INGBNL2A, VAT number: NL851703884B01 7\nTel. +31 (0)1 80 61 88 11, Fax +31 (0)1 80 61 88 25 Chamber of Commerce Rotterdam no. 55424309 VerD\nE-mail: sales@verdiimport.nl, www.verdiimport.nl Dutch law shall apply. The Rotterdam District Court shall have exclusive jurisdiction. l\n\nfrutt and vegetables:\n\n \n\x0c']&quot; </code></pre> <p>and then I want to extract the number before this words:</p> <pre><code> fruit_words = ['Appels Royal Gala 13kg 60/65 Generica PL Klasse I', 'Ananas Crownless 14kg 10 Sweet CR Klasse I', 'Peen Waspeen 14x1lkg 200-400 Generica BE Klasse I' ] </code></pre> <p>So I try it like this:</p> <pre><code>number_foud = re.findall(r&quot;([0-9]+)&quot; .join(fruit_words),verdi) </code></pre> <p>But if I try to run this with</p> <pre><code>print(number_foud) </code></pre> <p>it returns []</p> <p>question: what I have to change, that it will return the number before tex?</p> <p>Thank you</p> <p>for example 222 Appels Royal Gala 13kg 60/65 Generica PL Klasse I</p>
[ { "answer_id": 74123772, "author": "Matthias", "author_id": 1209921, "author_profile": "https://Stackoverflow.com/users/1209921", "pm_score": 2, "selected": true, "text": "|" } ]
2022/10/19
[ "https://Stackoverflow.com/questions/74123604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7713770/" ]
74,123,613
<p>Would this work?</p> <p>.env:</p> <p><code>ELASTIC_SEARCH_URI=http://localhost:9200/example-dev</code></p> <p>The docs just say to use <code>ELASTIC_SEARCH_URI=http://localhost:9200/</code> but I have two different apps on same dedicated server using elasticsearch. I want to specify a unique database for each app.</p> <pre><code>const es = new ElasticsearchClient({ node: &quot;http://localhost:9200&quot;, /* auth: { username: 'elastic', password: 'password' } */ }); </code></pre>
[ { "answer_id": 74125109, "author": "Sagar Patel", "author_id": 5489276, "author_profile": "https://Stackoverflow.com/users/5489276", "pm_score": 0, "selected": false, "text": "example-dev" }, { "answer_id": 74125653, "author": "Doğukan Akkaya", "author_id": 12671403, ...
2022/10/19
[ "https://Stackoverflow.com/questions/74123613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33522/" ]
74,123,615
<p>Using Laravel 8, I have a model with <code>belongsTo</code> relationship with another.</p> <pre><code>class Author extends Model {} </code></pre> <p>And another one,</p> <pre><code>class Post extends Model { public function author() { return $this-&gt;belongsTo('App\Models\Author', 'author_id'); } } // Controller Post::with('author'); </code></pre> <p>By using <code>with</code> I can retrieve the author based on Post. However, all attributes from author are retrieved. I don't want to return all fields since an author may have a confidential info.</p> <p>If I have multiple table to get <code>with(['model1', 'model2'...])</code>, this returns all foreign table fields.</p> <p>Is there a way like, <code>with(new AuthorResource())</code> so I can put logic into the resource like restrictions to fields to be displayed?</p>
[ { "answer_id": 74123710, "author": "ABHILASHA K.M", "author_id": 12232499, "author_profile": "https://Stackoverflow.com/users/12232499", "pm_score": 0, "selected": false, "text": "Post::with('author')->select('author.id')->get();\n" }, { "answer_id": 74124009, "author": "Ashu...
2022/10/19
[ "https://Stackoverflow.com/questions/74123615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7067321/" ]
74,123,634
<p>I have a repository with several folders and many subfolders and files inside:</p> <p>/folder1/....</p> <p>/folder2/....</p> <p>/folder3/....</p> <p>And whenever I change one (or more), an automated system should git pull the changes and recompile the code. Each folder has its own compilation script and it takes a long time to compile each of them. Is there a way to know, for the changes I'm about to pull, what were the modified folders, so I can run only those compilation scripts that are needed and not all of them?</p>
[ { "answer_id": 74123952, "author": "Ivan Yuzafatau", "author_id": 1889110, "author_profile": "https://Stackoverflow.com/users/1889110", "pm_score": 3, "selected": true, "text": "git fetch\n" }, { "answer_id": 74124010, "author": "LeGEC", "author_id": 86072, "author_pr...
2022/10/19
[ "https://Stackoverflow.com/questions/74123634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16536307/" ]
74,123,640
<p>I am trying to get the most recent date in a nested dicionary. The dates are strings and can be found in a variable number of dictionaries under the key <code>forth</code>. This is my approach:</p> <pre><code>data = { &quot;first&quot;: { &quot;second&quot;: { &quot;third_1&quot;: {&quot;forth&quot;: &quot;2022-01-01&quot;}, &quot;third_2&quot;: {&quot;forth&quot;: None}, &quot;third_3&quot;: {&quot;forth&quot;: &quot;2021-01-01&quot;}, } } } def get_max(data, key): tmp = [] for item in data.values(): tmp.append(item.get(key)) tmp = [ datetime.strptime(date, &quot;%Y-%m-%d&quot;).date().strftime(&quot;%Y-%m-%d&quot;) for date in tmp if date ] return max(tmp) out = data[&quot;first&quot;][&quot;second&quot;] out = get_max(data=out, key=&quot;forth&quot;) out </code></pre> <p>Is there anything I can improve?</p>
[ { "answer_id": 74123952, "author": "Ivan Yuzafatau", "author_id": 1889110, "author_profile": "https://Stackoverflow.com/users/1889110", "pm_score": 3, "selected": true, "text": "git fetch\n" }, { "answer_id": 74124010, "author": "LeGEC", "author_id": 86072, "author_pr...
2022/10/19
[ "https://Stackoverflow.com/questions/74123640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9748823/" ]
74,123,644
<p>I need to read from a text file in java and pass that information through a polymorphic method. My idea is a CryptoWallet in a .txt file reading as coin, amount and value, where in the text file its represented as Bitcoin 100 1.25.</p> <p>Ive got the code reading from the file and printing it, as below.</p> <pre><code>public class CryptoCurrencies public static void main (String[] args) throws IOException { System.out.println(&quot;Welcome to your Crypto Wallet&quot; + &quot;\nCurrently, you only own one coin.&quot;); File CryptoWallet = new File(&quot;/Users/curti/OneDrive/Desktop/crypto.txt&quot;); Scanner scan = new Scanner(CryptoWallet); String fileContent = &quot; &quot;; while(scan.hasNextLine()) { System.out.println(scan.nextLine()); continue; } </code></pre> <p>My main issue is actually getting the text file too recognise the numbers as doubles and variables, and assigning them to run through a polymorphic method. I understand the polymorphism side, but if anyone has any ideas for a possible polymorphic method id really appreciate it, having trouble thinking at the moment!</p> <p>Thanks everyone.</p>
[ { "answer_id": 74125939, "author": "vsfDawg", "author_id": 7275056, "author_profile": "https://Stackoverflow.com/users/7275056", "pm_score": 1, "selected": false, "text": "while(scan.hasNextLine()) {\n String line = scan.nextLine());\n String[] tokens = line.split(\" \");\n String nam...
2022/10/19
[ "https://Stackoverflow.com/questions/74123644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19991198/" ]
74,123,656
<p>I'm trying to pull a value out of nested JSON inside a column. I get the return value, but I am unable to also pull the first JSON key that the value binds to.</p> <p>Query only pulls 1 row.</p> <p>Example json:</p> <pre class="lang-json prettyprint-override"><code>{ &quot;key1&quot;: { &quot;data1&quot;: &quot;data1 object&quot;, &quot;data2&quot;: &quot;data2 object&quot; }, &quot;key2&quot;: { &quot;data1&quot;: &quot;data1 object&quot;, &quot;data2&quot;: &quot;data2 object&quot; } } </code></pre> <p>where key <code>key</code> values are dynamic and key <code>data</code> values are static.</p> <p>Expected result:</p> <pre class="lang-json prettyprint-override"><code>{ &quot;key1&quot;: { &quot;data1&quot;: &quot;data1 object&quot; }, &quot;key2&quot;: { &quot;data1&quot;: &quot;data1 object&quot; } } </code></pre> <p>or</p> <pre class="lang-json prettyprint-override"><code>{ &quot;key1&quot;: &quot;data1 object&quot;, &quot;key2&quot;: &quot;data1 object&quot; } </code></pre> <p>Not perfectly working query:</p> <pre class="lang-sql prettyprint-override"><code>SELECT json-&gt;&gt;&quot;$.*.data1&quot; AS data FROM table WHERE id=1; </code></pre> <p>output:</p> <pre class="lang-json prettyprint-override"><code>[ &quot;data1 object&quot;, &quot;data1 object&quot; ] </code></pre>
[ { "answer_id": 74124393, "author": "Flewz", "author_id": 20262622, "author_profile": "https://Stackoverflow.com/users/20262622", "pm_score": 0, "selected": false, "text": "JSON_KEYS()" }, { "answer_id": 74124672, "author": "Akina", "author_id": 10138734, "author_profi...
2022/10/19
[ "https://Stackoverflow.com/questions/74123656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20262622/" ]
74,123,663
<p>sorry for my naive, but i can't solve this. any reference or solution ?</p> <p>df1 =</p> <pre><code> date a b c 0 2011-12-30 100 400 700 1 2021-01-30 200 500 800 2 2021-07-30 300 600 900 </code></pre> <p>df2 =</p> <pre><code> date c b 0 2021-07-30 NaN NaN 1 2021-01-30 NaN NaN 2 2011-12-30 NaN NaN </code></pre> <p>desired output:</p> <pre><code> date c b 0 2021-07-30 900 600 1 2021-01-30 800 500 2 2011-12-30 700 400 </code></pre>
[ { "answer_id": 74124393, "author": "Flewz", "author_id": 20262622, "author_profile": "https://Stackoverflow.com/users/20262622", "pm_score": 0, "selected": false, "text": "JSON_KEYS()" }, { "answer_id": 74124672, "author": "Akina", "author_id": 10138734, "author_profi...
2022/10/19
[ "https://Stackoverflow.com/questions/74123663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16697053/" ]
74,123,688
<p><strong>Source</strong>: MS Access on Windows network share</p> <p><strong>Target</strong>: MySQL/MariaDB on Ubuntu</p> <p><strong>Tools</strong>: mdb-export, mysqlimport</p> <p><strong>record count</strong>: 1,5 Mio +</p> <p>I wonder if there is a fast and reliable way of comparing the imported data records.</p> <p>Is there an SQL standard equivalent to e.g. md5 fingerprint hashes of files? Right now, I am building different import routines and I only want to fast check for similarity and (if failed) search for the detailed differences later on.</p>
[ { "answer_id": 74123894, "author": "Juergen", "author_id": 2183431, "author_profile": "https://Stackoverflow.com/users/2183431", "pm_score": -1, "selected": false, "text": "CHECKSUM TABLE tbl_name\n" }, { "answer_id": 74126261, "author": "markusjm", "author_id": 7633996, ...
2022/10/19
[ "https://Stackoverflow.com/questions/74123688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2183431/" ]
74,123,698
<p>I have a data called &quot;test&quot;</p> <pre><code> dput(test)&gt; structure(list(Data = c(&quot;Apple&quot;, &quot;3&quot;, &quot;Orange&quot;, &quot;4&quot;, &quot;Grape&quot;, &quot;2&quot;, &quot;Orange&quot;, &quot;5&quot;, &quot;Grape&quot;, &quot;1&quot;, &quot;Orange&quot;, &quot;4&quot;)), class = c(&quot;tbl_df&quot;, &quot;tbl&quot;, &quot;data.frame&quot;), row.names = c(NA, -12L)) </code></pre> <p>I wish to extract the &quot;Orange&quot; number. How do I do that if all my data is in one column.</p> <p>My desire output is</p> <pre><code> Data Orange1 4 Orange2 5 Orange3 4 </code></pre>
[ { "answer_id": 74123752, "author": "RobertoT", "author_id": 17077978, "author_profile": "https://Stackoverflow.com/users/17077978", "pm_score": 3, "selected": true, "text": "dplyr" }, { "answer_id": 74123758, "author": "user2974951", "author_id": 2974951, "author_prof...
2022/10/19
[ "https://Stackoverflow.com/questions/74123698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14568947/" ]
74,123,712
<p>I have a list of radio group that need to be checked by user.</p> <pre><code>&lt;div&gt;&lt;input type='radio' class='radio_m' name='1-a' /&gt;&lt;/div&gt; &lt;div&gt;&lt;input type='radio' class='radio_m' name='1-a' /&gt;&lt;/div&gt; &lt;div&gt;&lt;input type='radio' class='radio_m' name='2-a' /&gt;&lt;/div&gt; &lt;div&gt;&lt;input type='radio' class='radio_m' name='2-a' /&gt;&lt;/div&gt; </code></pre> <p>User need to check at least one radio in each radio group. If not checked, all div which has same radio name will be flagged (change background-color to red)</p> <p>This is my current script</p> <pre><code>$(form).find(&quot;div .radio_m&quot;).each(function(i){ var _this = $(this); var ct_checked = 0; _this.each(function(c){ if(_this.is(':checked') == false){ _this.closest(&quot;div&quot;).css(&quot;background-color&quot;,&quot;#F3A3A3&quot;); } else{ _this.closest(&quot;div&quot;).css(&quot;background-color&quot;,&quot;transparent&quot;); } }); }); </code></pre> <p>My script only change the div with current checked radio. How do I target div which has radios with same name?</p> <p>Ex:</p> <ul> <li>If user check radio with name <code>1-a</code>, all div (div 1 and 2) which has radio name <code>1-a</code> will be transparent and other div (div 3 and 4) will be red</li> </ul> <p>Any help is greatly appreciated</p>
[ { "answer_id": 74123752, "author": "RobertoT", "author_id": 17077978, "author_profile": "https://Stackoverflow.com/users/17077978", "pm_score": 3, "selected": true, "text": "dplyr" }, { "answer_id": 74123758, "author": "user2974951", "author_id": 2974951, "author_prof...
2022/10/19
[ "https://Stackoverflow.com/questions/74123712", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7154727/" ]
74,123,718
<pre><code>import re cc = 'test 5555555555555555/03/22/284 test' cc = re.findall('[0-9]{15,16}\/[0-9]{2,4}\/[0-9]{2,4}\/[0-9]{3,4}', cc) print(cc) </code></pre> <blockquote> <p>[5555555555555555/03/22/284]</p> </blockquote> <p>This code is working fine but if i put <code>5555555555555555|03|22|284</code> on <strong>cc variable</strong> then this output will come: <code>[]</code></p> <p>I want one condition if it contains '|' then it gives output: <code>5555555555555555|03|22|284</code> or '/' then also it will give output: <code>5555555555555555/03/22/284</code></p>
[ { "answer_id": 74123784, "author": "Mark Reed", "author_id": 797049, "author_profile": "https://Stackoverflow.com/users/797049", "pm_score": 3, "selected": true, "text": "/" }, { "answer_id": 74123789, "author": "Zain Ul Abidin", "author_id": 2355176, "author_profile"...
2022/10/19
[ "https://Stackoverflow.com/questions/74123718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20281410/" ]
74,123,729
<p>First of all, thank you for reading this question</p> <p>So, I have a set of data which is the difference between two date in &quot;minutes&quot; the raw data type is &quot;Whole Number&quot; I would like to convert it to be &quot;DD:HH:MM&quot;, not sure if anyone could help me, thank you so much!</p> <p><a href="https://i.stack.imgur.com/hUbLX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hUbLX.png" alt="the result I want" /></a></p> <p><a href="https://i.stack.imgur.com/SegqP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SegqP.png" alt="that is what I did but cannot show it in Power BI properly" /></a></p>
[ { "answer_id": 74123784, "author": "Mark Reed", "author_id": 797049, "author_profile": "https://Stackoverflow.com/users/797049", "pm_score": 3, "selected": true, "text": "/" }, { "answer_id": 74123789, "author": "Zain Ul Abidin", "author_id": 2355176, "author_profile"...
2022/10/19
[ "https://Stackoverflow.com/questions/74123729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19595149/" ]
74,123,750
<p>I'm trying to create tiles and zones. Zones has to dimensional array of tiles. Tiles must has link to zone, but if i will create field &quot;zone link;&quot;, this tile will create new zone, and if i will create &quot;ref zone link;&quot;, compiler will say &quot;missing '(' and')'&quot;. Compiler thinks that i am trying to create method that will return reference to zone, but how to create link to zone as field?</p> <p>(This code written here, not inside any compiler)</p> <pre><code>using Something; public class Zone { public /*or privet*/ Tile[,] public Zone(short width, short length) { //create Tiles and //Give &quot;link&quot; to tile as &quot;this&quot; } } public class Tile { ref Zone link; //compiler error: missing &quot;(&quot; and &quot;)&quot;. he thinks this is method. //or Zone link; //logic error: infinite loop where every tile will create new zone. } </code></pre> <p>please help me :(</p> <p>i need this for unity, but please, don't say &quot;unity already has tilemaps&quot;</p> <p>p.s. sorry if i'm bad at english.</p>
[ { "answer_id": 74124119, "author": "madmonk46", "author_id": 9796331, "author_profile": "https://Stackoverflow.com/users/9796331", "pm_score": 1, "selected": false, "text": "public class Tile\n{\n Zone ParentZone;\n}\n" }, { "answer_id": 74124523, "author": "derHugo", ...
2022/10/19
[ "https://Stackoverflow.com/questions/74123750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20274801/" ]
74,123,755
<p>I'm trying to create a REST cartridge to expose API for getting my custom business component (WarehouseBO in this case). I have based my code on this guide - <a href="https://support.intershop.com/kb/index.php/Display/29L926" rel="nofollow noreferrer">Guide - Create a New Storefront REST Resource</a> and have created cartridge app_sf_rest_warehouse and in it WarehouseResource which has several dependencies but whenever I try to make a REST call it throws and error and in the logs it says there was no object available for injection (I have tried injecting CurrentApplicationBOProvider and LocaleMgr):</p> <pre><code>Lookup and initialization failed for a resource class: class com.luminoslabs.warehouse.rest.capi.WarehouseResource. org.glassfish.hk2.api.MultiException: A MultiException has 1 exceptions. They are: 1. org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl(requiredType=LocaleMgr,parent=WarehouseResource,qualifiers={},position=-1,optional=false,self=false,unqualified=null,424987312) </code></pre> <p>The URL I'm trying is: http://localhost:8080/INTERSHOP/rest/WFS/inSPIRED-inTRONICS_Business-Site/-/warehouses All of the following code artifacts are from <code>app_sf_rest_warehouse</code>:</p> <p>apps.component</p> <pre><code>&lt;components xmlns=&quot;http://www.intershop.de/component/2010&quot;&gt; &lt;fulfill requirement=&quot;selectedCartridge&quot; of=&quot;intershop.SMBResponsive.Cartridges&quot; value=&quot;app_sf_rest_warehouse&quot;/&gt; &lt;/components&gt; </code></pre> <p>instances.component</p> <pre><code>&lt;components xmlns=&quot;http://www.intershop.de/component/2010&quot;&gt; &lt;!-- Way where you attach your new resource to existing REST API root --&gt; &lt;fulfill requirement=&quot;subResource&quot; of=&quot;intershop.B2BWebShop.RESTAPI.root&quot;&gt; &lt;instance name=&quot;intershop.B2BWebShop.RESTAPI.WarehouseResource&quot; with=&quot;WarehouseResource&quot;&gt; &lt;fulfill requirement=&quot;name&quot; value=&quot;warehouses&quot; /&gt; &lt;/instance&gt; &lt;/fulfill&gt; &lt;fulfill requirement=&quot;resourceACLCartridge&quot; value=&quot;app_sf_rest_warehouse&quot; of=&quot;intershop.B2BWebShop.RESTAPI.AuthorizationService&quot;/&gt; &lt;/components&gt; </code></pre> <p>implementations.component</p> <pre><code>&lt;components xmlns=&quot;http://www.intershop.de/component/2010&quot;&gt; &lt;implementation name=&quot;WarehouseResource&quot; implements=&quot;AbstractRestResource&quot; class=&quot;com.luminoslabs.warehouse.rest.capi.WarehouseResource&quot;&gt; &lt;requires name=&quot;subResource&quot; contract=&quot;RestResource&quot; cardinality=&quot;0..n&quot; /&gt; &lt;requires name=&quot;name&quot; contract=&quot;String&quot; cardinality=&quot;1..1&quot; /&gt; &lt;/implementation&gt; &lt;/components&gt; </code></pre> <p>WarehouseReource.java</p> <pre><code>@Tag(name = &quot;Warehouse&quot;) @OpenAPIDefinition( info = @Info(version = &quot;1.0.0&quot;)) public class WarehouseResource extends AbstractRestResource implements RestResource { /*@Inject private CurrentApplicationBOProvider currentApplicationBOProvider;*/ @Inject private LocaleMgr localeMgr; public WarehouseResource() { super(); //NamingMgr.inject(this); //NamingMgr.injectMembers(this); } @Operation( summary = &quot;Returns the list of warehouses.&quot; ) @ApiResponses({@ApiResponse( responseCode = &quot;200&quot;, description = &quot;The list of warehouses.&quot;, content = {@Content( schema = @Schema( implementation = Collection.class ) )} ), @ApiResponse( responseCode = &quot;401&quot;, ref = &quot;401&quot; )}) @GET @Produces({&quot;application/json&quot;}) public Response getWarehouses() { //final WarehouseBORepository warehouseBORepository = currentApplicationBOProvider.get().getRepository(WarehouseBORepository.EXTENSION_ID); final Collection&lt;WarehouseBO&gt; warehouseBOs = null; //warehouseBORepository.getAllWarehouseBOs(); final Collection&lt;WarehouseRO&gt; warehouseROs = Optional.ofNullable(warehouseBOs).map( warehouses -&gt; warehouses.stream().map( warehouse -&gt; new WarehouseRO(warehouse) ).collect(Collectors.toList()) ).orElse(new ArrayList&lt;&gt;(0)); return Response.ok(warehouseROs).build(); } } </code></pre>
[ { "answer_id": 74126646, "author": "Johannes Metzner", "author_id": 8751376, "author_profile": "https://Stackoverflow.com/users/8751376", "pm_score": 2, "selected": false, "text": "AbstractRestResource" }, { "answer_id": 74137624, "author": "mihallievich", "author_id": 97...
2022/10/19
[ "https://Stackoverflow.com/questions/74123755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9725841/" ]
74,123,764
<p>I am trying to write a generic java method wherein I want to remove a part of a String after a particular character and till a particular character. For e.g. &quot;My name is-A&quot; is the String, then I want a method that should remove String till - or remove String after -. So my expected output here would be &quot;My name is-&quot; or &quot;A&quot;. Below is my code.</p> <pre><code>String p=&quot;Free Float Factor-FFF&quot;; char[] s2= p.toCharArray(); char[] s3; int i=0; do { s3=ArrayUtils.remove(s2, i); i++; }while((!s2.equals(&quot;-&quot;))&amp;&amp;i&lt;s2.length); System.out.println(new String(s3)); } </code></pre> <p>The output I am getting here is <strong>Free Float Factor-FF</strong> I want either &quot;Free Float Factor-&quot; or &quot;FFF&quot; as the output. I am trying to convert the String into an array and then remove the part of the String till - but it is removing the last character. Slightly confused by this.</p>
[ { "answer_id": 74124001, "author": "Andy Turner", "author_id": 3788176, "author_profile": "https://Stackoverflow.com/users/3788176", "pm_score": -1, "selected": false, "text": "indexOf" }, { "answer_id": 74124165, "author": "IamGroot", "author_id": 8327330, "author_pr...
2022/10/19
[ "https://Stackoverflow.com/questions/74123764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20262433/" ]
74,123,773
<p>I have created a project component that displays my projects on my portfolio website. I want to make it reusable so I can pass different values (projects) to the this.</p> <p>I'm creating an object containing all of the properties of the project and then passing it as a prop to the component.</p> <p>eg: let portfolioProject = [ { title: 'Portfolio Website', description: 'My portfolio website', img: Portfolio, gitHub: 'project' } ]</p> <p>When I pass the whole object to the component and log it in the console it works fine. When I try to add a property when logging it the value returns undefined. eg: project.title</p> <p>Does anyone know what may be causing this issue?</p> <p><em>I have shortened the code for this example to make it more clear.</em></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code> let portfolioProject = [ { title: 'Portfolio Website', description: 'My portfolio website', img: Portfolio, gitHub: 'https://github.com/gavinwalsh1996/flight-entertainment-system' } ] return ( &lt;ThemeContext.Provider value={{ theme, toggleTheme }}&gt; &lt;div className="App" id={theme}&gt; &lt;Header theme={theme} toggleTheme={toggleTheme}/&gt; &lt;Home /&gt; &lt;About /&gt; &lt;Projects heading={heading}/&gt; &lt;Projects project={portfolioProject}/&gt;</code></pre> </div> </div> </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>function Projects({heading, project}) { const {title, description, img, gitHub} = project console.log(project.title) // Title property returns undefined let buttonValue1= 'Live App'; let buttonValue2= 'Learn More'; let FlightEntLink = 'https://github.com/gavinwalsh1996/flight-entertainment-system';</code></pre> </div> </div> </p>
[ { "answer_id": 74124001, "author": "Andy Turner", "author_id": 3788176, "author_profile": "https://Stackoverflow.com/users/3788176", "pm_score": -1, "selected": false, "text": "indexOf" }, { "answer_id": 74124165, "author": "IamGroot", "author_id": 8327330, "author_pr...
2022/10/19
[ "https://Stackoverflow.com/questions/74123773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20165435/" ]
74,123,774
<p>I have a large .xlsx file with 1 million rows. I don't want to open the whole file in one go. I was wondering if I can read a chunk of the file, process it and then read the next chunk? (I prefer to use pandas for it.)</p> <pre><code>import pandas as pd # File size 50m data = pd.read_excel(&quot;m.xlsx&quot;) # It takes a long time to open a file </code></pre>
[ { "answer_id": 74124001, "author": "Andy Turner", "author_id": 3788176, "author_profile": "https://Stackoverflow.com/users/3788176", "pm_score": -1, "selected": false, "text": "indexOf" }, { "answer_id": 74124165, "author": "IamGroot", "author_id": 8327330, "author_pr...
2022/10/19
[ "https://Stackoverflow.com/questions/74123774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18307259/" ]
74,123,885
<p>How can I get the characters that repeat at the same position in a string?</p> <pre class="lang-r prettyprint-override"><code>df &lt;- data.frame(col1 = paste0(&quot;a&quot;, LETTERS[1:5]), col2 = paste0(&quot;b&quot;, letters[1:5]), col3 = paste0(&quot;ccde&quot;, letters[1:5]), col4 = paste0('?', letters[1:2], 1:5), col5 = paste0(1:5, 'hello you', letters[1:2], 1:5), col6 = paste0('hello', letters[1:2], 1:5, &quot;you&quot;), col7 = c(&quot;hello1 you&quot;, &quot;hello you2&quot;, &quot;hello3 you&quot;, &quot;hello you4&quot;, &quot;hello5 you&quot;)) # col1 col2 col3 col4 col5 col6 col7 # 1 aA ba ccdea ?a1 1hello youa1 helloa1you hello1 you # 2 aB bb ccdeb ?b2 2hello youb2 hellob2you hello you2 # 3 aC bc ccdec ?a3 3hello youa3 helloa3you hello3 you # 4 aD bd ccded ?b4 4hello youb4 hellob4you hello you4 # 5 aE be ccdee ?a5 5hello youa5 helloa5you hello5 you result &lt;- c(&quot;a&quot;, &quot;b&quot;, &quot;ccde&quot;, &quot;?&quot;, &quot;hello you&quot;, &quot;helloyou&quot;, &quot;hello&quot;) </code></pre>
[ { "answer_id": 74124001, "author": "Andy Turner", "author_id": 3788176, "author_profile": "https://Stackoverflow.com/users/3788176", "pm_score": -1, "selected": false, "text": "indexOf" }, { "answer_id": 74124165, "author": "IamGroot", "author_id": 8327330, "author_pr...
2022/10/19
[ "https://Stackoverflow.com/questions/74123885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13460602/" ]
74,123,888
<p>I have a function which is called on a click event:</p> <pre><code> useEffect(() =&gt; { document.addEventListener('click', (e) =&gt; handleClickOutside(e), true); }); </code></pre> <p>The function:</p> <pre><code> const myElement = useRef(null); const handleClickOutside = (e: MouseEvent) =&gt; { if (!colorPickerRef) { return; } if (!myElement.current?.contains(e.target)) { // do something } }; </code></pre> <p>However I get the error property <code>'contains' does not exist on type 'never'</code></p> <p>How can I promise typescript that <code>myElement.current</code> is not null?</p>
[ { "answer_id": 74124001, "author": "Andy Turner", "author_id": 3788176, "author_profile": "https://Stackoverflow.com/users/3788176", "pm_score": -1, "selected": false, "text": "indexOf" }, { "answer_id": 74124165, "author": "IamGroot", "author_id": 8327330, "author_pr...
2022/10/19
[ "https://Stackoverflow.com/questions/74123888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9856049/" ]
74,123,919
<p>I would like a parent that contains two side by side divs, the right one is 20px and the left one fills the remaining space.</p> <p>If there is too much text in the left div, I would like the excess to be hidden.</p> <p>Currently everything I have tried, it ends up wrapping onto the next line.</p> <p>Here's my code:</p> <p><a href="https://jsfiddle.net/5y7fngbk/" rel="nofollow noreferrer">https://jsfiddle.net/5y7fngbk/</a></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div style="display: flex; width: 300px; background-color: blue;"&gt; &lt;div style="width: 100%;overflow: hidden;"&gt;hello testset hello cats hello hello hello hello hello hello &lt;/div&gt; &lt;div style="width:20px;"&gt;x&lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>Can anyone tell me why <code>overflow:hidden</code> is not respected or how I can fix this?</p> <p>For the purposes of this example I have set the parent to 300px wide. However it would be 100% of its own parent when I come to use this code, i.e. the left div would shrink as I resize the window.</p>
[ { "answer_id": 74123968, "author": "Neil W", "author_id": 2936204, "author_profile": "https://Stackoverflow.com/users/2936204", "pm_score": 2, "selected": true, "text": " <div style=\"display: flex; width: 300px; background-color: yellow;\">\n <div style=\"width: 100%; white-spac...
2022/10/19
[ "https://Stackoverflow.com/questions/74123919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/174375/" ]
74,123,982
<p>Why I can't use <code>Object.keys()</code> method inside an <code>*ngIf</code> directive of Angular? WebStorm arises <em>Unresolved variable or type Object</em> error, highlighting the &quot;Object&quot; word.</p> <p>Example:</p> <pre><code>&lt;span *ngIf=&quot;Object.keys(item).includes('author')&quot;&gt; </code></pre> <p>Edit: I appreciate the answers; I knew how to make it work (so for example using a function created in the .ts with the Object.keys() method and returning true or false), but my question was why can't this code be directly used *<strong>inside the <em>ngIf</em></strong>, because everytime I write the word &quot;Object&quot; inside the *ngIf expression, WebStorm claims that error I mentioned.</p>
[ { "answer_id": 74124070, "author": "Matthieu Riegler", "author_id": 884123, "author_profile": "https://Stackoverflow.com/users/884123", "pm_score": 2, "selected": false, "text": "enum" }, { "answer_id": 74124226, "author": "Sachila Ranawaka", "author_id": 6428638, "au...
2022/10/19
[ "https://Stackoverflow.com/questions/74123982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12966003/" ]
74,124,033
<p>I have two arrays <code>mp</code> of shape (240, 480) and <code>pop_fts_norm</code> which is an array of length <code>N</code> of arrays of shape (240, 480). I want to create an array of length <code>N</code> with values from <code>mp</code> but only where elements of <code>x</code> are != 0, for each array <code>x</code> in pop_fts_norm.</p> <p>Inefficient code:</p> <pre><code>full_mp = np.array([np.array([mp[i][j] if (x != 0)[i][j] is True else 0 for i in range(240) for j in range(480)]).reshape(240, 480) for x in pop_fts_norm], dtype='float32') full_mp.shape </code></pre> <p>This works but works slowly.. How can be more efficiently written in pythonic style ?</p> <p>Thanks, Petru</p>
[ { "answer_id": 74124156, "author": "penguina", "author_id": 5726763, "author_profile": "https://Stackoverflow.com/users/5726763", "pm_score": 1, "selected": false, "text": "full_mp = np.array([np.where(x != 0, mp, 0) for x in pop_fts_norm])\nfull_mp.shape\n" }, { "answer_id": 741...
2022/10/19
[ "https://Stackoverflow.com/questions/74124033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5726763/" ]
74,124,046
<p>I need to replace the string of n-th occurrences that exists inside files.</p> <p>The case is like this:</p> <p>I have 1,000 occurrences of <code>Acme</code> inside files, which I managed to obtain the number through:</p> <pre><code>find . -type f -exec cat {} + | grep -c 'Acme' </code></pre> <p>I also had been able to replace <em>all</em> occurrences of <code>Acme</code> through:</p> <pre><code>grep -rl 'Acme' ./ | LC_ALL=C xargs sed -i '' 's/Acme/NotAcme/g' </code></pre> <p>However, I face difficulty when I try to only replace the n-th occurrences (E.g. Only replace the first 100 occurrences of <code>Acme</code>.</p> <p>The furthest I found is to iterate through all the occurrences of <code>Acme</code> through:</p> <pre><code>grep -roh Acme . | wc -w </code></pre> <p>Haven't found the way to iterate and replace the n-th occurrences of <code>Acme</code> so far.</p> <p>Any help will be appreciated. Thanks!</p>
[ { "answer_id": 74124342, "author": "anubhava", "author_id": 548225, "author_profile": "https://Stackoverflow.com/users/548225", "pm_score": 0, "selected": false, "text": "Acme" }, { "answer_id": 74124997, "author": "chovy", "author_id": 33522, "author_profile": "https...
2022/10/19
[ "https://Stackoverflow.com/questions/74124046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2857357/" ]
74,124,049
<p>I've got a combo box that I want to allow users to enter in numerical digits, but not allow them to enter alphabetical characters.</p> <p>My problem is that these numbers can be decimal so I need to allow the user to enter <code>.</code></p> <p>I've used <code>char.IsSymbol</code> but it doesn't seem to do what I want it to do.</p> <pre><code>private void DaySelection_ComboBox_KeyPress(object sender, KeyPressEventArgs e) { if (!char.IsControl(e.KeyChar) &amp;&amp; !char.IsDigit(e.KeyChar) &amp;&amp; !char.IsSymbol(e.KeyChar)) { e.Handled = true; } } </code></pre>
[ { "answer_id": 74124342, "author": "anubhava", "author_id": 548225, "author_profile": "https://Stackoverflow.com/users/548225", "pm_score": 0, "selected": false, "text": "Acme" }, { "answer_id": 74124997, "author": "chovy", "author_id": 33522, "author_profile": "https...
2022/10/19
[ "https://Stackoverflow.com/questions/74124049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11145145/" ]
74,124,050
<p>I'm a newbie on ReactJS and I'm currently working on a project with cards similar to those on the link provided. Cards with <code>isFavorite</code> value set to <code>true</code> should appear when <strong>FAVORITE</strong> button is clicked. My question is, how do I change the property value of <code>isFavorite</code> to <code>true</code> or <code>false</code> when I click on the <strong>Favorite</strong> button on each card?</p> <p>Code on the sandbox: <a href="https://codesandbox.io/s/cards-kgyzvc?file=/src/App.js" rel="nofollow noreferrer">https://codesandbox.io/s/cards-kgyzvc?file=/src/App.js</a></p> <p>data.js</p> <pre><code>const data = [ { id: 0, text: &quot;So you two dig up, dig up dinosaurs? Yeah, but your scientists were so preoccupied with whether or not they could, they didn't stop to think if they should. You know what? It is beets. I've crashed into a beet truck. You know what? It is beets. I've crashed into a beet truck.&quot;, isFavorite: true }, { id: 1, text: &quot;I gave it a cold? I gave it a virus. A computer virus. Hey, take a look at the earthlings. Goodbye! Eventually, you do plan to have dinosaurs on your dinosaur tour, right? This thing comes fully loaded. AM/FM radio, reclining bucket seats, and... power windows.&quot;, isFavorite: false }, { id: 2, text: &quot;Remind me to thank John for a lovely weekend. They're using our own satellites against us. And the clock is ticking. Jaguar shark! So tell me - does it really exist? Remind me to thank John for a lovely weekend. Checkmate... Yeah, but John, if The Pirates of the Caribbean breaks down, the pirates don’t eat the tourists.&quot;, isFavorite: false }, { id: 3, text: &quot;Just my luck, no ice. Eventually, you do plan to have dinosaurs on your dinosaur tour, right? Yeah, but John, if The Pirates of the Caribbean breaks down, the pirates don’t eat the tourists. Remind me to thank John for a lovely weekend. We gotta burn the rain forest, dump toxic waste, pollute the air, and rip up the OZONE! 'Cause maybe if we screw up this planet enough, they won't want it anymore!&quot;, isFavorite: true }, { id: 4, text: &quot;I was part of something special. Hey, you know how I'm, like, always trying to save the planet? Here's my chance. Eventually, you do plan to have dinosaurs on your dinosaur tour, right? Hey, take a look at the earthlings. Goodbye! I was part of something special.&quot;, isFavorite: false } ]; export default data; </code></pre> <p>App.js</p> <pre><code>export default function App() { const [all, setAll] = useState(true); const [favorites, setFavorites] = useState(false); const showAll = () =&gt; { setAll(true); setFavorites(false); }; const showFavorite = () =&gt; { setFavorites(true); setAll(false); }; return ( &lt;div className=&quot;App&quot;&gt; &lt;div className=&quot;button-group&quot;&gt; &lt;button className={all ? &quot;all active&quot; : &quot;all&quot;} onClick={showAll}&gt; ALL &lt;/button&gt; &lt;button className={favorites ? &quot;favorites active&quot; : &quot;favorites&quot;} onClick={showFavorite} &gt; FAVORITES &lt;/button&gt; &lt;/div&gt; &lt;br /&gt; &lt;Masonry breakpointCols={3} className=&quot;my-masonry-grid&quot; columnClassName=&quot;my-masonry-grid_column&quot; &gt; {all &amp;&amp; data.map((item) =&gt; ( &lt;Cards key={item.id} text={item.text} isFavorite={item.isFavorite} /&gt; ))} {favorites &amp;&amp; data .filter((item) =&gt; item.isFavorite === true) .map((filtered) =&gt; ( &lt;Cards key={filtered.id} text={filtered.text} isFavorite={filtered.isFavorite} /&gt; ))} &lt;/Masonry&gt; &lt;/div&gt; ); } </code></pre> <p>Cards.js</p> <pre><code>const Cards = ({ text, isFavorite }) =&gt; { return ( &lt;div className=&quot;cards&quot;&gt; &lt;p&gt;{text}&lt;/p&gt; &lt;button&gt;{isFavorite ? &quot;Added to Favorites!&quot; : &quot;Favorite&quot;}&lt;/button&gt; &lt;/div&gt; ); }; </code></pre>
[ { "answer_id": 74124342, "author": "anubhava", "author_id": 548225, "author_profile": "https://Stackoverflow.com/users/548225", "pm_score": 0, "selected": false, "text": "Acme" }, { "answer_id": 74124997, "author": "chovy", "author_id": 33522, "author_profile": "https...
2022/10/19
[ "https://Stackoverflow.com/questions/74124050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15612876/" ]
74,124,059
<p>A vector contains the following numerical data after prime factorization of a certain number x:</p> <pre><code>c &lt;- c(2,2,2,3) </code></pre> <p>This is the prime factorization of 24</p> <p>The first column of the matrix should contain the prime factors 2 and 3 The second column should contain the power of the prime factors.</p> <p>e.g.</p> <pre><code>| 2 3 | | 3 1 | </code></pre> <p>How would I go about creating this matrix.</p>
[ { "answer_id": 74124342, "author": "anubhava", "author_id": 548225, "author_profile": "https://Stackoverflow.com/users/548225", "pm_score": 0, "selected": false, "text": "Acme" }, { "answer_id": 74124997, "author": "chovy", "author_id": 33522, "author_profile": "https...
2022/10/19
[ "https://Stackoverflow.com/questions/74124059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20281500/" ]
74,124,080
<p>I have 2 dictionaries.</p> <p>One of which reports the added widgets (currentStatus), and the other is the default one (defaultDashboardWidgets)</p> <pre><code>private readonly Dictionary&lt;string, int&gt; defaultDashboardWidgets = new Dictionary&lt;string, int&gt; { { &quot;Configure Dashboard widgets&quot;, 1 }, { &quot;Recent Items&quot;, 4 }, { &quot;System status widget&quot;, 1 }, { &quot;Dashboard Notifications&quot;, 1 }, { &quot;Welcome title&quot;, 1 }, { &quot;Welcome description&quot;, 1 } }; </code></pre> <p>AND</p> <pre><code>private readonly Dictionary&lt;string, int&gt; currentStatus = new Dictionary&lt;string, int&gt; { { &quot;Configure Dashboard widgets&quot;, 1 }, { &quot;Recent Items&quot;, 6 }, { &quot;System status widget&quot;, 1 }, { &quot;Dashboard Notifications&quot;, 1 }, { &quot;Welcome title&quot;, 1 }, { &quot;Welcome description&quot;, 1 }, { &quot;Images&quot;, 1 } }; </code></pre> <p>I am trying to create a 3rd dictionary that contains the differences between the other two dictionaries.</p> <p>The new Dictionary should look like this:</p> <pre><code>new Dictionary&lt;string, int&gt; { {&quot;Recent items&quot;, 2}, {&quot;Images&quot;, 1} } </code></pre> <p>I am currently trying to achieve it via &quot;Except&quot;, its return the different keys, but keeps the old value.</p> <p>My Code:</p> <pre><code>var newDictionary = currentStatus.Except(this.defaultDashboardWidgets).ToDictionary(x =&gt; x.Key, x =&gt; x.Value) </code></pre> <p>And the result is :</p> <pre><code>{&quot;Recent items&quot;, 6}, {&quot;Images&quot;, 1} </code></pre>
[ { "answer_id": 74124640, "author": "Dmitry Bychenko", "author_id": 2319407, "author_profile": "https://Stackoverflow.com/users/2319407", "pm_score": 3, "selected": true, "text": "Key" }, { "answer_id": 74124813, "author": "DonMiguelSanchez", "author_id": 13337616, "au...
2022/10/19
[ "https://Stackoverflow.com/questions/74124080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15132002/" ]
74,124,087
<p>I'm having a XML similar to following and need to get <code>&lt;Document&gt;</code> nodes where<code>&lt;ZZXMLT&gt;</code> equals '04'.</p> <pre><code>&lt;DataArea&gt; &lt;Document&gt; &lt;ZZPRTF&gt;PMS241PF&lt;/ZZPRTF&gt; &lt;ZZXMLT Label=&quot;Variant&quot;&gt;03&lt;/ZZXMLT&gt; &lt;/Document&gt; &lt;Document&gt; &lt;ZZPRTF&gt;PMS241PF&lt;/ZZPRTF&gt; &lt;ZZXMLT Label=&quot;Variant&quot;&gt;04&lt;/ZZXMLT&gt; &lt;/Document&gt; &lt;Document&gt; &lt;ZZPRTF&gt;PMS242PF&lt;/ZZPRTF&gt; &lt;ZZXMLT Label=&quot;Variant&quot;&gt;04&lt;/ZZXMLT&gt; &lt;/Document&gt; &lt;/DataArea&gt; </code></pre> <p>Following is the powershell code.</p> <pre><code>$xml = [xml](Get-Content -Path $file.FullName | Out-String) $product = $xml.SelectSingleNode(&quot;//Document&quot;) $parent = $product.ParentNode $allproducts = @($parent.SelectNodes(&quot;Document&quot;) | Where-Object {$_.ZZXMLT -eq &quot;04&quot;}) </code></pre> <p>This is working fine when <code>&lt;ZZXMLT&gt;</code> does not have an attribute but for the original XML there is an attribute.</p> <p>Can somebody help me to get this done</p> <p>Thank you!</p>
[ { "answer_id": 74124207, "author": "Mathias R. Jessen", "author_id": 712649, "author_profile": "https://Stackoverflow.com/users/712649", "pm_score": 2, "selected": false, "text": "Where-Object" }, { "answer_id": 74124297, "author": "iRon", "author_id": 1701026, "autho...
2022/10/19
[ "https://Stackoverflow.com/questions/74124087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10289876/" ]
74,124,100
<p>I tried looking up this question or trying to mix other similar formulas I found together to no avail..</p> <p>Could someone help me out please?</p>
[ { "answer_id": 74124207, "author": "Mathias R. Jessen", "author_id": 712649, "author_profile": "https://Stackoverflow.com/users/712649", "pm_score": 2, "selected": false, "text": "Where-Object" }, { "answer_id": 74124297, "author": "iRon", "author_id": 1701026, "autho...
2022/10/19
[ "https://Stackoverflow.com/questions/74124100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20281622/" ]
74,124,215
<p>I want to ask a conceptional question and take advices about possible system design if possible.</p> <p>The plan is basically authenticating specific Gmail users to use my serverless backend application. I'm thinking about either forwarding users directly to my VPC or I can authenticate them in my host-provider server and then after forward them to the VPC (or directly Cloud Run service?).</p> <p>I'd be really glad if someone experienced can lead me about concepts and suggest design ideas about this.</p>
[ { "answer_id": 74124207, "author": "Mathias R. Jessen", "author_id": 712649, "author_profile": "https://Stackoverflow.com/users/712649", "pm_score": 2, "selected": false, "text": "Where-Object" }, { "answer_id": 74124297, "author": "iRon", "author_id": 1701026, "autho...
2022/10/19
[ "https://Stackoverflow.com/questions/74124215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9987570/" ]
74,124,221
<p>I'm trying to count the number of times the word &quot;text&quot; appears per row in Power BI. I've done a lot of google searching and seen examples like this:</p> <pre><code>Formula := CALCULATE ( COUNTROWS ( FILTER ( 'TestData', FIND ( &quot;text&quot;, 'TestData'[Description],, 0 ) &gt; 0 ) ),1=1 ) </code></pre> <p>but it isn't quite getting me there. How can I get for row 1, a result of 1 and row 2, a result of 3.</p> <pre><code>CREATE TABLE [dbo].[TestData]( [ID] [int] IDENTITY(1,1) NOT NULL, [Description] [varchar](100) NULL ) ON [PRIMARY] GO SET IDENTITY_INSERT [dbo].[TestData] ON GO INSERT [dbo].[TestData] ([ID], [Description]) VALUES (1, N'this is my demo text') GO INSERT [dbo].[TestData] ([ID], [Description]) VALUES (2, N'text text demo text') GO SET IDENTITY_INSERT [dbo].[TestData] OFF GO </code></pre> <p>Expected Result</p> <pre><code>ID Description Text Word Count 1 this is my demo text 1 2 text text demo text 3 </code></pre>
[ { "answer_id": 74124207, "author": "Mathias R. Jessen", "author_id": 712649, "author_profile": "https://Stackoverflow.com/users/712649", "pm_score": 2, "selected": false, "text": "Where-Object" }, { "answer_id": 74124297, "author": "iRon", "author_id": 1701026, "autho...
2022/10/19
[ "https://Stackoverflow.com/questions/74124221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2204060/" ]
74,124,249
<p>I'm on mixing two lists using flutter I declare a variable as final and when I tried to reuse it I got : The final variable 'd' can only be set once.Try making 'd' non-final. And I want it to be as final. this is my code :</p> <pre><code>final d = []; chunks.forEach((chunk) { final c = chunk as List&lt;int&gt;; final list4 = [(c[c.length - 2] ^ c[c.length - 1])]; d = c + list4; }); print('List With CRC : $d '); return d; } </code></pre> <p>Any suggestions please.</p>
[ { "answer_id": 74124207, "author": "Mathias R. Jessen", "author_id": 712649, "author_profile": "https://Stackoverflow.com/users/712649", "pm_score": 2, "selected": false, "text": "Where-Object" }, { "answer_id": 74124297, "author": "iRon", "author_id": 1701026, "autho...
2022/10/19
[ "https://Stackoverflow.com/questions/74124249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20150210/" ]
74,124,331
<p>i have the following full simple code</p> <pre><code>import 'package:flutter/material.dart'; class A2 extends StatefulWidget { const A2({Key? key}) : super(key: key); @override State&lt;A2&gt; createState() =&gt; _A2State(); } class _A2State extends State&lt;A2&gt; { @override Widget build(BuildContext context) { return Scaffold( body: Container( color: Colors.red, ), ); } } </code></pre> <p>well, now my red Container is color full</p> <p>Question : How do I make some space of the Container center colorless with space loss control like Following ?</p> <p><a href="https://i.stack.imgur.com/6eIky.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6eIky.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74124461, "author": "Vivek Tarsariya", "author_id": 20201716, "author_profile": "https://Stackoverflow.com/users/20201716", "pm_score": -1, "selected": false, "text": "class A2 extends StatefulWidget {\n const A2({Key? key}) : super(key: key);\n\n @override\n State<A2> ...
2022/10/19
[ "https://Stackoverflow.com/questions/74124331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16213673/" ]
74,124,368
<p>I have a data frame with various data and I want to drop some rows with the top 3 highest value in a column.</p> <p>My approach:</p> <p>First sort the data frame by the column &quot;Coal&quot;:</p> <p><code>energyDataRed &lt;- energyData[order(-energyData$Coal), ]</code></p> <p><a href="https://i.stack.imgur.com/ozK4C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ozK4C.png" alt="enter image description here" /></a></p> <p>And then drop the top 3 columns with:</p> <p><code>energyDataRed &lt;- energyDataRed[-1:-2, ]</code></p> <p>It works but I think there is a better way, right?</p>
[ { "answer_id": 74124461, "author": "Vivek Tarsariya", "author_id": 20201716, "author_profile": "https://Stackoverflow.com/users/20201716", "pm_score": -1, "selected": false, "text": "class A2 extends StatefulWidget {\n const A2({Key? key}) : super(key: key);\n\n @override\n State<A2> ...
2022/10/19
[ "https://Stackoverflow.com/questions/74124368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12191075/" ]
74,124,439
<p>how to get &quot;expected_output&quot; column with cumsum?</p> <pre><code>groupa = ['A', 'A', 'A', 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'C', 'C', 'C', 'C'] valuesa = [-5, 4, 3, -4, -2, -2, 2, -2, 5, -2, 3, 6, 7, -11] expected_output = [0, 4, 7, 3, 1, 0, 2, 0, 5, 3, 3, 9, 16, 5] dfa = pd.DataFrame(list(zip(groupa, valuesa)), columns=['group', 'val']) dfa['expected_output'] = pd.Series(expected_output) dfa['cumsum_output'] = dfa.groupby('group')['val'].cumsum() nega = dfa['val'] &lt; 0 dfa['output'] = dfa['val'].groupby( [nega[::-1].cumsum(), dfa['group']]).cumsum().clip(0) dfa </code></pre> <pre><code> group val expected_output cumsum_output output 0 A -5 0 -5 0 1 A 4 4 -1 4 2 A 3 7 2 7 3 A -4 3 -2 3 4 A -2 1 -4 0 5 A -2 0 -6 0 6 A 2 2 -4 2 7 B -2 0 -2 0 8 B 5 5 3 5 9 B -2 3 1 3 10 C 3 3 3 3 11 C 6 9 9 9 12 C 7 16 16 16 13 C -11 5 5 5 </code></pre> <blockquote> <p><a href="https://stackoverflow.com/questions/65223420/cumsum-on-pandas-df-with-reset-to-zero-for-negative-cumulative-values">Cumsum on Pandas DF with reset to zero for negative cumulative values</a></p> </blockquote>
[ { "answer_id": 74124461, "author": "Vivek Tarsariya", "author_id": 20201716, "author_profile": "https://Stackoverflow.com/users/20201716", "pm_score": -1, "selected": false, "text": "class A2 extends StatefulWidget {\n const A2({Key? key}) : super(key: key);\n\n @override\n State<A2> ...
2022/10/19
[ "https://Stackoverflow.com/questions/74124439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20281846/" ]
74,124,449
<p>Hello so I'm trying to define the function pairs:</p> <pre><code>pairs :: [a] -&gt; [(a, a)] pairs x = zip x (tail x) </code></pre> <p>However I'm using <code>Relude</code> as opposed to the normal Prelude. Which makes tail work with <code>Non-Empty a</code> rather then [a]. This has lead to some really confusing stuff when I try to fix it. As switching the [a] to [nonEmpty a] etc. Leads to the problem moving around.</p> <p>Any ideas on how to alter the function so it works with relude?.</p> <p>It also has it seems a way of doing things with the <code>viaNonEmpty</code> function however using this also has problems.</p> <p>Ultimately all I want to do is just be able to take [a] and create [(a, a)], and the zip xs (tail xs) method seemed from looking around to be the idiomatic way of doing this. But if this way is not doable using relude alright then.</p> <p>Any help is most appreciated. Thanks.</p>
[ { "answer_id": 74124484, "author": "chi", "author_id": 3234959, "author_profile": "https://Stackoverflow.com/users/3234959", "pm_score": 2, "selected": false, "text": "tail" }, { "answer_id": 74124490, "author": "Noughtmare", "author_id": 15207568, "author_profile": "...
2022/10/19
[ "https://Stackoverflow.com/questions/74124449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18422054/" ]
74,124,455
<p>I have the following code, where I need to populate a set with multiple objects that are instances of the same class (User). The problem is, I only get the first object when I log.</p> <pre><code>user = User.builder() .id(1L) .username(&quot;2397047&quot;) .nickname(&quot;test1&quot;) .build(); anotherUser = User.builder() .id(2L) .username(&quot;23971948&quot;) .nickname(&quot;test2&quot;) .build(); Set&lt;User&gt; userSet = new HashSet&lt;&gt;(); userSet.add(user); userSet.add(anotherUser); System.out.println(&quot;User set from test &quot; + userSet); </code></pre> <p>This code produces the following output</p> <pre><code>User set from test [User(id=1, nickname=test1, username= 2397047, password=null, roles=null, groups=null)] </code></pre> <p>Why am I unable to get the entire collection?</p> <p>This is my User class</p> <pre><code>package com.chama.chamaservice.user; import com.chama.chamaservice.BaseEntity; import com.chama.chamaservice.Views; import com.chama.chamaservice.config.ApplicationUserRole; import com.chama.chamaservice.group.Group; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonView; import lombok.*; import javax.persistence.*; import java.util.HashSet; import java.util.Set; @Builder @Entity @NoArgsConstructor @AllArgsConstructor @Getter @Setter @ToString public class User extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.AUTO) @JsonView(Views.Public.class) private Long id; @JsonView(Views.Public.class) private String nickname; @JsonView(Views.Public.class) private String username; // &lt;- Unique user's phone number private String password; @ElementCollection(targetClass = ApplicationUserRole.class) @CollectionTable(name = &quot;user_role&quot;, joinColumns = @JoinColumn(name = &quot;user_id&quot;)) @Enumerated(EnumType.STRING) @Column(name = &quot;role&quot;) private Set&lt;ApplicationUserRole&gt; roles; @JsonIgnore @ManyToMany(mappedBy = &quot;groupMembers&quot;, fetch = FetchType.LAZY, targetEntity = Group.class) private Set&lt;Group&gt; groups = new HashSet&lt;&gt;(); } </code></pre>
[ { "answer_id": 74124484, "author": "chi", "author_id": 3234959, "author_profile": "https://Stackoverflow.com/users/3234959", "pm_score": 2, "selected": false, "text": "tail" }, { "answer_id": 74124490, "author": "Noughtmare", "author_id": 15207568, "author_profile": "...
2022/10/19
[ "https://Stackoverflow.com/questions/74124455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15991889/" ]
74,124,456
<p>I would like to calculate column 'E' in DAX</p> <ol> <li><p>I wanted to <strong>count distinct</strong> 'B' based on 'C' and filter on 'D' = instock.</p> </li> <li><p>I later want to <strong>sum</strong> column E -- what is the best way to do this to exclude the duplications</p> </li> </ol> <p><a href="https://i.stack.imgur.com/RD18b.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RD18b.png" alt="enter image description here" /></a></p> <p>Thanks in advance</p>
[ { "answer_id": 74124729, "author": "Jos Woolley", "author_id": 17007704, "author_profile": "https://Stackoverflow.com/users/17007704", "pm_score": 1, "selected": false, "text": "=\nVAR ThisProductCode = 'Table'[product code]\nRETURN\n CALCULATE(\n DISTINCTCOUNT( 'Table'[size] )...
2022/10/19
[ "https://Stackoverflow.com/questions/74124456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19162390/" ]
74,124,530
<p>I have terraform that looks like:</p> <pre><code>terraform { backend &quot;s3&quot; { region = &quot;ap-southeast-1&quot; key = &quot;01-service-quota-state.json&quot; bucket = &quot;foobar-dev-infra-tf-state&quot; dynamodb_table = &quot;foobar-dev-infra-tf-state-lock&quot; } required_providers { aws = { source = &quot;hashicorp/aws&quot; } } } </code></pre> <p>Since we use a Makefile to initialise the backend, I have a large terraform repository where I want to reduce and refactor the above to:</p> <pre><code>terraform { backend &quot;s3&quot; {} required_providers { aws = { source = &quot;hashicorp/aws&quot; } } } </code></pre> <p>Initially I was planning to do this with sed, though I was hinted that I could do some sort of .tf -&gt; JSON -&gt; jq -&gt; .tf transformation. Is that right?</p>
[ { "answer_id": 74124729, "author": "Jos Woolley", "author_id": 17007704, "author_profile": "https://Stackoverflow.com/users/17007704", "pm_score": 1, "selected": false, "text": "=\nVAR ThisProductCode = 'Table'[product code]\nRETURN\n CALCULATE(\n DISTINCTCOUNT( 'Table'[size] )...
2022/10/19
[ "https://Stackoverflow.com/questions/74124530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4534/" ]
74,124,547
<p>I try to find the presence of expresions &quot;a1&quot; and &quot;a11&quot; in abc object.</p> <pre><code>abc &lt;- c(&quot;a1&quot;,&quot;a1|a11&quot;,&quot;a14&quot;,&quot;a11&quot;, &quot;a11|a14&quot;, &quot;a1|a3|a14&quot;, &quot;a11|a16&quot;) </code></pre> <p>The first query finds everything, also a11, a14 etc</p> <pre><code>str_detect(abc,&quot;a1&quot;) </code></pre> <p>Is there a way to distinguich somehow to find only the a1 and not a11, a12 etc.</p>
[ { "answer_id": 74124729, "author": "Jos Woolley", "author_id": 17007704, "author_profile": "https://Stackoverflow.com/users/17007704", "pm_score": 1, "selected": false, "text": "=\nVAR ThisProductCode = 'Table'[product code]\nRETURN\n CALCULATE(\n DISTINCTCOUNT( 'Table'[size] )...
2022/10/19
[ "https://Stackoverflow.com/questions/74124547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6449064/" ]
74,124,550
<p>How to convert timestamp string, e.g. &quot;1997-07-16T19:20:30.45+01:00&quot; into UTC time. The result of conversion should be <em>timespec</em> structure as in <a href="https://man7.org/linux/man-pages/man2/utimensat.2.html" rel="nofollow noreferrer">utimensat</a> input arguments.</p> <pre><code>// sorry, should be get_utc_time timespec get_local_time(const char* ts); </code></pre> <p>P.S. I need solution using either standard Linux/C/C++ facilities (whatever that means) or Boost C++ library.</p>
[ { "answer_id": 74126140, "author": "Howard Hinnant", "author_id": 576911, "author_profile": "https://Stackoverflow.com/users/576911", "pm_score": 3, "selected": true, "text": "\"+01:00\"" }, { "answer_id": 74127886, "author": "Steve Summit", "author_id": 3923896, "aut...
2022/10/19
[ "https://Stackoverflow.com/questions/74124550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/638231/" ]
74,124,565
<p>As the title, How do I get the second/third largest/smallest value across rows by <code>dplyr</code>? Is there an elegant way to achieve it?</p> <pre><code>a &lt;- data.frame(gp1=c(3:11), gp2=c(1:9), gp3=c(8,8,2,6,6,6,12,12,6)) ## the max/min value is very simple a %&gt;% rowwise() %&gt;% mutate(max1=max(gp1, gp2, gp3)) # # # A tibble: 9 × 4 # # Rowwise: # gp1 gp2 gp3 max1 # &lt;int&gt; &lt;int&gt; &lt;dbl&gt; &lt;dbl&gt; # 1 3 1 8 8 # 2 4 2 8 8 # 3 5 3 2 5 # 4 6 4 6 6 # 5 7 5 6 7 # 6 8 6 6 8 # 7 9 7 12 12 # 8 10 8 12 12 # 9 11 9 6 11 </code></pre> <p>The result should be similar to this:</p> <pre><code># # # A tibble: 9 × 4 # # Rowwise: # gp1 gp2 gp3 max1 max2 # &lt;int&gt; &lt;int&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; # 1 3 1 8 8 3 # 2 4 2 8 8 4 # 3 5 3 2 5 3 # 4 6 4 6 6 6 # 5 7 5 6 7 6 # 6 8 6 6 8 6 # 7 9 7 12 12 9 # 8 10 8 12 12 12 # 9 11 9 6 11 9 </code></pre>
[ { "answer_id": 74124624, "author": "jdobres", "author_id": 6436545, "author_profile": "https://Stackoverflow.com/users/6436545", "pm_score": 3, "selected": true, "text": "c_across" }, { "answer_id": 74124781, "author": "Anoushiravan R", "author_id": 14314520, "author_...
2022/10/19
[ "https://Stackoverflow.com/questions/74124565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7334572/" ]
74,124,572
<p>I'm working on a joint account with some other users, but would like to use my own .gitconfig. I use SendEnv with SSH to send GIT_AUTHOR_NAME among other things and my idea is that I would like to use this to only source my gitconfig if my name is contained in that variable.</p> <p>What I've tried so far is to use <a href="https://git-scm.com/docs/git-config/2.27.0#_conditional_includes" rel="nofollow noreferrer">includeIf</a></p> <pre><code>[includeIf &quot;hasconfig:author.name:My Name&quot;] path = ~/my_name/.gitconfig </code></pre> <p>however, either hasconfig isn't available in git 2.27.0 (which is the version I'm using) or this fails because of another reason.</p> <p>There is also to possibility of using</p> <pre class="lang-bash prettyprint-override"><code>if [[ &quot;$GIT_AUTHOR_NAME&quot; == &quot;My Name&quot; ]]; then . ~/my_name/.bashrc fi </code></pre> <p>in the joint .bashrc and then taking care of it in my .bashrc.</p> <p>But using <code>GIT_CONFIG</code> environment variable seem to only work with the <code>git config</code> command. If that still worked for all commands it would have been the best solution for me.</p> <p>I have seen a suggestion of creating an alias</p> <pre class="lang-bash prettyprint-override"><code>alias git=&quot;HOME=~/my_name command git&quot; </code></pre> <p>and that is the best one I've seen so far, but I don't like that solution particularly much.</p> <p>Is it possible to query environment variables in an includeIf expression? Or is there some other approach to include if GIT_AUTHOR_NAME is set to a specific variable?</p>
[ { "answer_id": 74124624, "author": "jdobres", "author_id": 6436545, "author_profile": "https://Stackoverflow.com/users/6436545", "pm_score": 3, "selected": true, "text": "c_across" }, { "answer_id": 74124781, "author": "Anoushiravan R", "author_id": 14314520, "author_...
2022/10/19
[ "https://Stackoverflow.com/questions/74124572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15399131/" ]
74,124,580
<p>I am trying to query mongoDB collection to fetch and match a specific date range and a specific array of ids, such as brachIds, or servicesIds.</p> <p>I want the query if it finds this result to return it, so that i can validate if a request already exists in that collection by a specific user.</p> <p>But whenever I pass array values to the <code>$or [{}]</code> segment of the query, no result comes back when i use <code>$all</code></p> <p>what am I doing wrong?</p> <p>Below code that is working and retrieving the document:</p> <pre><code> db.collection(&quot;requests&quot;) .find({'filter.dateRange.from': {$eq: moment(from, &quot;YYYY-MM-DD&quot;).startOf('day').format(&quot;YYYY-MM-DD[T]HH:mm:ss.SSS[Z]&quot;)}, 'filter.dateRange.to': {$eq: moment(to, &quot;YYYY-MM-DD&quot;).startOf('day').format(&quot;YYYY-MM-DD[T]HH:mm:ss.SSS[Z]&quot;)}, $or: [{'filter.branchesIds': {$eq: branchesIds }},{'filter.groupOfBranchesIds': { $eq: servicesIds }},{'filter.servicesIds': {$eq: groupOfBranchesIds }}]}) .toArray() .then(result =&gt; { if (result.length) { resolve(result) } else { resolve(result) } }).catch(error =&gt; { console.log(error); }) </code></pre> <p>Below code using $all that makes the query not return any document:</p> <pre><code> let _branchIds = branchesIds || []; let _servicesIds = servicesIds || []; let _groupOfBranchesIds = groupOfBranchesIds || []; db.collection(&quot;requests&quot;) .find({'filter.dateRange.from': {$eq: moment(from, &quot;YYYY-MM-DD&quot;).startOf('day').format(&quot;YYYY-MM-DD[T]HH:mm:ss.SSS[Z]&quot;)}, 'filter.dateRange.to': {$eq: moment(to, &quot;YYYY-MM-DD&quot;).startOf('day').format(&quot;YYYY-MM-DD[T]HH:mm:ss.SSS[Z]&quot;)}, $or: [{'filter.branchesIds': {$all: _branchIds }},{'filter.groupOfBranchesIds': { $all: _servicesIds }},{'filter.servicesIds': {$all: _groupOfBranchesIds }}]}) .toArray() .then(result =&gt; { if (result.length) { resolve(result) } else { resolve(result) } }).catch(error =&gt; { console.log(error); }) </code></pre>
[ { "answer_id": 74126224, "author": "Amit Wagner", "author_id": 8585202, "author_profile": "https://Stackoverflow.com/users/8585202", "pm_score": 0, "selected": false, "text": "$or: [{'filter.branchesIds': {$in: branchesIds }},{'filter.groupOfBranchesIds': { $in: servicesIds }},{'filter.s...
2022/10/19
[ "https://Stackoverflow.com/questions/74124580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20231084/" ]
74,124,582
<p>I have the below code in a external script and when the condition is true the message echo's to the login screen (this works fine). As a test I want the submit button to be disabled too, but how to achieve that? The ID of the button is &quot;btn_input&quot;</p> <pre><code>if(txtboxval == &quot;&quot; || emailboxval == &quot;&quot;) { document.getElementById(&quot;announcement&quot;).innerHTML=&quot;This is a text!&quot;; return; } </code></pre> <p>Is this possible?</p>
[ { "answer_id": 74126224, "author": "Amit Wagner", "author_id": 8585202, "author_profile": "https://Stackoverflow.com/users/8585202", "pm_score": 0, "selected": false, "text": "$or: [{'filter.branchesIds': {$in: branchesIds }},{'filter.groupOfBranchesIds': { $in: servicesIds }},{'filter.s...
2022/10/19
[ "https://Stackoverflow.com/questions/74124582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17565869/" ]
74,124,617
<p>Please find the below entities :</p> <pre><code>public class Country { public int Id; public string name; public string code; } public class City { public int Id; public string name; public country {get;set;} } public class Person { public int Id; public string name; public DateTime dob; public string gender; public city {get;set;} } </code></pre> <p>I need to get all properties as string list as mentioned below:</p> <pre><code>&quot;Id&quot; &quot;name&quot; &quot;dob&quot; &quot;gender&quot; &quot;city.Id&quot; &quot;city.name&quot; &quot;city.country.Id&quot; &quot;city.country.name&quot; &quot;city.country.code&quot; </code></pre> <p>And my method to get property is</p> <pre><code>private List&lt;string&gt; GetProps(Type type) { var result=new List&lt;string&gt;(); var properties = type.GetProperties().ToDictionary(x =&gt; x, x =&gt; x.GetType().GetProperties()); foreach (var item in properties) { result.Add(item.Key.ToString()); } return result; } GetProps(typeof(Person)); // calling in main method; </code></pre> <p>The coming result is</p> <pre><code>&quot;Id&quot; &quot;name&quot; &quot;dob&quot; &quot;gender&quot; &quot;city&quot; </code></pre> <p>But my expected result is : &quot;Id&quot; &quot;name&quot; &quot;dob&quot; &quot;gender&quot; &quot;city.Id&quot; &quot;city.name&quot; &quot;city.country.Id&quot; &quot;city.country.name&quot; &quot;city.country.code&quot;</p> <p>Please help :)</p>
[ { "answer_id": 74126224, "author": "Amit Wagner", "author_id": 8585202, "author_profile": "https://Stackoverflow.com/users/8585202", "pm_score": 0, "selected": false, "text": "$or: [{'filter.branchesIds': {$in: branchesIds }},{'filter.groupOfBranchesIds': { $in: servicesIds }},{'filter.s...
2022/10/19
[ "https://Stackoverflow.com/questions/74124617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7030060/" ]
74,124,651
<p>Say that I have these dataframes:</p> <pre><code>SNPs &lt;- c('SNP1', 'SNP2', 'SNP3', 'SNP4', 'SNP5', 'SNP6') Basepair &lt;- c('75', '251', '643', '820', '952', '1455') df &lt;- data.frame(SNPs, Basepair) BP_start &lt;- c('0', '100', '200', '300', '400', '500', '600', '700', '800', '900', '1000', '1100', '1200', '1300', '1400', '1500', '1600') BP_end &lt;- c('100', '200', '300', '400', '500', '600', '700', '800', '900', '1000', '1100', '1200', '1300', '1400', '1500', '1600', '1700') sweep_nr &lt;- c(1:17) df_sweep &lt;- data.frame(BP_start, BP_end, sweep_nr) </code></pre> <p>And I want to merge the df_sweep dataframe with the df dataframe, so that there is a new column showing what sweep_nr the SNP is included in.</p> <p>Then, they'd have to merge based on ranges, since for example SNP1 is between BP_start == 0 and BP_end == 100, but I haven't found any way to do this kind of merge.</p>
[ { "answer_id": 74125055, "author": "qwertzuiop", "author_id": 18231984, "author_profile": "https://Stackoverflow.com/users/18231984", "pm_score": 1, "selected": false, "text": "df_sweep <- data.frame(BP_start, BP_end, sweep_nr) %>% map_df(as.numeric)\n\nfilter_range <- function(bp, df_sw...
2022/10/19
[ "https://Stackoverflow.com/questions/74124651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20281875/" ]
74,124,666
<p>I tried multiple ways to get the first level <code>&lt;li&gt;</code> elements but i couldn´t find the correct way.</p> <p>I´ve tried:</p> <pre><code>for item in soup_inicio.find_all('div',{'class':'menu'}): sub_items = item.find_all('li', {'class':'categories'}) for sub_item in sub_items: print(sub_item.text) </code></pre> <p>This is what i´m trying to scrape:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class = 'menu'&gt; &lt;ul class = 'navigation' id = "news_ul"&gt; &lt;li class = 'categories'&gt; A &lt;/li&gt; &lt;ul&gt; &lt;li class = 'categories'&gt; A1 &lt;/li&gt; &lt;li class = 'categories'&gt; A2 &lt;/li&gt; &lt;li class = 'categories'&gt; A3 &lt;/li&gt; &lt;/ul&gt; &lt;li class = 'categories'&gt; B &lt;/li&gt; &lt;ul&gt; &lt;li class = 'categories'&gt; B1 &lt;/li&gt; &lt;/ul&gt; &lt;li class = 'categories'&gt; C &lt;/li&gt; &lt;ul&gt; &lt;li class = 'categories'&gt; C1 &lt;/li&gt; &lt;li class = 'categories'&gt; C2 &lt;/li&gt; &lt;/ul&gt; &lt;li class = 'categories'&gt; D &lt;/li&gt; &lt;ul&gt; &lt;li class = 'categories'&gt; D1 &lt;/li&gt; &lt;/ul&gt;</code></pre> </div> </div> </p> <p>This gives me all <code>&lt;li&gt;</code> elements (A,A1,A2,A3,B,B1,C,C1,C2,D,D1)</p> <p>I would like to get only elements</p> <pre><code>&lt;li&gt;A&lt;/li&gt; &lt;li&gt;B&lt;/li&gt; &lt;li&gt;C&lt;/li&gt; &lt;li&gt;D&lt;/li&gt; </code></pre>
[ { "answer_id": 74124794, "author": "Yevhen Kuzmovych", "author_id": 4727702, "author_profile": "https://Stackoverflow.com/users/4727702", "pm_score": 2, "selected": true, "text": "recursive" }, { "answer_id": 74126476, "author": "floox", "author_id": 4455426, "author_...
2022/10/19
[ "https://Stackoverflow.com/questions/74124666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18466776/" ]
74,124,670
<p>I'm making a little ticker animation for my navbar but for some reason, the ticker doesn't move when I click on a NavLink. At first, I thought it was a problem with the CSS file but that seems to be working fine. I then tried using an older version of react-router-dom but that also didn't seem to work. Some help would be appreciated.</p> <p>As you can see, the 'active-nav' class is supposed to change to any NavLink that is Active &amp; the rest are left with empty quotation marks.</p> <p>Navbar.jsx:</p> <pre><code>import {Link, NavLink} from 'react-router-dom' import {links} from '../data' import {GoThreeBars} from 'react-icons/go' import Logo from '../images/logo.png' import &quot;./navbar.css&quot; const Navbar = () =&gt; { return ( &lt;nav&gt; &lt;div className='container nav__container'&gt; &lt;Link to=&quot;/&quot; className='logo'&gt; &lt;img src={Logo} alt=&quot;Nav Logo&quot;/&gt; &lt;/Link&gt; &lt;ul className=&quot;nav__links&quot;&gt; { links.map(({name, path}, index) =&gt; { return ( &lt;li&gt; &lt;NavLink to={path} className={({isActive}) =&gt; isActive ? 'active-nav' : ''}&gt;{name}&lt;/NavLink&gt; &lt;/li&gt; ) }) } &lt;/ul&gt; &lt;button className=&quot;nav__toggle-btn&quot;&gt; &lt;GoThreeBars /&gt; &lt;/button&gt; &lt;/div&gt; &lt;/nav&gt; ) } export default Navbar </code></pre> <ul> <li>Here you can see that most of the functionality is in the CSS</li> </ul> <p>navbar.css:</p> <pre><code>nav { height: 5rem; width: 100vw; background: var(--color-primary); display: grid; place-items: center; position: fixed; top: 0; left: 0; z-index: 99; } /* only shows on medium and small screens */ .nav__toggle-btn { display: none; } .nav__container { height: 100%; display: flex; justify-content: space-between; align-items: center; position: relative; width: 1920px; } .logo { width: 7rem; margin-right: 400px; } .nav__links { display: flex; gap: 3.5rem; } .nav__links a { transition: var(--transition); } .nav__links a:hover { color: var(--color--secondary); } .active-nav { position: relative; } .nav__links::after { content: ''; display: block; width: 1.2rem; height: 1.2rem; background: var(--color-primary); position: absolute; left: calc(50% - 0.6rem); transform: rotate(45deg); margin-top: 2.7rem; } </code></pre> <p>package.json</p> <pre><code>{ &quot;name&quot;: &quot;reactappblue&quot;, &quot;version&quot;: &quot;0.1.0&quot;, &quot;private&quot;: true, &quot;dependencies&quot;: { &quot;@testing-library/jest-dom&quot;: &quot;^5.16.5&quot;, &quot;@testing-library/react&quot;: &quot;^13.4.0&quot;, &quot;@testing-library/user-event&quot;: &quot;^13.5.0&quot;, &quot;react&quot;: &quot;^18.2.0&quot;, &quot;react-dom&quot;: &quot;^18.2.0&quot;, &quot;react-icons&quot;: &quot;^4.6.0&quot;, &quot;react-router-dom&quot;: &quot;^6.3.0&quot;, &quot;react-scripts&quot;: &quot;5.0.1&quot;, &quot;web-vitals&quot;: &quot;^2.1.4&quot; }, &quot;scripts&quot;: { &quot;start&quot;: &quot;react-scripts start&quot;, &quot;build&quot;: &quot;react-scripts build&quot;, &quot;test&quot;: &quot;react-scripts test&quot;, &quot;eject&quot;: &quot;react-scripts eject&quot; }, &quot;eslintConfig&quot;: { &quot;extends&quot;: [ &quot;react-app&quot;, &quot;react-app/jest&quot; ] }, &quot;browserslist&quot;: { &quot;production&quot;: [ &quot;&gt;0.2%&quot;, &quot;not dead&quot;, &quot;not op_mini all&quot; ], &quot;development&quot;: [ &quot;last 1 chrome version&quot;, &quot;last 1 firefox version&quot;, &quot;last 1 safari version&quot; ] } } </code></pre> <p>app.js:</p> <pre><code>import {BrowserRouter, Routes, Route} from 'react-router-dom' import Home from './pages/home/Home' import About from './pages/about/About' import Contact from './pages/contact/Contact' import Gallery from './pages/gallery/Gallery' import Plans from './pages/plans/Plans' import Trainers from './pages/trainers/Trainers' import NotFound from './pages/notfound/Notfound' import Navbar from './components/Navbar' import {BrowserRouter as Router} from 'react-router-dom' const App = () =&gt; { return ( &lt;BrowserRouter&gt; &lt;Navbar /&gt; &lt;Routes&gt; &lt;Route index element={&lt;Home/&gt;} /&gt; &lt;Route path=&quot;about&quot; element={&lt;About/&gt;} /&gt; &lt;Route path=&quot;contact&quot; element={&lt;Contact/&gt;} /&gt; &lt;Route path=&quot;gallery&quot; element={&lt;Gallery/&gt;} /&gt; &lt;Route path=&quot;plans&quot; element={&lt;Plans/&gt;} /&gt; &lt;Route path=&quot;trainers&quot; element={&lt;Trainers/&gt;} /&gt; &lt;Route path=&quot;*&quot; element={&lt;NotFound/&gt;} /&gt; &lt;/Routes&gt; &lt;/BrowserRouter&gt; ) } export default App </code></pre>
[ { "answer_id": 74124794, "author": "Yevhen Kuzmovych", "author_id": 4727702, "author_profile": "https://Stackoverflow.com/users/4727702", "pm_score": 2, "selected": true, "text": "recursive" }, { "answer_id": 74126476, "author": "floox", "author_id": 4455426, "author_...
2022/10/19
[ "https://Stackoverflow.com/questions/74124670", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14367514/" ]
74,124,716
<p>Given two classes with default parameters in their constructor:</p> <pre><code>class Foo( val baz: Boolean = false, ) class Bar( val baz: Boolean = false, ) </code></pre> <p>and an extension function to create <code>Bar</code>s from <code>Foo</code>s:</p> <pre><code>fun Foo.toBar() = Bar( baz, ) </code></pre> <p>How would I make sure not to forget to add new properties to <code>Foo</code>, whenever they are added to <code>Bar</code> (they also have default values)? The following compiles and passes all tests that I would have written at that point.</p> <pre><code>class Foo( val baz: Boolean = false, ) class Bar( val baz: Boolean = false, val newProp: Boolean = false, ) fun Foo.toBar() = Bar( baz, ) </code></pre> <p>Edit: It is important to note here that this question is really about DTO mapping, so the properties don't always have the same type.</p> <p>Adding a test only makes sure that properties added to <code>Foo</code> and <code>Bar</code> are not removed accidentally, because I would need to remember to modify the test, just as I need to remember to modify Foo.</p> <p>So, how would I make sure to notice I forgot to add something to Foo in the first place?</p>
[ { "answer_id": 74124717, "author": "dbt", "author_id": 6239575, "author_profile": "https://Stackoverflow.com/users/6239575", "pm_score": 0, "selected": false, "text": "@RequiresOptIn(\n message = \"This constructor uses default values. \" +\n \"This could be dangerous because i...
2022/10/19
[ "https://Stackoverflow.com/questions/74124716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6239575/" ]
74,124,732
<p>This is one of error getting class,</p> <pre><code>import com.bookingsite.acme.config.document.paymentoption.PaymentGatewayConfiguration; import com.bookingsite.acme.config.dto.paymentgatewaysearchrequest.PaymentGatewayConfigSearchRequestDTO; import com.bookingsite.acme.config.dto.paymentgatewaysearchrequest.PaymentOptionsDTO; import com.couchbase.client.java.query.dsl.Sort; import lombok.Getter; import lombok.Setter; import java.util.List; @Getter @Setter public class PaymentGatewaySearchData { private String searchQuery; private Sort sort; private int offset; private int limit; private int totalCount; private List&lt;PaymentGatewayConfiguration&gt; paymentGatewaySearchResponseList; private PaymentGatewayConfigSearchRequestDTO paymentGatewayConfigSearchRequestDTO; private List&lt;PaymentOptionsDTO&gt; paymentOptions; } </code></pre> <p>I Upgraded Spring boot version to 2.7.4 and currently we using Couchbase to SDK3 version.After that getting this error.</p> <p>other used methords</p> <pre><code>public Sort getOrderByQuery( PaymentTemplateConfigSearchFilterRequestDTO paymentTemplateConfigSearchFilterRequestDTO) { if (validateOrderBy(paymentTemplateConfigSearchFilterRequestDTO)) { if (paymentTemplateConfigSearchFilterRequestDTO.getSortDirection().equals(SortDirectionDTO.DESCENDING)) { return Sort.desc(paymentTemplateConfigSearchFilterRequestDTO.getSortBy().getAction()); } else { return Sort.asc(paymentTemplateConfigSearchFilterRequestDTO.getSortBy().getAction()); } } else { return Sort.desc(N1QlQueryConstants.TEMPLATEMODIFIEDDATE); } } </code></pre> <p><strong>What would be the best possible options?</strong></p>
[ { "answer_id": 74132377, "author": "dnault", "author_id": 611819, "author_profile": "https://Stackoverflow.com/users/611819", "pm_score": 2, "selected": false, "text": "com.couchbase.client.java.query.dsl.Sort" } ]
2022/10/19
[ "https://Stackoverflow.com/questions/74124732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11276607/" ]
74,124,745
<p>When initializing multiple variables in Python is seems that every variable is different (i.e. not a reference) :</p> <pre><code>&gt;&gt;&gt;x = y = z = 6 &gt;&gt;&gt;x=5 &gt;&gt;&gt;y=0 &gt;&gt;&gt;print(x,y,z) &gt;&gt;&gt;5 0 6 </code></pre> <p>but when I am using a numpy array every variable is actually a reference:</p> <pre><code>import numpy as np x = y = z = 6*np.ones(1) x[0] = 5 y[0] = 0 print(x,y,z) [0.] [0.] [0.] </code></pre> <p>Why am I seeing this difference?</p>
[ { "answer_id": 74132377, "author": "dnault", "author_id": 611819, "author_profile": "https://Stackoverflow.com/users/611819", "pm_score": 2, "selected": false, "text": "com.couchbase.client.java.query.dsl.Sort" } ]
2022/10/19
[ "https://Stackoverflow.com/questions/74124745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1877002/" ]
74,124,756
<p>I am trying to create a react app which on clicking an element in the sidebar component it automatically affects another element in the react app. But I have no idea on how to achieve this. Below ComponentOne is the body and ComponentTwo is the sidebar.</p> <p>The App.js file Containing all components:</p> <pre><code>import ComponentOne from &quot;./ComponentOne&quot; import ComponentTwo from &quot;./ComponentTwo&quot; export default function App(){ return( &lt;ComponentOne /&gt; &lt;ComponentTwo /&gt; ) } </code></pre> <p>In my ComponentOne:</p> <pre><code>export default ComponentOne(){ const [inputedText, setInputText]=useState('') const handleChange =(event)=&gt; { const newValue = event.target.value; setInputText(newValue); } const saveText=()=&gt;{ alert(&quot;Your text have been saved&quot;) } return( &lt;&gt; &lt;input type={text} value={inputedText} onChange={handleChange} /&gt; &lt;button onClick={saveText}&gt;Save text&lt;/button&gt; &lt;/&gt; ) } </code></pre> <p>In ComponentTwo which will be a sidebar: On clicking the list item &quot;Save Text&quot; it should automatically click the button in ComponentOne.</p> <pre><code>export default ComponentTwo(){ return( &lt;&gt; &lt;nav&gt; &lt;ul&gt; &lt;li&gt;Save Text&lt;/li&gt; &lt;/ul&gt; &lt;/nav&gt; &lt;/&gt; ) } </code></pre>
[ { "answer_id": 74124817, "author": "Mohamad Ahmadi", "author_id": 11039101, "author_profile": "https://Stackoverflow.com/users/11039101", "pm_score": 1, "selected": false, "text": "import ComponentOne from \"./ComponentOne\"\nimport ComponentTwo from \"./ComponentTwo\"\n\nexport default ...
2022/10/19
[ "https://Stackoverflow.com/questions/74124756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18774932/" ]
74,124,775
<p>I needed to filter models instances with custom function, and using</p> <pre><code>Post.objects.filter(func) </code></pre> <p>didnt help, I got a type error cause &quot;object is not iterable, so I went with</p> <pre><code> def filter_posts(x): if x.author in followed_author_list: return True else: return False </code></pre> <pre><code>posts = filter(filter_posts, Post.objects.all()) return render(request, 'main.html', {'posts':posts }) </code></pre> <p>And it worked, but now I cant reverse the list, cause I want to order it so newest will be last. If I use list() on it, then posts stop appearing on my website at all, cause I assume its not a different type?..</p> <p>Question is, how do I reverse filter class, or pull this off in general, so I get my posts filtered in reverse order?</p>
[ { "answer_id": 74124817, "author": "Mohamad Ahmadi", "author_id": 11039101, "author_profile": "https://Stackoverflow.com/users/11039101", "pm_score": 1, "selected": false, "text": "import ComponentOne from \"./ComponentOne\"\nimport ComponentTwo from \"./ComponentTwo\"\n\nexport default ...
2022/10/19
[ "https://Stackoverflow.com/questions/74124775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20120924/" ]
74,124,836
<p>I am performing file operations using <code>pathlib</code>, more or less like this:</p> <pre><code>for path in Path.cwd().glob(&quot;*.ipynb&quot;): print(path) </code></pre> <p>The problem is that these files are on an external drive that tends to disconnect randomly. As a result the glob iterator throws a <code>FileNotFoundError</code>. This is a mockup of what is happening:</p> <pre><code>def hdd_disconnection_mockup(): for i in range(3): if i == 1: raise FileNotFoundError yield f&quot;Untitled{i}.ipynb&quot; </code></pre> <pre><code>&gt;&gt;&gt; for path in hdd_disconnection_mockup(): print(path) Untitled0.ipynb FileNotFoundError: </code></pre> <p>I would like to catch this exception and continue the execution of the for loop.</p> <p>So far I have tried the following:</p> <pre><code>def catch_filenotfounderror(glob): try: yield next(glob) except FileNotFoundError: pass </code></pre> <p>No exception is thrown, but this does not prevent the glob iterator to break the for loop.</p> <pre><code>&gt;&gt;&gt; for path in catch_filenotfounderror(hdd_disconnection_mockup()): print(path) Untitled0.ipynb </code></pre> <p>The expected output is</p> <pre><code>Untitled0.ipynb Untitled2.ipynb </code></pre>
[ { "answer_id": 74126451, "author": "Michael Dorner", "author_id": 1864294, "author_profile": "https://Stackoverflow.com/users/1864294", "pm_score": 1, "selected": false, "text": "FileNotFoundError" }, { "answer_id": 74129252, "author": "edd313", "author_id": 12040751, ...
2022/10/19
[ "https://Stackoverflow.com/questions/74124836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12040751/" ]
74,124,852
<p>I need to make API inside the map function. code is not waiting to complete the map function loop when i use the setTimeout function. In this below code &quot;All api action completed&quot; log should show after completed the API call with setTimeout. kindly suggest the solution.</p> <pre><code> async function FieldMapping() { let data = [ { &quot;contractID&quot;: &quot;D3047-IND-001&quot;, &quot;fieldValues&quot;: { &quot;custrecord_vgicp_add_insurance_expense&quot;: &quot;3000&quot;, &quot;custrecord_vgicp_advancespaid&quot;: &quot;2000&quot;, &quot;custrecord_vgicp_allow_food_other&quot;: &quot;3000&quot; } }, { &quot;contractID&quot;: &quot;D3048-IND-003&quot;, &quot;fieldValues&quot;: { &quot;custrecord_vgicp_add_insurance_expense&quot;: &quot;3700&quot;, &quot;custrecord_vgicp_advancespaid&quot;: &quot;3700&quot;, &quot;custrecord_vgicp_allow_food_other&quot;: &quot;3700&quot; } }, { &quot;contractID&quot;: &quot;D3049-IND-001&quot;, &quot;fieldValues&quot;: { &quot;custrecord_vgicp_add_insurance_expense&quot;: &quot;3700&quot;, &quot;custrecord_vgicp_advancespaid&quot;: &quot;3700&quot;, &quot;custrecord_vgicp_allow_food_other&quot;: &quot;3700&quot; } }, { &quot;contractID&quot;: &quot;D3081-FRA-002&quot;, &quot;fieldValues&quot;: { &quot;custrecord_vgicp_add_insurance_expense&quot;: &quot;3700&quot;, &quot;custrecord_vgicp_advancespaid&quot;: &quot;3700&quot;, &quot;custrecord_vgicp_allow_food_other&quot;: &quot;3700&quot; } }, { &quot;contractID&quot;: &quot;D3106-IND-002&quot;, &quot;fieldValues&quot;: { &quot;custrecord_vgicp_add_insurance_expense&quot;: &quot;2000&quot;, &quot;custrecord_vgicp_advancespaid&quot;: &quot;2000&quot;, &quot;custrecord_vgicp_allow_food_other&quot;: &quot;2000&quot; } } ] await Promise.all(data.map(async(payroll, index)=&gt; { setTimeout(async () =&gt; { let result = await apiCall(payroll) console.log(&quot;result:::&quot;, result) }, 1000*index+1 ) })) console.log(&quot;All API Action completed...&quot;) } async function apiCall() { //api call here } </code></pre>
[ { "answer_id": 74126451, "author": "Michael Dorner", "author_id": 1864294, "author_profile": "https://Stackoverflow.com/users/1864294", "pm_score": 1, "selected": false, "text": "FileNotFoundError" }, { "answer_id": 74129252, "author": "edd313", "author_id": 12040751, ...
2022/10/19
[ "https://Stackoverflow.com/questions/74124852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16896772/" ]
74,124,865
<p>I have the following:</p> <pre><code>ID_REF,GSM2819484,GSM2819485,GSM2819486,GSM2819487,GSM2819488,GSM2819489,GSM2819490,GSM2819491,GSM2819492,GSM2819493,GSM2819494,GSM2819495,GSM2819496,GSM2819497,GSM2819498,GSM2819499,GSM2819500,GSM2819501,GSM2819502,GSM2819503,GSM2819504,GSM2819505,GSM2819506,GSM2819507,GSM2819508,GSM2819509,GSM2819510,GSM2819511,GSM2819512,GSM2819513,GSM2819514,GSM2819515,GSM2819516,GSM2819517,GSM2819518,GSM2819519,GSM2819520,GSM2819521,GSM2819522,GSM2819523,GSM2819524,GSM2819525,GSM2819526,GSM2819527,GSM2819528,GSM2819529,GSM2819530,GSM2819531,GSM2819532,GSM2819533,GSM2819534,GSM2819535,GSM2819536,GSM2819537,GSM2819538,GSM2819539,GSM2819540,GSM2819541,GSM2819542,GSM2819543,GSM2819544,GSM2819545,GSM2819546,GSM2819547,GSM2819548,GSM2819549,GSM2819550,GSM2819551,GSM2819552,GSM2819553,GSM2819554,GSM2819555,GSM2819556,GSM2819557,GSM2819558,GSM2819559,GSM2819560,GSM2819561,GSM2819562,GSM2819563,GSM2819564,GSM2819571,GSM2819572,GSM2819573,GSM2819574,GSM2819575,GSM2819576,GSM2819577,GSM2819578,GSM2819579,GSM2819580,GSM2819581,GSM2819582,GSM2819583,GSM2819584,GSM2819585,GSM2819586,GSM2819587,GSM2819588,GSM2819589,GSM2819590,GSM2819591,GSM2819592,GSM2819593,GSM2819594,GSM2819595,GSM2819596 </code></pre> <p>Why is this code not working?</p> <pre><code>awk 'BEGIN { FS=&quot;,&quot;;OFS= &quot; &quot;}{print $0}' file </code></pre> <p>Also, how can I skip printing &quot;ID_REF&quot;?</p> <p>Desired output:</p> <pre><code>GSM2819484 GSM2819485 GSM2819486 GSM2819487 GSM2819488 GSM2819489 GSM2819490 GSM2819491 GSM2819492 GSM2819493 GSM2819494 GSM2819495 GSM2819496 GSM2819497 GSM2819498 GSM2819499 GSM2819500 GSM2819501 GSM2819502 GSM2819503 GSM2819504 GSM2819505 GSM2819506 GSM2819507 GSM2819508 GSM2819509 GSM2819510 GSM2819511 GSM2819512 GSM2819513 GSM2819514 GSM2819515 GSM2819516 GSM2819517 GSM2819518 GSM2819519 GSM2819520 GSM2819521 GSM2819522 GSM2819523 GSM2819524 GSM2819525 GSM2819526 GSM2819527 GSM2819528 GSM2819529 GSM2819530 GSM2819531 GSM2819532 GSM2819533 GSM2819534 GSM2819535 GSM2819536 GSM2819537 GSM2819538 GSM2819539 GSM2819540 GSM2819541 GSM2819542 GSM2819543 GSM2819544 GSM2819545 GSM2819546 GSM2819547 GSM2819548 GSM2819549 GSM2819550 GSM2819551 GSM2819552 GSM2819553 GSM2819554 GSM2819555 GSM2819556 GSM2819557 GSM2819558 GSM2819559 GSM2819560 GSM2819561 GSM2819562 GSM2819563 GSM2819564 GSM2819571 GSM2819572 GSM2819573 GSM2819574 GSM2819575 GSM2819576 GSM2819577 GSM2819578 GSM2819579 GSM2819580 GSM2819581 GSM2819582 GSM2819583 GSM2819584 GSM2819585 GSM2819586 GSM2819587 GSM2819588 GSM2819589 GSM2819590 GSM2819591 GSM2819592 GSM2819593 GSM2819594 GSM2819595 GSM2819596 </code></pre>
[ { "answer_id": 74124935, "author": "anubhava", "author_id": 548225, "author_profile": "https://Stackoverflow.com/users/548225", "pm_score": 3, "selected": true, "text": "awk -F, '{sub(/^[^,]*,/, \"\"); $1=$1} 1' file\n\nGSM2819484 GSM2819485 GSM2819486 GSM2819487 GSM2819488 GSM2819489 GS...
2022/10/19
[ "https://Stackoverflow.com/questions/74124865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8223979/" ]
74,124,880
<p>How does one change the size of the points only in a ggplot2 legend? I want them to remain the size I have in the plot code, but to appear bigger in the legend.</p> <p>My plot code is here:</p> <pre><code>ggplot(df, aes(x=log(length), y=log(wt), shape=Depth,fill=Depth,color=Depth, linetype=Depth)) + geom_point(aes(),size=2,alpha=1,stroke=1.3) + geom_smooth(method=lm, se=FALSE, fullrange=FALSE) + facet_wrap(~ LakeYear, nrow=3, ncol=2) + labs(x=&quot;ln Length (mm)&quot;, y=&quot;ln Weight (mg)&quot;) + scale_fill_manual(values=cbPalette2,name=&quot;Depth&quot;)+ scale_color_manual(values=cbPalette,name=&quot;Depth&quot;) + scale_shape_manual(values=c(16,15,21,18),name=&quot;Depth&quot;)+ scale_linetype_manual(values =c(&quot;&lt;5 m&quot;=&quot;solid&quot;, &quot;10-15 m&quot;=&quot;solid&quot;, &quot;15-20 m&quot;=&quot;solid&quot;,&quot;&gt;20 m&quot;=&quot;dashed&quot;),name=&quot;Depth&quot;)+ PlotTheme + theme(panel.spacing.x=unit(1.4, &quot;lines&quot;),panel.spacing.y=unit(1, &quot;lines&quot;),legend.title=element_text(size=16)) </code></pre> <p>I have tried to add <code>+ guides(color = guide_legend(override.aes = list(size=3)))</code> and <code>+ guides(shape = guide_legend(override.aes = list(size = 2))) </code> but this just changes the line size. I have tried some code I found from an example <a href="https://stackoverflow.com/questions/15059093/ggplot2-adjust-the-symbol-size-in-legends">here</a></p> <pre><code># Make JUST the legend points larger without changing the size of the legend lines: # To get a list of the names of all the grobs in the ggplot g grid::grid.ls(grid::grid.force()) # Set the size of the point in the legend to 2 mm grid::grid.gedit(&quot;key-[-0-9]-1-1&quot;, size = unit(4, &quot;mm&quot;)) </code></pre> <p>but I just get the error: &quot;In editThisGrob(child, specs) : slot 'size' not found&quot; so I'm assuming the key is wrong, but I can't figure out which from the list of all the grobs to use here. the list is here:</p> <blockquote> </blockquote> <pre><code> grid::grid.ls(grid::grid.force()) layout background.1-15-23-1 plot.background..rect.6707 panel-1-1.8-5-8-5 panel-1.gTree.6397 grill.gTree.6395 panel.background..rect.6386 panel.grid.minor.y..polyline.6388 panel.grid.minor.x..polyline.6390 panel.grid.major.y..polyline.6392 panel.grid.major.x..polyline.6394 NULL geom_point.points.6337 geom_smooth.gTree.6353 GRID.polyline.6348 GRID.polyline.6349 GRID.polyline.6350 GRID.polyline.6351 NULL panel.border..rect.6383 panel-2-1.13-5-13-5 panel-3.gTree.6429 grill.gTree.6427 panel.background..rect.6418 panel.grid.minor.y..polyline.6420 panel.grid.minor.x..polyline.6422 panel.grid.major.y..polyline.6424 panel.grid.major.x..polyline.6426 NULL geom_point.points.6341 geom_smooth.gTree.6365 GRID.polyline.6360 GRID.polyline.6361 GRID.polyline.6362 GRID.polyline.6363 NULL panel.border..rect.6415 panel-1-2.18-5-18-5 panel-5.gTree.6461 grill.gTree.6459 panel.background..rect.6450 panel.grid.minor.y..polyline.6452 panel.grid.minor.x..polyline.6454 panel.grid.major.y..polyline.6456 panel.grid.major.x..polyline.6458 NULL geom_point.points.6345 geom_smooth.gTree.6376 GRID.polyline.6372 GRID.polyline.6373 GRID.polyline.6374 NULL panel.border..rect.6447 panel-2-2.8-9-8-9 panel-2.gTree.6413 grill.gTree.6411 panel.background..rect.6402 panel.grid.minor.y..polyline.6404 panel.grid.minor.x..polyline.6406 panel.grid.major.y..polyline.6408 panel.grid.major.x..polyline.6410 NULL geom_point.points.6339 geom_smooth.gTree.6359 GRID.polyline.6354 GRID.polyline.6355 GRID.polyline.6356 GRID.polyline.6357 NULL panel.border..rect.6399 panel-1-3.13-9-13-9 panel-4.gTree.6445 grill.gTree.6443 panel.background..rect.6434 panel.grid.minor.y..polyline.6436 panel.grid.minor.x..polyline.6438 panel.grid.major.y..polyline.6440 panel.grid.major.x..polyline.6442 NULL geom_point.points.6343 geom_smooth.gTree.6371 GRID.polyline.6366 GRID.polyline.6367 GRID.polyline.6368 GRID.polyline.6369 NULL panel.border..rect.6431 panel-2-3.18-9-18-9 panel-6.gTree.6477 grill.gTree.6475 panel.background..rect.6466 panel.grid.minor.y..polyline.6468 panel.grid.minor.x..polyline.6470 panel.grid.major.y..polyline.6472 panel.grid.major.x..polyline.6474 NULL geom_point.points.6347 geom_smooth.gTree.6381 GRID.polyline.6377 GRID.polyline.6378 GRID.polyline.6379 NULL panel.border..rect.6463 strip-t-1-3.17-5-17-5 strip strip.1-1-1-1 strip.gTree.6555 strip.background.x..rect.6545 strip.text.x.top..titleGrob.6540 GRID.text.6538 strip-t-2-3.17-9-17-9 strip strip.1-1-1-1 strip.gTree.6557 strip.background.x..rect.6545 strip.text.x.top..titleGrob.6543 GRID.text.6541 strip-t-1-2.12-5-12-5 strip strip.1-1-1-1 strip.gTree.6551 strip.background.x..rect.6545 strip.text.x.top..titleGrob.6534 GRID.text.6532 strip-t-2-2.12-9-12-9 strip strip.1-1-1-1 strip.gTree.6553 strip.background.x..rect.6545 strip.text.x.top..titleGrob.6537 GRID.text.6535 strip-t-1-1.7-5-7-5 strip strip.1-1-1-1 strip.gTree.6547 strip.background.x..rect.6545 strip.text.x.top..titleGrob.6528 GRID.text.6526 strip-t-2-1.7-9-7-9 strip strip.1-1-1-1 strip.gTree.6549 strip.background.x..rect.6545 strip.text.x.top..titleGrob.6531 GRID.text.6529 axis-t-1-3.16-5-16-5 NULL axis-t-2-3.16-9-16-9 NULL axis-t-1-2.11-5-11-5 NULL axis-t-2-2.11-9-11-9 NULL axis-t-1-1.6-5-6-5 NULL axis-t-2-1.6-9-6-9 NULL axis-b-1-3.19-5-19-5 GRID.absoluteGrob.6481 NULL axis axis.1-1-1-1 GRID.polyline.6480 axis.2-1-2-1 GRID.titleGrob.6479 GRID.text.6478 axis-b-2-3.19-9-19-9 GRID.absoluteGrob.6481 NULL axis axis.1-1-1-1 GRID.polyline.6480 axis.2-1-2-1 GRID.titleGrob.6479 GRID.text.6478 axis-b-1-2.14-5-14-5 NULL axis-b-2-2.14-9-14-9 NULL axis-b-1-1.9-5-9-5 NULL axis-b-2-1.9-9-9-9 NULL axis-l-1-2.8-8-8-8 NULL axis-l-2-2.13-8-13-8 NULL axis-l-3-2.18-8-18-8 NULL axis-l-1-1.8-4-8-4 GRID.absoluteGrob.6505 NULL axis axis.1-1-1-1 GRID.titleGrob.6503 GRID.text.6502 axis.1-2-1-2 GRID.polyline.6504 axis-l-2-1.13-4-13-4 GRID.absoluteGrob.6505 NULL axis axis.1-1-1-1 GRID.titleGrob.6503 GRID.text.6502 axis.1-2-1-2 GRID.polyline.6504 axis-l-3-1.18-4-18-4 GRID.absoluteGrob.6505 NULL axis axis.1-1-1-1 GRID.titleGrob.6503 GRID.text.6502 axis.1-2-1-2 GRID.polyline.6504 axis-r-1-2.8-10-8-10 NULL axis-r-2-2.13-10-13-10 NULL axis-r-3-2.18-10-18-10 NULL axis-r-1-1.8-6-8-6 NULL axis-r-2-1.13-6-13-6 NULL axis-r-3-1.18-6-18-6 NULL xlab-t.5-9-5-5 NULL xlab-b.20-9-20-5 axis.title.x.bottom..titleGrob.6656 GRID.text.6654 ylab-l.8-3-18-3 axis.title.y.left..titleGrob.6659 GRID.text.6657 ylab-r.8-11-18-11 NULL guide-box.8-13-18-13 guide-box legend.box.background.2-4-4-2 NULL guides.3-3-3-3 layout background.1-6-8-1 legend.background..rect.6696 title.2-5-2-2 GRID.gTree.6697 guide.title.titleGrob.6662 GRID.text.6660 key-3-1-bg.4-2-4-2 legend.key..rect.6676 key-3-1-1.4-2-4-2 GRID.points.6677 key-3-1-2.4-2-4-2 GRID.gTree.6678 GRID.segments.6679 key-4-1-bg.5-2-5-2 legend.key..rect.6681 key-4-1-1.5-2-5-2 GRID.points.6682 key-4-1-2.5-2-5-2 GRID.gTree.6683 GRID.segments.6684 key-5-1-bg.6-2-6-2 legend.key..rect.6686 key-5-1-1.6-2-6-2 GRID.points.6687 key-5-1-2.6-2-6-2 GRID.gTree.6688 GRID.segments.6689 key-6-1-bg.7-2-7-2 legend.key..rect.6691 key-6-1-1.7-2-7-2 GRID.points.6692 key-6-1-2.7-2-7-2 GRID.gTree.6693 GRID.segments.6694 label-3-3.4-4-4-4 GRID.gTree.6698 guide.label.titleGrob.6665 GRID.text.6663 label-4-3.5-4-5-4 GRID.gTree.6699 guide.label.titleGrob.6668 GRID.text.6666 label-5-3.6-4-6-4 GRID.gTree.6700 guide.label.titleGrob.6671 GRID.text.6669 label-6-3.7-4-7-4 GRID.gTree.6701 guide.label.titleGrob.6674 GRID.text.6672 subtitle.4-9-4-5 plot.subtitle..zeroGrob.6703 title.3-9-3-5 plot.title..zeroGrob.6702 caption.21-9-21-5 plot.caption..zeroGrob.6705 tag.2-2-2-2 plot.tag..zeroGrob.6704 </code></pre> <p>Reproducible data here:</p> <pre><code>df&lt;-structure(list(length = c(11, 12, 11, 11.5, 10.5, 13, 14.5, 14, 13.5, 14.5, 16, 17, 16, 15, 16.5, 19.5, 17, 18, 18, 18, 21, 22, 22, 21, 25, 21.5, 12, 11, 11, 11, 12, 14, 14, 13, 15, 15, 17, 17, 18, 17, 17, 15, 18, 19, 18, 18, 18, 20, 20, 21.5, 21, 20.5, 19, 10, 10, 10, 11, 10, 14, 14, 14, 12, 12, 16, 15, 15, 16, 14.5, 17, 19, 17.5, 18, 16, 21, 20), wt = c(29.93, 36.62, 33.43, 26.19, 29.67, 47.1, 65.19, 53.49, 44.99, 73.23, 77.9, 84.43, 86.32, 92.27, 103.75, 169.24, 101.62, 90.84, 148.23, 104.87, 181.57, 206.07, 260.59, 218.19, 342.74, 142.64, 40.92, 29.82, 26.09, 30.9, 41.24, 48.46, 65.48, 48.97, 70.79, 72.81, 87.81, 82.07, 118.5, 83.5, 73.91, 73.04, 129.38, 117.68, 117.14, 110.19, 91.55, 126.26, 131.6, 200.63, 179.75, 169.95, 107.1, 32.99, 24.79, 27.12, 30.12, 17.89, 48.93, 53.61, 48.38, 35.52, 34.6, 85.03, 61.42, 54.22, 71.06, 71.91, 86.84, 85.96, 126.16, 135.9, 73.39, 138.03, 207.45), Depth = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L), .Label = c(&quot;&lt;5 m&quot;, &quot;10-15 m&quot;, &quot;15-20 m&quot;, &quot;&gt;20 m&quot;), class = &quot;factor&quot;), LakeYear = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c(&quot;one - 1995&quot;, &quot;two - 1993&quot;, &quot;three - 1999&quot;, &quot;four - 2015&quot;, &quot;five - 2019&quot;, &quot;six - 2019&quot;), class = &quot;factor&quot;)), row.names = c(NA, 75L), class = &quot;data.frame&quot;) </code></pre> <p>Any thoughts on making this work, or a simpler solution?</p> <p>Edit: Not a duplicate question, I highlighted other posts and said their solutions don't work for me.</p> <p>Original Plot here: <a href="https://i.stack.imgur.com/adkme.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/adkme.png" alt="enter image description here" /></a></p> <p>Added either</p> <pre><code> p+ guides(color = guide_legend(override.aes = list(size=5))) p+ guides(shape = guide_legend(override.aes = list(size = 5))) </code></pre> <p>I get this, without the actual shape changed, only the line <a href="https://i.stack.imgur.com/Ej42y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ej42y.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74128633, "author": "tjebo", "author_id": 7941188, "author_profile": "https://Stackoverflow.com/users/7941188", "pm_score": -1, "selected": false, "text": "library(tidyverse)\nlibrary(patchwork)\n\n## df <- ... your data df\n\n## your plot, simplified\np <- ggplot(df, aes(...
2022/10/19
[ "https://Stackoverflow.com/questions/74124880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3490557/" ]
74,124,899
<p>When I run <code>!python -V</code>, in jupyterlab I have Python 3.8.13</p> <p>When I run <code>!py -V</code>, also in jupyter I have this time Python 3.10.7</p> <p>When I run <code>python -V</code> and <code>py -V</code> in Powershell I have Python 3.10.7</p> <p>When I run</p> <pre><code>import sys print(sys.executable) print(sys.version) print(sys.version_info) </code></pre> <p>I have <code>3.10.7 (tags/v3.10.7:6cc6b13, Sep 5 2022, 14:08:36) [MSC v.1933 64 bit (AMD64)] sys.version_info(major=3, minor=10, micro=7, releaselevel='final', serial=0)</code></p> <p>Could you tell me why the first one is different from the others?</p> <p>I think it has to be an issue with conda version but I don't know where it comes from.</p> <p>Thanks</p>
[ { "answer_id": 74126792, "author": "H4iku", "author_id": 1825964, "author_profile": "https://Stackoverflow.com/users/1825964", "pm_score": 3, "selected": true, "text": "!python -V" }, { "answer_id": 74127353, "author": "pts", "author_id": 97248, "author_profile": "htt...
2022/10/19
[ "https://Stackoverflow.com/questions/74124899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15820854/" ]
74,124,900
<p>I have this kind of data frame</p> <p><code>df = pd.DataFrame(data={'Name': ['a1', 'a2','a1'], 'Quantity': [8,4,5], Order: [1,1,2], 'Result': [0,0,0]})</code></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Name</th> <th>Quantity</th> <th>Order</th> <th>Result</th> </tr> </thead> <tbody> <tr> <td>a1</td> <td>8</td> <td>1</td> <td>0</td> </tr> <tr> <td>a2</td> <td>4</td> <td>1</td> <td>0</td> </tr> <tr> <td>a1</td> <td>5</td> <td>2</td> <td>0</td> </tr> </tbody> </table> </div> <p>I would like to distribute a number, N=10, over the rows of the data frame according:</p> <ol> <li>Quantity -&gt; each name should receive, when possible, at most what is asking in Quantity</li> <li>by satisfying the Order --&gt; that is the order inside each group of Name</li> </ol> <p>The desired result should be:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Name</th> <th>Quantity</th> <th>Order</th> <th>Result</th> </tr> </thead> <tbody> <tr> <td>a1</td> <td>8</td> <td>1</td> <td>8</td> </tr> <tr> <td>a2</td> <td>4</td> <td>1</td> <td>2</td> </tr> <tr> <td>a1</td> <td>5</td> <td>2</td> <td>0</td> </tr> </tbody> </table> </div> <p>Therefore, first I try to satisfy the Name = a1 <strong>Order = 1</strong> by giving 8, then Name = a2 <strong>Order = 1</strong> by giving only 2 since is what is remaining from the initial N = 10. The Name = a1 <strong>Order = 2</strong> will not get anything.</p> <p>The only way I found to solve that problem is:</p> <ol> <li>An initial groupby on Name, to get the key names of all the groups (only two, a1 and a2, in the example)</li> <li>Two nested for loop, the inner on the Name, the outer on the Order, until N = 0</li> </ol> <p>Is there a way to avoid the for loops by using some pandas vectorised functions?</p>
[ { "answer_id": 74126792, "author": "H4iku", "author_id": 1825964, "author_profile": "https://Stackoverflow.com/users/1825964", "pm_score": 3, "selected": true, "text": "!python -V" }, { "answer_id": 74127353, "author": "pts", "author_id": 97248, "author_profile": "htt...
2022/10/19
[ "https://Stackoverflow.com/questions/74124900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11597613/" ]
74,124,909
<p>Hello every Body</p> <p>I have a table like this in SQL:</p> <p><a href="https://i.stack.imgur.com/u5Bh8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u5Bh8.png" alt="I have a table like this in SQL:" /></a></p> <p>I need to write SQL query to get the result as the following:</p> <p><a href="https://i.stack.imgur.com/uSgri.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uSgri.png" alt="I need to write SQL query to get the result as the following: " /></a></p> <p>Thanks for any help in advance</p>
[ { "answer_id": 74126792, "author": "H4iku", "author_id": 1825964, "author_profile": "https://Stackoverflow.com/users/1825964", "pm_score": 3, "selected": true, "text": "!python -V" }, { "answer_id": 74127353, "author": "pts", "author_id": 97248, "author_profile": "htt...
2022/10/19
[ "https://Stackoverflow.com/questions/74124909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7832516/" ]
74,124,931
<p>So, I have two datasets, such that all the columns in one dataset is present in the other, along with some extra columns. What I want to do is to create a new dataset of the differences between the entries in common columns, on the basis of matching a common identifier column, present in both the datasets. How can I do that in R? If it were a single column, I could have used the sqldf function as</p> <pre><code>sqldf(&quot;select a.v1 - b.v1 from ds1 a left join ds2 b on a.identifier=b.identifier&quot;) </code></pre> <p>But there are 900 common columns between both the datasets.</p>
[ { "answer_id": 74126792, "author": "H4iku", "author_id": 1825964, "author_profile": "https://Stackoverflow.com/users/1825964", "pm_score": 3, "selected": true, "text": "!python -V" }, { "answer_id": 74127353, "author": "pts", "author_id": 97248, "author_profile": "htt...
2022/10/19
[ "https://Stackoverflow.com/questions/74124931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7549745/" ]
74,124,939
<p>In line 6(alternative 8). <strong>I am getting an error if I use value of range(lens), but if I reduce the value of range(lens-1). I am getting an error and not the correct answer.</strong></p> <p>For example, for the input &quot;III&quot;, I should be getting the value 3, but instead I get the value 2. And for the input &quot;MCMXCIV&quot;, I am getting the value 2294 instead of 1994.</p> <p>In both instances, the last numeral is being skipped out. How to get without causing string index out of range?</p> <p>And Can someone point out what's going on wrong here?</p> <pre><code>def romanToInt( s: str) -&gt; int: lens = len(s) ans = 0 i = 0 while (i != lens): #for i in range(lens): print(i) print(s[i]) if(s[i] == 'I' ): if(s[i+1] == 'V'): ans = ans + 4 i += 1 elif(s[i+1] == 'X' ): ans = ans + 9 i += 1 else: ans +=1 elif(s[i] == 'V' ): ans += 5 elif(s[i] == 'X' ): if(s[i+1] == 'L'): ans += 40 i += 1 elif(s[i+1] == 'C'): ans += 90 i +=1 else: ans += 10 elif(s[i] == 'L' ): ans += 50 elif(s[i] == 'C' ): if(s[i+1] == 'D'): ans += 400 i += 1 elif(s[i+1] == 'C'): ans += 900 i +=1 else: ans += 100 elif(s[i] == 'D' ): ans += 500 elif(s[i] == 'M' ): ans += 1000 i += 1 return ans if __name__ == &quot;__main__&quot;: a = romanToInt(&quot;III&quot;) print(a) b = romanToInt(&quot;MCMXCIV&quot;) print(b) </code></pre>
[ { "answer_id": 74125046, "author": "Deniz Kaplan", "author_id": 2474573, "author_profile": "https://Stackoverflow.com/users/2474573", "pm_score": 0, "selected": false, "text": "i" } ]
2022/10/19
[ "https://Stackoverflow.com/questions/74124939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20282060/" ]
74,124,967
<p>i'm a begginner developer and the app in question is a test app for an api, from jkutner's tutorial on github. it is crashing as soon as it opens, which is weird, because i've used this exact same code at least thrice and it used to work. i'll leave the code and the logcat below, thank you in advance for your help!</p> <p>MainActivity</p> <pre><code>package com.example.myapplication; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import java.util.List; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; public class MainActivity extends AppCompatActivity { final EditText isbnInput = (EditText) findViewById(R.id.isbnInput); final TextView textView = (TextView) findViewById(R.id.textView); final Button button = (Button) findViewById(R.id.button); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Retrofit retrofit = new Retrofit.Builder() .baseUrl(&quot;https://venusdove.herokuapp.com&quot;) .addConverterFactory(GsonConverterFactory.create()) .build(); final BookService service = retrofit.create(BookService.class); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Book book = new Book(isbnInput.getText().toString()); Call&lt;Book&gt; createCall = service.create(book); createCall.enqueue(new Callback&lt;Book&gt;() { @Override public void onResponse(Call&lt;Book&gt; _, Response&lt;Book&gt; resp) { Book newBook = resp.body(); textView.setText(&quot;Created Book with ISBN: &quot; + newBook.isbn); } @Override public void onFailure(Call&lt;Book&gt; _, Throwable t) { t.printStackTrace(); textView.setText(t.getMessage()); } }); } }); } } </code></pre> <p>Book class</p> <pre><code>package com.example.myapplication; import com.google.gson.annotations.SerializedName; public class Book { @SerializedName(&quot;id&quot;) int id; @SerializedName(&quot;isbn&quot;) String isbn; public Book(int id, String isbn) { this.id = id; this.isbn = isbn; } public Book(String isbn) { this.isbn = isbn; } } </code></pre> <p>BookService class</p> <pre><code>package com.example.myapplication; import java.util.List; import retrofit2.Call; import retrofit2.http.Body; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.Path; public interface BookService { @GET(&quot;books&quot;) Call&lt;List&lt;Book&gt;&gt; all(); @GET(&quot;books/{isbn}&quot;) Call&lt;Book&gt; get(@Path(&quot;isbn&quot;) String isbn); @POST(&quot;books/new&quot;) Call&lt;Book&gt; create(@Body Book book); } </code></pre> <p>logcat</p> <pre><code>2022-10-19 08:56:03.651 8041-8041/com.example.myapplication E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.myapplication, PID: 8041 java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2679) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' on a null object reference at android.content.ContextWrapper.getApplicationInfo(ContextWrapper.java:152) at android.view.ContextThemeWrapper.getTheme(ContextThemeWrapper.java:157) at android.content.Context.obtainStyledAttributes(Context.java:655) at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:852) at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:819) at androidx.appcompat.app.AppCompatDelegateImpl.findViewById(AppCompatDelegateImpl.java:640) at androidx.appcompat.app.AppCompatActivity.findViewById(AppCompatActivity.java:261) at com.example.myapplication.MainActivity.&lt;init&gt;(MainActivity.java:22) at java.lang.Class.newInstance(Native Method) at android.app.Instrumentation.newActivity(Instrumentation.java:1174) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)  at android.app.ActivityThread.-wrap11(Unknown Source:0)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:164)  at android.app.ActivityThread.main(ActivityThread.java:6494)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) </code></pre>
[ { "answer_id": 74125046, "author": "Deniz Kaplan", "author_id": 2474573, "author_profile": "https://Stackoverflow.com/users/2474573", "pm_score": 0, "selected": false, "text": "i" } ]
2022/10/19
[ "https://Stackoverflow.com/questions/74124967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20282034/" ]
74,124,974
<p>This is the iframe (a <strong>chatbot html</strong> page) , which I am calling in another HTML project. So, i need to toggle the classes (shown below) <strong>as an <em>onclick</em> event or by any other functions</strong></p> <p><strong>chatbot html page=&gt;</strong> there is a logo, which I placed in bottom right and when someone clicking on that logo, a <strong>form</strong> div is opening... this project I'm calling in another project inside iframe</p> <pre><code> &lt;iframe id=&quot;overlayDiv&quot; class=&quot;overlayDiv&quot; src=&quot;http://127.0.0.1:5501/index.html&quot; frameborder=&quot;0&quot;&lt;/iframe&gt; </code></pre> <p><strong>classes for toggling</strong></p> <pre><code>&lt;style&gt; .overlayDiv { border: 1px solid red; z-index: 999; position: fixed; right: 0; bottom: 0; height: 91px; width: 92px; cursor: pointer; } .overlayDivActive { height: 470px; width: 390px; position: fixed; right: 0; bottom: 0; z-index: 999; border: 1px solid red; } &lt;/style&gt; </code></pre> <p><em>for that , below functionality is not working</em></p> <pre><code>$(document).ready(() =&gt; { $('#overlayDiv').click(function (e) { $('#overlayDiv').toggleClass('overlayDivActive') }) }) </code></pre>
[ { "answer_id": 74125046, "author": "Deniz Kaplan", "author_id": 2474573, "author_profile": "https://Stackoverflow.com/users/2474573", "pm_score": 0, "selected": false, "text": "i" } ]
2022/10/19
[ "https://Stackoverflow.com/questions/74124974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18151051/" ]
74,125,014
<p>I have a Material Angular Stepper (here a <a href="https://stackblitz.com/edit/angular-ivy-h5tx1j?file=src/app/app.component.html" rel="nofollow noreferrer">stackblitz running example</a>) and I would like to reset the form on each step when the step is loaded. I found in the <a href="https://material.angular.io/components/stepper/api" rel="nofollow noreferrer">Material Angular docs</a> that we can use <code>reset()</code> method on <code>MatStep</code> to</p> <blockquote> <p>Resets the step to its initial state. Note that this includes resetting form data.</p> </blockquote> <p>But, each time I call this method, it generates an error : <code>Error: list is undefined</code></p> <p>Here, a <a href="https://stackblitz.com/edit/angular-ivy-h5tx1j?file=src/app/app.component.html" rel="nofollow noreferrer">stackblitz running example</a></p> <p>app.component.html,</p> <pre class="lang-html prettyprint-override"><code>&lt;h1&gt;{{ name }}&lt;/h1&gt; &lt;hr /&gt; &lt;mat-stepper #stepper class=&quot;flex-grow-1&quot; (selectionChange)=&quot;reloadStep($event)&quot; &gt; &lt;mat-step #s1&gt; &lt;ng-template matStepLabel&gt;Username&lt;/ng-template&gt; &lt;ng-template matStepContent&gt; &lt;form&gt; &lt;input type=&quot;text&quot; placeholder=&quot;Username&quot; /&gt; &lt;/form&gt; &lt;/ng-template&gt; &lt;/mat-step&gt; &lt;mat-step #s2&gt; &lt;ng-template matStepLabel&gt;Something else &lt;/ng-template&gt; &lt;ng-template matStepContent&gt; &lt;form&gt; &lt;input type=&quot;text&quot; placeholder=&quot;Something else ...&quot; /&gt; &lt;/form&gt; &lt;/ng-template&gt; &lt;/mat-step&gt; &lt;/mat-stepper&gt; </code></pre> <p>app.component.ts,</p> <pre class="lang-js prettyprint-override"><code>import { Component, AfterViewInit, ViewChildren} from '@angular/core'; import { MatStepper, MatStep } from '@angular/material/stepper'; import { StepperSelectionEvent } from '@angular/cdk/stepper'; @Component({ selector: 'my-app', templateUrl: './app.component.html', styleUrls: ['./app.component.css'], }) export class AppComponent implements AfterViewInit { name = &quot;Material Angular Stepper&quot;; @ViewChildren('stepper') stepper!: MatStepper; @ViewChildren('s1') one!: MatStep; @ViewChildren('s2') two!: MatStep; steps: MatStep[] = []; ngAfterViewInit(): void { this.steps = [this.one, this.two]; } reloadStep = (stepperEvent: StepperSelectionEvent) =&gt; { const index = stepperEvent.selectedIndex; console.log('step changed:', index); this.steps[index].reset(); }; } </code></pre>
[ { "answer_id": 74125046, "author": "Deniz Kaplan", "author_id": 2474573, "author_profile": "https://Stackoverflow.com/users/2474573", "pm_score": 0, "selected": false, "text": "i" } ]
2022/10/19
[ "https://Stackoverflow.com/questions/74125014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17565505/" ]
74,125,056
<p>I have to convert two arrays into a single array base on given below condition. a= [&quot;dry chapati&quot;, &quot;dry chapati&quot;, &quot;dry chapati&quot;] b = [&quot;chapati&quot;, &quot;less fat&quot;, &quot;no oil&quot;];</p> <p>I want to convert a and b to as below</p> <p>c = [&quot;dry chapati&quot; : &quot;chapati&quot;, &quot;less fat&quot;, &quot;no oil&quot;]</p> <p>I am trying it as below but not getting desired result as c</p> <pre><code>let recipe = [&quot;dry chapati&quot;, &quot;dry chapati&quot;, &quot;dry chapati&quot;]; let tags = [&quot;chapati&quot;, &quot;less fat&quot;, &quot;no oil&quot;]; let r = []; for(let i=1; i&lt;recipe.length; i++){ if(recipe[i] == recipe[i+1]){ recipe[i] = tags // console.log(recipe); } } </code></pre> <p>Please help to find a solution.</p>
[ { "answer_id": 74125149, "author": "Maximilian Flechtner", "author_id": 15528148, "author_profile": "https://Stackoverflow.com/users/15528148", "pm_score": 1, "selected": false, "text": "let recipe = [\"dry chapati\", \"dry chapati\", \"dry chapati\"];\nlet tags = [\"chapati\", \"less fa...
2022/10/19
[ "https://Stackoverflow.com/questions/74125056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12790306/" ]
74,125,057
<p>example:</p> <pre><code>random_list = ['foo','foo','foo','foo',56,'foo','foo','foo','foo','foo'] # in random_list there are always 10 elements, one of which is 56, but its position is unknown def find_index_of_56_in_list_1(): for index in range(0,5): if 56 == random_list[index]: return index def find_index_of_56_in_list_2(): for index in range(6,10): if 56 == random_list[index]: return index </code></pre> <p>I would like to split the computational power of iterating in the list in 2 Thread one for the first half of the list 'find_index_of_56_in_list_1' and the other for the second half of the list 'find_index_of_56_in_list_2'. and if one process has terminated then the other must terminate as well and nothing or return 'none'.</p> <p>The problem I am trying to solve is not this one but a bigger one, this example is an analogy. I've tried with threading library, but i can't get one process to terminate when the other has terminated or vice versa.</p>
[ { "answer_id": 74125149, "author": "Maximilian Flechtner", "author_id": 15528148, "author_profile": "https://Stackoverflow.com/users/15528148", "pm_score": 1, "selected": false, "text": "let recipe = [\"dry chapati\", \"dry chapati\", \"dry chapati\"];\nlet tags = [\"chapati\", \"less fa...
2022/10/19
[ "https://Stackoverflow.com/questions/74125057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17218307/" ]
74,125,061
<p>i have the following simple full code</p> <pre><code>import 'package:flutter/material.dart'; class A2 extends StatefulWidget { const A2({Key? key}) : super(key: key); @override State&lt;A2&gt; createState() =&gt; _A2State(); } class _A2State extends State&lt;A2&gt; { @override Widget build(BuildContext context) { return Scaffold( body: ShaderMask( shaderCallback: ( bounds) { return LinearGradient( colors: [Colors.white.withOpacity(0.05),Colors.white], stops: const [0.0, 0.09], tileMode: TileMode.mirror, begin: Alignment.center, end: Alignment.center ).createShader(bounds); }, child: Container( decoration: BoxDecoration( border: Border.all(color: Colors.red, width: 100), ), ), ) ); } } </code></pre> <p>Question : how could i make the borders blur .</p> <p>i tried to use <code>ShaderMask</code> but the problem i cannot align the blur direction into the required area as shown in the following image</p> <p><a href="https://i.stack.imgur.com/of8vX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/of8vX.png" alt="enter image description here" /></a></p> <p>Note: i need only the border who get blur</p> <p><a href="https://i.stack.imgur.com/u62hp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u62hp.png" alt="enter image description here" /></a></p> <p>i am trying to make the blur area into where the green circles painted only</p> <p>i don't want the white part being affected by blur . ONLY BORDERS</p>
[ { "answer_id": 74125149, "author": "Maximilian Flechtner", "author_id": 15528148, "author_profile": "https://Stackoverflow.com/users/15528148", "pm_score": 1, "selected": false, "text": "let recipe = [\"dry chapati\", \"dry chapati\", \"dry chapati\"];\nlet tags = [\"chapati\", \"less fa...
2022/10/19
[ "https://Stackoverflow.com/questions/74125061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16213673/" ]
74,125,073
<p>I'm using Blazor and MudBlazor.</p> <p>If I call <a href="https://mudblazor.com/api/textfield" rel="nofollow noreferrer"><code>myMudTextField.Validate()</code></a> then it validates the field and updates the UI - shows validation errors, etc.</p> <p>Can I determine whether the field is valid without updating the UI? For example, something like <code>myMudTextField.IsValid</code>.</p>
[ { "answer_id": 74129611, "author": "Leandro Toloza", "author_id": 14322498, "author_profile": "https://Stackoverflow.com/users/14322498", "pm_score": 2, "selected": true, "text": "<MudTextField Validation=\"@(new Func<int, IEnumerable<string>>(PtoVtaStrength))\" T=\"int\" Pattern=\"^[+-]...
2022/10/19
[ "https://Stackoverflow.com/questions/74125073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9971404/" ]
74,125,095
<p>I want to print a single value from a map.</p> <pre><code> var myMap = { 0: { key: 754, name: luke, time: 1665537500000}, 1: { key: 436, name: obi, time: 1665532400000}, } print(myMap[1].value(&quot;name&quot;); // something like that </code></pre> <p>output should be: obi</p>
[ { "answer_id": 74125211, "author": "yodamousta", "author_id": 18979831, "author_profile": "https://Stackoverflow.com/users/18979831", "pm_score": 1, "selected": false, "text": "print(myMap[1][\"name\"]);\n" }, { "answer_id": 74125216, "author": "Manish Dayma", "author_id"...
2022/10/19
[ "https://Stackoverflow.com/questions/74125095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16126737/" ]
74,125,100
<p>I have one table as Images.</p> <pre><code>TableName ColumnName RecordId Caption ImageType ROTId DetailRecordId Table2 PAUTDPhoto_bin 1462 test PAUTPhotos 1041383 11480170 Table2 PAUTDPhoto_bin 1463 test1 PAUTPhotos 1041383 11480170 Table2 PAUTDPhoto_bin 1464 testing photo PAUTPhotos 1041383 11480170 Table1 ItemPhoto_bin 11480170 caption ItemPhoto 1041383 11480170 Table1 ItemPhoto_bin 11480171 test photo ItemPhoto 1041383 11480171 Table1 ItemPhoto_bin 11480172 description ItemPhoto 1041383 11480172 Table2 PAUTDPhoto_bin 1465 test PAUTPhotos 1041383 11480172 Table2 PAUTDPhoto_bin 1466 55 PAUTPhotos 1041383 11480172 </code></pre> <p>My output select query will do the following actions,</p> <p>1.) Need to do GroupBy by DetailRecordId and ColumnName.</p> <p>2.) After GroupBy I want to combine RecordId and Caption columns. Need to combine only 2 values into one.</p> <p>My output should be,</p> <pre><code>TableName ColumnName RecordId Caption ImageType ROTId DetailRecordId Table2 PAUTDPhoto_bin 1462$1463 test$test1 PAUTPhotos 1041383 11480170 Table2 PAUTDPhoto_bin 1464 testing photo PAUTPhotos 1041383 11480170 Table1 ItemPhoto_bin 11480170 caption ItemPhoto 1041383 11480170 Table1 ItemPhoto_bin 11480171 test photo ItemPhoto 1041383 11480171 Table1 ItemPhoto_bin 11480172 description ItemPhoto 1041383 11480172 Table2 PAUTDPhoto_bin 1465$1466 test$55 PAUTPhotos 1041383 11480172 </code></pre> <p><strong>Note:</strong> I want to join RecordId and Caption columns with only 2 values into that.</p>
[ { "answer_id": 74125462, "author": "Stuck at 1337", "author_id": 20091109, "author_profile": "https://Stackoverflow.com/users/20091109", "pm_score": 1, "selected": false, "text": "LEAD" }, { "answer_id": 74137899, "author": "ahmed", "author_id": 12705912, "author_prof...
2022/10/19
[ "https://Stackoverflow.com/questions/74125100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20281243/" ]
74,125,117
<p>So I need to make a function that takes a parameter of type <code>char **</code>, and makes that point to a string.</p> <p>I've spent hours on it and I know it's probably a super dumb thing that I'm missing.</p> <p>Here is my latest attempt:</p> <pre class="lang-c prettyprint-override"><code>void magic_string(char ** new_string) { char * my_string = (char*) malloc((5+1)*sizeof(char)); my_string = &quot;abcde&quot;; new_string = &amp;my_string; } </code></pre> <p>But when I try to use the <code>new_string</code> in the calling function, it is still <code>null</code>.</p> <p>I also tried replacing the last line with <code>*new_string = my_string</code> but recieved a bad access exception.</p>
[ { "answer_id": 74125179, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 1, "selected": false, "text": "my_string = \"abcde\";" }, { "answer_id": 74125189, "author": "dbush", "author_id": 1687119, "a...
2022/10/19
[ "https://Stackoverflow.com/questions/74125117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13292868/" ]
74,125,130
<p>I want to show a <code>camera</code> preview and capture images on a desktop application. The official flutter <code>camera</code> and <code>image_picker</code> packages <strong>do not support</strong> any desktop and I can't find another package to do this. suggest something Especially for the <strong>macOS</strong> desktop app.</p>
[ { "answer_id": 74125527, "author": "Nijat Namazzade", "author_id": 16788073, "author_profile": "https://Stackoverflow.com/users/16788073", "pm_score": 0, "selected": false, "text": "dependencies:\n file_selector: ^0.9.2+1\n" } ]
2022/10/19
[ "https://Stackoverflow.com/questions/74125130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20067845/" ]
74,125,133
<p>I was trying to integrate firebase in Flutter with FlutterFire. I have done very steps on documentation yet i couldnot start the app.</p> <p><strong>I tried Searching the error on StackOverflow yet could not find any hints on solution. What exactly am i missing?</strong></p> <blockquote> <pre><code>c:\drumkiller\google_maps_in_flutter&gt;flutterfire configure i Found 3 Firebase projects. ✔ Select a Firebase project to configure your Flutter application with · g-map-8f66c (g-map) ✔ Which platforms should your configuration support (use arrow keys &amp; space to select)? · android, ios, macos, web i Firebase android app com.example.google_maps_in_flutter is not registered on Firebase project g-map-8f66c. i Registered a new Firebase android app on Firebase project g-map-8f66c. i Firebase ios app com.example.googleMapsInFlutter is not registered on Firebase project g-map-8f66c. i Registered a new Firebase ios app on Firebase project g-map-8f66c. i Firebase macos app com.example.googleMapsInFlutter registered. i Firebase web app google_maps_in_flutter (web) is not registered on Firebase project g-map-8f66c. i Registered a new Firebase web app on Firebase project g-map-8f66c. Firebase configuration file lib\firebase_options.dart generated successfully with the following Firebase apps: Platform Firebase App Id web 1:178984749635:web:3e7e105df5e73d519da2f6 android 1:178984749635:android:2c82e4a8770b873e9da2f6 ios 1:178984749635:ios:07715f151dbe0db39da2f6 macos 1:178984749635:ios:07715f151dbe0db39da2f6 Learn more about using this file and next steps from the documentation: &gt; https://firebase.google.com/docs/flutter/setup c:\drumkiller\google_maps_in_flutter&gt; </code></pre> </blockquote> <p>Then some files were generated.Then in my main.dart</p> <pre><code>import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:google_maps_in_flutter/firebase_options.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title}); final String title; @override State&lt;MyHomePage&gt; createState() =&gt; _MyHomePageState(); } class _MyHomePageState extends State&lt;MyHomePage&gt; { int _counter = 0; void _incrementCounter() { setState(() { _counter++; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.title), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: &lt;Widget&gt;[ const Text( 'You have pushed the button this many times:', ), Text( '$_counter', style: Theme.of(context).textTheme.headline4, ), ], ), ), floatingActionButton: FloatingActionButton( onPressed: _incrementCounter, tooltip: 'Increment', child: const Icon(Icons.add), ), ); } } </code></pre> <p>The Error shown when I run: flutter run is</p> <pre><code>Launching lib\main.dart on M2101K7AG in debug mode... /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/method_channel/method_channel_firebase.dart:40:38: Error: Type 'PigeonInitializeResponse' not found. void _initializeFirebaseAppFromMap(PigeonInitializeResponse response) { ^^^^^^^^^^^^^^^^^^^^^^^^ /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/mocks.dart:5:10: Error: Type 'PigeonInitializeResponse' not found. Future&lt;PigeonInitializeResponse&gt; initializeApp( ^^^^^^^^^^^^^^^^^^^^^^^^ /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/mocks.dart:22:15: Error: Type 'PigeonInitializeResponse' not found. Future&lt;List&lt;PigeonInitializeResponse?&gt;&gt; initializeCore() async { ^^^^^^^^^^^^^^^^^^^^^^^^ /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/test_api.dart:47:10: Error: Type 'PigeonInitializeResponse' not found. Future&lt;PigeonInitializeResponse&gt; initializeApp( ^^^^^^^^^^^^^^^^^^^^^^^^ /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/test_api.dart:49:15: Error: Type 'PigeonInitializeResponse' not found. Future&lt;List&lt;PigeonInitializeResponse?&gt;&gt; initializeCore(); ^^^^^^^^^^^^^^^^^^^^^^^^ /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/method_channel/method_channel_firebase.dart:29:10: Error: 'PigeonInitializeResponse' isn't a type. List&lt;PigeonInitializeResponse?&gt; apps = await api.initializeCore(); ^^^^^^^^^^^^^^^^^^^^^^^^ /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/method_channel/method_channel_firebase.dart:33:15: Error: 'PigeonInitializeResponse' isn't a type. .cast&lt;PigeonInitializeResponse&gt;() ^^^^^^^^^^^^^^^^^^^^^^^^ /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/method_channel/method_channel_firebase.dart:40:38: Error: 'PigeonInitializeResponse' isn't a type. void _initializeFirebaseAppFromMap(PigeonInitializeResponse response) { ^^^^^^^^^^^^^^^^^^^^^^^^ /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/mocks.dart:9:12: Error: The method 'PigeonInitializeResponse' isn't defined for the class 'MockFirebaseApp'. - 'MockFirebaseApp' is from 'package:firebase_core_platform_interface/src/pigeon/mocks.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/mocks.dart'). Try correcting the name to the name of an existing method, or defining a method named 'PigeonInitializeResponse'. return PigeonInitializeResponse( ^^^^^^^^^^^^^^^^^^^^^^^^ /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/mocks.dart:24:7: Error: The method 'PigeonInitializeResponse' isn't defined for the class 'MockFirebaseApp'. - 'MockFirebaseApp' is from 'package:firebase_core_platform_interface/src/pigeon/mocks.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/mocks.dart'). Try correcting the name to the name of an existing method, or defining a method named 'PigeonInitializeResponse'. PigeonInitializeResponse( ^^^^^^^^^^^^^^^^^^^^^^^^ /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/test_api.dart:21:25: Error: 'PigeonInitializeResponse' isn't a type. } else if (value is PigeonInitializeResponse) { ^^^^^^^^^^^^^^^^^^^^^^^^ /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/test_api.dart:36:16: Error: The getter 'PigeonInitializeResponse' isn't defined for the class '_TestFirebaseCoreHostApiCodec'. - '_TestFirebaseCoreHostApiCodec' is from 'package:firebase_core_platform_interface/src/pigeon/test_api.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/test_api.dart'). Try correcting the name to the name of an existing getter, or defining a getter or field named 'PigeonInitializeResponse'. return PigeonInitializeResponse.decode(readValue(buffer)!); ^^^^^^^^^^^^^^^^^^^^^^^^ /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/test_api.dart:71:17: Error: 'PigeonInitializeResponse' isn't a type. final PigeonInitializeResponse output = ^^^^^^^^^^^^^^^^^^^^^^^^ /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/test_api.dart:86:22: Error: 'PigeonInitializeResponse' isn't a type. final List&lt;PigeonInitializeResponse?&gt; output = ^^^^^^^^^^^^^^^^^^^^^^^^ FAILURE: Build failed with an exception. * Where: Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1159 * What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'. &gt; Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1 * Try: &gt; Run with --stacktrace option to get the stack trace. &gt; Run with --info or --debug option to get more log output. &gt; Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 24s Running Gradle task 'assembleDebug'... 25.5s Exception: Gradle task assembleDebug failed with exit code 1 </code></pre> <p><strong>Files that were added Screen Shots:</strong></p> <p><a href="https://i.stack.imgur.com/4fSJ0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4fSJ0.png" alt="enter image description here" /></a></p> <p><strong>Error Screen Shot:</strong></p> <p><a href="https://i.stack.imgur.com/pcX1l.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pcX1l.png" alt="enter image description here" /></a></p> <p><strong>My pubspec.yaml</strong></p> <p><a href="https://i.stack.imgur.com/Y0w9R.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Y0w9R.png" alt="enter image description here" /></a></p> <p><strong>My flutter doctor:::</strong></p> <pre><code>Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.3.2, on Microsoft Windows [Version 10.0.19043.2130], locale en-US) [√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) [√] Chrome - develop for the web [√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.2.2) [√] Android Studio (version 2021.2) [√] VS Code (version 1.72.2) [√] Connected device (4 available) [√] HTTP Host Availability • No issues found! </code></pre> <p><strong>What i did was:</strong></p> <pre><code> 1. Created a flutter Project in firebase console 2. Set upped the flutter Fire 3. created a new flutter project 4. ran flutterfire configure in terminal 5. added firebase_core in pubspec.yaml 6. added await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform, ); inside main.dart 7. ran flutter run </code></pre>
[ { "answer_id": 74125527, "author": "Nijat Namazzade", "author_id": 16788073, "author_profile": "https://Stackoverflow.com/users/16788073", "pm_score": 0, "selected": false, "text": "dependencies:\n file_selector: ^0.9.2+1\n" } ]
2022/10/19
[ "https://Stackoverflow.com/questions/74125133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15180735/" ]
74,125,173
<p>I have a table of hierarchical data (tree data structure) of varying depth and I want to render it using an HTML table in which just the content of the first column of the table will be indented according to the depth of each row that is known beforehand:</p> <pre><code>&quot;comment one&quot; (row=1, depth=0) &quot;comment two&quot; (row=2, depth=0) &quot;comment three&quot; (row=3, depth=1) &quot;comment four&quot; (row=4, depth=2) &quot;comment five&quot; (row=5, depth=0) </code></pre> <p>Now how can I achieve this?</p> <p><a href="https://i.stack.imgur.com/aCBRa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aCBRa.png" alt="KDE System Monitor" /></a></p> <p>And I know I can easily do it by defining CSS classes for each depth, but I am looking for a general solution.</p>
[ { "answer_id": 74125294, "author": "Mr. Polywhirl", "author_id": 1762224, "author_profile": "https://Stackoverflow.com/users/1762224", "pm_score": -1, "selected": false, "text": "[data-row-depth=\"0\"] { padding-left: 0; }\n[data-row-depth=\"1\"] { padding-left: 0.5rem; }\n[data-row-dept...
2022/10/19
[ "https://Stackoverflow.com/questions/74125173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2817520/" ]
74,125,178
<p>I am trying to create a function that takes a data frame, an x-axis variable, and a y-axis variable to create a visual. Here's my code:</p> <pre><code>library(ggplot2) create_visual &lt;- function(data, x_axis, y_axis) { ggplot(data = data) + geom_point(mapping = aes(x = x_axis, y = y_axis)) } </code></pre> <p>When I run this code:</p> <pre><code>create_visual(penguins,flipper_length_mm,body_mass_g) </code></pre> <p>I get this error: <code>'Error in FUN(X[[i]], ...) : object 'flipper_length_mm' not found'</code></p> <p>I have loaded the dataset <code>Palmerpenguins</code> and checked the <code>penguins</code> data table, and it does have <code>flipper_length_mm</code>, yet I am getting this error. Could you please help me figure out where I am making a mistake?</p>
[ { "answer_id": 74125868, "author": "Merijn van Tilborg", "author_id": 10415749, "author_profile": "https://Stackoverflow.com/users/10415749", "pm_score": 1, "selected": true, "text": "get" }, { "answer_id": 74125885, "author": "Antreas Stefopoulos", "author_id": 13057055,...
2022/10/19
[ "https://Stackoverflow.com/questions/74125178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17220134/" ]
74,125,217
<p>Would you know how i can iterate through the self.checkxxx values so that I do not have to repeat the same if else clause over and over again. I am not sure how to do it if someone could give me an example that could be very useful Maybe like a for loop but the for loops i have tried have just not worked. I just get this error: <code>TypeError: cannot unpack non-iterable CheckState object</code></p> <pre><code>def checkbox_ledVA(self): self.LED = 'PASS' self.LED_fail = 'FAIL' self.checkPWR_rot_va = self.ui.PWR_rot_VA.checkState() self.checkPWR_grun_va = self.ui.PWR_grun_VA.checkState() self.checkP1_va = self.ui.Port1_VA.checkState() self.checkP2_va = self.ui.port2_VA.checkState() self.checkP3_va = self.ui.Port3_VA.checkState() if self.checkPWR_rot_va == 2: self.checkPWR_rot_va = self.LED_pass else: self.checkPWR_rot_va = self.LED_fail if self.checkPWR_grun_va == 2: self.checkPWR_grun_va = self.LED_pass else: self.checkPWR_grun_va = self.LED_fail if self.checkP1_va == 2: self.checkP1_va = self.LED_pass else: self.checkP1_va = self.LED_fail if self.checkP2_va == 2: self.checkP2_va = self.LED_pass else: self.checkP2_va = self.LED_fail if self.checkP3_va == 2: self.checkP3_va = self.LED_pass else: self.checkP3_va = self.LED_fail </code></pre> <p>Please give me an example so i can learn and apply it to my program</p>
[ { "answer_id": 74125295, "author": "Byron", "author_id": 4187337, "author_profile": "https://Stackoverflow.com/users/4187337", "pm_score": 1, "selected": false, "text": "for i, val in enumerate(self.values):\n if val == 2:\n self.values[i] = self.LED_pass\n else:\n se...
2022/10/19
[ "https://Stackoverflow.com/questions/74125217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17128344/" ]
74,125,229
<p>I wonder how can I load svg`s in preact &amp; vite for now I have tried simple import</p> <pre><code>import SvgLogo from './test.svg' export const Logo = () =&gt; ( &lt;SvgLogo /&gt; ) </code></pre> <p>but I doesnt render anything.</p>
[ { "answer_id": 74125322, "author": "JigolKa", "author_id": 16651308, "author_profile": "https://Stackoverflow.com/users/16651308", "pm_score": 0, "selected": false, "text": "import SvgLogo from './test.svg'\n\nexport const Logo = () => (\n <img src={SvgLogo} />\n)\n" }, { "ans...
2022/10/19
[ "https://Stackoverflow.com/questions/74125229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20130220/" ]
74,125,249
<p>How can I achieve this 'How to create an https server' Node.JS code in Asp.net (.Net 6)</p> <pre><code>const options = { key: fs.readFileSync('key.key'), cert: fs.readFileSync('cert.crt') }; https.createServer(options, function (req, res) { res.writeHead(200); res.end(&quot;hello world\n&quot;); }).listen(8000); </code></pre> <p>I'm trying to get my domain certificate to work with my ASP.Net code but couldn't find a solution.<br>Is ASP.Net even made to handle Server and Browsers communication or mainly made for APIs?</p>
[ { "answer_id": 74125322, "author": "JigolKa", "author_id": 16651308, "author_profile": "https://Stackoverflow.com/users/16651308", "pm_score": 0, "selected": false, "text": "import SvgLogo from './test.svg'\n\nexport const Logo = () => (\n <img src={SvgLogo} />\n)\n" }, { "ans...
2022/10/19
[ "https://Stackoverflow.com/questions/74125249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12603668/" ]
74,125,251
<p>I'm looking for something similar to this:</p> <pre><code>const object1 = { a: 1, b: 2, c: 3 }; console.log(Object.getOwnPropertyNames(object1)); // expected output: Array [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;] </code></pre> <p>However in my example I have:</p> <pre><code>const objectArray1 = [ { a: 112, b: 322, c: 233 }, { a: 611, b: 232, c: 331 }, { a: 132, b: 232, c: 342 } ]; </code></pre> <p>What's the most efficient way of getting the <code>[&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]</code> from this?</p> <p>Also, that'll probably never happen but if one of <code>objectArray1</code> objects has <code>d: 345</code> in it or a missing key/value pair, that needs to be handled.</p> <p>Any ideas?</p>
[ { "answer_id": 74125302, "author": "Nick Vu", "author_id": 9201587, "author_profile": "https://Stackoverflow.com/users/9201587", "pm_score": 2, "selected": false, "text": "Object.keys" }, { "answer_id": 74125308, "author": "Cerbrus", "author_id": 1835379, "author_prof...
2022/10/19
[ "https://Stackoverflow.com/questions/74125251", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14643631/" ]
74,125,252
<p>I'm creating a simple log in VC. let's ignore the input validation for both username &amp; password. I just want to enable the UIButton when both username's and password's UITextField is not empty. And whenever any one of them becomes empty, I want the button to be disabled.</p> <pre><code> @IBAction func typingUserName(_ sender: Any) { usernameTxtfield.layer.shadowPath = UIBezierPath(rect: usernameTxtfield.bounds).cgPath usernameTxtfield.layer.shadowRadius = 2 usernameTxtfield.layer.shadowOffset = .zero usernameTxtfield.layer.shadowOpacity = 0.5 signInIcon.isEnabled = false } @IBAction func typingPassword(_ sender: Any) { passwordTxtfield.layer.shadowPath = UIBezierPath(rect: passwordTxtfield.bounds).cgPath passwordTxtfield.layer.shadowRadius = 2 passwordTxtfield.layer.shadowOffset = .zero passwordTxtfield.layer.shadowOpacity = 0.5 signInIcon.isEnabled = false } @IBAction func usernameTxtFieldEditingChnged(_ sender: Any) { usernameTxtfield.layer.shadowRadius = 0 usernameTxtfield.layer.shadowOffset = .zero usernameTxtfield.layer.shadowOpacity = 0 } @IBAction func passwordEditingChaned(_ sender: Any) { passwordTxtfield.layer.shadowRadius = 0 passwordTxtfield.layer.shadowOffset = .zero passwordTxtfield.layer.shadowOpacity = 0 signInIcon.isEnabled = true } @IBAction func signInClicked(_ sender: Any) { performSegue(withIdentifier: &quot;welcomeVC&quot;, sender: signInIcon) } </code></pre> <p>As you can see, I'm enabling the button only after the password textfield EditingChanged has been triggered.</p>
[ { "answer_id": 74125905, "author": "Bulat Yakupov", "author_id": 17834877, "author_profile": "https://Stackoverflow.com/users/17834877", "pm_score": 3, "selected": true, "text": ".editingChanged" }, { "answer_id": 74126053, "author": "Seby Pudilic", "author_id": 11013339,...
2022/10/19
[ "https://Stackoverflow.com/questions/74125252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14692364/" ]
74,125,277
<p>I am trying to upload a new build of my app from the new Xcode 14.1 RC but it keeps failing with the below error:</p> <blockquote> <p>ITMS-90428: Invalid Swift Support - The files libswift_Concurrency.dylib don’t match /Payload/MY_APP.app/MY_APP_WatchOS.app/libswift_Concurrency.dylib. Make sure the files are correct, rebuild your app, and resubmit it. Don’t apply post-processing to /Payload/MY_APP.app/MY_APP_WatchOS.app/libswift_Concurrency.dylib.</p> </blockquote> <p>My bundle contains a watchOS 4.3 app which I thought might have been an issue, so I tried increasing it to watchOS 7.0 but still got the error.</p> <p>Bitcode is disabled for all targets. I don't think I have any post-processing enabled either as I just use the standard Xcode submit to App Store.</p>
[ { "answer_id": 74125905, "author": "Bulat Yakupov", "author_id": 17834877, "author_profile": "https://Stackoverflow.com/users/17834877", "pm_score": 3, "selected": true, "text": ".editingChanged" }, { "answer_id": 74126053, "author": "Seby Pudilic", "author_id": 11013339,...
2022/10/19
[ "https://Stackoverflow.com/questions/74125277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1077601/" ]
74,125,279
<p>When running this python code:</p> <pre><code>shapes = [{&quot;label&quot;: &quot;bad_stuff&quot;}, {&quot;label&quot;: &quot;cat&quot;}, {&quot;label&quot;: &quot;cat&quot;},{&quot;label&quot;: &quot;cat&quot;}, {&quot;label&quot;: &quot;bad_stuff&quot;}, {&quot;label&quot;: &quot;bad_stuff&quot;}] for elem in shapes: if elem['label'] == &quot;bad_stuff&quot;: shapes.remove(elem) </code></pre> <p>... I get this result:</p> <pre><code>[{'label': 'cat'}, {'label': 'cat'}, {'label': 'cat'}, {'label': 'bad_stuff'}] </code></pre> <p>Why does not the code remove the last element in the list and how can I solve it?</p>
[ { "answer_id": 74125544, "author": "Nick Laid", "author_id": 11764746, "author_profile": "https://Stackoverflow.com/users/11764746", "pm_score": 3, "selected": true, "text": "{\"label\": \"bad_stuff\"}" }, { "answer_id": 74126457, "author": "Rahul K P", "author_id": 44076...
2022/10/19
[ "https://Stackoverflow.com/questions/74125279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4826074/" ]
74,125,292
<p>I'm using Xamarin.Android and I'm trying to extend the functionality of the default <code>FragmentFactory</code>.</p> <pre><code>public class ExtendedFragmentFactory : FragmentFactory { public override Fragment Instantiate(ClassLoader classLoader, string className) { Class javaClass = Class.ForName(className, false, classLoader); var instance = javaClass.NewInstance(); } } </code></pre> <p>If I create a new instance using <code>NewInstance()</code>, then I am able to call <code>GetType()</code> on <code>instance</code> which does give me the .NET Type but how would I do this without unnecessarily creating an instance?</p> <p>I'm trying to get the Dependency Container to create the <code>Fragment</code> so I am not able to use the default instantiation method that Android uses with <code>FragmentManager</code> or <code>FragmentFactory</code>. My <code>Fragment</code> classes will have dependencies injected into them via their constructor, in other words, I will not have a parameterless constructor which the default instantiation implementation expects.</p> <p>Is there any way to get the .NET Type from Java.Lang.Class or the specified parameters in the <code>Instantiate</code> method?</p> <p>Is there any way I can use the <code>className</code> parameter to work out what the .NET Type is?</p>
[ { "answer_id": 74125544, "author": "Nick Laid", "author_id": 11764746, "author_profile": "https://Stackoverflow.com/users/11764746", "pm_score": 3, "selected": true, "text": "{\"label\": \"bad_stuff\"}" }, { "answer_id": 74126457, "author": "Rahul K P", "author_id": 44076...
2022/10/19
[ "https://Stackoverflow.com/questions/74125292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/959631/" ]
74,125,315
<p>In this website &quot;https://www.armoli.com&quot; as you can see, the menu is transparent at first and integrated with the image on the back, but its color changes as you scroll down.how can I do this in html?(with css and js)</p>
[ { "answer_id": 74125395, "author": "JDChris100", "author_id": 12695057, "author_profile": "https://Stackoverflow.com/users/12695057", "pm_score": -1, "selected": false, "text": ".navbar_active {\n color: red;\n}\n\n.navbar_other {\n color: blue;\n}\n" } ]
2022/10/19
[ "https://Stackoverflow.com/questions/74125315", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20107962/" ]
74,125,321
<p>I want to change my physics of my ListView when the keyboard appears. I did this with the help of flutter_keyboard_visibility. Code for the bool :</p> <pre><code>class LoginSignUpScreen extends StatefulWidget { const LoginSignUpScreen({Key? key}) : super(key: key); @override State&lt;LoginSignUpScreen&gt; createState() =&gt; _LoginSignUpScreenState(); } class _LoginSignUpScreenState extends State&lt;LoginSignUpScreen&gt; { late StreamSubscription&lt;bool&gt; keyboardSubscription; bool isKeyboardVisible = false; @override void initState() { super.initState(); var keyboardVisibilityController = KeyboardVisibilityController(); // Query print('Keyboard visibility direct query: ${keyboardVisibilityController.isVisible}'); // Subscribe keyboardSubscription = keyboardVisibilityController.onChange.listen((bool visible) { print('Keyboard visibility update. Is visible: $visible'); isKeyboardVisible = visible; }); } @override void dispose() { keyboardSubscription.cancel(); super.dispose(); } </code></pre> <p>but the bool is correct. It says False when the keyboard is down, and true when it's up. Somewhere here seems to be a mistake, but where?!</p> <pre><code> Widget build(BuildContext context) { return Scaffold( appBar: AppBar( toolbarHeight: 0.1, backgroundColor: Colors.black, ), body: Stack( children: [ Stack(children: [ Container( decoration: const BoxDecoration( gradient: LinearGradient( colors: [Color(0xfff68972), Color(0xfff67582)], begin: Alignment.topLeft, end: Alignment.bottomRight, ), ), ), ScrollConfiguration( behavior: MyBehavior(), child: ListView( controller: controllerV, scrollDirection: Axis.vertical, physics: isKeyboardVisible? const ClampingScrollPhysics(): const NeverScrollableScrollPhysics(), children:const [ LoginForm(), RegisterForm(), ]), ), ElevatedButton(onPressed: (){print(isKeyboardVisible);}, child: Text(&quot;TEST?&quot;)) ]), ], ), ); } } class MyBehavior extends ScrollBehavior { @override Widget buildOverscrollIndicator(BuildContext context, Widget child, ScrollableDetails details) { return child; } } </code></pre> <p>in this case the physics is alway Neverscrollable, so the init state, but than the state dont change anymore.</p>
[ { "answer_id": 74125387, "author": "Per.J", "author_id": 11582192, "author_profile": "https://Stackoverflow.com/users/11582192", "pm_score": 2, "selected": true, "text": "// Subscribe\nkeyboardSubscription = keyboardVisibilityController.onChange.listen((bool visible) {\nprint('Keyboard v...
2022/10/19
[ "https://Stackoverflow.com/questions/74125321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19913052/" ]
74,125,334
<p>I have to do performance testing of an application only compatible in Microsoft Edge(Compatible mode IE5).Need to record the application and test in Jmeter.</p> <p>Please help.</p>
[ { "answer_id": 74125387, "author": "Per.J", "author_id": 11582192, "author_profile": "https://Stackoverflow.com/users/11582192", "pm_score": 2, "selected": true, "text": "// Subscribe\nkeyboardSubscription = keyboardVisibilityController.onChange.listen((bool visible) {\nprint('Keyboard v...
2022/10/19
[ "https://Stackoverflow.com/questions/74125334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3627319/" ]
74,125,346
<p>I'm trying to make a utility function which will take either a tuple or an array and return whichever it took. I've constructed a generic type which understands whether it is passed a tuple or an array, but when I try to use the generic in my utility function, the generic doesn't detect the tuple:</p> <pre class="lang-js prettyprint-override"><code>type Foo = [number, number] type MaybeFoo&lt;T&gt; = T extends Foo ? Foo : number[] const bar = [1, 1, 1, 2] const baz: Foo = [1, 1] type WasntFoo = MaybeFoo&lt;typeof bar&gt; // WasntFoo is number[], which is what I want type WasFoo = MaybeFoo&lt;typeof baz&gt; // WasFoo is [number, number], which is what I want const utilityFunction = &lt;T,&gt;(arr: MaybeFoo&lt;T&gt;): MaybeFoo&lt;T&gt; =&gt; arr // in real life this does something to each el of arr but doesn't change the type const r1 = utilityFunction(bar) const r2 = utilityFunction(baz) // r2 is number[], when I want [number, number] </code></pre> <p>This is in TypeScript 4.8.4, playground <a href="https://www.typescriptlang.org/play?ssl=14&amp;ssc=76&amp;pln=1&amp;pc=1#code/C4TwDgpgBAYg9nKBeKBtAdgVwLYCMIBOANFFnoQLoBQVokUAsgIYj7xwA8AKgHzJRcoEAB7AI6ACYBnWAigB%20WYgBcpHPgKpqVAMZx0U4FFxMC-VAEYSVqDYBM1PQaMmAXqvbmbF7XWgB3Jil0YE8UZlYIdg4-OAAzY1MeWnBoAHUgsMYWNgQY1PjE1z4AehKoQKlPAEsZDHVCEjINChJ-AAtqnXaoWor2piMASQqmEJonQyg4hBhMdB1gav1%20biIeAApTAlUI3M5eAEpdnKi83mQ%20bYn9KYILfhm4OYWl-Q2TAkPdW6MCO0es3mi2W6A%20TFchygZSg-16MmahC0bXa4igI0CITQiOIanIBAoQA" rel="nofollow noreferrer">here</a></p>
[ { "answer_id": 74125523, "author": "Garuno", "author_id": 5625089, "author_profile": "https://Stackoverflow.com/users/5625089", "pm_score": 2, "selected": false, "text": "T" }, { "answer_id": 74125813, "author": "T.J. Crowder", "author_id": 157247, "author_profile": "...
2022/10/19
[ "https://Stackoverflow.com/questions/74125346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11799289/" ]
74,125,352
<p>I have an array of objects like this: If content tags have a value, it should be filter from another array.</p> <pre><code>let mainArray = [ { &quot;contentTitle&quot;: &quot;Article 2 Test&quot;, &quot;contentTags&quot;: [ &quot;Movies&quot;, &quot;Stories&quot; ], &quot;contentPagePath&quot;: &quot;global/en/top-page/listing-page/article2.html&quot; }, { &quot;contentTitle&quot;: &quot;Sub Article page&quot;, &quot;contentTags&quot;: [ &quot;test&quot;, &quot;Podcasts&quot; ], &quot;contentPagePath&quot;: &quot;global/en/top-page/listing-page/article1/sub-article-page.html&quot; }, { &quot;contentTitle&quot;: &quot;Page title article&quot;, &quot;contentTags&quot;: [ &quot;books&quot;, &quot;hotels&quot; ], &quot;contentPagePath&quot;: &quot;global/en/top-page/listing-page/article1.html&quot; }, { &quot;contentTitle&quot;: &quot;Article 5&quot;, &quot;contentTags&quot;: [ &quot;random&quot;, &quot;random2&quot; ], &quot;contentPagePath&quot;: &quot;global/en/top-page/listing-page/article-new5.html&quot; }]; </code></pre> <p>Now I have another array from which I want to filter the above array.</p> <pre><code>let filterArray = [&quot;Movies&quot;, &quot;Podcasts&quot;]; </code></pre> <p>Now I want the result from the above array's keys <strong>contentTags</strong> have any of the value from 2nd array.</p> <p>so After filter Result should be.</p> <pre><code>[ { &quot;contentTitle&quot;: &quot;Article 2 Test&quot;, &quot;contentTags&quot;: [ &quot;Movies&quot;, &quot;Stories&quot; ], &quot;contentPagePath&quot;: &quot;global/en/top-page/listing-page/article2.html&quot; }, { &quot;contentTitle&quot;: &quot;Sub Article page&quot;, &quot;contentTags&quot;: [ &quot;test&quot;, &quot;Podcasts&quot; ], &quot;contentPagePath&quot;: &quot;global/en/top-page/listing-page/article1/sub-article-page.html&quot; } ] </code></pre> <p>Result is like this because the mainArray have 2 objects, one have Movies from filter object and 2nd have Podcasts from filteredobject In it.</p>
[ { "answer_id": 74125452, "author": "Ram", "author_id": 8584025, "author_profile": "https://Stackoverflow.com/users/8584025", "pm_score": 1, "selected": false, "text": "contents.filter((d) => d.contentTags.find(e => targetTags.indexOf(e) > -1))\n" }, { "answer_id": 74125465, "...
2022/10/19
[ "https://Stackoverflow.com/questions/74125352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16703934/" ]
74,125,356
<p>I'm trying to find an element with a specific nth index as a CSS expression.</p> <p>How can I fix my code <strong>without changing</strong> the CSS expression?</p> <pre><code>try: expect(self.page.locator('div[class=&quot;some-class&quot;]:nth(3)')).\ to_be_visible(timeout=20000) return True except AssertionError: return False </code></pre> <p>The error I get is:</p> <p>{Error}DOMException: Failed to execute 'querySelectorAll' on 'Document': 'div[class=&quot;some-class&quot;]:nth(3)' is not a valid selector.</p>
[ { "answer_id": 74125452, "author": "Ram", "author_id": 8584025, "author_profile": "https://Stackoverflow.com/users/8584025", "pm_score": 1, "selected": false, "text": "contents.filter((d) => d.contentTags.find(e => targetTags.indexOf(e) > -1))\n" }, { "answer_id": 74125465, "...
2022/10/19
[ "https://Stackoverflow.com/questions/74125356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5359846/" ]
74,125,385
<p>I have a dictionary in python which is look like this :</p> <pre><code>{'Term1': [6, 'd3', 'd5', 'd43', 'd4', 'd6', 'd7'], 'Term2': [6, 'd1', 'd15', 'd46', 'd2', 'd3', 'd4'], 'Term3': [6, 'd3', 'd5', 'd43', 'd5', 'd6', 'd77'], 'Term4': [6, 'd1', 'd15', 'd46', 'd16', 'd17', 'd77'], 'Term5': [6, 'd3', 'd5', 'd43', 'd4', 'd10', 'd22'], 'Term6': [6, 'd1', 'd15', 'd46', 'd17', 'd55', 'd77'], 'Term7': [6, 'd3', 'd5', 'd43', 'd2', 'd7', 'd22'], 'Term8': [6, 'd1', 'd15', 'd46', 'd14', 'd66', 'd88'], 'Term9': [6, 'd1', 'd15', 'd46', 'd2', 'd77', 'd88'], 'Term10': [6, 'd3', 'd5', 'd43', 'd4', 'd44', 'd77'], 'Term11': [6, 'd1', 'd15', 'd46', 'd57', 'd66', 'd88'], 'Term12': [3, 'd2', 'd7', 'd66'], 'Term13': [3, 'd4', 'd44', 'd77'], 'Term14': [3, 'd55', 'd66', 'd88']} </code></pre> <p>key : values</p> <p>I need to make d's in the list sorted.. smth like :</p> <pre><code>'Term1': [6, 'd3', 'd4' 'd5', 'd6', 'd7', 'd43'] ... etc </code></pre> <p>I tried to do :</p> <pre><code>','.join(sorted(values, key=lambda x: int(x[1:]))) </code></pre> <p>where values are <code>intermediate_dictionary[term]</code></p> <p>but i entered in infinte loop , and it's not working ...</p> <p>this is my full code where I create the <code>self.final_inverted_index</code>:</p> <pre><code> for term in intermediate_dictionary.keys(): intermediate_dictionary[term].insert(0, len(intermediate_dictionary[term])) self.final_inverted_index[term] = intermediate_dictionary[term] </code></pre>
[ { "answer_id": 74125452, "author": "Ram", "author_id": 8584025, "author_profile": "https://Stackoverflow.com/users/8584025", "pm_score": 1, "selected": false, "text": "contents.filter((d) => d.contentTags.find(e => targetTags.indexOf(e) > -1))\n" }, { "answer_id": 74125465, "...
2022/10/19
[ "https://Stackoverflow.com/questions/74125385", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19692549/" ]
74,125,400
<p>I am using Frama-c for my research. How can I do to get CWE-ID from the results of Frama-C</p> <pre><code>[kernel:typing:implicit-function-declaration] 1v3/juliet_suite-c-cplus/CWE401_Memory_Leak__int64_t_calloc_08.c:121: Warning: </code></pre> <p>Thank you so much</p>
[ { "answer_id": 74125452, "author": "Ram", "author_id": 8584025, "author_profile": "https://Stackoverflow.com/users/8584025", "pm_score": 1, "selected": false, "text": "contents.filter((d) => d.contentTags.find(e => targetTags.indexOf(e) > -1))\n" }, { "answer_id": 74125465, "...
2022/10/19
[ "https://Stackoverflow.com/questions/74125400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20263931/" ]
74,125,426
<p>I'm using PyInstaller to convert .py to .exe.</p> <p>In the python code, the following command finds the local path of the .py file</p> <pre><code>path=os.path.dirname(os.path.abspath(__file__)) </code></pre> <p>While running the .exe, the path is diverted to: <code>...\AppData\Local\Temp\_MEI174042</code></p> <p>What is the proper way to find the local path of the .exe file?</p>
[ { "answer_id": 74125576, "author": "Divyessh", "author_id": 13810872, "author_profile": "https://Stackoverflow.com/users/13810872", "pm_score": 2, "selected": true, "text": "if getattr(sys, 'frozen', False):\n path = os.path.dirname(sys.executable)\nelif __file__:\n path = os.path....
2022/10/19
[ "https://Stackoverflow.com/questions/74125426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11195540/" ]