qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,138,039
<p>How do you define a method on an instance of a class and this method is only for the instance and not others?</p> <p>Please can someone provide a use case for this feature?</p>
[ { "answer_id": 74138351, "author": "Taimoor Hassan", "author_id": 13000257, "author_profile": "https://Stackoverflow.com/users/13000257", "pm_score": 1, "selected": false, "text": "self.class_method_name." } ]
2022/10/20
[ "https://Stackoverflow.com/questions/74138039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1508857/" ]
74,138,056
<p>I have written an R function to write some SAS code (yes, I know, I am lazy), and it prints text as follows:</p> <pre><code>proc_sql_missing &lt;- function(cols, data){ cat(&quot;\nproc sql;&quot;) cat(paste0(&quot;\n\tselect\tPat_TNO,\n\t\t\t&quot;, paste(names(data)[cols], collapse = &quot;,\n\t\t\t&quot;))) cat(&quot;\n\tfrom&quot;, substitute(data)) cat(paste0(&quot;\n\twhere\t&quot;, paste(names(data)[cols], collapse = &quot;= . OR\n\t\t\t&quot;), &quot;= .;&quot;)) cat(&quot;\nquit;&quot;) } </code></pre> <p>Which when called prints something similar to the following to the R output:</p> <pre><code>proc sql; select Pat_TNO, fuq_pa_enjoy_hate, fuq_pa_bored_interest, fuq_pa_like_dislike, fuq_pa_pleasble_unpleasble, fuq_pa_absorb_notabsorb, fuq_pa_fun_notfun, fuq_pa_energizing_tiring, fuq_pa_depress_happy, fuq_pa_pleasant_unpleast, fuq_pa_good_bad, fuq_pa_invigor_notinvigor, fuq_pa_frustrate_notfrust, fuq_pa_gratifying_notgrat, fuq_pa_exhilarate_notexhil, fuq_pa_stimulate_notstim, fuq_pa_accom_notaccom, fuq_pa_refresh_notrefresh, fuq_pa_doing_notdoing from followup where fuq_pa_enjoy_hate= . OR fuq_pa_bored_interest= . OR fuq_pa_like_dislike= . OR fuq_pa_pleasble_unpleasble= . OR fuq_pa_absorb_notabsorb= . OR fuq_pa_fun_notfun= . OR fuq_pa_energizing_tiring= . OR fuq_pa_depress_happy= . OR fuq_pa_pleasant_unpleast= . OR fuq_pa_good_bad= . OR fuq_pa_invigor_notinvigor= . OR fuq_pa_frustrate_notfrust= . OR fuq_pa_gratifying_notgrat= . OR fuq_pa_exhilarate_notexhil= . OR fuq_pa_stimulate_notstim= . OR fuq_pa_accom_notaccom= . OR fuq_pa_refresh_notrefresh= . OR fuq_pa_doing_notdoing= .; quit; </code></pre> <p>Is there any way I can automatically copy this text to the clipboard so I can paste straight into SAS?</p>
[ { "answer_id": 74138596, "author": "Stéphane Laurent", "author_id": 1100107, "author_profile": "https://Stackoverflow.com/users/1100107", "pm_score": 2, "selected": false, "text": "capture.output" }, { "answer_id": 74138703, "author": "Allan Cameron", "author_id": 1250031...
2022/10/20
[ "https://Stackoverflow.com/questions/74138056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19414769/" ]
74,138,067
<p><strong>Showing error l value required as left operand of assignment</strong></p> <pre><code>#include&lt;stdio.h&gt; void main() { int i,j,l,n,s; printf(&quot;Enter the number size you want to print :&quot;); scanf(&quot;%d&quot;,&amp;n); for(i=-n;i&lt;=n;i++) { (i&lt;0)? l=-i:l=i; for(j=0;j&lt;l+1;j++) { printf(&quot;* &quot;); } printf(&quot;\n&quot;); } } </code></pre> <p><strong>i want to write this one in ternary operator</strong></p> <pre><code>if(i&lt;0) { l=-i; } else { l=i; } </code></pre>
[ { "answer_id": 74138098, "author": "thomachan", "author_id": 4432916, "author_profile": "https://Stackoverflow.com/users/4432916", "pm_score": 2, "selected": false, "text": "(i<0)? l=-i:l=i;\n" }, { "answer_id": 74138119, "author": "Vlad from Moscow", "author_id": 2877241...
2022/10/20
[ "https://Stackoverflow.com/questions/74138067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17946613/" ]
74,138,109
<p>Say I have two CSV files. The first one, <code>input_1.csv</code>, has an index column, so when I run:</p> <pre><code>import pandas as pd df_1 = pd.read_csv(&quot;input_1.csv&quot;) df_1 </code></pre> <p>I get a DataFrame with an index column, as well as a column called <code>Unnamed: 0</code>, which is the same as the index column. I can prevent this duplication by adding the argument <code>index_col=0</code> and everything is fine.</p> <p>The second file, <code>input_2.csv</code>, has no index column, i.e., it looks like this:</p> <pre><code>| stuff | things | |--------:|---------:| | 1 | 10 | | 2 | 20 | | 3 | 30 | | 4 | 40 | | 5 | 50 | </code></pre> <p>Running <code>pd.read_csv(&quot;input_2.csv&quot;)</code> gives me a DataFrame with an index column. In this case, adding the <code>index_col=0</code> argument will set in the index column to <code>stuff</code>, as in the CSV file itself.</p> <p>My problem is that I have a function that contains the <code>read_csv</code> part, and I want it to return a DataFrame with an index column in either case. Is there a way to detect whether the input file has an index column or not, set one if it doesn't, and do nothing if it does?</p>
[ { "answer_id": 74138098, "author": "thomachan", "author_id": 4432916, "author_profile": "https://Stackoverflow.com/users/4432916", "pm_score": 2, "selected": false, "text": "(i<0)? l=-i:l=i;\n" }, { "answer_id": 74138119, "author": "Vlad from Moscow", "author_id": 2877241...
2022/10/20
[ "https://Stackoverflow.com/questions/74138109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19283541/" ]
74,138,131
<p>At the code below is my way to get path of downloads or Music Folder. But At the end it say's that you don't have a permission even though I have. In the Explanation below i explain that how I get error. <strong>But my main goal is not just solve that error my main goal is find all music files in android with unity</strong>. I searched too much answer in the internet but I could not solve this problem. I can play all musics that i want in windows through this way but it doesn't work on android. I can't understand that in the app info it shows that i gave the permission to all files but how it can be possible that program could not recognize that permission?</p> <p>In the first scene I'm asking for permissions. After accepting that permissions it automatically redirects me to the next scene which in that scene I'm trying to get Music or downloads folder in device. But it throws an exeption.</p> <p>This is my manifest file</p> <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; package=&quot;com.your.bundle.identifier&quot; xmlns:tools=&quot;http://schemas.android.com/tools&quot; android:versionName=&quot;1.0&quot; android:versionCode=&quot;1&quot; android:installLocation=&quot;preferExternal&quot;&gt; &lt;supports-screens android:smallScreens=&quot;true&quot; android:normalScreens=&quot;true&quot; android:largeScreens=&quot;true&quot; android:xlargeScreens=&quot;true&quot; android:anyDensity=&quot;true&quot; /&gt; &lt;application android:theme=&quot;@style/UnityThemeSelector&quot; android:icon=&quot;@drawable/app_icon&quot; android:label=&quot;@string/app_name&quot; android:debuggable=&quot;false&quot; android:isGame=&quot;true&quot; android:banner=&quot;@drawable/app_banner&quot;&gt; &lt;activity android:name=&quot;com.unity3d.player.UnityPlayerActivity&quot; android:label=&quot;@string/app_name&quot; android:screenOrientation=&quot;fullSensor&quot; android:launchMode=&quot;singleTask&quot; android:configChanges=&quot;mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale&quot;&gt; &lt;intent-filter&gt; &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt; &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt; &lt;category android:name=&quot;android.intent.category.LEANBACK_LAUNCHER&quot; /&gt; &lt;/intent-filter&gt; &lt;meta-data android:name=&quot;unityplayer.UnityActivity&quot; android:value=&quot;true&quot; /&gt; &lt;/activity&gt; &lt;/application&gt; &lt;uses-sdk android:minSdkVersion=&quot;9&quot; android:targetSdkVersion=&quot;24&quot; /&gt; &lt;uses-feature android:glEsVersion=&quot;0x00020000&quot; /&gt; &lt;uses-feature android:name=&quot;android.hardware.touchscreen&quot; android:required=&quot;false&quot; /&gt; &lt;uses-feature android:name=&quot;android.hardware.touchscreen.multitouch&quot; android:required=&quot;false&quot; /&gt; &lt;uses-feature android:name=&quot;android.hardware.touchscreen.multitouch.distinct&quot; android:required=&quot;false&quot; /&gt; &lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot;/&gt; &lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot;/&gt; &lt;/manifest&gt; </code></pre> <p>This is my asking permission code</p> <pre><code>using System.Collections; using UnityEngine; using UnityEngine.Android; using UnityEngine.SceneManagement; public class ButtonPressing : MonoBehaviour { private bool questionAsked; private void Start() { questionAsked = false; #if PLATFORM_ANDROID Permission.RequestUserPermission(Permission.ExternalStorageWrite); questionAsked = true; StartCoroutine(MyRoutine()); #endif } private IEnumerator MyRoutine() { questionAsked = true; if (questionAsked &amp;&amp; Permission.HasUserAuthorizedPermission(Permission.ExternalStorageRead) &amp;&amp;Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite)) { questionAsked = false; SceneManager.LoadScene(1); } else if (questionAsked &amp;&amp; Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite)) { questionAsked = false; Permission.RequestUserPermission(Permission.ExternalStorageRead); } yield return new WaitForSeconds(3f); StartCoroutine(MyRoutine()); } } </code></pre> <p>And here I'm trying to get downloads or music folder.</p> <pre><code> [Obsolete(&quot;Obsolete&quot;)] public void GetFiles() { #if PLATFORM_ANDROID if (Permission.HasUserAuthorizedPermission(Permission.ExternalStorageRead)&amp;&amp;Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite)) { _camera.backgroundColor = Color.grey; _path = &quot;/storage&quot;; directoryTexts.text+= _path + &quot;\n&quot;; try { string[] allDirectories = Directory.GetDirectories(_path, &quot;*Music*&quot;, SearchOption.AllDirectories); directoryTexts.text += allDirectories.Length + &quot;\n&quot;; if (allDirectories.Length!=0) { foreach (var allDirectory in allDirectories) { directoryTexts.text+= allDirectory + &quot;\n&quot;; } } else { directoryTexts.text += &quot;There is no directory \n&quot;; } } catch (Exception e) { directoryTexts.text += e + &quot;\n&quot;; throw; } } else { directoryTexts.text += &quot;You Dont Have a permission \n&quot;; } #endif } </code></pre> <p>But everytime i get this Exeption <a href="https://i.stack.imgur.com/u6Jnn.png" rel="nofollow noreferrer">Exeption Image</a></p> <p>By the way in the image &quot;Yes it has&quot; means yes it has a permission. I have checked it in start function. In Addition I have found in this forum <a href="https://forum.unity.com/threads/android-10-and-scoped-storage-missed-features-in-unity-2019.749333/" rel="nofollow noreferrer">https://forum.unity.com/threads/android-10-and-scoped-storage-missed-features-in-unity-2019.749333/</a> that others have the same issue.But no one couln'd not solve this problem.</p>
[ { "answer_id": 74139409, "author": "jdweng", "author_id": 5015238, "author_profile": "https://Stackoverflow.com/users/5015238", "pm_score": -1, "selected": false, "text": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Xml;\nusing S...
2022/10/20
[ "https://Stackoverflow.com/questions/74138131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20283441/" ]
74,138,142
<p>I have two dataframes and like to add a column to the first one with volume information from the second one. The first dataframe should have a volume column with the sum of the volume from the second dataframe determined between the index rows of the first dataframe. Can someone point me in the right direction please? So 507 in the example would be 260+61+186 from the other dataframe(*) between the corresponding times.</p> <p>Thanks!!</p> <pre><code>dataframe 1 adjclose datetime 2022-10-20 02:55:00 30492.0 2022-10-20 03:10:00 30402.0 2022-10-20 03:20:00 30457.0 2022-10-20 03:45:00 30376.0 2022-10-20 04:05:00 30425.0 2022-10-20 04:10:00 30373.0 2022-10-20 04:45:00 30436.0 2022-10-20 04:55:00 30401.0 2022-10-20 05:25:00 30437.0 Dataframe 2 volume datetime 2022-10-20 02:40:00 119.0 2022-10-20 02:45:00 210.0 2022-10-20 02:50:00 179.0 2022-10-20 02:55:00 260.0* 2022-10-20 03:00:00 61.0* 2022-10-20 03:05:00 186.0* 2022-10-20 03:10:00 204.0 2022-10-20 03:15:00 333.0 2022-10-20 03:20:00 122.0 2022-10-20 03:25:00 75.0 Desired result adjclose volume datetime 2022-10-20 02:35:00 30433.0 507 2022-10-20 02:55:00 30492.0 etc 2022-10-20 03:10:00 30402.0 etc 2022-10-20 03:20:00 30457.0 2022-10-20 03:45:00 30376.0 2022-10-20 04:05:00 30425.0 2022-10-20 04:10:00 30373.0 2022-10-20 04:45:00 30436.0 2022-10-20 04:55:00 30401.0 2022-10-20 05:25:00 30437.0 </code></pre>
[ { "answer_id": 74138300, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 1, "selected": false, "text": "merge_asof" } ]
2022/10/20
[ "https://Stackoverflow.com/questions/74138142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19424804/" ]
74,138,157
<p>Let's say I have branch &quot;A&quot;, from which a more advanced branch &quot;B&quot; was created.</p> <p>Usually all the changes that are implemented on branch &quot;A&quot; should be just pulled into branch &quot;B&quot;, but due to some differences between the branches a specific feature was implemented on &quot;A&quot; and &quot;B&quot; separately and in different ways.</p> <p>What I want to do is to stand on branch &quot;B&quot; and do &quot;git pull origin A&quot;, but without actually pulling any file changes, so that git will just think that B and A are synced at this specific point, and any additional &quot;git pull origin A&quot; command will just return that there's nothing pull and no changes detected (until the next commit to branch A).</p> <p>Is it possible to do so?</p>
[ { "answer_id": 74138202, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 0, "selected": false, "text": "# on branch B\ngit fetch origin\n" }, { "answer_id": 74138377, "author": "eftshift0", "autho...
2022/10/20
[ "https://Stackoverflow.com/questions/74138157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1483597/" ]
74,138,176
<p>my data look like this:</p> <pre><code>{569328: '[ 596005 4321416 5802640 6031690 6043910 8600475 8642629 9203255 9345445 10177065 10455451 13428248 22139349 22591458 24627241 24750476 26261826 26405611 27079105 27096884]', 574660: '[ 5956195 11260528 22181831 22437920 22642946 23278096 23407037 23458128 24244657 24355363 25014714 25115774 25156886 27047688 27089078 27398716]', 1187498: '[ 5855196 7755392 11183886 22894980 24648618 27185399]', 1226468: '[ 3573464 6279285 6294985 6542463 6981930 7427770 10325811 14970234 16878329 17935009 21811002 22329817 23543436 23907898 24456108 25283772]', 1236571: '[ 2777078 2826073 5944733 10484188 11052747 14682645 15688752 22333410 22614097 22646501 22783765 22978728 23231683 24259740 24605606 24839432 25492752 27009992 27044704]'} </code></pre> <p>As you can see, the values of the dict which are a column of my pandas df, are strings. However, I would like to convert them into proper lists. My result should look like this:</p> <pre><code>{569328: [596005, 4321416,5802640,6031690,6043910,8600475,8642629,9203255,9345445, 10177065,10455451,13428248,22139349,22591458,24627241,24750476,26261826,26405611, 27079105,27096884], 574660: [5956195,11260528,22181831,22437920,22642946,23278096,23407037,23458128, 24244657,24355363,25014714,25115774,25156886,27047688,27089078,27398716], ...} </code></pre> <p>Thank you :)</p>
[ { "answer_id": 74138198, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 2, "selected": true, "text": "strip" }, { "answer_id": 74138582, "author": "Kateryna", "author_id": 17995822, "author_profile":...
2022/10/20
[ "https://Stackoverflow.com/questions/74138176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10967961/" ]
74,138,177
<p>this is my TEAM table</p> <pre><code>POSITION NAME HEIGHT ________ _________ ______ GK Jhon 178 GK Steven 190 DF Paul 183 DF Andrew 178 DF Nick 169 MF Ali 170 MF Peter 176 MF Charlie 180 FW Simon 185 FW Son 184 FW Jack 179 </code></pre> <p>I want to select position, name and highest players each positions like:</p> <pre><code>POSITION NAME HEIGHT ________ _________ ______ GK Steven 190 DF Paul 183 MF Charlie 180 FW Simon 185 </code></pre> <p>Here is the code I tried.</p> <pre><code>SELECT POSITION, MAX(HEIGHT) FROM TEAM GROUP BY POSITION; </code></pre> <p>and that's the answer:</p> <pre><code>POSITION HEIGHT ________ ______ GK 190 DF 183 MF 180 FW 185 </code></pre> <p>As a result, I hope to insert name column on that result.</p>
[ { "answer_id": 74138241, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 1, "selected": false, "text": "RANK()" }, { "answer_id": 74138258, "author": "Alex Poole", "author_id": 266304, "author...
2022/10/20
[ "https://Stackoverflow.com/questions/74138177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20290378/" ]
74,138,201
<p>I'm trying to print all the &quot;a&quot; or other characters from an input string. I'm trying it with the .find() function but just print one position of the characters. How do I print all the positions where is an specific character like &quot;a&quot;</p>
[ { "answer_id": 74138293, "author": "assume_irrational_is_rational", "author_id": 11622508, "author_profile": "https://Stackoverflow.com/users/11622508", "pm_score": 2, "selected": true, "text": "find" }, { "answer_id": 74138422, "author": "ThisQRequiresASpecialist", "auth...
2022/10/20
[ "https://Stackoverflow.com/questions/74138201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17867287/" ]
74,138,222
<p>I have a json with below structure. I want to compare input with below elements each (Key/values) of json and return the response only if atleast one word matched from input to the compared string of JSON.</p> <p>input: &quot;Angular work space&quot;</p> <p>json:</p> <pre><code>[{id:1,name:&quot;angular repo&quot;},{id:2,name:&quot;node repo&quot;}] </code></pre> <p>first row in above json should be returned as 1 phrase is matching.</p>
[ { "answer_id": 74138293, "author": "assume_irrational_is_rational", "author_id": 11622508, "author_profile": "https://Stackoverflow.com/users/11622508", "pm_score": 2, "selected": true, "text": "find" }, { "answer_id": 74138422, "author": "ThisQRequiresASpecialist", "auth...
2022/10/20
[ "https://Stackoverflow.com/questions/74138222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20273793/" ]
74,138,271
<p>How can I change the background color of the <code>ElevatedButton</code>?</p> <pre><code>child: ElevatedButton( onPressed: (){}, child: Text('Get Started', style: TextStyle( color: Colors.white, fontSize: 20.0, ),), ), </code></pre>
[ { "answer_id": 74138293, "author": "assume_irrational_is_rational", "author_id": 11622508, "author_profile": "https://Stackoverflow.com/users/11622508", "pm_score": 2, "selected": true, "text": "find" }, { "answer_id": 74138422, "author": "ThisQRequiresASpecialist", "auth...
2022/10/20
[ "https://Stackoverflow.com/questions/74138271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20183851/" ]
74,138,307
<p>I have a table 'Report' which contain records of inspection from [StartDate] to [EndDate]. Inspections don't appear every day, so I have [ReportDate] too, but in one day I can have a few inspections. My table 'Report' has column: A, B, C, StartDate, EndDate, ReportDate. I want to receive grouping table which will contain number of days when inspection took place. This number of days should summary DISTINCTCOUNT of [ReportDate]. My problem is that I can not use DISTINCTCOUNT inside of GROUPBY(). So how I can calculate DISTINCTCOUNT? How to change below DAX statement?</p> <pre><code>New Table = GROUPBY('Report' ,'Report'[A] ,'Report'[B] ,&quot;Start Time&quot;, MIN ( CURRENTGROUP(), 'Report'[StartDate] ) ,&quot;End Time&quot;, MAXX ( CURRENTGROUP(), 'Report'[EndDate] ) ,&quot;Days&quot;, COUNTAX ( CURRENTGROUP(), 'Report'[ReportDate] ) ) </code></pre>
[ { "answer_id": 74138293, "author": "assume_irrational_is_rational", "author_id": 11622508, "author_profile": "https://Stackoverflow.com/users/11622508", "pm_score": 2, "selected": true, "text": "find" }, { "answer_id": 74138422, "author": "ThisQRequiresASpecialist", "auth...
2022/10/20
[ "https://Stackoverflow.com/questions/74138307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20290547/" ]
74,138,323
<p>I wish to update dates in date column based on a condition. But i'm unable to get it working:</p> <pre><code>d_ = { 'id': [1,2,3], 'dt1': ['28-10-2016', '18-11-2016', '21-12-2016'], } df = pd.DataFrame(d_) df['dt1'] = pd.to_datetime(df['dt1']) df id dt1 1 2016-10-28 2 2016-11-18 3 2016-12-21 df['dt1'] = np.where(df['id']==1, pd.to_datetime('2018-01-01'), df['dt1']) df id dt1 1 2018-01-01 00:00:00 2 1479427200000000000 3 1482278400000000000 df.dtypes id int64 dt1 object dtype: object </code></pre> <p>The other values in the column update to integer and the datatype of the column changes to 'object'.</p>
[ { "answer_id": 74138347, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 2, "selected": true, "text": "loc" }, { "answer_id": 74139221, "author": "Azhar Khan", "author_id": 2847330, "author_profile":...
2022/10/20
[ "https://Stackoverflow.com/questions/74138323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7218871/" ]
74,138,330
<p>I have some default cars <code>default: true</code> which contain the generic gas data. Basically I want to go through the cars and if I find a matching model I want to replace the gas value and replace with the generic value.</p> <p>My code works fine but seems pretty slow. My cars array can be like 500,000 records. Is there any faster way to do this? I was thinking like when I filter the default cars put them in a hashmap or something but I am kind of stuck</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const cars = [{ model: 'Ford', gas: 1.2, default: true }, { model: 'Nissan', gas: 1.242155, default: true }, { model: 'Nissan', gas: 4.242155 }, { model: 'Ford', gas: 5.5125 }]; const defaultCars = cars.filter(car =&gt; car.default); const newCars = cars.map(car =&gt; { const foundCar = defaultCars.find(defaultCar =&gt; car.model === defaultCar.model); if (foundCar) { car.gas = foundCar.gas return car; } }); console.log(newCars);</code></pre> </div> </div> </p>
[ { "answer_id": 74138442, "author": "trincot", "author_id": 5459839, "author_profile": "https://Stackoverflow.com/users/5459839", "pm_score": -1, "selected": true, "text": ".map" }, { "answer_id": 74138763, "author": "Vadim", "author_id": 1580941, "author_profile": "ht...
2022/10/20
[ "https://Stackoverflow.com/questions/74138330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12046376/" ]
74,138,355
<p>Currently, I'm looking at a TextFormField restriction.</p> <p>My requirement is</p> <ol> <li>Allow single 0 in TextFormField</li> <li>If it is 099, I want to remove the leading 0. So, it's 99</li> <li>Do not allow symbols or special characters like &quot;?&quot; or &quot;.&quot;</li> </ol> <p>I have tried the below code, but it's still allowed to input &quot;?&quot; or &quot;.&quot;</p> <pre><code>inputFormatters: [ new FilteringTextInputFormatter.allow(new RegExp(&quot;[0-9.]&quot;)), new FilteringTextInputFormatter.deny(RegExp(r'^0+(?=.)')), ], </code></pre> <p>I am seeking your help on this.</p> <p>Thanks in advance!</p>
[ { "answer_id": 74138442, "author": "trincot", "author_id": 5459839, "author_profile": "https://Stackoverflow.com/users/5459839", "pm_score": -1, "selected": true, "text": ".map" }, { "answer_id": 74138763, "author": "Vadim", "author_id": 1580941, "author_profile": "ht...
2022/10/20
[ "https://Stackoverflow.com/questions/74138355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16196190/" ]
74,138,367
<p>I have following folder structure in apache server.</p> <pre><code>Public_html --&gt;admin ---&gt;admin_login.php --&gt;website ---&gt;index.php </code></pre> <p>since the index.php inside the website folder, i have given following code in .htaccess</p> <pre><code>RewriteCond %{REQUEST_URI} !^/website/ RewriteRule ^(.*)$ /website/$1 [L,NC] </code></pre> <p>so that the when the user enter root url , it will appear &quot;www.myurl.com&quot; instead of &quot;www.myurl.com/website/&quot;</p> <p>but the issue is, i could not be able to access admin_login.php.</p> <p>is there anyway to modify .htaccess, to come website/index.php in main url and able to access admin_login.php(both)?</p> <p>Thanks in Advance</p>
[ { "answer_id": 74138922, "author": "RavinderSingh13", "author_id": 5866580, "author_profile": "https://Stackoverflow.com/users/5866580", "pm_score": 0, "selected": false, "text": "RewriteEngine ON\nRewriteCond %{ENV:REDIRECT_STATUS} ^$\nRewriteRule ^index\\.php/?$ website/index.php [QSA,...
2022/10/20
[ "https://Stackoverflow.com/questions/74138367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7967056/" ]
74,138,428
<p>I have an object:</p> <pre><code>var object_1 = { random_id: 'random_id_1'; name: name; surname: surname; } </code></pre> <p>and</p> <pre><code>var object_2 = { random_id: 'random_id_2'; name: 'name'; surname: 'surname'; } </code></pre> <p>how to equal this 2 objects with excluding random_id</p> <p>I tried to do it with plugin Chai:</p> <pre><code>expect(object_1).excluding('random_id').to.deep.equal(object_2) </code></pre> <p>but without success.</p>
[ { "answer_id": 74138922, "author": "RavinderSingh13", "author_id": 5866580, "author_profile": "https://Stackoverflow.com/users/5866580", "pm_score": 0, "selected": false, "text": "RewriteEngine ON\nRewriteCond %{ENV:REDIRECT_STATUS} ^$\nRewriteRule ^index\\.php/?$ website/index.php [QSA,...
2022/10/20
[ "https://Stackoverflow.com/questions/74138428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6588243/" ]
74,138,432
<p>I am using googleapis for sending push notifications using this api <a href="https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages/send?authuser=0" rel="nofollow noreferrer">https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages/send?authuser=0</a></p> <p>I want to know whether google store the push notifications sent by this API from my web application to my mobile app.</p> <p>Asking this question because users data is private and they don't want to store their data on any of the servers even the timings of the API call.</p> <p>Please help.</p>
[ { "answer_id": 74138922, "author": "RavinderSingh13", "author_id": 5866580, "author_profile": "https://Stackoverflow.com/users/5866580", "pm_score": 0, "selected": false, "text": "RewriteEngine ON\nRewriteCond %{ENV:REDIRECT_STATUS} ^$\nRewriteRule ^index\\.php/?$ website/index.php [QSA,...
2022/10/20
[ "https://Stackoverflow.com/questions/74138432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11097356/" ]
74,138,456
<h4>I'm trying to create a react app with "npx create-react-app my-app" but I'm getting this error.</h4> <pre><code>PS C:\Users\m.saral\Desktop\app&gt; npx create-react-app my-app Creating a new React app in C:\Users\m.saral\Desktop\app\my-app. Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts with cra-template... Aborting installation. Error: spawn UNKNOWN at ChildProcess.spawn (node:internal/child_process:420:11) at Object.spawn (node:child_process:733:9) at spawn (C:\Users\m.saral\AppData\Roaming\npm\node_modules\create-react-app\node_modules\cross-spawn\index.js:12:24) at C:\Users\m.saral\AppData\Roaming\npm\node_modules\create-react-app\createReactApp.js:383:19 at new Promise (&lt;anonymous&gt;) at install (C:\Users\m.saral\AppData\Roaming\npm\node_modules\create-react-app\createReactApp.js:334:10) at C:\Users\m.saral\AppData\Roaming\npm\node_modules\create-react-app\createReactApp.js:461:16 at processTicksAndRejections (node:internal/process/task_queues:96:5) { errno: -4094, code: 'UNKNOWN', syscall: 'spawn' Deleting generated file... package.json Deleting my-app/ from C:\Users\m.saral\Desktop\app Done. </code></pre> <pre><code>PS C:\Users\m.saral\Desktop\app&gt; node -v v16.18.0 </code></pre> <h5> I tried running command prompt as administrator </h5> <h5> I tried: </h5> <pre><code>npm uninstall -g create-react-app npm uninstall create-react-app I deleted and reinstalled Nodejs npm install npm@latest -g </code></pre> <h5> Node Version: v16.18.0 <br> Npm Version: 8.19.2 </h5>
[ { "answer_id": 74149630, "author": "Muhsin SARAL", "author_id": 20290539, "author_profile": "https://Stackoverflow.com/users/20290539", "pm_score": 1, "selected": true, "text": "PS C:\\Users\\m.saral\\Desktop\\app\\my-app> npm -v\n8.19.2\n" } ]
2022/10/20
[ "https://Stackoverflow.com/questions/74138456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20290539/" ]
74,138,499
<p>Today I stumbled across a problem with the number input in a hmtl Form. I'm trying to get an Input from the User in form of a float. For this case i use the Input tag as following (Sorry for the English/German names):</p> <pre><code>&lt;input asp-for=&quot;TBE_Leitwert&quot; type=&quot;number&quot; step=&quot;0.1&quot; class=&quot;form-control&quot; placeholder=&quot;Leitwert (mS)&quot; /&gt; </code></pre> <p>Somehow after submitting the form I don't get the float value. It seems like the Input is ignoring the separator at all, Example:</p> <p>The User puts in the value <code>1,1</code> but submitted was <code>11</code>.</p> <p>Value entered from a user:</p> <p><a href="https://i.stack.imgur.com/nmK2o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nmK2o.png" alt="Value entered from a user" /></a></p> <p>Value from submitted the form:</p> <p><a href="https://i.stack.imgur.com/CtRCV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CtRCV.png" alt="Value from submitted form" /></a></p> <p>The same problem results, even if I put the value <code>1.1</code> so it doesn't matter if I take the <code>dot</code> or <code>comma</code>, the value still is submitted wrong as <code>11</code></p> <p>Is there any way to get the right float values from submitting the form without using JS or AJAX?</p> <p><strong>Edit:</strong> I made a super minimal reproducible exampele.</p> <p>Index Page:</p> <pre><code>@model TestModel @{ ViewData[&quot;Title&quot;] = &quot;Home Page&quot;; } &lt;div class=&quot;text-center&quot;&gt; &lt;form asp-controller=&quot;Home&quot; asp-action=&quot;GetValue&quot;&gt; &lt;input asp-for=&quot;WantedValue&quot; type=&quot;number&quot; step=&quot;0.1&quot; /&gt; &lt;button type=&quot;submit&quot;&gt;Test&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>HomeController just added this 1 function:</p> <pre><code>public IActionResult GetValue(TestModel test) { return RedirectToAction(&quot;Index&quot;); } </code></pre> <p>Model:</p> <pre><code>public class TestModel { public double WantedValue { get; set; } } </code></pre> <p>it is still the same, if i enter a float value on the index:</p> <p><a href="https://i.stack.imgur.com/VNgEe.png" rel="nofollow noreferrer">Value entered by User on Index</a></p> <p>the Controller still gets a wrong value:</p> <p><a href="https://i.stack.imgur.com/hqYhc.png" rel="nofollow noreferrer">Wrong Value received from Form</a></p> <p>since i entered &quot;<code>1,1</code>&quot; on the Index site i was expecting to get the value &quot;<code>1,1</code>&quot; in the controller. Same with the Value &quot;<code>1.1</code>&quot;</p>
[ { "answer_id": 74149630, "author": "Muhsin SARAL", "author_id": 20290539, "author_profile": "https://Stackoverflow.com/users/20290539", "pm_score": 1, "selected": true, "text": "PS C:\\Users\\m.saral\\Desktop\\app\\my-app> npm -v\n8.19.2\n" } ]
2022/10/20
[ "https://Stackoverflow.com/questions/74138499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20290504/" ]
74,138,584
<p>Am trying to convert a .py application to an apk file using Google Colab but I keep encountering this error:</p> <pre><code>[DEBUG]: ERROR: Could not find a version that satisfies the requirement kivy-deps.angle (from versions: none) [DEBUG]: ERROR: No matching distribution found for kivy-deps.angle </code></pre> <p>I am using Python 3.9.9 and Kivy version 2.1.0 and I have installed all Kivy packages but each time I try converting my .py file to apk using Google Colab am getting the above mentioned error</p> <p>Here is the requirements for my .py application</p> <pre><code>C:\Users\26095\Desktop\TEQ_ANDROID&gt;pip show kivy Name: Kivy Version: 2.1.0 Summary: A software library for rapid development of hardware-accelerated multitouch applications. Home-page: http://kivy.org Author: Kivy Team and other contributors Author-email: kivy-dev@googlegroups.com License: MIT Location: c:\users\26095\appdata\roaming\python\python39\site-packages Requires: docutils, kivy-deps.angle, kivy-deps.glew, kivy-deps.sdl2, Kivy-Garden, pygments, pypiwin32 Required-by: </code></pre> <p>Here is part of my bulldozer.spec file where I have added all the requirements</p> <pre><code># comma separated e.g. requirements = sqlite3,kivy requirements = python3, kivy, docutils, kivy-deps.angle, kivy-deps.glew, kivy-deps.sdl2, Kivy-Garden, pygments, pypiwin32 </code></pre> <p>How can I resolve this issue?</p>
[ { "answer_id": 74149630, "author": "Muhsin SARAL", "author_id": 20290539, "author_profile": "https://Stackoverflow.com/users/20290539", "pm_score": 1, "selected": true, "text": "PS C:\\Users\\m.saral\\Desktop\\app\\my-app> npm -v\n8.19.2\n" } ]
2022/10/20
[ "https://Stackoverflow.com/questions/74138584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18927042/" ]
74,138,598
<p>I have these classes</p> <pre><code>public class SubMenuItem : SubMenuVariant { public string SubMenuTitle { get; set; } public LinkFieldType Link { get; set; } public List&lt;SubMenuSubItem&gt; SubItems { get; set; } } public class SubMenuHighlightItem : SubMenuVariant { [JsonPropertyName(FieldNames.HighlightTitle)] public string HighlightTitle { get; set; } [JsonPropertyName(FieldNames.HighlightText)] public string HighlightText { get; set; } [JsonPropertyName(FieldNames.HighlightText)] public Link HighLightLink { get; set; } } public class SubMenuVariant { } </code></pre> <p>Which I currently store in a <code>List&lt;SubMenuVariant&gt; submenu</code></p> <p>Problem is though I am not able to access the individual properties the different menues have, since they are being casted to a SubMenuVariant, which don't have any properties.</p> <p>The list can only contain one type, at no point will both types exist in the list. The items is not being added explicitly to the list, but is being created by JsonSerializer.Deserialize a json request, which contains the properties, to the baseclass.</p> <p>So the json can either look like this:</p> <pre><code>{ &quot;submenu&quot;: [ { &quot;SubMenuTitle &quot; : &quot;Title&quot;, &quot;Link&quot; : &quot;Link&quot;, &quot;SubItems&quot; : [ {...} ] } ] } </code></pre> <p>Or</p> <pre><code> { &quot;submenu&quot;: [ { &quot;HighlightTitle &quot; : &quot;Title&quot;, &quot;HighlightLink&quot; : &quot;Link&quot;, &quot;HighlightText&quot; : &quot;Text&quot; } ] } </code></pre> <p>Is it somehow possible to store different class types in the same list?</p>
[ { "answer_id": 74138620, "author": "Oliver Weichhold", "author_id": 88513, "author_profile": "https://Stackoverflow.com/users/88513", "pm_score": 0, "selected": false, "text": "List<object>" }, { "answer_id": 74138779, "author": "jmcilhinney", "author_id": 584183, "au...
2022/10/20
[ "https://Stackoverflow.com/questions/74138598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7400630/" ]
74,138,618
<p>I have a function that manipulates an array of unknown objects in which I have a <code>nested_key</code> as parameter. When I'm trying to use it for accessing a key in the object, typescript of course complains because it doesn't know the key is present in the object. Is there any way to define an interface that would take that parameter and add it into the typescript interface as key?</p> <p>Simplified function:</p> <pre><code>interface NestedItem { [key: string]: unknown } function manipulate(arr: NestedItem[], nested_key: string) { console.log(arr[0][nested_key].length) } </code></pre> <p>So what I need exactly is to somehow use the value of <code>nested_key</code> like e.g. this:</p> <pre><code>interface NestedItem { [key: nested_value]: unknown[] } </code></pre> <p>I also tried to first check whether the prop is the correct type but that seems not to help when checking with this function:</p> <p><code>const is_array = (value: unknown): value is unknown[] =&gt; Array.isArray(value)</code></p>
[ { "answer_id": 74138620, "author": "Oliver Weichhold", "author_id": 88513, "author_profile": "https://Stackoverflow.com/users/88513", "pm_score": 0, "selected": false, "text": "List<object>" }, { "answer_id": 74138779, "author": "jmcilhinney", "author_id": 584183, "au...
2022/10/20
[ "https://Stackoverflow.com/questions/74138618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10272819/" ]
74,138,645
<p>in Flutter 3.3.4 , I want control the state of the button by passing an object with its properties . I tried some solutions in stackoverflow (e.g <a href="https://stackoverflow.com/questions/49351648/how-do-i-disable-a-button-in-flutter">How do I disable a Button in Flutter?</a> ),but failed。</p> <p>I print the flag of the object , it looks right.</p> <p>here is my code</p> <pre><code>// Copyright 2018 The Flutter team. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { SwitchWidget wifiSwitch = SwitchWidget(); // SwitchWidget timeSwitch = SwitchWidget(); // SwitchWidget locationSwitch = SwitchWidget(); return MaterialApp( title: 'Startup N1ame Generator', home: Scaffold( appBar: AppBar( title: const Text('Startup Name Generator'), ), body: Center( child: Row( children: [ Column(children: [wifiSwitch]), Column(children: [ButtonWidget(wifiSwitch)]) ], ), ), ), ); } } class SwitchWidget extends StatefulWidget { bool flag = true; SwitchWidget({Key? key}) : super(key: key); @override State&lt;SwitchWidget&gt; createState() =&gt; _SwitchWidgetState(this); } class _SwitchWidgetState extends State&lt;SwitchWidget&gt; { SwitchWidget switchWidget; _SwitchWidgetState(this.switchWidget); @override Widget build(BuildContext context) { return Container( child: Switch( value: switchWidget.flag, onChanged: (newValue) =&gt; { setState(() { switchWidget.flag = newValue; print(&quot;-----------${switchWidget.flag}&quot;); }) }, ), ); } } class ButtonWidget extends StatefulWidget { late SwitchWidget _switchWidget; SwitchWidget get switchWidget =&gt; _switchWidget; set switchWidget(SwitchWidget switchWidget) =&gt; { print('The ButtonWidget is $switchWidget.'), _switchWidget = switchWidget }; ButtonWidget(switchWidget, {Key? key}) : super(key: key) { this.switchWidget = switchWidget; } @override State&lt;ButtonWidget&gt; createState() =&gt; _ButtonWidgetState(switchWidget); } class _ButtonWidgetState extends State&lt;ButtonWidget&gt; { SwitchWidget switchWidget; _ButtonWidgetState(this.switchWidget); @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.fromLTRB(50, 1, 1, 1), child: ElevatedButton( // color: Colors.blue, // disabledColor: Colors.grey, // textColor: Colors.black, child: Text(&quot;123&quot;), // onPressed: () {}, onPressed: this.switchWidget.flag ? _incrementCounter : null, style: ButtonStyle( foregroundColor: MaterialStateProperty.resolveWith( (states) { if (states.contains(MaterialState.disabled)) { return Colors.grey; } else { return Colors.white; } }, ), )), ); {} } void _incrementCounter() { print(&quot;object******** ${this.switchWidget.flag}&quot;); } } </code></pre>
[ { "answer_id": 74138620, "author": "Oliver Weichhold", "author_id": 88513, "author_profile": "https://Stackoverflow.com/users/88513", "pm_score": 0, "selected": false, "text": "List<object>" }, { "answer_id": 74138779, "author": "jmcilhinney", "author_id": 584183, "au...
2022/10/20
[ "https://Stackoverflow.com/questions/74138645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20290300/" ]
74,138,678
<p>I have a pandas dataframe:</p> <pre><code> id val label &quot;a1&quot; &quot;ab&quot; &quot;first&quot; &quot;a1&quot; &quot;aa&quot; &quot;second&quot; &quot;a1&quot; &quot;ca&quot; &quot;third&quot; &quot;b1&quot; &quot;cc&quot; &quot;first&quot; &quot;b1&quot; &quot;kf&quot; &quot;second&quot; &quot;b1&quot; &quot;ff&quot; &quot;third&quot; &quot;c1&quot; &quot;wer&quot; &quot;first&quot; &quot;c1&quot; &quot;iid&quot; &quot;second&quot; &quot;c1&quot; &quot;ff&quot; &quot;third&quot; </code></pre> <p>I want to transform it into dictionary wwhere key will be values from columns &quot;id&quot; and values will be dictionaries with keys &quot;label&quot; and values from column &quot;val&quot;. so the output must be:</p> <pre><code>{&quot;a1&quot;: {&quot;first&quot;: {&quot;ab&quot;}, &quot;second&quot;: {&quot;aa&quot;}, &quot;third&quot;: {&quot;ca&quot;}}, &quot;b1&quot;: {&quot;first&quot;: {&quot;cc&quot;}, &quot;second&quot;: {&quot;kf&quot;}, &quot;third&quot;: {&quot;ff&quot;}}, &quot;c1&quot;: {&quot;first&quot;: {&quot;wer&quot;}, &quot;second&quot;: {&quot;iid&quot;}, &quot;third&quot;: {&quot;ff&quot;}}, } </code></pre> <p>how could I do that?</p>
[ { "answer_id": 74138620, "author": "Oliver Weichhold", "author_id": 88513, "author_profile": "https://Stackoverflow.com/users/88513", "pm_score": 0, "selected": false, "text": "List<object>" }, { "answer_id": 74138779, "author": "jmcilhinney", "author_id": 584183, "au...
2022/10/20
[ "https://Stackoverflow.com/questions/74138678", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12314164/" ]
74,138,741
<p>This is a sample code:</p> <pre><code>var1 = float(input('Enter time interval: ')) print(f'OK, time interval is {var1}') # doing something with above variable </code></pre> <p>I want to run this <code>python</code> file like this without changing the code if possible:</p> <pre><code>python file.py 0&lt;'15' </code></pre> <p>But I get this error:</p> <pre><code>-bash: 15: No such file or directory </code></pre>
[ { "answer_id": 74138620, "author": "Oliver Weichhold", "author_id": 88513, "author_profile": "https://Stackoverflow.com/users/88513", "pm_score": 0, "selected": false, "text": "List<object>" }, { "answer_id": 74138779, "author": "jmcilhinney", "author_id": 584183, "au...
2022/10/20
[ "https://Stackoverflow.com/questions/74138741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5790653/" ]
74,138,754
<p>Sorry for all mistakes, English is not my native language. I'm relatively new in c++ and I have problem with understanding If I have a method that should be overridden and requires no parameters but I already have function that does exactly same job but requires two parameters should I rewrite my old method or this problem can be solved without rewriting? This function should be overridden:</p> <pre><code>virtual void read() = 0; </code></pre> <p>This is working function with two parameters required:</p> <pre><code>void read(rclcpp::Time time, rclcpp::Duration period){ ... } </code></pre>
[ { "answer_id": 74138620, "author": "Oliver Weichhold", "author_id": 88513, "author_profile": "https://Stackoverflow.com/users/88513", "pm_score": 0, "selected": false, "text": "List<object>" }, { "answer_id": 74138779, "author": "jmcilhinney", "author_id": 584183, "au...
2022/10/20
[ "https://Stackoverflow.com/questions/74138754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20290786/" ]
74,138,769
<p>Is there a way to run terraform apply for a specific tfstate file? By default it takes terraform.tfstate but I need to rename it as I am managing multiple state files in azure.</p> <p>Folder structure:<a href="https://i.stack.imgur.com/V43AR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V43AR.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74138620, "author": "Oliver Weichhold", "author_id": 88513, "author_profile": "https://Stackoverflow.com/users/88513", "pm_score": 0, "selected": false, "text": "List<object>" }, { "answer_id": 74138779, "author": "jmcilhinney", "author_id": 584183, "au...
2022/10/20
[ "https://Stackoverflow.com/questions/74138769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14332374/" ]
74,138,800
<p>As mentioned in <a href="https://github.com/ktorio/ktor-cli" rel="nofollow noreferrer">ktor cli</a> website, I'm trying to install it in my Linux machine. But I ended up with below error.</p> <blockquote> <p>error: cannot install &quot;ktor&quot;: persistent network error: Post <a href="https://api.snapcraft.io/v2/snaps/refresh" rel="nofollow noreferrer">https://api.snapcraft.io/v2/snaps/refresh</a>: dial tcp: lookup api.snapcraft.io: Temporary failure in name resolution</p> </blockquote> <p>Is it possible to install Ktor on Linux and how to create and run a project?</p>
[ { "answer_id": 74138620, "author": "Oliver Weichhold", "author_id": 88513, "author_profile": "https://Stackoverflow.com/users/88513", "pm_score": 0, "selected": false, "text": "List<object>" }, { "answer_id": 74138779, "author": "jmcilhinney", "author_id": 584183, "au...
2022/10/20
[ "https://Stackoverflow.com/questions/74138800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/265341/" ]
74,138,811
<p>I have the following table:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Quarter Start</th> </tr> </thead> <tbody> <tr> <td>30/12/2016</td> </tr> <tr> <td>31/03/2017</td> </tr> <tr> <td>30/06/2017</td> </tr> <tr> <td>29/09/2017</td> </tr> <tr> <td>29/12/2017</td> </tr> <tr> <td>30/03/2018</td> </tr> <tr> <td>29/06/2018</td> </tr> <tr> <td>28/09/2018</td> </tr> <tr> <td>28/12/2018</td> </tr> <tr> <td>29/03/2019</td> </tr> <tr> <td>28/06/2019</td> </tr> <tr> <td>27/09/2019</td> </tr> <tr> <td>27/12/2019</td> </tr> <tr> <td>27/03/2020</td> </tr> <tr> <td>26/06/2020</td> </tr> <tr> <td>25/09/2020</td> </tr> <tr> <td>01/01/2021</td> </tr> <tr> <td>02/04/2021</td> </tr> <tr> <td>02/07/2021</td> </tr> <tr> <td>01/10/2021</td> </tr> <tr> <td>31/12/2021</td> </tr> <tr> <td>01/04/2022</td> </tr> <tr> <td>01/07/2022</td> </tr> <tr> <td>30/09/2022</td> </tr> <tr> <td>30/12/2022</td> </tr> <tr> <td>24/03/2023</td> </tr> <tr> <td>30/06/2023</td> </tr> <tr> <td>29/09/2023</td> </tr> <tr> <td>29/12/2023</td> </tr> <tr> <td>29/03/2024</td> </tr> <tr> <td>28/06/2024</td> </tr> <tr> <td>27/09/2024</td> </tr> <tr> <td>03/01/2025</td> </tr> <tr> <td>04/04/2025</td> </tr> <tr> <td>03/10/2025</td> </tr> <tr> <td>02/01/2026</td> </tr> <tr> <td>03/04/2026</td> </tr> <tr> <td>03/07/2026</td> </tr> <tr> <td>02/10/2026</td> </tr> <tr> <td>01/01/2027</td> </tr> <tr> <td>02/04/2027</td> </tr> <tr> <td>02/07/2027</td> </tr> <tr> <td>01/10/2027</td> </tr> </tbody> </table> </div> <p>What can I write to always select the current quarter according to this table and the current date? For eg the current quarter is '09/12/2022', how can I always ensure to select the current quarter?</p> <p>Many thanks</p> <p>UPDATE: I have run by some of the suggestions as follows</p> <pre><code>SELECT quarter_start, EXTRACT (QUARTER FROM quarter_start) FROM odwh_work.sdc_2027 WHERE EXTRACT (QUARTER FROM quarter_start) = EXTRACT (QUARTER FROM current_date) ORDER BY 1 DESC </code></pre> <p>But I am still not returning 2022-12-09</p>
[ { "answer_id": 74138864, "author": "kometen", "author_id": 319826, "author_profile": "https://Stackoverflow.com/users/319826", "pm_score": 1, "selected": false, "text": "select * from foo where extract('quarter' from 'Quarter Start') = extract('quarter' from now());\n" }, { "answ...
2022/10/20
[ "https://Stackoverflow.com/questions/74138811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16562053/" ]
74,138,818
<p>i used to use my Laravel Project with PhP 5.6 and i'm using barcode Gnerator for my project some where and to do this i use this package .</p> <pre><code>laravel/laravel barcode_blog </code></pre> <p>now i upgraded my PhP To 7.4 (note: didn't upgrade my laravel yet). everything is working fine just when i search for a spasific barcode i got this error :</p> <pre><code>ErrorException in BarcodeGenerator.php line 293: Array and string offset access syntax with curly braces is deprecated (View:.../.../..) </code></pre> <p>now this is the code :</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;tr&gt; &lt;td width="19%"&gt;serial NUM&lt;/td&gt; &lt;td style="width: 1%"&gt;:&lt;/td&gt; &lt;td colspan="2"&gt; @if (!empty($INSTANCE)) &lt;?php $generator = new \Picqer\Barcode\BarcodeGeneratorHTML(); ?&gt; {!! $generator-&gt;getBarcode($INSTANCE-&gt;barcode, $generator::TYPE_CODE_128) !!} @endif &lt;/td&gt; &lt;/tr&gt;</code></pre> </div> </div> </p> <p>And I know the problem is with $generator = new \Picqer\Barcode\BarcodeGeneratorHTML(); this line when i delete it my code is working fine but i need it in the code how to use it in php 7.4 i belive it get changed</p>
[ { "answer_id": 74138864, "author": "kometen", "author_id": 319826, "author_profile": "https://Stackoverflow.com/users/319826", "pm_score": 1, "selected": false, "text": "select * from foo where extract('quarter' from 'Quarter Start') = extract('quarter' from now());\n" }, { "answ...
2022/10/20
[ "https://Stackoverflow.com/questions/74138818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19426344/" ]
74,138,824
<p>This compiles:</p> <pre class="lang-swift prettyprint-override"><code>let badger = get_closure() func get_closure() -&gt; (Int) -&gt; Void { return { (x: Int) -&gt; Void in print(x) if x &gt; 4 { return } else { badger(x + 1) } } } badger(1) </code></pre> <p>This doesn't with circular reference errors:</p> <pre class="lang-swift prettyprint-override"><code>let badger = get_closure() let get_closure = { () -&gt; (Int) -&gt; Void in return { (x: Int) -&gt; Void in print(x) if x &gt; 4 { return } else { badger(x + 1) } } } badger(1) </code></pre> <p>Why? I thought the <code>func</code> syntax is just sugar for the second more explicit syntax.</p>
[ { "answer_id": 74143035, "author": "Andrew Bekhtold", "author_id": 8927831, "author_profile": "https://Stackoverflow.com/users/8927831", "pm_score": 0, "selected": false, "text": "let get_closure: (Int) -> Void = { x in\n print(x)\n if x > 4 {\n return\n } else {\n b...
2022/10/20
[ "https://Stackoverflow.com/questions/74138824", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1532059/" ]
74,138,833
<p>I have a couple of old ETL jobs that need to be adopted to Prefect flows. All of them are utilizing <code>print</code> statements for logging. Jobs should be backward-compatible and keep printing existing messaged to stdout and stderr. The issue is that stout and stderr messages are ignored by Orion UI for viewing logs.</p> <p><strong>Long story short</strong>, I simply need stdout and stderr messages handled as logger.info and logger.warning respectively.</p> <p>In Prefect v1 there was <a href="https://docs-v1.prefect.io/core/concepts/logging.html#logging-stdout" rel="nofollow noreferrer">a native option</a> to forward stdout to logger. However, it's removed in v2.</p> <p>Anything native I'm missing here?</p>
[ { "answer_id": 74138834, "author": "Oleh Rybalchenko", "author_id": 7732200, "author_profile": "https://Stackoverflow.com/users/7732200", "pm_score": 2, "selected": false, "text": "class Logger:\n def __init__(self, level):\n self.level = level\n\n def write(self, message):\...
2022/10/20
[ "https://Stackoverflow.com/questions/74138833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7732200/" ]
74,138,848
<p>I have the following dataset:</p> <pre><code>Name Loc Site Date Total Alex Italy A 12.31.2020 30 Alex Italy B 12.31.2020 40 Alex Italy B 12.30.2020 100 Alex Italy A 12.30.2020 80 Alex France A 12.28.2020 10 Alex France B 12.28.2020 20 Alex France B 12.27.2020 10 </code></pre> <p>I want to add per each row the average of total in the day before the date per Name, Loc and Date</p> <p>This is the outcome I'm looking for:</p> <pre><code>Name Loc Site Date Total Prv_Avg Alex Italy A 12.31.2020 30 90 Alex Italy B 12.31.2020 40 90 Alex Italy B 12.30.2020 100 NULL Alex Italy A 12.30.2020 80 NULL Alex France A 12.28.2020 10 10 Alex France B 12.28.2020 20 10 Alex France B 12.27.2020 10 NULL </code></pre> <p>The Nulls are for rows where previous date couldn't be found.</p> <p>I've tried rolling but got mixed up with the index.</p>
[ { "answer_id": 74138912, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 3, "selected": true, "text": "mean" }, { "answer_id": 74140777, "author": "PaulS", "author_id": 11564487, "author_profile": "ht...
2022/10/20
[ "https://Stackoverflow.com/questions/74138848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10160198/" ]
74,138,860
<p>Is there a way to check if values in column has spaces in it?</p> <pre><code>asd &lt;- data.frame(a = c(&quot;new &quot;, &quot;Old&quot;), b = c(&quot;Cta&quot;, &quot;df&quot;)) </code></pre> <p>We have space in &quot;a&quot; column. So expected output to be</p> <pre><code> a b spaceInCola 1 new Cta TRUE 2 Old df FALSE </code></pre>
[ { "answer_id": 74138902, "author": "Aron Strandberg", "author_id": 4885169, "author_profile": "https://Stackoverflow.com/users/4885169", "pm_score": 2, "selected": false, "text": "grepl" }, { "answer_id": 74139016, "author": "Quinten", "author_id": 14282714, "author_p...
2022/10/20
[ "https://Stackoverflow.com/questions/74138860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11740857/" ]
74,138,863
<p>In my flutter app I am exploring a transition from the Provider package to Riverpod. The app is quite simple: it fetches a list of objects from a database, and allows the user to change these objects's characteristics. It is thus pretty similar to the <a href="https://github.com/rrousselGit/riverpod/tree/master/examples/todos" rel="nofollow noreferrer">official TODO example app</a>.</p> <p>I see however that such app does not provide an individual provider for each TODO item as I'd expect, but it rather declares a global provider the entire TODO list. I found such approach odd, as it requires that everytime a TODO item changes the entire list UI needs to be rebuilt (unless I am mistaken).</p> <p>Reading through other examples, I see that all providers are always declared globally. Does this mean it is not possible with Riverpod to create new providers at runtime? (As in my case, from a list of objects returned by an API?)</p> <p>I'm sorry if it is a trivial question, but I couldn't find any related example or documentation about this.</p> <p><strong>EDIT:</strong> I was mistaken indeed. The entire list is NOT rebuilt in its entirety. See answers below.</p>
[ { "answer_id": 74138902, "author": "Aron Strandberg", "author_id": 4885169, "author_profile": "https://Stackoverflow.com/users/4885169", "pm_score": 2, "selected": false, "text": "grepl" }, { "answer_id": 74139016, "author": "Quinten", "author_id": 14282714, "author_p...
2022/10/20
[ "https://Stackoverflow.com/questions/74138863", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8965508/" ]
74,138,879
<p>I want to render some stars based on a specific value, and this is what I have done so far</p> <pre><code>const Rating = ({ value }) =&gt; { const renderStars = () =&gt; { let stars = []; // This array should contain all stars either full, half or empty star for (let i = 0; i &lt; value; i++) { if (value % 1 !== 0) { // If the value has decimal number } else { // If the value has NO decimal number } } return stars?.map((star) =&gt; star); // Mapping the stars array }; return &lt;div className=&quot;rating&quot;&gt;{renderStars()}&lt;/div&gt;; }; export default Rating; </code></pre> <p>Now I have 3 icons: a full star, a half star, and an empty star. Let's say the rating value is 3.5, so what I want is to push to the stars array 3 full stars 1 half star and 1 empty star so that will be 5 stars in total. And then I can map through the array and render all the stars.</p>
[ { "answer_id": 74139069, "author": "Nick Parsons", "author_id": 5648954, "author_profile": "https://Stackoverflow.com/users/5648954", "pm_score": 3, "selected": true, "text": "value" }, { "answer_id": 74139180, "author": "Ali Faiz", "author_id": 15280808, "author_prof...
2022/10/20
[ "https://Stackoverflow.com/questions/74138879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18440430/" ]
74,138,929
<p>I working on a project that needs validation for the Login form to be done before submitting,</p> <p>And make the button disable until all form is valid in react js ( function component )?</p> <p>I write this code and I do not know how can make the button disable until every single field is valid</p> <p>also, I am a beginner in react js</p> <p>any advice, please?</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>import React, { useState } from "react"; import { emailValidator, passwordValidator } from "./regexValidator"; import { useNavigate } from "react-router-dom"; export default function Login() { const navigate = useNavigate(); const [isDisabled, setDisable] = useState(true); const [input, setInput] = useState({ email: "", password: "" }); const [errorPassword, seterrorPassword] = useState(""); const [errorEmail, seterrorEmail] = useState(""); const handleChange = (e) =&gt; { setInput({ ...input, [e.target.name]: e.target.value }); }; const formSubmitter = (e) =&gt; { e.preventDefault(); onKey(); navigate("/"); }; const onKey = (e) =&gt; { e.preventDefault(); setDisable(true); if (!emailValidator(input.email)) { seterrorEmail("Please enter valid email id"); } else { seterrorEmail(""); } if (!passwordValidator(input.password)) { seterrorPassword("Please enter valid password"); } else { seterrorPassword(""); setDisable(false); } }; return ( &lt;form onSubmit={formSubmitter}&gt; &lt;input type="email" name="email" onChange={handleChange} onKeyUp={onKey} error={errorEmail} /&gt; &lt;input name="password" onChange={handleChange} onKeyUp={onKey} error={errorPassword} /&gt; &lt;button type="button" disabled={isDisabled} /&gt; &lt;/form&gt; ); }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.1/umd/react.production.min.js"&gt;&lt;/script&gt; &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.1/umd/react-dom.production.min.js"&gt;&lt;/script&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74139069, "author": "Nick Parsons", "author_id": 5648954, "author_profile": "https://Stackoverflow.com/users/5648954", "pm_score": 3, "selected": true, "text": "value" }, { "answer_id": 74139180, "author": "Ali Faiz", "author_id": 15280808, "author_prof...
2022/10/20
[ "https://Stackoverflow.com/questions/74138929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20198038/" ]
74,138,968
<p>I can get the HICON with <a href="https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-extracticonw" rel="nofollow noreferrer">ExtractIconW</a></p> <p>for example:</p> <pre class="lang-golang prettyprint-override"><code>package main import ( &quot;log&quot; &quot;syscall&quot; &quot;unsafe&quot; ) func MakeIntResource(id uintptr) *uint16 { return (*uint16)(unsafe.Pointer(id)) } const IDI_QUESTION = 32514 func main() { user32Dll := syscall.NewLazyDLL(&quot;User32.dll&quot;) procLoadIconW := user32Dll.NewProc(&quot;LoadIconW&quot;) hIcon, _, _ := syscall.SyscallN(procLoadIconW.Addr(), 0, uintptr(unsafe.Pointer(MakeIntResource(IDI_QUESTION))), ) log.Println(hIcon) } </code></pre> <p>But I don't know what I should do next to save HICON as a file (bitmap format is enough).</p>
[ { "answer_id": 74139969, "author": "Anders", "author_id": 3501, "author_profile": "https://Stackoverflow.com/users/3501", "pm_score": 2, "selected": false, "text": "RT_ICON" }, { "answer_id": 74314179, "author": "Carson", "author_id": 9935654, "author_profile": "https...
2022/10/20
[ "https://Stackoverflow.com/questions/74138968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9935654/" ]
74,138,982
<p>I have the mazeGen class that generates a maze using a version of prims algorithm using JS and P5.JS. Within the mazeGen class i have a display funtion that logs the maze to console. When i run this line it says it is not defined as a funtion. THe class will be used in another progect to generate multiple mazes to need it as a class</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>let maze1 function setup() { maze1 = new MazeGen(11); maze1.display() } function draw() { background(220); } class MazeGen { constructor(size) { console.warn('in funt') this.size = size this.maze = new Array(this.size); for (let i = 0; i &lt; this.maze.length; i++) { this.maze[i] = new Array(this.size); for (let j = 0; j &lt; this.maze.length; j++) { this.maze[i][j] = 0 } } this.maze = this.PrimsAlgorithm() this.maze[1][0] = 3; this.maze[this.maze.length - 2][this.maze.length - 1] = 2; console.table(this.maze); return this.maze; } PrimsAlgorithm() { this.frontAvailable = [0, 0, 0, 0]; this.currentCell = [1, 1]; while (this.Complete(this.maze, this.size) === false) { //Console.WriteLine("Maze is not ready"); this.maze[this.currentCell[0]][this.currentCell[1]] = 1; this.frontAvailable = this.Frontier(this.maze, this.currentCell); //While the list of frontier cells is not empty while (this.frontAvailable[0] !== 0 || this.frontAvailable[1] !== 0 || this.frontAvailable[2] !== 0 || this.frontAvailable[3] !== 0) { //pick a random way this.picked = false; this.numSelected = 5; while (this.picked === false) { this.numSelected = Math.floor(Math.random() * 5); if (this.frontAvailable[this.numSelected] === 1) { this.picked = true; } } //'Move to cell' this.maze = this.MoveSquare(); this.frontAvailable = this.Frontier(); //Maze.PrintWhole(maze); } //List of frontier Cells is now empty //Move to random cell and check if it is a path this.currentCell = this.NewCurrent(); } return this.maze; } Frontier() { this.available = [0, 0, 0, 0]; //left check if (((this.currentCell[1]) - 2) &gt;= 0 &amp;&amp; this.maze[this.currentCell[0]][(this.currentCell[1]) - 2] === 0) { this.available[0] = 1; } else { this.available[0] = 0; } //up check if (((this.currentCell[0]) - 2) &gt;= 0 &amp;&amp; this.maze[(this.currentCell[0]) - 2][(this.currentCell[1])] === 0) { this.available[1] = 1; } else { this.available[1] = 0; } //right check if (this.currentCell[1] + 2 &lt; this.maze.length) { if (this.maze[this.currentCell[0]][(this.currentCell[1]) + 2] === 0) { this.available[2] = 1; } } else { this.available[2] = 0; } //down check if (this.currentCell[0] + 2 &lt; this.maze.length) { if (this.maze[this.currentCell[0] + 2][this.currentCell[1]] === 0) { this.available[3] = 1; } } else { this.available[3] = 0; } return this.available; } NewCurrent() { this.found = false this.currentCell = []; while (this.found === false) { this.cellX = Math.floor(Math.random() * (this.maze.length - 3) / 2) this.cellX = this.cellX * 2 + 1 this.cellY = Math.floor(Math.random() * (this.maze.length - 3) / 2) this.cellY = this.cellY * 2 + 1 if (this.maze[this.cellX][this.cellY] === 1) { this.currentCell[0] = this.cellX; this.currentCell[1] = this.cellY; this.found = true } } return this.currentCell; } MoveSquare() { if (this.numSelected === 0) { this.maze[this.currentCell[0]][(this.currentCell[1]) - 2] = 1; this.maze[this.currentCell[0]][(this.currentCell[1]) - 1] = 1; this.currentCell[1] = this.currentCell[1] - 2; } if (this.numSelected === 1) { this.maze[(this.currentCell[0]) - 2][(this.currentCell[1])] = 1; this.maze[(this.currentCell[0]) - 1][(this.currentCell[1])] = 1; this.currentCell[0] = this.currentCell[0] - 2; } if (this.numSelected === 2) { this.maze[this.currentCell[0]][(this.currentCell[1]) + 2] = 1; this.maze[this.currentCell[0]][(this.currentCell[1]) + 1] = 1; this.currentCell[1] = this.currentCell[1] + 2; } if (this.numSelected === 3) { this.maze[(this.currentCell[0]) + 2][(this.currentCell[1])] = 1; this.maze[(this.currentCell[0]) + 1][(this.currentCell[1])] = 1; this.currentCell[0] = this.currentCell[0] + 2; } return this.maze; } Complete() { let counter = 0; //Console.WriteLine(counter); for (let i = 0; i &lt; (this.size - 1) / 2; i++) { for (let j = 0; j &lt; (this.size - 1) / 2; j++) { let X = (2 * i) + 1; let Y = (2 * j) + 1; if (this.maze[X][Y] === 1) { counter++; } } } return counter === (this.size - 1) / 2 * (this.size - 1) / 2; } display(){ console.table(this.maze); } }</code></pre> </div> </div> </p>
[ { "answer_id": 74140754, "author": "Archigan", "author_id": 14333778, "author_profile": "https://Stackoverflow.com/users/14333778", "pm_score": 0, "selected": false, "text": ".display()" }, { "answer_id": 74140870, "author": "angel.bonev", "author_id": 3768239, "autho...
2022/10/20
[ "https://Stackoverflow.com/questions/74138982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17429145/" ]
74,138,989
<p>Has the Following Feature has been implemented for Gihub Repos yet?<strong>strong text</strong></p> <p>Multi-repo triggers You can specify multiple repositories in one YAML file and cause a pipeline to trigger by updates to any of the repositories. This feature is useful, for instance, in the following scenarios:</p> <p>You consume a tool or a library from a different repository. You want to run tests for your application whenever the tool or library is updated. You keep your YAML file in a separate repository from the application code. You want to trigger the pipeline every time an update is pushed to the application repository. With this update, multi-repo triggers will only work for Git repositories in Azure Repos. They don't work for GitHub or Bitbucket repository resources.</p> <p>SAMPLE :</p> <p>trigger:</p> <ul> <li>main</li> </ul> <p>resources: repositories: - repository: tools type: git name: MyProject/tools ref: main trigger: branches: include: - main - release</p>
[ { "answer_id": 74140754, "author": "Archigan", "author_id": 14333778, "author_profile": "https://Stackoverflow.com/users/14333778", "pm_score": 0, "selected": false, "text": ".display()" }, { "answer_id": 74140870, "author": "angel.bonev", "author_id": 3768239, "autho...
2022/10/20
[ "https://Stackoverflow.com/questions/74138989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20291074/" ]
74,139,021
<p>I have a column which I am splitting in Snowflake.</p> <p>The format is as follows:</p> <p><a href="https://i.stack.imgur.com/e73YD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e73YD.png" alt="enter image description here" /></a></p> <p>I have been using <code>split_to_table(A, ',')</code> inside of my query but as you can probably tell this uncorrectly also splits the <code>Scooter &gt; Sprinting, Jogging and Walking</code> record.</p> <p>Perhaps having the delimiter only work if there is no spaced on either side of it? As I cannot see a different condition that could work.</p> <p>I have been researching online but haven't found a suitable work around yet, is there anyone that encountered a similar problem in the past?</p> <p>Thanks</p>
[ { "answer_id": 74139266, "author": "Marcel", "author_id": 12480431, "author_profile": "https://Stackoverflow.com/users/12480431", "pm_score": 1, "selected": false, "text": "select replace(t.value, 'my_replacement', ', ') \nfrom table(\n split_to_table(replace('Car > Bike,Bike >...
2022/10/20
[ "https://Stackoverflow.com/questions/74139021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18701902/" ]
74,139,043
<p>(To preface, I know/believe you could use numpy.loadtxt and pandas but I want to know how to achieve the same result without them.)</p> <p>I would have a csv file like this, after opening it and assigning it to file while also using splitlines():</p> <pre><code>file = 'Top1','Top2','Top3','Top4','Top5' '1','a','3','b','5' 'a','2','b','3','c' '1','a','3','b','5' </code></pre> <p>How could I go about converting the file into a dictionary, with the top row being the keys, and the column underneath each key being its value, like so:</p> <pre><code>a_dict = { 'top1': ['1', 'a', '1'], 'top2': ['a', '2', 'a'], 'top3': ['3', 'b', '3'], 'top4': ['b', '3', 'b'], 'top5': ['5', 'c', '5'] } </code></pre> <p>I tried by doing this first:</p> <pre><code>a_dict = {} for i in file[0].split(','): a_dict[i] = '' print(a_dict) </code></pre> <p>which gave me:</p> <pre><code>a_dict = {&quot;'top1'&quot;: '', &quot;'top2'&quot;: '', &quot;'top3'&quot;: '', &quot;'top4'&quot;: '', &quot;'top5'&quot;: ''} </code></pre> <p>then, to get the columns into lists I tried:</p> <pre><code>prac_list = [] for i in file[1:]: i = i.split(',') x = 0 prac_list.append(num[x]) x+=1 print (prac_list) </code></pre> <p>and that gave me:</p> <pre><code>prac_list = [&quot;'1'&quot;, &quot;'a'&quot;, &quot;'1'&quot;] </code></pre> <p>but I got stuck up to that point, the idea was to have the <code>for loop</code> go through elements below the first row, and have it so each loop iteration would take the <code>x</code>'th index of each row and append them together as one element in the list like <code>['1', 'a', '1']</code>. eg:</p> <pre><code>x = 0 for i in file[1:]: get x'th index of each row append together as one element in prac_list x += 1 print (prac_list) </code></pre> <p>then loop through the dict and change the values to the items in the list, but I believe I am messing up the slicing and the appending to the list part.</p>
[ { "answer_id": 74139242, "author": "Rahul K P", "author_id": 4407666, "author_profile": "https://Stackoverflow.com/users/4407666", "pm_score": 2, "selected": false, "text": "zip" }, { "answer_id": 74139254, "author": "msamsami", "author_id": 13476175, "author_profile"...
2022/10/20
[ "https://Stackoverflow.com/questions/74139043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18964030/" ]
74,139,052
<p>As i was going through python basics and introduction one thing that really confuses me is namespaces. I cant seem to understand how they work.</p> <p>For instance in Cs50 course they brush over the concept but i wanted to get clearer understanding of it if possible because it seems very important to grasp. For example this code:</p> <pre><code>import cs50 x = get_int(&quot;x: &quot;) y = get_int(&quot;y: &quot;) print(x + y) </code></pre> <p>Causes this error:</p> <p>python calculator.py Traceback (most recent call last): File &quot;/workspaces/20377622/calculator.py&quot;, line 3, in x = get_int(&quot;x: &quot;) NameError: name 'get_int' is not defined</p> <p>What is wonder is why when cs50.get_int() is written instead interpreter doesn't throw an error? Is it because cs50 library is seen as its own namespace structure and . goes into that structure to get_int location? What does . operator do exactly here in terms of namespaces ?</p>
[ { "answer_id": 74139242, "author": "Rahul K P", "author_id": 4407666, "author_profile": "https://Stackoverflow.com/users/4407666", "pm_score": 2, "selected": false, "text": "zip" }, { "answer_id": 74139254, "author": "msamsami", "author_id": 13476175, "author_profile"...
2022/10/20
[ "https://Stackoverflow.com/questions/74139052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20081610/" ]
74,139,057
<pre><code>import 'package:flutter/material.dart'; ThemeData lightThemeData(BuildContext context) { return ThemeData.light().copyWith( primaryColor: Colors.teal, backgroundColor: Colors.white, scaffoldBackgroundColor: Colors.white, appBarTheme: const AppBarTheme( backgroundColor: Colors.white, ), ); } // dark Theme ThemeData darkThemeData(BuildContext context) { return ThemeData.dark().copyWith( primaryColor: Colors.tealAccent, backgroundColor: Colors.grey[850], scaffoldBackgroundColor: Colors.grey[850], appBarTheme: AppBarTheme( backgroundColor: Colors.grey[850], ), ); } </code></pre> <p>I have my light and dark themes defined. I have a bool to switch them which is changing correctly but the theme is not switching.</p> <pre><code>Switch( value: isDark, onChanged: (value) { setState(() { isDark = value; }); }, </code></pre> <p>I'm guessing the below is the problem? Is there anwyay to get this to work?</p> <pre><code> theme: isDark ? darkThemeData(context) : lightThemeData(context), </code></pre>
[ { "answer_id": 74139242, "author": "Rahul K P", "author_id": 4407666, "author_profile": "https://Stackoverflow.com/users/4407666", "pm_score": 2, "selected": false, "text": "zip" }, { "answer_id": 74139254, "author": "msamsami", "author_id": 13476175, "author_profile"...
2022/10/20
[ "https://Stackoverflow.com/questions/74139057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6903678/" ]
74,139,076
<p><a href="https://i.stack.imgur.com/IrZHe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IrZHe.png" alt="enter image description here" /></a></p> <p>I have multiple functions as shown in the image. For a fixed x value, I need to distribute it into f, g, and h functions for getting the maximum output (y). In other words, having a fixed x value, find a, b, and c in which these conditions are satisfied:</p> <ol> <li>a + b + c = x</li> <li>a &gt;= 0 and b &gt;= 0 and c &gt;= 0</li> <li>f(a) + g(b) + h(c) has max value.</li> </ol> <p>Given the functions are continuous and monotonic. How should I write code to find out a, b, and c? Thanks in advance!</p>
[ { "answer_id": 74139242, "author": "Rahul K P", "author_id": 4407666, "author_profile": "https://Stackoverflow.com/users/4407666", "pm_score": 2, "selected": false, "text": "zip" }, { "answer_id": 74139254, "author": "msamsami", "author_id": 13476175, "author_profile"...
2022/10/20
[ "https://Stackoverflow.com/questions/74139076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5745899/" ]
74,139,112
<p>I am very new to LINQ</p> <p>in Linq below is what I am trying to achieve :</p> <p>I have two classes - <code>List&lt;ClassA&gt;</code> - <code>List&lt;ClassB&gt;</code></p> <p>Now I want to map 1st item of Class A to first item of Class b</p> <pre><code> ClassA.ForEach( a =&gt; { // how to get the items from ClassB in the same order as it is in CLass b and assign it to Class A }); </code></pre>
[ { "answer_id": 74139154, "author": "DonMiguelSanchez", "author_id": 13337616, "author_profile": "https://Stackoverflow.com/users/13337616", "pm_score": 0, "selected": false, "text": " List<int> listA = new List<int>();\n\n List<int> listB = new List<int>();\n\n listA.Add(1);\n\n listB.Ad...
2022/10/20
[ "https://Stackoverflow.com/questions/74139112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18119406/" ]
74,139,124
<p>Im new to programming and this might be some rookie problem that im having, but id appreaciate a hand.</p> <pre><code> void Sort() { List&lt;Lag&gt; lagen = new List&lt;Lag&gt;() { AIK, DIF, MLM, BJK }; List&lt;Lag&gt; sorted = lagen.OrderByDescending(x =&gt; x.poäng) .ThenByDescending(x =&gt; x.målSK) .ThenByDescending(x =&gt; x.mål) .ToList(); Print(sorted); } </code></pre> <p>This is my sorting function, where i take one list, and turn it into a list called &quot;sorted&quot;. What i want to do now is let the user pick one of the objects in the sorted list by entering a number. This far iw written the following code. Where int hemlag, and int bortlag are objects in the sorted list.</p> <p>And now i want to change the value of &quot;Lag hemmalag&quot; &amp; &quot;Lag bortalag&quot; depending on what numbers (what team) the user put in.</p> <p>So for example, if the user input &quot;int hemlag&quot; is 2.. i want hemmalag = to be the 2nd object in the list &quot;sorted&quot;. And now i run into a problem. Cause i cant access that sorted list from this function.</p> <p>My theories are that it might have to do something with returning that list from the sorting function, but i have not yet found a way to do that...</p> <pre><code> void ChangeStats(int hemlag, int bortlag, int mål, int insläpp) { Sortera(); Lag hemmalag = AIK; Lag bortalag = AIK; if (hemlag == 1) { ; } if (hemlag == 2) { hemmalag = DIF; } if (hemlag == 3) { hemmalag = MLM; } if (hemlag == 4) { hemmalag = BJK; } if (bortlag == 1) { bortalag = AIK; } if (bortlag == 2) { bortalag = DIF; } if (bortlag == 3) { bortalag = MLM; } if (bortlag == 4) { bortalag = BJK; } hemmalag.mål += mål; hemmalag.insläppta += insläpp; bortalag.insläppta += mål; bortalag.mål += insläpp; if (mål &gt; insläpp) { hemmalag.poäng += 3; hemmalag.vinster++; hemmalag.spel++; bortalag.förlorade++; bortalag.spel++; } if (mål &lt; insläpp) { bortalag.poäng += 3; bortalag.vinster++; bortalag.spel++; hemmalag.förlorade++; hemmalag.spel++; } if (mål == insläpp) { bortalag.lika++; bortalag.poäng++; hemmalag.lika++; bortalag.poäng++; } Console.WriteLine(&quot;Stats changed&quot;); Console.WriteLine(&quot;---&quot;); Save(); Sortera(); } </code></pre> <p>Help appreciated, cheers!</p>
[ { "answer_id": 74139256, "author": "adam.k", "author_id": 6643814, "author_profile": "https://Stackoverflow.com/users/6643814", "pm_score": 2, "selected": false, "text": "return sorted" }, { "answer_id": 74139353, "author": "ThisQRequiresASpecialist", "author_id": 1938161...
2022/10/20
[ "https://Stackoverflow.com/questions/74139124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20125200/" ]
74,139,139
<p>Please help me with a regex to validate on a text field to accept. It should accept:</p> <ul> <li>0</li> <li>.50</li> <li>100</li> <li>0.01</li> <li> <ol start="50"> <li></li> </ol> </li> <li>10.0</li> <li>99.99</li> </ul> <p>It shouldn't accept:</p> <ul> <li>100.01</li> <li>50.567</li> </ul> <p>I have an almost working regex with me which accepts unlimited number of decimals, in case it helps:</p> <pre><code>^(0*100{1,1}\.?((?&lt;=\.)0*)?%?$)|(^0*\d{0,2}\.?((?&lt;=\.)\d*)??)$ </code></pre>
[ { "answer_id": 74139256, "author": "adam.k", "author_id": 6643814, "author_profile": "https://Stackoverflow.com/users/6643814", "pm_score": 2, "selected": false, "text": "return sorted" }, { "answer_id": 74139353, "author": "ThisQRequiresASpecialist", "author_id": 1938161...
2022/10/20
[ "https://Stackoverflow.com/questions/74139139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1477901/" ]
74,139,150
<p>I have built application forms that use a serial port C#.</p> <p>I want to save the last serial port number used and COM data in the .ini file when I close the executable. So, I can use the same data for the next use of the application</p> <pre><code> private void btnSave_Click(object sender, EventArgs e) { try { _Ser.PortName = cBoxPort.Text; _Ser.BaudRate = Convert.ToInt32(cBoxBaud.Text); _Ser.DataBits = Convert.ToInt32(cBoxDatabits.Text); _Ser.StopBits = (StopBits)Enum.Parse(typeof(StopBits), cBoxStopBits.Text); _Ser.Parity = (Parity)Enum.Parse(typeof(Parity), cBoxParitybits.Text); this.Close(); string[] data = { cBoxPort.Text, cBoxDatabits.Text, cBoxStopBits.Text, cBoxParitybits.Text }; } catch (Exception err) { MessageBox.Show(err.Message, (&quot;Error&quot;), MessageBoxButtons.OK, MessageBoxIcon.Error); } MessageBox.Show(&quot;Configuration has been saved&quot;,&quot;Status&quot;); } </code></pre>
[ { "answer_id": 74139256, "author": "adam.k", "author_id": 6643814, "author_profile": "https://Stackoverflow.com/users/6643814", "pm_score": 2, "selected": false, "text": "return sorted" }, { "answer_id": 74139353, "author": "ThisQRequiresASpecialist", "author_id": 1938161...
2022/10/20
[ "https://Stackoverflow.com/questions/74139150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18761748/" ]
74,139,181
<p>I am trying to do some analysis on PowerPivot.</p> <p>I have mainly 2 tables.</p> <ol> <li>List of Companies and Total number of employees</li> </ol> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Company</th> <th>Total number of employees</th> </tr> </thead> <tbody> <tr> <td>Company A</td> <td>50</td> </tr> <tr> <td>Company B</td> <td>10</td> </tr> </tbody> </table> </div> <ol start="2"> <li>And a &quot;Transaction&quot; Table about a migration, it lists how many employees were migrated on a specific date. See below. On 10.10.22 1 employee of Company A was migrated on 11.10.22 in total 2 employees were migrated. So it's always the total. And on 16.10.22 the total was 4 so 1 less than on the 15.10.22 (yeah can happen)</li> </ol> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Company</th> <th>Total Migrated employees</th> <th>Date</th> </tr> </thead> <tbody> <tr> <td>Company A</td> <td>1</td> <td>10.10.22</td> </tr> <tr> <td>Company A</td> <td>2</td> <td>11.10.22</td> </tr> <tr> <td>Company A</td> <td>5</td> <td>15.10.22</td> </tr> <tr> <td>Company A</td> <td>4</td> <td>16.10.22</td> </tr> <tr> <td>Company B</td> <td>1</td> <td>15.10.22</td> </tr> <tr> <td>Company B</td> <td>2</td> <td>16.10.22</td> </tr> </tbody> </table> </div> <p>At the end I want a table showing the progress in %, so something like this</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Company</th> <th>Total number of employees</th> <th>Total Migrated (last day)</th> <th>%</th> </tr> </thead> <tbody> <tr> <td>Company A</td> <td>50</td> <td>4</td> <td>8%</td> </tr> <tr> <td>Company B</td> <td>10</td> <td>2</td> <td>20%</td> </tr> </tbody> </table> </div> <p>Any direction really appreciated. I am thinking about Calculate and some kind of oldest function...</p> <p>Thanks a lot for your help</p>
[ { "answer_id": 74139256, "author": "adam.k", "author_id": 6643814, "author_profile": "https://Stackoverflow.com/users/6643814", "pm_score": 2, "selected": false, "text": "return sorted" }, { "answer_id": 74139353, "author": "ThisQRequiresASpecialist", "author_id": 1938161...
2022/10/20
[ "https://Stackoverflow.com/questions/74139181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9093700/" ]
74,139,197
<p>I am trying to implement <strong>SearchView</strong> with animation,</p> <p>SearchView is used in an <strong>activity_location.xml</strong></p> <p>cl_toolbar in activity_location overlaps the SearchView</p> <p>hence I tried to change its visibility to INVISIBLE when <strong>openSearch()</strong> called and again VISIBLE when <strong>closeSearch()</strong> called.</p> <p>getting a <strong>NullPointerException</strong> error in SearchView when tried to implement above things.</p> <pre><code>FATAL EXCEPTION: main Process: com.virusnetic.meather, PID: 11427 java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.constraintlayout.widget.ConstraintLayout.setVisibility(int)' on a null object reference at com.virusnetic.meather.views.SearchView._init_$lambda$0(SearchView.kt:26) at com.virusnetic.meather.views.SearchView.$r8$lambda$Mcmg8MRJAUGTfnVTINGMDsQmb5g(Unknown Source:0) at com.virusnetic.meather.views.SearchView$$ExternalSyntheticLambda0.onClick(Unknown Source:2) at android.view.View.performClick(View.java:7441) at android.view.View.performClickInternal(View.java:7418) at android.view.View.access$3700(View.java:835) at android.view.View$PerformClick.run(View.java:28676) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7839) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) </code></pre> <p>SearchView.kt</p> <pre><code>package com.virusnetic.meather.views import android.animation.Animator import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater import android.view.View import android.view.ViewAnimationUtils import android.widget.EditText import android.widget.FrameLayout import android.widget.RelativeLayout import androidx.constraintlayout.widget.ConstraintLayout import com.virusnetic.meather.R class SearchView( context: Context, attrs: AttributeSet ) : FrameLayout(context, attrs) { init { LayoutInflater.from(context) .inflate(R.layout.view_search, this, true) findViewById&lt;View&gt;(R.id.open_search_button).setOnClickListener { // Set Location toolbar to Invisible findViewById&lt;ConstraintLayout&gt;(R.id.cl_ToolBar).visibility = View.INVISIBLE openSearch() } findViewById&lt;View&gt;(R.id.close_search_button).setOnClickListener { closeSearch() // Set Location toolbar to GONE findViewById&lt;ConstraintLayout&gt;(R.id.cl_ToolBar).visibility = View.VISIBLE } } private fun openSearch() { val open_search_button: View = findViewById(R.id.open_search_button) val search_input_text: EditText = findViewById(R.id.search_input_text) val search_open_view: RelativeLayout = findViewById(R.id.search_open_view) search_input_text.setText(&quot;&quot;) search_open_view.visibility = View.VISIBLE val circularReveal = ViewAnimationUtils.createCircularReveal( search_open_view, (open_search_button.right + open_search_button.left) / 2, (open_search_button.top + open_search_button.bottom) / 2, 0f, width.toFloat() ) circularReveal.duration = 300 circularReveal.start() } private fun closeSearch() { val open_search_button: View = findViewById(R.id.open_search_button) val search_input_text: EditText = findViewById(R.id.search_input_text) val search_open_view: RelativeLayout = findViewById(R.id.search_open_view) val circularConceal = ViewAnimationUtils.createCircularReveal( search_open_view, (open_search_button.right + open_search_button.left) / 2, (open_search_button.top + open_search_button.bottom) / 2, width.toFloat(), 0f ) circularConceal.duration = 300 circularConceal.start() circularConceal.addListener(object : Animator.AnimatorListener { override fun onAnimationRepeat(animation: Animator?) = Unit override fun onAnimationCancel(animation: Animator?) = Unit override fun onAnimationStart(animation: Animator?) = Unit override fun onAnimationEnd(animation: Animator?) { search_open_view.visibility = View.INVISIBLE search_input_text.setText(&quot;&quot;) circularConceal.removeAllListeners() } }) } } </code></pre> <p>also the layout where I used the view</p> <p>view_search.xml</p> <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;FrameLayout android:id=&quot;@+id/frame&quot; xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;?actionBarSize&quot; android:background=&quot;@color/background&quot;&gt; &lt;RelativeLayout android:id=&quot;@+id/search_closed_view&quot; android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;match_parent&quot; android:layout_gravity=&quot;center&quot; android:visibility=&quot;visible&quot; android:background=&quot;@color/background&quot;&gt; &lt;View android:id=&quot;@+id/open_search_button&quot; android:layout_width=&quot;24dp&quot; android:layout_height=&quot;24dp&quot; android:layout_alignParentEnd=&quot;true&quot; android:layout_centerVertical=&quot;true&quot; android:layout_marginEnd=&quot;16dp&quot; android:background=&quot;@drawable/search&quot; android:backgroundTint=&quot;@color/translucent&quot;/&gt; &lt;/RelativeLayout&gt; &lt;RelativeLayout android:id=&quot;@+id/search_open_view&quot; android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;match_parent&quot; android:layout_gravity=&quot;center&quot; android:layout_margin=&quot;4dp&quot; android:background=&quot;@drawable/rounded_corner_background&quot; android:visibility=&quot;invisible&quot;&gt; &lt;View android:id=&quot;@+id/close_search_button&quot; android:layout_width=&quot;24dp&quot; android:layout_height=&quot;24dp&quot; android:layout_alignParentStart=&quot;true&quot; android:layout_centerVertical=&quot;true&quot; android:layout_marginStart=&quot;16dp&quot; android:background=&quot;@drawable/ic_round_close_24&quot; android:backgroundTint=&quot;@color/translucent&quot;/&gt; &lt;EditText android:id=&quot;@+id/search_input_text&quot; android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;match_parent&quot; android:layout_marginStart=&quot;16dp&quot; android:layout_marginEnd=&quot;16dp&quot; android:layout_toStartOf=&quot;@id/execute_search_button&quot; android:layout_toEndOf=&quot;@id/close_search_button&quot; /&gt; &lt;!-- TODO add add button --&gt; &lt;View android:id=&quot;@+id/execute_search_button&quot; android:layout_width=&quot;24dp&quot; android:layout_height=&quot;24dp&quot; android:layout_alignParentEnd=&quot;true&quot; android:layout_centerVertical=&quot;true&quot; android:layout_marginEnd=&quot;16dp&quot; android:background=&quot;@drawable/add&quot; android:backgroundTint=&quot;@color/translucent&quot;/&gt; &lt;/RelativeLayout&gt; &lt;/FrameLayout&gt; </code></pre> <p>activity_location.xml</p> <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot; xmlns:tools=&quot;http://schemas.android.com/tools&quot; android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;match_parent&quot; android:background=&quot;@color/background&quot; android:padding=&quot;30dp&quot; tools:context=&quot;.activities.LocationsActivity&quot;&gt; &lt;!-- Toolbar --&gt; &lt;androidx.constraintlayout.widget.ConstraintLayout android:id=&quot;@+id/cl_ToolBar&quot; android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;?actionBarSize&quot; android:elevation=&quot;1dp&quot; android:layout_marginTop=&quot;20dp&quot; app:layout_constraintTop_toTopOf=&quot;parent&quot;&gt; &lt;LinearLayout android:id=&quot;@+id/ll_back&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; app:layout_constraintTop_toTopOf=&quot;parent&quot; app:layout_constraintStart_toStartOf=&quot;parent&quot; app:layout_constraintBottom_toBottomOf=&quot;parent&quot;&gt; &lt;ImageView android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; android:background=&quot;@drawable/backicon&quot; /&gt; &lt;TextView android:id=&quot;@+id/tv_CurrentLocation&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; android:layout_marginStart=&quot;5dp&quot; android:text=&quot;Select City&quot; android:textColor=&quot;@color/translucent&quot; android:textSize=&quot;18sp&quot; android:fontFamily=&quot;@font/ubuntu_condensed_regular&quot; /&gt; &lt;/LinearLayout&gt; &lt;ImageButton android:id=&quot;@+id/ib_currentLocations&quot; android:layout_width=&quot;24dp&quot; android:layout_height=&quot;24dp&quot; android:layout_marginEnd=&quot;60dp&quot; android:background=&quot;@drawable/current_location&quot; android:backgroundTint=&quot;@color/translucent&quot; app:layout_constraintEnd_toEndOf=&quot;parent&quot; app:layout_constraintTop_toTopOf=&quot;parent&quot; app:layout_constraintBottom_toBottomOf=&quot;parent&quot;/&gt; &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt; &lt;!-- Search View --&gt; &lt;com.virusnetic.meather.views.SearchView android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;wrap_content&quot; android:layout_marginTop=&quot;20dp&quot; app:layout_constraintTop_toTopOf=&quot;parent&quot;/&gt; &lt;androidx.recyclerview.widget.RecyclerView android:id=&quot;@+id/rv_locations&quot; android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;wrap_content&quot; tools:listitem=&quot;@layout/location_list_item&quot; tools:itemCount=&quot;3&quot; app:layout_constraintTop_toBottomOf=&quot;@id/cl_ToolBar&quot; /&gt; &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt; </code></pre>
[ { "answer_id": 74139256, "author": "adam.k", "author_id": 6643814, "author_profile": "https://Stackoverflow.com/users/6643814", "pm_score": 2, "selected": false, "text": "return sorted" }, { "answer_id": 74139353, "author": "ThisQRequiresASpecialist", "author_id": 1938161...
2022/10/20
[ "https://Stackoverflow.com/questions/74139197", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16274322/" ]
74,139,215
<p>I've had hours and hours of problems with <strong>Xamarin Forms iOS provisioning</strong> for my app <strong>with and without</strong> a <strong>ShareExtension</strong>.</p> <p>I have had it working in the past with various combinations and permutations of configuring simulator/device/debug/release/certs/ids/auto or manual provisioning...etc. which I didn't record at the time, but it is very fickle and unpredictable and there are a large number of moving parts.</p> <p>As such the following is a systematic record of the steps I've taken with questions when things have behaved in unexpected ways and my app hasn't run or deployed correctly.</p> <p><strong>NOTE:</strong> The following steps are for <strong>development</strong> but if I can get dev running, I will then continue to update this question for the <strong>distribution</strong> process.</p> <p>The 3 main elements and their interaction that causes me most confusion are below:</p> <ol> <li>Online <strong>Apple Developer Portal</strong></li> <li><strong>MacOS</strong> with Xcode and keychain</li> <li><strong>Windows Visual Studio Xamarin</strong></li> </ol> <p><strong>STEPS TAKEN</strong></p> <p><strong>A) DELETE EVERYTHING FOR A FRESH START</strong></p> <p>I deleted all my certificates, identifiers and profiles from the above 3 (with the exception of the main app id which is in the app store and couldn't be deleted). For the physical devices I removed via:</p> <ul> <li>Xcode</li> <li>VS (Win)</li> <li>relevant folder locations on Win and Mac</li> <li>keychain</li> </ul> <p><strong>B) CREATE A DEV CERT, AUTO PROVISION, RUN THE APP</strong></p> <ul> <li>In visual studio login to my Apple account via Options -&gt; Apple Accounts</li> <li>Then View details -&gt; Create certificate</li> </ul> <p><strong>Outcome</strong>: This works fine. The new cert appears on Windows, Mac and on the Apple Dev Portal. The app runs successfully with auto provisioning.</p> <p>However, no profiles can be seen in the online Apple Dev Portal - why? - <strong>UPDATE</strong>: They now appear around 30 mins after they were created</p> <p><strong>C) ADD A SHARE EXTENSION</strong></p> <ul> <li>Add <strong>ShareExtension</strong> project and reference it to my main app.</li> <li>Use Automatic Provisioning</li> </ul> <p><strong>Outcome</strong>:</p> <ul> <li>Auto Provisioning gives: &quot;Invalid request, Service mapping to the requested URL is not available.&quot;. As a result I go into the Apple Dev Portal and manually create an ID, then retry Auto Provisioning, which is now successful. Try to run the app again but: app runs ok, but share extension can't be seen.</li> </ul> <p>I have double checked:</p> <ul> <li><p>Main app has ShareExtension reference</p> </li> <li><p>Main app info.plist has: <code>&lt;key&gt;NSExtensionPointIdentifier&lt;/key&gt;&lt;string&gt;com.apple.share-services&lt;/string&gt;</code></p> </li> <li><p>App group is set in VS for both projects and both App IDs in online portal</p> </li> </ul> <p>What is going on here?</p> <p><strong>---UPDATE---</strong></p> <p><strong>D) TRY MANUAL PROVISIONING INSTEAD</strong></p> <p>I did the following:</p> <ul> <li>Created two manual provisions, one for container and one for extension</li> <li>As Visual Studio Apple Account didn't reflect these, I downloaded the provisions from the portal, put them in the relevant Windows folder and now they appear</li> <li>Tried to build:</li> </ul> <p><a href="https://i.stack.imgur.com/S6Av0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S6Av0.png" alt="Manual Provisioning problems" /></a></p> <p>What is happening here?</p> <ul> <li>Why is the error about <strong>Auto</strong> Prov, when I have clearly set it to <strong>Manual</strong> Prov</li> <li>Why is the 2nd error about the profile not found when it shows in above drop-down, and in the portal that it very clearly exists?</li> </ul>
[ { "answer_id": 74139256, "author": "adam.k", "author_id": 6643814, "author_profile": "https://Stackoverflow.com/users/6643814", "pm_score": 2, "selected": false, "text": "return sorted" }, { "answer_id": 74139353, "author": "ThisQRequiresASpecialist", "author_id": 1938161...
2022/10/20
[ "https://Stackoverflow.com/questions/74139215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13622076/" ]
74,139,247
<p>I have created a login form in React that uses an Axios post request like this:</p> <pre><code> axios.post('http://localhost:8080/users/validate', { email: email, password: password, }) .then((res) =&gt; { setError(res.data); //If validation passed if (res.data.includes('Login successful')) { navigate('/'); }; }); </code></pre> <p>I would like to pass the <code>res.data</code> from this post request to a different React component. Specifically being the Header component so I can display the text from <code>res.data</code>.</p> <p>This is the structure of the components in my React app</p> <pre><code> &lt;&gt; &lt;Header /&gt; &lt;Routes&gt; &lt;Route path=&quot;/&quot; element={&lt;Index /&gt;}/&gt; &lt;Route path=&quot;/results/:id&quot; element={&lt;Results /&gt;} /&gt; {/* Passes route with ID from input */} &lt;Route path=&quot;/login&quot; element={&lt;Login /&gt;} /&gt; &lt;Route path=&quot;/register&quot; element={&lt;Register /&gt; } /&gt; &lt;Route path=&quot;/users&quot; element={&lt;Users /&gt;}/&gt; &lt;Route path=&quot;/products&quot; element={&lt;Products /&gt;}/&gt; &lt;Route path=&quot;*&quot; element={&lt;Error /&gt;}/&gt; &lt;/Routes&gt; &lt;Footer /&gt; &lt;/&gt; </code></pre> <p>With <code>Login</code> being the component containing the <code>res.data</code> and Header being the component I would like to send <code>res.data</code> too.</p> <p>Ill include the back-end for in case their is a method to send this to that component from the back-end but ideally I would like to do it through the front-end perhaps using an axios request.</p> <pre><code> app.post('/users/validate', (req, res) =&gt; { const email = req.body.email; const password = req.body.password; if (email &amp;&amp; password) { //Check all emails against input db.query(selectEmail, [email], (err, rows) =&gt; { if (err) throw err; if (rows.length &gt; 0) { //If password and email match then login if (HashPassword(password, rows[0].salt) == rows[0].password) { //Checks password and compares to hash res.send(rows[0].first_name); } else { res.send('Incorrect password'); }; } else { res.send('Email or password are incorrect'); }; }); }; }); </code></pre> <p>In a simplified version I want to send the <code>first_name</code> row from my back end to the <code>Header</code> component on my front-end. But I am struggling to understand how to do this because the post request containing <code>first_name</code> is found under is currently being used under the <code>Login</code> component.</p>
[ { "answer_id": 74139256, "author": "adam.k", "author_id": 6643814, "author_profile": "https://Stackoverflow.com/users/6643814", "pm_score": 2, "selected": false, "text": "return sorted" }, { "answer_id": 74139353, "author": "ThisQRequiresASpecialist", "author_id": 1938161...
2022/10/20
[ "https://Stackoverflow.com/questions/74139247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19366108/" ]
74,139,260
<p>I'm using XMLReader create to read xml file.By giving xmlfilepath as input it returns 'None'</p> <pre><code> public void Publish(string input, string output) { XmlReaderSettings settings = new() { DtdProcessing = DtdProcessing.Parse }; using (XmlReader reader = XmlReader.Create(input,settings))) { } } //For example input: C:\XML\30003.xml </code></pre> <p>XMLReader returns 'None' !!</p>
[ { "answer_id": 74139256, "author": "adam.k", "author_id": 6643814, "author_profile": "https://Stackoverflow.com/users/6643814", "pm_score": 2, "selected": false, "text": "return sorted" }, { "answer_id": 74139353, "author": "ThisQRequiresASpecialist", "author_id": 1938161...
2022/10/20
[ "https://Stackoverflow.com/questions/74139260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14032141/" ]
74,139,287
<p>here is the code:</p> <pre><code>#define _GNU_SOURCE #include &lt;cs50.h&gt; #include &lt;ctype.h&gt; #include &lt;stdio.h&gt; #include &lt;string.h&gt; string alphabet = &quot;abdcefghijklmnopqrstuvwxyz&quot;; string text = &quot;world&quot;; string ciphertext = &quot;&quot;; for(int i = 0; i &lt; strlen(text); i++) { ciphertext = strstr(alphabet, &amp;text[i]); printf(&quot;%s \n&quot;, ciphertext); } </code></pre> <p>It outputs the following result:</p> <pre><code>(null) (null) (null) (null) dcefghijklmnopqrstuvwxyz </code></pre> <p>So it looks like strstr() works only for the last character, in this case &quot;d&quot;. Why it does not work for prior characters? strcasestr() has the same behavior</p>
[ { "answer_id": 74139372, "author": "Ture Pålsson", "author_id": 4177009, "author_profile": "https://Stackoverflow.com/users/4177009", "pm_score": 2, "selected": false, "text": "strstr" }, { "answer_id": 74139563, "author": "0___________", "author_id": 6110094, "author...
2022/10/20
[ "https://Stackoverflow.com/questions/74139287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20291166/" ]
74,139,291
<p>I hope you are well! I'm developing a flashcard web app (concepts + definitions) in pure JavaScript to learn the theoretical elements of the degree I'm currently studying, web app dev precisely.</p> <p>I would like to create flashcards for 6 subjects that contain 5 units each. Since I'm still not able to create a backend system, I've seen I can pull data from a JSON file (or several) that would work as a database. I've created a single button for the flashcards in each unit and the idea is to the get the object properties in the button text one by one, every time I click on it. E.g.:</p> <pre><code> [ { &quot;subject&quot;: &quot;Database&quot;, &quot;concept&quot;: &quot;Relational data model&quot;, &quot;definition&quot;: &quot;An abstract model used to organize and manage the data...&quot; }, { &quot;subject&quot;: &quot;Database&quot;, &quot;concept&quot;: &quot;Information system&quot;, &quot;definition&quot;: &quot;An integrated set of components for collecting, storing...&quot; } ] </code></pre> <p>After the 1st click the button should show &quot;Relational data model&quot;, after the 2nd click &quot;An abstract model used to organize and manage the data...&quot;, after the 3rd click &quot;Information system&quot;, after the 4th click &quot;An integrated set of components for collecting, storing...&quot; and so on.</p> <p>I've created this function that works just the way I want but only for an array, not for the properties in an array of objects:</p> <pre><code> var clicks = 0; var button = document.querySelector(&quot;#myButton&quot;); var buttonText = [ &quot;Start&quot;, &quot;Concept 1&quot;, &quot;Definition 1&quot;, &quot;Concept 2&quot;, &quot;Definition 2&quot;, &quot;Concept 3&quot;, &quot;Definition 3&quot;, &quot;And so on...&quot;, ]; function showContent() { clicks += 1; button.innerHTML = buttonText[clicks]; } button.addEventListener(&quot;click&quot;, showContent); </code></pre> <p>I've tried several loops and the .forEach function but it would only show me the concept and definition at once instead of one at a time. I've tried different ways but I basically don't know how to loop through properties inside an object and then go to the next object properties each time I click. Maybe my approach is completely wrong and this can be done otherwise?</p> <p>Once I manage to solve this step, I will then adapt it/ add the necessary code to get the info from the JSON file (I've already tried it but I came across the same problem, it only shows the first concept).</p> <p>Thank you so much for your time and help!</p>
[ { "answer_id": 74139372, "author": "Ture Pålsson", "author_id": 4177009, "author_profile": "https://Stackoverflow.com/users/4177009", "pm_score": 2, "selected": false, "text": "strstr" }, { "answer_id": 74139563, "author": "0___________", "author_id": 6110094, "author...
2022/10/20
[ "https://Stackoverflow.com/questions/74139291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20290597/" ]
74,139,294
<p>I am using selenium with python and tried to run chromedriver in my Windows PC. I unpacked the zip file to several folder, listed in PATH. However, the same error always appers: &quot;'./chromedriver.exe' executable needs to be in PATH. Please see <a href="https://chromedriver.chromium.org/home%22" rel="nofollow noreferrer">https://chromedriver.chromium.org/home&quot;</a>. I`ve tried to put chromedriver.exe in several folders, listed in PATH, include system32 and Windows, but no luck. Here is an example.</p> <pre><code>driver = webdriver.Chrome(executable_path = r'C:\\Users\\polikarpov\\AppData\\Local\\Microsoft\\WindowsApp\\chromedriver.exe') </code></pre>
[ { "answer_id": 74139372, "author": "Ture Pålsson", "author_id": 4177009, "author_profile": "https://Stackoverflow.com/users/4177009", "pm_score": 2, "selected": false, "text": "strstr" }, { "answer_id": 74139563, "author": "0___________", "author_id": 6110094, "author...
2022/10/20
[ "https://Stackoverflow.com/questions/74139294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20232572/" ]
74,139,310
<p>I have multiple .dat files and all of them start with similar information at the beginning about the observation time, lat, long, and... . After this text information, there are 16 columns of observed data. which looks like this:</p> <pre><code>#Occultation start (UTC): 2022-01-01 00:10:00 #Occultation stop (UTC): 2022-01-01 00:12:04 #Occultation point latitude (degN): -59.5 #Occultation point longitude (degE): -54.6 #Center of curvature (m): 3264.126 -4599.850 27305.984 #Radius of curvature (m): 6382932.736 #Azimuth (degN): 177.809 #Undulation (m): 20.772 #Elevation (m): 0.000 #Processing method: Wave optics (CT2) #Background data: ECMWF forecast #Receiver data type: L1caL2c #Navbit correction: extern #Occultation type: Rising #OL/CL mode: OL-&gt;CL #Alt OL/CL (m): 8821 #alt w.r.t. EGM96 geoid|lat|lon|azimuth|ba_opt|impact_opt|refrac|dry_press|dry_temp|geopotential height|ba_raw|ba_L1|ba_L2|ba_model|snr_L1|snr_L2 0.000 -99999000.000 -99999000.000 -99999000.000 -0.99999E+08 -99999000.000 -0.99999E+08 -99999000.000 -99999000.000 -99999000.000 -0.99999E+08 -0.99999E+08 -0.99999E+08 -0.99999E+08 -99999000.000 -99999000.000 </code></pre> <p>what I want to do is :</p> <p>iterating through the multiple .dat files and extracting the latitude and longitude data and plotting them. I can do this with one file but in the loop I got errors. this code could give me the lat and long, but for some unknown reason after running it I receive an error:</p> <pre><code>f = open('/Users/file.dat','r') data = f.read() a = data.split lat=a[14:15] lon=a[19:20] lat TypeError Traceback (most recent call last) &lt;ipython-input-1-4f169d6b0f6f&gt; in &lt;module&gt; 2 data = f.read() 3 a = data.split ----&gt; 4 lat=a[14:15] 5 6 lon=a[19:20] TypeError: 'builtin_function_or_method' object is not subscriptable </code></pre> <p>and this is my loop:</p> <pre><code>x=[] y=[] for file in pathlist: with open (file, 'r') as input: dataset= file.read() a=dataset.split lat=a[14:15] lon=a[19:20] dlat=x.append[lat] dlon=y.append[lon] </code></pre> <p>and I receive this error:</p> <pre><code>AttributeError: 'str' object has no attribute 'read' </code></pre>
[ { "answer_id": 74139418, "author": "cards", "author_id": 16462878, "author_profile": "https://Stackoverflow.com/users/16462878", "pm_score": 2, "selected": true, "text": "sep" }, { "answer_id": 74139680, "author": "Rahul K P", "author_id": 4407666, "author_profile": "...
2022/10/20
[ "https://Stackoverflow.com/questions/74139310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15297253/" ]
74,139,314
<p>Im trying to use the function registerForActivityResult in my android project made in android studio. But when I write &quot;registerForActivityResult&quot; to use the function all that is showing is create function. I thought registerForActivityResult was a remade function in Android an I don't know what to do to make it work. If any of you kind souls could help me I would deeply appreciate it, I can always gather more information if needed!</p> <p><strong>Update</strong> Im currently using the guide provided in <a href="https://www.youtube.com/watch?v=XV-IYHYX__4&amp;ab_channel=BrandanJones" rel="nofollow noreferrer">this</a> video. I am using android.activity.1.3.1 and the code that isn't working is this: <code>private val signInLauncher = registerForActivityResult ( FirebaseAuthUIActivityResultContract() ) { res -&gt; this.signInResult(res) }</code></p>
[ { "answer_id": 74139418, "author": "cards", "author_id": 16462878, "author_profile": "https://Stackoverflow.com/users/16462878", "pm_score": 2, "selected": true, "text": "sep" }, { "answer_id": 74139680, "author": "Rahul K P", "author_id": 4407666, "author_profile": "...
2022/10/20
[ "https://Stackoverflow.com/questions/74139314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20291253/" ]
74,139,330
<p>Error start happens last five days, never was before, camunda spring-boot-starter version is 3.5.5.</p> <pre class="lang-none prettyprint-override"><code>ENGINE-16004 Exception while closing command context: ### Error querying database. Cause: org.apache.ibatis.executor.ExecutorException: Error preparing statement. Cause: org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection ### The error may exist in org/camunda/bpm/engine/impl/mapping/entity/Job.xml ### The error may involve org.camunda.bpm.engine.impl.persistence.entity.JobEntity.selectNextJobsToExecute ### The error occurred while executing a query ### SQL: SELECT SUB.* FROM ( select RES.* , row_number() over (ORDER BY RES.ID_ asc) rnk FROM ( select distinct RES.* from ACT_RU_JOB RES where (RES.RETRIES_ &gt; 0) and ( RES.DUEDATE_ is null or RES.DUEDATE_ &lt;= ? ) and (RES.LOCK_OWNER_ is null or RES.LOCK_EXP_TIME_ &lt; ?) and RES.SUSPENSION_STATE_ = 1 and ( ( RES.EXCLUSIVE_ = 1 and not exists( select J2.* from ACT_RU_JOB J2 where J2.PROCESS_INSTANCE_ID_ = RES.PROCESS_INSTANCE_ID_ -- from the same proc. inst. and (J2.EXCLUSIVE_ = 1) -- also exclusive and (J2.LOCK_OWNER_ is not null and J2.LOCK_EXP_TIME_ &gt;= ?) -- in progress ) ) or RES.EXCLUSIVE_ = 0 ) )RES ) SUB WHERE SUB.rnk &gt;= ? AND SUB.rnk &lt; ? ORDER BY SUB.rnk ### Cause: org.apache.ibatis.executor.ExecutorException: Error preparing statement. Cause: org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection. </code></pre> <p>Can anyone help please?</p>
[ { "answer_id": 74139418, "author": "cards", "author_id": 16462878, "author_profile": "https://Stackoverflow.com/users/16462878", "pm_score": 2, "selected": true, "text": "sep" }, { "answer_id": 74139680, "author": "Rahul K P", "author_id": 4407666, "author_profile": "...
2022/10/20
[ "https://Stackoverflow.com/questions/74139330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20291267/" ]
74,139,342
<p>Is there a way to use the PyTorch profiler when using Amazon SageMaker? Or can we call PyTorch profiler in the profiler config for SageMaker debugger</p>
[ { "answer_id": 74139418, "author": "cards", "author_id": 16462878, "author_profile": "https://Stackoverflow.com/users/16462878", "pm_score": 2, "selected": true, "text": "sep" }, { "answer_id": 74139680, "author": "Rahul K P", "author_id": 4407666, "author_profile": "...
2022/10/20
[ "https://Stackoverflow.com/questions/74139342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19947257/" ]
74,139,398
<pre><code>age = float(input('enter age ')) if age != 10 or age != '11': print('you are not 10 or 11. ') else: print('you are 10 or 11') </code></pre> <p>When i run this code it always prints ('you are not 10 or 11') regardless of age ?</p>
[ { "answer_id": 74139524, "author": "João Areias", "author_id": 4534466, "author_profile": "https://Stackoverflow.com/users/4534466", "pm_score": 0, "selected": false, "text": "age != 10 # This returns False\n" }, { "answer_id": 74139589, "author": "the_strange", "author_i...
2022/10/20
[ "https://Stackoverflow.com/questions/74139398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20291277/" ]
74,139,401
<p>How can I make a line that &quot;goes down&quot;, like this:</p> <p><a href="https://i.stack.imgur.com/Gpf6B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gpf6B.png" alt="image" /></a></p>
[ { "answer_id": 74139555, "author": "Ravindra S. Patil", "author_id": 13997210, "author_profile": "https://Stackoverflow.com/users/13997210", "pm_score": 3, "selected": true, "text": " Row(\n children: [\n Expanded(\n flex: 2,\n child: Contai...
2022/10/20
[ "https://Stackoverflow.com/questions/74139401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17863939/" ]
74,139,406
<p>I'm a begginner in Unity.</p> <p>I have a script, which arrange the movement of two game object. I use OnMouseDown. It activates the GameObject where the click happened and let the movement (with keyboard). My problem is if I click the second game object the first one still moves (both of them). How can I turn off the movement for the first object?</p> <pre><code> void OnMouseDown() { if (activeUnit==false ) { activeUnit=true; } else {activeUnit = false;} } void Movement (){ if (activeUnit == true) {//here comes the movement method </code></pre> <p>Thank you for your help!</p>
[ { "answer_id": 74139555, "author": "Ravindra S. Patil", "author_id": 13997210, "author_profile": "https://Stackoverflow.com/users/13997210", "pm_score": 3, "selected": true, "text": " Row(\n children: [\n Expanded(\n flex: 2,\n child: Contai...
2022/10/20
[ "https://Stackoverflow.com/questions/74139406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20221373/" ]
74,139,422
<hr /> <p>I was working on a project in that some situation comes out that:</p> <ul> <li>optionC is by default checked When someone checked optionA and optionB then optionC should unchecked When someone checked optionC after it unchecked then optionB should unchecked When someone check</li> </ul> <p>ed optionB after it unchecked then optionA should unchecked--- Thats All! Here is my Code:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var optionA = document.getElementById("optionA"); var optionB = document.getElementById("optionB"); var optionC = document.getElementById("optionC"); optionC.checked = true; [ optionA, optionB, optionC ].forEach(function(option) { option.addEventListener("click", function() { if(optionA.checked &amp;&amp; optionB.checked){ optionC.checked = false; } else if(optionA.checked &amp;&amp; optionB.checked &amp;&amp; optionC.checked){ optionB.checked = false; } //Here also Code is missing else{ optionC.checked = true; } }); });</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt; &lt;input type="checkbox" id="optionA" name="optionA" /&gt; &lt;label for="optionA"&gt;Option A&lt;/label&gt; &lt;input type="checkbox" id="optionB" name="optionB" /&gt; &lt;label for="optionB"&gt;Option B&lt;/label&gt; &lt;input type="checkbox" id="optionC" name="optionC" /&gt; &lt;label for="optionC"&gt;Option C&lt;/label&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p><strong>But I am facing an Error</strong> That after optionC is unchecked user is not able to check it again</p>
[ { "answer_id": 74139707, "author": "Haim Abeles", "author_id": 15298697, "author_profile": "https://Stackoverflow.com/users/15298697", "pm_score": 2, "selected": false, "text": "checkbox" }, { "answer_id": 74150809, "author": "zer00ne", "author_id": 2813224, "author_p...
2022/10/20
[ "https://Stackoverflow.com/questions/74139422", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16859575/" ]
74,139,431
<p>I'm trying to make a development environment using minikube.<br> I'm using <code>minikube image load</code> to upload local images to the cluster.<br> here is an example deployment:</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1 kind: Deployment metadata: name: sso spec: selector: matchLabels: app: mm template: metadata: labels: app: mm name: sso spec: containers: - name: sso image: sso-service imagePullPolicy: Never resources: limits: memory: &quot;128Mi&quot; cpu: &quot;500m&quot; ports: - containerPort: 3000 imagePullSecrets: - name: pull-secret </code></pre> <p>The first time I run <code>minikube image load &quot;sso-service&quot;</code> the deployment restarts, but after that, loading a new image doesn't cause a rollout with the new image.<br> I also tried running <code>kubectl rollout restart</code>, did not help.<br> Is there any way to force the deployment to perform a rollout with the new image?</p>
[ { "answer_id": 74139707, "author": "Haim Abeles", "author_id": 15298697, "author_profile": "https://Stackoverflow.com/users/15298697", "pm_score": 2, "selected": false, "text": "checkbox" }, { "answer_id": 74150809, "author": "zer00ne", "author_id": 2813224, "author_p...
2022/10/20
[ "https://Stackoverflow.com/questions/74139431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12356513/" ]
74,139,477
<p>I was trying <a href="https://godbolt.org/z/sYda3re8e" rel="nofollow noreferrer">this</a> code snippet</p> <pre><code>#include &lt;cstddef&gt; #include &lt;cstdio&gt; void f(int* ptr){ std::printf(&quot;int*\n&quot;); } void f(int val){ std::printf(&quot;int\n&quot;); } int main() { f(NULL); } </code></pre> <p>This errors out on both GCC and CLANG but MSVC prints <code>int</code>. As per my reading of <a href="https://timsong-cpp.github.io/cppwp/conv.ptr" rel="nofollow noreferrer"><code>[conv.ptr]</code></a>, since a null pointer constant (which is what <a href="https://timsong-cpp.github.io/cppwp/support.types.nullptr#2" rel="nofollow noreferrer"><code>NULL</code></a> is) of <em>integral type</em> can be converted to a pointer type, it should be ambiguous for the compiler while selecting the appropriate function since it can bind both to <code>int</code> and <code>int*</code>. I confirmed that all these compilers have <code>NULL</code> implemented as an integral type via</p> <pre><code>#if defined(_MSC_VER) static_assert(std::is_same&lt;decltype(NULL), int&gt;(), &quot;&quot;); #else static_assert(std::is_same&lt;decltype(NULL), long&gt;(), &quot;&quot;); #endif </code></pre> <p>So, is this an MSVC bug or am I missing something and compilers are not expected to throw an error in such cases?</p> <p>EDIT: I'm aware that <code>nullptr</code> is <em>the</em> way to gauge null-ness, but this question is merely out of curiosity and an attempt at understanding the specification around it.</p>
[ { "answer_id": 74139538, "author": "Some programmer dude", "author_id": 440558, "author_profile": "https://Stackoverflow.com/users/440558", "pm_score": 3, "selected": false, "text": "NULL" }, { "answer_id": 74140234, "author": "MSalters", "author_id": 15416, "author_p...
2022/10/20
[ "https://Stackoverflow.com/questions/74139477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1851678/" ]
74,139,513
<p>I want to code a Music Bot for discord. <a href="https://i.stack.imgur.com/Hw2bw.png" rel="nofollow noreferrer">But when I try to run the Bot, i get this error</a></p> <p>How can I fix this?</p>
[ { "answer_id": 74139538, "author": "Some programmer dude", "author_id": 440558, "author_profile": "https://Stackoverflow.com/users/440558", "pm_score": 3, "selected": false, "text": "NULL" }, { "answer_id": 74140234, "author": "MSalters", "author_id": 15416, "author_p...
2022/10/20
[ "https://Stackoverflow.com/questions/74139513", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19468345/" ]
74,139,518
<p>I working on a app that needs dynamic fields for filling form. this form may contains multiple timesheets and each timesheet include startDate and finishDate. so how can set property_change on datepicker that creates on runtime?</p> <pre><code>if (field.Type == &quot;Timesheets&quot;){ DatePicker sDate = new DatePicker(); sDate.StyleId = field.Name; sDate.PropertyChanged += sDate_changed; DatePicker fDate = new DatePicker(); fDate.StyleId = field.Name; sDate.PropertyChanged += fDate_changed; } private async void sDate_changed(object sender, PropertyChangedEventArgs e) { // here I don't have access to sdate and fdate } </code></pre>
[ { "answer_id": 74139538, "author": "Some programmer dude", "author_id": 440558, "author_profile": "https://Stackoverflow.com/users/440558", "pm_score": 3, "selected": false, "text": "NULL" }, { "answer_id": 74140234, "author": "MSalters", "author_id": 15416, "author_p...
2022/10/20
[ "https://Stackoverflow.com/questions/74139518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12477597/" ]
74,139,521
<p>I added sharedpreferences to checkbox then shows &quot; &quot; error and &quot;[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value&quot; error on flutter. How I resolve it?</p> <p>error .. <a href="https://i.stack.imgur.com/OuLBq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OuLBq.png" alt="enter image description here" /></a></p> <p>checkbox flutter code</p> <pre><code>class ConstantScreen2 extends StatefulWidget { const ConstantScreen2({Key? key}) : super(key: key); @override State&lt;ConstantScreen2&gt; createState() =&gt; _ConstantScreen2State(); } class _ConstantScreen2State extends State&lt;ConstantScreen2&gt; { final _preferencesService = PreferencesService(); var isChecked = false; @override void initState() { super.initState(); _populateFields(); } void _populateFields() async { final settings = await _preferencesService.getSettings(); setState(() { isChecked = settings.isChecked!; }); } @override Widget build(BuildContext context) { double height = MediaQuery.of(context).size.height; return Scaffold( backgroundColor: Colors.white, body: Container( decoration: const BoxDecoration( image: DecorationImage( image: AssetImage(Config.app_background3), fit: BoxFit.cover), ), child: SafeArea( child: ListView( padding: const EdgeInsets.only(top: 0, bottom: 0, right: 5, left: 0), children: &lt;Widget&gt;[ Row( children: &lt;Widget&gt;[ const Expanded( child: ListTile( minLeadingWidth: 1, leading: Icon( Icons.brightness_1, color: Colors.black, size: 10.0, ), title: Text( Config.app_agree2, style: TextStyle( fontSize: 13, fontWeight: FontWeight.bold), ), ), ), const Text( 'yes', style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold), ), Checkbox( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.0), ), side: MaterialStateBorderSide.resolveWith( (states) =&gt; BorderSide(width: 3.0, color: Colors.blueAccent), ), value: isChecked, onChanged: (value) =&gt; setState(() =&gt; isChecked = value!), ), ], ), Padding( padding: const EdgeInsets.only(top: 10, left: 0, bottom: 0), child: Center( child: SizedBox( width: 160.0, height: 35.0, child: ElevatedButton( style: ButtonStyle( shape: MaterialStateProperty.all&lt;RoundedRectangleBorder&gt;( RoundedRectangleBorder( borderRadius: BorderRadius.circular(18.0), side: const BorderSide( color: Colors.blueAccent, ), ), ), ), onPressed: isChecked ? displayMessage : null, child: const Text('next'), ), ), ), ), ], ), ), ), ); } void displayMessage() { if (isChecked == true) { Navigator.push( context, MaterialPageRoute(builder: (context) =&gt; const ChildGrowScreen()), ); _saveSettings; } else {} } void _saveSettings() { final newSettings = Settings(isChecked: isChecked); print(newSettings); _preferencesService.saveSettings(newSettings); } } </code></pre> <p>model</p> <pre><code>class Settings { bool? isChecked; Settings({bool? isChecked}); } </code></pre> <p>preference_services page</p> <pre><code>import 'package:shared_preferences/shared_preferences.dart'; import 'constant2_model.dart'; class PreferencesService { Future saveSettings(Settings settings) async { final preferences = await SharedPreferences.getInstance(); await preferences.setBool('isChecked', settings.isChecked!); print('Saved settings'); } Future&lt;Settings&gt; getSettings() async { final preferences = await SharedPreferences.getInstance(); final isChecked = preferences.getBool('isChecked'); return Settings(isChecked: isChecked); } } </code></pre> <p>I can't understand my error. How I resolve it? In my code I used a separate model and to save data I used the preference_service file.</p>
[ { "answer_id": 74139538, "author": "Some programmer dude", "author_id": 440558, "author_profile": "https://Stackoverflow.com/users/440558", "pm_score": 3, "selected": false, "text": "NULL" }, { "answer_id": 74140234, "author": "MSalters", "author_id": 15416, "author_p...
2022/10/20
[ "https://Stackoverflow.com/questions/74139521", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20000775/" ]
74,139,535
<p>my code is running fine but everytime iam running it i always get this error</p> <pre><code>Traceback (most recent call last): File &quot;pixiv2.py&quot;, line 20, in &lt;module&gt; print(url[&quot;url&quot;]) KeyError: 'url </code></pre> <p>here my code</p> <pre><code>import requests import json head = {&quot;cookie&quot;:&quot;first_visit_datetime_pc=2022-10-18+23%3A14%3A39;p_ab_id=6; p_ab_id_2=5; p_ab_d_id=733460558; yuid_b=FxYVh2A; _gcl_au=1.1.16757329.1666102482; _fbp=fb.1.1666102483510.1284265535; __utmv=235335808.|2=login%20ever=no=1^3=plan=normal=1^9=p_ab_id=6=1^10=p_ab_id_2=5=1^11=lang=en=1; _im_vid=01GFNQ5BHBK0BTS863E1PFV5XE; p_b_type=1; PHPSESSID=nno1inm7i9jm7tm3nn65h57fa60juhja; __utma=235335808.40218806.1666102482.1666174342.1666263027.5; __utmc=235335808; __utmz=235335808.1666263027.5.3.utmcsr=bing|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); __utmt=1; __cf_bm=qIXpzNczxkOor5MRFjhtcdyHRIoxMmfx4WjFBgLIaj0-1666263124-0-ATZ81C6AK30YynV2vdZUJy/1mOKr4bQsU6Jg8IQQ3NXN1igC9JmUCbw3UEi3Q94qZFmJGQCCbEiIWh9AkYF5jefgfEbxU/G8cZ90Y2Q9nIIz; _ga=GA1.2.40218806.1666102482; _gid=GA1.2.185213707.1666263130; tag_view_ranking=uusOs0ipBx~jhuUT0OJva~YbOo-qnBCR~BCvXu--kz8~zJbQX9XnS8~lGA3C7DKHJ~HPo9KI2ZWw~OH5ieNjgYI~0im78x6u68~j2Cs25NHKk~C1SJYGypg3~Ie2c51_4Sp~-wJIMuUetf~CZnOKinv48~5oPIfUbtd6~CtrLViGu8y~uXRQFgCSKj~3rrLyfdz97~I9PKKPZAGj~ukPRYeVH48~ovVM8EeCy5~GyDpAhs6Fr~FUI9Gz_VHc~LoDIs84uJh~T7wAIfdFn4~Kvc_vdVxQf~4mvK-PkuW6~shc8mfpHNf~vwW0YMBATT~Il2Wqia8Nd~zx-g5-W1ik~V_9MwDcP_t~nQRrj5c6w_~Oa9b6mEc1T~SvhFpM2bDA~av3fypOM0M~aPRj6MFMA5~jH0uD88V6F~2pZ4K1syEF~pGv7p05oAU~a6iatBgjr5~Nbvc4l7O_x~t21uiB0eUi~Mn6hsE75l9~jfnUZgnpFl~ZISI5v0br2~azESOjmQSV~pqhfTTXWkX~r8wAwzuHSI~o_4V1CUos4~aiBQfF9p1b~OIzjMQQa-D~Sz48L5kEb5~98c-9jH-Jp~sL9NH1EVf3~8iMVyPUkbe~DxtiQJj6de~WDg8bdJiXI~dDVC9t_E1h~qm_vcCNQ6W~3G3U6TElkH~mWmWMybG2e~UXbzwpvQqi~dC_oGmOpIw~cE1cc1WuGz~f3kE4r7g96~AZsiSz9Ta3~HftrmK7zQW~1jjRk-sprI; __utmb=235335808.22.9.1666263045840; _ga_75BBYNYN9J=GS1.1.1666263026.8.1.1666263555.0.0.0; cto_bundle=s5eMA19uJTJGVEtqR2ZEa3FkNUV3NENaWmN4bFRoQ3hzNjJYcXdiTG1sY0RLRUZ1bU04UUlCRWJ1TFNtS3oyS3YwWHExV1Z6SjI5RTNyQUxFU3JES2xtSDdYdUI4VG1va0RSYnZjUGNHWXR2ZCUyRnNKTzdJTzRNczgxJTJGZHhkdEY2T2FISyUyQnlzQzN4JTJGOVc3U29yRWU1eWI1d2JpNm1HM2Q3YXBwRExTMyUyQk55N3Z3eENYVzglM0Q&quot;, &quot;referer&quot;: &quot;https://www.pixiv.net/en/&quot;, &quot;user-agent&quot;: &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.47&quot;} query = &quot;13322496&quot; data = {&quot;q&quot;: query} link = 'https://www.pixiv.net/ajax/illust/13322496/recommend/init?limit=30&amp;lang=en' req = requests.get(link, data=data, headers=head) r = req.json() for url in r[&quot;body&quot;][&quot;illusts&quot;]: print(url[&quot;url&quot;]) </code></pre>
[ { "answer_id": 74139538, "author": "Some programmer dude", "author_id": 440558, "author_profile": "https://Stackoverflow.com/users/440558", "pm_score": 3, "selected": false, "text": "NULL" }, { "answer_id": 74140234, "author": "MSalters", "author_id": 15416, "author_p...
2022/10/20
[ "https://Stackoverflow.com/questions/74139535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17668517/" ]
74,139,540
<p>I have a domain class <code>View</code>:</p> <pre><code>public class View { private String id; private String docId; private String name; // constructor, getters, etc. } </code></pre> <p>And there's a list of <code>View</code> objects.</p> <p>Elements having the same <code>id</code>, only differ in one field <code>docId</code> (the second attribute), example:</p> <pre class="lang-java prettyprint-override"><code>List&lt;View&gt; viewList = new ArrayList&lt;&gt;(); viewList.add(new View(&quot;1234&quot;, &quot;ab123&quot;, &quot;john&quot;)); viewList.add(new View(&quot;1234&quot;, &quot;cd456&quot;, &quot;john&quot;)); viewList.add(new View(&quot;1234&quot;, &quot;ef789&quot;, &quot;john&quot;)); viewList.add(new View(&quot;5678&quot;, &quot;jh987&quot;, &quot;jack&quot;)); viewList.add(new View(&quot;5678&quot;, &quot;ij654&quot;, &quot;jack&quot;)); viewList.add(new View(&quot;5678&quot;, &quot;kl321&quot;, &quot;jack&quot;)); viewList.add(new View(&quot;9876&quot;, &quot;mn123&quot;, &quot;ben&quot;)); viewList.add(new View(&quot;9876&quot;, &quot;op456&quot;, &quot;ben&quot;)); } </code></pre> <p>A and I want to convert them into list of aggregated objects <code>NewView</code>.</p> <p><code>NewView</code> class look like this:</p> <pre><code>public static class NewView { private String id; private String name; private List&lt;String&gt; docId = new ArrayList&lt;&gt;(); } </code></pre> <p><em><strong>Expected Output</strong></em> for the sample data provided above would be:</p> <pre class="lang-json prettyprint-override"><code>{ &quot;id&quot;: &quot;1234&quot;, &quot;name&quot;: &quot;john&quot;, &quot;docIds&quot;: [&quot;ab123&quot;, &quot;cd456&quot;, &quot;ef789&quot;] }, { &quot;id&quot;: &quot;5678&quot;, &quot;name&quot;: &quot;jack&quot;, &quot;docIds&quot;: [&quot;jh987&quot;, &quot;ij654&quot;, &quot;kl321&quot;] }, { &quot;id&quot;: &quot;9876&quot;, &quot;name&quot;: &quot;ben&quot;, &quot;docIds&quot;: [&quot;mn123&quot;, &quot;op456&quot;] } </code></pre> <p>I've tried something like this:</p> <pre class="lang-java prettyprint-override"><code>Map&lt;String, List&lt;String&gt;&gt; docIdsById = viewList.stream() .collect(groupingBy( View::getId, Collectors.mapping(View::getDocId, Collectors.toList()) )); Map&lt;String, List&lt;View&gt;&gt; views = viewList.stream() .collect(groupingBy(View::getId)); List&lt;NewView&gt; newViewList = new ArrayList&lt;&gt;(); for (Map.Entry&lt;String, List&lt;View&gt;&gt; stringListEntry : views.entrySet()) { View view = stringListEntry.getValue().get(0); newViewList.add(new NewView( view.getId(), view.getName(), docIdsById.get(stringListEntry.getKey())) ); } </code></pre> <p>Can I create a list of <code>NewView</code> in only one Stream?</p>
[ { "answer_id": 74141339, "author": "WJS", "author_id": 1552534, "author_profile": "https://Stackoverflow.com/users/1552534", "pm_score": 0, "selected": false, "text": "toString()" }, { "answer_id": 74141512, "author": "Alexander Ivanchenko", "author_id": 17949945, "au...
2022/10/20
[ "https://Stackoverflow.com/questions/74139540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20290971/" ]
74,139,545
<p>My goal is to subtract the previous element from the current element in an array.</p> <p>I.e.</p> <p>Index position 1 - Index position 0 , then</p> <p>index position 2 - index position 1 , then</p> <p>index position 3 - index position 2</p> <pre><code>double[] arr = { 1, 22, 13, 4 }; </code></pre> <p>So: 22 - 1 = 21, then 13 - 21 = -8, then 4 - (-8) = 12</p> <p>The values in the array should look like this after the operation.</p> <pre><code>double[] arr = { 1, 21, -8, 12 }; </code></pre> <p>My approach is as follows:</p> <pre><code>double[] array = new double[matrix[0].length - 1]; DoubleBinaryOperator operator = (x, y) -&gt; y - x; for (int i = 0; i &lt; arr.length - 1; i++) { Arrays.parallelPrefix(arr, i, i + 1, operator); } </code></pre> <p>I thought I would use parallelPrefix to perform this operation.</p> <p>The operator is (x, y) -&gt; y - x..</p> <p>The array is iterated over and the parallelPrefix method is executed exactly as many times as the length of the array. During execution, the bounds to be calculated are always specified.</p> <p>But unfortunately the values are not changed.<br /> Do you have an idea where the error could be?</p>
[ { "answer_id": 74140091, "author": "VGR", "author_id": 1831987, "author_profile": "https://Stackoverflow.com/users/1831987", "pm_score": 1, "selected": false, "text": "Arrays.parallelPrefix(arr, operator);" }, { "answer_id": 74140529, "author": "Abra", "author_id": 216436...
2022/10/20
[ "https://Stackoverflow.com/questions/74139545", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10224292/" ]
74,139,581
<pre><code>const myStorage = { 'car': { 'inside': { 'glove box': 'maps', 'passenger seat': 'crumbs' }, 'outside': { 'trunk': 'jack' } } }; </code></pre> <p>I can understand 'glove box' is the property and its value is 'maps', but what about 'car', 'inside' and 'outside'. Are they also properties or the values of car? I can recognise with a comma that we have two objects here, but where do these start. Please elaborate on this.</p>
[ { "answer_id": 74139736, "author": "Fralle", "author_id": 3155183, "author_profile": "https://Stackoverflow.com/users/3155183", "pm_score": 2, "selected": true, "text": "myStorage" }, { "answer_id": 74139770, "author": "Bartolem", "author_id": 20291378, "author_profil...
2022/10/20
[ "https://Stackoverflow.com/questions/74139581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19391190/" ]
74,139,648
<p>I have my custom Button widget in a container which width is defined by the width of its content (it can't be static). When I put that widget in a wrap widget it expands my custom Button to screen width, but if I put it in a row it wraps correctly and I can't figure out how to maintain wanted width of children inside the wrap widget. Here is the code below:</p> <p>My Custom Button Widget:</p> <pre><code>class Button extends StatefulWidget { final String imageAsset; final String btnText; final Color colorBegin; final Color colorEnd; const Button({Key? key, required this.imageAsset, required this.btnText, required this.colorBegin, required this.colorEnd}) : super(key: key); @override State&lt;Button&gt; createState() =&gt; _ButtonState(); } class _ButtonState extends State&lt;Button&gt; { Variables variables = Variables(); @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( gradient: LinearGradient( colors: [widget.colorBegin, widget.colorEnd] ), borderRadius: BorderRadius.all(Radius.circular(variables.radius(context, 16))) ), child: Row( children: [ Image.asset( widget.imageAsset, height: variables.height(context, 5), width: variables.height(context, 5), ), SizedBox(width: variables.width(context, 3)), Text( widget.btnText, style: TextStyle( fontFamily: 'LeagueSpartanRegular', fontSize: variables.height(context, 2.5), color: Color(0xFF0B182A), ), ), SizedBox(width: variables.width(context, 4)), ], ), ); } } </code></pre> <p>My wrap widget:</p> <pre><code>class _ButtonListState extends State&lt;ButtonList&gt; { @override Widget build(BuildContext context) { return Wrap( alignment: WrapAlignment.center, runSpacing: 20, children: const [ Button( btnText: 'Little Friend', imageAsset: 'assets/images/icon_little_friend.png', colorBegin: Color(0xFFb3d7a4), colorEnd: Color(0xFFb0caaa), ), Button( btnText: 'Little Friend', imageAsset: 'assets/images/icon_little_friend.png', colorBegin: Color(0xFFb3d7a4), colorEnd: Color(0xFFb0caaa), ), Button( btnText: 'Little Friend', imageAsset: 'assets/images/icon_little_friend.png', colorBegin: Color(0xFFb3d7a4), colorEnd: Color(0xFFb0caaa), ), Button( btnText: 'Little Friend', imageAsset: 'assets/images/icon_little_friend.png', colorBegin: Color(0xFFb3d7a4), colorEnd: Color(0xFFb0caaa), ), ], ); } } </code></pre> <p>And my home screen:</p> <pre><code>class _HomeWidgetState extends State&lt;HomeWidget&gt; { Variables variables = Variables(); @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.only(top: variables.height(context, 7)), decoration: const BoxDecoration( image: DecorationImage( image: AssetImage(&quot;assets/images/bg_main.png&quot;), fit: BoxFit.cover, ), ), child: Column( children: [ TextCatalogue(), SizedBox(height: variables.height(context, 4)), Expanded(child: Stack( children: [ WhiteBackgroundHome(), ButtonList(), ] ) ), ], ), ); } } </code></pre> <p>Problem <a href="https://i.stack.imgur.com/MvcLl.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MvcLl.jpg" alt="Here is the problem" /></a></p> <p>This is the result when I replace wrap with row, the children aren't expanded</p> <p><a href="https://i.stack.imgur.com/xuydz.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xuydz.jpg" alt="image" /></a> I tried placing it out of the expanded widget on the home screen, tried deleting everything on the home screen and returning only the wrap widget still get the same result. It fixes the problem if I define the width of my custom button widget, but that is not the solution because the buttons will have different width depending on the text inside.</p>
[ { "answer_id": 74139736, "author": "Fralle", "author_id": 3155183, "author_profile": "https://Stackoverflow.com/users/3155183", "pm_score": 2, "selected": true, "text": "myStorage" }, { "answer_id": 74139770, "author": "Bartolem", "author_id": 20291378, "author_profil...
2022/10/20
[ "https://Stackoverflow.com/questions/74139648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19561836/" ]
74,139,653
<p>I'm trying to make a program that tells me how long there is (in minutes) until a certain time of day in the future. I've been trying to write working code all night, but I just can't wrap my head around strftime, timedelta and datetime. I'm quite new to python, and being able to do this would be quite useful to my day-to-day life; Can someone help me out?</p>
[ { "answer_id": 74139695, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": -1, "selected": false, "text": "from datetime import datetime\n\ntarget = '2023-01-01 00:00:00'\n\nt = datetime.strptime(target, '%Y-%m-%d %H:%M:%...
2022/10/20
[ "https://Stackoverflow.com/questions/74139653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20163115/" ]
74,139,696
<p>I have a Flask api server running, worked absolutely fine on 127.0.0.1 right up until I started tinkering with trying to get it working across the LAN. I can see the connections from other devices on the LAN in the debug log, and it is receiving the connections fine, but not serving any pages, only 404, but not even my custom 404. I have enabled Network Discovery, set network to Private, allowed Python through the firewall and tried using a non standard port (51234), disabled firewalls but I still get 404 errors.</p> <pre><code>127.0.0.1 - - [20/Oct/2022 12:38:00] &quot;GET / HTTP/1.1&quot; 404 - 192.168.1.205 - - [20/Oct/2022 12:38:11] &quot;GET /api/companies?id=1 HTTP/1.1&quot; 404 - 192.168.1.168 - - [20/Oct/2022 12:38:25] &quot;GET / HTTP/1.1&quot; 404 - 192.168.1.113 - - [20/Oct/2022 12:38:41] &quot;GET / HTTP/1.1&quot; 404 - 192.168.1.205 - - [20/Oct/2022 12:43:58] &quot;GET / HTTP/1.1&quot; 404 - </code></pre> <p>So in order to test it, I went back to basics and only allowed localhost again, and now nothing is working!</p> <p><code>* Serving Flask app 'training_server' * Debug mode: on * Running on http://127.0.0.1:5155 Press CTRL+C to quit * Restarting with stat * Debugger is active! 127.0.0.1 - - [20/Oct/2022 12:44:54] &quot;GET / HTTP/1.1&quot; 404 - 127.0.0.1 - - [20/Oct/2022 12:45:12] &quot;GET / HTTP/1.1&quot; 404 - 127.0.0.1 - - [20/Oct/2022 12:45:12] &quot;GET /favicon.ico HTTP/1.1&quot; 404 - 127.0.0.1 - - [20/Oct/2022 12:50:09] &quot;GET / HTTP/1.1&quot; 404 - </code></p> <pre><code>from flask import Flask, json, jsonify, request companies = [{&quot;id&quot;: 0, &quot;name&quot;: &quot;ACME&quot;, &quot;state&quot;:&quot;Essex&quot;}, {&quot;id&quot;: 1, &quot;name&quot;: &quot;Bluebell&quot;, &quot;state&quot;:&quot;Hertfordshire&quot;} ] users = [{&quot;company&quot;:&quot;ACME&quot;,&quot;name&quot;: &quot;Steve Herbert&quot;, &quot;employeeID&quot;:&quot;125785&quot;, &quot;email&quot;:&quot;sherbert@acme.com&quot;}, {&quot;company&quot;:&quot;ACME&quot;,&quot;name&quot;: &quot;Steve Herbert&quot;, &quot;employeeID&quot;:&quot;125785&quot;, &quot;email&quot;:&quot;sherbert@acme.com&quot;} ] api = Flask(__name__) api.config[&quot;DEBUG&quot;] = True api.config['JSON_SORT_KEYS'] = False api.run(host='127.0.0.1', port=5155) @api.route('/', methods=['GET']) def home(): return &quot;&lt;h1&gt;Company Directory&lt;/h1&gt;&lt;p&gt;This site is a prototype API for company directory listing.&lt;/p&gt;&quot; @api.route('/api/companies/all', methods=['GET']) def get_companies(): return jsonify(companies) @api.route('/api/companies', methods=['GET']) # Check if a param was provided as part of the URL. # If param is provided, assign it to a variable. If not, display an error in the browser. def get_company(): print('req' + str(request.args)) print('hello' + next(iter(request.args.keys()))) #print([elem[0:] for elem in request.args.keys()]) if 'id' in request.args: filter = next(iter(request.args.keys())) param = int(next(iter(request.args.values()))) elif 'name' in request.args: filter = next(iter(request.args.keys())) param = str(next(iter(request.args.values()))) else: return &quot;Error: No param field provided. Please specify a value.&quot; results = apiParam(param, filter, companies) return jsonify(results) def apiParam(param, filter, list): print('filter' + str(filter)) results = [] # Loop through the data and match results that fit the requested parameter. for li in list: if li[filter] == param: results.append(li) return results if __name__ == '__main__': api.run() </code></pre>
[ { "answer_id": 74139952, "author": "jerrythebum", "author_id": 1291738, "author_profile": "https://Stackoverflow.com/users/1291738", "pm_score": 3, "selected": true, "text": "import os\n\nif __name__ == '__main__':\n port = int(os.environ.get(\"PORT\", 5155))\n api.run(host='0.0.0....
2022/10/20
[ "https://Stackoverflow.com/questions/74139696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1291738/" ]
74,139,751
<p>I have a javascript and Powershell script allowing to detect a usb plug, and which shows me a pop up. Indeed, my script only detects new usb keys that have not yet been plugged into the system. That's why I would like to delete the usb key history from my computer, like USB OBLIVION does, in order to have as a new connection to each usb plug.</p> <p>I don't see what I need to add to my script... I have already tried deleting the content of:</p> <p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR</p> <p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\DeviceClasses\</p> <p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB</p> <p>Thanks</p>
[ { "answer_id": 74139952, "author": "jerrythebum", "author_id": 1291738, "author_profile": "https://Stackoverflow.com/users/1291738", "pm_score": 3, "selected": true, "text": "import os\n\nif __name__ == '__main__':\n port = int(os.environ.get(\"PORT\", 5155))\n api.run(host='0.0.0....
2022/10/20
[ "https://Stackoverflow.com/questions/74139751", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20289675/" ]
74,139,752
<p>i am making a website for school. The images need to float right with some <code>&lt;p&gt;</code> text to left of it but cant make it work. Who can help me, see img for clearence. Here is some code:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.img-inno { float: right; height: 10%; width: 10%; text-align: left; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;header class="inno"&gt; Innovation 1, Running &lt;/header&gt; &lt;p&gt; One of the best sporting technoligies out is a treadmill to determine which running shoes you need. &lt;/p&gt; &lt;p&gt; You will walk a couple of 100 meters and a screen will show how you place you foot in the shoes you have tested. &lt;/p&gt; &lt;p&gt; Based on that you can choose new choes and will determine again if the shoes fit. &lt;/p&gt; Eventually you will have some good data which shoes will fit the best. The data will be sent via email. &lt;footer&gt; &lt;p&gt; These shops are everywhere! In the USA and The Netherlands, you name it! &lt;/p&gt; &lt;a href="https://www.run4free.nl/"&gt; More info? Click here&lt;/a&gt; &lt;/footer&gt; &lt;a href="https://21run.com/eu/"&gt; &lt;img class="img-inno" id="img1" src="https://hips.hearstapps.com/hmg-prod/images/male-athlete-running-on-tartan-track-royalty-free-image-1624297569.jpg?crop=0.670xw:1.00xh;0.245xw,0&amp;resize=640:*" alt="Running, copyright belongs to runner's world"&gt; &lt;/a&gt; &lt;/article&gt; &lt;article&gt; &lt;header class="inno"&gt; Innovation 2, Bowling &lt;/header&gt; &lt;p&gt;This one could be a little bit silly, but it is a good innovation. I am talking about the Computerized Scoring Bowling.&lt;/p&gt; &lt;p&gt; A computer will focus on the score, while you can focus on the bowling aspect and don't have to count your scores. &lt;/p&gt; &lt;p&gt;These small innovations have a impact about our daily life without you aven noticing.&lt;/p&gt; &lt;footer&gt; Fun Fact: The risk of a false score went down drasticly after this invention. &lt;a href="https://www.bowlingcentrum.nl/"&gt;Make a reservation for bwoling here. &lt;/a&gt; &lt;/footer&gt; &lt;a href="https://www.etsy.com/nl/listing/1052730525/aangepaste-airbrushed-bowling-ball?gpla=1&amp;gao=1&amp;"&gt; &lt;img class="img-inno" src="https://cdn.bleacherreport.net/images_root/slides/photos/000/995/723/83452843_display_image.jpg?1307417974" alt="Bowling, Copyright belongs to bleacherreport.com"&gt; &lt;/a&gt; &lt;/article&gt;</code></pre> </div> </div> </p> <p><a href="https://i.stack.imgur.com/QyxEV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QyxEV.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74140110, "author": "c.m.", "author_id": 19850943, "author_profile": "https://Stackoverflow.com/users/19850943", "pm_score": 0, "selected": false, "text": "<article>\n <p>Text</p>\n <img src=\"\"/>\n</article>\n" }, { "answer_id": 74141274, "author": "Nik...
2022/10/20
[ "https://Stackoverflow.com/questions/74139752", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20111693/" ]
74,139,754
<p>I have some data from a <a href="https://forms.gle/rGQQL3tvA1PrE4dD8" rel="nofollow noreferrer">a Google Forms</a> and I'd like to <strong>slipt the common-separated answers</strong> and <strong>duplicate the participant's ID</strong></p> <ul> <li>The data looks like this:</li> </ul> <pre><code>&gt; head(data) names Q2 Q3 Q4 1 PART_1 fruits bananas, apples brocolli, lettuce, potatoes 2 PART_2 vegetables bananas, oranges brocolli 3 PART_3 fruits carrots, brocolli, lettuce </code></pre> <ul> <li>Desired output #1 (filling in with Nas):</li> </ul> <pre><code> names Q2 Q3 Q4 1 PART_1 fruits bananas brocolli PART_1 NA apples lettuce, PART_1 NA NA potatoes so on... </code></pre> <ul> <li>Desired output #2 (repeat the non-multiple choice answers (as Q1):</li> </ul> <pre><code> names Q2 Q3 Q4 1 PART_1 fruits bananas brocolli PART_1 fruits apples lettuce, PART_1 fruits NA potatoes so on... </code></pre> <ul> <li>If it's possible, a <code>tidyverse</code> solution would be much appreciated!</li> </ul> <p>Obs: <a href="https://stackoverflow.com/questions/56944323/separate-comma-separated-values-into-different-rows">The ideia is pretty much like this SQL question</a>. <a href="https://stackoverflow.com/questions/46335962/how-to-break-comma-separated-values-in-different-rows-in-r">I've seen this R question, but I'd like to repeat the participant's name, not rename them</a></p> <ul> <li>data:</li> </ul> <pre><code>structure(list(names = c(&quot;PART_1&quot;, &quot;PART_2&quot;, &quot;PART_3&quot;), Q2 = c(&quot;fruits&quot;, &quot;vegetables&quot;, &quot;fruits&quot;), Q3 = c(&quot;bananas, apples&quot;, &quot;bananas, oranges&quot;, &quot;&quot;), Q4 = c(&quot;brocolli, lettuce, potatoes&quot;, &quot;brocolli&quot;, &quot;carrots, brocolli, lettuce&quot; )), class = &quot;data.frame&quot;, row.names = c(NA, -3L)) </code></pre>
[ { "answer_id": 74139869, "author": "Ritchie Sacramento", "author_id": 2835261, "author_profile": "https://Stackoverflow.com/users/2835261", "pm_score": 4, "selected": true, "text": "library(tidyr)\nlibrary(dplyr)\n\ndat %>% \n pivot_longer(-c(Q2, names)) %>%\n separate_rows(value) %>%\...
2022/10/20
[ "https://Stackoverflow.com/questions/74139754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18364222/" ]
74,139,805
<p>I'm trying to create a regex pattern that accepts decimal numbers and the maximum length should be 3. These are the regex I tried but didn't work</p> <pre><code>new RegExp('d{1-3}') new RegExp('^[0-9]{3}$') </code></pre> <p>I want to achive to allow the decimal numbers between 0-999.</p> <p>For example 185.5</p> <p>Thanks in advance.</p>
[ { "answer_id": 74139876, "author": "Mohamad Ahmadi", "author_id": 11039101, "author_profile": "https://Stackoverflow.com/users/11039101", "pm_score": 3, "selected": true, "text": "^[1-9]{0,3}$" }, { "answer_id": 74139982, "author": "van_borshch", "author_id": 17361701, ...
2022/10/20
[ "https://Stackoverflow.com/questions/74139805", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14660576/" ]
74,139,813
<pre><code> Table({ orderDate: &quot;Lenovo Thinkpad&quot;, orderId: &quot;Procurement&quot;, ordererValue: 10, customer: &quot;499.99&quot;, customerEmail: orderValue * customer) } ) </code></pre> <p><a href="https://i.stack.imgur.com/29KHn.png" rel="nofollow noreferrer">Picture</a></p> <p>How to sum two columns in a third column in PowerApps table?</p>
[ { "answer_id": 74139891, "author": "Ganesh Sanap", "author_id": 8624276, "author_profile": "https://Stackoverflow.com/users/8624276", "pm_score": 1, "selected": false, "text": "ForAll(\n YourDataSourceName As aPatch,\n Patch(\n YourDataSourceName,\n {orderId: aPatch.orderId...
2022/10/20
[ "https://Stackoverflow.com/questions/74139813", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17368284/" ]
74,139,860
<p>Is there a way to set the value of a property for a CSS class dynamically, without using a compiler or javascript.</p> <pre><code>:root { --color-0 : red; --color-1 : blue; --color-3 : yellow; } .bg-color-[*] { background-color: var(--color-[*]); } </code></pre> <p>Then in my html I could pass in the numeric value that is used to select the correct variable</p> <pre><code>&lt;div class=&quot;bg-color-1&quot;&gt;This background should be red&lt;/div&gt; &lt;div class=&quot;bg-color-2&quot;&gt;This background should be blue&lt;/div&gt; &lt;div class=&quot;bg-color-3&quot;&gt;This background should be yellow&lt;/div&gt; </code></pre>
[ { "answer_id": 74140089, "author": "Yanan LYU", "author_id": 20291606, "author_profile": "https://Stackoverflow.com/users/20291606", "pm_score": 0, "selected": false, "text": "@for $i from 1 through 3 {\n .bg-color-#{$i} {\n background-color: var(--color-#{$i});\n }\n}\n" ...
2022/10/20
[ "https://Stackoverflow.com/questions/74139860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3779856/" ]
74,139,900
<p>I am new to data, Apology if I am not clear with my question.</p> <p>My requirement to export sql table to csv file, I used cmd.ExecuteReader in c# and loaded successfully for up to 1gb tables.</p> <p>But we have couple of other tables with size up to 60 gb.</p> <p>Is there any efficient way to export large table data to multiple csv files?</p> <p>Appreciate for any suggestions.</p>
[ { "answer_id": 74140089, "author": "Yanan LYU", "author_id": 20291606, "author_profile": "https://Stackoverflow.com/users/20291606", "pm_score": 0, "selected": false, "text": "@for $i from 1 through 3 {\n .bg-color-#{$i} {\n background-color: var(--color-#{$i});\n }\n}\n" ...
2022/10/20
[ "https://Stackoverflow.com/questions/74139900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20174126/" ]
74,139,910
<p>I'm trying to produce some weighted summary statistics, currently using <code>group_modify()</code>. For example, say I have this df:</p> <pre><code>require(tidyverse) x &lt;- tibble::tribble( ~treatment, ~question, ~bin, ~weight, &quot;first_name_of_treatment&quot;, &quot;didyou&quot;, 1L, 5.6, &quot;first_name_of_treatment&quot;, &quot;didthey&quot;, 0L, 10.3, &quot;first_name_of_treatment&quot;, &quot;willyou&quot;, 1L, 45.1, &quot;first_name_of_treatment&quot;, &quot;willthey&quot;, 0L, 2.2, &quot;first_name_of_treatment&quot;, &quot;didntthey&quot;, 1L, 1.5, &quot;another_t_name&quot;, &quot;didyou&quot;, 0L, 93.4, &quot;another_t_name&quot;, &quot;didthey&quot;, NA, NA, &quot;another_t_name&quot;, &quot;willyou&quot;, 1L, 52.1, &quot;another_t_name&quot;, &quot;willthey&quot;, 0L, 3.9, &quot;another_t_name&quot;, &quot;didntthey&quot;, NA, NA ) </code></pre> <p>If I run the following code, I get the output that's shown below.</p> <pre><code>x %&gt;% group_by(treatment, question) %&gt;% group_modify(~ tibble( n = sum(!is.na(.x)), mean = round(mean(as.numeric(unlist(.x)), na.rm = T), digits = 2), sd = round(sd(as.numeric(unlist(.x)), na.rm = T), digits = 2), se = round(sd/sqrt(n), digits = 3), ci_lo = round(mean - qnorm(1 - (.05 / 2)) * se, digits = 3), # qnorm() gets the specified Z-score ci_hi = round(mean + qnorm(1 - (.05 / 2)) * se, digits = 3), count_na = sum(is.na(.x)) ) ) </code></pre> <pre><code># A tibble: 10 × 9 # Groups: treatment, question [10] treatment question n mean sd se ci_lo ci_hi count_na &lt;chr&gt; &lt;chr&gt; &lt;int&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;int&gt; 1 another_t_name didntth… 0 NaN NA NA NaN NaN 2 2 another_t_name didthey 0 NaN NA NA NaN NaN 2 3 another_t_name didyou 2 46.7 66.0 46.7 -44.8 138. 0 4 another_t_name willthey 2 1.95 2.76 1.95 -1.88 5.78 0 5 another_t_name willyou 2 26.6 36.1 25.5 -23.5 76.6 0 6 first_name_of_treatment didntth… 2 1.25 0.35 0.247 0.766 1.73 0 7 first_name_of_treatment didthey 2 5.15 7.28 5.15 -4.94 15.2 0 8 first_name_of_treatment didyou 2 3.3 3.25 2.30 -1.20 7.80 0 9 first_name_of_treatment willthey 2 1.1 1.56 1.10 -1.06 3.26 0 10 first_name_of_treatment willyou 2 23.0 31.2 22.0 -20.2 66.3 0 </code></pre> <p>This is close to what I want, but the statistics in the grouped tibble are for the <code>weight</code> column, whereas what I want is for them to be for the <code>bin</code> column and apply the weights to that.</p> <p>So the ideal outcome is: the weighted mean of the <code>bin</code> column from the original tibble, for each value of <code>treatment</code> and <code>question</code>, weighted by the <code>weight</code> column (probably using <code>weighted.mean</code>).</p> <p>If I run <code>select(-weight)</code> before running <code>group_by(treatment, question)</code> I get the summary stats for the <code>bin</code> column (which is what I want), but then I don't have access to the weights which means I can't apply them.</p> <p>Is it possible to do what I want with a combination of <code>weighted.mean</code> and <code>group_modify()</code>? If not, what is a better way I can do this?</p>
[ { "answer_id": 74140089, "author": "Yanan LYU", "author_id": 20291606, "author_profile": "https://Stackoverflow.com/users/20291606", "pm_score": 0, "selected": false, "text": "@for $i from 1 through 3 {\n .bg-color-#{$i} {\n background-color: var(--color-#{$i});\n }\n}\n" ...
2022/10/20
[ "https://Stackoverflow.com/questions/74139910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5212742/" ]
74,139,920
<p>I'm trying to understand how static member functions work in C++.</p> <p>Below I have created a struct which represents a node-like data type. It has a single method to concatenate two objects.</p> <pre><code>struct obj { obj *parent; int id; obj(int id) { this-&gt;id = id; parent = this; } static void link(obj parent, obj child) { child.parent = &amp;parent; } }; </code></pre> <p>And here is the test I've written</p> <pre><code>int main() { obj a = obj(1); obj b = obj(2); obj::link(a, b); std::cout &lt;&lt; &quot;parent of a = &quot; &lt;&lt; a.parent-&gt;id &lt;&lt; std::endl; std::cout &lt;&lt; &quot;parent of b = &quot; &lt;&lt; b.parent-&gt;id &lt;&lt; std::endl; a.parent = &amp;b; std::cout &lt;&lt; &quot;parent of a = &quot; &lt;&lt; a.parent-&gt;id &lt;&lt; std::endl; std::cout &lt;&lt; &quot;parent of b = &quot; &lt;&lt; b.parent-&gt;id &lt;&lt; std::endl; return 0; } </code></pre> <p>My expectation here would be to have both sets of prints to output the same things, or in other words, I would expect <code>a.parent = &amp;b;</code> to not have any effect on the computation, as calling the function <code>link</code> should already have performed this operation.</p> <p>Unfortunately, running the code does not yield such results, as you can see below.</p> <pre><code>parent of a = 1 parent of b = 2 parent of a = 2 parent of b = 2 </code></pre> <p>I suspect this is due to the function being static. Indeed, using the function below yields the desidered output.</p> <pre><code>void linkTo(obj parent) { this-&gt;parent = &amp;parent; } </code></pre> <p>I now would like to understand why the first function does not work the way I think it would. I am pretty sure that the equivalent of such function would work in Java, which is a language I am more familiar with.</p> <p>My understanding is that if member functions are static, they cannot refer to fields of an object, as there is no way to identify which object they should be related to. In this case, however, the objects are being passed as parameters in the function call, so I would expect their members to be accessible and modifiable.</p> <p>Is there a way to perform the operation presented above using a static member function. If not, why is that the case?</p>
[ { "answer_id": 74139977, "author": "463035818_is_not_a_number", "author_id": 4117728, "author_profile": "https://Stackoverflow.com/users/4117728", "pm_score": 2, "selected": false, "text": "child.parent = &parent;" }, { "answer_id": 74141058, "author": "Dave", "author_id"...
2022/10/20
[ "https://Stackoverflow.com/questions/74139920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11863276/" ]
74,139,921
<p>I would like to do something like below.</p> <pre><code>private &lt;T&gt; void sliceGenericData (List&lt;T&gt; peData, **FunctionType** getterFunctionX) { // ... Some Code ... &lt;T&gt;.getterFunction() // ... Some Code ... } </code></pre> <p>A and B class will be my generic type as &lt;T&gt;. Example for a getter function for class A and B.</p> <pre><code>public class A{ long x = 5; public long getterFunction1(){ return x; } } public class B{ long x = 1; public long getterFunction2(){ return x; } } </code></pre> <p>I want to pass a getterFunction as argument to my <code>sliceGenericData()</code> and I would like to use it on type &lt;T&gt; (Class A or B). Since those classes have different name of getter functions as <code>getterFunction2, getterFunction1</code>. How can I do it?</p>
[ { "answer_id": 74140333, "author": "nyname00", "author_id": 5935221, "author_profile": "https://Stackoverflow.com/users/5935221", "pm_score": 4, "selected": true, "text": "private <T> void sliceGenericData (List<T> peData, Function<T, Long> fn) \n{ \n ... \n // apply your Object\n Lon...
2022/10/20
[ "https://Stackoverflow.com/questions/74139921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5384988/" ]
74,139,936
<p>I have the following endpoint in my Spring MVC controller:</p> <pre><code>@RestController public class ToolsController { @GetMapping(&quot;/v1/auth-check/....id....&quot;) @RolesAllowed(...) @MyCustomPermissions(...) public MyResult checkAuth(...., int databaseId, ....) { </code></pre> <p>Here roles allowed is a standard annotation, which checks with user data and prevent method from being called without permissions.</p> <p>Now I want additionally to check permissions with the help of a data, which is contained in a database object, identified by parameter <code>databaseId</code>. Can I read this object from somewhere so that my annotation also prevent method from being called?</p> <p>I can parse request separately in <code>HandlerInterceptorAdapter#preHandle</code></p> <p>This is bad because I will duplicate Spring's work. Are there any other mechanisms?</p>
[ { "answer_id": 74140333, "author": "nyname00", "author_id": 5935221, "author_profile": "https://Stackoverflow.com/users/5935221", "pm_score": 4, "selected": true, "text": "private <T> void sliceGenericData (List<T> peData, Function<T, Long> fn) \n{ \n ... \n // apply your Object\n Lon...
2022/10/20
[ "https://Stackoverflow.com/questions/74139936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/258483/" ]
74,139,939
<p>I am trying to find a way to check if a list contains contiguous elements which are not duplicated.</p> <p>For example, <br></p> <ul> <li><code>A = [1, 1, 4, 2, 2, 2]</code> this list <strong>contains</strong> contiguous elements which are not duplicated.</li> <li><code>A = [1, 1, 4, 4, 3, 4, 7, 7, 7]</code> this list <strong>does not contains</strong> contiguous elements which are not duplicated. Here the value 4 is contiguous from index 2 and 3 but its occurs again at index 5 which is not acceptable.</li> </ul> <p>Basically a unique value should only occur once in a list contiguously.</p> <p>Is there any means where the <code>time complexity should be less than O(n^2)</code>. <br> Also, is there some method in <code>itertools</code> through which I could acheive this?</p>
[ { "answer_id": 74140333, "author": "nyname00", "author_id": 5935221, "author_profile": "https://Stackoverflow.com/users/5935221", "pm_score": 4, "selected": true, "text": "private <T> void sliceGenericData (List<T> peData, Function<T, Long> fn) \n{ \n ... \n // apply your Object\n Lon...
2022/10/20
[ "https://Stackoverflow.com/questions/74139939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10060525/" ]
74,139,941
<p>I am coding a python function that has as input parameter certain excel range (e.g. &quot;A1:B2&quot;). How can I make python return a list of nº rows and nº columns from here?? (for instance if A1:B2 is the input, this list shall return [2,2])</p> <p>This is what I did:</p> <pre><code>def return_rows_columns_from_excel_range(excel_range): # import string # import re # excel range could be something like &quot;A1:C15&quot; alphabet = list(string.ascii_uppercase) first_cell = excel_range.split(&quot;:&quot;)[0] second_cell = excel_range.split(&quot;:&quot;)[1] column_1 = re.search('\D+',first_cell)[0] column_2 = re.search('\D+',second_cell)[0] row_1 = int(re.search('\d+',first_cell)[0]) row_2 = int(re.search('\d+',second_cell)[0]) columns = alphabet.index(column_2) - alphabet.index(column_1) + 1 rows = row_2 - row_1 + 1 output = [rows,columns] return output </code></pre> <p>This is valid if ranges are like &quot;A1:C15&quot;, but if the range is like &quot;AA1:AC13&quot; I am not very sure how to tackle it...</p>
[ { "answer_id": 74140333, "author": "nyname00", "author_id": 5935221, "author_profile": "https://Stackoverflow.com/users/5935221", "pm_score": 4, "selected": true, "text": "private <T> void sliceGenericData (List<T> peData, Function<T, Long> fn) \n{ \n ... \n // apply your Object\n Lon...
2022/10/20
[ "https://Stackoverflow.com/questions/74139941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8972132/" ]
74,139,947
<p>I couldn't find any information about this!</p> <p>So, I have a web app in react and use the firebase config settings and want to secure the firebase rules.</p> <p>I have these: build devices templates users</p> <p>I used this for the users:</p> <pre><code>{&quot;rules&quot;: { &quot;users&quot;: { &quot;$uid&quot;: { // Allow only authenticated content owners access to their data &quot;.read&quot;: &quot;auth !== null &amp;&amp; auth.uid === $uid&quot;, &quot;.write&quot;: &quot;auth !== null &amp;&amp; auth.uid === $uid&quot; }}}} </code></pre> <p>But I also need to allow the web app or any client that uses the api to have full access to the db and all the data and not just &quot;users&quot; from the react app.</p>
[ { "answer_id": 74140333, "author": "nyname00", "author_id": 5935221, "author_profile": "https://Stackoverflow.com/users/5935221", "pm_score": 4, "selected": true, "text": "private <T> void sliceGenericData (List<T> peData, Function<T, Long> fn) \n{ \n ... \n // apply your Object\n Lon...
2022/10/20
[ "https://Stackoverflow.com/questions/74139947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10579389/" ]
74,139,949
<p>Route [partner.file.download] not defined. is the error i get, but this route is defined. and yes i am logged in as a 'partner'</p> <p>Web.php</p> <pre><code>Route::group(['middleware' =&gt; 'role:partner', 'prefix' =&gt; 'partner', 'as' =&gt; 'partner.'], function(){ Route::resource('/dashboard', App\Http\Controllers\partner\PartnerController::class); Route::resource('/profile', App\Http\Controllers\partner\ProfileController::class); Route::resource('/file', App\Http\Controllers\partner\FileController::class); }); </code></pre> <p>controller</p> <pre><code> public function show($id) { $file = File::findOrFail($id); return view('partner.file.viewfile', compact('file')); } public function download($id) { return view('partner.file.index', compact('file)); } </code></pre> <p>index.blade</p> <pre><code> &lt;tbody&gt; @foreach($files as $file) &lt;tr&gt; &lt;td&gt;{{$file-&gt;title}} &lt;/td&gt; &lt;td&gt; &lt;a class=&quot;btn btn-big btn-succes&quot; style=&quot;background: orange;&quot; href=&quot;{{ route('partner.file.show', $file-&gt;id) }}&quot;&gt;View&lt;/a&gt; &lt;/td&gt; &lt;td&gt; &lt;a class=&quot;btn btn-big btn-succes&quot; style=&quot;background: green;&quot; href=&quot;{{ route('partner.file.download', $file-&gt;id) }}&quot;&gt;&lt;/a&gt; &lt;/td&gt; &lt;td&gt;{{@$file-&gt;language-&gt;name}} &lt;/td&gt; @foreach($file-&gt;tag as $tags) &lt;td style=&quot;background:{{$tags['color']}} ;&quot;&gt;{{@$tags-&gt;name}} &lt;/td&gt; @endforeach &lt;/tr&gt; @endforeach &lt;/tbody&gt; </code></pre>
[ { "answer_id": 74140353, "author": "Ebi", "author_id": 11021885, "author_profile": "https://Stackoverflow.com/users/11021885", "pm_score": 3, "selected": true, "text": "resource()" } ]
2022/10/20
[ "https://Stackoverflow.com/questions/74139949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19923550/" ]
74,139,967
<p>I have an VSTO Outlook Add-in. In the startup process I do some stuff that is required for the Add-in to work properly later (it is a MUST).</p> <p>I have noticed that sometimes (not always) and only in a few occasions when I start Outlook my Add-in takes longer than usual (more than it should) so Outlook disables it.</p> <p>I have been researching and analyzing how long it takes each thing to do at startup by using <a href="https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.stopwatch?view=net-7.0" rel="nofollow noreferrer">System.Diagnostics.Stopwatch</a> and I have see that the culprit is a task that creates a custom task pane which embeds an WPF user control. It looks like the initialization of this WPF user control makes Add-in get disabled, it takes a little more than 2 seconds whilst the rest of things take 2ms, 5ms, 110ms, etc. (below half a second). I guess this is due to how .NET framework layer works. So I am wondering if there is something I can do to improve the creation and initialization of this WPF user control and the custom task pane. The initialization of this custom task pane and the WPF user controls is a MUST for Add-in to work properly later, for example I cannot apply a lazy loading of this.</p> <p>Any ideas?</p>
[ { "answer_id": 74140353, "author": "Ebi", "author_id": 11021885, "author_profile": "https://Stackoverflow.com/users/11021885", "pm_score": 3, "selected": true, "text": "resource()" } ]
2022/10/20
[ "https://Stackoverflow.com/questions/74139967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1624552/" ]
74,140,040
<pre><code>object LoopList extends App { var even_list = List() var odd_list = List() for (i &lt;- Range(1,10)) { if ((i % 2) == 0) { even_list = even_list :+ i } else { odd_list = odd_list :+ i } } println(even_list) } </code></pre> <p>I am trying to create 2 simple lists for odd and even, although i know lists are immutable but i tried tuples as well. Please suggest a way to new solution using for loop only.</p>
[ { "answer_id": 74140353, "author": "Ebi", "author_id": 11021885, "author_profile": "https://Stackoverflow.com/users/11021885", "pm_score": 3, "selected": true, "text": "resource()" } ]
2022/10/20
[ "https://Stackoverflow.com/questions/74140040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20291612/" ]
74,140,047
<p>I have a <strong>compose.yml</strong> like this one:</p> <pre><code>version: '3.7' services: nginx: restart: unless-stopped image: ghcr.io/user/frontend:latest ports: - 80:80 depends_on: - backend backend: restart: unless-stopped image: ghcr.io/user/backend:latest entrypoint: /home/app/web/wsgi-entrypoint.sh expose: - 8000 </code></pre> <p>We have 2 images stored on Github: frontend and backend.</p> <p>My goal is the following: when an image has been updated on the Github Docker Registry, I'd like to automatically update the image on the server and launch the new one substituting the old one via docker-compose.</p> <p>For example: I have a running compose made by frontend and backend, but I just pushed a new image: <em>ghcr.io/user/frontend:latest</em>.</p> <p>Now, I want a single command which updates only the images that have been changed (in this case <em>ghcr.io/user/frontend:latest</em>) and when I reload the frontend webpage I see the changes.</p> <p>My attempt is the following:</p> <pre><code>docker-compose up -d --build </code></pre> <p>But the system says:</p> <pre><code>compose-backend_1 is up-to-date compose-nginx_1 is up-to-date </code></pre> <p>which is not true!</p> <p>So, the working procedure I use is a bit manual:</p> <pre><code>docker pull ghcr.io/user/frontend:latest </code></pre> <p>I see in the console: <em>Status: Downloaded <strong>newer</strong> image</em>, which is the proof that a new image has been downloaded. Then, if I relaunch the same command the console displays: <em>Status: Image is <strong>up to date</strong> for ghcr.io/user/frontend:latest</em></p> <p>Finally:</p> <pre><code>docker-compose up -d --build </code></pre> <p>says: <em>Recreating compose-nginx_1 ... done</em></p> <p>I suppose the command <em>docker-compose up -d --build</em> ALONE is not looking for new images and so does not update the image that is changed.</p> <p>So, is there a SINGLE specific command to fix this?</p>
[ { "answer_id": 74140353, "author": "Ebi", "author_id": 11021885, "author_profile": "https://Stackoverflow.com/users/11021885", "pm_score": 3, "selected": true, "text": "resource()" } ]
2022/10/20
[ "https://Stackoverflow.com/questions/74140047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1240075/" ]
74,140,057
<p>This is my code:</p> <pre><code> &lt;div class=&quot;entry-summary&quot;&gt; &lt;?php the_excerpt(); ?&gt; &lt;/div&gt; </code></pre> <p>But I would like to edit what the_excerpt function displays. Is it possible to reach the_excerpt function code? Where to find that function in WordPress files?</p> <p>Thanks!</p>
[ { "answer_id": 74140353, "author": "Ebi", "author_id": 11021885, "author_profile": "https://Stackoverflow.com/users/11021885", "pm_score": 3, "selected": true, "text": "resource()" } ]
2022/10/20
[ "https://Stackoverflow.com/questions/74140057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18772748/" ]
74,140,069
<p>I have a runnable code snippet below and here as well: <a href="https://stackblitz.com/edit/js-ecyxnt?file=index.html" rel="nofollow noreferrer">https://stackblitz.com/edit/js-ecyxnt?file=index.html</a></p> <p>What I would like to know is how I can elegantly accomplish with es6, toggling the <code>&lt;use href=&quot;&quot;&gt;</code> attribute somehow so that the svg switches between the regular and filled version.</p> <p>I want one svg element that starts out unfilled and on each click it toggle between it's normal state and being filled. I am confused how to do this, if I actually need two svgs in a parent svg in order to use <code>&lt;use&gt;</code> or what the best way to implement this would be.</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>.wishlist-btn { display: flex; align-items: center; justify-content: center; height: 100px; width: 100px; border: none; background: #fff; transition: all 0.5s ease-in-out; box-shadow: 0 0 15px rgba(0 0 0 / 25%); } .icon { height: 60px; width: 60px; margin: 20px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;h1&gt;Svg &amp;lt;use&amp;gt; href toggle&lt;/h1&gt; &lt;button class="wishlist-btn"&gt; &lt;svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"&gt; &lt;!-- how can I toggle #wishlist-add/#wishlist with JavaScript? --&gt; &lt;use href="#wishlist-add"/&gt; &lt;/svg&gt; &lt;/button&gt; &lt;svg viewBox="0 0 20 20" class="icon" id="wishlist-add" xmlns="http://www.w3.org/2000/svg"&gt; &lt;path d="M2.813 10.88l7.204 7.2 7.875-7.873a4.993 4.993 0 000-7.05 4.884 4.884 0 00-6.977 0l-.897.902-.46-.465-.476-.479A4.89 4.89 0 005.594 1.65a4.893 4.893 0 00-3.49 1.465 4.998 4.998 0 00-.001 7.05l.706.706.004.008z" stroke="currentColor" stroke-width="1.3" fill="none" fill-rule="evenodd" &gt;&lt;/path&gt; &lt;/svg&gt; &lt;svg viewBox="0 0 20 20" class="icon" id="wishlist" xmlns="http://www.w3.org/2000/svg"&gt; &lt;path d="M20 6.681c0 1.44-.55 2.88-1.646 3.984L10.017 19l-7.753-7.75-.004-.009-.617-.617a5.649 5.649 0 010-7.966A5.543 5.543 0 015.593 1c1.428 0 2.855.552 3.95 1.658l.476.479.435-.438a5.533 5.533 0 017.9 0A5.64 5.64 0 0120 6.681z" fill="currentColor" fill-rule="evenodd" &gt;&lt;/path&gt; &lt;/svg&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74140485, "author": "Robert Longson", "author_id": 1038015, "author_profile": "https://Stackoverflow.com/users/1038015", "pm_score": 1, "selected": false, "text": "function run(event) {\n let use = event.target.querySelector(\"use\");\n use.setAttribute(\"href\", use.get...
2022/10/20
[ "https://Stackoverflow.com/questions/74140069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17422582/" ]
74,140,078
<p>I am trying to annotate all my groups by the number of Users, that apply to a certain condition. In this case I want to get a number of users, that have related Offer model to the Task in the Group.</p> <p>Users can create Offers to the Task. One Task can be related to one Group.</p> <p>So as the result of annotating Groups I want something like this</p> <pre><code>| id | name | runners_num | | -- | ------ | ----------- | | 1 | name1 | 3 | | 2 | name2 | 5 | </code></pre> <p>With a query below I can get this count as a dictionary</p> <pre class="lang-py prettyprint-override"><code>runners = User.objects.filter( offer__tack__group_id=1 ).distinct( ).values( 'id' ).aggregate( count=Count('id') ) output: {'count': 5} </code></pre> <p>But I can't figure out how to do this with OuterRef clause</p> <pre class="lang-py prettyprint-override"><code>runners = User.objects.filter( offer__task__group_id=OuterRef('id') ).distinct().values('id') groups = Group.objects.annotate( runners_num=Count(Subquery(runners)) ) </code></pre> <p>It ended up with this wrong query</p> <pre class="lang-sql prettyprint-override"><code>SELECT &quot;groups&quot;.&quot;id&quot;, &quot;groups&quot;.&quot;name&quot;, COUNT( ( SELECT DISTINCT U0.&quot;id&quot; FROM &quot;users&quot; U0 INNER JOIN &quot;offers&quot; U1 ON (U0.&quot;id&quot; = U1.&quot;runner_id&quot;) INNER JOIN &quot;tasks&quot; U2 ON (U1.&quot;task_id&quot; = U2.&quot;id&quot;) WHERE U2.&quot;group_id&quot; = (&quot;groups&quot;.&quot;id&quot;) ) ) AS &quot;runners_num&quot; FROM &quot;groups&quot; GROUP BY &quot;groups&quot;.&quot;id&quot; LIMIT 21 </code></pre> <p>My models</p> <pre class="lang-py prettyprint-override"><code>class Task(models.Model): tasker = models.ForeignKey( &quot;user.User&quot;, null=True, blank=True, on_delete=models.SET_NULL, related_name=&quot;tasker&quot; runner = models.ForeignKey( &quot;user.User&quot;, null=True, blank=True, on_delete=models.SET_NULL, related_name=&quot;runner&quot;, ) group = models.ForeignKey( &quot;group.Group&quot;, on_delete=models.CASCADE ) class Offer(models.Model): task = models.ForeignKey(&quot;task.Task&quot;, on_delete=models.CASCADE) runner = models.ForeignKey(&quot;user.User&quot;, null=True, blank=True, on_delete=models.SET_NULL) class Group(model.Model): name = models.CharField(max_length=100) class GroupMembers(models.Model): group = models.ForeignKey(&quot;group.Group&quot;, on_delete=models.CASCADE) member = models.ForeignKey(&quot;user.User&quot;, null=True, blank=True, on_delete=models.SET_NULL) </code></pre> <h2>EDIT</h2> <p>I have conditions where my Users get filtered. In my case I want count only Users that have more than 3 Offers that apply to conditions. So probably I can't get rid of Subquery statement and OuterRef field.</p> <pre class="lang-py prettyprint-override"><code>runners = User.objects.filter( offer__task__group_id=OuterRef('id') ).distinct( ).annotate( offer_num=Count( 'offer', filter= Q( offer__task__completion_time__isnull=False, offer__task__completion_time__gte=timezone.now() - timedelta(hours=24), ) | Q( offer__task__status__in=( TaskStatus.ACTIVE, TaskStatus.ACCEPTED, TaskStatus.IN_PROGRESS, TaskStatus.WAITING_REVIEW ), offer__task__is_active=True, ), offer__runner_id=F('id'), ) ).filter( offer_num__gte=3 ).values('id') </code></pre> <p>It is working fine if I replace OuterRef('id') with just a int Group number. But I don't know the proper solution how to count on this QuerySet. Something like</p> <pre><code>runners_num = Count(Subquery(runners)) </code></pre> <p>And after that I get</p> <pre><code>django.db.utils.ProgrammingError: more than one row returned by a subquery used as an expression </code></pre>
[ { "answer_id": 74147505, "author": "Clepsyd", "author_id": 10722733, "author_profile": "https://Stackoverflow.com/users/10722733", "pm_score": 1, "selected": false, "text": "Group.objects.annotate(\n runners_count=Count(\n 'task__offer__user', distinct=True\n )\n).values('id...
2022/10/20
[ "https://Stackoverflow.com/questions/74140078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15506558/" ]