qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,265,655
<p>I am trying to convert below object to array of string</p> <p>JSON Object</p> <p>Input :</p> <pre><code> [ { &quot;name&quot;: &quot;Pantry&quot;, &quot;childrenItems&quot;: [ { &quot;name&quot;: &quot;Butter&quot;, &quot;childrenItems&quot;: [ { &quot;name&quot;: &quot;Cream&quot;, &quot;childrenItems&quot;: [] } ] }, { &quot;name&quot;: &quot;Snack&quot;, &quot;childrenItems&quot;: [] } ] }, { &quot;name&quot;: &quot;Medicine&quot;, &quot;childrenItems&quot;: [] } ] </code></pre> <p>Required Output:</p> <blockquote> <p><code>[ &quot;Pantry-&gt;Butter-&gt;Cream&quot;, &quot;Pantry-&gt;Snack&quot;, &quot;Medicine&quot; ]</code></p> </blockquote> <p>My POJO looks like this</p> <pre><code>@Data public class CategoryTreeDto { private String name; private List&lt;CategoryTreeDto&gt; childrenItems; } </code></pre> <p>How can I flatten the JSON object of Nested categories using java 8 stream API.</p> <p>I tried using the recursion and java 8 flatMap function to flatten and concatenate the strings but not getting output as expected.</p> <p>It is based on parent child relationship, as pantry is a parent and its child is butter and again butter's child is cream and also pantry has another child which is snack.</p>
[ { "answer_id": 74265632, "author": "Osm", "author_id": 19529694, "author_profile": "https://Stackoverflow.com/users/19529694", "pm_score": 3, "selected": true, "text": "=ArrayFormula(\n LAMBDA(a, {QUERY({a},\"Select Col1\"),SPLIT(QUERY({a},\"Select Col2\"),\",\")})\n (QUERY('Alias Key Ra...
2022/10/31
[ "https://Stackoverflow.com/questions/74265655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20380620/" ]
74,265,699
<p>I'm starting to write a framework in tcl which uses TclOO.</p> <p>I intend to keep a central library of core classes. Child classes will live in separate files which need to be able to source the core classes to derive from them. Using tcl <code>source</code> to obtain the core class definition doesn't feel right and I was wondering whether packages would do a better job.</p> <p>Before going down this rabbit hole I'd like to know if this could work in principle.</p>
[ { "answer_id": 74266157, "author": "Donal Fellows", "author_id": 301832, "author_profile": "https://Stackoverflow.com/users/301832", "pm_score": 3, "selected": true, "text": "namespace" }, { "answer_id": 74335274, "author": "Eric", "author_id": 4800745, "author_profil...
2022/10/31
[ "https://Stackoverflow.com/questions/74265699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1007226/" ]
74,265,728
<p>i have another &quot;movie database&quot; application in react. At the mount it renders movies based on api key which is set to &quot;new movies&quot;. Then i have useEffect which update movie list based on searchbar and its value. Problem is, it renders new movies and just after that renders movies based on searchbar value which is empty. I know that useEffect is running on mount. What is best practice to use it this way? Or is there any better hook for this particular use? Thank you.</p> <pre><code>React.useEffect(() =&gt; { fetch( `https://api.themoviedb.org/3/search/movie?api_keylanguage=en-US&amp;query=${searchValue}&amp;` ) .then((res) =&gt; res.json()) .then((data) =&gt; { setMovies(data.results); }); }, [searchValue]); </code></pre>
[ { "answer_id": 74265852, "author": "David", "author_id": 13019276, "author_profile": "https://Stackoverflow.com/users/13019276", "pm_score": -1, "selected": false, "text": " useEffect(() => {\n const getData = async () => {\n await fetch(\n `https://api.themoviedb.org/3/s...
2022/10/31
[ "https://Stackoverflow.com/questions/74265728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7744142/" ]
74,265,750
<p>I tried to do this thing in dart but it failed and I don't really understand why. I know that dart doesn't support robust &quot;Pattern Matching&quot; like elixir does, but I thought it should be able to compare two lists. No. Why not? what is it about the typing system that can't equate two lists and if it could, could it support even rudimentary pattern matching? I'm just trying to understand how equate works in dart I guess.</p> <pre><code>void main() { final x = 1; final y = 2; if (x == 1 &amp;&amp; y == 2) { print('this works fine of course'); } if ([1, 2] == [1, 2]) { print('but this does not'); } if ([x, y] == [1, 2]) { print('would this work if dart could equate lists?'); } } </code></pre>
[ { "answer_id": 74265852, "author": "David", "author_id": 13019276, "author_profile": "https://Stackoverflow.com/users/13019276", "pm_score": -1, "selected": false, "text": " useEffect(() => {\n const getData = async () => {\n await fetch(\n `https://api.themoviedb.org/3/s...
2022/10/31
[ "https://Stackoverflow.com/questions/74265750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3071728/" ]
74,265,751
<p>This is my checkbox components for multi selection.</p> <pre class="lang-js prettyprint-override"><code>const MultiselectCheckbox = ({ options, onChange, limitedCount }) =&gt; { const [data, setData] = React.useState(options); const toggle = index =&gt; { const newData = [...data]; newData.splice(index, 1, { label: data[index].label, checked: !data[index].checked }); setData(newData); onChange(newData.filter(x =&gt; x.checked)); }; return ( &lt;&gt; {data.map((item, index) =&gt; ( &lt;label key={item.label}&gt; &lt;input readOnly type=&quot;checkbox&quot; checked={item.checked || false} onClick={() =&gt; toggle(index)} /&gt; {item.label} &lt;/label&gt; ))} &lt;/&gt; ); }; const options = [{ label: 'Item One' }, { label: 'Item Two' }]; ReactDOM.render( &lt;MultiselectCheckbox options={options} onChange={data =&gt; { console.log(data); }} /&gt;, document.getElementById('root') ); </code></pre> <p>I want to limit the items I can choose by putting limitedCount in my code. props for example</p> <ul> <li>limitedSelectCount = 1 <ul> <li>Only one check box can be selected</li> </ul> </li> <li>limitedSelectCount = n <ul> <li>Multiple n check boxes available</li> </ul> </li> </ul>
[ { "answer_id": 74265852, "author": "David", "author_id": 13019276, "author_profile": "https://Stackoverflow.com/users/13019276", "pm_score": -1, "selected": false, "text": " useEffect(() => {\n const getData = async () => {\n await fetch(\n `https://api.themoviedb.org/3/s...
2022/10/31
[ "https://Stackoverflow.com/questions/74265751", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3871177/" ]
74,265,769
<p>Here is my Task</p> <pre><code>private async Task UploadFiles(InputFileChangeEventArgs inputFileChangeEventArgs) { _CarregaFoto = true; var fileFormat = &quot;image/png&quot;; var MAXALLOWEDSIZE = 60000000; var imageFile = await inputFileChangeEventArgs.File.RequestImageFileAsync(fileFormat, 6000, 6000); var buffer = new byte[imageFile.Size]; await imageFile.OpenReadStream(MAXALLOWEDSIZE).ReadAsync(buffer); AnexoDenunciaModel _novaFoto = new AnexoDenunciaModel(); _novaFoto.imagem = buffer; _novaFoto.id_ocorre = id; _novaFoto.nome = imageFile.Name; _novaFoto.Denunciante = true; await _db.InsertAnexoDenuncia(_novaFoto); _CarregaFoto = false; await LeTabelas2(); } </code></pre> <p>I've tried to change var fileFormat to pdf or discart this part but with no success, the task only accept png, jpg, etc. files. How can i accept other types like pdf, txt files?</p>
[ { "answer_id": 74265852, "author": "David", "author_id": 13019276, "author_profile": "https://Stackoverflow.com/users/13019276", "pm_score": -1, "selected": false, "text": " useEffect(() => {\n const getData = async () => {\n await fetch(\n `https://api.themoviedb.org/3/s...
2022/10/31
[ "https://Stackoverflow.com/questions/74265769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20122702/" ]
74,265,780
<p>Consider this data frame:</p> <pre class="lang-r prettyprint-override"><code> idPerson idAppt decision date 1 A 1 a 2021-09-10 2 A 1 b 2021-09-11 3 A 1 c 2021-09-12 4 A 1 d 2021-09-13 5 A 2 a 2021-09-20 6 A 2 b 2021-09-21 7 A 3 a 2021-09-10 8 A 3 b 2021-09-11 9 B 1 a 2021-09-10 10 B 1 b 2021-09-11 11 B 1 c 2021-09-12 12 B 1 d 2021-09-13 13 B 2 a 2021-09-11 14 B 2 b 2021-09-12 15 B 3 a 2021-09-14 16 B 3 b 2021-09-15 </code></pre> <p>For each groups of <code>idPerson</code> and <code>idAppt</code>, I'd like to get a <code>date2</code> column, but with certain conditions:</p> <ul> <li>For any groups (<code>idPerson</code> x <code>idAppt</code>) whose <code>decision == &quot;a&quot;</code> starts later than the date of <code>decision == &quot;d&quot;</code> of any other <code>idAppt</code> group with the same <code>idPerson</code>, report the date when <code>decision == &quot;d&quot;</code> of that group.</li> <li>For any other group that do not meet this requirement, <code>date2</code> should be the earliest date for this given <code>idPerson</code>.</li> </ul> <p>Which yields this data frame:</p> <pre class="lang-r prettyprint-override"><code> idPerson idAppt decision date date2 1 A 1 a 2021-09-10 2021-09-10 2 A 1 b 2021-09-11 2021-09-10 3 A 1 c 2021-09-12 2021-09-10 4 A 1 d 2021-09-13 2021-09-10 5 A 2 a 2021-09-20 2021-09-13 6 A 2 b 2021-09-21 2021-09-13 7 A 3 a 2021-09-10 2021-09-10 8 A 3 b 2021-09-11 2021-09-10 9 B 1 a 2021-09-10 2021-09-10 10 B 1 b 2021-09-11 2021-09-10 11 B 1 c 2021-09-12 2021-09-10 12 B 1 d 2021-09-13 2021-09-10 13 B 2 a 2021-09-11 2021-09-10 14 B 2 b 2021-09-12 2021-09-10 15 B 3 a 2021-09-14 2021-09-13 16 B 3 b 2021-09-15 2021-09-13 </code></pre> <hr /> <p>Data:</p> <pre class="lang-r prettyprint-override"><code>df &lt;- structure(list(idPerson = c(&quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;B&quot;, &quot;B&quot;, &quot;B&quot;, &quot;B&quot;, &quot;B&quot;, &quot;B&quot;, &quot;B&quot;, &quot;B&quot;), idAppt = c(1L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 1L, 1L, 1L, 1L, 2L, 2L, 3L, 3L), decision = c(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;a&quot;, &quot;b&quot;, &quot;a&quot;, &quot;b&quot;, &quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;a&quot;, &quot;b&quot;, &quot;a&quot;, &quot;b&quot;), date = structure(c(18880, 18881, 18882, 18883, 18890, 18891, 18880, 18881, 18880, 18881, 18882, 18883, 18881, 18882, 18884, 18885), class = &quot;Date&quot;)), class = c(&quot;tbl_df&quot;, &quot;tbl&quot;, &quot;data.frame&quot;), row.names = c(NA, -16L)) EO &lt;- structure(list(idPerson = c(&quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;B&quot;, &quot;B&quot;, &quot;B&quot;, &quot;B&quot;, &quot;B&quot;, &quot;B&quot;, &quot;B&quot;, &quot;B&quot;), idAppt = c(1L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 1L, 1L, 1L, 1L, 2L, 2L, 3L, 3L), decision = c(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;a&quot;, &quot;b&quot;, &quot;a&quot;, &quot;b&quot;, &quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;a&quot;, &quot;b&quot;, &quot;a&quot;, &quot;b&quot;), date = structure(c(18880, 18881, 18882, 18883, 18890, 18891, 18880, 18881, 18880, 18881, 18882, 18883, 18881, 18882, 18884, 18885), class = &quot;Date&quot;), date2 = c(&quot;2021-09-10&quot;, &quot;2021-09-10&quot;, &quot;2021-09-10&quot;, &quot;2021-09-10&quot;, &quot;2021-09-13&quot;, &quot;2021-09-13&quot;, &quot;2021-09-10&quot;, &quot;2021-09-10&quot;, &quot;2021-09-10&quot;, &quot;2021-09-10&quot;, &quot;2021-09-10&quot;, &quot;2021-09-10&quot;, &quot;2021-09-10&quot;, &quot;2021-09-10&quot;, &quot;2021-09-13&quot;, &quot;2021-09-13&quot;)), row.names = c(NA, -16L), class = c(&quot;tbl_df&quot;, &quot;tbl&quot;, &quot;data.frame&quot;)) </code></pre>
[ { "answer_id": 74266179, "author": "peter861222", "author_id": 17918739, "author_profile": "https://Stackoverflow.com/users/17918739", "pm_score": 2, "selected": false, "text": "#Select earlist date for decision d by idPerson\ndf_d <- df%>%\n filter(decision==\"d\")%>%\n group_by(idPer...
2022/10/31
[ "https://Stackoverflow.com/questions/74265780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13460602/" ]
74,265,785
<p>I'm trying to add a feature which when I click on my navbar, the animation restarts on the click, but I can't seem to make it work</p> <p>JAVSCRIPT</p> <pre><code>const homeButton = document.getElementById('li-home'); const home = document.getElementById('home'); function refreshHome() { home.removeClass('logo-animation') home.addClass('logo-animation'); setTimeout(function() { home.classList.remove('logo-animation'); }, 1000); } homeButton.onclick = refreshHome; </code></pre> <p>CSS class</p> <pre><code> .home-animation { animation: tracking-in-contract 1.2s cubic-bezier(0.215, 0.610, 0.355, 1.000) both; } </code></pre> <p>HTML</p> <pre><code> &lt;header id=&quot;home&quot;&gt; &lt;div class=&quot;logo logo-animation&quot; data-glitch=&quot;Soccmai&quot;&gt; &lt;div class=&quot;glitch-bloc&quot;&gt; &lt;p class=&quot;invisible-text&quot;&gt;{ soccmai }&lt;/p&gt; &lt;p class=&quot;glitchedAnim&quot;&gt;{ soccmai }&lt;/p&gt; &lt;p class=&quot;glitchedAnim&quot;&gt;{ soccmai }&lt;/p&gt; &lt;p class=&quot;glitchedAnim&quot;&gt;{ soccmai }&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;underLogo&quot;&gt; &lt;h2&gt;Web Developer | Graphic Designer&lt;/h2&gt; &lt;/div&gt; &lt;/header&gt; &lt;nav&gt; &lt;ul&gt; &lt;li&gt;&lt;a href='#home' id=&quot;li-home&quot;&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href='#about-me'&gt;About Me&lt;/a&gt;&lt;/li&gt; &lt;li&gt;Projects&lt;/li&gt; &lt;li&gt;Skills&lt;/li&gt; &lt;li&gt;Contact&lt;/li&gt; &lt;/ul&gt; &lt;/nav&gt; </code></pre> <p>I tried adding addClass, removeClass, or classList.add, classList.remove, but it doesn't change anything</p>
[ { "answer_id": 74266179, "author": "peter861222", "author_id": 17918739, "author_profile": "https://Stackoverflow.com/users/17918739", "pm_score": 2, "selected": false, "text": "#Select earlist date for decision d by idPerson\ndf_d <- df%>%\n filter(decision==\"d\")%>%\n group_by(idPer...
2022/10/31
[ "https://Stackoverflow.com/questions/74265785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20353720/" ]
74,265,811
<p>I have an annotation table from eggnog mapper and need to make this KO table:</p> <pre><code>Gene evalue KO Gene1 0.00003 KO0000 Gene2 0.00005 KO0001 Gene2 0.00005 KO0003 Gene3 0.000005 KO0002 </code></pre> <p>This is the table I have (test.txt):</p> <pre><code>Gene evalue KO Gene1 0.00003 KO0000 Gene2 0.00005 KO0001,KO0003 Gene3 0.000005 KO0002 </code></pre> <p>I have ~17,000 rows and the output is in xlsx format. The first issue I am having is that when I save the output file as a txt and view in linux (<code>head test.txt</code>) some of the columns look like this:</p> <pre><code>Gene,evalue,KO Gene1 0.00003 KO0000 Gene2 0.0005 &quot;KO0001,KO0003&quot; Gene3 0.00005 KO0002 </code></pre> <p>How can I remove the quotes around these values? And how can I make the annotation table above?</p> <p>I have tried this script from this thread (<a href="https://stackoverflow.com/questions/57705187/how-can-i-split-comma-separated-values-into-multiple-rows">How can I split comma separated values into multiple rows?</a>)</p> <pre><code>awk '
BEGIN { OFS=&quot;\t&quot; } { $1=$1;t=$0; } { while(index($0,&quot;,&quot;)) { gsub(/,[[:alnum:],]*/,&quot;&quot;); print; $0=t; gsub(OFS &quot;[[:alnum:]]*,&quot;,OFS); t=$0; } print t }' file </code></pre> <p>But it seems to get stuck in an infinite loop because of the quotes around the values in the third column.</p> <p>Thanks</p>
[ { "answer_id": 74267750, "author": "j_b", "author_id": 16482938, "author_profile": "https://Stackoverflow.com/users/16482938", "pm_score": 2, "selected": true, "text": "awk" }, { "answer_id": 74269885, "author": "The fourth bird", "author_id": 5424988, "author_profile...
2022/10/31
[ "https://Stackoverflow.com/questions/74265811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17665505/" ]
74,265,817
<p>I am a newbie in fetching data from APIs</p> <p>I have an api endpoint containing two query params and also having a body of string and int. I want to make an already existing post to be featured on the home page with time limit.</p> <p>in my repo I have written this</p> <pre><code> class FeaturePost { Future featurePost(int duration, String period) async { SharedPreferences preferences = await SharedPreferences.getInstance(); var token = preferences.getString('token').toString(); final queryParameters = { 'postpId': 'postId', 'id': 'id', }; http.post(Uri.dataFromString(&quot;https/url.com/api/v1/post?&quot; parameters: queryParameters), headers: { 'Content-Type': 'application/json', 'x-access-token': token, }, body: { &quot;duration&quot;: duration, &quot;period&quot;: period }); </code></pre> <p>here's my button</p> <pre><code> GestureDetector( onTap: () async { setState(() { period = &quot;${dropdownValue}&quot;; }); if (_postKey .currentState! .validate()) { var create = PostModel( postId: widget.postId, id: widget.userId, period: period, duration: int.parse( durationController .text), ); createPost .newPostDuration( create, widget.postId, ); } }, child: Center( child: Text('Make Post Featured',), ), ) </code></pre> <p>my controller</p> <pre><code>class FeaturePostController extends GetxController { final featureAPostRepo = FeaturePost(); Future&lt;dynamic&gt; newFeaturedPost(ostpId, id) async { try { final result = await featureAnAdRepo.featureAnAd(postId, id); Get.back(); await fromFeaturedAds.fetchFeaturedAds(); // Get.snackBar('Success', 'Post Featured Successfully'); print(result); return result; } catch (e) { throw Exception(e); } } } </code></pre> <p>this is the response i get Unhandled Exception: Null check operator used on a null value.</p>
[ { "answer_id": 74267750, "author": "j_b", "author_id": 16482938, "author_profile": "https://Stackoverflow.com/users/16482938", "pm_score": 2, "selected": true, "text": "awk" }, { "answer_id": 74269885, "author": "The fourth bird", "author_id": 5424988, "author_profile...
2022/10/31
[ "https://Stackoverflow.com/questions/74265817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10947448/" ]
74,265,826
<p>im trying to write code in python that basically its so that in the terminal you input whether you want to signup or log in if you already signed up i cant really figure out how to make it so that the signup input gets stored in a dictionary and then later when you try to enter the username and password it makes sure its the same one from the signup feature thanks in advance</p> <p>so far ive tried</p> <pre><code>accounts = {&quot;user&quot;:&quot;password&quot;, &quot;user2&quot;:&quot;password2&quot;} login_or_signup = input(&quot;Login or signup? &quot;) if login_or_signup.upper() == 'LOGIN': username = input(&quot;Enter your username: &quot;) if username in list(accounts.keys()): password = input(&quot;Enter your password: &quot;) if password in list(accounts.values()): print(&quot;Logged in successfully.&quot;) else: print(&quot;Account credentials do not match.&quot;) else: print(&quot;Account not found.&quot;) elif login_or_signup.upper() == &quot;SIGNUP&quot;: username = input(&quot;Enter your username: &quot;) password = input(&quot;Enter your password: &quot;) accounts.update({user,password}) </code></pre> <p>but im getting an error</p>
[ { "answer_id": 74267750, "author": "j_b", "author_id": 16482938, "author_profile": "https://Stackoverflow.com/users/16482938", "pm_score": 2, "selected": true, "text": "awk" }, { "answer_id": 74269885, "author": "The fourth bird", "author_id": 5424988, "author_profile...
2022/10/31
[ "https://Stackoverflow.com/questions/74265826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20380720/" ]
74,265,839
<p>I need to find an element and replace the <code>.textContent</code> of it within a constantly changing table. I'm fairly new to coding, but I've come across an issue when trying to replace certain elements' <code>.textContent</code>.</p> <p>I have a table on my website that shuffles the values upon every new session. I would like to have certain values within that table to be replaced.</p> <pre><code>&lt;table class = &quot;tb&quot;&gt; &lt;tr&gt; &lt;td&gt;Element 1&lt;/td&gt; &lt;td&gt;Element 2&lt;/td&gt; &lt;td&gt;Element 3&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>And upon each new session, the order of each element is changed.</p> <p>I want to first find &quot;Element 2&quot; and change it to &quot;Element 2.1&quot;, but I cannot do it with my current script because it just changes the 2nd row of the table rather than what I am looking for. So upon reshuffling, it might change Element 1 to the replacement value instead.</p> <p>I have a very simple script to swap out elements.</p> <pre><code>const Tableswap = () =&gt; { const findele = document.querySelectorAll(&quot;.tb&quot;)[1]; if (findele === null){ return; }; findele.textContent = &quot;Element 2.1&quot;; }; </code></pre> <p>I've tried the following to find the particular element that I am looking for, but I am not sure where to go from here:</p> <pre><code>//find the required element function contains(selector, text) { var elements = document.querySelectorAll(selector); return Array.prototype.filter.call(elements, function(element){ return RegExp(text).test(element.textContent); }); } const finder = contains('.tb', &quot;Element 2&quot;); if (finder === null){ return; }; finder.tb.textContent = &quot;Element 2.1&quot;; </code></pre> <p>I am honestly not sure if I even went in the right direction with all of this, and I am a complete newbie when it comes to all of this, I've basically been scavenging bits of code from everywhere and trying to understand what I'm doing along the way. I would prefer everything to be in JS, as I have absolutely no experience with JQuery and have no clue what it even is.</p>
[ { "answer_id": 74266182, "author": "Robert Bradley", "author_id": 20206840, "author_profile": "https://Stackoverflow.com/users/20206840", "pm_score": 0, "selected": false, "text": "<td id=\"myID\">" }, { "answer_id": 74267266, "author": "Kitswas", "author_id": 8659747, ...
2022/10/31
[ "https://Stackoverflow.com/questions/74265839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20380676/" ]
74,265,842
<p>I have a situation where 3 or 4 people are trying to write in a text file at the exact same time. I would like allow only 1 user at the time writing to the file.</p> <p>I tried:</p> <pre><code>Dim FNum As Integer FNum = FreeFile() Open &quot;\\SHARE\Logs\File.log&quot; For Append As FNum Print #FNum, Now() &amp; &quot;&gt; The user &quot; &amp; GetUserName() &amp; &quot; wrote something.&quot; Close #FNum </code></pre> <p>And it prevents many conflicts but not all.</p> <p>In my File.log, I notice that there ware some writes at the same time:</p> <pre><code>2022-10-31 11:35:22 &gt; The user USER1 wrote something. omething. 2022-10-31 11:35:23 &gt; The user USER2 wrote something. 2022-10-31 11:35:27 &gt; The user USER3 wrote something. 2022-10-31 11:36:02 &gt; The user USER4 wrote something. R6 wrote something. 2022-10-31 11:36:11 &gt; The user USER7 wrote something. </code></pre> <p>Conflicts lines below are incompletes (only some characters from the end of the line are written).</p> <p>Is there a way to prevent this from happening? I want the first user to access the file to be allowed to write to it and the others should get an error trying to write to the file until the first user finishes his write.</p> <p>Thank you!</p> <p>I thought that opening the file would lock it until the write was over but apparently users over network are not aware that the file was already open.</p>
[ { "answer_id": 74266328, "author": "Erik A", "author_id": 7296893, "author_profile": "https://Stackoverflow.com/users/7296893", "pm_score": 3, "selected": true, "text": "FNum = FreeFile()\nOpen \"\\\\SHARE\\Logs\\File.log\" For Append Lock Write As FNum\n Print #FNum, Now() & \"> The u...
2022/10/31
[ "https://Stackoverflow.com/questions/74265842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20284337/" ]
74,265,857
<p>I want to check if a string exists in a csv file.</p> <p>I'm trying to use <code>if ($PCname -in $logFileLocation) { write-output &quot;true&quot; } else { write-output &quot;false&quot; }</code></p> <p>However this always returns false.</p> <p>How can I check for a value within a csv file?</p>
[ { "answer_id": 74266328, "author": "Erik A", "author_id": 7296893, "author_profile": "https://Stackoverflow.com/users/7296893", "pm_score": 3, "selected": true, "text": "FNum = FreeFile()\nOpen \"\\\\SHARE\\Logs\\File.log\" For Append Lock Write As FNum\n Print #FNum, Now() & \"> The u...
2022/10/31
[ "https://Stackoverflow.com/questions/74265857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11306461/" ]
74,265,889
<p>I have a login page and the backend and frontend are ready all data to connect together, but my problem is: I wanna click on login button and then redirect to another page! i know how i have to redirect to another page with useNavigate, but the main problem is: if username and password is correct, then has to be link to another page! not automatically connecting when button onclick is!</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"&gt;&lt;/script&gt; &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"&gt;&lt;/script&gt; import React, {useState} from "react"; import {NavLink, useNavigate} from "react-router-dom"; import axios from "axios"; import "./LoginPage.css" export default function LoginPage() { const [username, setUsername] = useState("") const [password, setPassword] = useState("") const [me, setMe] = useState("") const navigate = useNavigate(); function handleLogin(){ axios.get("api/user/login",{auth: {username, password}}) .then(response =&gt; response.data) .then((data) =&gt; setMe(data)) .then(() =&gt; setUsername("")) .then(() =&gt; setPassword("")) .catch(() =&gt; alert("Sorry, Username or Password is wrong or Empty!")) } function handleLogout(){ axios.get("api/user/logout") .then(() =&gt; setMe("")) } return ( &lt;div className={"login-main"}&gt; &lt;NavLink to={"/question"}&gt;zur Question Page&lt;/NavLink&gt; &lt;h1&gt;Login Page&lt;/h1&gt; &lt;h3&gt;Login&lt;/h3&gt; &lt;input placeholder={"Username ..."} value={username} onChange={event =&gt; setUsername(event.target.value)}/&gt; &lt;input placeholder={"Password ..."} type={"password"} value={password} onChange={event =&gt; setPassword(event.target.value)}/&gt; &lt;button onClick={() =&gt; { handleLogin(); {navigate("/question")} }}&gt;Login&lt;/button&gt; } &lt;/div&gt; ) }</code></pre> </div> </div> </p> <p>!</p>
[ { "answer_id": 74266328, "author": "Erik A", "author_id": 7296893, "author_profile": "https://Stackoverflow.com/users/7296893", "pm_score": 3, "selected": true, "text": "FNum = FreeFile()\nOpen \"\\\\SHARE\\Logs\\File.log\" For Append Lock Write As FNum\n Print #FNum, Now() & \"> The u...
2022/10/31
[ "https://Stackoverflow.com/questions/74265889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15090238/" ]
74,265,890
<p>I'm intermittently getting out-of-memory issues on the dataflow job when inserting the data into Bigauqery using Apache Beam SDK for Java 2.29.0.</p> <p>Here is the stack trace</p> <pre><code> Error message from worker: java.lang.RuntimeException: java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached org.apache.beam.sdk.io.gcp.bigquery.BigQueryServicesImpl$DatasetServiceImpl.insertAll(BigQueryServicesImpl.java:982) org.apache.beam.sdk.io.gcp.bigquery.BigQueryServicesImpl$DatasetServiceImpl.insertAll(BigQueryServicesImpl.java:1022) org.apache.beam.sdk.io.gcp.bigquery.BatchedStreamingWrite.flushRows(BatchedStreamingWrite.java:375) org.apache.beam.sdk.io.gcp.bigquery.BatchedStreamingWrite.access$800(BatchedStreamingWrite.java:69) org.apache.beam.sdk.io.gcp.bigquery.BatchedStreamingWrite$BatchAndInsertElements.finishBundle(BatchedStreamingWrite.java:271) Caused by: java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached java.base/java.lang.Thread.start0(Native Method) java.base/java.lang.Thread.start(Thread.java:803) java.base/java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:937) java.base/java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1343) java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:129) java.base/java.util.concurrent.Executors$DelegatedExecutorService.submit(Executors.java:724) com.google.api.client.http.javanet.NetHttpRequest.writeContentToOutputStream(NetHttpRequest.java:188) com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:117) com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:84) com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1012) com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:514) com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:455) com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:565) org.apache.beam.sdk.io.gcp.bigquery.BigQueryServicesImpl$DatasetServiceImpl.lambda$insertAll$1(BigQueryServicesImpl.java:906) org.apache.beam.sdk.io.gcp.bigquery.BigQueryServicesImpl$BoundedExecutorService$SemaphoreCallable.call(BigQueryServicesImpl.java:1492) java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) java.base/java.lang.Thread.run(Thread.java:834) </code></pre> <p>I tried increasing the worker node size still seeing the same issue.</p>
[ { "answer_id": 74266436, "author": "Jeff Klukas", "author_id": 1260237, "author_profile": "https://Stackoverflow.com/users/1260237", "pm_score": 0, "selected": false, "text": "OutOfMemory" }, { "answer_id": 74267709, "author": "Mazlum Tosun", "author_id": 9261558, "au...
2022/10/31
[ "https://Stackoverflow.com/questions/74265890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4187091/" ]
74,265,938
<p>I have a hard time figuring out a huge performance issue with a component list via <code>v-for</code>.</p> <p><strong><strong>Here is my typescript code:</strong></strong></p> <pre class="lang-js prettyprint-override"><code>&lt;template&gt; &lt;template v-for=&quot;item in list&quot; :key=&quot;item.id&quot;&gt; &lt;TestComponent @mouseenter=&quot;hoveredItem = item&quot; @mouseleave=&quot;hoveredItem = null&quot; /&gt; &lt;/template&gt; &lt;div v-if=&quot;hoveredItem&quot;&gt;hovered&lt;/div&gt; &lt;/template&gt; &lt;script lang=&quot;ts&quot;&gt; import TestComponent from 'TestComponent.vue'; import { Options, Vue } from 'vue-class-component'; interface IItem {id:number, message:string}; @Options({ props:{}, components:{ TestComponent, } }) export default class TestView extends Vue { public list:IItem[] = []; public hoveredItem:IItem|null = null; public mounted():void { for (let i = 0; i &lt; 3; i++) { this.list.push({ id:i, message:&quot;Message &quot;+(i+1), }); } } } &lt;/script&gt; </code></pre> <p>When I roll over an item <em>(see @ mouseeenter)</em>, a <code>render()</code> is triggered on <strong>all</strong> the items of the list which shouldn't be necessary. I checked with <code>Vue Devtools</code> extension that shows these events for every single item of the list :</p> <ul> <li>render start</li> <li>render end</li> <li>patch start</li> <li>patch end</li> </ul> <p>If i remove the following line, no render/patch is triggered:</p> <pre class="lang-js prettyprint-override"><code>&lt;div v-if=&quot;hoveredItem&quot;&gt;hovered!&lt;/div&gt; </code></pre> <p>If instead of storing the item instance to <code>hoveredItem</code> i just raise a flag to display that div, i don't have the issue.</p> <p>If instead of instantiating the <code>&lt;TestComponent&gt;</code> I use a simple <code>&lt;div&gt;</code> i don't have the issue.</p> <p>If I don't use a <code>v-for</code> but manually instantiate items, I don't have the issue.</p> <p>If I $emit a custom event from the instead of using native @mouseover</p> <p>The <code>&lt;TestComponent&gt;</code> is just that:</p> <pre class="lang-html prettyprint-override"><code>&lt;template&gt; &lt;div&gt;item&lt;/div&gt; &lt;/template&gt; </code></pre> <p>Here is a codesandbox showing the issue of the first example and the fix via an $emit() from the child component <a href="https://dh5ldo.csb.app" rel="nofollow noreferrer">https://dh5ldo.csb.app</a></p> <p>Do you have any hint on why the first example triggers a render on all the list items when it's not something we would expect ?</p> <p>Thank you for reading me :)</p>
[ { "answer_id": 74266654, "author": "Dimava", "author_id": 5734961, "author_profile": "https://Stackoverflow.com/users/5734961", "pm_score": -1, "selected": false, "text": ":key=\"item.id\"" }, { "answer_id": 74270334, "author": "Durss", "author_id": 3813220, "author_p...
2022/10/31
[ "https://Stackoverflow.com/questions/74265938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3813220/" ]
74,265,949
<p>I refer to the following <a href="https://stackoverflow.com/questions/59051127/model-start-and-end-values-for-schedule-as-a-variable">SOW post</a> and the answer of Stuart Rossiter.</p> <p>I thought it was right to open a new thread about this, as the problem can be looked at a little differently after all these years. Now I get the following error: &quot;The method create_ShiftChange(double, TimeUnits) in the Main type is not applicable for the arguments (int, Integer).&quot;</p> <p>As I noted in my comment from Stuart Rossiter's solution, I believe the function <code>create_ShiftChange(...)</code> had different input arguments a few years ago.</p> <p>The cast from <code>getTimeoutToNextValue()</code> to <code>double</code> is not a problem. However, the cast of the second argument <code>getNextValue()</code> from <code>Integer</code> to <code>TimeUnits</code> presents me with a challenge.</p> <p>Does anyone have a solution for my problem or do I have to look for a detour, since the &quot;old&quot; <code>create_ShiftChange(...)</code> also has a different meaning due to the other input arguments? Thanks for the help!</p>
[ { "answer_id": 74272243, "author": "Benjamin", "author_id": 2164728, "author_profile": "https://Stackoverflow.com/users/2164728", "pm_score": 1, "selected": false, "text": "TimeUnits." }, { "answer_id": 74295235, "author": "Stuart Rossiter", "author_id": 185055, "auth...
2022/10/31
[ "https://Stackoverflow.com/questions/74265949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19247020/" ]
74,265,952
<p>I have a plot with an numeric x axis. The values are years. I want to modify the labels so that the first year is displayed in full, the subsequent instances are abbreviated. With this in mind, I wrote a function which replaces the first two digits. It works when applying it to a vector, however, not when using it in ggplot. Any idea what I am missing? Many thanks.</p> <p>PS I am aware of the scales package and its related functions for date/time scales. I have also seen this SO <a href="https://stackoverflow.com/questions/67232664/modify-all-but-last-element-of-y-axis-label">question</a>.</p> <pre class="lang-r prettyprint-override"><code>library(tidyverse) seq_year &lt;- seq(1970, 2010, 10) values &lt;- seq(10, 50, 10) df &lt;- tibble(seq_year, values) df %&gt;% ggplot() + geom_bar(aes(x = seq_year, y=values), stat=&quot;identity&quot;)+ scale_x_continuous(label=function(x) str_replace(x, regex(&quot;\\d{2}&quot;), &quot;'&quot;)) </code></pre> <p><img src="https://i.imgur.com/Mc9tnrO.png" alt="" /></p> <pre class="lang-r prettyprint-override"><code> fn_year_label &lt;- function(x){ y &lt;- str_replace(x[2:length(x)], regex(&quot;^\\d{2}&quot;), &quot;'&quot;) z &lt;- c(x[1],y) return(z) } #These are the axis labels I want to have. fn_year_label(seq_year) #&gt; [1] &quot;1970&quot; &quot;'80&quot; &quot;'90&quot; &quot;'00&quot; &quot;'10&quot; #But the plot doesn't show them df %&gt;% ggplot() + geom_bar(aes(x = seq_year, y=values), stat=&quot;identity&quot;)+ scale_x_continuous(label=fn_year_label) </code></pre> <p><img src="https://i.imgur.com/68ldHf6.png" alt="" /></p> <p><sup>Created on 2022-10-31 with <a href="https://reprex.tidyverse.org" rel="nofollow noreferrer">reprex v2.0.2</a></sup></p>
[ { "answer_id": 74266080, "author": "Limey", "author_id": 13434871, "author_profile": "https://Stackoverflow.com/users/13434871", "pm_score": 3, "selected": true, "text": " label=function(x) {\n print(x)\n x\n }\n" }, { "answer_id": 74266260, "author": "Jul...
2022/10/31
[ "https://Stackoverflow.com/questions/74265952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2221566/" ]
74,265,996
<p>I am working on a project where i try to implement a search function. My first step is to make sure that all input is set to lower case to make SQL calls easier. However i have stumbled upon a problem that i am struggling to fix. I do not know how to do a document.getElementById('') in react typescript. I am quite new to these languages and have tried the solutions found here (<a href="https://stackoverflow.com/questions/57326731/how-to-do-something-like-document-getelementbyid-value-in-typescript">How to do something like document.getElementById().value in typescript?</a>) but this does not seem to get the data stored in my element.</p> <p><strong>So im wondering how can i get the input in the searchbar into the variable defaultText.</strong></p> <p>here is the element that i want to grab</p> <pre><code>&lt;Row&gt;&lt;input type=&quot;search&quot; id=&quot;form1&quot; onChange={this.input} placeholder=&quot;Søk etter oppskrift..&quot;/&gt;&lt;/Row&gt; </code></pre> <p>here is the function which i attempt to set the input to lower case</p> <pre><code> input(){ const defaultText:string = (document.getElementById('form1') as HTMLInputElement).value; console.log (defaultText); // To convert Lower Case let lowerCaseText = defaultText.toLowerCase(); console.log(lowerCaseText); } </code></pre> <p>The outcome from both 'console.log' is simply an empty row</p>
[ { "answer_id": 74266126, "author": "Dulaj Ariyaratne", "author_id": 13368318, "author_profile": "https://Stackoverflow.com/users/13368318", "pm_score": 2, "selected": false, "text": "onChange" }, { "answer_id": 74266146, "author": "Harrison", "author_id": 15291770, "a...
2022/10/31
[ "https://Stackoverflow.com/questions/74265996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20380774/" ]
74,266,002
<p>I am getting a read access violation and I cant understand why. I though I allocated everything correctly and I shouldn't be reading past the end of anything? Any ideas or help is greatly appreciated.</p> <p>I am trying to read in a file that has a single integer per line and store those into a binary tree and linked list. The tree actually holds the data and the linked list just holds pointers to the nodes in the tree.</p> <p>The error happens in the <code>insert()</code> function when data and <code>node-&gt;num</code> are being compared.</p> <p>The <code>newNode()</code> function creates both a tree node and a linked list node, it only returns the tree node because of the double pointer handling the linked list.</p> <pre><code>// Garrett Manley // delete these when turning it in #pragma warning(disable : 4996) #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; // define structs struct treeNode { int num; struct treeNode *right, *left; }; struct listNode { struct treeNode *tNode; // data is a pointer to the tree struct listNode *next; }; // creates and returns a new node with given data, also adds node to linked list struct treeNode *newNode(int data, struct listNode *(*list)) { // make tree node struct treeNode *node = malloc(sizeof(struct treeNode)); node-&gt;num = data; node-&gt;left = NULL; node-&gt;right = NULL; // make list node // insert entry into linked list struct listNode *newNode; newNode = malloc(sizeof(struct listNode)); newNode-&gt;tNode = node; newNode-&gt;next = *list; *list = newNode; return (node); } // inserts given node into the tree in sorted order struct treeNode *insert(struct treeNode *node, int data, struct listNode *(*list)) { if (node == NULL) { // if the tree is empty return new node return (newNode(data, list)); } else { // if there is a node use recursion to get to the bottom of the tree and add a node in the right spot if (data &lt;= node-&gt;num) { node-&gt;left = insert(node-&gt;left, data, list); } else { node-&gt;right = insert(node-&gt;right, data, list); } return (node); // return the (unchanged) node pointer } } // print linked list by looping through list, keep looping until node.next == null // while looping print like this node.data.data to get the tree nodes data void printList(struct listNode *(*list)) { struct listNode *tmp = *list; while (tmp-&gt;next != NULL) { tmp = tmp-&gt;next; printf(&quot;here&quot;); } } // skim through the file and find how many entries there are int SCAN(FILE (*stream)) { int size = 0; char *str = malloc(100 * sizeof(char)); while (fgets(str, 100, stream) != NULL) { size++; } return size; } // loop through the file and load the entries into the main data array void LOAD(FILE *stream, int size, struct treeNode *(*tree), struct listNode *(*list)) { rewind(stream); int i; char *tmp = malloc(100 * sizeof(char)); for (i = 0; i &lt; size; i++) { fgets(tmp, 100, stream); // recursively call insert to create the list, fix *tree = insert(*tree, atol(tmp), list); } } // free up everything void FREE(struct treeNode *BlackBox, int size) { // free linked list first // then free the tree nodes, do this recursively } int main(int argv, char *argc[]) { FILE *file = fopen(&quot;./hw7.data&quot;, &quot;r&quot;); int size = SCAN(file); struct treeNode *tree = malloc(size * sizeof(struct treeNode)); struct listNode *list = malloc(size * sizeof(struct listNode)); LOAD(file, size, &amp;tree, &amp;list); // print output // print linked list //printList(list); fclose(file); return 0; } </code></pre>
[ { "answer_id": 74266557, "author": "chqrlie", "author_id": 4593267, "author_profile": "https://Stackoverflow.com/users/4593267", "pm_score": 1, "selected": false, "text": "main" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74266002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19997017/" ]
74,266,004
<p>Good afternoon,</p> <p>I'm trying to execute this query with Laravel:</p> <pre><code>SELECT COUNT(id) as total, (SUM(score) / COUNT(id)) as average, (SELECT COUNT(id) FROM rates Where book_id = :book_id AND score &gt;= 1 AND score &lt; 2) as count_1, (SELECT COUNT(id) FROM rates Where book_id = :book_id AND score &gt;= 2 AND score &lt; 3) as count_2, (SELECT COUNT(id) FROM rates Where book_id = :book_id AND score &gt;= 3 AND score &lt; 4) as count_3, (SELECT COUNT(id) FROM rates Where book_id = :book_id AND score &gt;= 4 AND score &lt; 5) as count_4, (SELECT COUNT(id) FROM rates Where book_id = :book_id AND score = 5) as count_5 FROM rates WHERE book_id = :book_id; </code></pre> <p>I have been looking for Away in Laravel to execute subqueries in the Select Statement. My last intent it has been with:</p> <pre><code> return DB::table('rates') -&gt;selectRaw([ DB::raw('COUNT(id) as total'), DB::raw('(SUM(score) / COUNT(id)) as average'), '(' . DB::raw(DB::table('rates')-&gt;select(DB::raw('COUNT(id) as count_1'))-&gt;where('book_id', $bookId)-&gt;where('score', '&gt;=', 1)-&gt;where('score', '&lt;', 2)-&gt;toSql()) . ')', '(' . DB::raw(DB::table('rates')-&gt;select(DB::raw('COUNT(id) as count_2'))-&gt;where('book_id', $bookId)-&gt;where('score', '&gt;=', 2)-&gt;where('score', '&lt;', 3)-&gt;toSql()) . ')', '(' . DB::raw(DB::table('rates')-&gt;select(DB::raw('COUNT(id) as count_3'))-&gt;where('book_id', $bookId)-&gt;where('score', '&gt;=', 3)-&gt;where('score', '&lt;', 4)-&gt;toSql()) . ')', '(' . DB::raw(DB::table('rates')-&gt;select(DB::raw('COUNT(id) as count_4'))-&gt;where('book_id', $bookId)-&gt;where('score', '&gt;=', 4)-&gt;where('score', '&lt;', 5)-&gt;toSql()) . ')', '(' . DB::raw(DB::table('rates')-&gt;select(DB::raw('COUNT(id) as count_5'))-&gt;where('book_id', $bookId)-&gt;where('score', 5)-&gt;toSql()) . ')' ]) -&gt;where('book_id', $bookId)-&gt;get(); </code></pre> <p>But I get errors from Laravel.</p> <p>Do you know how to execute a MySQL query with subqueries in the select statement, using the Query BUilder of Laravel?</p> <p>(And of course, I have been searching for 1 hour how to do and did not find any good answer on internet and Stack Overflow).</p>
[ { "answer_id": 74266289, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 1, "selected": false, "text": "SELECT COUNT(id) as total, \n (SUM(score) / COUNT(id)) as average,\n COUNT(CASE WHEN score >= 1 AND score < 2 THEN...
2022/10/31
[ "https://Stackoverflow.com/questions/74266004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1888372/" ]
74,266,005
<pre><code>interface I1 { x: number; y: string; } interface I2 { x?: number; y?: string; } const tmp1: Partial&lt;I1&gt; = {}, tmp2: I2 = {}; </code></pre> <p>Just like the example, is there an obvious difference between these two things?</p>
[ { "answer_id": 74267335, "author": "VLAZ", "author_id": 3689450, "author_profile": "https://Stackoverflow.com/users/3689450", "pm_score": 3, "selected": true, "text": "tmp1" }, { "answer_id": 74268921, "author": "Dakeyras", "author_id": 1857909, "author_profile": "htt...
2022/10/31
[ "https://Stackoverflow.com/questions/74266005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16136765/" ]
74,266,013
<p>I am working on an Angular 13 application that allows internationalization. When changing the culture, all static resources will instantly be translated, but I need to trigger the reloading of some data because translation is provided by an API.</p> <p>My code looks like the following.</p> <p>When the user is changing the current culture, it is stored in the database. This is done using an effect.</p> <pre class="lang-js prettyprint-override"><code>public languageChange(value: TranslationLanguage): void { this.store.dispatch(UpdatePreferredCultureRequestedAction({ value: value.cultureName })); this.translate.use(value.cultureName); } updatePreferredCulture$ = createEffect(() =&gt; this.actions$.pipe( ofType(UpdatePreferredCultureRequestedAction), concatMap(action =&gt; { return this.layoutInfoService.updatePreferredCulture(action.value).pipe( catchError(err =&gt; { this.validation.handleAndDisplayError(err); return of(Constants.defaultCultureName); }) ); }), switchMap((culture: string) =&gt; { return [UpdatePreferredCultureLoadedAction({ value: culture }), QuestionnaireListRequestedAction() // this forces the reloading of some translation-sensitive information ]; })) ); </code></pre> <p>This only contains only one of the actions that need to be triggered when the translation is changed.</p> <p>This does the job, but I am not happy with the solution:</p> <ol> <li>This seems to be an anti-pattern since <a href="https://github.com/timdeschryver/eslint-plugin-ngrx/blob/main/docs/rules/no-multiple-actions-in-effects.md" rel="nofollow noreferrer">I am returning more than one action from the effect</a> (not sure why is that, though)</li> <li>Translation effect is somewhat coupled to lots of business-specific actions</li> <li>Whenever an action to request translatable information is developed, the request action must be included here</li> </ol> <p>Is there a better way to implement effects being triggered when translation culture is changed?</p>
[ { "answer_id": 74268081, "author": "timdeschryver", "author_id": 10112124, "author_profile": "https://Stackoverflow.com/users/10112124", "pm_score": 2, "selected": false, "text": "UpdatePreferredCultureLoadedAction" }, { "answer_id": 74272839, "author": "Alexei - check Codida...
2022/10/31
[ "https://Stackoverflow.com/questions/74266013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2780791/" ]
74,266,024
<p>I'm trying to complete this assignment asking user for a number and if it's not -1 then it should loop. if it's -1 then to calculate the average of the other numbers. I'm getting stuck with the actual loop - it endlessly keeps printing the message to user to enter a different number - as in the picture - and doesn't give user a chance to enter a different number. Please help, I've been through so many videos and blogs and can't figure out what's actually wrong.</p> <pre><code>#creating a list for later calculations: wrong = [] #asking for input: input(&quot;Hi, We're gonna play a guessing game. When asked enter a number between -10 and 10.\nIf not correct you'll have to guess again ^-^&quot;) num =int(input(&quot;number:&quot;)) #looping while num != -abs(1): wrong.append(num) print(&quot;Nope, guess again:&quot;) if num == -abs(1): break av = sum(wrong) / len(wrong) print (&quot;You got it! The average of your wrong answers is: &quot;) print(av) print(&quot;The End&quot;) print(&quot;Nope, guess again:&quot;) </code></pre>
[ { "answer_id": 74266106, "author": "Kkameleon", "author_id": 12094184, "author_profile": "https://Stackoverflow.com/users/12094184", "pm_score": 1, "selected": false, "text": "input" }, { "answer_id": 74266134, "author": "hassan abbas", "author_id": 20341562, "author_...
2022/10/31
[ "https://Stackoverflow.com/questions/74266024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20380861/" ]
74,266,026
<p>I have the following DataFrame (Date in dd-mm-yyyy format):</p> <pre><code>import pandas as pd data={'Id':['A', 'B', 'C', 'A', 'B', 'C', 'B', 'C', 'A', 'C', 'B', 'C', 'B', 'C', 'A', 'B', 'C', 'A', 'B', 'C'], 'Date':['20-10-2022', '20-10-2022', '20-10-2022', '21-10-2022', '21-10-2022', '21-10-2022', '22-10-2022', '22-10-2022', '23-10-2022', '23-10-2022', '24-10-2022', '24-10-2022', '25-10-2022', '25-10-2022', '26-10-2022', '26-10-2022', '26-10-2022', '27-10-2022', '27-10-2022', '27-10-2022']} df=pd.DataFrame.from_dict(data) df Id Date 0 A 20-10-2022 1 B 20-10-2022 2 C 20-10-2022 3 A 21-10-2022 4 B 21-10-2022 5 C 21-10-2022 6 B 22-10-2022 7 C 22-10-2022 8 A 23-10-2022 9 C 23-10-2022 10 B 24-10-2022 11 C 24-10-2022 12 B 25-10-2022 13 C 25-10-2022 14 A 26-10-2022 15 B 26-10-2022 16 C 26-10-2022 17 A 27-10-2022 18 B 27-10-2022 19 C 27-10-2022 </code></pre> <p>This is the Final DataFrame that I want:</p> <p><a href="https://i.stack.imgur.com/V7NuM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V7NuM.png" alt="Final DataFrame that I want" /></a></p> <p>I have tried the following code:</p> <pre><code># Find first occurance and last occurance of any given Id. df_first_duplicate = df.drop_duplicates(subset=['Id'], keep='first') df_first_duplicate.rename(columns = {'Date':'DateOfFirstOccurance'}, inplace = True) df_first_duplicate.reset_index(inplace = True, drop = True) df_last_duplicate = df.drop_duplicates(subset=['Id'], keep='last') df_last_duplicate.rename(columns = {'Date':'DateOfLastOccurance'}, inplace = True) df_last_duplicate.reset_index(inplace = True, drop = True) # Merge the above two df's on key df_merged = pd.merge(df_first_duplicate, df_last_duplicate, on='Id') df_merged </code></pre> <p>But this is the output that I get:</p> <pre><code> Id DateOfFirstOccurance DateOfLastOccurance 0 A 20-10-2022 27-10-2022 1 B 20-10-2022 27-10-2022 2 C 20-10-2022 27-10-2022 </code></pre> <p>What should I do to get the desired output?</p>
[ { "answer_id": 74266106, "author": "Kkameleon", "author_id": 12094184, "author_profile": "https://Stackoverflow.com/users/12094184", "pm_score": 1, "selected": false, "text": "input" }, { "answer_id": 74266134, "author": "hassan abbas", "author_id": 20341562, "author_...
2022/10/31
[ "https://Stackoverflow.com/questions/74266026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5944235/" ]
74,266,046
<p><strong>Hi, everybody! I try to find best solution with assignment in title. But I don't understand how I can output way of calculation. I write python program, it can output random massive and max sum, but I need way too.</strong></p> <pre><code>from collections import deque as queue import random import numpy as np array=[] def creatArray(): r = 0 x = 5 y = 5 global array for i in range(x): array.append([]) for j in range(y): array[i].append(random.randint(0,100)) r += 1 return array creatArray() ROW = 5 COL = 5 # Check whether given cell (row, col) # is a valid cell or not. def isValid(p): # Return true if row number and column number # is in range return (p[0] &gt;= 0) and (p[1] &lt; COL) # Function to find maximum cost to reach # top right corner from bottom left corner def find_max_cost(mat): max_val = [[0 for i in range(COL)] for i in range(ROW)] max_val[ROW - 1][0] = mat[ROW - 1][0] # Starting po src = [ROW - 1, 0] # Create a queue for traversal q = queue() q.appendleft(src) # Enqueue source cell # Do a BFS starting from source cell # on the allowed direction while (len(q) &gt; 0): curr = q.pop() # Find up point up = [curr[0] - 1, curr[1]] # if adjacent cell is valid, enqueue it. if (isValid(up)): max_val[up[0]][up[1]] = max(max_val[up[0]][up[1]], mat[up[0]][up[1]] + max_val[curr[0]][curr[1]]) q.appendleft(up) # Find right po right = [curr[0], curr[1] + 1] if (isValid(right)): max_val[right[0]][right[1]] = max(max_val[right[0]][right[1]], mat[right[0]][right[1]] + max_val[curr[0]][curr[1]]) q.appendleft(right) # Find dig po dig = [curr[0]-1, curr[1] + 1] if (isValid(dig)): max_val[dig[0]][dig[1]] = max(max_val[dig[0]][dig[1]], mat[dig[0]][dig[1]] + max_val[curr[0]][curr[1]]) q.appendleft(dig) # Return the required answer return max_val[0][COL - 1] #Driver code print(&quot;Given matrix is &quot;) for i in range(ROW): for j in range(COL): print(array[i][j], end=&quot; &quot;) print() print(&quot;Maximum cost is &quot;, find_max_cost(array)) </code></pre> <p>I have not any ideas. Output my current code: Given matrix is 97 16 73 23 43 99 30 37 71 29 5 52 89 98 19 73 66 89 97 15 96 2 15 31 96 Maximum cost is 662</p> <p>Out, which I need: Given matrix is 97 16 73 23 43 99 30 37 71 29 5 52 89 98 19 73 66 89 97 15 96 2 15 31 96 Maximum cost is 662 Way is 96-73-5-99-97-16-73-23-46</p>
[ { "answer_id": 74266106, "author": "Kkameleon", "author_id": 12094184, "author_profile": "https://Stackoverflow.com/users/12094184", "pm_score": 1, "selected": false, "text": "input" }, { "answer_id": 74266134, "author": "hassan abbas", "author_id": 20341562, "author_...
2022/10/31
[ "https://Stackoverflow.com/questions/74266046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20379979/" ]
74,266,096
<pre><code> const [state,setState]=useState(0) return( &lt;&gt; {state} &lt;div onClick={setState(1)}&gt;&lt;/div&gt; &lt;/&gt; ) //Error //Too many re-renders. React limits the number of renders to prevent an infinite loop. </code></pre> <p>the code works when we use <code>{onClick={()=&gt;setState(1)}}</code> but I want to know why it don't work in the first case.</p>
[ { "answer_id": 74266321, "author": "ashish.g", "author_id": 604656, "author_profile": "https://Stackoverflow.com/users/604656", "pm_score": 1, "selected": false, "text": "<div onClick={setState(1)}></div>\n" }, { "answer_id": 74266365, "author": "Ilê Caian", "author_id": ...
2022/10/31
[ "https://Stackoverflow.com/questions/74266096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20380853/" ]
74,266,113
<p>After some effort, I convinced both the clang compiler and clang-tidy (static analyzer) to warn of a use-after-move situation. (see <a href="https://stackoverflow.com/a/74250567/225186">https://stackoverflow.com/a/74250567/225186</a>)</p> <pre><code>int main(int, char**) { a_class a; auto b = std::move(a); a.f(); // warns here, for example &quot;invalid invocation of method 'f' on object 'a' while it is in the 'consumed' state [-Werror,-Wconsumed]&quot; } </code></pre> <p>However, if I make the variable global (or static or lazily static), there is no more warning.</p> <pre><code>a_class a; int main(int, char**) { auto b = std::move(a); a.f(); // no warns here! } </code></pre> <p>See here: <a href="https://godbolt.org/z/3zW61qYfY" rel="noreferrer">https://godbolt.org/z/3zW61qYfY</a></p> <p><strong>Is it possible to generalize some sort of use-after-move detection at compile-time for global variables? Or is it impossible, even in principle?</strong></p> <hr /> <p>Note: please don't make this discussion about global object (I know it is a bad idea) or about the legality of using moved objects (I know some class are designed for that to be ok). The question is technical, about the compiler and tools to detect a certain bug-prone pattern in the program.</p> <hr /> <p>Full working code, compile with <code>clang ... -Wconsumed -Werror -std=c++11</code> or use <code>clang-tidy</code>. The clang annotation (extensions) help the compiler detect the patterns.</p> <pre><code>#include&lt;cassert&gt; #include&lt;memory&gt; class [[clang::consumable(unconsumed)]] a_class { std::unique_ptr&lt;int&gt; p_; public: [[clang::callable_when(unconsumed)]] void f() {} // private: [[clang::set_typestate(consumed)]] void invalidate() {} // not needed but good to know }; a_class a; int main(int, char**) { // a_class a; auto b = std::move(a); a.f(); // global doesn't warn here } </code></pre> <hr /> <p>Most of the information I could find about this clang extension is from here: Andrea Kling's blog <a href="https://awesomekling.github.io/Catching-use-after-move-bugs-with-Clang-consumed-annotations/" rel="noreferrer">https://awesomekling.github.io/Catching-use-after-move-bugs-with-Clang-consumed-annotations/</a></p>
[ { "answer_id": 74672835, "author": "Midas", "author_id": 20678816, "author_profile": "https://Stackoverflow.com/users/20678816", "pm_score": -1, "selected": false, "text": "#include<cassert>\n#include<memory>\n\nclass [[clang::consumable(unconsumed)]] a_class {\nstd::unique_ptr<int> p_;\...
2022/10/31
[ "https://Stackoverflow.com/questions/74266113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225186/" ]
74,266,118
<p>I have a SQL Statement like this :</p> <pre><code>UPDATE students SET name = :name, school = :school, grade = :grade WHERE id = :id AND school = :school </code></pre> <p>I would like to expose this SQL as an API update using the WSO2 Dataservice.</p> <p>It worked for me but i have to set all the value in the JSON payload like this :</p> <pre><code>{ &quot;_putupdateprofile&quot;: { &quot;name&quot;:&quot;oussama&quot;, &quot;school&quot;: &quot;AL-ZOUHOUR&quot;, &quot;grade&quot;: &quot;A1&quot;, &quot;id&quot;: 123 } } </code></pre> <p>where my objectif is to be able to update only one value like this :</p> <pre><code>{ &quot;_putupdateprofile&quot;: { &quot;name&quot;:&quot;oussama&quot;, &quot;id&quot;: 123 } } </code></pre> <p>So does WSO2 DataService support this?</p>
[ { "answer_id": 74672835, "author": "Midas", "author_id": 20678816, "author_profile": "https://Stackoverflow.com/users/20678816", "pm_score": -1, "selected": false, "text": "#include<cassert>\n#include<memory>\n\nclass [[clang::consumable(unconsumed)]] a_class {\nstd::unique_ptr<int> p_;\...
2022/10/31
[ "https://Stackoverflow.com/questions/74266118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10793556/" ]
74,266,124
<p>I am cleaning up a dataframe that has date of birth and date of death as a string. There are multiple formats of dates in those columns. Some contain just year (which is all I need). These are the formats of dates:</p> <pre><code>Jan 10 2020 1913 10/8/2019 June 14th 1980 </code></pre> <p>All I need is the year from each date. I have not been having any luck with pandas to_datetime since a significant portion of the rows only have year to begin with.</p> <p>Is there a way for me to pull just year from the strings so that I can get each column to look like:</p> <pre><code>2020 1913 2019 1980 </code></pre>
[ { "answer_id": 74266193, "author": "Deneb", "author_id": 2547890, "author_profile": "https://Stackoverflow.com/users/2547890", "pm_score": 0, "selected": false, "text": "str.extract" }, { "answer_id": 74266287, "author": "user19077881", "author_id": 19077881, "author_...
2022/10/31
[ "https://Stackoverflow.com/questions/74266124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20084383/" ]
74,266,144
<p>I need to scrape Prometheus metrics from an endpoint that requires a custom HTTP header, <code>x-service-token</code>.</p> <p>Prometheus does <a href="https://github.com/prometheus/prometheus/issues/1724" rel="nofollow noreferrer">not include an option to scrape using a custom HTTP header</a>, only the <code>Authorization</code> header.</p> <p><a href="https://github.com/prometheus/prometheus/issues/1724#issuecomment-282418757_" rel="nofollow noreferrer">One user shared a workaround</a> for using nginx to create a reverse proxy</p> <blockquote> <p>Just in case others come looking here for how to do this (there are at least 2 other issues on it), I've got a little nginx config that works. I'm not an nginx expert so don't mock! ;)</p> <p>I run it in docker. A forward proxy config file for nginx listening on 9191:</p> <pre><code>http { map $request $targetport { ~^GET\ http://.*:([^/]*)/ &quot;$1&quot;; } server { listen 0.0.0.0:9191; location / { proxy_redirect off; proxy_set_header NEW-HEADER-HERE &quot;VALUE&quot;; proxy_pass $scheme://$host:$targetport$request_uri; } } } events { } </code></pre> <p>Run the transparent forward proxy:</p> <p><code>docker run -d --name=nginx --net=host -v /path/to/nginx.conf:/etc/nginx/nginx.conf:ro nginx</code></p> <p>In your prometheus job (or global) add the <code>proxy_url</code> key</p> <pre class="lang-yaml prettyprint-override"><code> - job_name: 'somejob' metrics_path: '/something/here' proxy_url: 'http://proxyip:9191' scheme: 'http' static_configs: - targets: - '10.1.3.31:2004' - '10.1.3.31:2005' </code></pre> <p><em>Originally posted by @sra in <a href="https://github.com/prometheus/prometheus/issues/1724#issuecomment-282418757" rel="nofollow noreferrer">https://github.com/prometheus/prometheus/issues/1724#issuecomment-282418757</a></em></p> </blockquote> <p>I have tried configuring this, but without 'host' networking and using <code>host.docker.internal</code> instead of localhost, but nginx is not able to connect</p> <pre><code>nginx | 172.26.0.4 - - [31/Oct/2022:16:07:38 +0000] &quot;GET http://host.docker.internal:8080/actuator/prometheus HTTP/1.1&quot; 502 157 &quot;-&quot; &quot;Prometheus/2.39.1&quot; </code></pre> <p>This workaround also requires saving the API key in a file, which is not ideal, as this could accidentally be committed to a repo.</p> <p>Prometheus locked the GitHub issue, so users are not able to ask for help or follow up questions.</p> <p>There are two other StackOverflow questions on this topic, but the answers do not attempt to provide workarounds:</p> <ul> <li><a href="https://stackoverflow.com/questions/66032498/prometheus-scrape-metric-with-custom-header">Prometheus scrape /metric with custom header</a></li> <li><a href="https://stackoverflow.com/questions/44369197/adding-custom-header-in-http-request-of-prometheus?noredirect=1&amp;lq=1">Adding custom header in HTTP request of prometheus</a></li> </ul>
[ { "answer_id": 74266193, "author": "Deneb", "author_id": 2547890, "author_profile": "https://Stackoverflow.com/users/2547890", "pm_score": 0, "selected": false, "text": "str.extract" }, { "answer_id": 74266287, "author": "user19077881", "author_id": 19077881, "author_...
2022/10/31
[ "https://Stackoverflow.com/questions/74266144", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4161471/" ]
74,266,167
<p>None of the images I have saved locally can be found when trying to import them in my project.</p> <pre><code>import {portfolio} from './portfolio.png' </code></pre> <p>Leads to &quot;Cannot find module './portfolio.png' or its corresponding type declarations.ts(2307)&quot;.</p> <p>The image file path is 100% correct.</p> <p>Update: Image loads however I would like to know how to remove the typescript error.</p>
[ { "answer_id": 74266215, "author": "rastiq", "author_id": 11248668, "author_profile": "https://Stackoverflow.com/users/11248668", "pm_score": 1, "selected": false, "text": "import portfolio from './portfolio.png'" }, { "answer_id": 74266501, "author": "Varun Kaklia", "aut...
2022/10/31
[ "https://Stackoverflow.com/questions/74266167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19517082/" ]
74,266,172
<p>I would like to convert a dict of lists of a dict into a dataframe selectively. I would only like to take the publisher and the title from the results if the publisher name is Benzinga:</p> <pre><code> {'results': [{'id': 'knNyIzsECbl3YYPAKIQsEoaO4_roXDftV-auy9lSB-w', 'publisher': {'name': 'Benzinga', 'homepage_url': 'https://www.benzinga.com/'}, 'title': 'Earnings Scheduled For May 11, 2021'}, {'id': 'KNDx8p0PytFULh33UWse-BkT7XxpxLZtGLij22tiZMM', 'publisher': {'name': 'The Motley Fool', 'homepage_url': 'https://www.fool.com/', 'title': 'Taysha Gene Therapies, Inc. (TSHA) Q1 2021 Earnings Call Transcript'}]} </code></pre> <p>expected output:</p> <pre><code>publisher title Benzinga Earnings Scheduled For May 11, 2021 </code></pre> <p>If I convert to pandas dataframe first then it keeps lists and dicts in the elements of the dataframe...</p>
[ { "answer_id": 74266622, "author": "wutangforever", "author_id": 10576221, "author_profile": "https://Stackoverflow.com/users/10576221", "pm_score": 0, "selected": false, "text": "data = {'results': \n [{'id': 'knNyIzsECbl3YYPAKIQsEoaO4_roXDftV-auy9lSB-w',\n 'publisher': {'name': 'Be...
2022/10/31
[ "https://Stackoverflow.com/questions/74266172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15524510/" ]
74,266,202
<p>I created test that:</p> <ol> <li>erase existing download directory (cypress/download)</li> <li>Downloading a file.pdf/csv/txt/and so on...</li> <li>Makes an assertion and in order to do that you have to provide expected filename for instance 'correctFile.pdf' and cypress will match this expected name with filename that has been downloaded in 'cypress/download'.</li> <li>erase existing download directory (cypress/download)</li> </ol> <p><strong>cypress/download</strong> <code>TEST.pdf</code></p> <p><strong>TEST:</strong> `</p> <pre><code>it.only(&quot;should downloads file&quot;, () =&gt; { cy.task('deleteDirectory', downloadsFolder); // deleting download directory cy.get(&quot;downloadButton&quot;).click(); // downloading 'TEST.pdf' file cy.task('isExistDownloadedFile', 'TEST.pdf').should('equal', true); // assertion cy.task('deleteDirectory', downloadsFolder); // deleting download directory }) </code></pre> <p>`</p> <p><strong>plugins/index.js</strong> `</p> <pre><code> **--snip--** const path = require('path'); const fs = require('fs'); const downloadDirectory = path.join(__dirname, '..', 'downloads'); const findDownloadedFile = (filename) =&gt; { **const FileName = `${downloadDirectory}/${filename}`;** const contents = fs.existsSync(FileName); return contents; }; const hasFile = (filename, ms) =&gt; { const delay = 10; return new Promise((resolve, reject) =&gt; { if (ms &lt; 0) { return reject( new Error(`Could not find any file ${downloadDirectory}/${filename}`) ); } const found = findDownloadedFile(filename); if (found) { return resolve(true); } setTimeout(() =&gt; { hasFile(filename, ms - delay).then(resolve, reject); }, delay); }); }; **--snip--** // find downloaded file and match the name of that file with the expected filename on('task', { isExistDownloadedFile(filename, ms = 4000) { return hasFile(filename, ms); }, }); return config; </code></pre> <p>`</p> <p><strong>My question:</strong> Now I can assert only entire file name e.g. <code>TEST.pdf (downloaded) equal to TEST.pdf (expected)</code> RESULT: PASSED but how can I make that my program will also accept some characters, like only extension for instance: <code>TEST.pdf (downloaded) contains .pdf (expected)</code> RESULT: PASSED</p>
[ { "answer_id": 74266630, "author": "agoff", "author_id": 11625850, "author_profile": "https://Stackoverflow.com/users/11625850", "pm_score": 0, "selected": false, "text": "const findDownloadedFile = (filename) => {\n const files = fs.readDirSync(downloadDirectory).filter((x) => x.includ...
2022/10/31
[ "https://Stackoverflow.com/questions/74266202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19777975/" ]
74,266,203
<p>I tried using overflow hidden, box-shadow none, background none, background color transparent, outline none, border 0, border-width 0px and border none, but it doesn't change. Is there any more option I can do? I'm currently not using JavaScript or jQuery. I'm not using any framework either. How to remove the border?</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>header { background-color: rgb(255, 255, 255); height: 600px; } body { font-family: Arial, Helvetica, sans-serif; } .navbar { width: 98.5%; margin: auto; padding: 10px; display: flex; align-items: center; justify-content: space-between; outline: none; } .logo { width: 160px; cursor: pointer; margin-right: auto; } .navbar .dropdown { display: none; box-shadow: 0px 0px 2px #000; border-radius: 5px; outline: none; } .navbar ul li:hover .dropdown { display: block; } .navbar&gt;ul&gt;li { position: relative; } .navbar&gt;ul&gt;li&gt;.dropdown { position: absolute; top: 1.4em; } .navbar .dropdown li { display: block; margin: 15px; margin-left: -20px; text-align: left; } .navbar ul li { list-style: none; display: inline-block; margin: 0 20px; position: relative; } .navbar ul li a { text-decoration: none; color: black; border-bottom: 0px; } .navbar ul li a:hover { color: teal; } .navbar&gt;ul&gt;li::after { content: ''; height: 3px; width: 0; background: teal; position: absolute; left: 0; bottom: 0px; transition: 0.5s; } .navbar&gt;ul&gt;li:hover::after { width: 100%; } button1 { list-style: none; border: none; background: teal; padding: 10px 20px; border-radius: 20px; color: white; font-size: 15px; transition: 0.4s; } .Header-Register { text-align: center; } .content { position: relative; bottom: 200px; } .Full-Name { width: 100%; padding: 10px 0; margin: 5px 0; border-left: 0; border-top: 0; border-right: 0; outline: none; background: transparent; border-bottom: 2px solid #adadad; } .gender { margin: 20px; display: flex; text-align: center; justify-content: center; } .email { border-bottom: 2px solid #adadad; } .option { margin: 20px; } .Password { margin: 20px; border-bottom: 2px solid #adadad; } .Confirm-Password { border-bottom: 2px solid #adadad; } .Register { width: 5%; padding: 5px 30px; cursor: pointer; display: block; margin: auto; background: teal; border: 0; outline: none; border-radius: 5px; color: white; margin-top: 20px; } .content { position: relative; text-align: center; margin-top: -190px; bottom: 120px; } footer { position: relative; bottom: -15px; height: auto; background-color: rgb(255, 255, 255); padding-top: 0px; margin-top: 20px; } .socials { display: flex; align-items: center; justify-content: center; text-align: center; list-style: none; margin: 5px; position: relative; bottom: -20px; left: -20px; } .socials li { margin: 10px; } .socials a { text-decoration: none; color: #000; font-size: 25px; } .footer-content{ align-items: center; justify-content: center; text-align: center; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/&gt; &lt;header&gt; &lt;div class="banner-home"&gt; &lt;div class="navbar"&gt; &lt;img src="icon.png" class="logo"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://127.0.0.1:3000/Project/Home.html"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Products&lt;/a&gt; &lt;ul class="dropdown"&gt; &lt;li&gt;&lt;a href="#"&gt;Healthcare&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://127.0.0.1:3000/Project/Products.html"&gt;Cosmetic&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Misc.&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href="http://127.0.0.1:3000/Project/AboutUs.html"&gt;About Us&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Register&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;a href="#" style="text-decoration:none;"&gt;&lt;button1&gt;Login&lt;/button1&gt;&lt;/a&gt; &lt;/div&gt; &lt;div class="Header-Register"&gt; &lt;h1&gt;Register&lt;/h1&gt; &lt;/div&gt; &lt;/header&gt; &lt;section&gt; &lt;div class="content"&gt; &lt;div class="Full-Name"&gt; &lt;input type="text" placeholder="Full Name" required&gt; &lt;/div&gt; &lt;div class="email"&gt; &lt;input type="email" placeholder="Email" required&gt; &lt;/div&gt; &lt;div class="gender"&gt; &lt;input type="radio" name="radiobutton" value="Male"&gt; &lt;label for="radiobutton"&gt;Male&lt;/label&gt; &lt;input type="radio" name="radiobutton" value="Female"&gt; &lt;label for="radiobutton"&gt;Female&lt;/label&gt; &lt;/div&gt; &lt;div&gt; &lt;div class="option"&gt; &lt;select&gt; &lt;option value="Jakarta"&gt;Jakarta&lt;/option&gt; &lt;option value="Bogor"&gt;Bogor&lt;/option&gt; &lt;option value="Depok"&gt;Depok&lt;/option&gt; &lt;option value="Tangerang"&gt;Tangerang&lt;/option&gt; &lt;option value="Bekasi"&gt;Bekasi&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="Password"&gt; &lt;input type="text" placeholder="Password"&gt; &lt;/div&gt; &lt;div class="Confirm-Password"&gt; &lt;input type="text" placeholder="Confirm Password"&gt; &lt;/div&gt; &lt;div class="Register"&gt; &lt;a href="#" style="text-decoration:none; color: white;"&gt;Register&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;footer&gt; &lt;div&gt; &lt;ul class="socials"&gt; &lt;li&gt;&lt;a href="https://twitter.com/Clownehara" target="_blank"&gt;&lt;i class="fa fa-twitter"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="https://www.facebook.com/profile.php?id=100012662688022" target="_blank"&gt;&lt;i class="fa fa-facebook"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="https://www.instagram.com/satrianavito/" target="_blank"&gt;&lt;i class="fa fa-instagram"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div class="footer-content"&gt; &lt;p&gt;Copyright Ⓒ 2022 [NAME]. All Rights Reserved.&lt;/p&gt; &lt;/div&gt; &lt;/footer&gt; </code></pre> </div> </div> </p>
[ { "answer_id": 74266342, "author": "Harrison", "author_id": 15291770, "author_profile": "https://Stackoverflow.com/users/15291770", "pm_score": -1, "selected": false, "text": "input {\n border: none;\n}\n" }, { "answer_id": 74266362, "author": "Dev", "author_id": 2037142...
2022/10/31
[ "https://Stackoverflow.com/questions/74266203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20333204/" ]
74,266,211
<p>I would like to print the item of dictionary. how to do that? this is my code</p> <pre><code>{'naruto': [900, 170], 'onepiece': [600, 60]} for key, value in stock_dict1.items(): for value in stock_dict1.values(): print(key, value[0], value[1]) </code></pre> <p>when I print out, the result will be like this: how to do that?</p> <pre><code>naruto 900 170 onepiece 600 60 </code></pre>
[ { "answer_id": 74266342, "author": "Harrison", "author_id": 15291770, "author_profile": "https://Stackoverflow.com/users/15291770", "pm_score": -1, "selected": false, "text": "input {\n border: none;\n}\n" }, { "answer_id": 74266362, "author": "Dev", "author_id": 2037142...
2022/10/31
[ "https://Stackoverflow.com/questions/74266211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20362914/" ]
74,266,250
<p>Write a function nondec(n) that receives an integer n&gt;0 and reports whether its digits (in base 10) form a nondecreasing sequence (that is, each digit is greater or equal to the previous one).</p> <p>I am having trouble with this exercise. My code so far is:</p> <pre><code>def nondec(n): ''' &gt;&gt;&gt; nondec(113355779) True &gt;&gt;&gt; nondec(44569) True &gt;&gt;&gt; nondec(346234) False &gt;&gt;&gt; nondec(222) True &gt;&gt;&gt; nondec(789) True &gt;&gt;&gt; nondec(55555) True &gt;&gt;&gt; nondec(1234123) False &gt;&gt;&gt; nondec(98765) False ''' prev = 9 while n&gt;0 : lastdigit = n%10 if lastdigit &gt; prev: return False prev = lastdigit n = n/10 return True if __name__ == &quot;__main__&quot;: import doctest doctest.testmod(verbose=True) </code></pre> <p>It works for all cases but for those with repeated digits: 222, 55555. I tried many things but it makes my code worse. Thanks.</p>
[ { "answer_id": 74266364, "author": "m2r105", "author_id": 18164421, "author_profile": "https://Stackoverflow.com/users/18164421", "pm_score": 3, "selected": true, "text": "def nondec(n):\n '''\n >>> nondec(113355779)\n True\n >>> nondec(44569)\n True\n >>> nondec(346234...
2022/10/31
[ "https://Stackoverflow.com/questions/74266250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20323813/" ]
74,266,255
<p>I am currently learning arrays in C. In the training that I follow, it is marked two things that cause me problems :</p> <ul> <li>The first is that in the RAM each of the boxes that make up the table follows one another</li> <li>The second is that a table is a pointer that points to the first box of the table</li> </ul> <p>Could someone clarify for me about the storage of arrays in RAM and their relationship to pointers?</p> <p>But when I do this I notice that the addresses do not follow each other :</p> <pre><code> int arrays[3] = {10, 20, 30}; int i = 0; for (i=0 ; i &lt; 3 ; i++) { printf(&quot;%d : %d\n&quot;, i, &amp;arrays[i]); } </code></pre> <p>Result : 0 : 973077712 1 : 973077716 2 : 973077720</p> <hr /> <p>And when I do this I notice that array and &amp;array give me the same value which should not be the case for a &quot;classic pointer&quot; :</p> <pre><code> printf(&quot;value of arrays : %d\n&quot;, arrays); printf(&quot;value of &amp;arrays : %d\n&quot;, &amp;arrays); </code></pre> <p>Result : value of arrays : 1522530048 value of &amp;arrays : 1522530048</p> <pre><code></code></pre>
[ { "answer_id": 74266462, "author": "Vlad from Moscow", "author_id": 2877241, "author_profile": "https://Stackoverflow.com/users/2877241", "pm_score": 1, "selected": false, "text": "T" }, { "answer_id": 74266528, "author": "John Bollinger", "author_id": 2402272, "autho...
2022/10/31
[ "https://Stackoverflow.com/questions/74266255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19190909/" ]
74,266,271
<p>I've been trying to understand the call stack and recursive functions but I'm stuck here.</p> <p>In this code, The call stack will pile up 6 times, until a = 5, in which case it will return 1 to the 5th call stack. But after returning to the 5th call stack, the program just goes back to main.</p> <p>What about the other call stacks that don't have a return value? Doesn't every function on the call stack need to return a value?</p> <pre class="lang-java prettyprint-override"><code>public static int func1(int a) { if (a == 5) { return 1; } return func1(a + 1); } public static void main(String[] args) { func1(0); } </code></pre> <p>Edit: I've heard it shouldn't go back to main after the 5th call stack and it should go back down the call stack 1 at a time, but my code goes back to main right after this step which as you can see, is on the 5th call stack <a href="https://i.stack.imgur.com/wDO2J.png" rel="nofollow noreferrer">https://i.stack.imgur.com/wDO2J.png</a></p>
[ { "answer_id": 74266343, "author": "chrylis -cautiouslyoptimistic-", "author_id": 1189885, "author_profile": "https://Stackoverflow.com/users/1189885", "pm_score": 0, "selected": false, "text": "main" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74266271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20304864/" ]
74,266,280
<p>I am currently writing a program to simply reverse a string in C. However, when I try to copy the contents of the temp string I made into the original string, I get a segmentation fault. Also, when I try to free the memory I allocated for my test string I get a warning which says &quot; 'free' called on a pointer to an unallocated object &quot; Here is my code:</p> <pre><code>void reverseString(char* str, size_t size) { char *temp = (char*) malloc(sizeof(str) + 1); int j = size; for (int i = 0; i &lt; size; i++) { temp[i] = str[j]; j--; } for (int i = 0; i &lt; size; i++) { str[i] = temp[i]; } free(temp); return; } int main() { char* result = (char*)(malloc(sizeof(char) * 10)); result = &quot;Forty-two&quot;; reverseString(result, strlen(result)); printf(&quot;%s&quot;, result); free(result); result = NULL; return 0; } </code></pre>
[ { "answer_id": 74266359, "author": "Pedro Vieira", "author_id": 20378058, "author_profile": "https://Stackoverflow.com/users/20378058", "pm_score": 1, "selected": false, "text": "strlen" }, { "answer_id": 74267358, "author": "embedded4ever", "author_id": 8647388, "aut...
2022/10/31
[ "https://Stackoverflow.com/questions/74266280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18757789/" ]
74,266,329
<p>We are building an application using .NET 6 and EF Core 6 with an existing SQL Server database. We are using the database first approach and running the Scaffold-DbContext tool we were able to generate the dbcontex class. Everything works fine, a part for a parent child relation between two tables:</p> <p><a href="https://i.stack.imgur.com/pJIBH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pJIBH.png" alt="enter image description here" /></a></p> <p>The scaffold tool, for the above tables generated the following two classes:</p> <pre><code>public partial class TreeNode { public TreeNode() { TreeNodeHierarchyChildren = new HashSet&lt;TreeNodeHierarchy&gt;(); TreeNodeHierarchyParents = new HashSet&lt;TreeNodeHierarchy&gt;(); } public int Id { get; set; } public string Name { get; set; } public string Code { get; set; } public bool IsLeaf { get; set; } public int? OrganisationId { get; set; } public bool IsDeleted { get; set; } public virtual ICollection&lt;TreeNodeHierarchy&gt; TreeNodeHierarchyChildren { get; set; } public virtual ICollection&lt;TreeNodeHierarchy&gt; TreeNodeHierarchyParents { get; set; } } public partial class TreeNodeHierarchy { public int Id { get; set; } public int ParentId { get; set; } public int ChildId { get; set; } public virtual TreeNode Child { get; set; } public virtual TreeNode Parent { get; set; } } </code></pre> <p>And in the dbcontext class the following mapping:</p> <pre><code>modelBuilder.Entity&lt;TreeNode&gt;(entity =&gt; { entity.ToTable(&quot;TreeNode&quot;); entity.Property(e =&gt; e.Code).HasMaxLength(100); entity.Property(e =&gt; e.Name) .IsRequired() .HasMaxLength(255); }); modelBuilder.Entity&lt;TreeNodeHierarchy&gt;(entity =&gt; { entity.ToTable(&quot;TreeNodeHierarchy&quot;); entity.HasOne(d =&gt; d.Child) .WithMany(p =&gt; p.TreeNodeHierarchyChildren) .HasForeignKey(d =&gt; d.ChildId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName(&quot;FK_TreeNodeHierarchy_TreeNode_Child&quot;); entity.HasOne(d =&gt; d.Parent) .WithMany(p =&gt; p.TreeNodeHierarchyParents) .HasForeignKey(d =&gt; d.ParentId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName(&quot;FK_TreeNodeHierarchy_TreeNode_Parent&quot;); }); </code></pre> <p>Here is the issue, when I write the following:</p> <pre><code>var nodes = _context.TreeNodes.Include(th =&gt; th.TreeNodeHierarchyChildren) .Where(tn =&gt; tn.IsLeaf) ..... </code></pre> <p>it loads the child but not the parent.</p> <p><a href="https://i.stack.imgur.com/7bzyE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7bzyE.png" alt="enter image description here" /></a></p> <p>This relation works properly in the current application (.net 4.7) using LINQ to SQL.</p> <p>Am I missing something?</p> <p><strong>Updated</strong></p> <p>as suggested from @SpruceMoose, I included also the TreeNodeHierarchyParents property in the query but it didn't fix the issue.</p> <pre><code>var nodes = _context.TreeNodes .Include(th =&gt; th.TreeNodeHierarchyChildren) .Include(th =&gt; th.TreeNodeHierarchyParents) .Where(tn =&gt; tn.IsLeaf) </code></pre> <p><strong>Updated #2</strong></p> <p>I applied the mapping suggested from @Dave which in my opinion it makes sense (at the end the relation is like the Windows folders/files system). Anyway there is still something that's not working properly. When I debug the following code:</p> <pre><code>var nodes = _context.TreeNodes .Include(th =&gt; th.TreeNodeHierarchyChildren) .Include(th =&gt; th.TreeNodeHierarchyParents) .Where(tn =&gt; tn.IsLeaf) .ToList(); </code></pre> <p>I still see that the parent has not been loaded</p> <p><a href="https://i.stack.imgur.com/JqlOT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JqlOT.png" alt="enter image description here" /></a></p> <p><strong>Updated #3</strong></p> <p>I applied the change to the query as suggested from @Moho</p> <pre><code>var nodes = _context.TreeNodes .Include(th =&gt; th.TreeNodeHierarchyChildren) .ThenInclude(tnhc =&gt; tnhc.Child) .Include(th =&gt; th.TreeNodeHierarchyParents) .ThenInclude(tnhp =&gt; tnhp.Parent) .Where(tn =&gt; tn.IsLeaf) .ToList(); </code></pre> <p>and finally we got the Parent value</p> <p><a href="https://i.stack.imgur.com/aYLfp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aYLfp.png" alt="enter image description here" /></a></p> <p>Now we are missing the last step, the parents of a parent</p> <p><a href="https://i.stack.imgur.com/yuRRS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yuRRS.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74266675, "author": "SpruceMoose", "author_id": 1660123, "author_profile": "https://Stackoverflow.com/users/1660123", "pm_score": 2, "selected": false, "text": "Parent" }, { "answer_id": 74267218, "author": "Dave Cousineau", "author_id": 621316, "author...
2022/10/31
[ "https://Stackoverflow.com/questions/74266329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1026594/" ]
74,266,331
<p>I'm trying to implement a code for the following function: f(x) = sen(2πx), x ∈ [0, 2], to get the graph of it. But I'm getting the return that the sine is not defined. I'm not quite understanding what I would have to correct. I would be grateful if someone can help me</p> <p>Code I used:</p> <pre><code>import math import numpy as np import matplotlib.pyplot as plt def f(x): return sin*(2*np.pi*x) x = np.linspace(0,2) plt.plot(x, f(x)) plt.grid() plt.show() </code></pre> <p>This was the only code I thought of to solve this issue, because I thought it would print correctly and without errors</p>
[ { "answer_id": 74266385, "author": "Luckk", "author_id": 2888187, "author_profile": "https://Stackoverflow.com/users/2888187", "pm_score": 2, "selected": true, "text": "def f(x): return np.sin*(2*np.pi*x)\n" }, { "answer_id": 74266410, "author": "islam abdelmoumen", "auth...
2022/10/31
[ "https://Stackoverflow.com/questions/74266331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20362137/" ]
74,266,335
<p>How can I delect the white space in a list?</p> <p>I have:</p> <pre><code>text = [&quot; Hello&quot;, &quot; how are &quot;,&quot;you &quot;] </code></pre> <p>I want:</p> <pre><code>text = [&quot;Hello&quot;,&quot;how are&quot;,&quot;you&quot;] </code></pre>
[ { "answer_id": 74266350, "author": "Tim Roberts", "author_id": 1883316, "author_profile": "https://Stackoverflow.com/users/1883316", "pm_score": 1, "selected": false, "text": ".strip" }, { "answer_id": 74266375, "author": "islam abdelmoumen", "author_id": 19661530, "a...
2022/10/31
[ "https://Stackoverflow.com/questions/74266335", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20373888/" ]
74,266,347
<p>I have a variable where I dump the day, month and year of some events.</p> <p>$Myvariable -&gt; <code>17/10/2022</code></p> <p>I need to change the order of the day and month.</p> <p>$NewVariable-&gt; <code>10/17/2022</code></p> <p>Would someone know how to do it? Any ideas?</p> <p>I'm starting to work with powershell and I can't think of a way to do it.Any help or suggestion is welcome.</p> <p>Thanks for your time</p>
[ { "answer_id": 74266451, "author": "Mark", "author_id": 2203038, "author_profile": "https://Stackoverflow.com/users/2203038", "pm_score": 0, "selected": false, "text": "Myvariable='17/10/2022'\n\n# EDIT: Using Cyrus's FS,OFS improvement:\nNewvariable=$( awk 'BEGIN { FS=OFS=\"/\" }{ pri...
2022/10/31
[ "https://Stackoverflow.com/questions/74266347", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19957972/" ]
74,266,356
<p>I have been trying to use string.replace() function but it is not working</p> <p>here is what is i did;</p> <pre><code>const replaceTemplate = function (temp, product) { let output = temp.replace(/{%PRODUCTNAME%}/g, product.productName); console.log(product.productName); output = temp.replace(/{%IMAGE%}/g, product.image); output = temp.replace(/{%PRICE%}/g, product.price); output = temp.replace(/{%FROM%}/g, product.from); output = temp.replace(/{%NUTRIENTS%}/g, product.nutrients); output = temp.replace(/{%QUANTITY%}/g, product.quantity); output = temp.replace(/{%ID%}/g, product.id); output = temp.replace(/{%DESCRIPTION%}/g, product.description); if (!product.organic) output = output.replace(/{%NOT-ORGANIC%}/g, &quot;not_organic&quot;); return output; }; </code></pre> <p>This function is supposed to replace all placeholders in template argument being passed.</p> <pre><code>const cardsHTML = dataObj .map((el) =&gt; replaceTemplate(tempCard, el)) .join(&quot;&quot;); </code></pre> <p>This is my function call. dataObj is javascript object and tempcard is a html code template. I am reading it using</p> <pre><code>const tempCard = fs.readFileSync(`./templates/template-card.html`, &quot;utf-8&quot;); </code></pre> <p>Placeholders in tempCard are not getting replaced at all.</p>
[ { "answer_id": 74266470, "author": "Barmar", "author_id": 1491895, "author_profile": "https://Stackoverflow.com/users/1491895", "pm_score": 2, "selected": true, "text": "temp" }, { "answer_id": 74266510, "author": "Mario Sandoval", "author_id": 14566919, "author_profi...
2022/10/31
[ "https://Stackoverflow.com/questions/74266356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20381023/" ]
74,266,371
<p>I have two dataframes:</p> <p>df1 is a reference table with a list of individual codes and their corresponding values.</p> <p>df2 is a excerpt from a larger dataset, wherein one of the columns will contain multiple examples of the codes. It will also contain other values I want to ignore e.g. blanks and 'Not Applicable'.</p> <p>I need to split out each individual code from df2 and find the corresponding value from the reference table df1. I then want to return a column in df2 with the maximum value from the entire string of codes.</p> <pre><code>import pandas as pd df1 = [['H302',18], ['H312',17], ['H315',16], ['H316',15], ['H319',14], ['H320',13], ['H332',12], ['H304',11]] df1 = pd.DataFrame(df1, columns=['Code', 'Value']) df2 = [['H302,H304'], ['H332,H319,H312,H320,H316,H315,H302,H304'], ['H315,H312,H316'], ['H320,H332,H316,H315,H304,H302,H312'], ['H315,H319,H312,H316,H332'], ['H312'], ['Not Applicable'], ['']] df2 = pd.DataFrame(df2, columns=['Code']) </code></pre> <p>I had previously used the following:</p> <pre><code> df3 = [] for i in range(len(df2)): df3.append(df2['Code'][i].split(&quot;,&quot;)) max_values = [] for i in range(len(df3)): for j in range(len(df3[i])): for index in range(len(df1)): if df1['Code'][index] == df3[i][j]: df3[i][j] = df1['Value'][index] max_values.append(max(df3[i])) df2[&quot;Max Value&quot;] = max_values </code></pre> <p>However, the .append function is being removed and when used I get the following error &quot;'&gt;' not supported between instances of 'numpy.ndarray' and 'str'&quot;</p>
[ { "answer_id": 74266899, "author": "Shubham Sharma", "author_id": 12833166, "author_profile": "https://Stackoverflow.com/users/12833166", "pm_score": 2, "selected": true, "text": "df2['max'] = (\n df2['Code']\n .str.split(',')\n .explode()\n .map(df1.set_index('Code')['Value'...
2022/10/31
[ "https://Stackoverflow.com/questions/74266371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16399035/" ]
74,266,373
<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>class Movie { constructor(movieName, category ) { this._movieName = movieName; this._category = category; } showMovieName() { return `${movieName}`; } } const movie1 = new Movie("Avengers", "superheroes"); console.log(movie1.showMovieName());</code></pre> </div> </div> </p> <p>I have a Movie class and two fields with underscores. I need to create a method that returns the title of the movie. How can i do this? Now in the console the error movieName is not defined</p>
[ { "answer_id": 74266388, "author": "Ameer", "author_id": 10213537, "author_profile": "https://Stackoverflow.com/users/10213537", "pm_score": -1, "selected": false, "text": "this." }, { "answer_id": 74266441, "author": "rastiq", "author_id": 11248668, "author_profile":...
2022/10/31
[ "https://Stackoverflow.com/questions/74266373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20291334/" ]
74,266,381
<p>I am trying to recursively determine the sum of the values in a linked list.</p> <p>I am aware of one recursive solution that works:</p> <pre><code>def sum_list_rec1(head_node: Node): if head_node == None: return 0 return head_node.value + sum_list_rec1(head_node.next) </code></pre> <p>However, I am trying to use the pattern where a variable is passed to the recursive function initially which will store the total sum.</p> <p>Here is the code:</p> <pre><code>def sum_list_rec2(head_node: Node): val_sum = 0 calc_sum_rec(head_node, val_sum) return val_sum def calc_sum_rec(head_node: Node, val_sum: int): if head_node == None: return val_sum += head_node.value calc_sum_rec(head_node.next, val_sum) </code></pre> <p>If I try to print out the output of the sum_list_rec2() function with a linked list (e.g. (1) -&gt; (2) -&gt; (3) -&gt; (4)), I get an output of 0.</p>
[ { "answer_id": 74266484, "author": "Luckk", "author_id": 2888187, "author_profile": "https://Stackoverflow.com/users/2888187", "pm_score": 2, "selected": false, "text": "val_sum += head_node.value" }, { "answer_id": 74266536, "author": "quamrana", "author_id": 4834, "...
2022/10/31
[ "https://Stackoverflow.com/questions/74266381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9338351/" ]
74,266,421
<p>I recently started exploring classes and I have made my first class (sort of) but it doesn't seem to be working. I have code creating the class and function, then takes the values and blits an image to certain coordinates. for some reason It takes the values from inside the class instead of what I told it to have. I am new to classes so I'm not sure what to do, please help, thanks!</p> <pre><code>import pygame pygame.init() Screen = pygame.display.set_mode((800, 400)) TC = pygame.image.load(&quot;TC.png&quot;).convert_alpha() ANUM = 0 class MTC() : def __init__(self,) : self.Tx = 0 self.Ty = 0 Screen.blit(TC,(self.Tx,self.Ty)) TMTC = MTC() TMTC.Tx = 800 TMTC.Ty = 800 while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() pygame.display.update() </code></pre>
[ { "answer_id": 74266453, "author": "Rabbid76", "author_id": 5577765, "author_profile": "https://Stackoverflow.com/users/5577765", "pm_score": 2, "selected": false, "text": "blit" }, { "answer_id": 74266504, "author": "jbh", "author_id": 20204644, "author_profile": "ht...
2022/10/31
[ "https://Stackoverflow.com/questions/74266421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19934942/" ]
74,266,434
<p>I've got this &quot;search-box&quot; with several input fields. I'm trying to add a 2nd placeholder element to get that text transformation effect when clicking the search fields e. g. <code>&lt;span class=&quot;placeholder2&quot; &gt;Insert banana number:&lt;/span&gt;</code>. These 2nd additional placeholders created 2 unwanted changes:</p> <ol> <li><p>A trembling/jerkiness in the animation after the search field is clicked to start typing, particularly the 1st search field.</p> </li> <li><p>An unwanted space between each search field. In the example below I have removed the 2nd place holder of the 2nd search field to see the difference:<br/> the space between &quot;apples&quot; and &quot;peach&quot; is ok, but between &quot;bananas&quot; and &quot;apples&quot; is not.</p> </li> </ol> <p>I need a way to:</p> <ol> <li>Remove the jerkiness from the animation.</li> <li>Remove the unwanted space created by the 2nd placeholder text.</li> </ol> <p>My guess is that the issue is probably the fact that the positioning of the placeholders is set as <code>position: relative;</code>. I tried several workarounds/tricks but I cannot get rid of these 2 issues, without messing up the position/size etc. of the search fields and &quot;SEARCH&quot; buttons.</p> <p>Is there a way to fix this or some workaround?</p> <p>Example is below:<br /> (also in case you prefer here: <a href="https://jsfiddle.net/jqzzy/ztnp0275/19/" rel="nofollow noreferrer">https://jsfiddle.net/jqzzy/ztnp0275/19/</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>///////////////////////// - BODY LOAD FIX - /////////////////////////////// window.addEventListener("load", () =&gt; { document.querySelector("body").classList.add("body_onload"); }); ////////////////////////// - ANIMATE ITEMS ON LOAD - //////////////////////// var items = document.getElementsByClassName("fade-item"); for (let i = 0; i &lt; items.length; ++i) { fadeIn(items[i], i * 50) } function fadeIn(item, delay) { setTimeout(() =&gt; { item.classList.add('fadein') }, delay) }</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>body { background-color: rgb(26, 26, 26); color: rgb(204, 204, 204); width: 290px; height: 300px; border: solid 1px rgb(78, 78, 78); border-radius: 5px; padding: 10px; font-family: Calibri, Arial, Helvetica, sans-serif; } /* ////////////////// ANIMATION ITEMS ONLOAD //////////////// */ .fade-item { transition: 0.2s ease-in-out; opacity: 0; } .fadein { animation-name: fadeIn; animation-duration: 0.2s; animation-fill-mode: both; } @-webkit-keyframes fadeIn { 0% { opacity: 0; transform: scale(0.3); } 100% { opacity: 1; transform: scale(1.0); } } /* ////////////////// STRUCTURE //////////////////// */ table.unstyledTable thead th { font-weight: normal; } .special-text { color: red; } .askit { color: red; font-size: 18px; padding: 2px; font-family: Calibri, Arial, Helvetica, sans-serif; } .title { color: rgb(231, 231, 231); font-size: 16px; padding: 3px; font-family: Calibri, Arial, Helvetica, sans-serif; } .sections { color: rgb(168, 168, 168); font-size: 14px; padding: 2px; font-family: Calibri, Arial, Helvetica, sans-serif; } .footing { color: rgb(155, 155, 155); position: absolute; right: 15px; bottom: 10px; font-size: 10px; padding: 2px; font-family: Calibri, Arial, Helvetica, sans-serif; } * { box-sizing: border-box; } @media screen and (max-width: 800px) { .topnav a, .topnav input[type=text], .topnav .search-container button { float: none; display: block; text-align: left; width: 200px; margin: 0px; } .topnav input[type=text] { border: 1px solid rgb(102, 102, 102); font-size: 16px; } } /*////// BUTTON ///////*/ .form-submit-button { background: #464646; color: rgb(172, 172, 172); border-style: solid; height: 39px; width: 60px; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 14px; border: 0px solid rgb(102, 102, 102); border-radius: 9px; -webkit-transition: 0.25s ease-out; animation: 0.25s ease-out 0s 1 scaleBtn; } @-webkit-keyframes scaleBtn { 0% { transform: scale(0.5); } 100% { transform: scale(1.0); } } .form-submit-button:hover { outline: 0; box-shadow: inset 0 5px 5px rgba(0, 0, 0, .075), 0 0 5px #6461ff; -webkit-box-shadow: inset 0 5px 5px rgba(0, 0, 0, .075), 0 0 5px #6461ff; -webkit-transition: 0.3s ease-out; } .flex-parent:hover .form-submit-button { background: #5c5c5c; } .input:hover { background: #3d3d3d; } s /*/////////////////////////////////////////////////////////////////*/ button:focus { outline: 0; } /*///////////// HIGHLIGHT BOX ANIMATION /////////////// */ span input[type="text"] { border: 2px solid rgb(238, 238, 238); background-color: rgb(49, 49, 49); height: 40px; -webkit-transition: all .4s; -webkit-transform: translate(0px, 0); /* will-change: transform, opacity; */ border: none; border: solid 1px #ccc; border-radius: 7px; -webkit-transition: 0.25s ease-out; animation: 0.25s ease-out 0s 1 scaleBtn; } @-webkit-keyframes scaleBtn { 0% { transform: scale(0.65); } 100% { transform: scale(1.0); } } span input[type="text"]:focus { margin: 3px; scale: 103%; border-color: #e63f3f; outline: 0; -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(233, 102, 102, 0.6); box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(233, 102, 102, 0.6); } span input:focus { background-color: #3d3d3d; margin: 3px; scale: 103%; border-color: #e63f3f; outline: 0; -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(233, 102, 102, 0.6); box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(233, 102, 102, 0.6); } /*///////////// PLACEHOLDER TEXT ANIMATION /////////////// */ .placeholder { position: relative; width: 0px; top: -32px; right: -5px; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 18px; font-weight: normal; padding: 0px 0px; color: grey; -webkit-transition: 0.3s; -webkit-transform: translate(0px, 0); pointer-events: none; white-space: nowrap; opacity: 1; } .input:focus~.placeholder { top: -55px; right: -8px; font-size: 16px; font-weight: normal; color: #e4a8a8; opacity: 0; } .placeholder2 { position: relative; width: 0px; top: -50px; right: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 18px; font-weight: normal; padding: 0px 0px; color: grey; -webkit-transition: 0.3s; -webkit-transform: translate(0px, 0); pointer-events: none; white-space: nowrap; opacity: 0; } .input:focus~.placeholder2 { top: -75px; right: -8px; font-size: 16px; font-weight: normal; color: #e4a8a8; background-color: rgb(26, 26, 26); opacity: 1; } input:not(:focus) { top: -60px; right: -2px; font-size: 14px; color: rgba(158, 89, 89, 0); } /*////////////////////// DIV ALIGNMENT SIDE BY SIDE ////////////////////////*/ .inline-block-child { display: inline-block; } .flex-parent { display: flex; } .flex-child { flex: 2 1 auto; } .inline-flex-parent { display: inline-flex; } /*//////////////// TOP NAV ///////////////// */ #box_active { font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 18px; font-weight: normal; color: #6461ff; } .no-underline { color: #ababab; text-decoration: none; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt; &lt;link rel="stylesheet" href="boxes.css"&gt; &lt;title&gt;Fruit box v1.0.2&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h4&gt;MY FRUITS&lt;/h4&gt; &lt;section&gt; &lt;span class="fade-item"&gt; &lt;div class="parent flex-parent"&gt; &lt;div class="child flex-child"&gt; &lt;div class="topnav"&gt; &lt;input type="text" id="linkBananas" class="input" maxlength="" value="" autofocus="autofocus" autocomplete="off"&gt; &lt;span class="placeholder"&gt;Search for bananas:&lt;/span&gt; &lt;span class="placeholder2"&gt;Insert banana number:&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &amp;nbsp;&amp;nbsp; &lt;div class="child flex-child"&gt; &lt;button id="linkBananas_BT" type="submit" class="form-submit-button" tabindex="-1"&gt;SEARCH&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/span&gt; &lt;/section&gt; &lt;!-- /// --&gt; &lt;section&gt; &lt;span class="fade-item"&gt; &lt;div class="parent flex-parent"&gt; &lt;div class="child flex-child"&gt; &lt;div class="topnav"&gt; &lt;input type="text" id="linkApples" class="input" maxlength="" value="" autofocus="autofocus" autocomplete="off"&gt; &lt;span class="placeholder"&gt;Search for apples:&lt;/span&gt; &lt;!--&lt;span class="placeholder2" &gt;Enter apple number:&lt;/span&gt; --&gt; &lt;/div&gt; &lt;/div&gt; &amp;nbsp;&amp;nbsp; &lt;div class="child flex-child"&gt; &lt;button id="linkApples_BT" type="submit" class="form-submit-button" tabindex="-1"&gt;SEARCH&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/span&gt; &lt;/section&gt; &lt;!-- /// --&gt; &lt;span class="fade-item"&gt; &lt;div class="parent flex-parent"&gt; &lt;div class="child flex-child"&gt; &lt;div class="topnav"&gt; &lt;input type="text" id="linkPeach" class="input" maxlength="" value="" autofocus="autofocus" autocomplete="off"&gt; &lt;span class="placeholder"&gt;Search for peach:&lt;/span&gt; &lt;span class="placeholder2"&gt;Enter peach number:&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &amp;nbsp;&amp;nbsp; &lt;div class="child flex-child"&gt; &lt;button id="linkPeach_BT" type="submit" class="form-submit-button" tabindex="-1"&gt;SEARCH&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/span&gt; &lt;!-- /// --&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74268071, "author": "Heretic Monkey", "author_id": 215552, "author_profile": "https://Stackoverflow.com/users/215552", "pm_score": 1, "selected": false, "text": "&nbsp;" }, { "answer_id": 74269896, "author": "Verminous", "author_id": 16498578, "author_p...
2022/10/31
[ "https://Stackoverflow.com/questions/74266434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16498578/" ]
74,266,440
<p>Suppose I have a method as follows...</p> <pre class="lang-cs prettyprint-override"><code>public static async Task DoIt(Func&lt;Task&gt; doit) { // Do something first await doit(); // Do something last } </code></pre> <p>I can pass in an awaitable function as follows...</p> <pre class="lang-cs prettyprint-override"><code>await DoIt(() =&gt; Task.Delay(1000)); </code></pre> <p>If I want to pass in something non-awaitable, I can do it like this...</p> <pre><code>_ = DoIt(() =&gt; Task.Run(() =&gt; Console.WriteLine(&quot;Hi&quot;))); </code></pre> <p>...but this seems quite ugly. Is there a neater way of doing this?</p>
[ { "answer_id": 74266495, "author": "John Wu", "author_id": 2791540, "author_profile": "https://Stackoverflow.com/users/2791540", "pm_score": 4, "selected": true, "text": "async void" }, { "answer_id": 74267277, "author": "Theodor Zoulias", "author_id": 11178549, "auth...
2022/10/31
[ "https://Stackoverflow.com/questions/74266440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/706346/" ]
74,266,465
<p>I am running a test for a component that needs to check if it has a particular CSS style. As the React Native Testing Library doesn't have this function by default, I installed the @testing-library/react-native to use toHaveStyle from there but while running a test I get an error: Test suite failed to run. Cannot find module '@testing-library/jest-native' from &quot;a path to my test file here&quot;. Here is my test and the jest config:</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>// test file import React from 'react'; import {toHaveStyle} from '@testing-library/jest-native'; describe('JobForm', () =&gt; { expect.extend({toHaveStyle}); // .... }); // package.json { //... "jest": { "preset": "react-native", "moduleFileExtensions": [ "ts", "tsx", "js", "jsx", "json", "node" ], "transformIgnorePatterns": [ "node_modules/(?!(jest-)?@?react-native|@react-native-community|@react-navigation|aws-amplify-react-native|@ui-kitten)" ], "setupFiles": [ "&lt;rootDir&gt;/jest.setup.js", "./node_modules/react-native-gesture-handler/jestSetup.js" ] } } //jest.setup.js import mockRNCNetInfo from '@react-native-community/netinfo/jest/netinfo-mock.js'; import mockAsyncStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock'; jest.mock('@react-native-community/netinfo', () =&gt; mockRNCNetInfo); jest.mock('@react-native-async-storage/async-storage', () =&gt; mockAsyncStorage);</code></pre> </div> </div> </p>
[ { "answer_id": 74266495, "author": "John Wu", "author_id": 2791540, "author_profile": "https://Stackoverflow.com/users/2791540", "pm_score": 4, "selected": true, "text": "async void" }, { "answer_id": 74267277, "author": "Theodor Zoulias", "author_id": 11178549, "auth...
2022/10/31
[ "https://Stackoverflow.com/questions/74266465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16537918/" ]
74,266,490
<p>When trying to reference another object, I get this error:</p> <blockquote> <p>Assets/Scripts/Gravity.cs(55,63): error CS1061: 'GameObject' does not contain a definition for 'mass' and no accessible extension method 'mass' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)</p> </blockquote> <p>I'm very new to unity and C# as a whole so I'm not sure what is going on here. Any help would be greatly appreciated.</p> <p>Here's the code</p> <pre><code>using System.Collections; using System.Collections.Generic; using UnityEngine; public class Gravity : MonoBehaviour { [SerializeField] private GameObject otherBody; public Vector3 initialVelocity; Vector3 currentVelocity; bool simulate = false; bool initial = false; public int mass; int constant; void Awake() { } // Start is called before the first frame update void Start() { constant = Global.GravitationalConstant; } // Update is called once per frame void Update() { constant = Global.GravitationalConstant; if (Input.GetKeyDown(KeyCode.Space)) { simulate = !simulate; if (initial == false) { currentVelocity = initialVelocity; } initial = true; } if (simulate) { GravityUpdate(); // currentVelocity = initialVelocity; } } void GravityUpdate() { float sqrDist = (otherBody.transform.position - transform.position).sqrMagnitude; Vector3 moveDir = (otherBody.transform.position - transform.position).normalized; Vector3 force = moveDir * constant * mass * otherBody.mass / sqrDist; currentVelocity += force * Time.deltaTime; transform.position += currentVelocity * Time.deltaTime; } } </code></pre> <p>I've tried making reference to the script name, as in - <code>otherBody.Gravity.mass</code> but it just then says that <code>Gravity</code> is undefined.</p>
[ { "answer_id": 74266495, "author": "John Wu", "author_id": 2791540, "author_profile": "https://Stackoverflow.com/users/2791540", "pm_score": 4, "selected": true, "text": "async void" }, { "answer_id": 74267277, "author": "Theodor Zoulias", "author_id": 11178549, "auth...
2022/10/31
[ "https://Stackoverflow.com/questions/74266490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20253509/" ]
74,266,509
<p>I'm searching for some icons for a flutter app. materialappPallete.com was introduced to me. but I can't find any icon part in. please guide me how can I have access to the icon part? thanks</p>
[ { "answer_id": 74266495, "author": "John Wu", "author_id": 2791540, "author_profile": "https://Stackoverflow.com/users/2791540", "pm_score": 4, "selected": true, "text": "async void" }, { "answer_id": 74267277, "author": "Theodor Zoulias", "author_id": 11178549, "auth...
2022/10/31
[ "https://Stackoverflow.com/questions/74266509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20019751/" ]
74,266,511
<p>I am making a blackjack simulator with python and are having problems with when the player want another card. To begin with the player gets a random sample of two numbers from a list and then get the option to take another card or not to. When the answer is yes another card is added to the random sample but it gets added as a list inside of the list.</p> <p>This is is the line when the answer is yes to another card.</p> <pre><code>if svar == &quot;JA&quot;: handspelare.append(random.sample(kortlek,1)) print(handspelare) </code></pre> <p>This returns, [5, 10, [13]] and it is this list inside of the list i want to get rid of so i can sum the numbers, any suggestions on how i can get rid of this?</p> <pre><code></code></pre>
[ { "answer_id": 74266567, "author": "DeepSpace", "author_id": 1453822, "author_profile": "https://Stackoverflow.com/users/1453822", "pm_score": 3, "selected": true, "text": "random.sample(kortlek,1)" }, { "answer_id": 74266571, "author": "Hoblovski", "author_id": 10538725,...
2022/10/31
[ "https://Stackoverflow.com/questions/74266511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19321160/" ]
74,266,527
<p>Is it possible to simplify the following so that when I have a new product type, I do not need to add another line of code for the new product type to initialize it? There is syntax error if I do not initialize the variable.</p> <pre><code>enum ProductType { PC = 'pc', LAPTOP = 'laptop', TV = 'tv' } let productList: { [key in ProductType]: Product[] | undefined } = { [ProductType.PC]: undefined, [ProductType.LAPTOP]: undefined, [ProductType.TV]: undefined } </code></pre>
[ { "answer_id": 74266567, "author": "DeepSpace", "author_id": 1453822, "author_profile": "https://Stackoverflow.com/users/1453822", "pm_score": 3, "selected": true, "text": "random.sample(kortlek,1)" }, { "answer_id": 74266571, "author": "Hoblovski", "author_id": 10538725,...
2022/10/31
[ "https://Stackoverflow.com/questions/74266527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2663857/" ]
74,266,566
<p>i am trying to build a spring boot app using JWT token, but it shows me this error</p> <pre><code>java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na] at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na] at io.jsonwebtoken.impl.Base64Codec.decode(Base64Codec.java:26) ~[jjwt-0.9.1.jar:0.9.1] at io.jsonwebtoken.impl.DefaultJwtBuilder.signWith(DefaultJwtBuilder.java:99) ~[jjwt-0.9.1.jar:0.9.1] at com.JavaInUseSpringSECURITY.JavaInUseSpringSECURITY.JWTTOKEN.JwtUtil.doGenerateToken(JwtUtil.java:49) ~[classes/:na] at com.JavaInUseSpringSECURITY.JavaInUseSpringSECURITY.JWTTOKEN.JwtUtil.generateToken(JwtUtil.java:43) ~[classes/:na] </code></pre> <hr /> <p>the JwtUtil class is : I am following everything from a guy using this strategy: <a href="https://www.javainuse.com/webseries/spring-security-jwt/chap4" rel="nofollow noreferrer">https://www.javainuse.com/webseries/spring-security-jwt/chap4</a></p> <pre><code>@Service public class JwtUtil { private String secret; private int jwtExpirationInMs; @Value(&quot;${jwt.secret}&quot;) public void setSecret(String secret) { this.secret = secret; } @Value(&quot;${jwt.jwtExpirationInMs}&quot;) public void setJwtExpirationInMs(int jwtExpirationInMs) { this.jwtExpirationInMs = jwtExpirationInMs; } // generate token for user public String generateToken(UserDetails userDetails) { Map&lt;String, Object&gt; claims = new HashMap&lt;&gt;(); Collection&lt;? extends GrantedAuthority&gt; roles = userDetails.getAuthorities(); if (roles.contains(new SimpleGrantedAuthority(&quot;ROLE_ADMIN&quot;))) { claims.put(&quot;isAdmin&quot;, true); } if (roles.contains(new SimpleGrantedAuthority(&quot;ROLE_USER&quot;))) { claims.put(&quot;isUser&quot;, true); } return doGenerateToken(claims, userDetails.getUsername()); } private String doGenerateToken(Map&lt;String, Object&gt; claims, String subject) { return Jwts.builder().setClaims(claims).setSubject(subject) .setIssuedAt(new Date(System.currentTimeMillis())) .setExpiration(new Date(System.currentTimeMillis() + jwtExpirationInMs)).signWith(SignatureAlgorithm.HS512, secret).compact(); } } </code></pre> <p>I was expecting to get the token from postman using POST,BODY,JSON and giving username and password, but i am getting :</p> <pre><code>{ &quot;timestamp&quot;: &quot;2022-10-31T16:35:00.188+00:00&quot;, &quot;status&quot;: 500, &quot;error&quot;: &quot;Internal Server Error&quot;, &quot;path&quot;: &quot;/authenticate&quot; } </code></pre>
[ { "answer_id": 74266923, "author": "Elbashir Saror", "author_id": 20033482, "author_profile": "https://Stackoverflow.com/users/20033482", "pm_score": 0, "selected": false, "text": " <dependency>\n <groupId>com.sun.xml.bind</groupId>\n <artifactId>jaxb-core</artifactId>\n ...
2022/10/31
[ "https://Stackoverflow.com/questions/74266566", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19441686/" ]
74,266,584
<p>How do I take an <code>iframe</code> if I have two with the same classes and neither <code>eq()</code> nor <code>first()</code> works when I use <code>cy.iframe()</code>.</p> <p>Here is the error:</p> <p><a href="https://i.stack.imgur.com/5VfVj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5VfVj.png" alt="" /></a></p> <p>Each radio is made up of a 'form' and inside each one contains the respective iframe.<br /> But I only want to take the one that is checked</p> <p><a href="https://i.stack.imgur.com/0qsZs.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0qsZs.jpg" alt="enter image description here" /></a>*</p> <p>This is my script</p> <p><a href="https://i.stack.imgur.com/yfL7y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yfL7y.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74266923, "author": "Elbashir Saror", "author_id": 20033482, "author_profile": "https://Stackoverflow.com/users/20033482", "pm_score": 0, "selected": false, "text": " <dependency>\n <groupId>com.sun.xml.bind</groupId>\n <artifactId>jaxb-core</artifactId>\n ...
2022/10/31
[ "https://Stackoverflow.com/questions/74266584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19679097/" ]
74,266,589
<p>For a web Application, when the user makes a choice of radio button on a previous unrelated field, I am trigerring location for the next step by calling attemptLocation().</p> <pre><code> const attemptLocation = () =&gt; { if (&quot;geolocation&quot; in navigator) { </code></pre> <p>The possible scenarios are:</p> <ol> <li>A popup appears in browser and user allows the location immediately - <code>Works !</code></li> <li>The user clicks on 'Block' and location is not available. The user then realizes that they cannot proceed so they click on the location icon in browser and <code>allow</code> location.</li> </ol> <p><strong>How to detect this change they made from <code>block</code> to <code>allow</code> in the browser</strong> because right now</p> <ul> <li><p>In Chrome: the page does not detect change to <code>allow</code> and users get stuck.</p> </li> <li><p>In Firefox: Unless the user clicks <code>remember this selection</code> the browser keeps asking the same <code>allow or not</code> question even when user said <code>allow</code> and refreshed the page.</p> </li> <li><p>In Edge: When the user changes to allow, location is updated and <code>works</code> but again only after they refresh the page and start over</p> </li> </ul> <p><strong>To simplify the question:</strong> After page loads, the user who blocked location, changes from block to allow location, how can I alert (&quot;thanks for changing from block location to allow location&quot;) ?</p>
[ { "answer_id": 74266674, "author": "Dev", "author_id": 20371423, "author_profile": "https://Stackoverflow.com/users/20371423", "pm_score": -1, "selected": false, "text": "useEffect()" }, { "answer_id": 74267044, "author": "Kal", "author_id": 3717114, "author_profile":...
2022/10/31
[ "https://Stackoverflow.com/questions/74266589", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3717114/" ]
74,266,618
<p>What I have right now is this, and I'd like to use less code to do the same function. How would I achieve the same output with less lines of code?</p> <pre><code> // img 1 hover var image = document.getElementById(&quot;rImg&quot;); image.addEventListener('mouseover', function(){ image.src = &quot;images/blackback.png&quot; }) image.addEventListener('mouseout', function(){ image.src = &quot;images/blackfront.png&quot; }) // img 2 hover var img2 = document.getElementById(&quot;rMImg&quot;); img2.addEventListener('mouseover', function(){ img2.src = &quot;images/greyback.png&quot; }) img2.addEventListener('mouseout', function(){ img2.src = &quot;images/greyfront.png&quot; }) // img 3 hover var img3 = document.getElementById(&quot;lMImg&quot;); img3.addEventListener('mouseover', function(){ img4.src = &quot;images/navyback.png&quot; }) img3.addEventListener('mouseout', function(){ img3.src = &quot;images/navyront.png&quot; }) </code></pre>
[ { "answer_id": 74266691, "author": "Roko C. Buljan", "author_id": 383904, "author_profile": "https://Stackoverflow.com/users/383904", "pm_score": 2, "selected": true, "text": "mouseenter/leave" }, { "answer_id": 74266721, "author": "rastiq", "author_id": 11248668, "au...
2022/10/31
[ "https://Stackoverflow.com/questions/74266618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20381202/" ]
74,266,641
<p>source: <a href="https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-POSIX-REGEXP" rel="nofollow noreferrer">https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-POSIX-REGEXP</a></p> <p>I'm trying to imitate the following 2 SQL queries in C. The first works; the second failed:</p> <pre class="lang-sql prettyprint-override"><code>SELECT regexp_match('hello world test', 'world.{3}'); SELECT regexp_match('foobarbequebaz', '(bar)(beque)'); </code></pre> <hr /> <pre><code>#include&lt;regex.h&gt; #include&lt;stdio.h&gt; #include&lt;string.h&gt; #include&lt;stdlib.h&gt; #define MAX_MATCHES 1024 int main(void) { regex_t regex; int reti; char msgbuf[100]; char buff0[20]; char buff[20]; char buff1[20]; char *sz1 = &quot;hello world test&quot;; //char *sz2= &quot;foobarbequebaz&quot;; char *pattern1 = &quot;world.{3}&quot;; //char *pattern2 = &quot;(bar)(beque)&quot;; regmatch_t matches[MAX_MATCHES]; /* Compile regular expression */ reti = regcomp(&amp;regex,pattern1,REG_EXTENDED); if(reti){ fprintf(stderr,&quot;could not compile\n&quot;); exit(EXIT_FAILURE); } reti = regexec(&amp;regex,sz1,MAX_MATCHES,matches,0); if(!reti){ printf(&quot;szso=%d\n&quot;,matches[1].rm_so); printf(&quot;szeo=%d\n&quot;,matches[1].rm_eo); memcpy(buff0,sz1+matches[0].rm_so,matches[0].rm_eo-matches[0].rm_so); memcpy(buff,sz1+matches[1].rm_so,matches[1].rm_eo-matches[1].rm_so); memcpy(buff1,sz1+matches[2].rm_so,matches[2].rm_eo-matches[2].rm_so); printf(&quot;group0: %s\n&quot;,buff0); printf(&quot;group1: %s\n&quot;,buff); printf(&quot;group2: %s\n&quot;,buff1); } else if(reti == REG_NOMATCH){ puts(&quot;No match&quot;); } else{ regerror(reti,&amp;regex,msgbuf,sizeof(msgbuf)); fprintf(stderr,&quot;Regex match failed: %s\n&quot;,msgbuf); exit(EXIT_FAILURE); } regfree(&amp;regex); exit(EXIT_SUCCESS); } </code></pre> <hr /> <p>output</p> <pre><code>szso=3 szeo=11 group1: barbeque </code></pre> <p>expect two groups, so group1 only return <code>bar</code>.</p> <hr /> <p>Update to the question:</p> <ul> <li><code>pattern2</code> match again <code>sz2</code> behavior as expected.</li> <li>However, if only if only one part of the pattern matches then <code>matches[0]</code> should be the same as <code>matches[1]</code>.</li> <li>So in this new context, should I expect <code>group0</code> is the same as <code>group1</code>?</li> </ul>
[ { "answer_id": 74266708, "author": "nwellnhof", "author_id": 1956010, "author_profile": "https://Stackoverflow.com/users/1956010", "pm_score": 1, "selected": false, "text": "matches[0]" }, { "answer_id": 74267296, "author": "Jonathan Leffler", "author_id": 15168, "aut...
2022/10/31
[ "https://Stackoverflow.com/questions/74266641", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15603477/" ]
74,266,658
<p>Python/numpy beginner so this should be easy to solve. Given a numpy 2d array of floats <code>map</code>, e.g.</p> <pre><code>map = [[0.19982308 0.19982308 0.19986019 ... 0.25456086 0.25463998 0.25463998] [0.19982308 0.19982308 0.19986019 ... 0.25456086 0.25463998 0.25463998] [0.19998285 0.19998285 0.20000038 ... 0.25459546 0.25466287 0.25466287] ... [0.4762167 0.4762167 0.47602317 ... 0.45300224 0.4541465 0.4541465 ] [0.4767613 0.4767613 0.47632453 ... 0.45406988 0.45538843 0.45538843] [0.4767613 0.4767613 0.47632453 ... 0.45406988 0.45538843 0.45538843]] </code></pre> <p>I want to carry out this operation:</p> <pre><code>new_map = np.where(map &gt; 0.4, [255,255,255], [0,0,0]) </code></pre> <p>That is, I want to create a new 2d array of the same dimensions but with RGB values instead of floats. Which RGB value is assigned to <code>new_map[x][y]</code> - white = [255,255,255] or black = [0,0,0] - is determined by whether <code>map[x][y]</code> is above a threshold (0.4 in the case above).</p> <p>I get the following error message: <code>operands could not be broadcast together with shapes (512,512) (3,) (3,)</code></p> <p>I think I understand why - <code>np.where</code> restricts to the dimensions of <code>map</code> and I'm in effect trying to increase those dimensions by substituting the float for a nested array of length three.</p> <p>Is there a workaround for this issue using <code>where</code> or any other numpy operation? Thanks!</p>
[ { "answer_id": 74266738, "author": "Ulises Bussi", "author_id": 17194418, "author_profile": "https://Stackoverflow.com/users/17194418", "pm_score": 2, "selected": false, "text": "import numpy as np\n#import matplotlib.pyplot as plt\n\n#create map\nmap = np.random.rand(200,200)\n\n#to sho...
2022/10/31
[ "https://Stackoverflow.com/questions/74266658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11853066/" ]
74,266,692
<p>my goal is to get the max of two lists, for instance : list a -[1,2,3] list b - [0,4,1]</p> <p>the desire resuls: 1,4,3 <a href="https://i.stack.imgur.com/uKjp9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uKjp9.png" alt="enter image description here" /></a></p> <pre><code> </code></pre> <p>def ddh(a,b): v=[]</p> <pre><code>for i,j in range(len(a),len(b)): if a[i]&gt;b[j]: v.append (a[i]) else: v.append (b[j]) return v </code></pre> <p>a=[1,2,555,9999] b=[22,4,444] ddh(a,b)</p> <pre><code> </code></pre> <p>I tried to run the code and got just []</p>
[ { "answer_id": 74266740, "author": "DeepSpace", "author_id": 1453822, "author_profile": "https://Stackoverflow.com/users/1453822", "pm_score": 3, "selected": false, "text": "zip" }, { "answer_id": 74266744, "author": "Tom McLean", "author_id": 14720380, "author_profil...
2022/10/31
[ "https://Stackoverflow.com/questions/74266692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20381268/" ]
74,266,694
<p>It seems that in virtual inheritance, operator= and copy constructor are treated differently. Consider the following code:</p> <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt; #include &lt;ostream&gt; class A { public: A(int x) : x(x) { std::cout &lt;&lt; &quot;A is initialized&quot; &lt;&lt; std::endl; } A(const A&amp; rhs) { std::cout &lt;&lt; &quot;Copy constructor for A&quot; &lt;&lt; std::endl; } A&amp; operator=(const A&amp; rhs) { std::cout &lt;&lt; &quot;A::operator=()&quot; &lt;&lt; std::endl; return *this; } virtual void funcB() = 0; virtual void funcC() = 0; int x; }; class B : virtual public A { public: B(int x) { std::cout &lt;&lt; &quot;B is initialized&quot; &lt;&lt; std::endl; } B(const B&amp; rhs) { std::cout &lt;&lt; &quot;Copy constructor for B&quot; &lt;&lt; std::endl; } B&amp; operator=(const B&amp; rhs) { std::cout &lt;&lt; &quot;B::operator=()&quot; &lt;&lt; std::endl; return *this; } void funcB() override { std::cout &lt;&lt; &quot;B&quot; &lt;&lt; std::endl; } void funcC() override = 0; }; class C : public B { public: C(int x) : A(x + 1), B(x) { std::cout &lt;&lt; &quot;C is initialized&quot; &lt;&lt; std::endl; } void funcC() override { std::cout &lt;&lt; &quot;C&quot; &lt;&lt; std::endl; } }; int main() { C c(1); C c2(c); c2 = c; std::cout &lt;&lt; c.x; } </code></pre> <p>Here B inherit virtually from A and C inherit from B. The output is:</p> <pre><code>A is initialized B is initialized C is initialized Copy constructor for A Copy constructor for B B::operator=() 2 </code></pre> <p>We can see that the default copy constructor of C has successfully called the copy constructor for both B and A, which is what I want. But the default operator= did not call operator= of A, which is strange.</p> <p>A possible explanation to this is that the copy constructor of A is called by B, not C. However, since I have deliberately made B pure virtual, I don't have to initialize A in the copy constructor of B and in fact I did not. So the copy constructor of A is called most likely from C, but I have no proof of it since A will be initialized before B anyway, no matter who calls its constructor.</p>
[ { "answer_id": 74266979, "author": "i chik", "author_id": 8959935, "author_profile": "https://Stackoverflow.com/users/8959935", "pm_score": 0, "selected": false, "text": "c2 = c;" }, { "answer_id": 74267203, "author": "apple apple", "author_id": 5980430, "author_profi...
2022/10/31
[ "https://Stackoverflow.com/questions/74266694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12984075/" ]
74,266,700
<p>as i searched i used this command: <code>npx create-react-app my-react-app </code> and here what i got:</p> <p><a href="https://i.stack.imgur.com/mhj13.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mhj13.png" alt="enter image description here" /></a></p> <p>it says <strong>Need to install the following packages: <code>create-react-app@5.0.1</code></strong></p> <p>so, i used the command <code>create-react-app@5.0.1 </code> and the result is:</p> <p><a href="https://i.stack.imgur.com/mbS2C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mbS2C.png" alt="enter image description here" /></a></p> <p>because of this problem i can not have a react environment. How can i fix this?</p> <p>editttt for the guy who says just click (Y) for the first picture i already did that many times and it does not work <a href="https://i.stack.imgur.com/yKAVV.png" rel="nofollow noreferrer">enter image description here</a></p>
[ { "answer_id": 74266737, "author": "habby", "author_id": 8574562, "author_profile": "https://Stackoverflow.com/users/8574562", "pm_score": -1, "selected": false, "text": "npm install -g create-react-app@latest" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74266700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15926838/" ]
74,266,727
<p>I have built this small HTML file you can see here <a href="https://alterego.cc/mypublicip/" rel="nofollow noreferrer">https://alterego.cc/mypublicip/</a> that returns your public IP. If you inspect the code of the page you can actually see the HTML in there, because that's an HTML file of course</p> <p>What I would actually like to achieve is something like this <a href="https://wtfismyip.com/text" rel="nofollow noreferrer">https://wtfismyip.com/text</a> (from someone else) where if you inspect the code you can see it's just a text file there. No additional tags or anything in particular</p> <p>How could I achieve the same result?</p> <p>I have tried a bit of everything but I always end up having some HTML code in there. In particular with DIV and innerText but no particular luck so far. I believe I am following the wrong approach and there is something I am missing</p> <p>Thanks!</p>
[ { "answer_id": 74266737, "author": "habby", "author_id": 8574562, "author_profile": "https://Stackoverflow.com/users/8574562", "pm_score": -1, "selected": false, "text": "npm install -g create-react-app@latest" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74266727", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20381241/" ]
74,266,797
<p>I have a list like this:</p> <pre><code>lista=['a','b','b','c','d','e','c','e','b','b'] </code></pre> <p>note that the list will be filled from another source, so I can't know the items nor number</p> <p>what I need is this result:</p> <pre><code>['a','b','b_1','c','d','e','c_1','e_1','b_2','b_3'] </code></pre> <p>I tried with recursive checks but it doesn't garantee that all recurrancies are detected... thanks in advance!!</p>
[ { "answer_id": 74266843, "author": "j1-lee", "author_id": 11450820, "author_profile": "https://Stackoverflow.com/users/11450820", "pm_score": 3, "selected": false, "text": "lista = ['a','b','b','c','d','e','c','e','b','b']\n\noutput = []\ncounter = {}\n\nfor x in lista:\n if x in coun...
2022/10/31
[ "https://Stackoverflow.com/questions/74266797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11497899/" ]
74,266,804
<p>I am attempting leetcode merging of sorted linkedlist</p> <p>I have just discovered a mistake of my code that I placed <code>list1 = list1.next</code> right before the <code>result.next = list1</code>, causing the code to caused an infinite loop. However, I tried to trace and still don't understand how the logic caused an infinite loop.</p> <p><strong>Wrong Solution</strong></p> <pre><code> // Loop until list1 and list2 is not empty while (list1 != null &amp;&amp; list2 != null) { if (list1.val &lt; list2.val) { list1 = list1.next; result.next = list1; } else { list2 = list2.next; result.next = list2; } System.out.println(list2.val); result = result.next; } </code></pre> <p><strong>Correct Solution</strong></p> <pre><code> while (list1 != null &amp;&amp; list2 != null) { if (list1.val &lt; list2.val) { result.next = list1; list1 = list1.next; } else { result.next = list2; list2 = list2.next; } System.out.println(list2.val); result = result.next; } </code></pre> <p>Can someone enlighten me why does the placement of list1 = list1.next and list2 = list2.next, will caused an infinite loop? Here are my debugging attempts</p> <p><a href="https://i.stack.imgur.com/mvRw9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mvRw9.png" alt="1) The 2nd last iteration" /></a></p> <p><a href="https://i.stack.imgur.com/KujoG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KujoG.png" alt="The final iteration" /></a></p> <p>As you can see the two images, represents the value of the result linkedlist, which will continuously loop through the value of 4,2,3 -&gt; 2,4,2 -&gt; 4,2,3 -&gt; 2,4,2 .... vice versa.</p> <p>Finally here is my input 1,2,4 1,3,4</p>
[ { "answer_id": 74267090, "author": "Vaibhav Kumar", "author_id": 2321572, "author_profile": "https://Stackoverflow.com/users/2321572", "pm_score": 0, "selected": false, "text": "System.out.println(list2.val);\n" }, { "answer_id": 74267319, "author": "trincot", "author_id"...
2022/10/31
[ "https://Stackoverflow.com/questions/74266804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2047436/" ]
74,266,816
<p>I have two lists.</p> <p>The first list is the authors' list. The second list has two types of objects, authors and text. Text is split into words. The structure of the second list is that there is an author first and several words which together make his speech. In the second list there are several authors with their speeches.</p> <pre><code>authors = ['M. Maxime Gremet', 'M. le président.', 'M.Claude Goasgu', 'M.Jean-Marc Ayr', 'M.Maxime Gremet', 'M.Roland Chassa', 'M.le président.'] </code></pre> <pre><code>authors_and_words = ['M. le président.', &quot;Conformément au premier alinéa de l'article 28 de la Constitution, je déclare ouverte la session ordinaire de 2003-2004.&quot;, &quot;Mes chers collègues, permettez-moi d'abord de vous dire combien je suis heureux de vous retrouver tous.&quot;, 'M. Maxime Gremetz.', 'Nous aussi !'] </code></pre> <p>I would like to extract an author and the words of his speech from the second list into a new list (or even better a dictionary).</p> <p>Output dictionary would be of the following structure:</p> <pre><code>{'author': ['word1', 'word2', 'word3']} </code></pre> <p>If we take the actual lists, the solution would be the following list.</p> <pre><code>solution = [{'M. le président.': [&quot;Conformément au premier alinéa de l'article 28 de la Constitution, je déclare ouverte la session ordinaire de 2003-2004.&quot;, &quot;Mes chers collègues, permettez-moi d'abord de vous dire combien je suis heureux de vous retrouver tous.&quot;]}, {'M. Maxime Gremetz.':['Nous aussi !']}] </code></pre> <p>I tried to do with different types of loops but I struggle to keep the state of the second list. I guess there is an algorithimic solution for this, but unfortunately I don't have much experience with algorithms.</p>
[ { "answer_id": 74266991, "author": "Pranav Hosangadi", "author_id": 843953, "author_profile": "https://Stackoverflow.com/users/843953", "pm_score": 2, "selected": true, "text": "authors_and_words" }, { "answer_id": 74272070, "author": "LLaP", "author_id": 2758414, "au...
2022/10/31
[ "https://Stackoverflow.com/questions/74266816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2758414/" ]
74,266,830
<p><code>emp_record_change_log_tbl</code> has the following columns. I want the query to be like this, where &quot;SQL code needed&quot; will be the query to get the name of the person who entered the first record for a specific employee.</p> <p><a href="https://i.stack.imgur.com/O1dsa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/O1dsa.png" alt="enter image description here" /></a></p> <pre class="lang-sql prettyprint-override"><code>Select change_id, Emp_ID, new salary, {sql code needed} as first_entered_by from emp_record_change_log_tbl </code></pre> <p>I know that at some point I will need a min function to first get the initial date.</p> <p>But the result I am hoping for is to get John doe for employee 103 and Sarah Smith for employee 102.</p>
[ { "answer_id": 74266950, "author": "Derrick Moeller", "author_id": 3194005, "author_profile": "https://Stackoverflow.com/users/3194005", "pm_score": 2, "selected": false, "text": "SELECT DISTINCT t.Emp_ID, last_modifiedby, last_modifieddate\nFROM emp_record_change_log_tbl t\nCROSS APPLY ...
2022/10/31
[ "https://Stackoverflow.com/questions/74266830", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8594588/" ]
74,266,871
<p>I was wondering if there was a way to automate/condense adding the specific classes &quot;.header-child-accordion .header-child-accordion-set-(incrementing number)&quot; to sibling divs that exist between two controlling sibling divs that contain the class &quot;.mv-header-menu-accordion-(incrementing number)&quot; as opposed to manually dictating the classes from one controlling sibling div to another.</p> <p>I have done this one by one through identifying if there is, for example, a div that contains &quot;.mv-header-menu-accordion-11&quot; nextUntil &quot;.mv-header-menu-accordion-12&quot;.</p> <p>Is there a way to: $('.mv-header-menu-accordion- + (i+1)').nextUntil('.mv-header-menu-accordion-+ ((i+1)+1)').addClass(&quot;header-child-accordion header-child-accordion-set-+ (i+1)&quot;);</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).ready(function() { $(".header-menu-nav-folder-content").each(function() { $(this).find('.mv-header-menu-accordion').each(function() { $('.mv-header-menu-accordion-1').nextUntil('.mv-header-menu-accordion-2').addClass("header-child-accordion header-child-accordion-set-1"); $('.mv-header-menu-accordion-2').nextUntil('.mv-header-menu-accordion-3').addClass("header-child-accordion header-child-accordion-set-2"); $('.mv-header-menu-accordion-3').nextUntil('.mv-header-menu-accordion-4').addClass("header-child-accordion header-child-accordion-set-3"); $('.mv-header-menu-accordion-4').nextUntil('.mv-header-menu-accordion-5').addClass("header-child-accordion header-child-accordion-set-4"); $('.mv-header-menu-accordion-5').nextUntil('.mv-header-menu-accordion-6').addClass("header-child-accordion header-child-accordion-set-5"); $('.mv-header-menu-accordion-6').nextUntil('.mv-header-menu-accordion-7').addClass("header-child-accordion header-child-accordion-set-6"); $('.mv-header-menu-accordion-7').nextUntil('.mv-header-menu-accordion-8').addClass("header-child-accordion header-child-accordion-set-7"); $('.mv-header-menu-accordion-8').nextUntil('.mv-header-menu-accordion-9').addClass("header-child-accordion header-child-accordion-set-8"); $('.mv-header-menu-accordion-9').nextUntil('.mv-header-menu-accordion-10').addClass("header-child-accordion header-child-accordion-set-9"); $('.mv-header-menu-accordion-10').nextUntil('.mv-header-menu-accordion-11').addClass("header-child-accordion header-child-accordion-set-10"); $('.mv-header-menu-accordion-11').nextUntil('.mv-header-menu-accordion-12').addClass("header-child-accordion header-child-accordion-set-11"); }); }); });</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt; &lt;div class="header-menu-nav-folder-content"&gt; &lt;div class="mv-header-menu-accordion-1 mv-header-menu-accordion"&gt; &lt;p&gt;Parent 1&lt;/p&gt; &lt;/div&gt; &lt;div class=""&gt; &lt;p&gt;Child 1&lt;/p&gt; &lt;/div&gt; &lt;div class=""&gt; &lt;p&gt;Child 2&lt;/p&gt; &lt;/div&gt; &lt;div class=""&gt; &lt;p&gt;Child 3&lt;/p&gt; &lt;/div&gt; &lt;div class="mv-header-menu-accordion-2 mv-header-menu-accordion"&gt; &lt;p&gt;Parent 2&lt;/p&gt; &lt;/div&gt; &lt;div class=""&gt; &lt;p&gt;Child 1&lt;/p&gt; &lt;/div&gt; &lt;div class=""&gt; &lt;p&gt;Child 2&lt;/p&gt; &lt;/div&gt; &lt;div class=""&gt; &lt;p&gt;Child 3&lt;/p&gt; &lt;/div&gt; &lt;div class="mv-header-menu-accordion-3 mv-header-menu-accordion"&gt; &lt;p&gt;Parent 3&lt;/p&gt; &lt;/div&gt; &lt;div class=""&gt; &lt;p&gt;Child 1&lt;/p&gt; &lt;/div&gt; &lt;div class=""&gt; &lt;p&gt;Child 2&lt;/p&gt; &lt;/div&gt; &lt;div class=""&gt; &lt;p&gt;Child 3&lt;/p&gt; &lt;/div&gt; &lt;div class="mv-header-menu-accordion-4 mv-header-menu-accordion"&gt; &lt;p&gt;Parent 4&lt;/p&gt; &lt;/div&gt; &lt;div class=""&gt; &lt;p&gt;Child 1&lt;/p&gt; &lt;/div&gt; &lt;div class=""&gt; &lt;p&gt;Child 2&lt;/p&gt; &lt;/div&gt; &lt;div class=""&gt; &lt;p&gt;Child 3&lt;/p&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74267144, "author": "Mister Jojo", "author_id": 10669010, "author_profile": "https://Stackoverflow.com/users/10669010", "pm_score": 0, "selected": false, "text": "const\n grpCls = '.mv-header-menu-accordion-'\n, clsAdd = 'header-child-accordion header-child-accordion-set-...
2022/10/31
[ "https://Stackoverflow.com/questions/74266871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14926793/" ]
74,266,915
<p>I'm trying to use JSONata to convert arrays of &quot;key/value&quot; objects into properties of the parent object. My input looks like this:</p> <pre class="lang-json prettyprint-override"><code>[ { &quot;city&quot;: &quot;Ottawa&quot;, &quot;properties&quot;: [ { &quot;name&quot;: &quot;population&quot;, &quot;value&quot;: 37 }, { &quot;name&quot;: &quot;postalCode&quot;, &quot;value&quot;: 10001 }, { &quot;name&quot;: &quot;founded&quot;, &quot;value&quot;: 1826 } ] }, { &quot;city&quot;: &quot;Toronto&quot;, &quot;properties&quot;: [ { &quot;name&quot;: &quot;population&quot;, &quot;value&quot;: 54 }, { &quot;name&quot;: &quot;postalCode&quot;, &quot;value&quot;: 10002 } ] } ] </code></pre> <p>I'm struggling to generate the output I need, I've seen examples that reference explicit elements, <a href="https://stackoverflow.com/a/59171614/13114951">like in this answer</a>, but I need the properties to be converted &quot;dynamically&quot; since I don't know them in advance. I think I need something like this, but I'm missing some particular function:</p> <pre class="lang-js prettyprint-override"><code>$[].{ &quot;city&quot;: city, properties.name: properties.value } </code></pre> <p>This is the output I need to generate:</p> <pre class="lang-json prettyprint-override"><code>[ { &quot;city&quot;: &quot;Ottawa&quot;, &quot;population&quot;: 37, &quot;postalCode&quot;: 10001, &quot;founded&quot;: 1826 }, { &quot;city&quot;: &quot;Toronto&quot;, &quot;population&quot;: 54, &quot;postalCode&quot;: 10002 } ] </code></pre> <p>The <code>properties</code> arrays don't always contain the same keys, but the <code>city</code> attributes are always present.</p>
[ { "answer_id": 74267136, "author": "sanurah", "author_id": 4079056, "author_profile": "https://Stackoverflow.com/users/4079056", "pm_score": -1, "selected": false, "text": " $[].{\n \"city\": $.city,\n $.properties[0].name: $.properties[0].value,\n $.properties[1].name: $.proper...
2022/10/31
[ "https://Stackoverflow.com/questions/74266915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13114951/" ]
74,266,921
<p>I tried to implement custom Linq Chunk function and found this code example <code>This function should separate IEnumerable into IEnumerable of concrete size</code></p> <pre><code>public static class EnumerableExtentions { public static IEnumerable&lt;IEnumerable&lt;T&gt;&gt; Batch&lt;T&gt;(this IEnumerable&lt;T&gt; source, int size) { using (var enumerator = source.GetEnumerator()) { while (enumerator.MoveNext()) { int i = 0; IEnumerable&lt;T&gt; Batch() { do yield return enumerator.Current; while (++i &lt; size &amp;&amp; enumerator.MoveNext()); } yield return Batch(); } } } } </code></pre> <p>So, I have a question.Why when I try to execute some Linq operation on the result, they are incorrect? For example:</p> <pre><code>IEnumerable&lt;int&gt; list = Enumerable.Range(0, 10); Console.WriteLine(list.Batch(2).Count()); // 10 instead of 5 </code></pre> <p>I have an assumption, that it happens because inner IEnumerable Batch() is only triggered when Count() is called, and something goes wrong there, but I don't know what exactly.</p>
[ { "answer_id": 74267157, "author": "Rivo R.", "author_id": 18123471, "author_profile": "https://Stackoverflow.com/users/18123471", "pm_score": -1, "selected": false, "text": "public static IEnumerable<IEnumerable<T>> Batch<T>(this IEnumerable<T> arr, int size)\n{\n for (var i = 0; i < a...
2022/10/31
[ "https://Stackoverflow.com/questions/74266921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17009170/" ]
74,266,931
<p>I would like to filter the json object while iterating through it and run curl command over each item from the output.</p> <p>JSON object.</p> <pre><code>{ &quot;repo&quot;: &quot;releases&quot;, &quot;path&quot;: &quot;/apps/releases&quot;, &quot;created&quot;: &quot;2021-04-01T10:12:23.496-01:00&quot;, &quot;children&quot;: [ { &quot;uri&quot;: &quot;/Image1&quot;, &quot;folder&quot;: true, &quot;created&quot;: 2022-08-09T17.12.22.987.04.000 }, { &quot;uri&quot;: &quot;/Image2&quot;, &quot;folder&quot;: true, &quot;created&quot;: 2022-06-10T10.12.22.412.10.000 }, { &quot;uri&quot;: &quot;/Image3&quot;, &quot;folder&quot;: true, &quot;created&quot;: 2022-10-10T07.03.14.742.01.000 }, { &quot;uri&quot;: &quot;/Image4&quot;, &quot;folder&quot;: true, &quot;created&quot;: 2022-10-10T07.010.11.542.08.000 } ] } </code></pre> <p>Looking for some logic that will iterate through the uri under children and that is passed through curl command as $i which would be Image1, Image2 and Image3.</p> <pre><code>curl -k -s --user user:password -X GET &quot;https://artifactory.com/api/releases/baseimage/${i}&quot; </code></pre> <p>While I was running this below command and the output is as follows</p> <pre><code>for i in $(curl -k -s --user user:password -X GET &quot;https://artifactory.com/api/releases/baseimage/&quot; | jq -c &quot;.children[] |.uri) </code></pre> <p>Output: [&quot;/Image1&quot;, &quot;/Image2&quot;, &quot;/Image3&quot;]</p> <p>I tried the following command but in the output it replaces ${i} with only Image3, somehow it is not taking Image1 and Image2.</p> <pre><code>for i in $(curl -k -s --user user:password -X GET &quot;https://artifactory.com/api/releases/baseimage/&quot; | jq -r &quot;.children[] |.uri); do curl -k -s --user user:password -X GET &quot;https://artifactory.com/api/releases/baseimage/${i}&quot;; done </code></pre> <p>I tried the following command but in the output it replaces ${i} with only Image3, somehow it is not taking Image1 and Image2.</p>
[ { "answer_id": 74267157, "author": "Rivo R.", "author_id": 18123471, "author_profile": "https://Stackoverflow.com/users/18123471", "pm_score": -1, "selected": false, "text": "public static IEnumerable<IEnumerable<T>> Batch<T>(this IEnumerable<T> arr, int size)\n{\n for (var i = 0; i < a...
2022/10/31
[ "https://Stackoverflow.com/questions/74266931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8453197/" ]
74,266,952
<p>I want to create a dataframe <code>pathways</code> with two columns:</p> <ol> <li><code>Genes</code>: All the genes that are in the <code>Genes</code> column of the <code>enriched</code> data frame.</li> <li><code>Pathways</code>: The rownames of <code>enriched</code> that correspond to each gene; the gene may appear in more than one row.</li> </ol> <p>I'm not sure where to begin.</p> <p>How I generated the <code>enriched</code> data frame:</p> <pre><code>rownames(enrich.top5) &lt;- enrich.top5[,2] enrich.top5[,2] &lt;- NULL enriched &lt;- data.frame(do.call('rbind', strsplit(as.character(enrich.top5$Genes),';',fixed=TRUE))) rownames(enriched) &lt;- rownames(enrich.top5) </code></pre> <p><code>enriched</code></p> <pre><code>&gt; dput(enriched[1:5,1:20]) structure(list(X1 = c(&quot;CALML6&quot;, &quot;ATF2&quot;, &quot;MYLK2&quot;, &quot;ATF2&quot;, &quot;PRDM4&quot; ), X2 = c(&quot;CALML3&quot;, &quot;ARAF&quot;, &quot;ITGA2B&quot;, &quot;PPP2R2A&quot;, &quot;CALML6&quot;), X3 = c(&quot;CALML4&quot;, &quot;ELK1&quot;, &quot;TNC&quot;, &quot;TCL1B&quot;, &quot;IRS1&quot;), X4 = c(&quot;ACTB&quot;, &quot;CRKL&quot;, &quot;ELK1&quot;, &quot;TCL1A&quot;, &quot;CALML3&quot;), X5 = c(&quot;CRKL&quot;, &quot;ELK4&quot;, &quot;ACTB&quot;, &quot;PPP2R1B&quot;, &quot;CALML4&quot;), X6 = c(&quot;AKT2&quot;, &quot;RPS6KA4&quot;, &quot;MYLK3&quot;, &quot;PPP2R1A&quot;, &quot;CRKL&quot; ), X7 = c(&quot;RASSF5&quot;, &quot;RPS6KA3&quot;, &quot;CRKL&quot;, &quot;CREB3L4&quot;, &quot;RPS6KA3&quot;), X8 = c(&quot;AKT3&quot;, &quot;RPS6KA6&quot;, &quot;MYLK&quot;, &quot;CREB3L1&quot;, &quot;RPS6KA6&quot;), X9 = c(&quot;KDR&quot;, &quot;RPS6KA5&quot;, &quot;ACTG1&quot;, &quot;MYC&quot;, &quot;RPS6KA5&quot;), X10 = c(&quot;AKT1&quot;, &quot;MYC&quot;, &quot;IGF1R&quot;, &quot;AKT2&quot;, &quot;AKT2&quot;), X11 = c(&quot;PLCE1&quot;, &quot;AKT2&quot;, &quot;MYLK4&quot;, &quot;MYB&quot;, &quot;ARHGDIA&quot;), X12 = c(&quot;PRKCG&quot;, &quot;RPS6KA2&quot;, &quot;PPP1CB&quot;, &quot;CREB3L2&quot;, &quot;RPS6KA2&quot;), X13 = c(&quot;PRKCI&quot;, &quot;AKT3&quot;, &quot;COMP&quot;, &quot;AKT3&quot;, &quot;AKT3&quot;), X14 = c(&quot;PRKCB&quot;, &quot;STMN1&quot;, &quot;PPP1CC&quot;, &quot;KDR&quot;, &quot;RPS6KA1&quot; ), X15 = c(&quot;PRKCA&quot;, &quot;RPS6KA1&quot;, &quot;CCND3&quot;, &quot;AKT1&quot;, &quot;ARHGDIB&quot; ), X16 = c(&quot;TIAM1&quot;, &quot;KDR&quot;, &quot;CCND2&quot;, &quot;FLT3LG&quot;, &quot;AKT1&quot;), X17 = c(&quot;ADCY9&quot;, &quot;AKT1&quot;, &quot;CCND1&quot;, &quot;PRKCA&quot;, &quot;MAP3K5&quot;), X18 = c(&quot;PRKD3&quot;, &quot;PRKACA&quot;, &quot;IBSP&quot;, &quot;EREG&quot;, &quot;MAP2K1&quot;), X19 = c(&quot;PARD3&quot;, &quot;PRKACB&quot;, &quot;TNN&quot;, &quot;CDC37&quot;, &quot;MAP2K2&quot;), X20 = c(&quot;PFN4&quot;, &quot;PRKCG&quot;, &quot;AKT2&quot;, &quot;DDIT4&quot;, &quot;PRKCD&quot;)), row.names = c(&quot;Rap1 signaling pathway&quot;, &quot;MAPK signaling pathway&quot;, &quot;Focal adhesion&quot;, &quot;PI3K-Akt signaling pathway&quot;, &quot;Neurotrophin signaling pathway&quot; ), class = &quot;data.frame&quot;) </code></pre> <p>Desired output (example only):</p> <pre><code>pathways = data.frame( Genes = c( &quot;TP53&quot;, &quot;WT1&quot;, &quot;PHF6&quot;, &quot;DNMT3A&quot;, &quot;DNMT3B&quot;, &quot;TET1&quot;, &quot;TET2&quot;, &quot;IDH1&quot;, &quot;IDH2&quot;, &quot;FLT3&quot;, &quot;KIT&quot;, &quot;KRAS&quot;, &quot;NRAS&quot;, &quot;RUNX1&quot;, &quot;CEBPA&quot;, &quot;ASXL1&quot;, &quot;EZH2&quot;, &quot;KDM6A&quot; ), Pathway = rep(c( &quot;TSG&quot;, &quot;DNAm&quot;, &quot;Signalling&quot;, &quot;TFs&quot;, &quot;ChromMod&quot; ), c(3, 6, 4, 2, 3)), stringsAsFactors = FALSE ) head(pathways) #&gt; Genes Pathway #&gt; 1 TP53 TSG #&gt; 2 WT1 TSG #&gt; 3 PHF6 TSG #&gt; 4 DNMT3A DNAm #&gt; 5 DNMT3B DNAm #&gt; 6 TET1 DNAm </code></pre>
[ { "answer_id": 74266981, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 2, "selected": false, "text": "as.data.frame(as.table(as.matrix(enriched)))[-2]\n" }, { "answer_id": 74267043, "author": "TarJae", "a...
2022/10/31
[ "https://Stackoverflow.com/questions/74266952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20076555/" ]
74,266,973
<p>I want to write for WooCommerce product features with .. alert and I need help to complete the code</p> <p>If the user selects a variable from the available product and one of the variables selected by the user is null, I want to show a warning to the user.</p> <p>`</p> <pre><code>&lt;?php // PHP program to pop an alert // message box on the screen // Display the alert box echo '&lt;script&gt;alert(&quot;Welcome to Geeks for Geeks&quot;)&lt;/script&gt;'; ?&gt; </code></pre> <p>`</p> <p>` this is my code</p>
[ { "answer_id": 74266981, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 2, "selected": false, "text": "as.data.frame(as.table(as.matrix(enriched)))[-2]\n" }, { "answer_id": 74267043, "author": "TarJae", "a...
2022/10/31
[ "https://Stackoverflow.com/questions/74266973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20381413/" ]
74,267,000
<p>How to increase this number(you can try it on the browser console):</p> <pre><code>36893488147419103000 + 1 </code></pre> <p>The result of this is:</p> <pre><code>36893488147419103000 </code></pre> <p>The number stays the same no changes to it why is that? and how can I increase it by 1?</p>
[ { "answer_id": 74267082, "author": "Ben Aston", "author_id": 38522, "author_profile": "https://Stackoverflow.com/users/38522", "pm_score": 2, "selected": false, "text": "BigInt" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74267000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8732597/" ]
74,267,062
<p>I updated drupal from 9.2.7 to latest version using composer. The update was completed but the site throws &quot;This site currently unable to handle this request.HTTP ERROR 500&quot; I changed the owner as &quot;sudo chown -R username:groupname &lt;drupal_directory&gt;&quot; with backup's username and password. But no use. I applied &quot;chmod 755 -R &lt;drupal_directory&gt;&quot; and the site loaded. But am getting permission errors when I tried a new update with composer. I am sure this problem is because of permission but what is the proper way to fix this problem?</p>
[ { "answer_id": 74267082, "author": "Ben Aston", "author_id": 38522, "author_profile": "https://Stackoverflow.com/users/38522", "pm_score": 2, "selected": false, "text": "BigInt" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74267062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20381418/" ]
74,267,064
<p>I have a bunch of dynamically created cards and I want each of them to lead to a specific page. How do I do that ? Thanks</p> <p>My code so far:</p> <p>Cards that are supposed to be leading to a specific question page:</p> <pre><code>import React from 'react'; import {Card, Button} from 'react-bootstrap' import { Link } from 'react-router-dom'; const QCard = () =&gt; { const cardInfo = [ {image: &quot;&quot;, title: &quot;question1&quot;, text: &quot;super hard q1&quot;}, {image: &quot;&quot;, title: &quot;question2&quot;, text: &quot;super hard q2&quot;}, {image: &quot;&quot;, title: &quot;question3&quot;, text: &quot;super hard q3&quot;}, {image: &quot;&quot;, title: &quot;question4&quot;, text: &quot;super hard q4&quot;}, {image: &quot;&quot;, title: &quot;question5&quot;, text: &quot;super hard q5&quot;}, {image: &quot;&quot;, title: &quot;question6&quot;, text: &quot;super hard q6&quot;}, ] const renderQCard = (card, index) =&gt; { return ( &lt;Card style={{ width: '20rem' }} key={index} className=&quot;box&quot;&gt; &lt;Card.Img variant=&quot;top&quot; src={card.image} /&gt; &lt;Card.Body&gt; &lt;Card.Title&gt;{card.title}&lt;/Card.Title&gt; &lt;Card.Text&gt; {card.text} &lt;/Card.Text&gt; &lt;Link to=&quot;Question&quot;&gt; &lt;Button variant=&quot;primary&quot;&gt;Answer&lt;/Button&gt; &lt;/Link&gt; &lt;/Card.Body&gt; &lt;/Card&gt; ); } return &lt;div className='App'&gt;{cardInfo.map(renderQCard)}&lt;/div&gt; } export default QCard </code></pre>
[ { "answer_id": 74267175, "author": "l1qu1d", "author_id": 4858687, "author_profile": "https://Stackoverflow.com/users/4858687", "pm_score": 1, "selected": false, "text": "link: \"/toPage\"" }, { "answer_id": 74267211, "author": "abderahmen Gasmi", "author_id": 19619662, ...
2022/10/31
[ "https://Stackoverflow.com/questions/74267064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19306887/" ]
74,267,081
<p>I have setup environment variables for to access MongoDB database. All works except for the MongoDB connection string which is pretty long.</p> <p>Mongodb string can be provided in different format,</p> <pre class="lang-bash prettyprint-override"><code>mongodb://myDBReader:D1fficultP%40ssw0rd@mongodb0.example.com:27017/?authSource=admin </code></pre> <p>Other examples are here - <a href="https://www.fosslinux.com/50317/connection-string-in-mongodb-with-examples.htm" rel="nofollow noreferrer">https://www.fosslinux.com/50317/connection-string-in-mongodb-with-examples.htm</a></p> <p>In my case the string was provided by the database admin, so I am using it as it is provided. All, the environmental variables are shown at it is in <code>.bashrc</code> file except the MONGODB connection string. If I use the string from within my python script it works well, but when I call it through environment variables (.bashrc file) something changes the string.</p> <br> <p><strong>Setup on .bashrc</strong></p> <pre class="lang-bash prettyprint-override"><code>export MGDB_CON_STRING=&quot;mongodb://myMGDB:someuname....................server/dbname?authSource=$external&amp;authMechanism=PLAIN.....&quot; </code></pre> <p>When this variable is called by python script as</p> <pre class="lang-bash prettyprint-override"><code>mgdb_con_str = os.environ[&quot;MGDB_CON_STRING&quot;] </code></pre> <p>something is eating up the text <code>$external&amp;</code> to be exact) in this string and returning it as</p> <pre><code>&quot;mongodb://myMGDB:someuname....................server/dbname?authSource=authMechanism=PLAIN.....&quot; </code></pre> <br> <p><strong>However, if I override this variable again by using it within python script it works</strong></p> <p><code>mgdb_con_str = r&quot;mongodb://myMGDB:someuname....................server/dbname?authSource=$external&amp;authMechanism=PLAIN.....&quot;</code> <strong>- so this works</strong></p> <p>Something is eating that <code>$external&amp;</code> within the string and I cannot find what exactly is causing this. I also cannot find any question related to this problem elsewhere on stack or general google search. But, string value of all other environment variables do not change. And, similar problem arises if I read the mongodb string through config file.</p>
[ { "answer_id": 74267334, "author": "DeepSpace", "author_id": 1453822, "author_profile": "https://Stackoverflow.com/users/1453822", "pm_score": 1, "selected": false, "text": "export A=\"...authSource=$external&something_else\"\n" }, { "answer_id": 74270525, "author": "everesti...
2022/10/31
[ "https://Stackoverflow.com/questions/74267081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6346698/" ]
74,267,102
<p>I have a service with ingress of <code>/api/my-service</code></p> <p>My kong configuration look like this:</p> <pre><code>services: - name: myService protocol: http host: myservice.mynamespace port: 8080 path: / plugins: - name: jwt config: key_claim_name: iss claims_to_verify: - exp routes: - tags: - OAS3_import - OAS3file_openapi.json name: myservice-backend methods: - GET paths: - /api/my-service/v0/contexts strip_path: false - tags: </code></pre> <p>When I request <code>http://kongProxy/api/my-service/v0/myEndpoint</code> I want kong to create an upstream request like <code>http://my-service/v0/myEndpoint</code></p> <p>I thought I can use the strip_path setting, but that strips the suffix, not the prefix.</p> <p>I looked at the request transformer but looks like an overkill for something like that. And I prefer to avoid it because the cong image has been provided to me and would like to avoid having to request modifications.</p> <p>Any ideas?</p>
[ { "answer_id": 74466102, "author": "user2311578", "author_id": 2311578, "author_profile": "https://Stackoverflow.com/users/2311578", "pm_score": 1, "selected": false, "text": "services:\n - name: myService\n protocol: http\n host: myservice.mynamespace\n port: 8080\n path: /...
2022/10/31
[ "https://Stackoverflow.com/questions/74267102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2036161/" ]
74,267,105
<p>Sql Server version: Sql Server 2019 - 15.04138.2 Here is the script to generate the data in SQL Server:</p> <pre><code>CREATE TABLE #data ( Device varchar(100), Hall INT, EquipNo INT, LocNo INT, HitCount INT, Operator VARCHAR(100) ) INSERT INTO #data VALUES ('Tiger', 0, 0, 0, 0, null) , ('Tiger', 1, 0, 10, 0, NULL) , ('Tiger', 1, 5, 10, 0, NULL) , ('Tiger', 1, 5, 10, 0, NULL) , ('Tiger', 1, 5, 10, 3, NULL) , ('Tiger', 1, 5, 10, 3, 'Sam') , ('Shark', 0, 0, 0, 0, null) , ('Shark', 2, 3, 0, 0, null) , ('Shark', 2, 3, null, 5, null) , ('Shark', 2, 3, 20, 2, null) , ('Shark', 2, 3, 20, 2, 'Alex') , ('Tiger', 0, 0, 0, 0, null) , ('Tiger', 1, 3, 0, 0, null) , ('Tiger', 1, null, null, 5, null) , ('Tiger', 1, 3, 20, 10, 'Sam') , ('Tiger', 1, 3, 20, 2, 'Sam') </code></pre> <p>In the above data, a record is valid if it has values in Device, Hall, EquipNo and HitCount columns, other than zero or empty string. The data can be grouped logically by Device, Hall and EquipNo. If 2 records in a group have &quot;Device, hall, EquipNo and HitCount&quot; data then we need to select the record with the highest value for HitCount. But if the hitcount is the same then we should take the record with the most information.</p> <p>The desired result is (order is not important):</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: center;">Device</th> <th style="text-align: center;">Hall</th> <th style="text-align: center;">EquipNo</th> <th style="text-align: center;">LocNo</th> <th style="text-align: center;">HitCount</th> <th style="text-align: center;">Operator</th> </tr> </thead> <tbody> <tr> <td style="text-align: center;">Tiger</td> <td style="text-align: center;">1</td> <td style="text-align: center;">5</td> <td style="text-align: center;">10</td> <td style="text-align: center;">3</td> <td style="text-align: center;">Sam</td> </tr> <tr> <td style="text-align: center;">Shark</td> <td style="text-align: center;">2</td> <td style="text-align: center;">3</td> <td style="text-align: center;">Null</td> <td style="text-align: center;">5</td> <td style="text-align: center;">Null</td> </tr> <tr> <td style="text-align: center;">Tiger</td> <td style="text-align: center;">1</td> <td style="text-align: center;">3</td> <td style="text-align: center;">20</td> <td style="text-align: center;">10</td> <td style="text-align: center;">Sam</td> </tr> </tbody> </table> </div> <p>As an additional clarification, please see the following image to see what data we should end up with:<br /> <a href="https://ibb.co/5sKDPqj" rel="nofollow noreferrer">records to be selected</a></p> <p>Using another temporary table or more is ok to end up with the desired result.</p> <hr /> <hr /> <p>UPDATE: Here is the updated script to create a temp table with test data and applying solution provided by Hogan:</p> <pre><code>CREATE TABLE #data ( Device varchar(100), Hall INT, EquipNo INT, LocNo INT, HitCount INT, Operator VARCHAR(100) ) INSERT INTO #data VALUES ('Tiger', 0, 0, 0, 0, null) , ('Tiger', 1, 0, 10, 0, NULL) , ('Tiger', 1, 5, 10, 0, NULL) , ('Tiger', 1, 5, 10, 0, NULL) , ('Tiger', 1, 5, 10, 3, NULL) , ('Tiger', 1, 5, 10, 3, 'Sam') , ('Shark', 0, 0, 0, 0, null) , ('Shark', 2, 3, 0, 0, null) , ('Shark', 2, 3, null, 5, null) , ('Shark', 2, 3, 20, 2, null) , ('Shark', 2, 3, 20, 2, 'Alex') , ('Tiger', 0, 0, 0, 0, null) , ('Tiger', 1, 3, 0, 0, null) , ('Tiger', 1, null, null, 5, null) , ('Tiger', 1, 3, 20, 10, 'Sam') , ('Tiger', 1, 3, 20, 2, 'Sam') SELECT Device, Hall, EquipNo, LocNo, HitCount, Operator FROM ( SELECT Device, Hall, EquipNo, LocNo, HitCount, Operator, ROW_NUMBER() OVER( PARTITION BY Device, Hall, EquipNo ORDER BY HitCount DESC, (CASE WHEN EquipNo IS NOT NULL THEN 1 ELSE 0 END + CASE WHEN LocNo IS NOT NULL THEN 1 ELSE 0 END + CASE WHEN Operator IS NOT NULL THEN 1 ELSE 0 END) DESC ) as RN FROM #data ) S WHERE S.RN = 1 </code></pre> <p>However, the result of running the query is:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: center;">Device</th> <th style="text-align: center;">Hall</th> <th style="text-align: center;">EquipNo</th> <th style="text-align: center;">LocNo</th> <th style="text-align: center;">HitCount</th> <th style="text-align: center;">Operator</th> </tr> </thead> <tbody> <tr> <td style="text-align: center;">Shark</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> <td style="text-align: center;">null</td> </tr> <tr> <td style="text-align: center;">Shark</td> <td style="text-align: center;">2</td> <td style="text-align: center;">3</td> <td style="text-align: center;">null</td> <td style="text-align: center;">5</td> <td style="text-align: center;">null</td> </tr> <tr> <td style="text-align: center;">Tiger</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> <td style="text-align: center;">null</td> </tr> <tr> <td style="text-align: center;">Tiger</td> <td style="text-align: center;">1</td> <td style="text-align: center;">null</td> <td style="text-align: center;">null</td> <td style="text-align: center;">5</td> <td style="text-align: center;">null</td> </tr> <tr> <td style="text-align: center;">Tiger</td> <td style="text-align: center;">1</td> <td style="text-align: center;">0</td> <td style="text-align: center;">10</td> <td style="text-align: center;">0</td> <td style="text-align: center;">null</td> </tr> <tr> <td style="text-align: center;">Tiger</td> <td style="text-align: center;">1</td> <td style="text-align: center;">3</td> <td style="text-align: center;">20</td> <td style="text-align: center;">10</td> <td style="text-align: center;">Sam</td> </tr> <tr> <td style="text-align: center;">Tiger</td> <td style="text-align: center;">1</td> <td style="text-align: center;">5</td> <td style="text-align: center;">10</td> <td style="text-align: center;">3</td> <td style="text-align: center;">Sam</td> </tr> </tbody> </table> </div> <p>Device must have a value that is not empty string. Hall and EquipNo also must have a value that is not zero.</p> <p>So the desired result should be (order is not important):</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: center;">Device</th> <th style="text-align: center;">Hall</th> <th style="text-align: center;">EquipNo</th> <th style="text-align: center;">LocNo</th> <th style="text-align: center;">HitCount</th> <th style="text-align: center;">Operator</th> </tr> </thead> <tbody> <tr> <td style="text-align: center;">Tiger</td> <td style="text-align: center;">1</td> <td style="text-align: center;">5</td> <td style="text-align: center;">10</td> <td style="text-align: center;">3</td> <td style="text-align: center;">Sam</td> </tr> <tr> <td style="text-align: center;">Shark</td> <td style="text-align: center;">2</td> <td style="text-align: center;">3</td> <td style="text-align: center;">Null</td> <td style="text-align: center;">5</td> <td style="text-align: center;">Null</td> </tr> <tr> <td style="text-align: center;">Tiger</td> <td style="text-align: center;">1</td> <td style="text-align: center;">3</td> <td style="text-align: center;">20</td> <td style="text-align: center;">10</td> <td style="text-align: center;">Sam</td> </tr> </tbody> </table> </div> <p>Thx.</p>
[ { "answer_id": 74466102, "author": "user2311578", "author_id": 2311578, "author_profile": "https://Stackoverflow.com/users/2311578", "pm_score": 1, "selected": false, "text": "services:\n - name: myService\n protocol: http\n host: myservice.mynamespace\n port: 8080\n path: /...
2022/10/31
[ "https://Stackoverflow.com/questions/74267105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20381359/" ]
74,267,110
<p>This question is a follow-up to <a href="https://stackoverflow.com/questions/74265780/get-date-last-condition-by-group">this question</a>, but where each <code>idPerson</code> can have multiple <code>decision == &quot;d&quot;</code>. There are multiple <code>idPerson</code>, but one suffices to explain the question. <code>idAppt</code> are nested into <code>idPerson</code>. Consider this data frame.</p> <pre class="lang-r prettyprint-override"><code> idPerson idAppt decision date 1 A 1 a 2021-09-10 2 A 1 b 2021-09-11 3 A 1 c 2021-09-12 4 A 1 d 2021-09-13 5 A 2 a 2021-09-20 6 A 2 b 2021-09-21 7 A 3 a 2021-09-10 8 A 3 b 2021-09-11 9 A 4 a 2021-09-21 10 A 4 b 2021-09-22 11 A 4 c 2021-09-23 12 A 4 d 2021-09-24 13 A 5 a 2021-09-10 14 A 5 b 2021-09-11 15 A 6 a 2021-10-10 16 A 6 b 2021-10-11 </code></pre> <p>I'd like to construct a <code>date2</code> column which replies to these conditions:</p> <ul> <li>For a given <code>idAppt</code>, if <code>decision == &quot;a&quot;</code> is later than any other date when <code>decision == &quot;d&quot;</code> of that same <code>idPerson</code>, report the latest value of <code>date</code> when <code>decision == &quot;d&quot;</code> for that <code>idPerson</code> (the closest before). For example, in group <code>idAppt == 2</code>, the date of <code>decision == &quot;a&quot;</code> is later than the date of <code>decision == &quot;d&quot;</code> of group <code>idAppt == 1</code>, so <code>date2</code> should be <code>2021-09-13</code>. Same applies for group <code>idAppt == 6</code>, but here there are two <code>decision == &quot;d&quot;</code> that are earlier (row 4 and 12). In that case, <code>date2</code> should be the closest before <code>2021-10-10</code>, i.e. <code>2021-09-23</code>.</li> <li>When there is no <code>decision == &quot;d&quot;</code>'s <code>date</code> earlier than the <code>date</code> of <code>decision == &quot;a&quot;</code> for a given <code>idAppt</code>, take the earliest of the given <code>idPerson</code>.</li> </ul> <p>Which gives the following desired output:</p> <pre class="lang-r prettyprint-override"><code> idPerson idAppt decision date date2 1 A 1 a 2021-09-10 2021-09-10 2 A 1 b 2021-09-11 2021-09-10 3 A 1 c 2021-09-12 2021-09-10 4 A 1 d 2021-09-13 2021-09-10 5 A 2 a 2021-09-20 2021-09-13 #&lt;- correspond to value of row 4 6 A 2 b 2021-09-21 2021-09-13 7 A 3 a 2021-09-10 2021-09-10 8 A 3 b 2021-09-11 2021-09-10 9 A 4 a 2021-09-21 2021-09-13 10 A 4 b 2021-09-22 2021-09-13 11 A 4 c 2021-09-23 2021-09-13 12 A 4 d 2021-09-24 2021-09-13 13 A 5 a 2021-09-11 2021-09-10 #&lt;- earliest value because 2021-09-10 is earlier than 2021-09-13 14 A 5 b 2021-09-12 2021-09-10 15 A 6 a 2021-10-10 2021-09-24 #&lt;- correspond to value of row 12 16 A 6 b 2021-10-11 2021-09-24 </code></pre> <hr /> <p>data</p> <pre class="lang-r prettyprint-override"><code>df &lt;- structure(list(idPerson = c(&quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;), idAppt = c(1L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 6L, 6L), decision = c(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;a&quot;, &quot;b&quot;, &quot;a&quot;, &quot;b&quot;, &quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;a&quot;, &quot;b&quot;, &quot;a&quot;, &quot;b&quot;), date = structure(c(18880, 18881, 18882, 18883, 18890, 18891, 18880, 18881, 18891, 18892, 18893, 18894, 18881, 18882, 18910, 18911), class = &quot;Date&quot;)), class = c(&quot;tbl_df&quot;, &quot;tbl&quot;, &quot;data.frame&quot;), row.names = c(NA, -16L)) EO &lt;- structure(list(idPerson = c(&quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;), idAppt = c(1L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 6L, 6L), decision = c(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;a&quot;, &quot;b&quot;, &quot;a&quot;, &quot;b&quot;, &quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;a&quot;, &quot;b&quot;, &quot;a&quot;, &quot;b&quot;), date = structure(c(18880, 18881, 18882, 18883, 18890, 18891, 18880, 18881, 18891, 18892, 18893, 18894, 18881, 18882, 18910, 18911), class = &quot;Date&quot;), date2 = c(&quot;2021-09-10&quot;, &quot;2021-09-10&quot;, &quot;2021-09-10&quot;, &quot;2021-09-10&quot;, &quot;2021-09-13&quot;, &quot;2021-09-13&quot;, &quot;2021-09-10&quot;, &quot;2021-09-10&quot;, &quot;2021-09-13&quot;, &quot;2021-09-13&quot;, &quot;2021-09-13&quot;, &quot;2021-09-13&quot;, &quot;2021-09-10&quot;, &quot;2021-09-10&quot;, &quot;2021-09-24&quot;, &quot;2021-09-24&quot;)), row.names = c(NA, -16L), class = c(&quot;tbl_df&quot;, &quot;tbl&quot;, &quot;data.frame&quot;)) </code></pre>
[ { "answer_id": 74274217, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 1, "selected": false, "text": "library(dplyr)\ndf %>%\n group_by(idPerson) %>%\n mutate(d_date = list(date[decision == \"d\"]), min_date_person = ...
2022/10/31
[ "https://Stackoverflow.com/questions/74267110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13460602/" ]
74,267,122
<p>I need to transform json objects with arbitrary keys, and integer values like so</p> <p><code>{&quot;a&quot;:1, &quot;sql&quot;:5}</code> → <code>{&quot;a&quot;:{&quot;f&quot;:1},&quot;sql&quot;:{&quot;f&quot;:5}}</code>.</p> <p>I can't figure out the correct postgres jsonb methods. I've set up this <a href="https://www.db-fiddle.com/f/toGP1HVYw6oSHH2W5RSLyd/1" rel="nofollow noreferrer">db fiddle</a> to make it easy to interact.</p> <p>Help is highly appreciated. Thanks in advance.</p>
[ { "answer_id": 74267200, "author": "Bergi", "author_id": 1048572, "author_profile": "https://Stackoverflow.com/users/1048572", "pm_score": 3, "selected": true, "text": "jsonb_each" }, { "answer_id": 74267499, "author": "Miles Elam", "author_id": 11471381, "author_prof...
2022/10/31
[ "https://Stackoverflow.com/questions/74267122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1178402/" ]
74,267,143
<pre><code> import 'package:internet_connection_checker/internet_connection_checker.dart'; /*Error --&gt; Target of URI doesn't exist: 'package:internet_connection_checker/internet_connection_checker.dart'. Try creating the file referenced by the URI, or Try using a URI for a file that does exist*/ .... void checkingNetwork() async { ans = await InternetConnectionChecker().hasConnection; /*Error -- The method 'InternetConnectionChecker' isn't defined for the type '_WelcomeMessageState'. Try correcting the name to the name of an existing method, or defining a method named 'InternetConnectionChecker'.*/ } @override void initState() { super.initState(); checkingNetwork(); } </code></pre> <p>I have this code to check network connectivity but even after adding plugin to pubspec, its giving error. How can I remove this?</p>
[ { "answer_id": 74267200, "author": "Bergi", "author_id": 1048572, "author_profile": "https://Stackoverflow.com/users/1048572", "pm_score": 3, "selected": true, "text": "jsonb_each" }, { "answer_id": 74267499, "author": "Miles Elam", "author_id": 11471381, "author_prof...
2022/10/31
[ "https://Stackoverflow.com/questions/74267143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17879169/" ]
74,267,150
<p>i have alot of similar containers in my app that hold varied pieces of text. I want to make a Dart Function that i can then use to return the container and the specify color and text height and width.</p> <p>when I try to make the Dart Function:</p> <pre><code>Container MyContainer() {} </code></pre> <p>the MyContainer part is coming back with the error: The body might complete normally, causing 'null' to be returned, but the return type, 'Container', is a potentially non-nullable type</p> <p>I've looked at the docs but don't understand how the common fixes would be implemented into the function.</p> <p>cheers</p>
[ { "answer_id": 74267963, "author": "nicover ", "author_id": 12566751, "author_profile": "https://Stackoverflow.com/users/12566751", "pm_score": 1, "selected": false, "text": "StatelessWidget" }, { "answer_id": 74268026, "author": "Ye Lwin Oo", "author_id": 19209151, "...
2022/10/31
[ "https://Stackoverflow.com/questions/74267150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20373623/" ]
74,267,151
<p>I am working in Reactjs and i am using Nextjs framework, Right now i am tyring to fetch data from database using nextjs, But right now i am getting following error TypeError: Cannot read property 'id' of undefined,How can i remove this ? Here is my current code</p> <pre><code>import { Box, Heading } from &quot;@chakra-ui/react&quot;; export async function getStaticProps() { const response = await fetch(&quot;https://fakestoreapi.com/products&quot;); const data = await response.json(); return { props: { products, }, }; } function Test({products}) { return ( &lt;Box&gt; {products.map((product) =&gt; ( &lt;Box&gt; &lt;Text&gt; {product.title} &lt;/Text&gt; &lt;/Box&gt; ))} &lt;/Box&gt; ); } export default Test; </code></pre> <p>Here is my index.js file</p> <pre class="lang-js prettyprint-override"><code>import Head from 'next/head' import Image from 'next/image' import styles from '../styles/Home.module.css' import Test from '../components/testing/test' export default function Home() { return ( &lt;div className={styles.container}&gt; &lt;Test/&gt; &lt;/div&gt; ) } </code></pre>
[ { "answer_id": 74285530, "author": "mahmoud ettouahri", "author_id": 10832410, "author_profile": "https://Stackoverflow.com/users/10832410", "pm_score": 2, "selected": true, "text": "import Head from 'next/head'\nimport Image from 'next/image'\nimport styles from '../styles/Home.module.c...
2022/10/31
[ "https://Stackoverflow.com/questions/74267151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20381573/" ]
74,267,155
<p>How can i change color of a text if it comes after a certain text ? and only the word that comes after and leave the rest by there default color eg : any word comes after Die to be red , das to be green , der to be blue</p> <p>der mann (blue) die frau (red) das buch (green)</p> <p>die frau ist Schön . (the only part to become red is <em>die frau</em> leaving <em>ist Schön</em> black .</p> <p>Appreciate your help</p> <p>i don't know how to write codes</p>
[ { "answer_id": 74285530, "author": "mahmoud ettouahri", "author_id": 10832410, "author_profile": "https://Stackoverflow.com/users/10832410", "pm_score": 2, "selected": true, "text": "import Head from 'next/head'\nimport Image from 'next/image'\nimport styles from '../styles/Home.module.c...
2022/10/31
[ "https://Stackoverflow.com/questions/74267155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20381489/" ]
74,267,222
<p>Is it possible to inherit the Ethereum contract it self and add some function to it?</p> <p>I just want to know it is possible to do and if it is how?</p>
[ { "answer_id": 74285530, "author": "mahmoud ettouahri", "author_id": 10832410, "author_profile": "https://Stackoverflow.com/users/10832410", "pm_score": 2, "selected": true, "text": "import Head from 'next/head'\nimport Image from 'next/image'\nimport styles from '../styles/Home.module.c...
2022/10/31
[ "https://Stackoverflow.com/questions/74267222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19765063/" ]
74,267,225
<p>I have a use case to implement in which historic data processing needs to be done before my streaming job can start processing live events.</p> <p>My streaming job will become part of already running system, which means data is already present. And this data first needs to be processed before my job starts processing the live streaming events.</p> <p>So how should i design this, what i can think off are the following ways; a) First process the historic data, once done than only start the streaming job. b) Start the historic data processing &amp; streaming job simultaneously. But keep buffering the events until the historic data has been processed. c) Make one job having both the capabilities of historic data processing + streaming live events.</p> <p>Pros &amp; Cons of the above approaches;</p> <ol> <li><p>Approach (a), simple but needs manual intervention. Plus as the historic data will take time to get loaded, and once done post that when i start the job what should be the flink consumer property to read from the stream - earliest, latest or timestamp based? Reason to think about it as the moment job starts it will be a fresh consumer with no offset/consumer group id registered with kafka broker (in my case it is Oracle streaming service)</p> </li> <li><p>Approach (b) buffer size should be large enough to withhold the events states. Also the window that will hold the events needs to buffer till 'x' timestamp value for the first time only while post that it should be 'y' value (ideally very very less than 'x' as the bootstrapping is already done) . How to make this possible?</p> </li> <li><p>Approach (c) sounds good, but historic processing is only for first time &amp; most importantly post historic processing only buffered events need to be processed. So next time as no historic processing is reqd. so how would other stream knows that it should keep processing the events as no historic processing is reqd.</p> </li> </ol> <p>Appreciate any help/suggestions to implement &amp; design my use case better.</p>
[ { "answer_id": 74272290, "author": "David Anderson", "author_id": 2000823, "author_profile": "https://Stackoverflow.com/users/2000823", "pm_score": 1, "selected": false, "text": "HybridSource" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74267225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5536449/" ]
74,267,227
<p>I have been tasked with marking up a document whose visual headings have been authored something like:</p> <ul> <li>Our paper discussing a variety of 2022 XYZ efforts <ul> <li>XYZ in 2022 within the fine arts sector <ul> <li>XYZ's 2022 progress in the fine arts sector summarized</li> <li>Results of XYZ's 2022 progress by individual genre <ul> <li>Fine arts sector progress at XYZ within the craftsman movement</li> <li>Fine arts sector progress at XYZ within the impressionist movement</li> <li>Fine arts sector progress at XYZ within the postrecessional movement</li> </ul> </li> </ul> </li> <li>XYZ in 2022 within the science sector <ul> <li>XYZ's 2022 progress in the science sector summarized</li> <li>Results of XYZ's 2022 progress by individual branch <ul> <li>Science sector progress at XYZ within the chemistry field</li> <li>Science sector progress at XYZ within the biology field</li> <li>Science sector progress at XYZ within the phlogistonomy field</li> </ul> </li> </ul> </li> <li>XYZ in 2022 within the advanced research sector <ul> <li>XYZ's 2022 progress in the research sector summarized</li> <li>Results of XYZ's 2022 progress by endeavor <ul> <li>Research sector progress at XYZ within the public transit space</li> <li>Research sector progress at XYZ within the quantum photonics space</li> <li>Research sector progress at XYZ within the renewable mining space</li> </ul> </li> </ul> </li> </ul> </li> </ul> <p>My concern is that the way the headings are worded will make them tedious to navigate via screen reader. For example if I want to jump to the &quot;impressionist movement&quot; section I will have to listen to lots of repeated &quot;XY within fine arts results&quot; prefixes ahead of the actual info distinguishing each heading from the other.</p> <p>This is not my content and I am not allowed to change the headings, nor will the authors. However, I have been given permission to adjust the <strong>markup</strong> so as to present a <em>modified</em> semantic &quot;outline&quot; view that differs from the visual one. Feedback welcome, but I think an outline like the following would be more useful to someone navigating by screen reader:</p> <ul> <li>Our paper discussing a variety of 2022 XYZ efforts <ul> <li>Fine arts sector at XYZ in 2022 <ul> <li>Summary of XYZ's 2022 progress</li> <li>Results by individual genre <ul> <li>craftsman movement</li> <li>impressionist movement</li> <li>postrecessional movement</li> </ul> </li> </ul> </li> <li>Science sector at XYZ in 2022 <ul> <li>Summary of XYZ's 2022 progress</li> <li>Results by individual branch <ul> <li>chemistry field</li> <li>biology field</li> <li>phlogistonomy field</li> </ul> </li> </ul> </li> <li>Advanced research at XYZ in 2022 <ul> <li>Summary of XYZ's 2022 progress</li> <li>Results by endeavor <ul> <li>public transit space</li> <li>quantum photonics space</li> <li>renewable mining space</li> </ul> </li> </ul> </li> </ul> </li> </ul> <p>My question is, how do I accomplish this in a way that real-world screenreading utilities will pick up?</p> <p>If I simply take each heading like:</p> <pre><code>&lt;h4&gt;Fine arts sector progress at XYZ within the impressionist movement&lt;/h4&gt; </code></pre> <p>And add an <code>aria-label</code> with the shortened version like:</p> <pre><code>&lt;h4 aria-label=&quot;impressionist movement&quot;&gt;Fine arts sector progress at XYZ within the impressionist movement&lt;/h4&gt; </code></pre> <p>Will that be an effective and appropriate solution? Is there a way I can test the results using something built into the OS like VoiceOver or ChromeVox, or do the paid utilities like JAWS behave quite a bit differently in this regard?</p>
[ { "answer_id": 74268789, "author": "slugolicious", "author_id": 76714, "author_profile": "https://Stackoverflow.com/users/76714", "pm_score": 3, "selected": true, "text": "<h4>" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74267227", "https://Stackoverflow.com", "https://Stackoverflow.com/users/179583/" ]
74,267,232
<p>I am unable to pass the test even though, my code works perfectly When I checked,</p> <p>Below is my code..</p> <pre><code>import sys import csv def main(): n, m = passing_arg() read_file(n, m) def passing_arg(): if len(sys.argv) &gt; 3: sys.exit(&quot;Too many command-line arguments&quot;) elif len(sys.argv) &lt; 3: sys.exit(&quot;Too few command-line arguments&quot;) elif sys.argv[1].endswith(&quot;.csv&quot;) == False or sys.argv[2].endswith(&quot;.csv&quot;) == False: sys.exit(&quot;Not a CSV file&quot;) else: x = sys.argv[1] y = sys.argv[2] return x, y def read_file(x, y): try: with open(x) as file: content = csv.DictReader(file) print(type(content)) add_header = True for row in content: last, first = row[&quot;name&quot;].split(&quot;, &quot;) with open(y, &quot;a&quot;) as f: fieldnames = ['First', 'Last', 'House'] content1 = csv.DictWriter(f, fieldnames=fieldnames) if add_header: content1.writeheader() add_header = False content1.writerow({fieldnames[0] : first, fieldnames[1] : last, fieldnames[2] : row[&quot;house&quot;]}) except FileNotFoundError: sys.exit(f&quot;Could not read {x}&quot;) if __name__ == &quot;__main__&quot;: main() </code></pre> <p>I am not ignoring a whitespace as well. This is where my code fails: <a href="https://submit.cs50.io/check50/4e891d917868cb8a4ede3e3dde8903cc7ddb62c7" rel="nofollow noreferrer">link</a></p> <p>BEFORE:</p> <pre><code>name,house &quot;Abbott, Hannah&quot;,Hufflepuff &quot;Bell, Katie&quot;,Gryffindor &quot;Bones, Susan&quot;,Hufflepuff &quot;Boot, Terry&quot;,Ravenclaw &quot;Brown, Lavender&quot;,Gryffindor &quot;Bulstrode, Millicent&quot;,Slytherin &quot;Chang, Cho&quot;,Ravenclaw &quot;Clearwater, Penelope&quot;,Ravenclaw &quot;Crabbe, Vincent&quot;,Slytherin &quot;Creevey, Colin&quot;,Gryffindor &quot;Creevey, Dennis&quot;,Gryffindor &quot;Diggory, Cedric&quot;,Hufflepuff &quot;Edgecombe, Marietta&quot;,Ravenclaw &quot;Finch-Fletchley, Justin&quot;,Hufflepuff &quot;Finnigan, Seamus&quot;,Gryffindor &quot;Goldstein, Anthony&quot;,Ravenclaw &quot;Goyle, Gregory&quot;,Slytherin &quot;Granger, Hermione&quot;,Gryffindor &quot;Johnson, Angelina&quot;,Gryffindor &quot;Jordan, Lee&quot;,Gryffindor &quot;Longbottom, Neville&quot;,Gryffindor &quot;Lovegood, Luna&quot;,Ravenclaw &quot;Lupin, Remus&quot;,Gryffindor &quot;Malfoy, Draco&quot;,Slytherin &quot;Malfoy, Scorpius&quot;,Slytherin &quot;Macmillan, Ernie&quot;,Hufflepuff &quot;McGonagall, Minerva&quot;,Gryffindor &quot;Midgen, Eloise&quot;,Gryffindor &quot;McLaggen, Cormac&quot;,Gryffindor &quot;Montague, Graham&quot;,Slytherin &quot;Nott, Theodore&quot;,Slytherin &quot;Parkinson, Pansy&quot;,Slytherin &quot;Patil, Padma&quot;,Gryffindor &quot;Patil, Parvati&quot;,Gryffindor &quot;Potter, Harry&quot;,Gryffindor &quot;Riddle, Tom&quot;,Slytherin &quot;Robins, Demelza&quot;,Gryffindor &quot;Scamander, Newt&quot;,Hufflepuff &quot;Slughorn, Horace&quot;,Slytherin &quot;Smith, Zacharias&quot;,Hufflepuff &quot;Snape, Severus&quot;,Slytherin &quot;Spinnet, Alicia&quot;,Gryffindor &quot;Sprout, Pomona&quot;,Hufflepuff &quot;Thomas, Dean&quot;,Gryffindor &quot;Vane, Romilda&quot;,Gryffindor &quot;Warren, Myrtle&quot;,Ravenclaw &quot;Weasley, Fred&quot;,Gryffindor &quot;Weasley, George&quot;,Gryffindor &quot;Weasley, Ginny&quot;,Gryffindor &quot;Weasley, Percy&quot;,Gryffindor &quot;Weasley, Ron&quot;,Gryffindor &quot;Wood, Oliver&quot;,Gryffindor &quot;Zabini, Blaise&quot;,Slytherin </code></pre> <p>AFTER:</p> <pre><code>First,Last,House Hannah,Abbott,Hufflepuff Katie,Bell,Gryffindor Susan,Bones,Hufflepuff Terry,Boot,Ravenclaw Lavender,Brown,Gryffindor Millicent,Bulstrode,Slytherin Cho,Chang,Ravenclaw Penelope,Clearwater,Ravenclaw Vincent,Crabbe,Slytherin Colin,Creevey,Gryffindor Dennis,Creevey,Gryffindor Cedric,Diggory,Hufflepuff Marietta,Edgecombe,Ravenclaw Justin,Finch-Fletchley,Hufflepuff Seamus,Finnigan,Gryffindor Anthony,Goldstein,Ravenclaw Gregory,Goyle,Slytherin Hermione,Granger,Gryffindor Angelina,Johnson,Gryffindor Lee,Jordan,Gryffindor Neville,Longbottom,Gryffindor Luna,Lovegood,Ravenclaw Remus,Lupin,Gryffindor Draco,Malfoy,Slytherin Scorpius,Malfoy,Slytherin Ernie,Macmillan,Hufflepuff Minerva,McGonagall,Gryffindor Eloise,Midgen,Gryffindor Cormac,McLaggen,Gryffindor Graham,Montague,Slytherin Theodore,Nott,Slytherin Pansy,Parkinson,Slytherin Padma,Patil,Gryffindor Parvati,Patil,Gryffindor Harry,Potter,Gryffindor Tom,Riddle,Slytherin Demelza,Robins,Gryffindor Newt,Scamander,Hufflepuff Horace,Slughorn,Slytherin Zacharias,Smith,Hufflepuff Severus,Snape,Slytherin Alicia,Spinnet,Gryffindor Pomona,Sprout,Hufflepuff Dean,Thomas,Gryffindor Romilda,Vane,Gryffindor Myrtle,Warren,Ravenclaw Fred,Weasley,Gryffindor George,Weasley,Gryffindor Ginny,Weasley,Gryffindor Percy,Weasley,Gryffindor Ron,Weasley,Gryffindor Oliver,Wood,Gryffindor Blaise,Zabini,Slytherin </code></pre> <p>I noticed even the whitespaces between the names that are separated by commas in before.csv. but still unable to pass the test.</p>
[ { "answer_id": 74268789, "author": "slugolicious", "author_id": 76714, "author_profile": "https://Stackoverflow.com/users/76714", "pm_score": 3, "selected": true, "text": "<h4>" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74267232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20381497/" ]
74,267,249
<p>I'm having a JSON-structure that looks like this:</p> <pre><code>[ [ { &quot;word&quot;: &quot;china&quot;, &quot;count&quot;: 0 }, { &quot;word&quot;: &quot;kids&quot;, &quot;count&quot;: 1 }, { &quot;word&quot;: &quot;music&quot;, &quot;count&quot;: 0 } ], [ { &quot;word&quot;: &quot;china&quot;, &quot;count&quot;: 3 }, { &quot;word&quot;: &quot;kids&quot;, &quot;count&quot;: 0 }, { &quot;word&quot;: &quot;music&quot;, &quot;count&quot;: 2 } ], [ { &quot;word&quot;: &quot;china&quot;, &quot;count&quot;: 10 }, { &quot;word&quot;: &quot;kids&quot;, &quot;count&quot;: 3 }, { &quot;word&quot;: &quot;music&quot;, &quot;count&quot;: 2 } ] ] </code></pre> <p>I would like to convert this JSON to a plain old Java object which looks like this:</p> <pre><code>public class Word { private String text; private Integer min; private Integer max; } </code></pre> <p>I would like the &quot;<strong>min</strong>&quot; and &quot;<strong>max</strong>&quot; properties to represent the minimum and maximum occurrences of that specific word in all elements of the array.</p> <p>For example, the maximum counts for the word &quot;china&quot; is 10 and the minimum is 0.</p> <p>I would like to accomplish something like this:</p> <pre><code> word.text = &quot;china&quot; word.min = 0; word.max = 10; </code></pre> <p>I'm quite new at Java and this is my first attempt to deserialize something a bit more complex. I've been trying out different options using Jackson ObjectMapper, is this the way to go and how would I accomplish this?</p>
[ { "answer_id": 74268789, "author": "slugolicious", "author_id": 76714, "author_profile": "https://Stackoverflow.com/users/76714", "pm_score": 3, "selected": true, "text": "<h4>" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74267249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12579181/" ]
74,267,253
<p>I am trying to connect the container of my springboot application with the container of a mysql image using docker-compose, however when I run <code>docker-compose up</code> my terminal starts a loop where it starts the spring application, try to connect with the MySQL container, fails and keep trying. The error that I get is <strong>com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failures</strong></p> <p>docker-compose file:</p> <pre><code>version: '3.8' services: mysqldb: image: mysql platform: linux/x86_64 env_file: ./.env restart: always environment: - MYSQL_ROOT_PASSWORD=$MYSQLDB_ROOT_PASSWORD - MYSQL_DATABASE=$MYSQLDB_DATABASE ports: - $MYSQLDB_LOCAL_PORT:$MYSQLDB_DOCKER_PORT volumes: - db:/var/lib/mysql app: depends_on: - mysqldb build: . restart: always env_file: ./.env ports: - $APP_LOCAL_PORT:$APP_DOCKER_PORT environment: - DB_HOST=mysqldb - DB_USER=$MYSQLDB_USER - DB_PASSWORD=$MYSQLDB_ROOT_PASSWORD - DB_NAME=$MYSQLDB_DATABASE - DB_PORT=$MYSQLDB_DOCKER_PORT stdin_open: true tty: true volumes: db: </code></pre> <p>.env:</p> <pre><code>MYSQLDB_USER=root MYSQLDB_ROOT_PASSWORD=12345678 MYSQLDB_DATABASE=dronefeederdb MYSQLDB_LOCAL_PORT=3306 MYSQLDB_DOCKER_PORT=3306 APP_LOCAL_PORT=8080 APP_DOCKER_PORT=8080 </code></pre> <p>Application.yaml:</p> <pre><code>server: port: 8080 spring: datasource: username: ${DB_USER} password: ${DB_PASSWORD} url: jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME} jpa: hibernate: ddl-auto: update show-sql: true open-in-view: false #https://ia-tec-development.medium.com/lombok-e-spring-data-jpa-142398897733 security.user: name: dronefeeder password: dronefeeder #https://www.baeldung.com/spring-boot-security-autoconfiguration resilience4j.circuitbreaker: configs: default: waitDurationInOpenState: 10s failureRateThreshold: 10 #instances: #estudantes: #baseConfig: default </code></pre> <p>Dockerfile:</p> <pre><code>FROM openjdk:11.0-jdk as build-image WORKDIR /app COPY . . RUN ./mvnw clean package -DskipTests FROM openjdk:11.0-jre COPY --from=build-image /app/target/*.jar /app/app.jar EXPOSE 8080 ENTRYPOINT [&quot;java&quot;,&quot;-Djava.security.egd=file:/dev/./urandom&quot;, &quot;-jar&quot;, &quot;/app/app.jar&quot;] </code></pre> <p>Repository link: <a href="https://github.com/julia-baptista/dronefeeder/tree/docker-configuration" rel="nofollow noreferrer">https://github.com/julia-baptista/dronefeeder/tree/docker-configuration</a></p>
[ { "answer_id": 74267328, "author": "gvisoc", "author_id": 1916029, "author_profile": "https://Stackoverflow.com/users/1916029", "pm_score": 0, "selected": false, "text": "app" }, { "answer_id": 74267683, "author": "antonkronaj", "author_id": 1435948, "author_profile":...
2022/10/31
[ "https://Stackoverflow.com/questions/74267253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16921153/" ]
74,267,261
<p>I have a list of numbers, some of them have leading underscores, some of them don't.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>A</th> <th>B</th> </tr> </thead> <tbody> <tr> <td>_12</td> <td>34</td> </tr> <tr> <td>99</td> <td>_42</td> </tr> </tbody> </table> </div> <p>Which is the best way of adding up these numbers?</p> <p>Note: I tried this custom script formula which for some reason doesn&quot;t work (only returns the first item passed in the range), and anyway I guess there should be an easier way just using native GoogleSheet formulas.</p> <pre><code>function sum_with_underscores(underscored_nums) { let nums = underscored_nums.map( x =&gt; String(x).replace(&quot;_&quot;, &quot;&quot;)) return nums.reduce((pv, cv) =&gt; parseFloat(pv) + parseFloat(cv), 0); } </code></pre>
[ { "answer_id": 74267328, "author": "gvisoc", "author_id": 1916029, "author_profile": "https://Stackoverflow.com/users/1916029", "pm_score": 0, "selected": false, "text": "app" }, { "answer_id": 74267683, "author": "antonkronaj", "author_id": 1435948, "author_profile":...
2022/10/31
[ "https://Stackoverflow.com/questions/74267261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9374372/" ]
74,267,382
<p>I am new to android and trying to write this pyramid in java but it is not printing exactly.</p> <p>i want to print like this <a href="https://i.stack.imgur.com/ze5Dl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ze5Dl.png" alt="enter image description here" /></a></p> <p><strong>my code to write this is</strong></p> <pre><code> String searchQuery = &quot;rooms in mumbai&quot;; int n = searchQuery.length(); for (int i = 0; i&lt;=n; i++) { for (int j = 0; j&lt;=i-1; j++) { System.out.print(searchQuery.charAt(j)); } System.out.println(); } </code></pre> <p><strong>but this printing this</strong></p> <pre><code>r ro roo room rooms rooms rooms i rooms in rooms in rooms in m rooms in mu rooms in mum rooms in mumb rooms in mumba rooms in mumbai </code></pre> <p>As we can see it is priting some lines two times and I want the print to start from &quot;roo&quot; but it is printing from &quot;r&quot;. Guide me how can i do that</p>
[ { "answer_id": 74267456, "author": "mmartinez04", "author_id": 20131874, "author_profile": "https://Stackoverflow.com/users/20131874", "pm_score": 1, "selected": true, "text": "roo" }, { "answer_id": 74267466, "author": "7eg", "author_id": 13311722, "author_profile": ...
2022/10/31
[ "https://Stackoverflow.com/questions/74267382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11915666/" ]
74,267,410
<p>I need to find the midpoint of the arc USING JavaScript <a href="https://i.stack.imgur.com/FJuFM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FJuFM.png" alt="enter image description here" /></a>.</p> <p>I want to find M in terms of the following information:</p> <p>A.X and A.Y, the coordinates of A B.X and B.Y, the coordinates of B Radius, the radius of the arc C.X and C.Y, the center of the arc How do I compute the coordinates of M?</p> <p>I have a problem with the x sign</p> <pre><code>var a = {x:x1,y:y1} var b = {x:x2,y:y2} var c = {x:cx,y:cy} var theta1 = Math.atan(a.y / a.y); var theta2 = Math.atan(b.y / b.x) var theta = (theta1 + theta2) / 2; var mx = r * Math.cos(theta); var my = r * Math.sin(theta); var positive if (cx &gt; 0) { positive = 1 } else { positive = -1 } var midx = positive * (Math.abs(mx) + Math.abs(cx)) var midy = my + cy writeBlock(cx, cy); writeBlock(mx, my, x1, y1, x2, y2); </code></pre>
[ { "answer_id": 74267456, "author": "mmartinez04", "author_id": 20131874, "author_profile": "https://Stackoverflow.com/users/20131874", "pm_score": 1, "selected": true, "text": "roo" }, { "answer_id": 74267466, "author": "7eg", "author_id": 13311722, "author_profile": ...
2022/10/31
[ "https://Stackoverflow.com/questions/74267410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20379317/" ]
74,267,444
<p>I made a request to an endpoint and I get this object, I'm filtering the name like this:</p> <pre><code>fetch('http://endpoint', requestOptions) .then((response) =&gt; response.json()) .then((result) =&gt; { const onlineUsers = result.resource.items[1].onlineUsers &gt;= 1; console.log(onlineUsers); }) .catch((error) =&gt; console.log('error', error)); </code></pre> <p>This workers, but I just need the result of what is in the key named <code>Forms</code>, but there is a possibility that it will change its position, so the <code>items[1]</code> it may not work anymore</p> <p>This is an example of the object I receive:</p> <pre><code>{ &quot;type&quot;: &quot;application/vn+json&quot;, &quot;resource&quot;: { &quot;total&quot;: 4, &quot;itemType&quot;: &quot;application&quot;, &quot;items&quot;: [ { &quot;name&quot;: &quot;Test&quot;, &quot;onlineUsers&quot;: 1 }, { &quot;name&quot;: &quot;Forms&quot;, &quot;onlineUsers&quot;: 1 }, { &quot;name&quot;: &quot;Users&quot;, &quot;onlineUsers&quot;: 7 }, { &quot;name&quot;: &quot;OnlineUsers&quot;, &quot;onlineUsers&quot;: 5 } ] }, &quot;method&quot;: &quot;get&quot;, &quot;status&quot;: &quot;success&quot; } </code></pre> <p>Is there any way to receive this object and filter by name? Like:</p> <pre><code>if (hasName === &quot;Forms&quot;, get onlineUsers) { // Do something } </code></pre> <p>Thanks!</p>
[ { "answer_id": 74267469, "author": "rocambille", "author_id": 6612932, "author_profile": "https://Stackoverflow.com/users/6612932", "pm_score": 3, "selected": true, "text": "console.log(\n result.resource.items.filter((item) => item.name === \"Forms\")\n);\n" }, { "answer_id": 7...
2022/10/31
[ "https://Stackoverflow.com/questions/74267444", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19220623/" ]
74,267,458
<p>I want to set the background color of a certain text range in a RichTextBox.</p> <p>However, the only way to do that is by selecting it like that:</p> <pre><code> RichTextBox1.Select(10, 3) 'select text starting from position 10, use a length of 3 RichTextBox1.SelectionBackColor = Color.White </code></pre> <p>Using .Select puts the cursor at this location.</p> <p>How do I achieve the same without changing the cursor location?</p> <p>Solutions have been posted which just reset the cursor, but this does not help. I need a method would not set the cursor to a different location.</p>
[ { "answer_id": 74267648, "author": "evilmandarine", "author_id": 2983568, "author_profile": "https://Stackoverflow.com/users/2983568", "pm_score": 0, "selected": false, "text": "Public Sub New()\n InitializeComponent()\n richTextBox1.Text += \"RichTextBox text line 1\" & Environmen...
2022/10/31
[ "https://Stackoverflow.com/questions/74267458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1390192/" ]