qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,188,020
<p>i'm trying to make login page for my game so I can track everything.. anyway I have enough knoldgke to build it using php and c# to configure the connection to the database... everything here is fine...</p> <p>but i got always invalid password error even when the password is right (using password_verify - password_hash) I track it on php first to see maybe the query having errors but it was completely fine I went then to sql made password without hashing just normal password also i'm getting same error so the last thing was unity c#.. i checked the code it was fine (tracking it by letting it print the user and pass every process) but i noticed that from the beginning before the password sent from input field to php file there's small space that not even a space it's something weird I tried to copy it but nothing shows it doesn't even make space but it's there.. I tried to send password by writing it from string inside the code not from UI it printed normal but whenever I use input field It has same problem (keep in mind: username field has no problems) so i tried to make new field or copying username field.. same thing here's a picture : <a href="https://i.stack.imgur.com/CVdxG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CVdxG.png" alt="enter image description here" /></a></p> <p>here's video also : <a href="https://www.veed.io/view/0e7cdf7d-ac42-4334-87c0-95c002ac0d0d?sharingWidget=true" rel="nofollow noreferrer">click here</a></p> <p>the password for testing is ll26956 if you can zoom in there's a blue line thats the small space when i tried to click on the numbr 6 it showes there's something after the number</p> <p>I tried input password manually and everything went good and there's no spaces like this</p> <p>before : <a href="https://i.stack.imgur.com/PeUh3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PeUh3.png" alt="enter image description here" /></a></p> <p>after : <a href="https://i.stack.imgur.com/Tv2jZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Tv2jZ.png" alt="enter image description here" /></a></p> <p>video after write password manually : <a href="https://www.veed.io/view/25e6fdc4-b4f7-4d4f-9a40-e0d72e25d34a?sharingWidget=true" rel="nofollow noreferrer">Click here2</a> i tried all functions for deleting spaces it doesn't even recognized as space</p> <pre><code> public class ButtonVerify : MonoBehaviour { public Button SubmitButton; public TMP_Text username; public TMP_Text password; // Start is called before the first frame update void Start() { Button btn = SubmitButton.GetComponent&lt;Button&gt;(); btn.onClick.AddListener(TaskOnClick); } void TaskOnClick() { StartCoroutine(Login(username.text.ToString(), password.text.ToString())); } IEnumerator Login(string user_email, string user_pass) { WWWForm form = new WWWForm(); form.AddField(&quot;loginEmail&quot;, user_email); form.AddField(&quot;loginPassword&quot;, user_pass); using (UnityWebRequest www = UnityWebRequest.Post(&quot;imagine_theres_url&quot;,form)) { yield return www.SendWebRequest(); if(www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { Debug.Log(www.downloadHandler.text); } } } </code></pre> <p>}</p>
[ { "answer_id": 74188015, "author": "L8R", "author_id": 14551796, "author_profile": "https://Stackoverflow.com/users/14551796", "pm_score": -1, "selected": false, "text": "$( \".cartcontainer p:first-child\" ).text();\n" }, { "answer_id": 74188050, "author": "Phil", "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74188020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19409681/" ]
74,188,049
<p>I am trying to recreate this design for the navbar <a href="https://i.stack.imgur.com/ZJWPm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZJWPm.png" alt="navbar" /></a></p> <p>But I can't figure out a proper way to add the triangle shape.</p> <p>What I have now: <a href="https://i.stack.imgur.com/qccDW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qccDW.png" alt="enter image description here" /></a></p> <pre><code>&lt;!-- Navbar Logo Space --&gt; &lt;div&gt; &lt;div id=&quot;navbar-logo&quot; class=&quot;z-0 inset-1.5 absolute bg-light-green w-1/4 h-24&quot;&gt; &lt;div class=&quot;hidden md:flex flex items-center space-x-1&quot;&gt; &lt;!-- logo --&gt; &lt;a href=&quot;#&quot; class = &quot;py-5 px-2&quot; &gt;LOGO&lt;/a&gt; &lt;!-- title --&gt; &lt;a href=&quot;#&quot; class = &quot;py-5 px-2&quot;&gt;PLACEHOLDER&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I can add a triangle using this:</p> <pre><code>#navbar-logo::after { content: ''; background: #06C982; position: absolute; top: 0; z-index: 10; left: 27em; width: 10em;; height: 99%; transform: skewX(-38deg); } </code></pre> <p>But its fixed and its causing issues with responsiveness.</p> <p>Is there an efficient way I could do this? Possibly with tailwind.</p>
[ { "answer_id": 74188015, "author": "L8R", "author_id": 14551796, "author_profile": "https://Stackoverflow.com/users/14551796", "pm_score": -1, "selected": false, "text": "$( \".cartcontainer p:first-child\" ).text();\n" }, { "answer_id": 74188050, "author": "Phil", "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74188049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13000728/" ]
74,188,075
<p>I am accessing an API using a cURL request in PHP. The response I receive contains the data I would expect, but when I loop through to process it, certain keys cause the error &quot;Uncaught TypeError: Cannot access offset of type string on string.&quot; I've read through the numerous help questions here related to the error, but can't find anything with how to address a situation where &quot;some&quot; array keys cause an error.</p> <p><strong>Edit #2</strong>: I have determined that for some reason, the order of declaring the variables below is causing the error. If I simply move declaring <code>$transactionType</code> <em><strong>above</strong></em> <code>$transactionValue</code> with no other changes, the code works. Why would the order of accessing those values cause the code to fail? All data from the array is returned as strings from the API. (Leaving original statements unedited to give context and meaning to other answers)</p> <p>My code:</p> <pre><code>$curl = curl_init($urlAPI); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, [ 'x-qn-api-version: 1', 'Content-Type: application/json' ]); $response = curl_exec($curl); curl_close($curl); $decodedResponse = json_decode($response,true); $transactionList = $decodedResponse[&quot;result&quot;]; foreach($transactionList as $key =&gt; $value) { $timestamp = $value[&quot;timeStamp&quot;]; $hash = $value[&quot;hash&quot;]; $transactionValue = $value[&quot;value&quot;]; $transactionType = $value[&quot;functionName&quot;]; //if I comment out this line with no other changes, it works as expected //Do stuff } </code></pre> <p>As noted, if I comment out <code>$transactionType</code> it works perfectly and returns the 100+ results as expected. When I debug and <code>print_r($transactionList)</code>, the <code>functionName</code> key exists in every result (sometimes is empty, though). Another item of interest is if I use <code>isset</code> to check the <code>functionName</code> key first, it cannot find any instances where it is set - even though print_r clearly shows it is. An example of the result from the API:</p> <pre><code>Array ( [0] =&gt; Array ( [timeStamp] =&gt; 1624666351 [hash] =&gt; 0x37f2ec62dbd3f812215ae2e82dcfb11feb56d27255ab10ee102d4ce29942a347 [transactionIndex] =&gt; 95 [value] =&gt; 132506677002809378 [functionName] =&gt; ) [1] =&gt; Array ( [timeStamp] =&gt; 1624672333 [hash] =&gt; 0x9eebfa157829c632b58f743bbe7fb018add5de7a3881796cc6764e942cccf458 [transactionIndex] =&gt; 133 [value] =&gt; 122506677002809378 [functionName] =&gt; swap(uint256 amountOutMin, address[] path, address to, uint256 deadline) ) </code></pre> <p>Where am I going wrong with this where my code breaks if I try to access <code>functionName</code>?</p>
[ { "answer_id": 74188015, "author": "L8R", "author_id": 14551796, "author_profile": "https://Stackoverflow.com/users/14551796", "pm_score": -1, "selected": false, "text": "$( \".cartcontainer p:first-child\" ).text();\n" }, { "answer_id": 74188050, "author": "Phil", "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74188075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1610758/" ]
74,188,089
<p>I have two JavaScript arrays:</p> <pre><code>let array1 = [{name:'jane', age: 20}, {name:'john', age: 30}]; let array2 = [{name:'bob', age: 50}, {name:'john', age: 25}]; </code></pre> <p>I want the output to be:</p> <pre><code>let result = [{name:'jane', age: 20},{name:'bob', age: 50}, {name:'john', age: 55}]; </code></pre> <p>The output array should combine john's age (30+25) since john is a duplicate.</p> <p>How to merge two arrays of objects in JavaScript and combine any objects that have the same name and add the age.</p>
[ { "answer_id": 74188015, "author": "L8R", "author_id": 14551796, "author_profile": "https://Stackoverflow.com/users/14551796", "pm_score": -1, "selected": false, "text": "$( \".cartcontainer p:first-child\" ).text();\n" }, { "answer_id": 74188050, "author": "Phil", "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74188089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19072766/" ]
74,188,103
<p>Im currently downloading a txt file on a button click but want to make the txt file more readable. Is there a way to bold the text in a blob? Only thing I've found is related more to the markup.</p> <p>a.href = window.URL.createObjectURL(new Blob([&quot;this text needs to be bold&quot;]);</p>
[ { "answer_id": 74188015, "author": "L8R", "author_id": 14551796, "author_profile": "https://Stackoverflow.com/users/14551796", "pm_score": -1, "selected": false, "text": "$( \".cartcontainer p:first-child\" ).text();\n" }, { "answer_id": 74188050, "author": "Phil", "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74188103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20326028/" ]
74,188,115
<p>I have a question about my coding homework about lists and dictionaries. I understand up until question 4, and that is where I get stuck. Can anyone help explain what to do?</p> <ol> <li><p>Creates a list.</p> </li> <li><p>Alters the contents of the list.</p> </li> <li><p>Extracts one item from the list and saves it as a variable.</p> </li> <li><p>Stores the value in a dictionary with a key pointing to it.</p> </li> <li><p>Adds more key-value pairs to the dictionary.</p> </li> <li><p>Retrieves and prints the stored dictionary value by accessing it with a key.</p> <pre><code>animals = ['cat', 'dog', 'chicken', 'horse', 'pig'] animals.remove('dog') print(animals) horse = animals[2:3] print(horse) </code></pre> </li> </ol>
[ { "answer_id": 74188015, "author": "L8R", "author_id": 14551796, "author_profile": "https://Stackoverflow.com/users/14551796", "pm_score": -1, "selected": false, "text": "$( \".cartcontainer p:first-child\" ).text();\n" }, { "answer_id": 74188050, "author": "Phil", "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74188115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18612495/" ]
74,188,150
<p>I am trying to implement react-chessboard with chess.js to my website so that I can evaluate a position that a user can create themselves, I am not trying to verify legal moves. Here is my code:</p> <pre><code>import React from 'react'; import {useState} from 'react'; import {Chessboard} from 'react-chessboard'; import {Chess} from 'chess.js'; const Board = () =&gt; { const [game, setGame] = useState(new Chess()); const makeMove = (move) =&gt; { const gameCopy = {...game}; gameCopy.move(move); setGame(gameCopy); return; } const onDrop = (startSquare, endSquare) =&gt; { makeMove({ from: startSquare, to: endSquare, }); return; } return &lt;Chessboard position={game.fen()} onPieceDrop={onDrop} /&gt;; } export default Board; </code></pre> <p>When I try to make a move on the webpage it gives this error: Uncaught TypeError: gameCopy.move is not a function.</p> <p>The code is straight from the react-chessboard documentation so I'm not sure why there is an error.</p> <p>How can I fix this?</p> <p>Thank you</p>
[ { "answer_id": 74188015, "author": "L8R", "author_id": 14551796, "author_profile": "https://Stackoverflow.com/users/14551796", "pm_score": -1, "selected": false, "text": "$( \".cartcontainer p:first-child\" ).text();\n" }, { "answer_id": 74188050, "author": "Phil", "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74188150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14551989/" ]
74,188,160
<p>I want to convert the given string to a title case:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const titleCase = function (text) { if (text === "") return ""; let textArr = text.split(" "); const outputArr = textArr.map( ele =&gt; ele.toLowerCase().replace(ele[0], ele[0].toUpperCase()) ); const output = outputArr.join(" "); return output; }; const test1 = titleCase("this is an example"); const test2 = titleCase("WHAT HAPPENS HERE"); console.log(test1); console.log(test2);</code></pre> </div> </div> </p> <p><code>test1</code> gives me the right result <code>This Is An Example</code> but test2 returns <code>what happens here</code> which is not the result that I want.</p> <p>I am confused... where did it go wrong?</p>
[ { "answer_id": 74188015, "author": "L8R", "author_id": 14551796, "author_profile": "https://Stackoverflow.com/users/14551796", "pm_score": -1, "selected": false, "text": "$( \".cartcontainer p:first-child\" ).text();\n" }, { "answer_id": 74188050, "author": "Phil", "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74188160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17176026/" ]
74,188,161
<p>I have a spreadsheet that lists various employee shifts, with one column for start time and another for end time (in 24-hour military time). I need to be able to run a function to calculate how long each shift is. I am sure I am way over thinking this because I am very stuck. Below is the function that I have so far but unfortunately for an 8 hour shift it comes back as undefined:</p> <pre><code>// Desired result for a shift from 0500-1300, 1300-2100 or 2100-0500 would be &quot;8:00&quot; Logger.log(calculate8hours(500, 1300)) function calculate8hours (x, y) { if ( (y-x) &gt;0) { let hour = (String((y - x) / 100)).split(&quot;.&quot;)[0]; let minutes = (String((y - x) / 100)).split(&quot;.&quot;)[1]; return `${hour}:${minutes}` } else { return (((2400-x) + y)) /100; }; }; </code></pre>
[ { "answer_id": 74188188, "author": "Topdev", "author_id": 20315389, "author_profile": "https://Stackoverflow.com/users/20315389", "pm_score": 0, "selected": false, "text": "var duration = moment.duration(end.diff(startTime));\nvar hours = duration.asHours();\n" }, { "answer_id": ...
2022/10/25
[ "https://Stackoverflow.com/questions/74188161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18936063/" ]
74,188,175
<p>I want to support serializing additional relevant data with a Serilog log but I want to ensure that this data is written in valid JSON. It will be captured and stored separately by my own log event sink.</p> <p>For this example I have an optional object property called &quot;additionalDetails&quot;</p> <p>I can use the following to write the log information and the additionalDetails can be extracted as JSON:</p> <pre><code>int messageId = 99; var additionalDetails = new {SomeId = 1, SomeValue = &quot;This is a test value&quot;}; logger.Information(&quot;Test Log Entry: {messageId} Additional Details: {@additionalDetails}&quot;, messageId, additionalDetails); </code></pre> <p>In my Sink I can retrieve the &quot;additionalDetails&quot; as JSON from the logEvent.Properties and write it. However, I don't want to necessarily include the AdditionalDetails in every log message text.</p> <p>What I would like is:</p> <pre><code>int messageId = 99; var additionalDetails = new {SomeId = 1, SomeValue = &quot;This is a test value&quot;}; logger .ForContext(&quot;additionalDetails&quot;, additionalDetails) .Information(&quot;Test Log Entry: {messageId}&quot;, messageId); </code></pre> <p>The problem here is that while the Sink can see the additionalDetails value, it isn't coming back as valid JSON, but the default stringified value. For unit testing I am validating that the stored object is complete, which puts a bit of a blocker if I cannot convert that stringified value back into an object.</p> <p>On a whim I tried: <code>.ForContext(&quot;@additionalDetails&quot;, additionalDetails)</code> and &quot;{@additionalDetails}&quot; but that was no joy.</p> <p>I also found a recommendation to write the object as a string using <code>JsonConvert.Serialize(additionalDetails)</code> but that ended up causing extra quote escaping in the resulting string captured by the Sink <code>logEvent.Properties[&quot;additionalDetails&quot;].ToString()</code>.</p> <p>Is there a way that <code>ForContext</code> can serialize an object like with the &quot;{@additionalDetails}&quot;, or include the &quot;{@additionalDetails}&quot; and parameter in the <code>.Information()</code> etc. calls without the parameter being rendered in the message? (sounds rather silly round-about)</p>
[ { "answer_id": 74188188, "author": "Topdev", "author_id": 20315389, "author_profile": "https://Stackoverflow.com/users/20315389", "pm_score": 0, "selected": false, "text": "var duration = moment.duration(end.diff(startTime));\nvar hours = duration.asHours();\n" }, { "answer_id": ...
2022/10/25
[ "https://Stackoverflow.com/questions/74188175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/423497/" ]
74,188,183
<p>I am in the <code>z.py</code> file, and I would like to import the <code>x.py</code> file and also a function of it (function_example). Considering that I cannot use directly <code>import folder1</code> or <code>from folder1.x import *</code>,</p> <p>how can I import file x? How can I enter the folder1 folder when I am in the z.py file of the other folder?</p> <pre><code>my_project/ engine/ folder1/ x.py folder2/ y.py other/ z.py </code></pre> <p>On the web I read that I could use this, but it doesn't work for me:</p> <pre><code>import sys sys.path.insert(0, 'my_project/engine/folder1/x') import x from x import function_example engine.folder1.x.function_example(sogg) #use function imported </code></pre>
[ { "answer_id": 74188188, "author": "Topdev", "author_id": 20315389, "author_profile": "https://Stackoverflow.com/users/20315389", "pm_score": 0, "selected": false, "text": "var duration = moment.duration(end.diff(startTime));\nvar hours = duration.asHours();\n" }, { "answer_id": ...
2022/10/25
[ "https://Stackoverflow.com/questions/74188183", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20296788/" ]
74,188,246
<p>This is so simple, yet why so complicated ?</p> <p>I was to return true if there are two same integer in a list and false otherwise, but I can't seem to get it right. Why?</p> <p>Here's what i did:</p> <p>python</p> <pre><code>def high(n): for x in n: if x==x: return True elif x!=x: return False </code></pre> <p>Thanks,</p>
[ { "answer_id": 74188282, "author": "pavel", "author_id": 2825403, "author_profile": "https://Stackoverflow.com/users/2825403", "pm_score": 2, "selected": false, "text": "[1, 2, 2]" }, { "answer_id": 74188324, "author": "Beginer", "author_id": 8691290, "author_profile"...
2022/10/25
[ "https://Stackoverflow.com/questions/74188246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20214604/" ]
74,188,249
<p>Hello I am trying to figure out how to modify this membership function to find the nearest crisp value. This is just part of the code I am working on and I just want some advice on what I could do to find the nearest crisp value.</p> <pre><code>def membership(inputValue, fuzzySet): for p in fuzzySet: fuzzyValue, crisp = p if crisp == inputValue: return fuzzyValue bottle = {(0.0,0.2), (0.5,0.5), (1.0,1.0), (0.5,1.5), (0.0,2.0)} </code></pre> <p>What the input should look like:</p> <pre><code>&gt;&gt;&gt; membership(2.0,bottle) 0.0 &gt;&gt;&gt; membership(0.712321345,bottle) 0.5 </code></pre>
[ { "answer_id": 74188371, "author": "Modularizer", "author_id": 15607248, "author_profile": "https://Stackoverflow.com/users/15607248", "pm_score": 0, "selected": false, "text": "crisps=[v[1] for v in bottle]\n" }, { "answer_id": 74188388, "author": "bn_ln", "author_id": 1...
2022/10/25
[ "https://Stackoverflow.com/questions/74188249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12385020/" ]
74,188,254
<p>I am currently trying to create a search function to filter a constitution on the Home Page by using the name[title]. I used the CupertinoSearchTextField class. The constitutions posted will be displayed when the homepage, the search bar will allow users to search for a specific constitution.</p> <p>Code of search widget container</p> <pre><code>import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class SearchBar extends StatelessWidget { const SearchBar({super.key}); @override Widget build(BuildContext context) { return Container( margin: const EdgeInsets.symmetric(vertical: 30), padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 8), child: CupertinoSearchTextField( onChanged: ((value) { }), autofocus: true, itemColor: Colors.black, itemSize: 20, backgroundColor: const Color.fromARGB(255, 185, 204, 218), placeholderStyle: const TextStyle( color: Colors.black, fontSize: 18, ), ), ); } } </code></pre> <p>Code of the Home Page</p> <pre><code>// ignore_for_file: prefer_const_constructors import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:project/controller/constitution_controller.dart'; import 'package:project/model/constitution_model.dart'; import 'package:project/screens/branch_page.dart'; import 'package:project/widgets/drawer_widget.dart'; import 'package:project/widgets/searchbar.dart'; import 'package:project/widgets/shimmer_grid_card.dart'; import 'package:shimmer/shimmer.dart'; import '../widgets/constitution_card.dart'; class HomePage extends StatefulWidget { const HomePage({Key? key}) : super(key: key); @override State&lt;HomePage&gt; createState() =&gt; _HomePageState(); } class _HomePageState extends State&lt;HomePage&gt; { final ConstitutionController constitutionController = Get.find(); @override Widget build(BuildContext context) { final double height = MediaQuery.of(context).size.height; return Scaffold( appBar: AppBar( backgroundColor: const Color(0xFF0B3C5D), elevation: 0.0, ), drawer: DrawerWidget(), body: Stack(children: [ Container( height: height * 0.45, decoration: const BoxDecoration( color: Color(0xFF0B3C5D), // image: DecorationImage( // image: ExactAssetImage('images/hpb.png')) ), ), SafeArea( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 20), child: Column( children: [ Text( 'Legal Companion', style: GoogleFonts.firaSans( textStyle: const TextStyle( color: Colors.white, fontSize: 32, ), ), ), // The Search bar const SearchBar(), const SizedBox( height: 70, ), Flexible( child: Obx(() { if (constitutionController.isLoading.value) { return GridView.builder( itemBuilder: (_, __) { return Shimmer.fromColors( baseColor: Colors.grey[300]!, highlightColor: Colors.grey[100]!, period: Duration(seconds: 2), enabled: constitutionController.isLoading.value, child: ShimmerGridCard()); }, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2), ); } else { return GridView.builder( itemCount: constitutionController.constitutionList.length, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2), itemBuilder: (context, index) { Constitution constitution = constitutionController.constitutionList[index]; return InkWell( onTap: (() { Get.to( BranchPage(constitutionId: constitution)); }), child: ConstitutionCard(constitutionController .constitutionList[index])); }); } }), ), ], ), ), ), ]), ); } } </code></pre> <p>The Constitution Card Code. The various cards on the home page</p> <pre><code>// ignore_for_file: prefer_const_constructors import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:project/model/constitution_model.dart'; class ConstitutionCard extends StatelessWidget { final Constitution constitution; const ConstitutionCard(this.constitution, {super.key}); @override Widget build(BuildContext context) { return Card( color: Colors.blueAccent[80], child: Padding( padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Spacer(), SizedBox( height: 85, width: double.infinity, child: SvgPicture.asset(&quot;assets/images/ug.svg&quot;), ), const Spacer(), Text( constitution.title, textAlign: TextAlign.center, style: GoogleFonts.openSans( textStyle: const TextStyle( fontSize: 16, fontWeight: FontWeight.w700, ), ), ), Spacer() ], ), ), ); } } </code></pre> <p>The Code of the Controller</p> <pre><code>import 'dart:convert'; import 'package:get/state_manager.dart'; import 'package:project/model/constitution_model.dart'; import 'package:project/services/service.dart'; class ConstitutionController extends GetxController { var isLoading = false.obs; RxList constitutionList = &lt;Constitution&gt;[].obs; RxList chapterList = &lt;Chapter&gt;[].obs; RxList sectionList = &lt;Section&gt;[].obs; //Causes the objects to appear on debugging @override void onInit() { getConstitutions(&quot;&quot;); super.onInit(); } void getConstitutions(String search) async { try { isLoading(true); dynamic response = await HttpService.getConstitutions(search); if (response.statusCode == 200) { List&lt;dynamic&gt; body = jsonDecode(response.body); List&lt;Constitution&gt; constitutions = body .map( (dynamic item) =&gt; Constitution.fromJson(item), ) .toList(); constitutionList(constitutions); isLoading(false); } } catch (err) { isLoading(false); } finally { isLoading(false); } } Future getChapters(String constitutionId) async { try { isLoading(true); dynamic response = await HttpService.getChapters(constitutionId); if (response.statusCode == 200) { List&lt;dynamic&gt; body = jsonDecode(response.body); List&lt;Chapter&gt; chapters = body .map( (dynamic item) =&gt; Chapter.fromJson(item), ) .toList(); chapterList(chapters); isLoading(false); } } catch (err) { // print(err); isLoading(false); } finally { isLoading(false); } } Future getSections(String constitutionId, String chapterId) async { try { isLoading(true); dynamic response = await HttpService.getSections(constitutionId, chapterId); if (response.statusCode == 200) { List&lt;dynamic&gt; body = jsonDecode(response.body); List&lt;Section&gt; sections = body .map( (dynamic item) =&gt; Section.fromJson(item), ) .toList(); sectionList(sections); // print(sectionList); isLoading(false); } } catch (err) { // print(&quot;errorr hhhherrrrrrrhhhh&quot;); // print(err); isLoading(false); } finally { isLoading(false); } } } </code></pre>
[ { "answer_id": 74188371, "author": "Modularizer", "author_id": 15607248, "author_profile": "https://Stackoverflow.com/users/15607248", "pm_score": 0, "selected": false, "text": "crisps=[v[1] for v in bottle]\n" }, { "answer_id": 74188388, "author": "bn_ln", "author_id": 1...
2022/10/25
[ "https://Stackoverflow.com/questions/74188254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20199673/" ]
74,188,321
<p>I have 3 schemas:</p> <pre><code>const userSchema = new mongoose.Schema({ username:{ type: String, unique: true }, password:{ type: String }, tasks:{ type:[mongoose.Types.ObjectId] } }) </code></pre> <pre><code>const taskSchema = new mongoose.Schema({ title:{ type: String }, finished:{ type: Boolean }, deadline:{ type:Date }, subtasks:{ type:[mongoose.Types.ObjectId] } }) </code></pre> <pre><code>const subtaskSchema = new mongoose.Schema({ title:{ type: String }, finished:{ type: Boolean }, deadline:{ type:Date }, }) </code></pre> <p>I would like to perform a query that would return something like this:</p> <pre><code>{ &quot;_id&quot;: &quot;id&quot;, &quot;username&quot;: &quot;username&quot;, &quot;password&quot;: &quot;password&quot;, &quot;tasks&quot;: [ &quot;_id&quot;: &quot;id&quot;, &quot;title&quot;: &quot;title&quot;, &quot;deadline&quot;: &quot;deadline&quot;, &quot;finished&quot;: false, &quot;subtasks&quot;: [ { &quot;_id&quot;: &quot;id&quot;, &quot;title&quot;: &quot;title&quot;, &quot;deadline&quot;: &quot;deadline&quot;, &quot;finished&quot;: false } ] ] } </code></pre> <p>To my understading, aggregate should do this but I'm not quite sure how to handle nested arrays with it. I know that relational DBs would suit this better, but this is the situation I am currently in. Any help is appreciated!</p>
[ { "answer_id": 74188371, "author": "Modularizer", "author_id": 15607248, "author_profile": "https://Stackoverflow.com/users/15607248", "pm_score": 0, "selected": false, "text": "crisps=[v[1] for v in bottle]\n" }, { "answer_id": 74188388, "author": "bn_ln", "author_id": 1...
2022/10/25
[ "https://Stackoverflow.com/questions/74188321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14276786/" ]
74,188,323
<p>I am making a chat app, and I want to escape all HTML sent to the event (except <code>&lt;a&gt;</code> tags, because links are auto-converted to HTML).</p> <p>This is my escape function:</p> <pre class="lang-js prettyprint-override"><code>const escapeHtml = (unsafe) =&gt; { return unsafe.replaceAll('&lt;', '&amp;lt;').replaceAll('&gt;', '&amp;gt;'); }; </code></pre> <p>and this is the element's HTML (that is shown to the user/client):</p> <pre class="lang-js prettyprint-override"><code>message.innerHTML = escapeHtml(json.username) + &quot;:&lt;br/&gt;&quot; + escapeHtml(json.message); </code></pre>
[ { "answer_id": 74188590, "author": "slebetman", "author_id": 167735, "author_profile": "https://Stackoverflow.com/users/167735", "pm_score": -1, "selected": false, "text": ".replaceAll()" }, { "answer_id": 74189012, "author": "Kaiido", "author_id": 3702797, "author_pr...
2022/10/25
[ "https://Stackoverflow.com/questions/74188323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14551796/" ]
74,188,391
<p>I call the API to get all the images and render them on the page. Then I want to click on an image to navigate to a new page which can show the attributes of the clicked image like src, id, name, etc.</p> <p>Here is the part of my code</p> <pre><code>function CustomContent() { const [customContent, setCustomContentResults] = useState([]) const fetchData = async() =&gt; {...} useEffect(...) const handleClick=(post)=&gt;{ } const content = customContent?.map(post =&gt; { return &lt;li key={post.id}&gt; &lt;div&gt; &lt;img alt=&quot;&quot; src={post.src.medium} onClick={() =&gt; handleClick(post)}&gt;&lt;/img&gt; &lt;/div&gt; &lt;/li&gt; }) return ( &lt;div &gt; &lt;ul&gt; {content} &lt;/ul&gt; &lt;/div&gt; ) } </code></pre> <p>How to write the handleClick function? And in the detail.jsx, how to get the post data?</p>
[ { "answer_id": 74188590, "author": "slebetman", "author_id": 167735, "author_profile": "https://Stackoverflow.com/users/167735", "pm_score": -1, "selected": false, "text": ".replaceAll()" }, { "answer_id": 74189012, "author": "Kaiido", "author_id": 3702797, "author_pr...
2022/10/25
[ "https://Stackoverflow.com/questions/74188391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20280200/" ]
74,188,393
<p>I have a large collection of JSON documents that has many entries of the following format (contents in my example are important to my question):</p> <pre><code>doc1 { &quot;data&quot;: [{ &quot;entry&quot;: { &quot;fieldA&quot;: &quot;aaa&quot;, &quot;fieldB&quot;: &quot;xxx&quot; } }, { &quot;entry&quot;: { &quot;fieldA&quot;: &quot;ccc&quot;, &quot;fieldB&quot;: &quot;yyy&quot; } }, { &quot;entry&quot;: { &quot;fieldA&quot;: &quot;eee&quot;, &quot;fieldB&quot;: &quot;xxx&quot; } } ] } doc2 { &quot;data&quot;: [{ &quot;entry&quot;: { &quot;fieldA&quot;: &quot;aaa&quot;, &quot;fieldB&quot;: &quot;xxx&quot; } }, { &quot;entry&quot;: { &quot;fieldA&quot;: &quot;ccc&quot;, &quot;fieldB&quot;: &quot;yyy&quot; } }, { &quot;entry&quot;: { &quot;fieldA&quot;: &quot;eee&quot;, &quot;fieldB&quot;: &quot;nnn&quot; } } ] } ... docN { &quot;data&quot;: [{ &quot;entry&quot;: { &quot;fieldA&quot;: &quot;aaa&quot;, &quot;fieldB&quot;: &quot;yyy&quot; } }, { &quot;entry&quot;: { &quot;fieldA&quot;: &quot;ccc&quot;, &quot;fieldB&quot;: &quot;yyy&quot; } }, { &quot;entry&quot;: { &quot;fieldA&quot;: &quot;eee&quot;, &quot;fieldB&quot;: &quot;xxx&quot; } } ] } </code></pre> <p>What I want to do is create a query that follows the below rule:</p> <p>Only returns documents where it has a <code>fieldA</code> that contains <code>aaa</code> and has another entry where <code>fieldA</code> contains <code>eee</code> AND where the <code>fieldB</code> of those entries have values that match.</p> <p>In the above example, that would be the first top level document as the <code>fieldB</code> for both sub entries are <code>xxx</code></p> <p>Additionally it would be nice to have just the entries pruned in the returned document, instead of the whole document</p>
[ { "answer_id": 74190018, "author": "nodejs developer", "author_id": 20155346, "author_profile": "https://Stackoverflow.com/users/20155346", "pm_score": 0, "selected": false, "text": "[{\n $unwind: {\n path: '$data'\n }\n}, {\n $match: {\n $or: [\n {\n 'data.entry.fieldA': 'aaa'\n ...
2022/10/25
[ "https://Stackoverflow.com/questions/74188393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1354514/" ]
74,188,424
<p>The Code A is from the <a href="https://stackoverflow.com/questions/74092059/how-can-i-convert-a-val-to-a-fun-when-i-use-jetpack-compose-in-kotlin">question</a> answered by Roman Y.</p> <p>The Code A can work well when it invokes with <code>background(appState)() {...}</code>, why can't I remove parentheses ()?</p> <p>But Code B fails when it invoke with <code>background(appState) {...}</code>, why?</p> <p>And more Code C can work well when it invokes with <code>val aa=background(appState) aa{...}</code>, why?</p> <p><strong>Code A</strong></p> <pre><code>@Composable fun NiaApp( windowSizeClass: WindowSizeClass, appState: NiaAppState = rememberNiaAppState(windowSizeClass) ) { NiaTheme { background(appState)() { Scaffold( ... ) { padding -&gt; } } } } @Composable fun background(appState: NiaAppState): @Composable (@Composable () -&gt; Unit) -&gt; Unit = when (appState.currentDestination?.route) { ForYouDestination.route -&gt; { content -&gt; NiaGradientBackground(content = content) } else -&gt; { content -&gt; NiaBackground(content = content) } } </code></pre> <p><strong>Code B</strong></p> <pre><code>@Composable fun NiaApp( windowSizeClass: WindowSizeClass, appState: NiaAppState = rememberNiaAppState(windowSizeClass) ) { NiaTheme { background(appState){ Scaffold( ... ) { padding -&gt; } } } } ... </code></pre> <p><strong>Code C</strong></p> <pre><code>@Composable fun NiaApp( windowSizeClass: WindowSizeClass, appState: NiaAppState = rememberNiaAppState(windowSizeClass) ) { val aa=background(appState) NiaTheme { aa{ Scaffold( ... ) { padding -&gt; } } } } ... </code></pre>
[ { "answer_id": 74237647, "author": "z.y", "author_id": 19023745, "author_profile": "https://Stackoverflow.com/users/19023745", "pm_score": 4, "selected": true, "text": "Kotlin" }, { "answer_id": 74266402, "author": "KennyC", "author_id": 15319313, "author_profile": "h...
2022/10/25
[ "https://Stackoverflow.com/questions/74188424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/828896/" ]
74,188,452
<p>I have 12 or so buttons on my HTML, and I want to change the text of just one paragraph after I click each button, because each button should deliver a different text. The problem is that, because I generated all the buttons through a Jinja loop (I'm running server in Flask) I only get the text from the LAST iteration of the loop, no matter which button I click. As you can see, I created the function that does the magic, but I don't know where to place it so I can get the text from each button separately. I hope this is not too obvious and someone'll be kind enough to respond. Please consider that I'm studying Python, so I'm below noob level on all things JS. Thanks a lot!</p> <pre><code>&lt;table class=&quot;table&quot;&gt; &lt;tr&gt; {%for i in days: %} &lt;td&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt; {{ days[i] }} &lt;hr class=&quot;zero&quot;&gt; &lt;/th&gt; &lt;/tr&gt; {%for x in tasks: %} {%if x.owner_id == i: %} &lt;tr&gt; &lt;td&gt; &lt;button class=&quot;click&quot; onclick=&quot;change_text()&quot;&gt;{{ x.task_name }}&lt;/button&gt; &lt;hr class=&quot;zero&quot;&gt; &lt;/td&gt; &lt;/tr&gt; {%endif%} &lt;script&gt; function change_text(){ document.getElementById(&quot;demo&quot;).innerHTML = &quot;{{ x.task_id }}&quot;; } &lt;/script&gt; {%endfor%} &lt;/table&gt; &lt;/td&gt; {%endfor%} </code></pre>
[ { "answer_id": 74188475, "author": "flappix", "author_id": 2213309, "author_profile": "https://Stackoverflow.com/users/2213309", "pm_score": 2, "selected": true, "text": "change_text" }, { "answer_id": 74188481, "author": "lester", "author_id": 20199673, "author_profi...
2022/10/25
[ "https://Stackoverflow.com/questions/74188452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20326218/" ]
74,188,455
<p>I am trying to build out multilayer dictionary. The input looks like this.</p> <pre><code>my_list = [['Japan', 'Consumer Durables'], ['United States', 'Electronic Technology', 'ANALYST PICK'], ['Japan', 'Finance'], ['South Korea', 'Electronic Technology']] df = pd.DataFrame(my_list, columns=['country','sector','flag']) </code></pre> <pre><code> country sector flag 0 Japan Consumer Durables None 1 United States Electronic Technology ANALYST PICK 2 Japan Finance None 3 South Korea Electronic Technology None </code></pre> <p>And desired output looks like this.</p> <pre><code>{&quot;groups&quot; : [ { &quot;name&quot; : &quot;Japan&quot;, &quot;groups&quot; : [ {&quot;name&quot; : &quot;Consumer Durables&quot;, &quot;indices&quot; : [0]}, {&quot;name&quot; : &quot;Finance&quot;, &quot;indices&quot; : [2]} ], }, { &quot;name&quot; : &quot;United States&quot;, &quot;groups&quot; : [ { &quot;name&quot; : &quot;Electronic Technology&quot;, &quot;groups&quot; : [ {&quot;name&quot; : &quot;ANALYST PICK&quot;, &quot;indices&quot; : [1]} ] } ] }, { &quot;name&quot; : &quot;South Korea&quot;, &quot;groups&quot; : [ {&quot;name&quot; : &quot;Electronic Technology&quot;, &quot;indices&quot; : [3]} ] } ] } </code></pre> <p>Each indices refers the index of the original dataframe. I tried to build the code with for loops but had no luck.</p> <p>Is there anyway to solve this problem?</p> <p>Thanks.</p>
[ { "answer_id": 74188475, "author": "flappix", "author_id": 2213309, "author_profile": "https://Stackoverflow.com/users/2213309", "pm_score": 2, "selected": true, "text": "change_text" }, { "answer_id": 74188481, "author": "lester", "author_id": 20199673, "author_profi...
2022/10/25
[ "https://Stackoverflow.com/questions/74188455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14405631/" ]
74,188,468
<p>I've got an array with data like this</p> <pre><code>a = [[1,2,3],[4,5,6],[7,8,9]] </code></pre> <p>and I want to change it to</p> <pre><code>b = [[1,1,2,2,3,3],[1,1,2,2,3,3],[4,4,5,5,6,6],[4,4,5,5,6,6],[7,7,8,8,9,9],[7,7,8,8,9,9]] </code></pre> <p>I've tried to use <code>numpy.resize()</code> function but after resizing, it gives <code>[[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]]</code>. I can use a for loop to put the numbers at the indexes I need but just wondering if there is any easier way of doing that?</p> <p>To visualise the task, here is the original array</p> <p><a href="https://i.stack.imgur.com/g2Rb5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g2Rb5.png" alt="Array a" /></a></p> <p>This is what I want</p> <p><a href="https://i.stack.imgur.com/LWD0J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LWD0J.png" alt="Array b" /></a></p>
[ { "answer_id": 74188577, "author": "Modularizer", "author_id": 15607248, "author_profile": "https://Stackoverflow.com/users/15607248", "pm_score": 3, "selected": true, "text": "np.tile" }, { "answer_id": 74191424, "author": "MisterMiyagi", "author_id": 5349916, "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74188468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10275029/" ]
74,188,499
<p>We assume curr_player to be 'X'. Output should be 'O', and vice-versa</p> <p>(is my code correct?)</p> <pre><code> #my code def switchPlayer(curr_player): if curr_player == &quot;X&quot; or curr_player == &quot;x&quot;: print(&quot;your Player 'O' &quot;) return curr_player if curr_player == &quot;O&quot; or curr_player == &quot;o&quot;: print(&quot;your Player 'X' &quot;) return curr_player switchPlayer(&quot;X&quot;) </code></pre>
[ { "answer_id": 74188577, "author": "Modularizer", "author_id": 15607248, "author_profile": "https://Stackoverflow.com/users/15607248", "pm_score": 3, "selected": true, "text": "np.tile" }, { "answer_id": 74191424, "author": "MisterMiyagi", "author_id": 5349916, "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74188499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19862700/" ]
74,188,512
<p>I'm stuck on this exercise:</p> <p>Please write a program that asks for tomorrow's weather forecast and then suggests weather-appropriate clothing.</p> <p>The suggestion should change if the temperature (measured in degrees Celsius) is over 20, 10, or 5 degrees, and also if there is rain on the radar.</p> <p>Some examples of expected behavior:</p> <pre><code>What is the weather forecast for tomorrow? Temperature: 21 Will it rain (yes/no): no Wear jeans and a T-shirt </code></pre> <pre><code>What is the weather forecast for tomorrow? Temperature: 11 Will it rain (yes/no): no Wear jeans and a T-shirt I recommend a jumper as well </code></pre> <pre><code>What is the weather forecast for tomorrow? Temperature: 7 Will it rain (yes/no): no Wear jeans and a T-shirt I recommend a jumper as well Take a jacket with you </code></pre> <pre><code>What is the weather forecast for tomorrow? Temperature: 3 Will it rain (yes/no): yes Wear jeans and a T-shirt I recommend a jumper as well Take a jacket with you Make it a warm coat, actually I think gloves are in order Don't forget your umbrella! </code></pre> <p>My code is:</p> <pre><code>temperature = int(input(&quot;Temperature: &quot;)) rain = input(&quot;Will it rain (yes/no): &quot;) if temperature &gt; 20: print(&quot;Wear jeans and a T-shirt&quot;) if temperature &gt; 10: print(&quot;I recommend a jumper as well&quot;) if temperature &gt; 5: print(&quot;Take a jacket with you&quot;) if rain == &quot;yes&quot;: print(&quot;Don't forget your umbrella!&quot;) </code></pre> <p>I don't know how to resolve it! Can anyone teach me?</p>
[ { "answer_id": 74188577, "author": "Modularizer", "author_id": 15607248, "author_profile": "https://Stackoverflow.com/users/15607248", "pm_score": 3, "selected": true, "text": "np.tile" }, { "answer_id": 74191424, "author": "MisterMiyagi", "author_id": 5349916, "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74188512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20326322/" ]
74,188,547
<pre><code>import hashlib import csv import glob def hash(text): return hashlib.sha256(text.encode('UTF-8')).hexdigest() def hash_file(input_file_name,output_file_name): with open(input_file_name, newline='') as f_input, open(output_file_name, 'w', newline='') as f_output: csv_input = csv.reader(f_input) csv_output = csv.writer(f_output) csv_output.writerow(next(csv_input)) # Copy the header row to the output count = 0 print(count) for customer_email in csv_input: csv_output.writerow([hash(customer_email[0])]) count = count + 1 print(str(count) + &quot; - &quot; + customer_email[0]) f_input.close() f_output.close mylist = [f for f in glob.glob(&quot;*.csv&quot;)] for file in mylist: i_file_name = file o_file_name = &quot;hashed-&quot; + file hash_file(i_file_name,o_file_name) </code></pre> <p>I'm trying the above code and I keep getting a list index out of range. I have about 15 csv files that I would like to hash the email address on. It gets the first csv file and keeps iterating through it until I get the error message. Any help would be appreciated.</p>
[ { "answer_id": 74188577, "author": "Modularizer", "author_id": 15607248, "author_profile": "https://Stackoverflow.com/users/15607248", "pm_score": 3, "selected": true, "text": "np.tile" }, { "answer_id": 74191424, "author": "MisterMiyagi", "author_id": 5349916, "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74188547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20326377/" ]
74,188,610
<p>I was going by this update for EKS <a href="https://aws.amazon.com/about-aws/whats-new/2020/03/amazon-eks-adds-envelope-encryption-for-secrets-with-aws-kms/" rel="nofollow noreferrer">https://aws.amazon.com/about-aws/whats-new/2020/03/amazon-eks-adds-envelope-encryption-for-secrets-with-aws-kms/</a> and this blog from AWS <a href="https://aws.amazon.com/blogs/containers/using-eks-encryption-provider-support-for-defense-in-depth/" rel="nofollow noreferrer">https://aws.amazon.com/blogs/containers/using-eks-encryption-provider-support-for-defense-in-depth/</a>.</p> <p>This is a very cryptic line which never confirms whether EKS encrypts secrets or not by default</p> <blockquote> <p>In EKS, we operate the etcd volumes encrypted at disk-level using AWS-managed encryption keys.</p> </blockquote> <p>I did understand that:-</p> <ul> <li>KMS with EKS will provide envelope encryption,like encrypting the DEK using CMK.</li> <li>But it never mentioned that if I don't use this feature ( of course KMS will cost ), does EKS encrypts data by default?</li> </ul> <p>Because Kubernetes by default does not encrypt data . <a href="https://kubernetes.io/docs/concepts/configuration/secret/" rel="nofollow noreferrer">Source</a></p> <blockquote> <p>Kubernetes Secrets are, by default, stored unencrypted in the API server's underlying data store (etcd). Anyone with API access can retrieve or modify a Secret, and so can anyone with access to etcd. Additionally, anyone who is authorized to create a Pod in a namespace can use that access to read any Secret in that namespace; this includes indirect access such as the ability to create a Deployment.</p> </blockquote>
[ { "answer_id": 74189027, "author": "Adiii", "author_id": 3288890, "author_profile": "https://Stackoverflow.com/users/3288890", "pm_score": 0, "selected": false, "text": "etcd" } ]
2022/10/25
[ "https://Stackoverflow.com/questions/74188610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13126651/" ]
74,188,618
<p>I am having some trouble with writing a method that when prompted with a number returns how many times each value is repeated. For example, if the number 7846597 is entered the method would return:</p> <pre class="lang-none prettyprint-override"><code>0 - 0 1 - 0 2 - 0 3 - 0 4 - 1 5 - 1 6 - 1 7 - 2 8 - 1 9 - 1 </code></pre> <p>I know this would be most easily done with a loop, but I am not sure how to write the actual code. I also know that I need to convert the number value I get as an input into a string so I can use char methods.</p> <p>This is my attempt:</p> <pre class="lang-java prettyprint-override"><code>public double countOccurences(int num) { String str = num + &quot;&quot;; int goneThrough = 0; int count0 = 0; int count1 = 0; int count2 = 0; int count3 = 0; int count4 = 0; int count5 = 0; int count6 = 0; int count7 = 0; int count8 = 0; int count9 = 0; while(goneThrough &lt;= str.length()) { int value = 0; if(value &gt;= 10){ value = value * 0; } if(str.charAt(0) == 0) count0++; if(str.charAt(0) = 1) count1++; } return count0; return count1; return count2; return count3; return count4; return count5; return count6; return count7; return count8; return count9; } </code></pre>
[ { "answer_id": 74188717, "author": "Chintan Trivedi", "author_id": 17791486, "author_profile": "https://Stackoverflow.com/users/17791486", "pm_score": 1, "selected": false, "text": "// code\nimport java.util.*;\n\nclass Main { \n public static void main(String args[]) { \n String nu...
2022/10/25
[ "https://Stackoverflow.com/questions/74188618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20146539/" ]
74,188,619
<p>I have 3 C++ files:</p> <p>Main.cpp</p> <pre><code>#include &quot;FileA.h&quot; </code></pre> <p>FileA.h</p> <pre><code>#include &quot;FileB.h&quot; class FileA{ private: FileB* b; //It doesn't give error here! }; </code></pre> <p>FileB.h</p> <pre><code>class FileB{ private: FileA* A; //The error is here! }; </code></pre> <p>When I run the Main.cpp file, the compiler says:</p> <pre><code>'FileA' does not name a type, did you mean 'FileB'? </code></pre> <p>This is the first time I use StackOverflow to ask question so it's kinda messy, sorry. Anyone knows how to fix this problem and the cause of it ? Thank you in advance!</p>
[ { "answer_id": 74188663, "author": "bolov", "author_id": 2805305, "author_profile": "https://Stackoverflow.com/users/2805305", "pm_score": 2, "selected": false, "text": "#include" }, { "answer_id": 74188701, "author": "user4581301", "author_id": 4581301, "author_profi...
2022/10/25
[ "https://Stackoverflow.com/questions/74188619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16665265/" ]
74,188,629
<p><strong>My Problems:</strong> I'm trying to set auto height to my table cell. However, when I using <code>tableView.rowHeight = UITableView.automaticDimension</code> or <code>func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -&gt; CGFloat { return UITableView.automaticDimension }</code>. As shown on image, I got <strong>0</strong> height for my tableView; but if I set the tableView's height at autoLayout, I can see my tableView again.(which is not right because I want height to be dynamic, the button and the view should at bottom of table view.) <a href="https://i.stack.imgur.com/HaJaQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HaJaQ.png" alt="enter image description here" /></a> <a href="https://i.stack.imgur.com/CIk45.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CIk45.png" alt="enter image description here" /></a></p> <p><strong>Here is My ViewController Code:</strong></p> <pre><code>class ViewController: UIViewController { var dataSource = [&quot;1&quot;, &quot;2&quot;, &quot;1&quot;, &quot;2&quot;, &quot;1&quot;, &quot;2&quot;, &quot;1&quot;, &quot;2&quot;, &quot;1&quot;, &quot;2&quot;, &quot;1&quot;, &quot;2&quot;, &quot;1&quot;, &quot;2&quot;, &quot;1&quot;, &quot;2&quot;, &quot;1&quot;, &quot;2&quot;, &quot;1&quot;, &quot;2&quot;, &quot;1&quot;, &quot;2&quot;, &quot;1&quot;, &quot;2&quot;, &quot;1&quot;, &quot;2&quot;, &quot;1&quot;, &quot;2&quot;, &quot;1&quot;, &quot;2&quot;, &quot;1&quot;, &quot;2&quot;,] private lazy var scrollView: UIScrollView = { let scrollView = UIScrollView() scrollView.delegate = self scrollView.showsVerticalScrollIndicator = false scrollView.showsHorizontalScrollIndicator = false scrollView.contentInsetAdjustmentBehavior = .never scrollView.bounces = false return scrollView }() private lazy var tableView: UITableView = { let tableView = UITableView(frame: .zero, style: .plain) tableView.backgroundColor = .clear tableView.delegate = self tableView.dataSource = self tableView.register(TestTabelCell.self, forCellReuseIdentifier: TestTabelCell.identifier) tableView.rowHeight = UITableView.automaticDimension return tableView }() private lazy var moreBtn: UIButton = { let button = UIButton() button.setTitle(&quot;Click for More&quot;, for: .normal) button.setTitleColor(UIColor.green, for: .normal) return button }() private lazy var bottomView: UIView = { let view = UIView() view.backgroundColor = .brown return view }() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. setupUI() } func setupUI() { view.addSubview(scrollView) scrollView.addSubview(tableView) scrollView.addSubview(moreBtn) scrollView.addSubview(bottomView) scrollView.snp.makeConstraints { make in make.top.leading.trailing.equalToSuperview() make.bottom.equalToSuperview() } stackView.snp.makeConstraints { make in make.edges.equalToSuperview() } tableView.snp.makeConstraints { make in make.top.equalToSuperview() make.leading.trailing.equalToSuperview() } moreBtn.snp.makeConstraints { make in make.top.equalTo(tableView.snp.bottom) make.leading.trailing.equalToSuperview() make.height.equalTo(20) } bottomView.snp.makeConstraints { make in make.top.equalTo(moreBtn.snp.bottom) make.leading.trailing.equalToSuperview() make.width.equalTo(390) make.height.equalTo(400) make.bottom.equalToSuperview() } } } extension ViewController: UITableViewDelegate, UITableViewDataSource { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int { return dataSource.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: TestTabelCell.identifier, for: indexPath) if let cell = cell as? TestTabelCell { cell.updateUI(String(indexPath.row)) } return cell } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -&gt; CGFloat { print(&quot;print&quot;, UITableView.automaticDimension) return UITableView.automaticDimension } } </code></pre> <p><strong>and Here is My Cell Code:</strong></p> <pre><code>class TestTabelCell: UITableViewCell { static let identifier = &quot;ParlorJourneyListCell&quot; private lazy var label: UILabel = { let label = UILabel() label.font = UIFont.systemFont(ofSize: 12) label.textColor = .black return label }() override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: .default, reuseIdentifier: reuseIdentifier) setupUI() } required init?(coder aDecoder: NSCoder) { fatalError(&quot;init(coder:) has not been implemented&quot;) } func setupUI() { addSubview(label) label.snp.makeConstraints { make in make.top.equalToSuperview().inset(8) make.height.equalTo(20) make.bottom.equalToSuperview() } } func updateUI(_ num: String) { label.text = &quot;Test Num: \(num)&quot; } } </code></pre>
[ { "answer_id": 74188848, "author": "son", "author_id": 3214202, "author_profile": "https://Stackoverflow.com/users/3214202", "pm_score": 2, "selected": true, "text": "reloadData()" }, { "answer_id": 74247766, "author": "Arun Srithar", "author_id": 9425621, "author_pro...
2022/10/25
[ "https://Stackoverflow.com/questions/74188629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17296089/" ]
74,188,635
<p><a href="https://i.stack.imgur.com/0AdAq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0AdAq.png" alt="enter image description here" /></a></p> <p>Hi, I'm a Jenkins noob here, may I ask if there is a way for me to get the build trigger type (manual or auto) of the current build and the update status of the working copy like in the image above (no change or there are commits) in the Groovy script, so Jenkins can skip the auto build if there is no change?</p> <p>Thanks a lot.</p>
[ { "answer_id": 74188848, "author": "son", "author_id": 3214202, "author_profile": "https://Stackoverflow.com/users/3214202", "pm_score": 2, "selected": true, "text": "reloadData()" }, { "answer_id": 74247766, "author": "Arun Srithar", "author_id": 9425621, "author_pro...
2022/10/25
[ "https://Stackoverflow.com/questions/74188635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15306098/" ]
74,188,647
<p>How do I create a github workflow step name with a variable value.</p> <p>I tried this but it does not work.</p> <pre><code>name: Publish on: push: branches: - main env: REGISTRY: ghcr.io jobs: Publish: runs-on: ubuntu-latest steps: - name: Log into Container registry ${{ env.REGISTRY }} </code></pre>
[ { "answer_id": 74190177, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 0, "selected": false, "text": "name: Publish\non:\n push:\n branches:\n - main\nenv:\n REGISTRY: ghcr.io\n\njobs:\n Publish:\n runs-on: ubuntu...
2022/10/25
[ "https://Stackoverflow.com/questions/74188647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1096499/" ]
74,188,678
<p>I need to fetch data from API based on key and place the data inside a tablecell. I have tried something like the following but didn't work. It is showing an uncaught error.In that case, I know hooks shouldn't be called inside loops, conditions, or nested functions. Then how I would get the <code>item.id</code>?</p> <blockquote> <p>Uncaught Error: Rendered more hooks than during the previous render.</p> </blockquote> <p>My code is:</p> <pre><code>import React, { useState, useEffect } from 'react'; import { Table, TableRow, TableCell, TableHead, TableBody, } from '@mui/material'; import makeStyles from '@mui/styles/makeStyles'; import { useEffectAsync } from '../reactHelper'; import { useTranslation } from '../common/components/LocalizationProvider'; import PageLayout from '../common/components/PageLayout'; import SettingsMenu from './components/SettingsMenu'; import CollectionFab from './components/CollectionFab'; import CollectionActions from './components/CollectionActions'; import TableShimmer from '../common/components/TableShimmer'; const useStyles = makeStyles((theme) =&gt; ({ columnAction: { width: '1%', paddingRight: theme.spacing(1), }, })); const StoppagesPage = () =&gt; { const classes = useStyles(); const t = useTranslation(); const [timestamp, setTimestamp] = useState(Date.now()); const [items, setItems] = useState([]); const [geofences, setGeofences] = useState([]); const [loading, setLoading] = useState(false); useEffect(() =&gt; { fetch('/api/geofences') .then((response) =&gt; response.json()) .then((data) =&gt; setGeofences(data)) .catch((error) =&gt; { throw error; }); }, []); useEffectAsync(async () =&gt; { setLoading(true); try { const response = await fetch('/api/stoppages'); if (response.ok) { setItems(await response.json()); } else { throw Error(await response.text()); } } finally { setLoading(false); } }, [timestamp]); return ( &lt;PageLayout menu={&lt;SettingsMenu /&gt;} breadcrumbs={['settingsTitle', 'settingsStoppages']}&gt; &lt;Table&gt; &lt;TableHead&gt; &lt;TableRow&gt; &lt;TableCell&gt;{t('settingsStoppage')}&lt;/TableCell&gt; &lt;TableCell&gt;{t('settingsCoordinates')}&lt;/TableCell&gt; &lt;TableCell&gt;{t('sharedRoutes')}&lt;/TableCell&gt; &lt;TableCell className={classes.columnAction} /&gt; &lt;/TableRow&gt; &lt;/TableHead&gt; &lt;TableBody&gt; {!loading ? items.map((item) =&gt; ( &lt;TableRow key={item.id}&gt; &lt;TableCell&gt;{item.name}&lt;/TableCell&gt; &lt;TableCell&gt;{`Latitude: ${item.latitude}, Longitude: ${item.longitude}`}&lt;/TableCell&gt; &lt;TableCell&gt; { geofences.map((geofence) =&gt; geofence.name).join(', ') } &lt;/TableCell&gt; &lt;TableCell className={classes.columnAction} padding=&quot;none&quot;&gt; &lt;CollectionActions itemId={item.id} editPath=&quot;/settings/stoppage&quot; endpoint=&quot;stoppages&quot; setTimestamp={setTimestamp} /&gt; &lt;/TableCell&gt; &lt;/TableRow&gt; )) : (&lt;TableShimmer columns={2} endAction /&gt;)} &lt;/TableBody&gt; &lt;/Table&gt; &lt;CollectionFab editPath=&quot;/settings/stoppage&quot; /&gt; &lt;/PageLayout&gt; ); }; export default StoppagesPage; </code></pre>
[ { "answer_id": 74189961, "author": "Drew Reese", "author_id": 8690857, "author_profile": "https://Stackoverflow.com/users/8690857", "pm_score": 1, "selected": false, "text": "useEffect" }, { "answer_id": 74199092, "author": "cosmic", "author_id": 19905399, "author_pro...
2022/10/25
[ "https://Stackoverflow.com/questions/74188678", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19905399/" ]
74,188,679
<p>I'm stuck on a problem where I am supposed to make a method that returns the row with the highest average number in a 2D array</p> <p>The method that I attached here only gets the averages of each row. I believe that I need to keep track the row with the highest average but I just don't know how Any suggestions?</p> <pre><code>int[][] array = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} }; public static double getRowAverage(int grid[][]) { int i, j; double sum = 0, average = 0; for (i = 0; i &lt; grid.length; i++) { for (j = 0; j &lt; grid[i].length; j++) { sum = sum + grid[i][j]; } average=sum/grid[i].length; System.out.println(&quot;Average of row &quot; + (i+1) + &quot; = &quot; + average); sum=0; double a = i+1; } return average; } </code></pre>
[ { "answer_id": 74189961, "author": "Drew Reese", "author_id": 8690857, "author_profile": "https://Stackoverflow.com/users/8690857", "pm_score": 1, "selected": false, "text": "useEffect" }, { "answer_id": 74199092, "author": "cosmic", "author_id": 19905399, "author_pro...
2022/10/25
[ "https://Stackoverflow.com/questions/74188679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20187389/" ]
74,188,737
<p>How do i get a function to read a certain amount of lines and then compute a total by adding up the numbers from those lines printing it then looping to read the next lines etc. The function opens up a file that has hundreds of lines with numbers on them.</p> <p>Example:</p> <pre><code>def open_input_file(): while True: name_of_file = input(&quot;Enter the name of the input file: &quot;) try: file_wanted = open(name_of_file, 'r') return file_wanted except FileNotFoundError: print(f&quot;The file {name_of_file} was not found. Check the file name and try again.&quot;) def average_steps(read_file, amount_of_days): open(read_file.name, 'r') amount_of_lines = len(open(read_file.name).readlines(amount_of_days)) total = 0 for line in read_file: num = int(line) total += num average = total / amount_of_lines return average def main(): file_wanted = open_input_file() month_list = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] day_list = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] day_being_used = 0 month_being_used = 0 months = 12 for month_being_used in range(months): steps = average_steps(file_wanted, day_list[day_being_used]) print(f&quot;The average steps taken in {month_list[month_being_used]} was {steps} &quot;) day_being_used += 1 month_being_used += 1 file_wanted.close() if __name__ == '__main__': main() </code></pre>
[ { "answer_id": 74189221, "author": "shawn caza", "author_id": 1586014, "author_profile": "https://Stackoverflow.com/users/1586014", "pm_score": 0, "selected": false, "text": "def open_input_file():\n while True:\n name_of_file = input(\"Enter the name of the input file: \")\n ...
2022/10/25
[ "https://Stackoverflow.com/questions/74188737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20326002/" ]
74,188,738
<pre><code>ls -la | awk 'BEGIN {printf &quot;%s\t%s\n&quot;,&quot;Name&quot;,&quot;Size&quot;}{if ($9 == &quot;.&quot; &amp;&amp; $5 == 0) print $9,&quot;\t&quot;$5}' drwxrws---+ 6 rsy512 group20 4096 Oct 24 20:54 . drwxrws---+ 6 root group20 68 Oct 24 14:19 .. -rwxrw----. 1 rsy512 group20 568 Mar 3 2010 adhoc -rw-r-----. 1 rsy512 group20 0 Mar 3 2010 .ghost1.c -rw-r-----. 1 rsy512 group20 0 Mar 3 2010 .ghost2 -rw-r-----. 1 rsy512 group20 0 Mar 3 2010 .ghost3.cpp drwxr-s---+ 2 rsy512 group20 6 Mar 3 2010 .ghostdir -rwxrw----. 1 rsy512 group20 21 Feb 17 2010 input4.txt -rwxrw----. 1 rsy512 group20 1878 Feb 26 2008 lab1.cpp -rwxrw----. 1 rsy512 group20 1171 Feb 4 2010 Lab2.cpp -rwxrw----. 1 rsy512 group20 1013 Mar 3 2010 proc -rwxrw----. 1 rsy512 group20 109 Mar 3 2010 prog1.c -rwxrw----. 1 rsy512 group20 104 Mar 3 2010 prog2.c -rwxrw----. 1 rsy512 group20 0 Mar 3 2010 prog3.c.txt -rwxrw----. 1 rsy512 group20 0 Mar 3 2010 prog.4c drwxrws---+ 2 rsy512 group20 6 Mar 3 2010 programs.c drwxrws---+ 2 rsy512 group20 6 Mar 3 2010 programs.cpp -rw-rw----. 1 rsy512 group20 46 Oct 24 20:54 script1_t20 drwxrws---+ 2 rsy512 group20 6 Mar 3 2010 test1 </code></pre> <p>I need to output the 3 files &quot;.ghost...&quot; and their file size. With the header name and size.</p> <p>Im trying to use a logical AND (&amp;&amp;) to achieve this effect. Only after both conditions are satisfied, proceed to print the information. Add a header ,&quot;Name&quot;, &quot;Size&quot; to your results. Add this awk script (preceded by ls -l |) to the content of script1_tXX</p>
[ { "answer_id": 74189221, "author": "shawn caza", "author_id": 1586014, "author_profile": "https://Stackoverflow.com/users/1586014", "pm_score": 0, "selected": false, "text": "def open_input_file():\n while True:\n name_of_file = input(\"Enter the name of the input file: \")\n ...
2022/10/25
[ "https://Stackoverflow.com/questions/74188738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20326550/" ]
74,188,800
<p>I'm trying to deploy nested stack using command</p> <blockquote> <p><code>aws cloudformation deploy --stack-name &quot;${STACK_NAME}&quot; --template-file &quot;${S3_ROOT_TEMPLATE}&quot; --parameter-overrides ${PARAMS[@]} --region ${REGION}</code></p> </blockquote> <p>But despite the <code>S3_ROOT_TEMPLATE</code> having proper url, I get the error</p> <blockquote> <p>Invalid template path https://<code>&lt;s3-bucket-name&gt;</code>.s3.us-east-2.amazonaws.com/sm-domain-templates/main_stack.yaml</p> </blockquote> <p>Any idea what's wrong with the above?</p>
[ { "answer_id": 74189221, "author": "shawn caza", "author_id": 1586014, "author_profile": "https://Stackoverflow.com/users/1586014", "pm_score": 0, "selected": false, "text": "def open_input_file():\n while True:\n name_of_file = input(\"Enter the name of the input file: \")\n ...
2022/10/25
[ "https://Stackoverflow.com/questions/74188800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/423879/" ]
74,188,806
<p>Recently we encountered an issue with <code>math.log()</code> . Since <code>243</code> is a perfect power of <code>3</code> , assumption that taking floor should be fine was wrong as it seems to have precision error on lower side. So as a hack we started adding a small value before taking logarithm. Is there a way to configue <code>math.log</code> upfront or something similar that that we dont have to add EPS every time.</p> <p>To clarify some of the comments Note we are not looking to round to nearest integer. Our goal is to keep the value exact or at times take floor. But if the precision error is on lower side floor screws up big time, that's what we are trying to avoid.</p> <p>code:</p> <pre><code>import math math.log(243, 3) int(math.log(243, 3)) </code></pre> <p>output:</p> <pre><code>4.999999999999999 4 </code></pre> <p>code:</p> <pre><code>import math EPS = 1e-09 math.log(243 + EPS, 3) int(math.log(243 + EPS, 3)) </code></pre> <p>output:</p> <pre><code>5.0000000000037454 5 </code></pre>
[ { "answer_id": 74188931, "author": "Nikolay Zakirov", "author_id": 9023490, "author_profile": "https://Stackoverflow.com/users/9023490", "pm_score": -1, "selected": false, "text": "from decimal import Decimal, Context, ROUND_HALF_UP, ROUND_HALF_DOWN\nctx1 = Context(prec=20, rounding=ROUN...
2022/10/25
[ "https://Stackoverflow.com/questions/74188806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/865220/" ]
74,188,813
<p>In practicing python, I've come across the sliding window technique but don't quite understand the implementation. Given a string k and integer N, the code is to loop through, thereby moving the window from left to right. However, the capture of the windowed elements as well as how the window grows is fuzzy to me.</p> <p>These sliding window questions on Leetcode are similar but do not have the alphabetic aspect.</p> <ol> <li>Fruits into baskets : <a href="https://leetcode.com/problems/fruit-into-baskets/" rel="nofollow noreferrer">https://leetcode.com/problems/fruit-into-baskets/</a></li> <li>Longest substring without repeating characters : <a href="https://leetcode.com/problems/longest-substring-without-repeating-characters/" rel="nofollow noreferrer">https://leetcode.com/problems/longest-substring-without-repeating-characters/</a></li> <li>Longest substring after k replacements : <a href="https://leetcode.com/problems/longest-repeating-character-replacement/" rel="nofollow noreferrer">https://leetcode.com/problems/longest-repeating-character-replacement/</a></li> <li>Permutation in string: <a href="https://leetcode.com/problems/permutation-in-string/" rel="nofollow noreferrer">https://leetcode.com/problems/permutation-in-string/</a></li> <li>String anagrams: <a href="https://leetcode.com/problems/find-all-anagrams-in-a-string/" rel="nofollow noreferrer">https://leetcode.com/problems/find-all-anagrams-in-a-string/</a></li> <li>Average of any contiguous subarray of size k : <a href="https://leetcode.com/problems/maximum-average-subarray-i/" rel="nofollow noreferrer">https://leetcode.com/problems/maximum-average-subarray-i/</a></li> <li>Maximum sum of any contiguous subarray of size k : <a href="https://leetcode.com/problems/maximum-subarray/" rel="nofollow noreferrer">https://leetcode.com/problems/maximum-subarray/</a></li> <li>Smallest subarray with a given sum : <a href="https://leetcode.com/problems/minimum-size-subarray-sum/" rel="nofollow noreferrer">https://leetcode.com/problems/minimum-size-subarray-sum/</a></li> <li>Longest substring with k distinct characters : <a href="https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters/" rel="nofollow noreferrer">https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters/</a></li> </ol> <p>Most occurring contiguous sub-string here defined as three letters in growing sequence. For example, for an input string k of 'cdegoxyzcga' and length N of 3, the output would be [cde, xyz].</p>
[ { "answer_id": 74188931, "author": "Nikolay Zakirov", "author_id": 9023490, "author_profile": "https://Stackoverflow.com/users/9023490", "pm_score": -1, "selected": false, "text": "from decimal import Decimal, Context, ROUND_HALF_UP, ROUND_HALF_DOWN\nctx1 = Context(prec=20, rounding=ROUN...
2022/10/25
[ "https://Stackoverflow.com/questions/74188813", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10047888/" ]
74,188,824
<p>my function in a controller is here below</p> <pre><code>public function getStudentsinGrade($grade, $school_id){ $students = Student::where('school_id', $school_id)-&gt;get(); $this -&gt; grade = $grade; $gradeStudent= $students-&gt;filter(function($value,$key){ return $value-&gt;grade == $this-&gt;grade; }); if(count($gradeStudent) &gt; 0){ return response()-&gt;json($gradeStudent); } else{ return response('No Registered Student'); } } </code></pre> <p>the response I am getting is here below</p> <pre><code>*{ &quot;2&quot;: &lt;---this number here is the problem and it appeared when get API response { &quot;id&quot;: 14, &quot;student_name&quot;: &quot;Polly Grain&quot;, &quot;gender&quot;: &quot;Female&quot;, &quot;stream_id&quot;: 1, &quot;school_id&quot;: 1, &quot;final_year_id&quot;: 2, &quot;grade&quot;: &quot;Form Four&quot; }, &quot;3&quot;: { &quot;id&quot;: 15, &quot;student_name&quot;: &quot;Polly Grain&quot;, &quot;gender&quot;: &quot;Male&quot;, &quot;stream_id&quot;: 3, &quot;school_id&quot;: 1, &quot;final_year_id&quot;: 2, &quot;grade&quot;: &quot;Form Four&quot;} }* </code></pre> <p>and the response I want to get is the one below</p> <blockquote> <p>[ { &quot;id&quot;: 1, &quot;student_name&quot;: &quot;sae sddat&quot;, &quot;gender&quot;: &quot;male&quot;, &quot;stream_id&quot;: 2, &quot;school_id&quot;: 10, &quot;final_year_id&quot;: 12, &quot;grade&quot;: &quot;Form One&quot; }, { &quot;id&quot;: 1, &quot;student_name&quot;: &quot;sae sddat&quot;, &quot;gender&quot;: &quot;male&quot;, &quot;stream_id&quot;: 2, &quot;school_id&quot;: 10, &quot;final_year_id&quot;: 12, &quot;grade&quot;: &quot;Form One&quot; }, { &quot;id&quot;: 1, &quot;student_name&quot;: &quot;sae sddat&quot;, &quot;gender&quot;: &quot;male&quot;, &quot;stream_id&quot;: 2, &quot;school_id&quot;: 10, &quot;final_year_id&quot;: 12, &quot;grade&quot;: &quot;Form One&quot; } ]</p> </blockquote>
[ { "answer_id": 74188931, "author": "Nikolay Zakirov", "author_id": 9023490, "author_profile": "https://Stackoverflow.com/users/9023490", "pm_score": -1, "selected": false, "text": "from decimal import Decimal, Context, ROUND_HALF_UP, ROUND_HALF_DOWN\nctx1 = Context(prec=20, rounding=ROUN...
2022/10/25
[ "https://Stackoverflow.com/questions/74188824", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11966370/" ]
74,188,845
<p>I have a command I execute on a pipeline :</p> <p><code>firebase hosting:channel:deploy --only main --project test-project --config firebase.json test</code></p> <p>This command apparently throw out those outputs =&gt; <a href="https://github.com/marketplace/actions/deploy-to-firebase-hosting" rel="nofollow noreferrer">https://github.com/marketplace/actions/deploy-to-firebase-hosting</a></p> <blockquote> <p>urls The url(s) deployed to</p> <p>expire_time The time the deployed preview urls expire</p> <p>details_url A single URL that was deployed to</p> </blockquote> <p>When I run it it goes basically with</p> <pre><code>$ firebase hosting:channel:deploy --only main --project test-project --config firebase.json test === Deploying to 'test-project'... i deploying hosting i hosting[test-project]: beginning deploy... i hosting[test-project]: found 497 files in dist/apps/main + hosting[test-project]: file upload complete i hosting[test-project]: finalizing version... + hosting[test-project]: version finalized i hosting[test-project]: releasing new version... + hosting[test-project]: release complete + Deploy complete! Project Console: https://console.firebase.google.com/project/test-project/overview Hosting URL: https://test-project.web.app ! hosting:channel: Unable to add channel domain to Firebase Auth. Visit the Firebase Console at https://console.firebase.google.com/project/test-project/authentication/providers ! hosting:channel: Unable to sync Firebase Auth state. + hosting:channel: Channel URL (test-project): https://test-project--test-xj60axa8.web.app [expires 2022-11-01 12:22:04] </code></pre> <p>I would like to retrieve that last line, store it in a variable to reuse it in a future step of the pipeline.</p> <p>I tried to do</p> <pre><code> - RESULT=$(firebase hosting:channel:deploy --only main --project test-project --config firebase.json test) - echo &quot;export PREVIEW_LINK=$RESULT&quot; &gt;&gt; set_preview_link.sh </code></pre> <p>But this put the whole command output.</p> <p>Is there a way to just get</p> <p><code>hosting:channel: Channel URL (test-project): https://test-project--test-xj60axa8.web.app [expires 2022-11-01 12:22:04]</code></p> <p>or even just the <code>https://test-project--test-xj60axa8.web.app</code></p>
[ { "answer_id": 74188931, "author": "Nikolay Zakirov", "author_id": 9023490, "author_profile": "https://Stackoverflow.com/users/9023490", "pm_score": -1, "selected": false, "text": "from decimal import Decimal, Context, ROUND_HALF_UP, ROUND_HALF_DOWN\nctx1 = Context(prec=20, rounding=ROUN...
2022/10/25
[ "https://Stackoverflow.com/questions/74188845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3241192/" ]
74,188,858
<p>I am starting to learn about ruby on rails but somehow I got an issue calling <code>rails</code> in my project folder. When I call <code>rails --version</code> on a non project generated by rails it worked fine, but when I call inside the project, I get this error</p> <pre><code>❯ rails -v /Users/mac/Devs/Rails/test/rails-test-api/config/boot.rb:4:in `require': cannot load such file -- bootsnap/setup (LoadError) from /Users/mac/Devs/Rails/test/rails-test-api/config/boot.rb:4:in `&lt;top (required)&gt;' from bin/rails:3:in `require_relative' from bin/rails:3:in `&lt;main&gt;' </code></pre> <p>Any rails command won't work inside my project folder.</p> <p>I am running on Macbook Pro M1 Monterey 12.6 and already open my terminal in Rosetta. This is my spec</p> <pre><code>❯ rails -v Rails 7.0.4 ~ ❯ ruby --version ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin21] ~ ❯ rails --version Rails 7.0.4 ~ ❯ bundle version Bundler version 2.3.23 (2022-10-05 commit 250d9d485d) ~ ❯ gem --version 3.3.7 </code></pre> <p>Any help would be appreciated, thanks!</p> <p><strong>--Edited</strong></p> <ul> <li>I already add <code>gem &quot;bootsnap&quot;, require: false</code> in my <code>Gemfile</code>, then I installed it but still get those error.</li> </ul> <pre><code>❯ rails --version /Users/mac/Devs/Rails/test/rails-test-api/config/boot.rb:4:in `require': cannot load such file -- bootsnap/setup (LoadError) from /Users/mac/Devs/Rails/test/rails-test-api/config/boot.rb:4:in `&lt;top (required)&gt;' from bin/rails:3:in `require_relative' from bin/rails:3:in `&lt;main&gt;' </code></pre> <ul> <li>I also already remove the bootsnap from my <code>Gemfile</code> and commented <code>require &quot;bootsnap/setup&quot;</code> in my <code>boot.rb</code>. But it leads to another error</li> </ul> <pre><code>❯ rails --version bin/rails:4:in `require': cannot load such file -- rails/commands (LoadError) from bin/rails:4:in `&lt;main&gt;' </code></pre> <p><strong>--Edited</strong> I added <code>gem 'bootsnap'</code> into my Gemfile, run <code>bundle install</code>, I got <code>Bundle complete! 4 Gemfile dependencies, 41 gems now installed.</code> but I see no bootsnap installation there.</p> <p>I already install bootsnap manually <code>gem install bootsnap</code>, succeed. But if i tried to <code>bundle info bootsnap</code> it will return <code>Could not find gem 'bootsnap'.</code></p>
[ { "answer_id": 74188931, "author": "Nikolay Zakirov", "author_id": 9023490, "author_profile": "https://Stackoverflow.com/users/9023490", "pm_score": -1, "selected": false, "text": "from decimal import Decimal, Context, ROUND_HALF_UP, ROUND_HALF_DOWN\nctx1 = Context(prec=20, rounding=ROUN...
2022/10/25
[ "https://Stackoverflow.com/questions/74188858", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2924335/" ]
74,188,863
<pre><code>icon_image = 'hci.png' </code></pre> <pre><code>icon = CustomIcon( icon_image, icon_size=(75, 95), icon_anchor=(10, 30), ) </code></pre> <pre><code>from folium.plugins import MarkerCluster import folium from folium.features import CustomIcon mm = folium.Map( location=[latitude, longitude], zoom_start=15 ) coords = sub_df[['Latitude', 'Longitude']] marker_cluster = MarkerCluster().add_to(mm) for lat, long in zip(coords['Latitude'], coords['Longitude']): folium.Marker([lat, long], icon=icon).add_to(marker_cluster) mm </code></pre> <p>also i tried this code this code is okay</p> <p>but cant show 'hci.png'icon</p> <p>that icon is Company CI icon</p> <h2><strong>It was my original question</strong></h2> <p>I want to change to Marker purple star to that Company</p> <pre><code>import folium import pandas as pd df = pd.read_excel('p대리점.xlsx')enter code here latitude = 37.58 longitude = 127.0 m = folium.Map(location=[latitude, longitude], zoom_start=11.5) sub_df = df from folium.plugins import MarkerCluster m = folium.Map( location=[latitude, longitude], zoom_start=15 ) coords = sub_df[['Latitude', 'Longitude']] marker_cluster = MarkerCluster().add_to(m) for lat, long in zip(coords['Latitude'], coords['Longitude']): folium.Marker([lat, long], icon=folium.Icon(color='purple',icon='star')).add_to(marker_cluster) m </code></pre> <p>[<a href="https://i.stack.imgur.com/KzBGc.jpg" rel="nofollow noreferrer">1</a>: <a href="https://i.stack.imgur.com/KzBGc.jpg%5D%5B1%5D" rel="nofollow noreferrer">https://i.stack.imgur.com/KzBGc.jpg][1]</a> <a href="https://i.stack.imgur.com/KzBGc.jpg" rel="nofollow noreferrer">1</a>: <a href="https://i.stack.imgur.com/KzBGc.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/KzBGc.jpg</a></p> <p>and i changed this code by answer but cant Clustering and Markis location also little different</p> <p><a href="https://i.stack.imgur.com/myi4y.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/nE4TL.png</a><a href="https://i.stack.imgur.com/nE4TL.png" rel="nofollow noreferrer">https://i.stack.imgur.com/nE4TL.png</a></p>
[ { "answer_id": 74188931, "author": "Nikolay Zakirov", "author_id": 9023490, "author_profile": "https://Stackoverflow.com/users/9023490", "pm_score": -1, "selected": false, "text": "from decimal import Decimal, Context, ROUND_HALF_UP, ROUND_HALF_DOWN\nctx1 = Context(prec=20, rounding=ROUN...
2022/10/25
[ "https://Stackoverflow.com/questions/74188863", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19785434/" ]
74,188,870
<p>I have the following data frame (say df1) in R:</p> <p><a href="https://i.stack.imgur.com/SUnub.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SUnub.png" alt="enter image description here" /></a></p> <p>and would like to find the sum of the sizes for each of the &quot;continent&quot;, &quot;country&quot;, and &quot;sex&quot; combinations in cases where the category column values are A and B. I would then like to change the category value to D, and the desired new data frame (say df2) is given below:</p> <p><a href="https://i.stack.imgur.com/VjbJH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VjbJH.png" alt="enter image description here" /></a></p> <p>As I am new to R programming, I would really appreciate it if anyone can help me in converting the df1 to df2 and many thanks in advance.</p> <p>PS. The code for my original data frame with category A, B, and C is given below:</p> <pre><code> df1 &lt;- data.frame(&quot;continent&quot; = c('Europe', 'Europe', 'Europe', 'Europe', 'Europe', 'Europe', 'Asia', 'Asia', 'Asia', 'Asia', 'Asia', 'Asia'), &quot;country&quot; = c('Germany', 'Germany', 'Germany', 'Germany', 'Germany','Germany','Japan', 'Japan', 'Japan', 'Japan', 'Japan','Japan'), &quot;sex&quot; = c('male', 'male', 'male', 'female', 'female', 'female', 'male', 'male', 'male', 'female', 'female', 'female'), &quot;category&quot; = c('A', 'B', 'C','A', 'B', 'C', 'A', 'B', 'C', 'A', 'B', 'C'), &quot;size&quot; = c(20, 35, 40, 32, 14, 53,18,31, 16,65,13,22)) </code></pre>
[ { "answer_id": 74188909, "author": "Gregor Thomas", "author_id": 903061, "author_profile": "https://Stackoverflow.com/users/903061", "pm_score": 2, "selected": true, "text": "A" }, { "answer_id": 74191578, "author": "GKi", "author_id": 10488504, "author_profile": "htt...
2022/10/25
[ "https://Stackoverflow.com/questions/74188870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18239212/" ]
74,188,876
<p>I want to extract data from this website which has shadow-dom. I think I've managed to access the elements inside the shadow-dom using JavaScript, but I haven't figured out how to use the returned value from the JavaScript as <code>WebElements</code> so that I can process the data.</p> <pre><code>library(RSelenium) rD &lt;- rsDriver(browser=&quot;firefox&quot;, port=4547L, verbose=F) remDr &lt;- rD[[&quot;client&quot;]] remDr$navigate(&quot;https://www.transfermarkt.us&quot;) ## run script to enable dropdown list in the website. This creates a &lt;ul&gt; tag in the shadow-dom which lists all items in the dropdown list. remDr$executeScript(&quot;return document.querySelector('tm-quick-select-bar').setAttribute('dropdown-visible', 'countries')&quot;) Sys.sleep(5) </code></pre> <p>This is only the portion that contains the shadow-dom. I'm not sure if this is required, but this is where the dropdown lists is present</p> <pre><code>wrapper &lt;- remDr$findElement(using=&quot;tag name&quot;, value=&quot;tm-quick-select-bar&quot;) </code></pre> <p>Below is the script to access the dropdown list</p> <pre><code>script &lt;- 'return document.querySelector(&quot;#main &gt; header &gt; div.quick-select-wrapper &gt; tm-quick-select-bar&quot;).shadowRoot.querySelector(&quot;div &gt; tm-quick-select:nth-child(2) &gt; div &gt; div.selector-dropdown &gt; ul&quot;);' test &lt;- remDr$executeScript('return document.querySelector(&quot;#main &gt; header &gt; div.quick-select-wrapper &gt; tm-quick-select-bar&quot;).shadowRoot.querySelector(&quot;div &gt; tm-quick-select:nth-child(2) &gt; div &gt; div.selector-dropdown &gt; ul&quot;);', list(wrapper)) </code></pre> <p>This returns the following list.</p> <pre><code>&gt; test $`element-6066-11e4-a52e-4f735466cecf` [1] &quot;4adac8f8-2c94-4e48-b7a3-521eb961ef8c&quot; </code></pre> <p>I have no idea how to extract the items from this. It doesn't seem like it's a WebElement. What is this list and what information does it contain? How can I extract it?</p> <p>I tried this</p> <pre><code>lapply(test, function(x){ x$getElementText() x[[1]]$getElementText() }) </code></pre> <p>But, it returns the errors:</p> <pre><code>Error in x$getElementText : $ operator is invalid for atomic vectors </code></pre>
[ { "answer_id": 74188909, "author": "Gregor Thomas", "author_id": 903061, "author_profile": "https://Stackoverflow.com/users/903061", "pm_score": 2, "selected": true, "text": "A" }, { "answer_id": 74191578, "author": "GKi", "author_id": 10488504, "author_profile": "htt...
2022/10/25
[ "https://Stackoverflow.com/questions/74188876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6401955/" ]
74,188,947
<p>I'm having a problem in GitLab. My repository commit graph is not showing the main branch. The repo have two branches, main and develop, and its only showing the develop branch. I know that I messed up the branch somehow when I push to 'develop'. But the history said that I merged 'develop' to 'develop'. I don't know where I messed up. <a href="https://i.stack.imgur.com/6aoKe.png" rel="nofollow noreferrer">Here's the commit graph</a>: <img src="https://i.stack.imgur.com/6aoKe.png" alt="graph" /></p> <p>Would someone tell me where and why I messed up?</p>
[ { "answer_id": 74188909, "author": "Gregor Thomas", "author_id": 903061, "author_profile": "https://Stackoverflow.com/users/903061", "pm_score": 2, "selected": true, "text": "A" }, { "answer_id": 74191578, "author": "GKi", "author_id": 10488504, "author_profile": "htt...
2022/10/25
[ "https://Stackoverflow.com/questions/74188947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20326770/" ]
74,188,951
<p>I am trying to build a dropdown menu for plotly timeline plot. Here is my code:</p> <pre><code>import pandas as pd import plotly.express as px def main(): d = { 'T_ID': ['T1', 'T2', 'T3', 'T1'], 'TYPE': ['Type1', 'Type2', 'Type3', 'Type2'], 'SYS_START_TIME': ['2021-06-20 06:05', '2021-06-23 15:13', '2021-06-27 13:01', '2021-06-29 14:02'], 'SYS_END_TIME': ['2021-06-20 11:39', '2021-06-23 15:25', '2021-06-27 13:09', '2021-06-29 15:09'], } df = pd.DataFrame(data=d) df['SYS_START_TIME'] = pd.to_datetime(df['SYS_START_TIME']) df['SYS_END_TIME'] = pd.to_datetime(df['SYS_END_TIME']) labels = df[&quot;T_ID&quot;].unique() buttonsLabels = [dict(label=&quot;All&quot;, method=&quot;update&quot;, visible=True, args=[ {'x_start': [df.SYS_START_TIME]}, {'x_end': [df.SYS_END_TIME]}, {'y': [df.T_ID]}, ] )] for label in labels: buttonsLabels.append(dict(label=label, method=&quot;update&quot;, visible=True, args=[ {'x_start': [df.loc[df.T_ID == label, &quot;SYS_START_TIME&quot;]]}, {'x_end': [df.loc[df.T_ID == label, &quot;SYS_END_TIME&quot;]]}, {'y': [df.loc[df.T_ID == label, &quot;T_ID&quot;]]}, ] )) fig = px.timeline( df, x_start=&quot;SYS_START_TIME&quot;, x_end=&quot;SYS_END_TIME&quot;, y=&quot;T_ID&quot;, color=&quot;TYPE&quot;, hover_data=['SYS_START_TIME', 'SYS_END_TIME', 'TYPE'] ) fig.update_layout(xaxis=dict( title='Date', tickformat='%Y-%m-%d %H:%M', dtick=&quot;D&quot;, showgrid=True ), updatemenus=[dict(buttons=buttonsLabels, showactive=True)]) fig.show() if __name__ == '__main__': main() </code></pre> <p>When I run the code, it shows all the data but when I press the buttons in the menu it doesn't update the plot, it still shows all the data. Can anyone help me?</p>
[ { "answer_id": 74188909, "author": "Gregor Thomas", "author_id": 903061, "author_profile": "https://Stackoverflow.com/users/903061", "pm_score": 2, "selected": true, "text": "A" }, { "answer_id": 74191578, "author": "GKi", "author_id": 10488504, "author_profile": "htt...
2022/10/25
[ "https://Stackoverflow.com/questions/74188951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14161153/" ]
74,188,955
<p>I need to put the button on the center just like in the picture below. It should be on the lines. What is the proper and correct way to do this?</p> <p><a href="https://codesandbox.io/s/jovial-ptolemy-2mg3f8?file=/demo.js" rel="nofollow noreferrer">Codesandbox</a></p> <p><a href="https://i.stack.imgur.com/dnhKx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dnhKx.png" alt="enter image description here" /></a></p> <pre><code>&lt;MainContainer&gt; &lt;Stack spacing={1}&gt; &lt;Card sx={{ minWidth: 275 }}&gt; &lt;CardContent&gt; &lt;Typography sx={{ fontSize: 14 }} color=&quot;text.secondary&quot; gutterBottom &gt; Word of the Day &lt;/Typography&gt; &lt;Typography variant=&quot;h5&quot; component=&quot;div&quot;&gt; be{bull}nev{bull}o{bull}lent &lt;/Typography&gt; &lt;Typography sx={{ mb: 1.5 }} color=&quot;text.secondary&quot;&gt; adjective &lt;/Typography&gt; &lt;Typography variant=&quot;body2&quot;&gt; well meaning and kindly. &lt;br /&gt; {'&quot;a benevolent smile&quot;'} &lt;/Typography&gt; &lt;/CardContent&gt; &lt;/Card&gt; &lt;/Stack&gt; &lt;Stack justifyContent={&quot;center&quot;} alignItems={&quot;center&quot;}&gt; &lt;Button variant=&quot;contained&quot; color=&quot;primary&quot; sx={{ maxWidth: 50 }}&gt; Hello &lt;/Button&gt; &lt;/Stack&gt; &lt;/MainContainer&gt; </code></pre>
[ { "answer_id": 74188979, "author": "Mulli", "author_id": 4284015, "author_profile": "https://Stackoverflow.com/users/4284015", "pm_score": 0, "selected": false, "text": " <Button variant=\"contained\" color=\"primary\" sx={{ maxWidth: 50, margin: '0 auto' }}>\n" }, { "answ...
2022/10/25
[ "https://Stackoverflow.com/questions/74188955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8305219/" ]
74,188,975
<p>I am trying to have a variable that is defined in a parent function be modified in the child function and then returned back to the parent as an updated variable.</p> <p>Code I have tried is below:</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 wuzi = 20; console.log(wuzi); //20 as expected testWuzi(wuzi); console.log(wuzi); //I need this to be 30 function testWuzi(wuzi) { wuzi = 30; }</code></pre> </div> </div> </p>
[ { "answer_id": 74189015, "author": "flyingfox", "author_id": 3176419, "author_profile": "https://Stackoverflow.com/users/3176419", "pm_score": 1, "selected": false, "text": "value" }, { "answer_id": 74189025, "author": "JLRishe", "author_id": 1945651, "author_profile"...
2022/10/25
[ "https://Stackoverflow.com/questions/74188975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8562712/" ]
74,188,980
<p>It's supposed to open in a pop-up text box but I want the user to be able to choose <code>h</code> or <code>s</code> and then there's another pop-up that gives the answer.</p> <p>But nothing is working. This is what I have so far:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script language=&quot;javaScript&quot;&gt; var minutes=prompt(&quot;Enter number of minutes&quot;); var answer=prompt(&quot;Enter h for hours or s for seconds&quot;); function convertToHours(minutes) { hours=minutes/60; window.alert(&quot;There are &quot; + hours + &quot; hours in &quot; + minutes + &quot; minutes&quot;); } function convertToSeconds(minutes) { seconds=minutes*60; window.alert(&quot;There are &quot; + seconds + &quot; seconds in &quot; +minutes + &quot; minutes&quot;); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
[ { "answer_id": 74189009, "author": "Tim Dang", "author_id": 19546542, "author_profile": "https://Stackoverflow.com/users/19546542", "pm_score": 0, "selected": false, "text": "if (minutes!= null) {\n // Do something or call your function in here\n}\nif (answer!= null) {\n // Do somethin...
2022/10/25
[ "https://Stackoverflow.com/questions/74188980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20326808/" ]
74,188,996
<p>The code at line 7 works when 'Add' is typed. But the code at line 7 keeps repeating when 'View' prompt is entered. This is my password storing programe</p> <pre><code>import string master_pass = input('Lost in Soul Sand be everything, but the KEY! \n') while master_pass == 'Soul': action = input('Add/View Soul?').lower() if action == 'add': U = input('Soulname: ') P = input('Soul Sand: ') with open('sandvalley.txt','a') as f: f.write( U + '|' + P + '\n') print('Souls saw the light') if action == 'view': with open('sandvalley.txt','r') as narrate: narrate.readlines() for row in narrate: print(row) if action != 'add' or 'view': print('Soul has left the storm') break print ('End') </code></pre>
[ { "answer_id": 74189009, "author": "Tim Dang", "author_id": 19546542, "author_profile": "https://Stackoverflow.com/users/19546542", "pm_score": 0, "selected": false, "text": "if (minutes!= null) {\n // Do something or call your function in here\n}\nif (answer!= null) {\n // Do somethin...
2022/10/25
[ "https://Stackoverflow.com/questions/74188996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20326811/" ]
74,189,030
<p>I'd like to do a loop with these JSON strings.</p> <pre><code>$json_m = '[ {&quot;name&quot;:&quot;1&quot;,&quot;value&quot;:&quot;1&quot;}, {&quot;name&quot;:&quot;2&quot;,&quot;value&quot;:&quot;2&quot;}, {&quot;name&quot;:&quot;3&quot;,&quot;value&quot;:&quot;3&quot;}, {&quot;name&quot;:&quot;4&quot;,&quot;value&quot;:&quot;4&quot;}, {&quot;name&quot;:&quot;5&quot;,&quot;value&quot;:&quot;5&quot;}, ]'; $json_a = '[ {&quot;name&quot;:&quot;1-m&quot;,&quot;value&quot;:&quot;1&quot;}, {&quot;name&quot;:&quot;2-m&quot;,&quot;value&quot;:&quot;3&quot;}, {&quot;name&quot;:&quot;3-m&quot;,&quot;value&quot;:&quot;5&quot;}, ]'; </code></pre> <p>I do a loop and on <code>$json_m</code>. If the value exists in both JSON, I set the parameter to <code>TRUE</code></p> <p>This is my current code:</p> <pre><code>$jm = json_decode($json_m, true); $ja = json_decode($json_a, true); $i = 0; $is_exist = FALSE; foreach($jm as $rows ){ if($rows[&quot;value&quot;] == $ja[$i][&quot;value&quot;]){ $is_exist = TRUE; } $dataadd = array ( 'ID' =&gt; $i, 'NAME' =&gt; $rows[&quot;value&quot;], 'STATUS' =&gt; $is_exist ); $i++; } </code></pre> <p>This script returns as all FALSE, based on my example the <code>STATUS</code> should return like this:</p> <pre><code>TRUE FALSE TRUE FALSE TRUE </code></pre> <p>Do I miss something or what? Any help is greatly appreciated.</p>
[ { "answer_id": 74189009, "author": "Tim Dang", "author_id": 19546542, "author_profile": "https://Stackoverflow.com/users/19546542", "pm_score": 0, "selected": false, "text": "if (minutes!= null) {\n // Do something or call your function in here\n}\nif (answer!= null) {\n // Do somethin...
2022/10/25
[ "https://Stackoverflow.com/questions/74189030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7154727/" ]
74,189,046
<p>I have a list of strings in python of the form <code>ABC_###</code> where ### is a number from 1-999. I want to remove the _ and any leading 0s from the number, basically any <code>_</code>, <code>_0</code>, or <code>_00</code> to get the format <code>ABC 4</code> or <code>ABC 909</code>. I can think of a couple of dumb ways to do this but no smart ways, so I'm here :)</p>
[ { "answer_id": 74189009, "author": "Tim Dang", "author_id": 19546542, "author_profile": "https://Stackoverflow.com/users/19546542", "pm_score": 0, "selected": false, "text": "if (minutes!= null) {\n // Do something or call your function in here\n}\nif (answer!= null) {\n // Do somethin...
2022/10/25
[ "https://Stackoverflow.com/questions/74189046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13801789/" ]
74,189,054
<p>I need to make it so when a user enters data (scans a barcode) into column D it will automatically move them back to column A so they can start over.</p>
[ { "answer_id": 74189121, "author": "D T", "author_id": 1497597, "author_profile": "https://Stackoverflow.com/users/1497597", "pm_score": 1, "selected": false, "text": "Worksheet_Change" }, { "answer_id": 74198122, "author": "VBasic2008", "author_id": 9814069, "author_...
2022/10/25
[ "https://Stackoverflow.com/questions/74189054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19926452/" ]
74,189,100
<p>let's say i have this</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">id</th> <th style="text-align: center;">center</th> <th style="text-align: right;">right</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">1</td> <td style="text-align: center;">Two</td> <td style="text-align: right;">NULL</td> </tr> <tr> <td style="text-align: left;">1</td> <td style="text-align: center;">NULL</td> <td style="text-align: right;">Three</td> </tr> </tbody> </table> </div> <p>and want to be like this</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">id</th> <th style="text-align: center;">center</th> <th style="text-align: right;">right</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">1</td> <td style="text-align: center;">Two</td> <td style="text-align: right;">Three</td> </tr> </tbody> </table> </div> <p>my first table is just a representation of what actually I am encountering, everything will be appreciated, thank you in advance.</p>
[ { "answer_id": 74189121, "author": "D T", "author_id": 1497597, "author_profile": "https://Stackoverflow.com/users/1497597", "pm_score": 1, "selected": false, "text": "Worksheet_Change" }, { "answer_id": 74198122, "author": "VBasic2008", "author_id": 9814069, "author_...
2022/10/25
[ "https://Stackoverflow.com/questions/74189100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3296131/" ]
74,189,111
<p>I have created some schemas (dsfv, dsfn, etc.) and insert some tables inside each schema, including the following tables :</p> <ul> <li>poste_hta_bt (parent table with attribute &quot;code_pt&quot; as unique key);</li> <li>transfo_hta_bt (having also &quot;code_pt&quot; attribute as foreign key that referenced poste_hta_bt).</li> </ul> <p>I have also created a function trigger that count the total number of entities from &quot;transfo_hta_bt&quot; and report it in &quot;nb_transf&quot; attribute of &quot;poste_hta_bt&quot;.</p> <p>My code is as follows :</p> <pre><code>SET SESSION AUTHORIZATION dsfv; SET search_path TO dsfv, public; CREATE TABLE IF NOT EXISTS poste_hta_bt ( id_pt serial NOT NULL, code_pt varchar(30) NULL UNIQUE, etc. ); CREATE TABLE IF NOT EXISTS transfo_hta_bt ( id_tra serial NOT NULL, code_tra varchar(30) NULL, code_pt varchar(30) NULL, etc. ); ALTER TABLE transfo_hta_bt ADD CONSTRAINT &quot;FK_transfo_hta_bt_poste_hta_bt&quot; FOREIGN KEY (code_pt) REFERENCES poste_hta_bt (code_pt) ON DELETE No Action ON UPDATE No Action; CREATE OR REPLACE FUNCTION recap_transf() RETURNS TRIGGER language plpgsql AS $$ DECLARE som_transf smallint; som_transf1 smallint; BEGIN IF (TG_OP = 'INSERT') THEN SELECT COUNT(*) INTO som_transf FROM dsfv.transfo_hta_bt WHERE code_pt = NEW.code_pt; UPDATE dsfv.poste_hta_bt SET nb_transf = som_transf WHERE dsfv.poste_hta_bt.code_pt = NEW.code_pt; RETURN NULL; ELSIF (TG_OP = 'DELETE') THEN SELECT COUNT(*) INTO som_transf FROM dsfv.transfo_hta_bt WHERE code_pt = OLD.code_pt; UPDATE dsfv.poste_hta_bt SET nb_transf = som_transf WHERE dsfv.poste_hta_bt.code_pt = OLD.code_pt; RETURN NULL; ELSIF (TG_OP = 'UPDATE') THEN SELECT COUNT(*) INTO som_transf FROM dsfv.transfo_hta_bt WHERE code_pt = NEW.code_pt; SELECT COUNT(*) INTO som_transf1 FROM dsfv.transfo_hta_bt WHERE code_pt = OLD.code_pt; UPDATE dsfv.poste_hta_bt SET nb_transf = som_transf WHERE dsfv.poste_hta_bt.code_pt = NEW.code_pt; UPDATE dsfv.poste_hta_bt SET nb_transf = som_transf1 WHERE dsfv.poste_hta_bt.code_pt = OLD.code_pt; RETURN NULL; ELSE RAISE WARNING 'Other action occurred: %, at %', TG_OP, now(); RETURN NULL; END IF; END; $$ ; DROP TRIGGER IF EXISTS recap_tr ON dsfv.transfo_hta_bt; CREATE TRIGGER recap_tr AFTER INSERT OR UPDATE OR DELETE ON dsfv.transfo_hta_bt FOR EACH ROW EXECUTE PROCEDURE recap_transf(); </code></pre> <p>This code runs correctly but I didn't understand why the following: In the function trigger, I noticed that I have to specify the schema of each table, despite that I adjusted search_path to dsfv from the beginning. Also when I replace dsfv.transfo_hta_bt with TG_TABLE_NAME in the function trigger, the lattest variable is unrecognized. Thank you in advance for your help.</p>
[ { "answer_id": 74189121, "author": "D T", "author_id": 1497597, "author_profile": "https://Stackoverflow.com/users/1497597", "pm_score": 1, "selected": false, "text": "Worksheet_Change" }, { "answer_id": 74198122, "author": "VBasic2008", "author_id": 9814069, "author_...
2022/10/25
[ "https://Stackoverflow.com/questions/74189111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15341614/" ]
74,189,136
<p>I would like to ask for help with the following code. The purpose is to be open Monday to Friday during certain hours, closed on Saturday and Sunday. My problem is that this code doesn't work, it always prints &quot;closed&quot;. I tried it yesterday and it still says &quot;closed&quot; during opening hours. What is wrong with this code, can someone fix it?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var a = document.getElementById("hoursofoperation"); var d = new Date(); var n = d.getDay(); var now = d.getHours() + "." + d.getMinutes(); var weekdays = [ ["Sunday"] // close ["Monday", 8.30, 21.30], ["Tuesday", 6.00, 11.30], ["Wednesday", 8.30, 12.00], ["Thursday", 8.30, 12.00], ["Friday", 8.30, 12.30], ["Saturday"] // close ]; var day = weekdays[n]; if (now &gt; day[2] &amp;&amp; now &lt; day[3] || now &gt; day[4] &amp;&amp; now &lt; day[5]) { a.innerHTML = "We are Open now now."; } else { a.innerHTML = "We are Closed, kar."; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;span id="hoursofoperation"&gt;&lt;/span&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74189121, "author": "D T", "author_id": 1497597, "author_profile": "https://Stackoverflow.com/users/1497597", "pm_score": 1, "selected": false, "text": "Worksheet_Change" }, { "answer_id": 74198122, "author": "VBasic2008", "author_id": 9814069, "author_...
2022/10/25
[ "https://Stackoverflow.com/questions/74189136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20319752/" ]
74,189,143
<p>I have some code that creates a react component:</p> <pre><code>const MyMessage = ({ message }) =&gt; { if(message?.attachments?.length &gt; 0){ // We have an image return( &lt;img src={message.attachments[0].file} alt=&quot;message-attachment&quot; className='message-image' style={{ float: 'right' }} /&gt; ) }} </code></pre> <p>I get the following error pointing to the <code>?.</code> syntax</p> <pre><code>react_devtools_backend.js:4026 Error in ./src/components/MyMessage.jsx Syntax error: C:/Users/GitHub/react_chat_app/src/components/MyMessage.jsx: Unexpected token (4:15) </code></pre> <p>When I remove the <code>?.</code> and replace with</p> <p><code>if(message.attachments.length &gt; 0) </code></p> <p>it works fine. What is wrong with my syntax when using <code>?.</code>?</p>
[ { "answer_id": 74189121, "author": "D T", "author_id": 1497597, "author_profile": "https://Stackoverflow.com/users/1497597", "pm_score": 1, "selected": false, "text": "Worksheet_Change" }, { "answer_id": 74198122, "author": "VBasic2008", "author_id": 9814069, "author_...
2022/10/25
[ "https://Stackoverflow.com/questions/74189143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7107548/" ]
74,189,147
<p>I am self-learning Java programming and I was trying to do some number conversion from base 10 to any base, but I keep getting a negative value with the code below</p> <pre class="lang-java prettyprint-override"><code>import java.lang.Math; import java.util.Scanner; public class NumberSystemConversion { public static void main(String [] args) { System.out.println(&quot;Enter the source base of the integer&quot;); Scanner sc = new Scanner(System.in); int sBase = sc.nextInt(); System.out.println(&quot;Enter the destination base of the integer&quot;); int dBase = sc.nextInt(); System.out.println(&quot;Enter the integer&quot;); String s1 = sc.next(); //int len = s1.length(); int decNumber = 0; for (int i =0; i &lt;= s1.length()-1; i++) { decNumber += s1.indexOf(i)*Math.pow(sBase,i); } System.out.println(decNumber); } } </code></pre>
[ { "answer_id": 74189121, "author": "D T", "author_id": 1497597, "author_profile": "https://Stackoverflow.com/users/1497597", "pm_score": 1, "selected": false, "text": "Worksheet_Change" }, { "answer_id": 74198122, "author": "VBasic2008", "author_id": 9814069, "author_...
2022/10/25
[ "https://Stackoverflow.com/questions/74189147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20326869/" ]
74,189,156
<p>This is a simplified version of my problem using a DynamoDB Table. Most items in the Table represent sales across multiple countries. One of my required access patterns is to retrieve all sales in countries which belong to a certain <code>country_grouping</code> between a range of <code>order_date</code>s. The incoming stream of sales data contains the <code>country</code> attribute, but not the <code>country_grouping</code> attribute.</p> <p>Another entity in the same Table is a reference table, which is infrequently updated, which could be used to identify the <code>country_grouping</code> for each <code>country</code>. Can I design a GSI or otherwise structure the table to retrieve all sales for a given <code>country_grouping</code> between a range of order dates?</p> <p>Here's an example of the Table structure:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">PK</th> <th style="text-align: left;">SK</th> <th style="text-align: left;">sale_id</th> <th style="text-align: left;">order_date</th> <th style="text-align: left;">country</th> <th style="text-align: left;">country_grouping</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">SALE#ID#1</td> <td style="text-align: left;">ORDER_DATE#2022-06-01</td> <td style="text-align: left;">1</td> <td style="text-align: left;">2022-06-01</td> <td style="text-align: left;">UK</td> <td style="text-align: left;"></td> </tr> <tr> <td style="text-align: left;">SALE#ID#2</td> <td style="text-align: left;">ORDER_DATE#2022-09-01</td> <td style="text-align: left;">2</td> <td style="text-align: left;">2022-09-01</td> <td style="text-align: left;">France</td> <td style="text-align: left;"></td> </tr> <tr> <td style="text-align: left;">SALE#ID#3</td> <td style="text-align: left;">ORDER_DATE#2022-07-01</td> <td style="text-align: left;">3</td> <td style="text-align: left;">2022-07-01</td> <td style="text-align: left;">Switzerland</td> <td style="text-align: left;"></td> </tr> <tr> <td style="text-align: left;">COUNTRY_GROUPING#EU</td> <td style="text-align: left;">COUNTRY#France</td> <td style="text-align: left;"></td> <td style="text-align: left;"></td> <td style="text-align: left;">France</td> <td style="text-align: left;">EU</td> </tr> <tr> <td style="text-align: left;">COUNTRY_GROUPING#NATO</td> <td style="text-align: left;">COUNTRY#UK</td> <td style="text-align: left;"></td> <td style="text-align: left;"></td> <td style="text-align: left;">UK</td> <td style="text-align: left;">NATO</td> </tr> <tr> <td style="text-align: left;">COUNTRY_GROUPING#NATO</td> <td style="text-align: left;">COUNTRY#France</td> <td style="text-align: left;"></td> <td style="text-align: left;"></td> <td style="text-align: left;">France</td> <td style="text-align: left;">NATO</td> </tr> </tbody> </table> </div> <p><strong>Possible solution 1</strong></p> <p>As the sales items are streamed into the Table, query the <code>country_grouping</code> associated with the <code>country</code> in the sale, and write the corresponding <code>country_grouping</code> to each sale record. Then create a GSI where <code>country_grouping</code> is the partition key and the <code>order_date</code> is the sort key. This seems expensive to me, consuming 1 RCU and 1 WCU per sale record imported. If country groupings changed (imagine the UK rejoins the EU), then I would run an update operation against all sales in the UK.</p> <p><strong>Possible solution 2</strong></p> <p>Have the application first query to retrieve every <code>country</code> in the desired <code>country_grouping</code>, then send an individual request for each country using a GSI where the partition key is <code>country</code> and the <code>order_date</code> is the sort key. Again, this seems less than ideal, as I consume 1 WCU per country, plus the 1 WCU to obtain the list of countries.</p> <p>Is there a better way?</p>
[ { "answer_id": 74196940, "author": "Borislav Stoilov", "author_id": 5625696, "author_profile": "https://Stackoverflow.com/users/5625696", "pm_score": 0, "selected": false, "text": "COUNTRY_GROUPING#EU#ORDER_DATE#2022-07-01" } ]
2022/10/25
[ "https://Stackoverflow.com/questions/74189156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6816950/" ]
74,189,173
<p>I am trying to make a macro that will automatically group (collapse) all rows when the text in column A is not in bold. I do not have any code yet, however when I have done it before based on cell color, <a href="https://stackoverflow.com/questions/55539862/macro-to-group-rows-by-fill-color-does-nothing-and-i-am-not-sure-why">code taken from here</a>, it has not worked based on the solution provided. Any help will be greatly appreciated.</p> <p><a href="https://i.stack.imgur.com/aMhb5.png" rel="nofollow noreferrer">Rows as they appear</a></p> <p><a href="https://i.stack.imgur.com/FNUQc.png" rel="nofollow noreferrer">Rows when they are grouped, which I have done manually.</a></p>
[ { "answer_id": 74189242, "author": "ricardogerbaudo", "author_id": 7011129, "author_profile": "https://Stackoverflow.com/users/7011129", "pm_score": 1, "selected": false, "text": "Range.Font.Bold" }, { "answer_id": 74189574, "author": "mtholen", "author_id": 2666502, ...
2022/10/25
[ "https://Stackoverflow.com/questions/74189173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20326972/" ]
74,189,193
<p>I am trying to create a function evenoddarray() which is supposed to accept one parameter which should be an array of numbers. This function should check all the numbers in the array in order to log whether each number is even or odd.</p> <p>For example, evenoddarray(1, 45,8,6,9) should display 'odd,odd,even,even,odd'.</p> <p>Thank you.</p> <pre><code>function evenoddarray(array) { let tab = [1, 45,8,6,9]; for (const value of tab) { if (value % 2 === 0) { console.log('even'); } else { console.log('odd'); } } } evenoddarray(); </code></pre>
[ { "answer_id": 74189224, "author": "Ranjith Ramachandra", "author_id": 1278480, "author_profile": "https://Stackoverflow.com/users/1278480", "pm_score": 1, "selected": false, "text": "\nconst evenOrOdd = (num) => num % 2 == 0?'even':'odd';\nlet evenOddMap = (array) => array.map((a) => ev...
2022/10/25
[ "https://Stackoverflow.com/questions/74189193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20268805/" ]
74,189,254
<p>I am trying to create a looping text based &quot;choose your own adventure&quot; story game. The code is built into separate functions. Each function has a story element (returned in text format), a selection of player choices used for updating the text on the buttons (returned in dictionary format) and then the next functions to pull up based on the choice the player makes (also in dictionary format.</p> <p>When complete and properly working, there will be two buttons below the text, that once clicked, would instantly update the onscreen text and the buttons at the bottom of the screen.</p> <p>From my experimentation so far, it seems that I cannot put a while loop before the point where it creates the window, and I cannot figure out how to build a loop after the point where it creates the window. I am thinking I have mapped the buttons wrong, but I am at a loss for where to go next. If anyone has any ideas, it would be most helpful. Thank you.</p> <p>Current main Function:</p> <pre><code>import PySimpleGUI as sg def main (): sg.theme(&quot;default1&quot;) # All the stuff inside your window. char_info = character_creation() char_name = char_info[0] char_gender = char_info[1] scene_loading(char_name,char_gender) # Maps the player choices to the variable current_scene current_scene = cabin_scene(char_name, char_gender) # Returns (story_text, player_choices, next_scenes) # Pulls display text from current scene to display to user display_text = current_scene [0] # Pulls returned options from current scene to be mapped to display current_options = current_scene [1] option_1 = current_options [&quot;option_1&quot;] option_2 = current_options [&quot;option_2&quot;] # Format of dictionary values # {&quot;option_1&quot;:first_scene,&quot;option_2&quot;:second_scene} next_scenes = current_scene [2] first_scene = next_scenes [&quot;option_1&quot;] second_scene = next_scenes [&quot;option_2&quot;] layout = [ [sg.Text(display_text) ], [sg.Button(option_1),sg.Button(option_2)], [sg.Button(&quot;Cancel&quot;)] ] # Create the Window window = sg.Window(&quot;The Ultimate Choose Your Own Adventure Story&quot;, layout) # Event Loop to process &quot;events&quot; and get the &quot;values&quot; of the inputs while True: event, values = window.read() if event == sg.WIN_CLOSED or event == &quot;Cancel&quot;: # if user closes window or clicks cancel break window. Close() </code></pre> <p>Sample function return values:</p> <pre><code>story_text = f&quot;&quot;&quot;Insert text personalized to user here.&quot;&quot;&quot; player_choices = { &quot;option_1&quot;:&quot;HIDE&quot;, &quot;option_2&quot;:&quot;ESCAPE&quot;} next_scenes = { &quot;option_1&quot;:closet_scene, &quot;option_2&quot;:forest_scene} return story_text, player_choices, next_scenes </code></pre>
[ { "answer_id": 74193690, "author": "Jason Yang", "author_id": 11936135, "author_profile": "https://Stackoverflow.com/users/11936135", "pm_score": 0, "selected": false, "text": "import PySimpleGUI as sg\n\nlayout = [\n [sg.Text('Page 1/5', size=20, key='TEXT')],\n [sg.pin(sg.Button(...
2022/10/25
[ "https://Stackoverflow.com/questions/74189254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19891316/" ]
74,189,267
<pre><code>DetailsImpl.java public detailResponse fetchId(String accId){ Optional&lt;Acc&gt; acc = accRep.findById(accId); //Here I need to write the logic that if accId is not there in data base than I need to show the response from another API and the class service impl class for that is FeeDetails.java. FeeDetails.java{ @Overeide public List&lt;Response&gt; getRes(String accId){ return client.getDetailsOfField(accId); } </code></pre> <p>I need to check if accId is there in database if it is present then logic is working fine but if it's not present than I need to show the response from already existing logic which is written in FeeDetails.java class. I am facing problem in writing the logic as it's giving an internal error when I hit the API.</p>
[ { "answer_id": 74193690, "author": "Jason Yang", "author_id": 11936135, "author_profile": "https://Stackoverflow.com/users/11936135", "pm_score": 0, "selected": false, "text": "import PySimpleGUI as sg\n\nlayout = [\n [sg.Text('Page 1/5', size=20, key='TEXT')],\n [sg.pin(sg.Button(...
2022/10/25
[ "https://Stackoverflow.com/questions/74189267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20280477/" ]
74,189,269
<p>I am working with a typescript/node.js codebase, where there is a function that is called normally:</p> <pre><code>func('param1', 'param2', param3') </code></pre> <p>This function does not have a return value but it will print different kinds of output to the terminal when the code is run - this output might be normal <code>console.log</code> statements or an error of some sort. I want to be able to capture whatever the function print out into a variable for use later on - does anyone know how to capture what the function outputs into a variable? (so I can use it in if statments later)</p>
[ { "answer_id": 74189335, "author": "Extreme_Tough", "author_id": 2691327, "author_profile": "https://Stackoverflow.com/users/2691327", "pm_score": 0, "selected": false, "text": "let log = function(msg){\n console.log(msg);\n outputLog += msg + \"\\n\";\n}\n" }, { "answer_id": 7...
2022/10/25
[ "https://Stackoverflow.com/questions/74189269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14917411/" ]
74,189,283
<p>input - 15:30<br /> output - 17:10<br /> I try to do this:</p> <pre><code>time = '15:30' moment(time) .add(40, 'minutes') .add(2, 'hours') .format('HH:mm') </code></pre> <p>but it doesn't work, moment says &quot;invalid date&quot;</p>
[ { "answer_id": 74189301, "author": "Josué Martínez", "author_id": 11507342, "author_profile": "https://Stackoverflow.com/users/11507342", "pm_score": 3, "selected": true, "text": "const time = '15:30' // Valid date\nconst time = '252:10' // Invalid date\n" }, { "answer_id": 74189...
2022/10/25
[ "https://Stackoverflow.com/questions/74189283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18671377/" ]
74,189,298
<p>Are there any other cleaner approach for my code? Looks my code isn't readable.</p> <pre><code>const materials = entry.materials.flat().map(c =&gt; ({ ...c, ...(c.quality_id ? { quality_id: c.quality_id } : { quality_id: null }), ...(c.quantity_used ? { quantity_used: c.quantity_used } : { quantity_used: 0 }), ...(c.remarks ? { remarks: c.remarks } : { remarks: &quot;&quot; }), })); </code></pre>
[ { "answer_id": 74189311, "author": "CertainPerformance", "author_id": 9515207, "author_profile": "https://Stackoverflow.com/users/9515207", "pm_score": 3, "selected": true, "text": "c" }, { "answer_id": 74189324, "author": "Robby Cornelissen", "author_id": 3558960, "a...
2022/10/25
[ "https://Stackoverflow.com/questions/74189298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19991216/" ]
74,189,310
<p>I have a React app that runs fine with <code>npm start</code>, but fails to build with the following error when running <code>npm run build</code>:</p> <pre><code>`Creating an optimized production build... Failed to compile. Attempted import error: './parseq-lang.js' does not contain a default export (imported as 'grammar'). </code></pre> <p>The import statement looks like this (<a href="https://github.com/rewbs/sd-parseq/blob/master/src/parseq-lang-interpreter.js" rel="nofollow noreferrer">you can see the full file here</a>):</p> <pre><code>import grammar from './parseq-lang.js'; </code></pre> <p>The module being imported is generated code from <code>nearleyc</code>. Its export portion looks like this (<a href="https://github.com/rewbs/sd-parseq/blob/master/src/parseq-lang.js" rel="nofollow noreferrer">you can see the full file here</a> – again this is generated code, so I'd rather not change this if I can avoid it):</p> <pre><code>(function () { [...] if (typeof module !== 'undefined'&amp;&amp; typeof module.exports !== 'undefined') { module.exports = grammar; } else { window.grammar = grammar; } })(); </code></pre> <p>Does anyone know what might be happening or have any pointers to help me debug? Thanks!</p>
[ { "answer_id": 74200795, "author": "rewbs", "author_id": 6095, "author_profile": "https://Stackoverflow.com/users/6095", "pm_score": 0, "selected": false, "text": "nearleyc" }, { "answer_id": 74201203, "author": "mli", "author_id": 17839690, "author_profile": "https:/...
2022/10/25
[ "https://Stackoverflow.com/questions/74189310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6095/" ]
74,189,380
<p>The program is to accept a choice from the user.</p> <p>Choice 1 to check the deposit</p> <p>Choice 2 to make a deposit - when I entered choice two it should accept a deposit that is greater than 0 but less than 100,000, if this condition is not met then the program should prompt the user to enter the deposit until the condition is met.</p> <p>If the condition is met, then the program should add the deposit entered to 30,000 and print the result.</p> <p>My problem is even if the deposit is greater than 100,000 or less than 0, it is still printing the result and it should only prompt the user to enter the deposit until it is greater than 0 or less than 100,000.</p> <p>What could be the error or problem in my code?</p> <pre><code>balance = 30000 choice = int(input(&quot;Enter 1 to Check Balance\nEnter 2 to deposit\nEnter 3 to withdrawl\n:&quot;)) if choice == 1: print(&quot;Your balance is $&quot;,balance) if choice == 2: while True: deposit= float(input(&quot;Enter the deposit you would like to make:&quot;)) if deposit &lt; 0 or deposit &gt; 100000: print(&quot;INVALID ENTRY! The deposit must not be less than 0 or greater than 100000.&quot;) if(deposit &lt; 0 and deposit &gt; 100000): continue; newbalance = deposit + balance print(&quot;Your balance is $&quot;, newbalance) </code></pre>
[ { "answer_id": 74200795, "author": "rewbs", "author_id": 6095, "author_profile": "https://Stackoverflow.com/users/6095", "pm_score": 0, "selected": false, "text": "nearleyc" }, { "answer_id": 74201203, "author": "mli", "author_id": 17839690, "author_profile": "https:/...
2022/10/25
[ "https://Stackoverflow.com/questions/74189380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20327086/" ]
74,189,395
<p>This is my custom user registration form WordPress site, actually, this is my first custom development, and here all the data passes the DB my problem is I need to show my error message inside the HTML code. how can I do it? can anyone help me to solve this problem? now my error messages show like this (Array ( [username_empty] =&gt; Needed Username [email_valid] =&gt; Email has no valid value [texnumber_empty] =&gt; Needed Tax Number )) but I need only show error message only Ex: this one ( [username_empty] =&gt; Needed Username) I need to show &quot;Needed Username&quot; Like this.</p> <pre><code>if (is_user_logged_in()) { // echo '&lt;script&gt;alert(&quot;Welcome, registered user!&quot;)&lt;/script&gt;'; echo '&lt;script type=&quot;text/javascript&quot;&gt;'; echo 'alert(&quot;Welcome, registered user!&quot;);'; echo 'window.location.href = &quot;Url&quot;;'; echo '&lt;/script&gt;'; } else { // echo 'Welcome, visitor!'; global $wpdb; if ($_POST) { $username = $wpdb-&gt;escape($_POST['user_login']); $email = $wpdb-&gt;escape($_POST['user_email']); $taxnumber = $wpdb-&gt;escape($_POST['tax_number']); $password = $wpdb-&gt;escape($_POST['user_pass']); $ConfPassword = $wpdb-&gt;escape($_POST['user_confirm_password']); $error = array(); if (strpos($username, ' ') !== FALSE) { $error['username_space'] = &quot;Username has Space&quot;; } if (empty($username)) { $error['username_empty'] = &quot;Needed Username&quot;; } if (username_exists($username)) { $error['username_exists'] = &quot;Username already exists&quot;; } if (!is_email($email)) { $error['email_valid'] = &quot;Email has no valid value&quot;; } if (email_exists($email)) { $error['email_existence'] = &quot;Email already exists&quot;; } if (empty($taxnumber)) { $error['texnumber_empty'] = &quot;Needed Tax Number&quot;; } if (strcmp($password, $ConfPassword) !== 0) { $error['password'] = &quot;Password didn't match&quot;; } if (count($error) == 0) { $user_id = wp_create_user($username, $password, $email); $userinfo = array( 'ID' =&gt; $user_id, 'user_login' =&gt; $username, 'user_email' =&gt; $email, 'user_pass' =&gt; $password, 'role' =&gt; 'customer', ); // Update the WordPress User object with first and last name. wp_update_user($userinfo); // Add the company as user metadata update_user_meta($user_id, 'tax_number', $taxnumber); echo '&lt;script type=&quot;text/javascript&quot;&gt;'; echo 'alert(&quot;User Created Successfully&quot;);'; echo 'window.location.href = &quot;url&quot;;'; echo '&lt;/script&gt;'; exit(); } else { print_r($error); } } ?&gt; &lt;section id=&quot;wholesale-custom-register-form&quot;&gt; &lt;div class=&quot;container wholesale-custom-register-form&quot;&gt; &lt;div class=&quot;register-form&quot;&gt; &lt;div class=&quot;register-form-title&quot;&gt; &lt;h1&gt;Wholesale Register Form&lt;/h1&gt; &lt;/div&gt; &lt;div class=&quot;wholesale-register&quot;&gt; &lt;form class=&quot;register-fm&quot; method=&quot;POST&quot;&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label&gt;User Name&lt;/label&gt; &lt;input class=&quot;form-control&quot; type=&quot;text&quot; name=&quot;user_login&quot; id=&quot;user_login&quot; placeholder=&quot;Username&quot; /&gt; &lt;?php foreach ($error as $error) { echo $error . &quot;&lt;br&gt;&quot;; } ?&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label&gt;Email&lt;/label&gt; &lt;input class=&quot;form-control&quot; type=&quot;email&quot; name=&quot;user_email&quot; id=&quot;user_email&quot; placeholder=&quot;Email&quot; /&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label&gt;Tax Number&lt;/label&gt; &lt;input class=&quot;form-control&quot; type=&quot;text&quot; name=&quot;tax_number&quot; id=&quot;tax_number&quot; placeholder=&quot;Tax Number&quot; /&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label&gt;Enter Password&lt;/label&gt; &lt;input class=&quot;form-control&quot; type=&quot;password&quot; name=&quot;user_pass&quot; id=&quot;user_pass&quot; placeholder=&quot;Password&quot; /&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label&gt;Enter Cofirm Password&lt;/label&gt; &lt;input class=&quot;form-control&quot; type=&quot;password&quot; name=&quot;user_confirm_password&quot; id=&quot;user_confirm_password&quot; placeholder=&quot;Cofirm Password&quot; /&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;button class=&quot;custom-register-btn&quot; type=&quot;submit&quot; name=&quot;btnsubmit&quot;&gt;Log In&lt;/button&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/section&gt; &lt;?php }; </code></pre> <p>This is my code I will try many times but I can't get the error messages inside the HTML body.</p>
[ { "answer_id": 74200795, "author": "rewbs", "author_id": 6095, "author_profile": "https://Stackoverflow.com/users/6095", "pm_score": 0, "selected": false, "text": "nearleyc" }, { "answer_id": 74201203, "author": "mli", "author_id": 17839690, "author_profile": "https:/...
2022/10/25
[ "https://Stackoverflow.com/questions/74189395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9569324/" ]
74,189,407
<p>I have quite a complex If statement that I would like to add as a column in my pandas dataframe. In the past I've always used numpy.select for this type of problem, however I wouldn't know how to achieve that with a multi-line if statement.</p> <p>I was able to get this in Excel:</p> <pre><code>=IF(sum1=3,IF(AND(col1=col2,col2=col3),0,1),IF(sum1=2,IF(OR(col1=col2,col2=col3,col1=col3),0,1),IF(sum1=1,0,1))) </code></pre> <p>and write it in Python just as a regular multi-line 'if statement', just want to find out if there is a far cleaner way of presenting this.</p> <pre><code>if df['sum1'] == 3: if df['col1'] == df['col2'] and df['col2'] == df['col3']: df['verify_col'] = 0 else: df['verify_col'] = 1 elif df['sum1'] == 2: if df['col1'] == df['col2'] or df['col2'] == df['col3'] or df['col1'] == df['col3']: df['verify_col'] = 0 else: df['verify_col'] = 1 elif df['sum1'] == 1: df['verify_col'] = 0 else: df['verify_col'] = 1 </code></pre> <p>Here's some sample data:</p> <pre><code>df = pd.DataFrame({ 'col1': ['BMW', 'Mercedes Benz', 'Lamborghini', 'Ferrari', null], 'col2': ['BMW', 'Mercedes Benz', null, null, 'Tesla'], 'col3': ['BMW', 'Mercedes', 'Lamborghini', null, 'Tesla_'], 'sum1': [3, 3, 2, 1, 2] }) </code></pre> <p>I want a column which has the following results:</p> <pre><code>'verify_col': [0, 1, 0, 0, 1] </code></pre> <p>It basically checks whether the columns match for those that have values in them and assigns a 1 or a 0 for each row. 1 meaning they are different, 0 meaning zero difference.</p>
[ { "answer_id": 74189443, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 3, "selected": true, "text": "numpy.where" }, { "answer_id": 74189508, "author": "Raibek", "author_id": 11040577, "author_profi...
2022/10/25
[ "https://Stackoverflow.com/questions/74189407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13344757/" ]
74,189,409
<p>I have a <code>yml</code> bitbucket pipeline where I would like to auto commit a message containing <code>#</code> and <code>:</code></p> <p>I am doing :</p> <p><code>- git commit -m &quot;[skip ci] $ISSUE #comment Link : $LINK&quot;</code></p> <p>The issue is the pipeline don't run cause it consider <code>#</code> to be a comment.</p> <p>I tried to escape it using</p> <pre><code> - git commit -m |- &quot;[skip ci] $ISSUE #comment Link : $LINK&quot; </code></pre> <p>or</p> <pre><code> - git commit -m |- &quot;[skip ci] $ISSUE '#'comment Link ':' $LINK&quot; </code></pre> <p>but they dont work as expected</p> <p>I am expecting a commit message like <code>&quot;[skip ci] UI-12 #comment Link : www.test.com/123&quot;</code></p> <p>What I get is either</p> <pre><code>bash: opt/atlassian/pipelines/agent/tmp/bashScript17301903987873752811.sh: line 23: unexpected EOF while looking for matching </code></pre> <p>or the <code>'</code> remaining</p> <p>How can I achieve this ?</p>
[ { "answer_id": 74189443, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 3, "selected": true, "text": "numpy.where" }, { "answer_id": 74189508, "author": "Raibek", "author_id": 11040577, "author_profi...
2022/10/25
[ "https://Stackoverflow.com/questions/74189409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3241192/" ]
74,189,412
<p>I am trying to sort a list of objects in Java. Each object contains two date fields <code>Date1</code> and <code>Date2</code>. If <code>Date1</code> is not null then <code>Date2</code> should be null and if <code>Date2</code> is not null then <code>Date1</code> should be null. Let's say Our class name is <code>Product</code> and we have a list <code>inventoryList</code> of object <code>products</code>.</p> <pre><code>products :[ { &quot;name&quot;:&quot;abc&quot;, ..., &quot;Date1&quot;: &quot;2021-04-18 10:36:34 PM&quot;, ..., &quot;Date2&quot;:&quot;null&quot;, ... }, &quot;name&quot;:&quot;def&quot;, ..., &quot;Date1&quot;: &quot;null&quot;, ..., &quot;Date2&quot;:&quot;2021-05-17 11:26:34 PM&quot;, ... ] </code></pre> <p>I want to sort this list with respect to either of the date of the object in descending order. Thanks in advance.</p>
[ { "answer_id": 74189613, "author": "HariHaravelan", "author_id": 2816429, "author_profile": "https://Stackoverflow.com/users/2816429", "pm_score": 1, "selected": false, "text": "Product" }, { "answer_id": 74189704, "author": "Futarimiti", "author_id": 17966065, "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74189412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11031894/" ]
74,189,437
<p>how to compare the key value (selected) in objects and remove the object in the main object. My object is:-</p> <pre><code> mainObject={ &quot;2022-10-29&quot;:{ &quot;disabled&quot;:true, &quot;disableTouchEvent&quot;:true }, &quot;2022-10-26&quot;:{ &quot;selected&quot;:true, &quot;selectedColor&quot;:&quot;#3634A3&quot;, &quot;selectedTextColor&quot;:&quot;#FFFFFF&quot; }, &quot;2022-10-30&quot;:{ &quot;disabled&quot;:true, &quot;disableTouchEvent&quot;:true }, &quot;2022-11-05&quot;:{ &quot;disabled&quot;:true, &quot;disableTouchEvent&quot;:true } } </code></pre> <p>i want to remove the object</p> <pre><code>&quot;2022-10-26&quot;:{ &quot;selected&quot;:true, &quot;selectedColor&quot;:&quot;#3634A3&quot;, &quot;selectedTextColor&quot;:&quot;#FFFFFF&quot; } </code></pre> <p>Final output should be:-</p> <pre><code>finalObject={ &quot;2022-10-29&quot;:{ &quot;disabled&quot;:true, &quot;disableTouchEvent&quot;:true }, &quot;2022-10-30&quot;:{ &quot;disabled&quot;:true, &quot;disableTouchEvent&quot;:true }, &quot;2022-11-05&quot;:{ &quot;disabled&quot;:true, &quot;disableTouchEvent&quot;:true } } </code></pre>
[ { "answer_id": 74189465, "author": "ChanHyeok-Im", "author_id": 6329353, "author_profile": "https://Stackoverflow.com/users/6329353", "pm_score": 3, "selected": false, "text": "delete" }, { "answer_id": 74189565, "author": "Vijay Ankith", "author_id": 20327255, "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74189437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20131021/" ]
74,189,447
<p>I'm writing a program that will read from /etc/passwd and output the username and shell.</p> <p>For example, here is the first line of the /etc/passwd file:</p> <pre class="lang-none prettyprint-override"><code>root:x:0:0:root:/root:/bin/bash </code></pre> <p>I need to only output the user and the shell. In this instance it would print:</p> <pre class="lang-none prettyprint-override"><code>root:/bin/bash </code></pre> <p>The values are separated by <code>':'</code> so I just need to print the string before the first <code>':'</code> and the string after the 6th <code>':'</code></p> <p>Here is the code I have so far:</p> <pre><code>#include &lt;string.h&gt; #define BUFFERSIZE 4096 int printf(const char *text, ...); int main(void) { int fd; int buff_size = 1; char buff[BUFFERSIZE]; int size; fd = open(&quot;/etc/passwd&quot;, O_RDONLY); if (fd &lt; 0) { printf(&quot;Error opening file \n&quot;); return -1; } size = strlen(buff - 17); size = size + 1; while ((size = read(fd, buff, 1)) &gt; 0) { buff[1] = '\0'; write(STDOUT_FILENO, buff, size); } } </code></pre> <p>(I am creating prototypes for <code>printf</code> because one of the requirements was to write the program without including <code>&lt;stdio.h&gt;</code> or <code>&lt;stdlib.h&gt;</code>)</p>
[ { "answer_id": 74190111, "author": "chqrlie", "author_id": 4593267, "author_profile": "https://Stackoverflow.com/users/4593267", "pm_score": 2, "selected": true, "text": "strlen(buff - 17)" }, { "answer_id": 74190353, "author": "David C. Rankin", "author_id": 3422102, ...
2022/10/25
[ "https://Stackoverflow.com/questions/74189447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15615382/" ]
74,189,449
<p>I would like to run bq load command once every day at 00:00 UTC. Can I use Google Cloud scheduler for scheduling this command?</p>
[ { "answer_id": 74190111, "author": "chqrlie", "author_id": 4593267, "author_profile": "https://Stackoverflow.com/users/4593267", "pm_score": 2, "selected": true, "text": "strlen(buff - 17)" }, { "answer_id": 74190353, "author": "David C. Rankin", "author_id": 3422102, ...
2022/10/25
[ "https://Stackoverflow.com/questions/74189449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8427453/" ]
74,189,511
<pre><code>TypeError: Cannot read properties of undefined (reading '0') at Proxy.render (form1.vue?4692:190:1) at renderComponentRoot (runtime-core.esm-bundler.js?5c40:893:1) form1.vue?4692:190 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '0') at Proxy.render (form1.vue?4692:190:1) at renderComponentRoot (runtime-core.esm-bundler.js?5c40:893:1) at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js?5c40:5030:1) at ReactiveEffect.run (reactivity.esm-bundler.js?a1e9:160:1) </code></pre> <p>Error Occurred</p> <pre><code>&lt;input type=&quot;text&quot; class=&quot;form-control&quot; v-model=&quot;data['item3'][0].item1&quot; /&gt; </code></pre> <p>data to:</p> <pre><code>item3: [ { item1: 'SSS', item2: [{ item3: '2' }], item3: '', item4: '2', item5: '', item6: '', item7: '', item8: '', item9: '', item10: '1', item11: '1', }, ], </code></pre> <p>vue page data to:</p> <pre><code>const data = ref&lt;any&gt;({}); onMounted(() =&gt; { data.value = props.modelValue; if (!data.value['sheetname']) { data.value = new E507().data; data.value.sheetname = props.sheet.templatename; } console.log(data.value); }); </code></pre> <p>data['item3'][0] Inaccessible. data['item3']?.[0] I couldn't do v-model in binding.</p> <p>Is there a way to access the 0th object?</p>
[ { "answer_id": 74189899, "author": "Rohìt Jíndal", "author_id": 4116300, "author_profile": "https://Stackoverflow.com/users/4116300", "pm_score": 1, "selected": false, "text": "data" }, { "answer_id": 74190085, "author": "knary", "author_id": 9789287, "author_profile"...
2022/10/25
[ "https://Stackoverflow.com/questions/74189511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20327254/" ]
74,189,518
<p>I need to parse this table:</p> <pre><code>╔══════╦═══════════╦═══════════╦═══════════╗ ║ Year ║ Cost_Mon1 ║ Cost_Mon2 ║ Cost_Mon3 ║ ╠══════╬═══════════╬═══════════╬═══════════╣ ║ 2022 ║ 1176 ║ 3970 ║ 540 ║ ║ 2023 ║ 540 ║ 540 ║ 3716 ║ ╚══════╩═══════════╩═══════════╩═══════════╝ </code></pre> <p>To this format with efficient way (better performance)</p> <pre><code>╔══════╦═══════╦══════╗ ║ Year ║ Month ║ Cost ║ ╠══════╬═══════╬══════╣ ║ 2022 ║ 1 ║ 1176 ║ ║ 2022 ║ 2 ║ 3970 ║ ║ 2022 ║ 3 ║ 540 ║ ║ 2023 ║ 1 ║ 540 ║ ║ 2023 ║ 2 ║ 540 ║ ║ 2023 ║ 3 ║ 3716 ║ ╚══════╩═══════╩══════╝ </code></pre>
[ { "answer_id": 74189583, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 3, "selected": true, "text": "SELECT Year, 1 AS Month, Cost_Mon1 AS Cost FROM yourTable\nUNION ALL\nSELECT Year, 2, Cost_Mon2 FROM yourTabl...
2022/10/25
[ "https://Stackoverflow.com/questions/74189518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3951963/" ]
74,189,532
<p>I have installed node@16(<code>v16.18.0</code>) in macOS and npm version: <code>8.19.2</code>.</p> <ul> <li><em><strong>Operating System macOS(Monterey) version:</strong></em> <code>12.6</code></li> <li><em><strong>Xcode Verion:</strong></em> <code>14.0.1</code></li> </ul> <p>Followed some instructions to setup react-native environment in my devices using bellow steps are mentioned:</p> <ol> <li>Homebrew install(<em><strong>Version: 3.6.7</strong></em> ): <code>/bin/bash -c &quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)&quot;</code></li> <li>watchman install(<em><strong>Version: 2022.10.24.00</strong></em>): <code>brew install watchman</code></li> <li>Install Ruby(<em><strong>version: 2.6.8p205</strong></em>): <code>brew install ruby</code></li> <li>Install CocoaPods(<em><strong>gem version: 3.0.3.1</strong></em>): <code>sudo gem install cocoapods</code></li> <li>CocoaPods in fixed location(<em><strong>pod version: 1.11.3</strong></em>): <code>sudo gem install -n /usr/local/bin ffi cocoapods</code></li> </ol> <p>After successfully installed all of the aboves I was going to create react-native app using <code>npx react-native init AwesomeProject</code> comand and faced <code>Your Ruby version is 2.6.8, but your Gemfile specified 2.7.5</code> error is also given in attached file. please check it and help me to suggest the way to solved.</p> <p><a href="https://i.stack.imgur.com/e8Gfl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/e8Gfl.png" alt="uby version is 2.6.8, but your Gemfile specified 2.7.5" /></a></p> <p>All of the resourses are mentioned below which I have follwed to solved this issues but i didn't solve it.</p> <ol> <li><a href="https://stackoverflow.com/questions/37914702/how-to-fix-your-ruby-version-is-2-3-0-but-your-gemfile-specified-2-2-5-while">How to fix &quot;Your Ruby version is 2.3.0, but your Gemfile specified 2.2.5&quot; while server starting</a></li> <li><a href="https://stackoverflow.com/questions/52055992/your-ruby-version-is-2-5-1-but-your-gemfile-specified-2-4-0">Your Ruby version is 2.5.1 but your Gemfile specified 2.4.0</a></li> <li><a href="https://stackoverflow.com/questions/27094643/rbenv-your-ruby-version-is-2-0-0-but-your-gemfile-specified-2-1-2">rbenv Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2</a></li> </ol>
[ { "answer_id": 74205647, "author": "Alexander", "author_id": 14367221, "author_profile": "https://Stackoverflow.com/users/14367221", "pm_score": 5, "selected": false, "text": "$ brew update\n$ brew install ruby-build\n$ brew install rbenv\n\n$ rbenv install 2.7.5\n$ rbenv global 2.7.5\n"...
2022/10/25
[ "https://Stackoverflow.com/questions/74189532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14065992/" ]
74,189,554
<p>Hello all how can get two same name column from two different table as single result in two different column as combine result.</p> <p>Eg: customer table have column customerid</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>custmerId</th> <th>customerName</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>row</td> </tr> <tr> <td>2</td> <td>row</td> </tr> </tbody> </table> </div> <p>Order Table</p> <p>it has also column customerid</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>custmerId</th> <th>orderName</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>order1</td> </tr> <tr> <td>4</td> <td>order2</td> </tr> <tr> <td>5</td> <td>order3</td> </tr> </tbody> </table> </div> <p>Expected Output</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>custmerId</th> <th>custmerId</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1</td> </tr> <tr> <td>2</td> <td>4</td> </tr> <tr> <td></td> <td>5</td> </tr> </tbody> </table> </div> <p><strong>Note</strong>: There is no relation between both table</p>
[ { "answer_id": 74189678, "author": "SavyJS", "author_id": 2673275, "author_profile": "https://Stackoverflow.com/users/2673275", "pm_score": 2, "selected": false, "text": "SELECT o.CustomerID as OCustomerID, c.CustomerId as CCustomerID\nFROM Customers AS c, Orders AS o;\n" }, { "a...
2022/10/25
[ "https://Stackoverflow.com/questions/74189554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16084371/" ]
74,189,567
<p>In C# I have a list like this:</p> <pre><code>var sequence = new List&lt;int&gt; { 10, 7, 10, 1, 10, 5, 10, 8 , 11 , 50 }; </code></pre> <p>I want to create 10 separate list by iterating through the sequence and in each iteration select three element instead of one element.</p> <p><img src="https://i.stack.imgur.com/tSJAn.png" alt="Iterating though list with overlap" /></p> <p>I wrote code below for this purpose but it has flaws and must be a better way of doing that:</p> <pre><code>var sequence = new List&lt;int&gt; { 10, 7, 10, 1, 10, 5, 10, 8 , 11 , 50 }; var lists = Enumerable.Range(0, 10) .Select(i =&gt; { var list = sequence.GetRange(i, 3); return list; }).ToList(); </code></pre> <p>P.S.: ‌Functional way I mean somthing like this:</p> <pre><code>var lists = Sequence.Window(sourceSafed.Skip(1)).....Select(window =&gt; window.Take(3))......ToList(); </code></pre>
[ { "answer_id": 74189678, "author": "SavyJS", "author_id": 2673275, "author_profile": "https://Stackoverflow.com/users/2673275", "pm_score": 2, "selected": false, "text": "SELECT o.CustomerID as OCustomerID, c.CustomerId as CCustomerID\nFROM Customers AS c, Orders AS o;\n" }, { "a...
2022/10/25
[ "https://Stackoverflow.com/questions/74189567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17132825/" ]
74,189,594
<p>I am creating a simple app which renders a list of courses and some details about the courses.</p> <p>The course details are split into the Header, Content and Total.</p> <p>In the Content section, is a child component: Part, however Typescript complains that the JSX element is &quot;unknown&quot; and I have no idea why it is.</p> <p>Can anyone make sense of this?</p> <p>App.js</p> <pre><code> import Header from './components/Header' import Content from './components/Content' import Total from './components/Total' import { CoursePart } from './types' const App = () =&gt; { const courseName = &quot;Half Stack application development&quot;; const courseParts: CoursePart[] = [ { name: &quot;Fundamentals&quot;, exerciseCount: 10, description: &quot;This is the easy course part&quot;, type: &quot;normal&quot; }, { name: &quot;Advanced&quot;, exerciseCount: 7, description: &quot;This is the hard course part&quot;, type: &quot;normal&quot; }, { name: &quot;Using props to pass data&quot;, exerciseCount: 7, groupProjectCount: 3, type: &quot;groupProject&quot; }, { name: &quot;Deeper type usage&quot;, exerciseCount: 14, exerciseSubmissionLink: &quot;https://fake-exercise-submit.made-up-url.dev&quot;, type: &quot;submission&quot; } ] return ( &lt;div&gt; &lt;Header courseName={courseName} /&gt; &lt;Content courseParts={courseParts} /&gt; &lt;Total courseParts={courseParts} /&gt; &lt;/div&gt; ); }; export default App; </code></pre> <p>Content component:</p> <pre><code>import { interfacePart } from '../types' import Part from './Part' const Content = ({ courseParts }: {courseParts: interfacePart }): unknown =&gt; { return ( &lt;div&gt; &lt;Part courseParts={courseParts} /&gt; &lt;/div&gt; ) } export default Content </code></pre> <p>Part component:</p> <pre><code>import { interfacePart } from '../types' // eslint-disable-next-line react/prop-types const Part = ({ courseParts }: {courseParts: interfacePart }) =&gt; { return ( courseParts.forEach(part =&gt; { switch (part.name) { case &quot;Fundamentals&quot;: return ( &lt;div&gt; {part.name} &lt;/div&gt; ) case &quot;Advanced&quot;: return ( &lt;div&gt; {part.name} &lt;/div&gt; ) case &quot;Using props to pass data&quot;: return ( &lt;div&gt; {part.name} &lt;/div&gt; ) case &quot;Deeper type usage&quot;: return ( &lt;div&gt; {part.name} &lt;/div&gt; ) default: break } }) ) } export default Part </code></pre> <p>types.tsx</p> <pre><code>export interface Title { courseName: string } export interface CoursePartBase { name: string; exerciseCount: number; type: string; } export interface CoursePartBaseDescription extends CoursePartBase { description?: string; } export interface CoursePartOne extends CoursePartBaseDescription { name: &quot;Fundamentals&quot;; } export interface CoursePartTwo extends CoursePartBase { name: &quot;Using props to pass data&quot;; groupProjectCount: number; } export interface CoursePartThree extends CoursePartBaseDescription { name: &quot;Deeper type usage&quot;; description?: string; exerciseSubmissionLink: string; } export interface CoursePartFour extends CoursePartBaseDescription { name: &quot;Advanced&quot;; } export interface CourseSpecialPart extends CoursePartBaseDescription { name: &quot;Backend development&quot;; requirements: Array&lt;string&gt;; } export type CoursePart = CoursePartOne | CoursePartTwo | CoursePartThree | CoursePartFour | CourseSpecialPart; export interface interfacePart { reduce(arg0: (carry: any, part: any) =&gt; any, arg1: number): import(&quot;react&quot;).ReactNode; forEach(arg0: (part: any) =&gt; JSX.Element | undefined): unknown; part?: CoursePart; } </code></pre>
[ { "answer_id": 74189678, "author": "SavyJS", "author_id": 2673275, "author_profile": "https://Stackoverflow.com/users/2673275", "pm_score": 2, "selected": false, "text": "SELECT o.CustomerID as OCustomerID, c.CustomerId as CCustomerID\nFROM Customers AS c, Orders AS o;\n" }, { "a...
2022/10/25
[ "https://Stackoverflow.com/questions/74189594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12894011/" ]
74,189,598
<p>I'm rendering nested routes with the parent route rendering some components I would like present in every page.</p> <p>I want the Default component to render for every page and have <code>&quot;/&quot;</code> redirect to <code>&quot;/home&quot;</code>. Currently, when I input my <code>&quot;url.com/&quot;</code>, the page does not redirect and displays an error fallback component.</p> <p>Could someone please help me find a solution to and understand why the redirect is not working?</p> <pre><code>const publicRoutes = [ { path: '', element: &lt;Default/&gt;, children: [ { path: '/', element: &lt;Navigate to='/home' /&gt; }, ...otherRoutes ], }, ]; </code></pre>
[ { "answer_id": 74189711, "author": "Drew Reese", "author_id": 8690857, "author_profile": "https://Stackoverflow.com/users/8690857", "pm_score": 2, "selected": false, "text": "\"/\"" } ]
2022/10/25
[ "https://Stackoverflow.com/questions/74189598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14330686/" ]
74,189,618
<p>I would like convert string to JSON while receiving the value from API. I am sending value from postman but I am unable to convert it to the JSON object in the model class ,I have decorated model class with the custom decorator. Thanks in Advance.</p> <p>This is the Model Class and I wrote custom JSON convertor.</p> <pre><code> namespace WebApplication2.Models { [Serializable] public class Test { [JsonConverter(typeof(UserConverter))] public AS_AscContext AscParcelContext { get; set; } } public class AS_AscContext { public string ShellType { get; set; } public string LayoutName { get; set; } } public class UserConverter : JsonConverter { private readonly Type[] _types; public UserConverter(params Type[] types) { _types = types; } public override void WriteJson(JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer) { JToken t = JToken.FromObject(value); if (t.Type != JTokenType.Object) { t.WriteTo(writer); } else { JObject o = (JObject)t; IList&lt;string&gt; propertyNames = o.Properties().Select(p =&gt; p.Name).ToList(); o.AddFirst(new JProperty(&quot;Keys&quot;, new JArray(propertyNames))); o.WriteTo(writer); } } public override object ReadJson(JsonReader reader, Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer) { throw new NotImplementedException(&quot;Unnecessary because CanRead is false. The type will skip the converter.&quot;); } public override bool CanRead { get { return false; } } public override bool CanConvert(Type objectType) { return _types.Any(t =&gt; t == objectType); } } </code></pre> <p><strong>This is the controller receiving value</strong></p> <pre><code> [HttpPost] public IActionResult Privacy([FromBody]Test aS_AggregatorRequest) { return View(); } </code></pre> <p><a href="https://i.stack.imgur.com/Vg6fY.png" rel="nofollow noreferrer">This is the postman collection</a></p>
[ { "answer_id": 74189711, "author": "Drew Reese", "author_id": 8690857, "author_profile": "https://Stackoverflow.com/users/8690857", "pm_score": 2, "selected": false, "text": "\"/\"" } ]
2022/10/25
[ "https://Stackoverflow.com/questions/74189618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13235639/" ]
74,189,637
<p>This is my data:</p> <pre><code>obj = Object { Great Lakes: Array(3) [&quot;Michigan&quot;, &quot;Indiana&quot;, &quot;Ohio&quot;] Heartland: Array(2) [&quot;Missouri&quot;, &quot;Illinois&quot;] } </code></pre> <p>How can I change it to something like one by one:</p> <pre><code>{&quot;Illinois&quot;: &quot;Heartland&quot;, &quot;Michigan&quot;: &quot;Great Lakes&quot;, ...} </code></pre> <p><strong>I have to use <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map" rel="nofollow noreferrer">Map</a>, <em>Object.entries</em> and <em>Array.flat()</em></strong>.</p> <p>I used : <code>namemap = new Map(Object.entries(obj).map(function ([k, v]) {return [v, k];} ))</code> but this is not I want or maybe this is not complete.</p>
[ { "answer_id": 74189711, "author": "Drew Reese", "author_id": 8690857, "author_profile": "https://Stackoverflow.com/users/8690857", "pm_score": 2, "selected": false, "text": "\"/\"" } ]
2022/10/25
[ "https://Stackoverflow.com/questions/74189637", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14285143/" ]
74,189,654
<p>I am writing some code that parses some SQL expressions, but have run into a problem I cannot solve on my own. I want to replace a certain word in a SQL statement but not if that word is contained within a phrase that is enclosed in single or double quotes. My use case is SQL expression parsing but I think this is more a generic string replacement thing.</p> <p>To take an example consider the expression: <code>select {foo} from Table where {foo} = &quot;This is {foo} today&quot; or {foo} = 'this is {foo} tomorrrow' or {foo} = &quot;it's all '{foo}' to me!&quot;</code></p> <p>Assuming I want to replace <code>{foo}</code> to the string <code>bar</code>, the output would be: <code>select bar from Table where bar = &quot;This is {foo} today&quot; or bar = 'this is {foo} tomorrow' or bar = &quot;it's all '{foo}' to me!&quot;</code></p> <p>As we can see all <code>{foo}</code> expressions enclosed within quotes (single or double) have not been replaced.</p> <p>We can make the assumption that quotes will be closed, i.e. there will be no stray quotes floating around (<code>where {foo} = 'un'even&quot;</code> is not a use case we need to consider.)</p> <p>Text within nested quotes should not be replaced (as however you look at it the text is contained within quotes :) ) The example shows an example of this in the <code>or {foo} = &quot;it's all '{foo}' to me!&quot;</code> part (as well as containing three single quotes just for fun)</p> <p>I have done quite a bit of research on this and it seems a tricky thing to do in Javascript (or any other language no doubt). This seems a good fit for regex, but any javascript solution regex or not would be helpful. The closest I have come in Stack Overflow to a solution is <a href="https://stackoverflow.com/questions/15683128/dont-replace-regex-if-it-is-enclosed-by-a-character">Don&#39;t replace regex if it is enclosed by a character</a> but it isn't a close enough match to help</p>
[ { "answer_id": 74189772, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 1, "selected": false, "text": "'.+?'|\\{foo\\}" }, { "answer_id": 74190001, "author": "pastalord", "author_id": 11988016, ...
2022/10/25
[ "https://Stackoverflow.com/questions/74189654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4406780/" ]
74,189,684
<p>I've been doing CSS for a while now but couldn't figure out what's going here. Feeling really dumb :) Could you explain the behaviour?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.parent { display:inline-block; } .child { border: 2px solid red; padding: 20px; /* this works as expected */ padding: 20%; box-sizing: border-box; /* makes no difference */ }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="parent"&gt; &lt;div class="child"&gt;CSSisAwesome&lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74189770, "author": "micahlt", "author_id": 10806546, "author_profile": "https://Stackoverflow.com/users/10806546", "pm_score": -1, "selected": false, "text": ".parent" }, { "answer_id": 74190703, "author": "Temani Afif", "author_id": 8620333, "author_p...
2022/10/25
[ "https://Stackoverflow.com/questions/74189684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/559079/" ]
74,189,685
<pre><code>def getAllBooksPagesURLs(): lists_of_url = [] lists_of_url.append(r&quot;http://books.toscrape.com/&quot;) for j in range(2,51): lists_of_url.append(r&quot;http://books.toscrape.com/catalogue/page-%d.html&quot;%j) return lists_of_url def getAndParseURL(url): result = requests.get(url) soup = BeautifulSoup(result.text, 'html.parser') return soup def getBooksURLs(url,z): soup = getAndParseURL(url) return([z+ x.a.get('href') for x in soup.findAll( &quot;div&quot;, class_=&quot;image_container&quot;)]) books_url = [] title_list = [] main_page_list = [] list_of_rewiew_num = [] list_of_bookpage = [] list_of_resultitle = [] books_done_page = [] list_of_review_num=[] for y in getAllBooksPagesURLs()[0:1]: main_page=getAndParseURL(y) result_of_title = main_page.findAll(&quot;h3&quot;) for x in result_of_title: list_of_resultitle.append(x.find(&quot;a&quot;).get(&quot;title&quot;)) books_url = getBooksURLs(y,y) for b in books_url: print(b) books_page = getAndParseURL(b) if books_page.find(&quot;td&quot;) is None: list_of_review_num.append(0) else: review_num =books_page.find(&quot;td&quot;).contents[0] list_of_review_num.append(review_num) books_url list_of_resultitle list_of_review_num </code></pre> <blockquote> <p>above is my code ,the result is</p> </blockquote> <p>['a897fe39b1053632', '90fa61229261140a', '6957f44c3847a760', 'e00eb4fd7b871a48', '4165285e1663650f', 'f77dbf2323deb740', '2597b5a345f45e1b', 'e72a5dfc7e9267b2', 'e10e1e165dc8be4a', '1dfe412b8ac00530', '0312262ecafa5a40', '30a7f60cd76ca58c', 'ce6396b0f23f6ecc', '3b1c02bac2a429e6', 'a34ba96d4081e6a4', 'deda3e61b9514b83', 'feb7cc7701ecf901', 'e30f54cea9b38190', 'a18a4f574854aced', 'a22124811bfa8350']</p> <blockquote> <p>the garble codes are like 'a22124811bfa8350', is it about dynamic html? I donnot know. my desire output of list_of_review_num should be</p> </blockquote> <pre><code>[0,1,2,3] </code></pre> <p>how to get the correct output?could you plz help me? thank u in advance</p>
[ { "answer_id": 74189770, "author": "micahlt", "author_id": 10806546, "author_profile": "https://Stackoverflow.com/users/10806546", "pm_score": -1, "selected": false, "text": ".parent" }, { "answer_id": 74190703, "author": "Temani Afif", "author_id": 8620333, "author_p...
2022/10/25
[ "https://Stackoverflow.com/questions/74189685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16566489/" ]
74,189,687
<p>I just registered my own domain on GCP and instead, created a new GCP. I wanted to migrate my old GCP to new one. So, I signed in using <code>firebase login:ci</code>. The new window opened up to choose my account and I used my new assigned account for registered domain on new GCP. Then I run firebase init inside. I got this error after selecting firebase project I created using a new GCP.</p> <blockquote> <p>Error: HTTP Error: 403, Permission denied to get service [firestore.googleapis.com] Help Token: AWzfkCMe3kI1xtpLJkoCpzQg-sn3fQt7oX8VPut5qpv5cBZcYLNuMwx9Ml1UofnrC9fStBNhbTPnPBJlx-jiM4Br3U-pBp91mmYWnqnrOxClIEQY</p> </blockquote>
[ { "answer_id": 74189770, "author": "micahlt", "author_id": 10806546, "author_profile": "https://Stackoverflow.com/users/10806546", "pm_score": -1, "selected": false, "text": ".parent" }, { "answer_id": 74190703, "author": "Temani Afif", "author_id": 8620333, "author_p...
2022/10/25
[ "https://Stackoverflow.com/questions/74189687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13890662/" ]
74,189,688
<pre><code> to={routeName.tutorClassView + '?classId=' + `${_.get(value, '_id')}`} to={routeName.tutorClassView + '?classId=' + `${_.get(v, 'id')}` + '&amp;providerId=' + `${_.get(v, 'provider.id')}`} </code></pre> <p>What am i doing wrong here</p>
[ { "answer_id": 74189770, "author": "micahlt", "author_id": 10806546, "author_profile": "https://Stackoverflow.com/users/10806546", "pm_score": -1, "selected": false, "text": ".parent" }, { "answer_id": 74190703, "author": "Temani Afif", "author_id": 8620333, "author_p...
2022/10/25
[ "https://Stackoverflow.com/questions/74189688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20327397/" ]
74,189,694
<pre><code>from pprint import pprint from Goo_gle import Create_Service CLIENT_SECRET_FILE = 'Client_Calendar.json' API_NAME = 'calendar' API_VERSION = 'v3' SCOPES = ['https://www.googleapis.com/auth'] service = Create_Service(CLIENT_SECRET_FILE, API_NAME, API_VERSION, SCOPES) </code></pre> <p>Output:</p> <pre><code>Traceback (most recent call last): File &quot;d:\Play with code\PROGRAMMINGS\Python\Artificial Inteligence\calen_dar.py&quot;, line 2, in &lt;module&gt; from Goo_gle import Create_Service File &quot;d:\Play with code\PROGRAMMINGS\Python\Artificial Inteligence\Goo_gle.py&quot;, line 5, in &lt;module&gt; from google_auth_oauthlib.flow import Flow, InstalledAppFlow File &quot;C:\Python\lib\site-packages\google_auth_oauthlib\__init__.py&quot;, line 21, in &lt;module&gt; from .interactive import get_user_credentials File &quot;C:\Python\lib\site-packages\google_auth_oauthlib\interactive.py&quot;, line 27, in &lt;module&gt; import google_auth_oauthlib.flow File &quot;C:\Python\lib\site-packages\google_auth_oauthlib\flow.py&quot;, line 69, in &lt;module&gt; import google_auth_oauthlib.helpers File &quot;C:\Python\lib\site-packages\google_auth_oauthlib\helpers.py&quot;, line 27, in &lt;module&gt; from google.auth import external_account_authorized_user ImportError: cannot import name 'external_account_authorized_user' from 'google.auth' (C:\Python\lib\site-packages\google\auth\__init__.py) </code></pre> <p>I am not getting why this is happening. This code was working from last 3 month but today after updating google libraries, this error came.. How to fix this?</p>
[ { "answer_id": 74193071, "author": "Steve Pike", "author_id": 310391, "author_profile": "https://Stackoverflow.com/users/310391", "pm_score": 4, "selected": false, "text": "google-auth-library-python-oauth" }, { "answer_id": 74197632, "author": "Vu Phan", "author_id": 146...
2022/10/25
[ "https://Stackoverflow.com/questions/74189694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20327380/" ]
74,189,703
<pre><code>List=[&quot;2&quot;,&quot;10&quot;,&quot;15&quot;,&quot;23&quot;,&quot;exit&quot;] # Output required List_new = [2,10,15,23] </code></pre>
[ { "answer_id": 74189745, "author": "Nuri Taş", "author_id": 19255749, "author_profile": "https://Stackoverflow.com/users/19255749", "pm_score": 2, "selected": false, "text": "isnumeric" }, { "answer_id": 74189753, "author": "Harsha Biyani", "author_id": 3457761, "auth...
2022/10/25
[ "https://Stackoverflow.com/questions/74189703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19748912/" ]
74,189,707
<p>I have placed a picture (OLE object) in the group footer and I need to check whether this object is printed in the current worksheet or not. So basically I want to detect the end of group and update an object (string) which is placed in the group header. Is this possible in the formula editor?</p>
[ { "answer_id": 74189745, "author": "Nuri Taş", "author_id": 19255749, "author_profile": "https://Stackoverflow.com/users/19255749", "pm_score": 2, "selected": false, "text": "isnumeric" }, { "answer_id": 74189753, "author": "Harsha Biyani", "author_id": 3457761, "auth...
2022/10/25
[ "https://Stackoverflow.com/questions/74189707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8988753/" ]
74,189,759
<p>I am attempting to filter the information from a websocket request. I can complete my request fine however the response comes back with more information than I actually require. I want to filter this information out and then use it in a variable.</p> <p>For example if I just use the sample code from ByBit websocket api</p> <pre><code>import json from websocket import create_connection ws = create_connection(&quot;wss://stream-testnet.bybit.com/realtime&quot;) ws.send('{&quot;op&quot;: &quot;subscribe&quot;, &quot;args&quot;: [&quot;instrument_info.100ms.BTCUSD&quot;]}'); bybitresult = ws.recv() print(bybitresult) ws.close() </code></pre> <p>I get the response below</p> <pre><code>{&quot;topic&quot;:&quot;instrument_info.100ms.BTCUSD&quot;,&quot;type&quot;:&quot;snapshot&quot;,&quot;data&quot;:{&quot;id&quot;:1,&quot;symbol&quot;:&quot;BTCUSD&quot;,&quot;last_price_e4&quot;:192785000,&quot;last_price&quot;:&quot;19278.50&quot;,&quot;bid1_price_e4&quot;:192780000,&quot;bid1_price&quot;:&quot;19278.00&quot;,&quot;ask1_price_e4&quot;:192785000,&quot;ask1_price&quot;:&quot;19278.50&quot;,&quot;last_tick_direction&quot;:&quot;ZeroPlusTick&quot;,&quot;prev_price_24h_e4&quot;:192650000,&quot;prev_price_24h&quot;:&quot;19265.00&quot;,&quot;price_24h_pcnt_e6&quot;:700,&quot;high_price_24h_e4&quot;:204470000,&quot;high_price_24h&quot;:&quot;20447.00&quot;,&quot;low_price_24h_e4&quot;:187415000,&quot;low_price_24h&quot;:&quot;18741.50&quot;,&quot;prev_price_1h_e4&quot;:192785000,&quot;prev_price_1h&quot;:&quot;19278.50&quot;,&quot;price_1h_pcnt_e6&quot;:0,&quot;mark_price_e4&quot;:192886700,&quot;mark_price&quot;:&quot;19288.67&quot;,&quot;index_price_e4&quot;:193439800,&quot;index_price&quot;:&quot;19343.98&quot;,&quot;open_interest&quot;:467889481,&quot;open_value_e8&quot;:0,&quot;total_turnover_e8&quot;:1786988413378107,&quot;turnover_24h_e8&quot;:65984748882,&quot;total_volume&quot;:478565052570,&quot;volume_24h&quot;:12839296,&quot;funding_rate_e6&quot;:-677,&quot;predicted_funding_rate_e6&quot;:-677,&quot;cross_seq&quot;:5562806725,&quot;created_at&quot;:&quot;2018-12-29T03:04:13Z&quot;,&quot;updated_at&quot;:&quot;2022-10-25T06:09:48Z&quot;,&quot;next_funding_time&quot;:&quot;2022-10-25T08:00:00Z&quot;,&quot;countdown_hour&quot;:2,&quot;funding_rate_interval&quot;:8,&quot;settle_time_e9&quot;:0,&quot;delisting_status&quot;:&quot;0&quot;},&quot;cross_seq&quot;:5562806725,&quot;timestamp_e6&quot;:1666678189180180} </code></pre> <p>However, I only want to use some of the data within the &quot;data&quot; string for example 'last_price' and 'timestamp_e6'. I have attempted this by trying to split the output string but am not having any luck at the moment.</p> <p>Any help would be greatly appreciated. Thank you</p>
[ { "answer_id": 74189745, "author": "Nuri Taş", "author_id": 19255749, "author_profile": "https://Stackoverflow.com/users/19255749", "pm_score": 2, "selected": false, "text": "isnumeric" }, { "answer_id": 74189753, "author": "Harsha Biyani", "author_id": 3457761, "auth...
2022/10/25
[ "https://Stackoverflow.com/questions/74189759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18370643/" ]
74,189,763
<p>I have written below code to get the response data <strong>chunk</strong> in the variable called <strong>outBody</strong>, but it is showing undefined. Any suggestions please?</p> <pre><code>var options = { host: 'jsonplaceholder.typicode.com', port: 80, path: '/todos/1' }; var outBody; http.get(options, function(res) { console.log(&quot;Got response: &quot; + res.statusCode); res.on(&quot;data&quot;, function(chunk) { outBody = chunk; }); }).on('error', function(e) { console.log(&quot;Got error: &quot; + e.message); }); console.log(outBody); </code></pre> <p>I actually want to use the variable <strong>outBody</strong> outside the http request. How can I use it?</p>
[ { "answer_id": 74189745, "author": "Nuri Taş", "author_id": 19255749, "author_profile": "https://Stackoverflow.com/users/19255749", "pm_score": 2, "selected": false, "text": "isnumeric" }, { "answer_id": 74189753, "author": "Harsha Biyani", "author_id": 3457761, "auth...
2022/10/25
[ "https://Stackoverflow.com/questions/74189763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6876073/" ]
74,189,810
<p>I have a website that has been built at say <code>montypython.netlify.app</code></p> <p>The client has their main website at <code>holygrail.com</code> and they want <code>holygrail.com/resources</code> to show the contents of <code>montypython.netlify.app</code> but <em>keep the URL the same</em>. Which means that it should continue to show <code>holygrail.com/resources</code> in the search bar.</p> <p>This also means that any pages from <code>montypython.netlify.app</code> should appear are subdirectories of <code>holygrail.com/resources</code></p> <p>Example: <code>montypython.netlify.app/about</code> should appear as <code>holygrail.com/resources/about</code></p> <p>I am guessing this has to do with editing the .htaccess at <code>holygrail.com</code> but what rewrite/redirect rules can I reference? There are a lot of URLs so is there a wildcard approach I can use?</p> <p>This is what I've tried:</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteCond %{HTTP_HOST} ^holygrail\.com$ [NC] RewriteRule ^resources/(.*)$ https://montypython.netlify.app/$1 [R=301,L] &lt;/IfModule&gt; </code></pre>
[ { "answer_id": 74270157, "author": "Joseph Ishak", "author_id": 1893392, "author_profile": "https://Stackoverflow.com/users/1893392", "pm_score": 1, "selected": false, "text": "RewriteCond %{HTTP_HOST} ^holygrail\\.com$ [NC] \n" }, { "answer_id": 74290806, "author": "user3357...
2022/10/25
[ "https://Stackoverflow.com/questions/74189810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4112751/" ]
74,189,826
<p>I'm very new to QT so please assume I know nothing. I want an auto-complete where it only matches against the text after the last comma.</p> <p>e.g. if my word bank is [&quot;alpha&quot;, &quot;beta&quot;, &quot;vector space&quot;], and the user currently has typed &quot;epsilon,dog,space&quot; then it should match against &quot;vector space&quot; since &quot;space&quot; is a substring of &quot;vector space&quot;.</p> <p>I'm using PyQt6 and my current code looks something like this (adapted from a YouTube tutorial):</p> <pre><code>line_of_text = QLineEdit(&quot;&quot;) word_bank = [name for name,value in names_dict.items()] completer = QCompleter(word_bank) completer.setCaseSensitivity(Qt.CaseSensitivity.CaseInsensitive) completer.setFilterMode(Qt.MatchContains) line_of_text.setCompleter(completer) </code></pre> <p>So currently, if word_bank is [&quot;alpha&quot;, &quot;beta&quot;, &quot;vector space&quot;], then if line_of_text had the string &quot;epsilon,dog,space&quot; then it wouldn't match against anything because &quot;epsilon,dog,space&quot; isn't a substring of &quot;alpha&quot; nor &quot;beta&quot; nor &quot;vector space&quot;.</p> <p>How can I alter my code to achieve what I would like to achieve? -- I'm experienced with programming, just not with Qt.</p> <p><strong>PS:</strong> I have tried doing</p> <pre><code>line_of_text.textChanged[str].connect(my_function) </code></pre> <p>where my_function takes only the substring of line_of_text after the last comma and feeds it to completer.setCompletionPrefix and then calls completer.complete(). This simply does not work. I assume the reason is that completer.complete() updates the completion prefix from line_of_text, causing the call to completer.setCompletionPrefix to be overwritten immediately after.</p>
[ { "answer_id": 74189873, "author": "ThatOneCoder", "author_id": 15942680, "author_profile": "https://Stackoverflow.com/users/15942680", "pm_score": 0, "selected": false, "text": "for word in str.split(\",\"):\n \n for check in word_bank:\n etc...\n\n" }, { "ans...
2022/10/25
[ "https://Stackoverflow.com/questions/74189826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10868964/" ]
74,189,828
<p>Why it displays [object Object]? I'm trying to display a selection of countries. See the example code.</p> <p><a href="https://i.stack.imgur.com/arSuA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/arSuA.png" alt="enter image description here" /></a></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>document.addEventListener('DOMContentLoaded', () =&gt;{ const selectDrop = document.querySelector('#countries'); fetch('https://restcountries.com/v3.1/all').then(res =&gt; { return res.json(); }).then(data =&gt; { let output = ""; data.forEach(country =&gt; { output += `&lt;option&gt;${country.name}&lt;/option&gt;`; }) selectDrop.innerHTML = output; }).catch(err =&gt; { console.log(err); }) });</code></pre> </div> </div> </p>
[ { "answer_id": 74189861, "author": "R4ncid", "author_id": 14326899, "author_profile": "https://Stackoverflow.com/users/14326899", "pm_score": 2, "selected": false, "text": "country.name.common" }, { "answer_id": 74189894, "author": "Dexter633", "author_id": 16015164, ...
2022/10/25
[ "https://Stackoverflow.com/questions/74189828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20271429/" ]
74,189,891
<p>I want to make a trigger that will insert a value from a connected row. For example I have a table with 3 rows as below:</p> <p><a href="https://i.stack.imgur.com/zInBq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zInBq.png" alt="Table" /></a></p> <p>I create a trigger that will work once row 3 and 4 are deleted (in this case will be deleted at the same time). And I want to record <code>invnr</code> and <code>extinvnr</code> from row 1 based on <code>idparent=id</code>. I cannot seem to make it work though.</p> <pre><code>CREATE OR REPLACE TRIGGER LOG_DELETEDPAYMENTS BEFORE DELETE ON payments FOR EACH ROW BEGIN IF :old.invnr IS NULL THEN INSERT INTO TABLE_LOG_DELETEDPAYMENTS (table_name, invnr, extinvnr, invdate, transactionid, info, createdby, deleted_by, date_of_delete) values ('payments', :old.invnr, :old.extinvnr, :old.invdate, :old:transactionid, :old.info, :old.createdby, sys_context('userenv','OS_USER'), SYSDATE); END IF; END; </code></pre> <p>How can I incorporate this into the trigger above?</p>
[ { "answer_id": 74211499, "author": "d r", "author_id": 19023353, "author_profile": "https://Stackoverflow.com/users/19023353", "pm_score": 2, "selected": true, "text": "create or replace TRIGGER LOG_DELETEDPAYMENTS\nBEFORE DELETE ON payments\nFOR EACH ROW\nDECLARE\n PRAGMA AUTONOMOUS_...
2022/10/25
[ "https://Stackoverflow.com/questions/74189891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17982417/" ]
74,189,927
<p>i've added firebase_auth and get this error</p> <pre><code> CocoaPods could not find compatible versions for pod &quot;GTMSessionFetcher/Core&quot;: In Podfile: firebase_auth (from `.symlinks/plugins/firebase_auth/ios`) was resolved to 4.0.2, which depends on Firebase/Auth (= 10.0.0) was resolved to 10.0.0, which depends on FirebaseAuth (~&gt; 10.0.0) was resolved to 10.0.0, which depends on GTMSessionFetcher/Core (~&gt; 2.1) mobile_scanner (from `.symlinks/plugins/mobile_scanner/ios`) was resolved to 0.0.1, which depends on GoogleMLKit/BarcodeScanning (~&gt; 2.6.0) was resolved to 2.6.0, which depends on MLKitBarcodeScanning (~&gt; 1.7.0) was resolved to 1.7.0, which depends on MLKitVision (~&gt; 3.0) was resolved to 3.0.0, which depends on GTMSessionFetcher/Core (~&gt; 1.1) </code></pre> <p>if i remove the firebase_auth, everything goes fine . i've tried to use arch -x86_64 pod install with no success . any one faced this issue?</p>
[ { "answer_id": 74211499, "author": "d r", "author_id": 19023353, "author_profile": "https://Stackoverflow.com/users/19023353", "pm_score": 2, "selected": true, "text": "create or replace TRIGGER LOG_DELETEDPAYMENTS\nBEFORE DELETE ON payments\nFOR EACH ROW\nDECLARE\n PRAGMA AUTONOMOUS_...
2022/10/25
[ "https://Stackoverflow.com/questions/74189927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17098000/" ]
74,189,935
<p>I have this problem I'm curious about where I have an Array and I need to compute the Sum of this function:</p> <p><code>Arr[L] + (Arr[L] ^ Arr[L+1]) + ... + (Arr[L] ^ Arr[L+1] ^ ... ^ Arr[R])</code></p> <p><strong>Example:</strong></p> <p>If the Array given was: <code>[1, 2, 3, 5]</code> and I asked what's the sum on the range <code>[L = 1, R = 3]</code> (assuming 1-based Index), then it'd be:</p> <p><code>Sum = 1 + (1 ^ 2) + (1 ^ 2 ^ 3) = 4</code></p> <p>In this problem, the Array, the size of the Array, and the Ranges are given. My approach for this is too slow.</p> <p>There's also a variable called Q which indicates the number of Queries that would process each [L, R].</p> <p><strong>What I have:</strong></p> <p>I XOR'ed each element and then summed it to a variable within the range of [L, R]. Is there any faster way to compute this if the elements in the Array are suppose... 1e18 or 1e26 larger?</p> <pre><code>#include &lt;iostream&gt; #include &lt;array&gt; int main (int argc, const char** argv) { long long int N, L, R; std::cin &gt;&gt; N; long long int Arr[N]; for (long long int i = 0; i &lt; N; i++) { std::cin &gt;&gt; Arr[i]; } std::cin &gt;&gt; L &gt;&gt; R; long long int Summation = 0, Answer = 0; for (long long int i = L; i &lt;= R; i++) { Answer = Answer ^ Arr[i - 1]; Summation += Answer; } std::cout &lt;&lt; Summation &lt;&lt; '\n'; return 0; } </code></pre>
[ { "answer_id": 74190284, "author": "selbie", "author_id": 104458, "author_profile": "https://Stackoverflow.com/users/104458", "pm_score": 1, "selected": false, "text": "int sum = 0;\nint prev = 0;\n\nfor (int i = L; i <= R; i++)\n{\n int current = (prev ^ Arr[i]);\n sum += current;...
2022/10/25
[ "https://Stackoverflow.com/questions/74189935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14497521/" ]