qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,267,482
<h2>I have provided a <a href="https://dotnetfiddle.net/moqCNW" rel="nofollow noreferrer">dotnetfiddle</a> to show the issue.</h2> <p>I try to copy object from a source that have the same property names and type except some properties that have IEnumerable and target object has IList using reflection.</p> <pre><code>public T CopyTo&lt;T&gt;(object src) where T : new() { var targetObj = new T(); //Getting Type of Src var sourceType = src.GetType(); BindingFlags flags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty; var sourcePi = sourceType.GetProperties(flags); foreach (var property in sourcePi) { var pi = targetObj.GetType().GetProperty(property.Name); if (pi == null || !pi.CanWrite) continue; object sourceValue = property.GetValue(src, null); //var sourceValue = Convert.ChangeType(property.GetValue(src, null), pi.PropertyType); //this works, but hard wired if (sourceValue is IEnumerable&lt;string&gt; i) sourceValue = ((IEnumerable&lt;string&gt;)i).Cast&lt;string&gt;().ToList(); pi.SetValue(targetObj, sourceValue, null); } return targetObj; } </code></pre> <p>It raises an error:</p> <blockquote> <p>System.ArgumentException: 'Object of type 'System.String[]' cannot be converted to type 'System.Collections.Generic.List`1[System.String]'.'</p> </blockquote> <p>I tried to convert:</p> <pre><code> var sourceValue = Convert.ChangeType(property.GetValue(src, null), pi.PropertyType); </code></pre> <p>but also get error<br /> <code>System.InvalidCastException: Object must implement IConvertible.</code></p> <p>this <a href="https://stackoverflow.com/questions/5718077/cannot-add-items-to-an-ilist-list-being-casted-from-an-ienumerable">issue</a> can't help.</p> <p>My workaround solution is casting :</p> <pre><code> sourceValue = ((IEnumerable&lt;string&gt;) sourceValue).Cast&lt;string&gt;().ToList(); </code></pre> <p>The disadvantage is hard wiring the cast to <code>IEnumerable&lt;string&gt;</code></p> <p>Is there a better way to copy <code>IEnumerable&lt;T&gt; to IList&lt;T&gt; </code> or any generic collection using reflection.</p>
[ { "answer_id": 74268037, "author": "Ygalbel", "author_id": 1543596, "author_profile": "https://Stackoverflow.com/users/1543596", "pm_score": 0, "selected": false, "text": "1. Source IEnumerable<T>, Destination: List<T> => Create New list and put in CTOR\n\n2. Source List<T>, Destination:...
2022/10/31
[ "https://Stackoverflow.com/questions/74267482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3142139/" ]
74,267,498
<p>I have a matrix in <code>R</code> and I am trying to create plots between first column (Y) with all other columns (<code>Xj j=1,...,12</code>). I am using the following code to do that:</p> <pre><code>set.seed(123) dat &lt;- as.data.frame(matrix(rnorm(20 * 13, mean = 0, sd = 1), 20, 13)) colnames(dat) &lt;- c(&quot;Y&quot;, paste0(&quot;X&quot;,1:12)) data_def &lt;- pivot_longer(dat, -Y) ggplot(data_def, aes(x = Y, y = value)) + stat_smooth(se = FALSE, color = &quot;red&quot;, size = 0.5, method = &quot;loess&quot;) + facet_wrap( ~ name, scales = &quot;free_y&quot;, strip.position = &quot;bottom&quot;) + theme_classic() + labs(x = NULL, y = &quot;Y&quot;) </code></pre> <p>which results in: <a href="https://i.stack.imgur.com/NTpvu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NTpvu.png" alt="enter image description here" /></a></p> <p>However after <code>X1</code> comes <code>X10</code>, <code>X11</code> and <code>X12</code> instead of <code>X2</code>, <code>X3</code>, etc.. How can I re arrange the order?</p>
[ { "answer_id": 74268037, "author": "Ygalbel", "author_id": 1543596, "author_profile": "https://Stackoverflow.com/users/1543596", "pm_score": 0, "selected": false, "text": "1. Source IEnumerable<T>, Destination: List<T> => Create New list and put in CTOR\n\n2. Source List<T>, Destination:...
2022/10/31
[ "https://Stackoverflow.com/questions/74267498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12649684/" ]
74,267,505
<p>I am trying to correct casing issues due to improper data input (writing in all CAPS, all lower case, or improper unit capitalizations) when returning records from and older DB. I found this solution for converting a string to title case, but I want to add exceptions to it. The original code had an exception to lower case minor words unless they are the first or last word, which I really like, but I want to add an additional exception for another predefined array of words that I have already set the casing for (Initialisms, acronyms, units of measure) that I can add to as we find more exceptions. I know it is not recommended to change a prototype, but I have yet to find another way to make it work like the ‘.toLowerCase()’ method, and I really like being able to make it work like a method and add ‘.toTitleCase()’ after my value like this: {item.name.toTitleCase()}.</p> <p>Is there a way of accomplishing this without modifying the prototype, but still use it as a method, plus adding an array of exceptions?</p> <p>Here is what I have:</p> <pre><code>const casingPreset = [&quot;cm&quot;, &quot;DOE&quot;, &quot;ft&quot;, &quot;ID&quot;, &quot;KC&quot;, &quot;mm&quot;, &quot;TV&quot;, &quot;USA&quot;]; String.prototype.toTitleCase = function () { var i, j, str, lowers; str = this.replace(/([^\W_]+[^\s-]*) */g, (txt) =&gt; { return txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase(); }); // Words left lowercase unless first or last words in the string lowers = [&quot;A&quot;, &quot;An&quot;, &quot;And&quot;, &quot;As&quot;, &quot;At&quot;, &quot;But&quot;, &quot;By&quot;, &quot;For&quot;, &quot;From&quot;, &quot;In&quot;, &quot;Into&quot;, &quot;Near&quot;, &quot;Nor&quot;, &quot;Of&quot;, &quot;On&quot;, &quot;Onto&quot;, &quot;Or&quot;, &quot;The&quot;, &quot;To&quot;, &quot;With&quot;]; for (i = 0, j = lowers.length; i &lt; j; i++) str = str.replace(new RegExp(&quot;\\s&quot; + lowers[i] + &quot;\\s&quot;, &quot;g&quot;), function (txt) { return txt.toLowerCase(); }); return str; }; </code></pre> <p>Taking something like this: ‘THE DOE IN THE USA DOESN’T USE THE UNIT CM.’</p> <p>And returning something like this: “The DOE in the USA Doesn’t Use the Unit cm.’</p> <p>Of course the example above is nonsense, but give you an idea of what I want to accomplish</p>
[ { "answer_id": 74267615, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 1, "selected": false, "text": "const casingPreset = [\"cm\", \"DOE\", \"ft\", \"ID\", \"KC\", \"mm\", \"TV\", \"USA\"];\n\nfunction toTitleCase (inp...
2022/10/31
[ "https://Stackoverflow.com/questions/74267505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10982789/" ]
74,267,519
<p>I'm having problems in &quot;evolving&quot; a script to clean lines of a TXT, attached example of TXT:</p> <pre><code>Fri Oct 14 22:27:49.100 EDT Interface Status Protocol Description -------------------------------------------------------------------------------- Lo0 up up Loopback0 interface configured by Netmiko Lo55 up up Lo100 up up ***MERGE LOOPBACK 100**** Lo111 up up Configured by NETCONF Nu0 up up Mg0/RP0/CPU0/0 up up DO NOT TOUCH THIS ! Gi0/0/0/0 admin-down admin-down ANSIBLE NXOS TEST Gi0/0/0/1 admin-down admin-down test Gi0/0/0/1.100 admin-down admin-down Gi0/0/0/2 admin-down admin-down Link to P2 configured by Netmiko Gi0/0/0/3 up up Configured by Ansible !!!!!!!! Gi0/0/0/4 up up Updated by Ansible using Jinja Template Gi0/0/0/5 up up Configured by Ansible !!!!!! Gi0/0/0/6 admin-down admin-down Updated by Ansible using Jinja Template Gi0/0/0/6.11 admin-down admin-down Lo20 admin-down admin-down Lo22 up up Loopback para pruebas [K --More-- [KLo69 admin-down admin-down Gi0/3/3/4 up up A SDH Gi0/3/3/4.852 up up TMU a Red BIT [K --More-- [KGi0/3/3/4.853 up up Configured by Ansible !!!!!! Gi0/3/4/2.256 up up Frontera Cliente A Gi0/3/4/2.257 up up Frontera Cliente B [K --More-- [KGi0/3/4/2.261 up up Frontera Cliente C Te0/7/0/3 admin-down admin-down Mg0/RP0/CPU0/0 down down Mg0/RP1/CPU0/0 admin-down admin-down [KRP/0/RP0/CPU0:ROUTER1# </code></pre> <p>and the script is as follows:</p> <pre><code>list_txt = [ruta/&quot;prueba.txt&quot;] for txt in list_txt: with open(txt, &quot;r&quot;) as f: lines = f.readlines() with open(txt, &quot;w&quot;) as fw: for line in lines: if not re.match(&quot;-{5}|\s+|([A-Za-z0-9]+( [A-Za-z0-9]+)+)&quot;, line): fw.write(line) </code></pre> <p>With this script I am able to delete the lines of the date above everything, the blank lines and the lines where they are pure hyphens, the problem is that I am trying to add 2 things:</p> <p>1- Add to the regex that if it contains the word &quot;CPU&quot; so the lines would be deleted:</p> <pre><code>Mg0/RP0/CPU0/0 down down Mg0/RP1/CPU0/0 admin-down admin-down [KRP/0/RP0/CPU0:ROUTER1# </code></pre> <p>2 - On the other hand, I need to delete that strange addition that is added in some lines, such as:</p> <pre><code>[K --More-- [KLo69 admin-down admin-down </code></pre> <p>and make it clean like this:</p> <pre><code>Lo69 admin-down admin-down </code></pre> <p>This last one I try to do it through txt.lstrip(&quot;[K&quot;) but it had no effect, I'm doing it incorrectly and it doesn't work and the Regex I'm not hitting the key either and I can't add the word CPU, I'm not so clear How to generate the Regex clearly.</p> <p>Ideally, I would like you to be able to add everything to the existing script so as not to complicate things so much, could you give me a hand please?</p>
[ { "answer_id": 74268575, "author": "trincot", "author_id": 5459839, "author_profile": "https://Stackoverflow.com/users/5459839", "pm_score": 1, "selected": false, "text": "spans = []\nresult = []\nwith open(txt, \"r\") as f:\n it = iter(f.readlines()) \n # Skip lines until headi...
2022/10/31
[ "https://Stackoverflow.com/questions/74267519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20178424/" ]
74,267,562
<p>The height of an object, in metres, t seconds after it is launched straight up into the air is given by the equation h = -4.9t^2+bt+c where b represents the ball’s initial speed in metres per second and c represents the ball’s initial height in metres. Using the elif statement, write a Python program that displays the height of the ball every second from the instant it is thrown until it hits the ground.</p> <p>Design your program such that the following criteria are satisfied: • The user enters the initial speed and the initial height. • The format of the output is as follows: After 2 seconds, the height is 30.87 m. • Instead of displaying negative height values, the output states that the ball is on the ground. • The output does not contain grammatical errors, such as “After 1 seconds,....”</p> <p>My code is the following:</p> <pre class="lang-py prettyprint-override"><code>#initial values t = 0 h = 0 #ask user for initial speed and initial height b = float(input(&quot;What is the initial speed in metres per second?: &quot;)) c = float(input(&quot;What is the initial height in metres: &quot;)) #calculate and display height while h&gt;=0: h = round(-4.9*t**2+b*t+c, 2) if t==1: print(&quot;After 1 second, the height is&quot;, h, &quot;m.&quot;) elif h&gt;0: print(&quot;After&quot;, t, &quot;seconds, the height is:&quot;, h, &quot;m.&quot;) else: print(&quot;After&quot;, t,&quot;seconds, the ball is on the ground&quot;) t = t+1 </code></pre> <p>The code runs but after the user inputs the initial speed and height the program keeps running and doesn't output anything.</p>
[ { "answer_id": 74268575, "author": "trincot", "author_id": 5459839, "author_profile": "https://Stackoverflow.com/users/5459839", "pm_score": 1, "selected": false, "text": "spans = []\nresult = []\nwith open(txt, \"r\") as f:\n it = iter(f.readlines()) \n # Skip lines until headi...
2022/10/31
[ "https://Stackoverflow.com/questions/74267562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13765358/" ]
74,267,569
<p>In a angular i added a tab control, but list of available tabs i will get from backend. so i added a code to display template base on some key . but every time when i switch a tab, I can see OnInit event for a new tab and for a current. I dont need to load a current tab infor again, so, perfectly, it should call onDestroy for a current tab and OnInit for a new.</p> <pre><code>&lt;mat-tab-group disableRipple (selectedTabChange)=&quot;tabChange($event)&quot;&gt; &lt;ng-container *ngFor=&quot;let info of tabs&quot;&gt; &lt;mat-tab [label]=&quot;info.title&quot;&gt; &lt;ng-template matTabContent&gt; &lt;ng-container *ngIf=&quot;selectedTab == 'step1'&quot;&gt; &lt;app-step1&gt;&lt;/app-step1&gt; &lt;/ng-container&gt; &lt;ng-container *ngIf=&quot;selectedTab == 'step2'&quot;&gt; &lt;app-step2&gt;&lt;/app-step2&gt; &lt;/ng-container&gt; &lt;ng-container *ngIf=&quot;selectedTab == 'step3'&quot;&gt; &lt;app-step3&gt;&lt;/app-step3&gt; &lt;/ng-container&gt; &lt;/ng-template&gt; &lt;/mat-tab&gt; &lt;/ng-container&gt; &lt;/mat-tab-group&gt; </code></pre> <p>i tried to do instead of ngIf add a [hidden] attribute and tried to do a switch, but still not correct behaviour for me</p> <p>added a code with an issue. <a href="https://stackblitz.com/edit/angular-ivy-hxg7rd?file=src/app/app.component.html" rel="nofollow noreferrer">stackblitz</a></p>
[ { "answer_id": 74267690, "author": "nate-kumar", "author_id": 9987590, "author_profile": "https://Stackoverflow.com/users/9987590", "pm_score": 0, "selected": false, "text": "display: none" }, { "answer_id": 74267892, "author": "Mehyar Sawas", "author_id": 5012127, "a...
2022/10/31
[ "https://Stackoverflow.com/questions/74267569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2676791/" ]
74,267,574
<p>So i have a struct. <code>pub struct Foo&lt;TFn, TArg, TReturn&gt; where TFn: Fn(TArg) -&gt; TReturn { func: TFn }</code></p> <p>This makes sence in my head being used to C# Generics, but why doesn't it work in rust? I want the field 'func' to be of type Fn where the argument is of type 'TArg' and the return value is of type 'TReturn'.</p> <p>The compiler is complaining that the paramter 'TArg' and 'TReturn' are never used, but they are helping to define the signature of the TFn value.</p> <p>I tried removing the 'never used' parameters and just writing in a type in the constraint explicitly. That works fine.</p>
[ { "answer_id": 74267690, "author": "nate-kumar", "author_id": 9987590, "author_profile": "https://Stackoverflow.com/users/9987590", "pm_score": 0, "selected": false, "text": "display: none" }, { "answer_id": 74267892, "author": "Mehyar Sawas", "author_id": 5012127, "a...
2022/10/31
[ "https://Stackoverflow.com/questions/74267574", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13647264/" ]
74,267,578
<p>I have a Scala based multi module project for which I'm having a GitHub Actions pipeline which contains two jobs, one for test and the other for publishing to GitHub packages. Here is my file:</p> <pre><code>name: Build my projects on: push: paths-ignore: - 'images/**' - README.md branches: - master tags: - 'v*.*.*' pull_request: branches: - master release: types: [ created ] env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: test: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 - name: Cache ivy2 uses: actions/cache@v1 with: path: ~/.ivy2/cache key: ${{ runner.os }}-sbt-ivy-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - name: SBT Test run: sbt clean test publish: needs: test steps: - name: Checkout - uses: actions/checkout@v2 - name: SBT Publish run: sbt publish </code></pre> <p>I would need the following:</p> <ol> <li>Trigger the publish job only when I want to do a release, but how do I know that I want to do a release? Do I tag a release when I commit the changes? If I tag it, then how can I check if there is a tag so that I know that I have to run the publish job?</li> </ol>
[ { "answer_id": 74267690, "author": "nate-kumar", "author_id": 9987590, "author_profile": "https://Stackoverflow.com/users/9987590", "pm_score": 0, "selected": false, "text": "display: none" }, { "answer_id": 74267892, "author": "Mehyar Sawas", "author_id": 5012127, "a...
2022/10/31
[ "https://Stackoverflow.com/questions/74267578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3102968/" ]
74,267,601
<p>I am trying to reach two private subnet EC2 instances from ELB in public subnet. But the instances are always showing as unhealthy. I tried lot of options but nothing worked.</p> <p>Here is the configuration I tried:</p> <p>1.Created VPC DNS resolution: Enabled DNS hostnames: Disabled</p> <ol start="2"> <li>Created 2 Public subnets and 2 Private Subnets. The only difference between these two is the Route table. Auto-assign public IPv4 address is set to &quot;No&quot; in Public Subnet</li> </ol> <p>I have added Internet gateway as a route in Route table of public subnet.</p> <p>Public subnet - Route Table <a href="https://i.stack.imgur.com/yGy7e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yGy7e.png" alt="enter image description here" /></a></p> <p>Private subnet - Route table <a href="https://i.stack.imgur.com/3atBd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3atBd.png" alt="enter image description here" /></a></p> <ol> <li><p>Created Two EC2 instances in Private subnet . Userdata set to apache webserver</p> </li> <li><p>The Security group of the instances <a href="https://i.stack.imgur.com/aB1FC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aB1FC.png" alt="enter image description here" /></a></p> </li> <li><p>Created an ALB in Public subnet</p> </li> </ol> <p>ALB Security group config is :</p> <p><a href="https://i.stack.imgur.com/Qmx1j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qmx1j.png" alt="enter image description here" /></a></p> <p>Have also added default security group in ALB: <a href="https://i.stack.imgur.com/WVJsv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WVJsv.png" alt="enter image description here" /></a></p> <p>Target group is showing unhealthy for the private EC2 instances <a href="https://i.stack.imgur.com/DpihD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DpihD.png" alt="enter image description here" /></a></p> <p>Any help on pointing out why this fails?</p>
[ { "answer_id": 74268530, "author": "Broshi", "author_id": 999270, "author_profile": "https://Stackoverflow.com/users/999270", "pm_score": 0, "selected": false, "text": "200" }, { "answer_id": 74269891, "author": "John Rotenstein", "author_id": 174777, "author_profile"...
2022/10/31
[ "https://Stackoverflow.com/questions/74267601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3217396/" ]
74,267,623
<p>I am running into a strange error on a website using multiple PHP scripts. For some reason, every submit button only calls the first PHP script defined rather than the one chosen. I know all of these scripts work and this issue started only recently. Here is the code in question:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Embed PHP in a .html File&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h2&gt;POV&lt;/h2&gt; &lt;form action=&quot;index.php&quot;&gt; &lt;button type=&quot;gohome&quot;&gt;Return to main form&lt;/button&gt; &lt;/form&gt; &lt;h3&gt;WIP Final results:&lt;/h3&gt; &lt;br&gt; &lt;?php include(&quot;showdatabasecontents.php&quot;); ?&gt; &lt;form method=&quot;post&quot; action=&quot;clearFinal.php&quot;&gt; &lt;input type=&quot;submit&quot; name=&quot;clearFinal&quot; value=&quot;Clear Responses&quot;&gt; &lt;form method=&quot;post&quot; action=&quot;resetFinal.php&quot;&gt; &lt;input type=&quot;submit&quot; name=&quot;resetFinal&quot; value=&quot;Reset ID Count&quot;&gt; &lt;h3&gt;Students names&lt;/h3&gt; &lt;?php include(&quot;showdatabasecontent2.php&quot;); ?&gt; &lt;h3&gt;Add a Student&lt;/h3&gt; &lt;form method=&quot;post&quot; action=&quot;addstudent.php&quot;&gt; Student Name : &lt;input type=&quot;text&quot; name=&quot;studentname&quot;&gt;&lt;br&gt;&lt;br&gt; &lt;input type=&quot;submit&quot; name=&quot;addstudent&quot; value=&quot;Submit&quot;&gt; &lt;/form&gt; &lt;h3&gt;Delete a student&lt;/h3&gt; &lt;form method=&quot;post&quot; action=&quot;connect.php&quot;&gt; ID : &lt;input type=&quot;text&quot; name=&quot;id&quot;&gt;&lt;br&gt;&lt;br&gt; &lt;input type=&quot;submit&quot; name=&quot;removeStudent&quot; value=&quot;Submit&quot;&gt; &lt;br&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I have tried changing some of the names for the buttons to make sure there was not a conflict but that did not make any different. Any info on this issue will help, thanks!</p>
[ { "answer_id": 74267779, "author": "Mahen", "author_id": 20373506, "author_profile": "https://Stackoverflow.com/users/20373506", "pm_score": 1, "selected": false, "text": "<input type=\"submit\" name=\"\" value=\"\">\n" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74267623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15139170/" ]
74,267,630
<p>Is there a way to save data just before a crash with sharedpreference? I search to deactivate a function only if a crash happens. So, to disable the function, I need to detect the crash. I'd like to use crash analytics to accomplish that, is that possible?</p> <p>I tried to simulate a crash, but <code>catch (error)</code> is not called:</p> <pre><code>try { FirebaseCrashlytics.instance.crash(); } catch (error) { prefs.setBool(&quot;crash&quot;,true); } </code></pre>
[ { "answer_id": 74298231, "author": "Naveen Avidi", "author_id": 5557479, "author_profile": "https://Stackoverflow.com/users/5557479", "pm_score": -1, "selected": false, "text": "futureMethod(params).catchError((e){\n debugPrint(e.toString());\n //todo handle error\n});\n" }, { ...
2022/10/31
[ "https://Stackoverflow.com/questions/74267630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9611719/" ]
74,267,647
<p>I need to get a random rotation on the Z-axis and then rotate a object to that Z-axis in a set speed, but i have no idea how to do that. Any help would be appreciated. I am using C# btw. .</p> <p>I tried to do it with a Vector 2 but i could not get that to work with the Z-axis</p>
[ { "answer_id": 74298231, "author": "Naveen Avidi", "author_id": 5557479, "author_profile": "https://Stackoverflow.com/users/5557479", "pm_score": -1, "selected": false, "text": "futureMethod(params).catchError((e){\n debugPrint(e.toString());\n //todo handle error\n});\n" }, { ...
2022/10/31
[ "https://Stackoverflow.com/questions/74267647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20381851/" ]
74,267,656
<p>I have a list of tuples like this one (PRODUCT_ID, COUNTRY_CODE):</p> <pre><code>[(1111, 'CO'), (2222, 'CO'), (1111, 'BR')] </code></pre> <p>and a dataframe like this one:</p> <pre><code>df = pd.DataFrame({ 'COUNTRY_CODE': ['CO','CO','CO','BR','BR','BR','CO'], 'VERTICAL_GROUP_ID': [2,2,3,2,3,3,3], 'SUB_VERTICAL': ['SUPER','SUPER','HOME','LICOR','SPORTS','HOME','TECH'], 'PRODUCT_ID': [1111,3333,1111,4444,1111,2222,2222], 'SHOWN': [7,8,12,14,16,1,13], }) </code></pre> <p>How can I filter the dataframe so that I get a resulting dataframe like this, filtered with only the values from the list of tuples by PRODUCT_ID and COUNTRY_CODE?</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">COUNTRY_CODE</th> <th style="text-align: center;">VERTICAL_GROUP_ID</th> <th style="text-align: right;">SUB_VERTICAL</th> <th style="text-align: left;">PRODUCT_ID</th> <th style="text-align: center;">SHOWN</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">CO</td> <td style="text-align: center;">2</td> <td style="text-align: right;">SUPER</td> <td style="text-align: left;">1111</td> <td style="text-align: center;">7</td> </tr> <tr> <td style="text-align: left;">CO</td> <td style="text-align: center;">3</td> <td style="text-align: right;">HOME</td> <td style="text-align: left;">1111</td> <td style="text-align: center;">12</td> </tr> <tr> <td style="text-align: left;">BR</td> <td style="text-align: center;">3</td> <td style="text-align: right;">SPORTS</td> <td style="text-align: left;">1111</td> <td style="text-align: center;">16</td> </tr> <tr> <td style="text-align: left;">CO</td> <td style="text-align: center;">3</td> <td style="text-align: right;">TECH</td> <td style="text-align: left;">2222</td> <td style="text-align: center;">13</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74267704, "author": "I'mahdi", "author_id": 1740577, "author_profile": "https://Stackoverflow.com/users/1740577", "pm_score": 2, "selected": true, "text": "zip" }, { "answer_id": 74267711, "author": "Shubham Sharma", "author_id": 12833166, "author_profi...
2022/10/31
[ "https://Stackoverflow.com/questions/74267656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11036109/" ]
74,267,685
<p>I am trying to plot to see if what I am doing is correct, but not quite sure how this can be done.</p> <p>I have this dict under:</p> <pre><code>k = {'Boston': [{'name': 'Jayson Tatum','rebounds': 8.0, 'assists': 4.4, 'points': 26.9}, {'name': 'Jaylen Brown','rebounds': 6.1, 'assists': 3.5, 'points': 23.6}, {'name': 'Marcus Smart', 'rebounds': 3.8, 'assists': 5.9, 'points': 12.1}], 'Phoenix': [{'name': 'Devin Booker', 'rebounds': 5.0, 'assists': 4.8, 'points': 26.8}, {'name': 'Deandre Ayton', 'rebounds': 10.2, 'assists': 1.4, 'points': 17.2}, {'name': 'Chris Paul', 'rebounds': 4.4, 'assists': 0.0, 'points': 14.7}], 'Philadelphia': [{'name': 'Tyrese Maxey', 'rebounds': 3.2, 'assists': 4.3, 'points': 17.5}, {'name': 'Tobias Harris', 'rebounds': 6.8, 'assists': 3.5, 'points': 17.2}, {'name': 'Georges Niang','rebounds': 2.7, 'assists': 1.3, 'points': 9.2}], 'Milwaukee': [{'name': 'Giannis Antetokounmpo', 'rebounds': 11.6, 'assists': 5.8, 'points': 29.9}, {'name': 'Khris Middleton','rebounds': 5.4, 'assists': 5.4, 'points': 20.1}, {'name': 'Jrue Holiday','rebounds': 4.5, 'assists': 6.8, 'points': 18.3}], 'Golden State': [{'name': 'Stephen Curry', 'rebounds': 5.2, 'assists': 6.3, 'points': 25.5}, {'name': 'Klay Thompson', 'rebounds': 3.9, 'assists': 2.8, 'points': 20.4}, {'name': 'Jordan Poole', 'rebounds': 3.4, 'assists': 4.0, 'points': 18.5}], 'Miami': [{'name': 'Jimmy Butler', 'rebounds': 5.9, 'assists': 5.5, 'points': 21.4}, {'name': 'Tyler Herro', 'rebounds': 5.0, 'assists': 4.0, 'points': 20.7}, {'name': 'Bam Adebayo', 'rebounds': 10.1, 'assists': 3.4, 'points': 19.1}], 'Dallas': [{'name': 'Luka Dončić''rebounds': 9.1, 'assists': 8.7, 'points': 28.4}, {'name': 'Jalen Brunson', rebounds': 3.9, 'assists': 4.8, 'points': 16.3}, {'name': 'Tim Hardaway Jr.', 'rebounds': 3.7, 'assists': 2.2, 'points': 14.2}], 'Memphis': [{'name': 'Ja Morant', 'rebounds': 5.7, 'assists': 6.7, 'points': 27.4}, {'name': 'Dillon Brooks','rebounds': 3.2, 'assists': 2.8, 'points': 18.4}, {'name': 'Desmond Bane', 'rebounds': 4.4, 'assists': 2.7, 'points': 18.2}]} </code></pre> <p>This dict has a team as a key, and a list as a value, this list holds three dicts, one for each player.</p> <p>What I am wondering is how to plot this, I want to choice between printing rebound, assists or points, how can i specify which one to plot?</p> <p>I tried to turn k into a dataframe, but the rows still are a list of dicts, which i dont know how to acces for ploting.</p> <p>I also tried something like this:</p> <pre><code>for team in k: players = top_players_in_teams[team] names = list(players.keys()) values = [value[wantedType] for value in list(players.values())] team_bars = ax.bar(names, values, label=team, zorder=3) team_bars.set_label(team) ax.set_title(&quot;SOMETHING&quot;) ax.legend(title=&quot;TeaM&quot;, bbox_to_anchor=(1.05, 1)) plt.grid(b=True, which=&quot;major&quot;, axis=&quot;y&quot;, zorder=0) plt.xticks(rotation=90) </code></pre>
[ { "answer_id": 74267925, "author": "user19077881", "author_id": 19077881, "author_profile": "https://Stackoverflow.com/users/19077881", "pm_score": 2, "selected": true, "text": "import pandas as pd\nimport matplotlib.pyplot as plt\n\nmydict = {}\n\ni = 0\nfor team in k:\n for player i...
2022/10/31
[ "https://Stackoverflow.com/questions/74267685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15970133/" ]
74,267,700
<p>I have a resource, as an example a '<strong>book</strong>'.</p> <p>I want to create a REST POST endpoint to allow consumers to create a new book.</p> <p>However, some of the properties are <strong>required</strong> and <strong>computed</strong> by API, and others were actually taken as they are</p> <pre><code>Book { name, color, author # computed } </code></pre> <p>Let's say the <strong>author</strong> is somehow calculated in API based on the book name.</p> <p>I can think of these solutions each has its drawbacks:</p> <ul> <li>enforce consumer to provide the author and just filter it (do not take into account as an input) # bad because it is very unpredictable why the author was changed</li> <li>allow the user to provide author # same problem</li> <li>do not allow the user to provide an author and show an exception if the user provides it</li> </ul> <p>The last solution seems to be the most obvious one. The main problem I can see is that it is inconsistent and can be bizarre for consumers to see the author later on GET request.</p> <p>I want my POST endpoint to be as expressive as possible. So the POST and GET data transfer objects will look almost the same.</p> <p>Are there any simple, expressive, and predictable patterns to consider?</p>
[ { "answer_id": 74270459, "author": "Evert", "author_id": 80911, "author_profile": "https://Stackoverflow.com/users/80911", "pm_score": 1, "selected": false, "text": "GET" }, { "answer_id": 74280136, "author": "inf3rno", "author_id": 607033, "author_profile": "https://...
2022/10/31
[ "https://Stackoverflow.com/questions/74267700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7642122/" ]
74,267,730
<p>I want to implement list of radiobuttons, but radiobutton shouldn't have a circle and if radiobutton is checked, then the background color is different from the others. Like in this photo. <a href="https://i.stack.imgur.com/LsOeE.png" rel="nofollow noreferrer">(https://i.stack.imgur.com/LsOeE.png)</a></p> <p>I think I can use radiobuttons or tabs, but i don't know how to change the styles of this things. Tell me a widget with similar logic or how to change the style of radiobuttons/tabs.</p>
[ { "answer_id": 74270459, "author": "Evert", "author_id": 80911, "author_profile": "https://Stackoverflow.com/users/80911", "pm_score": 1, "selected": false, "text": "GET" }, { "answer_id": 74280136, "author": "inf3rno", "author_id": 607033, "author_profile": "https://...
2022/10/31
[ "https://Stackoverflow.com/questions/74267730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20367319/" ]
74,267,736
<p>I was traying to write a code that calculate the sum of 2*j+i+1 where 0&lt;=j&lt;=i&lt;=n but I wasn't very optimazed there are my code :</p> <pre><code>def get_sum(n): s=0 for j in range(n+1): ss=0 ss=sum(2*j+i+1 for i in range(j,n+1)) s+=ss return s </code></pre> <p>Write to calculate a a sum of 2*j+i+1 where 0&lt;=j&lt;=i&lt;=n but it wasn't optimazed</p>
[ { "answer_id": 74267895, "author": "Z Li", "author_id": 14751619, "author_profile": "https://Stackoverflow.com/users/14751619", "pm_score": 2, "selected": false, "text": "def get_sum2(n):\n return (4*n*n*n + 15*n*n + 17*n + 6)/6\n" }, { "answer_id": 74268413, "author": "Al...
2022/10/31
[ "https://Stackoverflow.com/questions/74267736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20371693/" ]
74,267,746
<p>I have an ingress (nginx) that proxies to an application exposing 8443 (SSL) with a self-signed certificate. It works all fine in http but in https I get the following error:</p> <pre><code>2022/10/31 18:04:28 [error] 39#39: *1855 SSL_do_handshake() failed (SSL: error:1409442E:SSL routines:ssl3_read_bytes:tlsv1 alert protocol version:SSL alert number 70) while SSL handshaking to upstream, client: 127.0.0.1, server: _, request: &quot;GET /web-service/ HTTP/2.0&quot;, upstream: &quot;https://10.2.1.37:8443/web-service/&quot;, host: &quot;localhost:8443&quot; </code></pre> <p>After a little bit of research I established that my web-service is only supporting:</p> <pre><code>&quot;TLSv1.3&quot; and &quot;TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:TLS_AES_128_CCM_SHA256:TLS_AE&quot; </code></pre> <p>I curled in and indeed if I use anything else than explicitly TLSv1.3 I get a similar error. I also force the web service to downgrade to TLSv1.2 and it works but obviously that's not great.</p> <p>Is there a way to configure the ingress nginx backend configuration to only use TLSv1.3 and these protocols in the ingress itself.</p> <p>Something like <code>ssl_protocols TLSv1.3;</code> but as an annotation at the backend level? I tried a snippet but it does not seem to be applied at the right level.</p> <p>Here is my current code:</p> <pre><code>apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: hello-world-ingress2 annotations: nginx.ingress.kubernetes.io/ssl-redirect: &quot;false&quot; nginx.ingress.kubernetes.io/backend-protocol: &quot;HTTPS&quot; nginx.ingress.kubernetes.io/secure-backends: &quot;true&quot; nginx.ingress.kubernetes.io/use-regex: &quot;true&quot; nginx.ingress.kubernetes.io/auth-tls-verify-client: &quot;off&quot; nginx.ingress.kubernetes.io/rewrite-target: /web-service/$1 spec: ingressClassName: nginx rules: - http: paths: - path: /web-service/(.*) pathType: Prefix backend: service: name: my-web-service port: number: 8443 </code></pre>
[ { "answer_id": 74267895, "author": "Z Li", "author_id": 14751619, "author_profile": "https://Stackoverflow.com/users/14751619", "pm_score": 2, "selected": false, "text": "def get_sum2(n):\n return (4*n*n*n + 15*n*n + 17*n + 6)/6\n" }, { "answer_id": 74268413, "author": "Al...
2022/10/31
[ "https://Stackoverflow.com/questions/74267746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11251733/" ]
74,267,755
<p>At the moment, I have a component which completes some backend calls to decide when to start displaying the UI.</p> <p>It's structured like this:</p> <pre><code>useEffect(() =&gt; { getData() }) const getData = async () =&gt; { await verifyUser() await fetchData() } </code></pre> <p>The purpose here, is that verifyUser() is supposed to run first, and in the response to verifyUser(), a user id is provided by the backend.</p> <pre><code>const verifyUser = async () =&gt; { if (!localStorage.getItem('auth')) { return } if (localStorage.getItem('auth')) { await axios.post(&quot;/api/checkAuth&quot;, { token: JSON.parse(localStorage.getItem('auth')) }) .then((response) =&gt; { return setUserId(response.data.user_id) }) .catch((err) =&gt; { console.log(err) localStorage.removeItem('auth') }) } } </code></pre> <p>As a result of this, the fetchData() function is supposed to wait until the verifyUser() function has stopped resolving, so it can use the user id in the database query.</p> <p>However, at the moment it...</p> <ul> <li>Calls once, without the user id</li> <li>Then calls again, with the user id (and therefore resolves successfully)</li> </ul> <p>Here's the function for reference:</p> <pre><code>const fetchData = async () =&gt; { console.log(&quot;Fetch data called.&quot;) console.log(userId) await axios.post(&quot;/api/fetch/fetchDetails&quot;, { user_id: userId }) .then((response) =&gt; { // Sets user details in here... return response }) .then(() =&gt; { return setFetching(false) }) .catch((err) =&gt; { console.log(err) }) } </code></pre> <p>What I'm trying to achieve here is to essentially remove any concurrency and just run the functions sequentially. I'm not 100% sure what the best practice here would be, so some feedback would be appreciated!</p>
[ { "answer_id": 74267895, "author": "Z Li", "author_id": 14751619, "author_profile": "https://Stackoverflow.com/users/14751619", "pm_score": 2, "selected": false, "text": "def get_sum2(n):\n return (4*n*n*n + 15*n*n + 17*n + 6)/6\n" }, { "answer_id": 74268413, "author": "Al...
2022/10/31
[ "https://Stackoverflow.com/questions/74267755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12640056/" ]
74,267,774
<p>In my Jetpack compose project, I have a field that can contain different types of serializable data.</p> <pre><code>val httpBody : Serializable? get() = when(this) { is InitiatePayment -&gt; this.pendingTransaction //data class annotated with @Serializable is VerifyPaymentConfirmation -&gt; this.transactionId //Normal String is ValidateCart -&gt; this.cartItems //Another data class with @Serializable else -&gt; null } </code></pre> <p><strong>Any?</strong> Type works. But when using <strong>Serializable?</strong>,</p> <p>Gives the error,</p> <pre><code>Type mismatch. Required: Serializable? Found: PendingTransactionDTO </code></pre> <p>In Swift, I could just do</p> <pre><code>var httpBody : Codable? { switch self { case .initiatePayment(let pendingTransaction): return pendingTransaction //Codable struct case .verifyStoreCode(let storeCode): return storeCode //String case .verifyPaymentConfirmation(let transactionId): return transactionId //String default: return nil } } </code></pre> <p>In this case, httpBody property accepts everything that implements the Codable interface/protocol.</p> <p>In short, how to get the property type to accept any class/data class/object that is annotated with @Serializable, plus primitives like String and Int, which I suppose are by default, serializable in Kotlin.</p> <p>Any tips? Or is it even possible to do this in Kotlin?</p>
[ { "answer_id": 74267895, "author": "Z Li", "author_id": 14751619, "author_profile": "https://Stackoverflow.com/users/14751619", "pm_score": 2, "selected": false, "text": "def get_sum2(n):\n return (4*n*n*n + 15*n*n + 17*n + 6)/6\n" }, { "answer_id": 74268413, "author": "Al...
2022/10/31
[ "https://Stackoverflow.com/questions/74267774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3520225/" ]
74,267,776
<p>I am learning Material UI ( ver.5.10.10 ) for the first time. I want to customize the TextField of material UI. As I do not like the transition from focus off to focus on I would like the TextField styling to always show as if it were in focus (I don't want it to be in focus, just the same style as if it were).</p> <p>I'm searching in documentation &amp; google in general but I have no clue how I can achiev this.</p> <p>Images explaining:</p> <p><a href="https://i.stack.imgur.com/zXuXN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zXuXN.png" alt="MUI TextField" /></a></p> <p>(1) This is the default style of the TextField, without focus</p> <p><a href="https://i.stack.imgur.com/YILOW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YILOW.png" alt="MUI TextField Focused" /></a></p> <p>(2) This is the default style of the TextField when in focus</p> <p>I would like it to always look like in (2) , no matter if it's in focus or not</p> <p>I tried to find a property that allows changing this behavior but I didn't find anything, I guess it could be done with a customTheme? Or maybe there is a simpler way</p> <p>Thanks!</p>
[ { "answer_id": 74267895, "author": "Z Li", "author_id": 14751619, "author_profile": "https://Stackoverflow.com/users/14751619", "pm_score": 2, "selected": false, "text": "def get_sum2(n):\n return (4*n*n*n + 15*n*n + 17*n + 6)/6\n" }, { "answer_id": 74268413, "author": "Al...
2022/10/31
[ "https://Stackoverflow.com/questions/74267776", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15549038/" ]
74,267,778
<p>I was reading an <a href="https://blog.stephencleary.com/2012/02/async-and-await.html" rel="nofollow noreferrer">article</a> by @stephen-cleary around async/await. He mentioned below code</p> <pre><code>public async Task DoOperationsConcurrentlyAsync() { Task[] tasks = new Task[3]; tasks[0] = DoOperation0Async(); tasks[1] = DoOperation1Async(); tasks[2] = DoOperation2Async(); // At this point, all three tasks are running at the same time. // Now, we await them all. await Task.WhenAll(tasks); } </code></pre> <p>He mentions the tasks are already started when the methods are called (e.g DoOperation0Async()). In which thread does these methods gets run in? Do all methods that return a Task run in a different thread (or get queued up in the threadpool).</p> <p>OR do they all run synchronously? If they run synchronously, why use Task.WhenAll() ? Why not just await each method that returns a Task?</p> <pre><code>public async Task DoOperationsConcurrentlyAsync() { await DoOperation0Async(); await DoOperation1Async(); await DoOperation2Async(); } </code></pre>
[ { "answer_id": 74267895, "author": "Z Li", "author_id": 14751619, "author_profile": "https://Stackoverflow.com/users/14751619", "pm_score": 2, "selected": false, "text": "def get_sum2(n):\n return (4*n*n*n + 15*n*n + 17*n + 6)/6\n" }, { "answer_id": 74268413, "author": "Al...
2022/10/31
[ "https://Stackoverflow.com/questions/74267778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13096281/" ]
74,267,781
<p>I am taking a Java class and the teacher isn't being very helpful with my question. The assignment is to create a hand of cards using the following tester class:</p> <pre><code>public class Tester { public static void main(String[] args) { // No pair System.out.println(&quot;No pair&quot;); Hand noPair1 = new Hand(new Card(10, 3), new Card(3, 0), new Card(13, 2), new Card(5, 1), new Card(14, 3)); System.out.println(&quot;\n&quot;); } } </code></pre> <p>There is a Hand class and a Card class:</p> <pre><code>public class Hand { private ArrayList&lt;Card&gt; cards; public Hand() { cards = new ArrayList&lt;Card&gt;(); // initialize cards } } </code></pre> <p>Card Class:</p> <pre><code>public class Card { // instance variables private final int rank; // card rank private final int suit; // card suit public Card(int rankIn, int suitIn) { rank = rankIn; suit = suitIn; } </code></pre> <p>My question: How do I get the Hand class to call the Card class from within the Hand class? The error is occurring on the line Hand noPair1 = new Hand(new Card(10,3), ...);</p> <p>I am not allowed to change the Tester class.</p> <p>Tried compiling and running the Tester class.</p>
[ { "answer_id": 74267868, "author": "Louis Wasserman", "author_id": 869736, "author_profile": "https://Stackoverflow.com/users/869736", "pm_score": 0, "selected": false, "text": " public Hand()\n {\n cards = new ArrayList<Card>(); // initialize cards\n }\n" }, { "a...
2022/10/31
[ "https://Stackoverflow.com/questions/74267781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14717361/" ]
74,267,796
<p>I have a large spreadsheet with a list of English phrases/words in one column and then another column where all of those are translated into another language using the <code>GOOGLETRANSLATE</code> function. One example of such a row:<a href="https://i.stack.imgur.com/rdeHE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rdeHE.png" alt="internal Google error" /></a></p> <p>The formula is <code>=GOOGLETRANSLATE(G786, &quot;en&quot;, &quot;nl&quot;)</code></p> <p>When I click on it a box appears saying &quot;Error&quot; and then beneath that</p> <blockquote> <p>&quot;Google Translate internal error.&quot;</p> </blockquote> <p>I am unsure what the issue is and how I can solve it. The strange thing is that if I change the formula to replace the cell number to a plain string like &quot;Hello&quot; and click enter it will properly translate it to Dutch, and actually if I re-insert the same formula shown in the picture with the cell number it actually translates it as expected.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>EN</th> <th>NL</th> </tr> </thead> <tbody> <tr> <td>Confirm before proceeding</td> <td>=GOOGLETRANSLATE(G777, &quot;en&quot;, &quot;nl&quot;)</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74267955, "author": "player0", "author_id": 5632629, "author_profile": "https://Stackoverflow.com/users/5632629", "pm_score": 1, "selected": false, "text": "=BYROW(G2:INDEX(G:G; MAX((G:G<>\"\")*ROW(G:G))); \n LAMBDA(x; GOOGLETRANSLATE(x; G1; H1))\n" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74267796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5900695/" ]
74,267,909
<p>I set up logging module wide like so:</p> <pre><code>def setup_logging(app): &quot;&quot;&quot; Set up logging so as to include RequestId and relevant logging info &quot;&quot;&quot; RequestID(app) handler = logging.StreamHandler() handler.setStream(sys.stdout) handler.propagate=False handler.setFormatter( logging.Formatter(&quot;[MHPM][%(module)s][%(funcName)s] %(levelname)s : %(request_id)s - %(message)s&quot;) ) handler.addFilter(RequestIDLogFilter()) # &lt;&lt; Add request id contextual filter logging.getLogger().addHandler(handler) logging.getLogger().setLevel(level=&quot;DEBUG&quot;) </code></pre> <p>and I use it so:</p> <pre><code># in init.py setup_logging(app) </code></pre> <pre><code># in MHPMService.py logger = logging.getLogger(__name__) </code></pre> <p>But here's what I see on my console:</p> <pre><code>DEBUG:src.service.MHPMService:MHPMService.__init__(): initialized [MHPM][MHPMService][__init__] DEBUG : 5106ec8e-9ffa-423d-9401-c34a92dcfa23 - MHPMService.__init__(): initialized </code></pre> <p>I only want the second type of logs in my application, how do I do this?</p>
[ { "answer_id": 74267955, "author": "player0", "author_id": 5632629, "author_profile": "https://Stackoverflow.com/users/5632629", "pm_score": 1, "selected": false, "text": "=BYROW(G2:INDEX(G:G; MAX((G:G<>\"\")*ROW(G:G))); \n LAMBDA(x; GOOGLETRANSLATE(x; G1; H1))\n" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74267909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1474572/" ]
74,267,934
<p>I want to apply the functions from one class to the private variables from another derived class. I was hoping that this way I could avoid redefining the exact same function multiple times.</p> <p>I've added an example below.</p> <pre><code>#include &lt;iostream&gt; class A { public: void print1(); void print2(); private: int array[3] = {1, 2, 3}; }; class B: public A { public: void print3(); private: int array[3] = {4, 5, 6}; }; void A::print1() { std::cout &lt;&lt; this-&gt;array[0] &lt;&lt; std::endl; } void A::print2() { std::cout &lt;&lt; this-&gt;array[1] &lt;&lt; std::endl; } void B::print3() { print1(); print2(); std::cout &lt;&lt; this-&gt;array[2] &lt;&lt; std::endl; } int main() { B b; b.print3(); // Output = 1 2 6, I want = 4 5 6 return 0; } </code></pre> <p>I thought that perhaps defining the <em>array</em> in class <em>A</em> and <em>B</em> as public, so it would get overwritten, would work, but this did not have any effect.</p>
[ { "answer_id": 74268101, "author": "MarkB", "author_id": 17841694, "author_profile": "https://Stackoverflow.com/users/17841694", "pm_score": 0, "selected": false, "text": "print1" }, { "answer_id": 74268179, "author": "Alejandro Montilla", "author_id": 6780663, "autho...
2022/10/31
[ "https://Stackoverflow.com/questions/74267934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6908550/" ]
74,267,936
<p>im using the clarifai face recognition Api and getting an error on my console saying: &quot;TypeError: axios.post is not a function&quot;. anyone knows how do I solve it?</p> <ul> <li>i dont use Axios in my code, but i think the API uses it. thanks<img src="https://i.stack.imgur.com/i90al.jpg" alt="the Error on the console" /></li> </ul> <p>I tried installing Axios and clarifai again and it did nothing</p>
[ { "answer_id": 74268101, "author": "MarkB", "author_id": 17841694, "author_profile": "https://Stackoverflow.com/users/17841694", "pm_score": 0, "selected": false, "text": "print1" }, { "answer_id": 74268179, "author": "Alejandro Montilla", "author_id": 6780663, "autho...
2022/10/31
[ "https://Stackoverflow.com/questions/74267936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20381999/" ]
74,267,962
<p>I'm trying to create a script in order to run multiple <code>kubectl exec</code> commands against multiple pods with multiple containers. The script seems to generate the command just fine but errors out when attempting to run it.</p> <p>example command that is generated: <code>kubectl -n &lt;namespace&gt; exec &lt;pod_name&gt; -c &lt;container_name&gt; -- openssl version</code></p> <p>When I copy the generated command and run it directly it works fine, but if I try to run the command within the script I get an error.</p> <pre><code>OCI runtime exec failed: exec failed: unable to start container process: exec: &quot;openssl version&quot;: executable file not found in $PATH: unknown </code></pre> <p>command terminated with exit code 126</p> <p>snippet from .sh file:</p> <pre><code>for pod in $PODS; do CONTAINERS=($(kubectl -n $NAMESPACE get pods $pod -o jsonpath='{.spec.containers[*].name}' | tr -s '[[:space:]]' '\n')) header &quot;{pod: \&quot;$pod\&quot;, containers: \&quot;$(echo $CONTAINERS | tr -d '\n')\&quot;}&quot; if [ &quot;$DRYRUN&quot; != &quot;true&quot; ]; then for container in $CONTAINERS; do echo &quot;COMMAND BEING RUN: \&quot;kubectl -n $NAMESPACE exec $pod -c $container -- $COMMAND\&quot;&quot; kubectl -n $NAMESPACE exec $pod -c $container -- $COMMAND done fi done </code></pre>
[ { "answer_id": 74268651, "author": "Shivam Nagar", "author_id": 1909506, "author_profile": "https://Stackoverflow.com/users/1909506", "pm_score": 2, "selected": false, "text": "exec" }, { "answer_id": 74287833, "author": "Othyn", "author_id": 4494375, "author_profile"...
2022/10/31
[ "https://Stackoverflow.com/questions/74267962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10122521/" ]
74,267,964
<p>I am trying to make this code work on Visual Studio 2022, but it tells me that after the second <code>void printArray(int theArray\[\], int sizeOfArray)</code> it expected a <code>;</code>. I am doing this code based on <a href="https://youtu.be/VnZbghMhfOY" rel="nofollow noreferrer">https://youtu.be/VnZbghMhfOY</a>. How can I fix this?</p> <p>Here is the code I have:</p> <pre><code>#include &lt;iostream&gt; using namespace std; void printArray(int theArray[], int sizeOfArray); int main() { int bucky[3] = {20, 54, 675}; int jessica[6] = {54, 24, 7, 8, 9, 99}; printArray(bucky, 3); void printArray(int theArray[], int sizeOfArray) { for (int x = 0; x &lt; sizeOfArray; x++){ cout &lt;&lt; theArray[x] &lt;&lt; endl; } } } </code></pre> <p>I tried to change the code order but that only made it worse, the error saying <code>;</code> is apparently useless and the whole thing breaks apart if I put it there.</p>
[ { "answer_id": 74267990, "author": "Jeffrey", "author_id": 4474230, "author_profile": "https://Stackoverflow.com/users/4474230", "pm_score": 1, "selected": false, "text": "#include <iostream>\nusing namespace std;\n\nvoid printArray(int theArray[], int sizeOfArray);\n\nint main()\n{\n\n ...
2022/10/31
[ "https://Stackoverflow.com/questions/74267964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20381934/" ]
74,267,975
<p>This is my QUERY in SQLite. Currently following the Google Data Analytics Certificate.</p> <pre><code>SELECT Warehouse.warehouse_id, Warehouse.state || ': ' || Warehouse.warehouse_alias AS warehouse_name, COUNT(Orders.order_id) AS number_of_orders, (SELECT COUNT(*) FROM Warehouse_Orders Orders) AS total_orders, CASE WHEN COUNT(Orders.order_id)/(SELECT COUNT(*) FROM Warehouse_Orders Orders) &lt;= 0.20 THEN 'Fulfilled 0-20% of Orders' WHEN COUNT(Orders.order_id)/(SELECT COUNT(*) FROM Warehouse_Orders Orders) &gt; 0.20 AND COUNT(Orders.order_id)/(SELECT COUNT(*) FROM Warehouse_Orders Orders) &lt;= 0.60 THEN 'Fulfilled 21-60% of Orders' ELSE 'Fulfilled more than 60% of Orders' END AS fulfillment_summary FROM Warehouse_Stats Warehouse LEFT JOIN Warehouse_Orders Orders ON Warehouse.warehouse_id = Orders.warehouse_id GROUP BY Warehouse.warehouse_id, warehouse_name HAVING COUNT(Orders.order_id) &gt;1 </code></pre> <p>I realise it is a problem with my CASE</p> <ul> <li>The Orders.order_id is fine as the COUNT returns the number of orders per warehouse. -Yet the total is not working &quot;SELECT COUNT(*) FROM Warehouse_Orders Orders&quot;</li> </ul> <p>How do I find the total?</p> <p>I've tried, to take my SQL query apart and try different methods but I'm struggling to return the total.</p>
[ { "answer_id": 74267990, "author": "Jeffrey", "author_id": 4474230, "author_profile": "https://Stackoverflow.com/users/4474230", "pm_score": 1, "selected": false, "text": "#include <iostream>\nusing namespace std;\n\nvoid printArray(int theArray[], int sizeOfArray);\n\nint main()\n{\n\n ...
2022/10/31
[ "https://Stackoverflow.com/questions/74267975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20380170/" ]
74,267,978
<p>so I was working on creating the raw function of concatenating a string in c. One solution that was provided to me was :</p> <pre><code>char *_strcat(char *dest, char *src) { int c, c2; c = 0; while (dest[c]) c++; for (c2 = 0; src[c2] ; c2++) dest[c++] = src[c2]; return (dest); } </code></pre> <p>The part that confuses me is <code>while (dest[c])</code>, and other similar parts. I've already gone through pointers through various resources but I can't seem to understand this part. A good explanation will be much appreciated.</p>
[ { "answer_id": 74268032, "author": "Abdul Niyas P M", "author_id": 6699447, "author_profile": "https://Stackoverflow.com/users/6699447", "pm_score": 1, "selected": false, "text": "char *dest" }, { "answer_id": 74268060, "author": "Vlad from Moscow", "author_id": 2877241, ...
2022/10/31
[ "https://Stackoverflow.com/questions/74267978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14085645/" ]
74,267,980
<pre class="lang-py prettyprint-override"><code>seq = 'TGCCTTGGGCACCATGCAGTACCAAACGGAACGATAGTG' for nucleotide in seq: if nucleotide == 'A': a_nt = seq.count('A') elif nucleotide == 'G': g_nt = seq.count('G') elif nucleotide == 'C': c_nt = seq.count('C') elif nucleotide == 'T': t_nt = seq.count('T') elif nucleotide == 'N': n_nt = seq.count('N') else: sys.exit(&quot;Did not code&quot;) print(a_nt, g_nt, c_nt, t_nt, n_nt) </code></pre> <p>Error:</p> <pre class="lang-py prettyprint-override"><code>NameError: name 'n_nt' is not defined. Did you mean: 'a_nt'? </code></pre> <p>If the nucleotide is not in 'AGCTN', <code>sys.exit(&quot;no this code&quot;)</code>. Even counts of N is zero, it should be printed out.</p> <p>If I print out a, g, c, and t, it works well. But <code>n_nt</code> is not working.</p>
[ { "answer_id": 74268032, "author": "Abdul Niyas P M", "author_id": 6699447, "author_profile": "https://Stackoverflow.com/users/6699447", "pm_score": 1, "selected": false, "text": "char *dest" }, { "answer_id": 74268060, "author": "Vlad from Moscow", "author_id": 2877241, ...
2022/10/31
[ "https://Stackoverflow.com/questions/74267980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20381971/" ]
74,268,004
<p>I have the below code on my current component. The requirement is when a user enters the negative number it should convert to positive number and surrounded with braces. For example if a user enters -200 it should be converted to (200).</p> <p>The current code is adding the brackets '(' when entered negative number but the negative symbol is not being removed.</p> <p>I need help with how to remove the negative '-' symbol</p> <pre><code>const Format: React.FC&lt;Props&gt; = ({ includePrefix, ...otherProps }) =&gt; { const prefix: string | undefined = includePrefix === true || includePrefix === undefined ? '$' : undefined; return ( &lt;NumberFormat autoComplete=&quot;off&quot; thousandSeparator isNumericString prefix={Number(otherProps.value) &lt; 0 ? `(${prefix || ''}` : prefix} suffix={Number(otherProps.value) &lt; 0 ? ')' : ''} allowNegative {...otherProps} /&gt; ); }; /// &lt;reference types=&quot;react&quot; /&gt; //exclude types from the InputHTMLAttributes declare const {defaultValue, value, ...inputAttributes}: React.InputHTMLAttributes&lt;HTMLInputElement&gt;; type InputAttributes = typeof inputAttributes; declare module &quot;react-number-format&quot; { export interface NumberFormatState { value?: string; numAsString?: string; } export interface NumberFormatValues { floatValue: number; formattedValue: string; value: string; } export type FormatInputValueFunction = (inputValue: string) =&gt; string; export interface SyntheticInputEvent extends React.SyntheticEvent&lt;HTMLInputElement&gt; { readonly target: HTMLInputElement; data: any; } export interface NumberFormatProps extends InputAttributes { thousandSeparator?: boolean | string; decimalSeparator?: boolean | string; thousandsGroupStyle?: 'thousand' | 'lakh' | 'wan'; decimalScale?: number; fixedDecimalScale?: boolean; displayType?: 'input' | 'text'; prefix?: string; suffix?: string; format?: string | FormatInputValueFunction; removeFormatting?: (formattedValue: string) =&gt; string; mask?: string | string[]; value?: number | string; defaultValue?: number | string; isNumericString?: boolean; customInput?: React.ComponentType&lt;any&gt;; allowNegative?: boolean; allowEmptyFormatting?: boolean; onValueChange?: (values: NumberFormatValues) =&gt; void; /** * these are already included in React.HTMLAttributes&lt;HTMLInputElement&gt; * onKeyDown: Function; * onMouseUp: Function; * onChange: Function; * onFocus: Function; * onBlur: Function; */ type?: 'text' | 'tel' | 'password'; isAllowed?: (values: NumberFormatValues) =&gt; boolean; renderText?: (formattedValue: string) =&gt; React.ReactNode; getInputRef?: ((el: HTMLInputElement) =&gt; void) | React.Ref&lt;any&gt;; allowedDecimalSeparators?: Array&lt;string&gt;; [key: string]: any; } class NumberFormat extends React.Component&lt;NumberFormatProps, any&gt; {} export default NumberFormat; } </code></pre>
[ { "answer_id": 74268032, "author": "Abdul Niyas P M", "author_id": 6699447, "author_profile": "https://Stackoverflow.com/users/6699447", "pm_score": 1, "selected": false, "text": "char *dest" }, { "answer_id": 74268060, "author": "Vlad from Moscow", "author_id": 2877241, ...
2022/10/31
[ "https://Stackoverflow.com/questions/74268004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5889940/" ]
74,268,054
<p>I tried to make a stopwatch in the console, but the message kept on clearing before I had time to read it.<br /> I tried increasing how long the Timeout function would go, but for some reason, it didn't make a difference.<br /> Can somebody help me with making the messages not clear so fast?</p> <pre><code>setTimeout(function() { console.log(&quot;1&quot;); }, 1000); setTimeout(function() { console.clear() },1099); setTimeout(function() { console.log(&quot;2&quot;); }, 2000); setTimeout(function() { console.clear() }, 2099); setTimeout(function() { console.log(&quot;3&quot;); }, 3000); setTimeout(function() { console.clear() }, 3099); </code></pre>
[ { "answer_id": 74268112, "author": "guu876", "author_id": 20375093, "author_profile": "https://Stackoverflow.com/users/20375093", "pm_score": 1, "selected": false, "text": " let sec = 0;\n setInterval(function () {\n console.clear();\n console.log(sec)...
2022/10/31
[ "https://Stackoverflow.com/questions/74268054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20382068/" ]
74,268,058
<p>I have a javascript array defined as below:</p> <pre><code>var hexgon = ['M',r*Math.cos(0/180*Math.PI),r*Math.sin(0/180*Math.PI) ,r*Math.cos(30/180*Math.PI),r*Math.sin(30/180*Math.PI) ,r*Math.cos(90/180*Math.PI),r*Math.sin(90/180*Math.PI) ,r*Math.cos(150/180*Math.PI),r*Math.sin(150/180*Math.PI) ,r*Math.cos(210/180*Math.PI),r*Math.sin(210/180*Math.PI) ,r*Math.cos(270/180*Math.PI),r*Math.sin(270/180*Math.PI), ,r*Math.cos(330/180*Math.PI),r*Math.sin(330/180*Math.PI),'Z'] </code></pre> <p>How to use a loop to simplify this logic?</p>
[ { "answer_id": 74268112, "author": "guu876", "author_id": 20375093, "author_profile": "https://Stackoverflow.com/users/20375093", "pm_score": 1, "selected": false, "text": " let sec = 0;\n setInterval(function () {\n console.clear();\n console.log(sec)...
2022/10/31
[ "https://Stackoverflow.com/questions/74268058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1914781/" ]
74,268,093
<p>I am creating a social network in Java for my final paper and i need to list all the mutual followers of a user in a table through the listMutualFollowers() function.</p> <p>I tried this:</p> <pre><code>public ArrayList listMutualFollowers(int id_user) { try { ArrayList data = new ArrayList(); PreparedStatement ps = connection.prepareStatement(&quot;SELECT id_follower FROM followers WHERE id_user = &quot; + id_user); ResultSet rs = ps.executeQuery(); while (rs.next()) { PreparedStatement ps2 = connection.prepareStatement(&quot;SELECT * FROM followers WHERE id_user = &quot; + rs.getInt(&quot;id_follower&quot;)); ResultSet rs2 = ps2.executeQuery(); while (rs2.next()) { data.add(new Object[]{ getFollowerName(rs2.getInt(&quot;id_follower&quot;)) }); } ps2.close(); rs2.close(); } ps.close(); rs.close(); connection.close(); return data; } catch (SQLException e) { e.getMessage(); JOptionPane.showMessageDialog(null, &quot;listMutualFollowers():&quot; + e.getMessage()); return null; } } </code></pre> <p>I was expecting this function to return the name of a user's mutual followers, but it returned a list with the user's own name on every line of the ArrayList. (Yes, I noticed my big logic error in the second PreparedStatement)</p>
[ { "answer_id": 74268112, "author": "guu876", "author_id": 20375093, "author_profile": "https://Stackoverflow.com/users/20375093", "pm_score": 1, "selected": false, "text": " let sec = 0;\n setInterval(function () {\n console.clear();\n console.log(sec)...
2022/10/31
[ "https://Stackoverflow.com/questions/74268093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18402907/" ]
74,268,108
<p>I need to create a function that takes string and decoding rules. It is supposed to change characters in string until there is nothing possible to change according to decoding rules. Each time I get string and decoding rules (first is what change, second is to what).</p> <p>I'm quite lost, I tried to create all possible combinations and then generate list based on rules. Here's my try.</p> <pre><code>rules = [('E',&quot;GZ&quot;),('F',&quot;HK&quot;),('C',&quot;EF&quot;),('J',&quot;CC&quot;)] string = &quot;JCEJ&quot; combinations = [(x,y,z) | x &lt;- [ch | ch &lt;- string], y &lt;- [x | (x,y) &lt;- rules], z &lt;- [y | (x,y) &lt;- rules]] generate = [z | (x,y,z) &lt;- combinations, if x == y then z else x] </code></pre> <p>Error message:</p> <pre class="lang-none prettyprint-override"><code>decoder.hs:8:57: error: • Couldn't match expected type ‘Bool’ with actual type ‘[Char]’ • In the expression: z In the expression: if x == y then z else x In a stmt of a list comprehension: if x == y then z else x | 8 | generate = [z | (x,y,z) &lt;- combinations, if x == y then z else x] | ^ decoder.hs:8:64: error: • Couldn't match expected type ‘Bool’ with actual type ‘Char’ • In the expression: x In the expression: if x == y then z else x In a stmt of a list comprehension: if x == y then z else x | 8 | generate = [z | (x,y,z) &lt;- combinations, if x == y then z else x] | ^ </code></pre>
[ { "answer_id": 74268167, "author": "Willem Van Onsem", "author_id": 67579, "author_profile": "https://Stackoverflow.com/users/67579", "pm_score": 1, "selected": false, "text": "String" }, { "answer_id": 74268533, "author": "Chris", "author_id": 15261315, "author_profi...
2022/10/31
[ "https://Stackoverflow.com/questions/74268108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20357532/" ]
74,268,115
<p>I am currently learning C programming (my experience is in Python, Java and Swift). I am trying to count how many numbers are on the first line of a text file.</p> <p>The text file looks a bit like this:</p> <pre><code>-54 37 64 82 -98 ... </code></pre> <p>I have tried various different ideas that I have had. The first was to check each character in turn for the EOL, and if it wasn't to add 1 to the total. I quickly realised this only works for single digit numbers, and not general integers.</p> <p>I then tried to use <code>fscanf</code> to find the last number on the line, and then rewind and use fscanf to count each number until that last number was found again:</p> <pre><code>int temp; FILE *fd = fopen(&quot;test.txt&quot;, &quot;r&quot;); fscanf(fd, &quot;%d\n&quot;, &amp;temp); printf(&quot;Last Number on Line is: %d\n&quot;, temp); </code></pre> <p>However before I could even write the next logic to count the numbers I realised that this printed <code>Last Number on Line is: -54</code> which was not the expected output from the above file example.</p> <p>At this point I am rather stuck. Searching online mainly returns results on how to count how many lines are in a file due to the similarity of the question.</p> <p>Any help would be much appreciated!</p>
[ { "answer_id": 74268818, "author": "Vlad from Moscow", "author_id": 2877241, "author_profile": "https://Stackoverflow.com/users/2877241", "pm_score": -1, "selected": false, "text": "fgets" }, { "answer_id": 74269099, "author": "Harry Day", "author_id": 9682666, "autho...
2022/10/31
[ "https://Stackoverflow.com/questions/74268115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9682666/" ]
74,268,128
<p>I am trying to take the Plus icon for my accordion and toggle it to a Minus icon on click using Javascript and then back to Plus when clicked again. Can anyone assist?</p> <p>`</p> <pre><code>&lt;div class=&quot;faqs-container&quot;&gt; &lt;div class=&quot;faqs-question&quot;&gt; &lt;button&gt; &lt;h3&gt;Which services do you provide?&lt;/h3&gt; &lt;i class=&quot;bi bi-plus&quot;&gt;&lt;/i&gt; &lt;/button&gt; &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>`</p> <p>`</p> <pre><code>.faqs-container { max-width: 90%; margin: 0 auto; } .faqs-question { width: 100%; border: 2px solid #999; border-radius: 4px; margin-bottom: 25px; } .faqs-container:hover{ color: #999; } .faqs-question button{ width: 100%; background-color: white; display: flex; justify-content: space-between; align-items: center; padding: 20px 15px; border: none; outline: none; font-size: 24px; font-family: 'interstate', sans-serif; font-weight: 500; color: #300600; cursor: pointer; transition: 0.6s ease-in-out; } .faqs-question button h3{ font-size: 28px; font-family: 'interstate', sans-serif; font-weight: 500; transition: 0.2s ease-in-out; padding: 10px; } .faqs-question button h3:hover{ color: #999; transition: 0.2s ease-in-out; } .faqs-question i{ font-size: 48px; transition: 0.5s ease-in-out; } .faqs-question i:hover{ color: #999; transition: 0.2s ease-in-out; } .faqs-question p { margin-top: 10px; font-size: 24px; font-family: 'Merriweather-Sans', sans-serif; font-weight: 300; line-height: 55px; color: #444; max-height: 0; opacity: 0; overflow: hidden; transition: 0.6s ease; } .faqs-question p.show{ max-height: 45vh; opacity: 1; padding: 10px 0px 40px 15px; padding-right: 40px; padding-left: 20px; margin-bottom: 35px; } </code></pre> <p>`</p> <p>`</p> <pre><code>&lt;script&gt; const buttons = document.querySelectorAll('button'); buttons.forEach( button =&gt;{ button.addEventListener('click',()=&gt;{ const faq = button.nextElementSibling; faq.classList.toggle('show'); }) } ) &lt;/script&gt; </code></pre> <p>`</p> <p>I am not sure where to start. Although I figured out how to show the accordion answer onclick, I am not sure how to toggle the Minus icon..</p>
[ { "answer_id": 74268818, "author": "Vlad from Moscow", "author_id": 2877241, "author_profile": "https://Stackoverflow.com/users/2877241", "pm_score": -1, "selected": false, "text": "fgets" }, { "answer_id": 74269099, "author": "Harry Day", "author_id": 9682666, "autho...
2022/10/31
[ "https://Stackoverflow.com/questions/74268128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19991177/" ]
74,268,156
<p>I made a SystemVerilog testbbench for a simple D flip flop.</p> <p>Design code:</p> <pre><code> module dff (dff_if vif); always@(posedge vif.clk) begin if(vif.rst == 1'b1) vif.dout &lt;= 1'b0; else vif.dout &lt;= vif.din; end endmodule </code></pre> <p>In the testbench, the monitor class is forever going on even though simulation has reached $finished.</p> <p>Testbench code:</p> <pre><code> interface dff_if; logic clk; logic rst; logic din; logic dout; endinterface /////////////////////////////////////////////////////////////////////////tran class transaction; randc bit in; bit out; function transaction copy(); copy=new(); copy.in=this.in; copy.out=this.out; endfunction function void display(string tag); $display(&quot;[%s] datain:%d dataout=%d&quot;,tag,in,out); endfunction endclass /////////////////////////////////////////////////////////////////////////gen class generator; transaction t; mailbox gtd; mailbox gts; event drvnext; //delete after test event done; function new(mailbox gtd,mailbox gts); t=new(); this.gtd=gtd; this.gts=gts; endfunction task run(); repeat(10) begin $display(&quot;______________________________________________________________________&quot;); assert(t.randomize) else $error(&quot;[GEN] : RANDOMIZATION FAILED&quot;); gtd.put(t.copy()); gts.put(t.copy()); t.display(&quot;GEN&quot;); @(drvnext); end -&gt;done; $display(&quot;DONE&quot;); endtask endclass ///////////////////////////////////////////////////////////////////////////drv class driver; virtual dff_if vif; transaction t; mailbox gtd; //event drvnext; function new(mailbox gtd); t=new(); this.gtd=gtd; endfunction task run(); forever begin @(posedge vif.clk); @(posedge vif.clk); gtd.get(t); vif.din=t.in; t.display(&quot;DRV&quot;); end endtask endclass //////////////////////////////////////////////////////////////////////////mon class monitor; virtual dff_if vif; transaction tr; mailbox mts; event drvnext; function new(mailbox mts); tr=new(); this.mts=mts; endfunction task run(); forever begin @(posedge vif.clk); @(posedge vif.clk); tr.out=vif.dout; mts.put(tr); tr.display(&quot;MON&quot;); -&gt;drvnext; end endtask endclass ////////////////////////////////////////////////////////////////////////////////// module tb; generator g; driver drv; monitor mn; dff_if vif(); dff dut(vif); mailbox gtd; mailbox gts; mailbox mts; event drvnext; event done; initial begin gtd=new(); gts=new(); mts=new(); g=new(gtd,gts); drv=new(gtd); mn=new(mts); g.drvnext=drvnext; mn.drvnext=drvnext; g.done=done; drv.vif=vif; mn.vif=vif; fork g.run(); drv.run(); mn.run(); join_any @(done); $finish; end initial vif.clk=0; always #5 vif.clk=~vif.clk; endmodule </code></pre> <p>Simulation Output (of some last transactions):</p> <pre><code># KERNEL: [GEN] datain:0 dataout=0 # KERNEL: [DRV] datain:0 dataout=0 # KERNEL: [MON] datain:0 dataout=1 # KERNEL: _______________________________________________________________________________________ # KERNEL: [GEN] datain:1 dataout=0 # KERNEL: [DRV] datain:1 dataout=0 # KERNEL: [MON] datain:0 dataout=0 # KERNEL: _______________________________________________________________________________________ # KERNEL: [GEN] datain:0 dataout=0 # KERNEL: [DRV] datain:0 dataout=0 # KERNEL: [MON] datain:0 dataout=1 # KERNEL: DONE # KERNEL: [MON] datain:0 dataout=0 # KERNEL: [MON] datain:0 dataout=0 # KERNEL: [MON] datain:0 dataout=0 # KERNEL: [MON] datain:0 dataout=0 # KERNEL: [MON] datain:0 dataout=0 # KERNEL: [MON] datain:0 dataout=0 # KERNEL: [MON] datain:0 dataout=0 # KERNEL: [MON] datain:0 dataout=0 # KERNEL: [MON] datain:0 dataout=0 </code></pre> <p>Can anyone tell me what I am doing wrong here?</p>
[ { "answer_id": 74268818, "author": "Vlad from Moscow", "author_id": 2877241, "author_profile": "https://Stackoverflow.com/users/2877241", "pm_score": -1, "selected": false, "text": "fgets" }, { "answer_id": 74269099, "author": "Harry Day", "author_id": 9682666, "autho...
2022/10/31
[ "https://Stackoverflow.com/questions/74268156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17644047/" ]
74,268,199
<pre><code>Error: Cannot find module 'F:\vite\bin\vite.js' at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15) at Function.Module._load (node:internal/modules/cjs/loader:769:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12) at node:internal/main/run_main_module:17:47 { code: 'MODULE_NOT_FOUND', requireStack: [] } npm ERR! code 1 npm ERR! path F:\A. WEB DESIGN &amp; DEVELOPMENT\My Projects\SAIMUM\saimum npm ERR! command failed npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c vite npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\ataur\AppData\Local\npm-cache\_logs\2022-10-31T19_15_47_188Z-debug.log </code></pre> <p>npm install worked correctly, but npm run dev raise this errro. my project is new and the laravel version is Laravel v9.37.0 (PHP v8.1.10)</p>
[ { "answer_id": 74268818, "author": "Vlad from Moscow", "author_id": 2877241, "author_profile": "https://Stackoverflow.com/users/2877241", "pm_score": -1, "selected": false, "text": "fgets" }, { "answer_id": 74269099, "author": "Harry Day", "author_id": 9682666, "autho...
2022/10/31
[ "https://Stackoverflow.com/questions/74268199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19756987/" ]
74,268,238
<p>Given boolean matrix <em>M</em>, I need to find a set of submatrices <em>A = {A<sub>1</sub>, ..., A<sub>n</sub>}</em> such that matrices in <em>A</em> contain all True values in matrix <em>M</em> and only them. Submatrices don't have to be continuous, i.e. each submatrix is defined by the two sets of indices <em>{i<sub>1</sub>, ..., i<sub>k</sub>}</em>, <em>{j<sub>1</sub>, ..., j<sub>t</sub>}</em> of <em>M</em>. (For example submatrix could be something like [{1, 2, 5}, {4, 7, 9, 13}] and it is all cells in intersection of these rows and columns.) Optionally submatrices can intersect if this results in better solution. The total number of submatrices <em>n</em> should be minimal.</p> <p>Size of the matrix <em>M</em> can be up to 10^4 x 10^4, so I need an effective algorithm. I suppose that this problem may not have an effective exact algorithm, because it reminds me some NP-hard problems. If this is true, then any good and fast approximation is OK. We can also suggest that the amount of true values is not very big, i.e. &lt; 1/10 of all values, but to not have accidental DOS in prod, the solution not using this fact is better.</p> <p>I don't need any code, just a general idea of the algorithm and justification of its properties, if it's not obvious.</p> <p><strong>Background</strong></p> <p>We are calculating some expensive distance matrices for logistic applications. Points in these requests are often intersecting, so we are trying do develop some caching algorithm to not calculate parts of some requests. And to split big requests into smaller ones with only unknown submatrices. Additionally some distances in the matrix may be not needed for the algorithm. On the one hand the small amount of big groups calculates faster, on the other hand if we include a lot of &quot;False&quot; values, and our submatrices are unreasonably big, this can slow down the calculation. The exact criterion is intricate and the time complexity of &quot;expensive&quot; matrix requests is hard to estimate. As far as I know for square matrices it is something like C*n^2.5 with quite big C. So it's hard to formulate a good optimization criterion, but any ideas are welcome.</p> <p><strong>About data</strong></p> <p>True value in matrix means that the distance between these two points have never been calculated before. Most of the requests (but not all) are square matrices with the same points on both axes. So most of the M is expected to be almost symmetric. And also there is a simple case of several completely new points and the other distances are cached. I deal with this cases on preprocessing stage. All the other values can be quite random. If they are too random we can give up cache and calculate the full matrix M. But sometimes there are useful patterns. I think that because of the nature of the data it is expected to contain more big sumbatrices then random data. Mostly True values are occasional, but form submatrix patterns, that we need to find. But we cannot rely on this completely, because if algorithm gets too random matrix it should be able to at least detect it to not have too long and complex calculations.</p> <p><strong>Update</strong></p> <p>As stated in <a href="https://en.wikipedia.org/wiki/Bipartite_dimension" rel="nofollow noreferrer">wikipedia</a> this problem is called Bipartite Dimension of a graph and is known to be NP-hard. So we can reformulate it info finding fast relaxed approximations for the simple cases of the problem. We can allow some percentage of false values and we can adapt some simple, but mostly effective greedy heuristic.</p>
[ { "answer_id": 74268320, "author": "ravenspoint", "author_id": 16582, "author_profile": "https://Stackoverflow.com/users/16582", "pm_score": 0, "selected": false, "text": " t\n" }, { "answer_id": 74334186, "author": "petern0691", "author_id": 16015991, "author_profile...
2022/10/31
[ "https://Stackoverflow.com/questions/74268238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5558953/" ]
74,268,260
<p>This function calculates the length of a singly linked list recursively.</p> <p><code>tail</code> is an instance variable that points to the next object in the list.</p> <pre class="lang-java prettyprint-override"><code> public int length() { if (tail == null) { return 1; } return 1 + tail.length(); } </code></pre> <p>However it uses no parameters as shown. I'm struggling to understand the logic behind this code, could I get some help with understanding what's actually going on here?</p> <p>My first point of confusion is when the function reaches the last object in the list, that objects tail will be null, so why does the function not just end up returning 1?<br /> And secondly, what does <code>1 + tail.length()</code> actually do?</p> <p>The most I understand is that <code>1</code> and <code>tail.length()</code> can be added due to the <code>length</code> function having a return type of int.</p>
[ { "answer_id": 74268286, "author": "Lou Franco", "author_id": 3937, "author_profile": "https://Stackoverflow.com/users/3937", "pm_score": 1, "selected": false, "text": "this" }, { "answer_id": 74268288, "author": "Louis Wasserman", "author_id": 869736, "author_profile...
2022/10/31
[ "https://Stackoverflow.com/questions/74268260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17463100/" ]
74,268,272
<p>I have a deployed active react app through GitHub pages and I'm looking to update it with newer code, i.e. color changes, update text, etc. The code has already been pushed to my GitHub repo, on my main branch but it's not updating the live GitHub page. I'm obviously missing something but couldn't find anything reading documentation or other stackoverflow questions. Can anyone help? Also I've seen a lot of people posting their package.json so here's mine</p> <p>Edit: I already have the github pages live with prior code, but pushing the newer code to live is what I need help with.</p> <pre><code>{ &quot;name&quot;: &quot;react-portfolio&quot;, &quot;version&quot;: &quot;1.0.0&quot;, &quot;private&quot;: &quot;true&quot;, &quot;homepage&quot;: &quot;N/A&quot;, &quot;dependencies&quot;: { &quot;@testing-library/jest-dom&quot;: &quot;^5.16.2&quot;, &quot;@testing-library/react&quot;: &quot;^12.1.3&quot;, &quot;@testing-library/user-event&quot;: &quot;^13.5.0&quot;, &quot;react&quot;: &quot;^17.0.2&quot;, &quot;react-dom&quot;: &quot;^17.0.2&quot;, &quot;react-scripts&quot;: &quot;^5.0.0&quot;, &quot;web-vitals&quot;: &quot;^2.1.4&quot; }, &quot;scripts&quot;: { &quot;start&quot;: &quot;react-scripts start&quot;, &quot;build&quot;: &quot;react-scripts build&quot;, &quot;test&quot;: &quot;react-scripts test&quot;, &quot;eject&quot;: &quot;react-scripts eject&quot;, &quot;predeploy&quot;: &quot;npm run build&quot; }, &quot;eslintConfig&quot;: { &quot;extends&quot;: [ &quot;react-app&quot;, &quot;react-app/jest&quot; ] }, &quot;browserslist&quot;: { &quot;production&quot;: [ &quot;&gt;0.2%&quot;, &quot;not dead&quot;, &quot;not op_mini all&quot; ], &quot;development&quot;: [ &quot;last 1 chrome version&quot;, &quot;last 1 firefox version&quot;, &quot;last 1 safari version&quot; ] }, &quot;devDependencies&quot;: { &quot;gh-pages&quot;: &quot;^3.2.3&quot; } } </code></pre>
[ { "answer_id": 74268286, "author": "Lou Franco", "author_id": 3937, "author_profile": "https://Stackoverflow.com/users/3937", "pm_score": 1, "selected": false, "text": "this" }, { "answer_id": 74268288, "author": "Louis Wasserman", "author_id": 869736, "author_profile...
2022/10/31
[ "https://Stackoverflow.com/questions/74268272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16902324/" ]
74,268,278
<p>I need help in writing the Python code which would return the following output_string as mentioned below in the examples.</p> <p>Example 1:</p> <pre><code>input_string = &quot;AAABCCCCDDA&quot; output_string = &quot;3AB4C2DA&quot; </code></pre> <p>Example 2:</p> <pre><code>input_string = &quot;ABBBBCCDDDDAAAAA&quot; output_string = &quot;A4B2C4D5A&quot; </code></pre>
[ { "answer_id": 74268343, "author": "I'mahdi", "author_id": 1740577, "author_profile": "https://Stackoverflow.com/users/1740577", "pm_score": 1, "selected": false, "text": "itertools.groupby" }, { "answer_id": 74268891, "author": "SergFSM", "author_id": 18344512, "auth...
2022/10/31
[ "https://Stackoverflow.com/questions/74268278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3248423/" ]
74,268,289
<p>I have made it find the max and min value in the entire 2d array seen below but now I'm wanting to make it find the highest value in each row and don't really know how to go about it.</p> <pre><code>public class Main { public static void main ( String[] args ) { int[][] data = { {3, 2, 5}, {1, 4, 4, 8, 13}, {9, 1, 0, 2}, {0, 2, 6, 3, -1, -8} }; int max = data[0][0]; int min = data[0][0]; for ( int row=0; row &lt; data.length; row++) { for ( int col=0; col &lt; data[row].length; col++) { if (data[row][col] &gt; max){ max = data[row][col]; } if (data[row][col] &lt; min){ min = data[row][col]; } } } System.out.println( &quot;max = &quot; + max + &quot;; min = &quot; + min ); } } </code></pre> <p>I keep getting results like</p> <pre><code>2 5 4 4 8 1 3 1 1 2 2 6 6 6 6 </code></pre>
[ { "answer_id": 74268343, "author": "I'mahdi", "author_id": 1740577, "author_profile": "https://Stackoverflow.com/users/1740577", "pm_score": 1, "selected": false, "text": "itertools.groupby" }, { "answer_id": 74268891, "author": "SergFSM", "author_id": 18344512, "auth...
2022/10/31
[ "https://Stackoverflow.com/questions/74268289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17987869/" ]
74,268,311
<p>I intend to redirect this url:</p> <blockquote> <p><code>http://localhost/iiif/http/image-service/papyrus,1/full/400,300/0/default.jpg</code></p> </blockquote> <p>to</p> <blockquote> <p><code>http://localhost/iiif/http/image.php?req=763648&amp;id=papyrus,1&amp;region=full&amp;size=400,300&amp;rotation=0&amp;quality=default&amp;format=jpg</code></p> </blockquote> <p>I have written the rewrite rule as:</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; RewriteEngine on RewriteBase /iiif/http/ RewriteRule image-service/(.*)/(.*)/(.*)/(.*)/(.*).(.*)$ image.php?req=763648&amp;id=$1&amp;region=$2&amp;size=$3&amp;rotation=$4&amp;quality=$5&amp;format=$6 [R=301,NC,L,P] &lt;/IfModule&gt; </code></pre> <p>The result is:</p> <pre><code>Array ( [req] =&gt; 763648 [id] =&gt; papyrus,1 [region] =&gt; full [size] =&gt; 400,300 [rotation] =&gt; 0 [quality] =&gt; default.jp. ) </code></pre> <p>instead of:</p> <pre><code>Array ( [req] =&gt; 763648 [id] =&gt; papyrus,1 [region] =&gt; full [size] =&gt; 400,300 [rotation] =&gt; 0 [quality] =&gt; default [format] =&gt; jpg ) </code></pre> <p>I suspect that this is due to the presence of a period/dot(.) in the url. How can I correct it?</p>
[ { "answer_id": 74268346, "author": "JRiggles", "author_id": 8512262, "author_profile": "https://Stackoverflow.com/users/8512262", "pm_score": 2, "selected": true, "text": "/(.*)/(.*)/(.*)/(.*)/(.*)\\.(.*)\n" }, { "answer_id": 74268711, "author": "anubhava", "author_id": 5...
2022/10/31
[ "https://Stackoverflow.com/questions/74268311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2590824/" ]
74,268,322
<p>I have the following class in which I have an IEnumerable list as follows</p> <pre><code>public class Orders{ public string No {get;set;} public string Id {get;set;} public IEnumerable&lt;string&gt; OrderTypes{get;set;} = new List&lt;string&gt;{&quot;order 1&quot;,&quot;order 2&quot;,&quot;order 3&quot;} } </code></pre> <p>instead of me assigning the values directly above is there a way i can put it in a seperate class as follows</p> <pre><code>public class OrderTypes(){ IEnumerable&lt;string&gt; myEnumberable = new List&lt;string&gt;() myEnumberable.add(&quot;Order 1&quot;) myEnumberable.add(&quot;Order 3&quot;) myEnumberable.add(&quot;Order 4&quot;) myEnumberable.add(&quot;Order 5&quot;) myEnumberable.add(&quot;Order 6&quot;) } </code></pre> <p>and then call this function above like</p> <pre><code>public class Orders{ public string No {get;set;} public string Id {get;set;} public IEnumerable&lt;string&gt; OrderTypes{get;set;} = OrderTypes } </code></pre> <p>the reason for this is cause my list gets too long and it would be easier to view, but im not sure how to achieve this.</p>
[ { "answer_id": 74268440, "author": "merlinabarzda", "author_id": 10163557, "author_profile": "https://Stackoverflow.com/users/10163557", "pm_score": 1, "selected": false, "text": "Orders" }, { "answer_id": 74268442, "author": "knittl", "author_id": 112968, "author_pro...
2022/10/31
[ "https://Stackoverflow.com/questions/74268322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18786249/" ]
74,268,361
<p>So I'm trying to answer a leetcode question but I believe I'm stuck on something simple but I can't figure it out. The error that keeps popping up is &quot;name 'twoSum' is not defined&quot;. Can anyone tell me what I'm missing here? It's clearly defined as far as I can see?</p> <pre><code>class Solution: def twoSum(num: int, target: int) -&gt; int: for i in range(len(num) -1): for j in range(i, len(num)-1): if num[i] + num[j] == target: list = [i, j] return list def main(): num = [3,2,4] target = 6 r= twoSum(num, target) print(r) if __name__ == '__main__': main() </code></pre>
[ { "answer_id": 74268440, "author": "merlinabarzda", "author_id": 10163557, "author_profile": "https://Stackoverflow.com/users/10163557", "pm_score": 1, "selected": false, "text": "Orders" }, { "answer_id": 74268442, "author": "knittl", "author_id": 112968, "author_pro...
2022/10/31
[ "https://Stackoverflow.com/questions/74268361", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19568462/" ]
74,268,368
<p>I just want to add conditional styling into my input. my current input looks like a mess. basically when activeItem is &quot;Height&quot; i just want to show height value and change with setHeight</p> <pre class="lang-js prettyprint-override"><code>const [activeItem, setActiveItem] = useState('Length'); const [visible, setVisible] = useState(false); const [length, setLength] = useState(0); const [height, setHeight] = useState(0); const [width, setWidth] = useState(0); const [weight, setWeight] = useState(0); &lt;InputModal visible={visible} value={ activeItem === 'Length' ? length : activeItem === 'Height' ? height : activeItem === 'Width' ? width : activeItem === 'Weight' ? weight : '' } onTextChange={ activeItem === 'Length' ? setLength : activeItem === 'Height' ? setHeight : activeItem === 'Width' ? setWidth : activeItem === 'Weight' ? setWeight : '' } toggle={() =&gt; setVisible(!visible)} onSubmit={() =&gt; setVisible(!visible)} /&gt; </code></pre>
[ { "answer_id": 74268440, "author": "merlinabarzda", "author_id": 10163557, "author_profile": "https://Stackoverflow.com/users/10163557", "pm_score": 1, "selected": false, "text": "Orders" }, { "answer_id": 74268442, "author": "knittl", "author_id": 112968, "author_pro...
2022/10/31
[ "https://Stackoverflow.com/questions/74268368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17939803/" ]
74,268,374
<p>This is something I still don't quite understand very well, I have the following situation:</p> <blockquote> <pre><code>// #2) Check if this array includes any name that has &quot;John&quot; inside of it. If it does, return that // name or names in an array. const dragons = ['Tim', 'Johnathan', 'Sandy', 'Sarah']; </code></pre> </blockquote> <p>at first I tried the following:</p> <pre><code>const name = dragons.forEach(element =&gt; { element.includes(&quot;John&quot;) ? element : null }); </code></pre> <p>it returns <code>undefined</code></p> <p>then:</p> <pre><code>const name = dragons.filter(element =&gt; { element.includes(&quot;John&quot;); }); </code></pre> <p>it returns an empty array</p> <p>then:</p> <pre><code>function name() { const dragons = ['Tim', 'Johnathan', 'Sandy', 'Sarah']; dragons.forEach(element =&gt; { if (element.includes(&quot;John&quot;)) { return element; } }); } </code></pre> <p>again it returns <code>undefined</code></p> <p>but the interesting thing is that if on any of the attempts I change the action to do to <code>console.log(element);</code> then it will show &quot;Johnathan&quot; which is the correct output.</p> <p>so it means that the logic is working, I just don't understand why it won't return the value if I want to let's say assign it to a variable.</p> <p>I even tried the following:</p> <pre><code>const dragons = ['Tim', 'Johnathan', 'Sandy', 'Sarah']; dragons.forEach(element =&gt; { if (element.includes(&quot;John&quot;)) { const name = element; } }); </code></pre> <p>but it again returns name as <code>undefined</code>, why is that?</p> <p>edit: this was my first stack overflow question, really I wasn't expecting someone answering my question, I thought maybe it was a dumb question or that i didn't explained myself well but it was very nice to find such a supportive community, thank you so much to all of you who commented and helped me!</p>
[ { "answer_id": 74268455, "author": "Franco Agustín Torres", "author_id": 20318366, "author_profile": "https://Stackoverflow.com/users/20318366", "pm_score": 3, "selected": true, "text": "forEach" }, { "answer_id": 74268463, "author": "mbojko", "author_id": 7194268, "a...
2022/10/31
[ "https://Stackoverflow.com/questions/74268374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20382194/" ]
74,268,437
<p>I have created a dictionary using <code>dict()</code> where the key is a word and the item is the amount of time that word occurs in a text file.</p> <p>I am trying to sort on the amount of occurrences a word has from high to low.</p> <p>An example of the input is:</p> <p><code>{'stack': 2, 'over': 1, 'flow': 3}</code></p> <p>The desired output is any type of list that shows both the word and its occurrences i.e.:</p> <p><code>[['flow', 3], ['stack', 2], ['over', 1]]</code></p> <p>I have tried using:</p> <p><code>sorted(word_dict, key=word_dict.get, reverse=True)</code></p> <p>output:</p> <pre><code>['flow', 'stack', 'over'] </code></pre> <p>which I found on other SO posts; however, this only outputs the words and not the occurrences, how could I solve this?</p>
[ { "answer_id": 74268505, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 2, "selected": true, "text": "lst = [[k, dct[k]] for k in sorted(dct, key=dct.get, reverse=True)]\nprint(lst)\n" }, { "answer_id": ...
2022/10/31
[ "https://Stackoverflow.com/questions/74268437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20207326/" ]
74,268,472
<p>I am new to ROS2, so maybe the question makes no sense...</p> <p>I am going to design a robot, and all initial testing will be virtual: in Gasebo, instead of the real world.</p> <p>Robot is Raspberry Pi 3 or 4 based.</p> <p>Now, in the real world, one or few such robots will run in parallel, and there will be a central PC for compute-intensive tasks like image processing (plus overall control). It will run on ROS2.</p> <p>Now: do I have to develop it all on Ubuntu and then port to Raspberry Pi, or can I somehow make the emulated Rasp. Pi run on Ubuntu, so when I am done, the code could be copied to a &quot;real&quot; Rasp. Pi, without re-testing?</p> <p>I don't mind installing Ubuntu on Rasp. Pi, instead of Rasp. native OS, but then the question is: can I count on the code that was tested in Ubuntu PC to run smoothly on PI?</p> <p>I am not sure if this is the right approach, so if there is an alternative, please let me know (as same applise to running Arduinos and so on...)</p> <p>Thank you.</p> <p>P.S. Or, tu put it differently, can I (and do I need) to run multiple nodes of ROS2 on a single &quot;test&quot; Ubuntu PC, while some of these nodes are contained in some kind of Raspberry PI emulator?</p>
[ { "answer_id": 74268505, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 2, "selected": true, "text": "lst = [[k, dct[k]] for k in sorted(dct, key=dct.get, reverse=True)]\nprint(lst)\n" }, { "answer_id": ...
2022/10/31
[ "https://Stackoverflow.com/questions/74268472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5079088/" ]
74,268,483
<p>It seems I can start a coroutine using a number of mechanisms. Two of them are <code>coroutineScope</code> and <code>launch</code> but reading the Kotlin coroutine docs I am unclear what the difference is and when I would use one over the other</p> <pre><code>fun main() { println(&quot;Main block ${Thread.currentThread().name}&quot;) runBlocking { coroutineScope { println(&quot;Coroutine scope ${Thread.currentThread().name}&quot;) } launch { println(&quot;Launch ${Thread.currentThread().name}&quot;) } } } </code></pre> <p>I ran the above and can see that both start a new coroutine. What is the difference?</p>
[ { "answer_id": 74268529, "author": "Louis Wasserman", "author_id": 869736, "author_profile": "https://Stackoverflow.com/users/869736", "pm_score": 2, "selected": false, "text": "coroutineScope" }, { "answer_id": 74269792, "author": "cactustictacs", "author_id": 13598222, ...
2022/10/31
[ "https://Stackoverflow.com/questions/74268483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20206687/" ]
74,268,500
<p>I have 3 table with excatcly same columns names. For this example lets say id,name,category, price.</p> <p>when i extract data i got the desired data where each field renamed to source table. it is not so convinet and i want to extract data from same columns as arr of obj.</p> <p><strong>currently query:</strong></p> <pre><code>SELECT ta.name AS name_a, tb.name AS name_b, ta.price AS price_a, tb.price AS price_b, ta.category FROM table_A ta JOIN table_b tb on tb.id = ta.id </code></pre> <p><strong>Currently result</strong></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>id</th> <th>name_a</th> <th>name_b</th> <th>price_a</th> <th>price_b</th> <th>category</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>name1</td> <td>name2</td> <td>x</td> <td>y</td> <td>cats</td> </tr> <tr> <td>2</td> <td>name3</td> <td>name4</td> <td>m</td> <td>n</td> <td>cats</td> </tr> </tbody> </table> </div> <p><strong>Desired result</strong></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: right;">id</th> <th style="text-align: center;">names</th> <th style="text-align: center;">prices</th> <th style="text-align: right;">category</th> </tr> </thead> <tbody> <tr> <td style="text-align: right;">1</td> <td style="text-align: center;">{name_a:name1,name_b:name2}</td> <td style="text-align: center;">{price_a:x,price_b:y}</td> <td style="text-align: right;">cats</td> </tr> <tr> <td style="text-align: right;">2</td> <td style="text-align: center;">{name_a:name3,name_b:name4}</td> <td style="text-align: center;">{price_a:m,price_b:n}</td> <td style="text-align: right;">cats</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74268589, "author": "Stefanov.sm", "author_id": 2302032, "author_profile": "https://Stackoverflow.com/users/2302032", "pm_score": 2, "selected": false, "text": "jsonb_build_object" }, { "answer_id": 74268611, "author": "Edouard", "author_id": 8060017, "...
2022/10/31
[ "https://Stackoverflow.com/questions/74268500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19529973/" ]
74,268,511
<p>I am trying to add an extra tick and label to an existing ggplot. Namely,</p> <pre><code>&gt; df_partial_1[10:20,] X v Tv_partial upper lower 10 10 10 9.473527 9.561264 9.385789 11 11 11 10.185980 10.292432 10.079528 12 12 12 10.876827 11.002762 10.750893 13 13 13 11.546730 11.692879 11.400580 14 14 14 12.196326 12.363378 12.029275 15 15 15 12.826239 13.014827 12.637651 16 16 16 13.437071 13.647775 13.226367 17 17 17 14.029405 14.262751 13.796060 18 18 18 14.603809 14.860269 14.347349 19 19 19 15.160833 15.440830 14.880835 20 20 20 15.701009 16.004918 15.397100 </code></pre> <p>is my data. Using codes:</p> <pre><code>require(ggplot2) ggplot(df_partial_1[10:20,], aes(x = log(v), y = log(Tv_partial))) + theme_bw() + xlab(&quot;v&quot;) + ylab(bquote(lnT[v])) + scale_x_continuous(labels = ~floor(exp(.)), sec.axis=sec_axis(~., name = &quot;ln v&quot;)) + geom_line(aes(y=log(upper)), linetype=&quot;dashed&quot;) + geom_line(aes(y=log(Tv_partial))) + geom_line(aes(y=log(lower)), linetype=&quot;dashed&quot;) </code></pre> <p>I can obtain the plot:</p> <p><a href="https://i.stack.imgur.com/CBRiW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CBRiW.png" alt="enter image description here" /></a></p> <p>How can I add a tick at <code>v = 12.5</code> on the bottom axis? I found an answer below but could not make it work</p> <p><a href="https://stackoverflow.com/questions/29824773/annotate-ggplot-with-an-extra-tick-and-label">Annotate ggplot with an extra tick and label</a></p> <pre><code>&gt; ggplot(df_partial_1[10:20,], aes(x = log(v), y = log(Tv_partial))) + theme_bw() + xlab(&quot;v&quot;) + ylab(bquote(lnT[v])) + scale_x_continuous(labels = ~floor(exp(.)), sec.axis=sec_axis(~., name = &quot;ln v&quot;)) + geom_point() + annotate(v=12.5, y=0, label=&quot;xyz&quot;, color=&quot;red&quot;) +annotate(v=12.5, ymin=-1, ymax=1, color=&quot;red&quot;) + + geom_line(aes(y=log(upper)), linetype=&quot;dashed&quot;) + + geom_line(aes(y=log(Tv_partial))) + + geom_line(aes(y=log(lower)), linetype=&quot;dashed&quot;) Error in layer(geom = geom, params = list(na.rm = na.rm, ...), stat = StatIdentity, : argument &quot;geom&quot; is missing, with no default </code></pre> <p>Thanks!</p> <p>===============================================</p> <p>The following codes give an ok plot but how can I add a tick of <code>v = 12.5</code> on the axis?</p> <pre><code>ggplot(df_partial_1[10:20,], aes(x = log(v), y = log(Tv_partial))) + theme_bw() + xlab(&quot;v&quot;) + ylab(bquote(lnT[v])) + scale_x_continuous(labels = ~floor(exp(.)), sec.axis=sec_axis(~., name = &quot;ln v&quot;)) + geom_segment(aes(x = log(12.5), y = 2, xend = log(12.5), yend = 2.415)) + geom_line(aes(y=log(upper)), linetype=&quot;dashed&quot;) + geom_line(aes(y=log(Tv_partial))) + geom_line(aes(y=log(lower)), linetype=&quot;dashed&quot;) </code></pre> <p><a href="https://i.stack.imgur.com/SMQkB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SMQkB.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74269684, "author": "KacZdr", "author_id": 12382064, "author_profile": "https://Stackoverflow.com/users/12382064", "pm_score": 3, "selected": true, "text": "> dput(df_partial_1)\nstructure(list(X = 10:20, v = 10:20, Tv_partial = c(9.4856413914822, \n10.146674007643, 10.816...
2022/10/31
[ "https://Stackoverflow.com/questions/74268511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10173383/" ]
74,268,523
<p>So I have a public repository from my lecturer on GitLab, which I cloned into intellij via &quot;import VCS&quot; (https Link). Now I want to always push into my own repository in GitLab and not the public repository. How can i do this in intellij or where else can I set this up?</p> <p>I already tried to copy the project into a new project and push seperately but this isnt a good solution because then i need to copy everything manually whenever new things are being added in the public repository and i cant just pull from the public repository. The optimal solution would be, that i can pull from the public repository but push my commits into my own repository in GitLab</p>
[ { "answer_id": 74288587, "author": "Ruslan Kuleshov", "author_id": 12360005, "author_profile": "https://Stackoverflow.com/users/12360005", "pm_score": 0, "selected": false, "text": "Git | Manage remotes" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74268523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20191573/" ]
74,268,536
<p>Suppose I have data, in power bi, in the following form...</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>group</th> <th>condition</th> </tr> </thead> <tbody> <tr> <td>A</td> <td>yes</td> </tr> <tr> <td>A</td> <td>maybe</td> </tr> <tr> <td>B</td> <td>yes</td> </tr> <tr> <td>B</td> <td>yes</td> </tr> </tbody> </table> </div> <p><strong>question</strong><br /> Is there a way to count the distinct elements of one column, where every value in another column matches a condition?</p> <p>e.g. can we create a count of distinct <code>group</code> values where every associated <code>[condition]</code> equals <code>yes</code>?</p>
[ { "answer_id": 74288587, "author": "Ruslan Kuleshov", "author_id": 12360005, "author_profile": "https://Stackoverflow.com/users/12360005", "pm_score": 0, "selected": false, "text": "Git | Manage remotes" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74268536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20114321/" ]
74,268,567
<p>How can I send &quot;records&quot; variable to another screen?</p> <p><a href="https://i.stack.imgur.com/IFiMn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IFiMn.png" alt="Problem Image" /></a></p>
[ { "answer_id": 74288587, "author": "Ruslan Kuleshov", "author_id": 12360005, "author_profile": "https://Stackoverflow.com/users/12360005", "pm_score": 0, "selected": false, "text": "Git | Manage remotes" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74268567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19196093/" ]
74,268,568
<p>I'm trying to use stringr/dplyr to extract a pathway name from a table cell containing excess information. All cells in this table follow the same general format. Some examples are:</p> <hr /> <p>(R)-lactate from methylglyoxal: step 1/2. {ECO:0000256|ARBA:ARBA00005008, ECO:0000256|RuleBase:RU361179}.</p> <hr /> <p>(S)-dihydroorotate from bicarbonate: step 3/3. {ECO:0000256|ARBA:ARBA00004880}.</p> <hr /> <p>3,4',5-trihydroxystilbene biosynthesis</p> <hr /> <p>From these examples, I want to extract &quot;(R)-lactate from methylglyoxal&quot;, &quot;(S)-dihydroorotate from bicarbonate&quot;, and &quot;3,4',5-trihydroxystilbene biosynthesis&quot; respectively. I'm struggling to figure out which combination of regular expressions to use in order to accomplish this. I've been trying to use the positive look behind assertion <code>?&lt;=...</code> along with <code>str_extract</code> to extract all information preceding the first &quot;:&quot;, but I can't get it to work. Any help would be appreciated!</p>
[ { "answer_id": 74288587, "author": "Ruslan Kuleshov", "author_id": 12360005, "author_profile": "https://Stackoverflow.com/users/12360005", "pm_score": 0, "selected": false, "text": "Git | Manage remotes" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74268568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20326298/" ]
74,268,582
<pre><code>class Element { public: ElementTypes type = DOT; Element() {} Element(ElementTypes type) : type(type) {} virtual void Draw() { return; } }; </code></pre> <pre><code>class Dot : public Element { public: int x, y; Dot(int x, int y) : x(x), y(y) {} void Draw() override { DrawCircle(x, y, 2.f, BLACK); } }; </code></pre> <pre><code>class Drawing { public: std::vector&lt;Element*&gt; Elements; void AddDot(Dot&amp; dot) { Elements.emplace_back(&amp;dot); } void Draw() { for (auto element : Elements) { element-&gt;Draw(); } } }; </code></pre> <p>For some reason, there is a crash when trying to call <code>element-&gt;Draw()</code>.</p> <pre class="lang-none prettyprint-override"><code>Exception thrown at 0x00007FF66DDC1486 in geometry.exe: 0xC0000005: Access violation reading location 0x0000000000000000. </code></pre> <p>I am using the function <code>AddDot</code> to add an element to the vector</p> <p>Not using a pointer to the class, the <code>Draw</code> function is just not overriden.</p>
[ { "answer_id": 74288587, "author": "Ruslan Kuleshov", "author_id": 12360005, "author_profile": "https://Stackoverflow.com/users/12360005", "pm_score": 0, "selected": false, "text": "Git | Manage remotes" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74268582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18234396/" ]
74,268,637
<p>I've completely stuck with this task and I really dunno how to make this program work properly, because I think I've already tried many possible options, but it still unfortunately didn't work properly.</p> <p>The task is: &quot;The blacksmith has to shoe several horses and needs to see if he has the correct number of horseshoes. Write a check(p, k) function that, for a given number of horseshoes p and number of horses k, prints out how many horseshoes are missing, remaining, or whether the number is correct (see sample file for output format).&quot;</p> <p>The code I've already done is:</p> <pre><code>def check(p, k): if p % 2 == 0 and k % 2 == 0 and p % k == 0: print(&quot;Remaining:&quot;, k % p) elif p % k != 0: print(&quot;Missing:&quot;, p // k + 1) else: print(&quot;OK&quot;) check(20, 6) check(10, 2) check(12, 3) check(13, 3) </code></pre> <p>The output should look like this:</p> <pre><code>Missing: 4 Remaining: 2 OK Remaining: 1 </code></pre>
[ { "answer_id": 74268715, "author": "jprebys", "author_id": 3268228, "author_profile": "https://Stackoverflow.com/users/3268228", "pm_score": 1, "selected": false, "text": "def check(p, k):\n required_shoes = k * 4\n if p == required_shoes:\n # just right\n elif p < requir...
2022/10/31
[ "https://Stackoverflow.com/questions/74268637", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20372783/" ]
74,268,646
<p><a href="https://i.stack.imgur.com/Ymdb7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ymdb7.png" alt="enter image description here" /></a></p> <p>Im trying to schedule my stored procedure to run every day and save the results into a table. I got the stored procedure to work but im not able to create a table with the results.</p> <p>Creating a table backed by the SP to run daily</p>
[ { "answer_id": 74268715, "author": "jprebys", "author_id": 3268228, "author_profile": "https://Stackoverflow.com/users/3268228", "pm_score": 1, "selected": false, "text": "def check(p, k):\n required_shoes = k * 4\n if p == required_shoes:\n # just right\n elif p < requir...
2022/10/31
[ "https://Stackoverflow.com/questions/74268646", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20382484/" ]
74,268,681
<p>I have tried the code below, but it just returns literally ONLY the files and folders in my desktop folder. Whereas when you open shell:Desktop in File Explorer you get the same files PLUS all the drive letters and few other shell folders like &quot;This PC&quot; and Libraries.</p> <pre><code>DirectoryInfo di = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)); foreach (FileInfo fi in di.GetFiles()) Console.WriteLine(fi.FullName); foreach (DirectoryInfo subdir in di.GetDirectories()) Console.WriteLine(subdir.FullName); </code></pre>
[ { "answer_id": 74268913, "author": "Anderson Constantino", "author_id": 12081337, "author_profile": "https://Stackoverflow.com/users/12081337", "pm_score": 0, "selected": false, "text": "DirectoryInfo di = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));\n...
2022/10/31
[ "https://Stackoverflow.com/questions/74268681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12562386/" ]
74,268,685
<p>I'm using Radzen in a Blazor WebAssembly app.</p> <pre><code>@page &quot;/modificarRiesgo&quot; @page &quot;/modificarRiesgo/{Nombre}&quot; @inject NavigationManager navManager @inject IModuloRiesgosServices _riesgosService &lt;h3&gt;ModificarRiesgo&lt;/h3&gt; @if(riesgo == null){ &lt;p&gt;Loading...&lt;/p&gt; } else{ &lt;p style=&quot;color:red;text-align:center&quot;&gt;Seguro que desea modificar este archivo?&lt;/p&gt; &lt;RadzenTemplateForm Data=&quot;@riesgo&quot; TItem=&quot;RiesgoDTO&quot;&gt; &lt;div class=&quot;row&quot;&gt; &lt;div class=&quot;col-10&quot;&gt; &lt;RadzenFieldset Text=&quot;Detalle de Riesgos&quot;&gt; &lt;div class=&quot; row&quot;&gt; &lt;div class=&quot;col-md-2 align-items-center d-flex&quot;&gt; &lt;RadzenLabel Text=&quot;Nombre&quot; /&gt; &lt;/div&gt; &lt;div class=&quot;col-md-6&quot;&gt; &lt;RadzenTextBox Name=&quot;Nombre&quot; Style=&quot;width:100%&quot; @bind-Value=&quot;@riesgo.Nombre&quot; /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot; row&quot;&gt; &lt;div class=&quot;col-md-2 align-items-center d-flex&quot;&gt; &lt;RadzenLabel Text=&quot;Descripcion&quot; /&gt; &lt;/div&gt; &lt;div class=&quot;col-md-6&quot;&gt; &lt;RadzenTextArea Name=&quot;Descripcion&quot; Style=&quot;width:100%&quot; @bind-Value=&quot;@riesgo.Descripcion&quot; /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot; row&quot;&gt; &lt;div class=&quot;col-md-2 align-items-center d-flex&quot;&gt; &lt;RadzenLabel Text=&quot;Viabilidad&quot; /&gt; &lt;/div&gt; &lt;div class=&quot;col-md-6&quot;&gt; &lt;RadzenNumeric Name=&quot;Viabilidad&quot; Style=&quot;width:100%&quot; @bind-Value=&quot;@riesgo.Viabilidad&quot; /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot; row&quot;&gt; &lt;div class=&quot;col-md-2 align-items-center d-flex&quot;&gt; &lt;RadzenLabel Text=&quot;Impacto&quot; /&gt; &lt;/div&gt; &lt;div class=&quot;col-md-6&quot;&gt; &lt;RadzenNumeric Name=&quot;Impacto&quot; Style=&quot;width:100%&quot; @bind-Value=&quot;@riesgo.Impacto&quot; /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;row&quot;&gt; &lt;div class=&quot;col-md-2 align-items-center d-flex&quot;&gt; &lt;div class=&quot;col-md-6&quot;&gt; &lt;RadzenButton Text=&quot;Cancelar&quot; ButtonStyle=&quot;ButtonStyle.Danger&quot; Click=@(args =&gt; cancel()) /&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/RadzenFieldset&gt; &lt;/div&gt; &lt;/div&gt; &lt;/RadzenTemplateForm&gt; } @code { [Parameter] public string? Nombre { get; set; } public RiesgoDTO riesgo { get; set; } = new RiesgoDTO(); protected override async Task OnInitializedAsync(){ obtener(Nombre); } public async void obtener(string nombre){ var response = await _riesgosService.ObtenerTodosLosRiesgos(); foreach(var r in response.Data){ if (r.Nombre == nombre) riesgo = r; } } protected void cancel() { navManager.NavigateTo(&quot;/gestionarRiesgos&quot;); } } </code></pre> <p>I'm not using &quot;id&quot; as paramater cause I use &quot;Guid&quot;, and it cannot be sent as a paramater, so I'm using the string value &quot;Nombre&quot; OnInitializedAsync has a method that looks for the object based on its &quot;Nombre&quot; and assigns it to the variable &quot;riesgo&quot;</p> <p>If anybody had any idea, please. I've been working onthis for 3 days</p>
[ { "answer_id": 74269289, "author": "Lex", "author_id": 548997, "author_profile": "https://Stackoverflow.com/users/548997", "pm_score": 2, "selected": true, "text": "obtener" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74268685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20216845/" ]
74,268,716
<p>these last weeks I have been trying to learn the ADA language, to do it I made an exercise to reverse a string using recursion, however when I compile it with GNATProve it gives me several errors which I have not been able to solve, it would be of great help if you could guide me on how to solve them using Preconditions and Postconditions.</p> <p>My code:</p> <pre><code>function String_Reverse(Str:String) return String with Pre =&gt; Str'Length &gt; 0 , Post =&gt; String_Reverse'Result'Length &lt;= Str'Length; function String_Reverse (Str : String) return String is Result : String (Str'Range); begin if Str'Length = 1 then Result := Str; else Result := String_Reverse (Str (Str'First + 1 .. Str'Last)) &amp; Str (Str'First); end if; return Result; end String_Reverse; </code></pre> <p>Errors:</p> <pre class="lang-bash prettyprint-override"><code>dth113.adb:18:69: low: range check might fail 18&gt;| String_Reverse (Str (Str'First + 1 .. Str'Last)) &amp; 19 | Str (Str'First); reason for check: result of concatenation must fit in the target type of the assignment possible fix: precondition of subprogram at line 8 should mention Str 8 | function String_Reverse(Str:String) return String with | ^ here dth113.adb:18:69: medium: length check might fail 18&gt;| String_Reverse (Str (Str'First + 1 .. Str'Last)) &amp; 19 | Str (Str'First); reason for check: array must be of the appropriate length possible fix: precondition of subprogram at line 8 should mention Str 8 | function String_Reverse(Str:String) return String with | ^ here </code></pre> <p>I'm tried using Preconditons and Postconditions about the input Str length</p>
[ { "answer_id": 74269289, "author": "Lex", "author_id": 548997, "author_profile": "https://Stackoverflow.com/users/548997", "pm_score": 2, "selected": true, "text": "obtener" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74268716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20284071/" ]
74,268,724
<p>when i set level to INFO in file_handler. am getting other log levels also printed into the file. how can i get each log level printed into different log file . i dont want duplicate logs in any of the files.Can any one please help?</p> <pre><code>import logging logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) formatter = logging.Formatter('%(asctime)s : %(name)s :%(levelname)s :%(message)s') formatter1 = logging.Formatter('%(levelname)s :%(message)s') file_handler = logging.FileHandler('test_log.log') file_handler.setLevel(logging.INFO) file_handler.setFormatter(formatter) stream_handler = logging.StreamHandler() stream_handler.setLevel(logging.WARNING) stream_handler.setFormatter(formatter1) logger.addHandler(file_handler) logger.addHandler(stream_handler) logger.error(&quot;this is error&quot;) logger.debug(&quot;this is debug&quot;) logger.info(&quot;this is info&quot;) logger.critical(&quot;this is critical&quot;) logger.warning(&quot;this is warning&quot;) </code></pre> <p>i tried this and am getting all the other log levels also into the log file</p>
[ { "answer_id": 74269289, "author": "Lex", "author_id": 548997, "author_profile": "https://Stackoverflow.com/users/548997", "pm_score": 2, "selected": true, "text": "obtener" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74268724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15349625/" ]
74,268,757
<p>I am creating a module that reads CSV and Excel files using Apache POI and Opencsv.</p> <p>For reading CSV files, I am creating 1 class and 2 methods:</p> <pre><code>class CsvReader { void open() {//implementation} List&lt;CsvDto1&gt; get1() {//implementation} List&lt;CsvDto2&gt; get2() {//implementation} void close() {//implementation} } </code></pre> <p>For reading Excel files, I am also creating 1 class and 2 methods:</p> <pre><code>class ExcelReader { void open() {//implementation} List&lt;ExlDto1&gt; get3() {//implementation} List&lt;ExlDto2&gt; get4() {//implementation} void close() {//implementation} } </code></pre> <p>All I want is to implement a pattern that will be helped maintainable in the future. So I created an interface called <code>FileReadable</code>:</p> <pre><code>interface FileReadable { void open(); List&lt;CsvDto1&gt; get1() List&lt;CsvDto2&gt; get2() List&lt;ExlDto1&gt; get3() List&lt;ExlDto2&gt; get4() void close(); } </code></pre> <p>then <code>CsvReader</code> and <code>ExcelReader</code> will be implemented from <code>FileRedable</code>. The issue is <code>get1()</code> and <code>get2()</code> exist in <code>CsvReader</code> but they do not exist in <code>ExcelReader</code>, <code>get3()</code> and <code>get4()</code> exist in <code>ExcelReader</code> but they do not exist in <code>CsvReader</code>. How do I create a common <code>read</code> method for both classes or do we have any design pattern for this case?</p> <pre><code> interface FileReadable { void open(); Reader read(); void close(); } </code></pre>
[ { "answer_id": 74268997, "author": "c3R1cGFy", "author_id": 5149545, "author_profile": "https://Stackoverflow.com/users/5149545", "pm_score": 2, "selected": false, "text": "Dto1" }, { "answer_id": 74272823, "author": "StepUp", "author_id": 1646240, "author_profile": "...
2022/10/31
[ "https://Stackoverflow.com/questions/74268757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16573073/" ]
74,268,769
<p>I using javascript for concatenate two columns that I have in an table:</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 ruta = document.getElementById('ruta1').innerHTML; var desborde = document.getElementById('desborde1').innerHTML; document.getElementById('concatenate').innerHTML += '' + ruta + '' + desborde;</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;table id="Enrut_calx" class="table table-striped"&gt; &lt;thead class="thead-dark"&gt; &lt;tr&gt; &lt;th class="text-center"&gt;Ruta 1&lt;/th&gt; &lt;th class="text-center"&gt;Desborde 1&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; @foreach (var item in Model) { &lt;tr&gt; &lt;td class="text-center" id="ruta1"&gt; @Html.DisplayFor(modelItem =&gt; item.RUTA_1) &lt;/td&gt; &lt;td class="text-center" id="desborde1"&gt; @Html.DisplayFor(modelItem =&gt; item.DESBORDE_1) &lt;/td&gt; &lt;td class="text-center" id="concatenate"&gt; @Html.DisplayFor(modelItem =&gt; item.DESBORDES) &lt;/td&gt; &lt;/tr&gt; } &lt;/table&gt;</code></pre> </div> </div> </p> <p>My result is:</p> <p><a href="https://i.stack.imgur.com/3h8KG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3h8KG.png" alt="enter image description here" /></a></p> <p>However, although the result that it shows me in the image is what I require, in the other rows it does not show me the same result and it makes the rows blank.</p> <p>Which if someone could guide me I would appreciate it.</p>
[ { "answer_id": 74268997, "author": "c3R1cGFy", "author_id": 5149545, "author_profile": "https://Stackoverflow.com/users/5149545", "pm_score": 2, "selected": false, "text": "Dto1" }, { "answer_id": 74272823, "author": "StepUp", "author_id": 1646240, "author_profile": "...
2022/10/31
[ "https://Stackoverflow.com/questions/74268769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11633787/" ]
74,268,794
<p>I'm new to Typescript and trying to wrap my head around the best way to handle class inheritance where base classes have some different properties.</p> <p>Basically, I have a base class for which I want to define some common functionality and a set of subclasses that have different properties as they represent different database models. I'm trying to figure out how to get the types working.</p> <p>For example:</p> <pre><code>class BaseClass { static create(props) { /*... */ } update(props) { /*... */ } } type SubClassOneProps = { firstName: string lastName: string } class SubClassOne extends BaseClass { firstName!: string lastName!: string } type SubClassTwoProps = { streetName: string streetNumber: number } class SubClassTwo extends BaseClass { streetName!: string streetNumber!: number } // I'm looking for typing that will allow me to do the following: SubClassOne.create({firstName: &quot;Bob&quot;, lastName: &quot;Doe&quot;}) SubClassTwo.create({streetName: &quot;Sunset Blvd&quot;, streetNumber: 100}) //and then same idea with the instance methods, although I would use Partial&lt;&gt; with these </code></pre> <p>Since the properties are different for each subclass, the signatures vary a bit even though they will all be basic key/value pairs. I don't see how to get the typing right and can't figure out how to specify the properties from the subclasses.</p> <p>I'm also going to need to store some metadata on each of these properties (specifically, whether they should be publicly accessible or not), and then have an instance method that can export the public properties to a JSON object. But I'll save that as another problem for later.</p> <p>Any guidance appreciated!</p>
[ { "answer_id": 74268948, "author": "Besnik Korça", "author_id": 13305073, "author_profile": "https://Stackoverflow.com/users/13305073", "pm_score": 1, "selected": false, "text": "class BaseClass {\n static create<T>(props: T) {\n /*... */\n }\n update(props) {\n /*... */\n }\n}...
2022/10/31
[ "https://Stackoverflow.com/questions/74268794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1923052/" ]
74,268,806
<p>I developed a following endpoint using SpringBoot:</p> <pre><code>@RestController @RequestMapping(&quot;api/v1&quot;) public class UserResource { @GetMapping(&quot;users&quot;) public ResponseEntity&lt;List&lt;User&gt;&gt; getUsers() { return ResponseEntity.ok().body(List.of(new User(&quot;George&quot;, &quot;Walker&quot;))); } } </code></pre> <p>The endpoint works when I launched it using <code>bootRun</code> Gradle task.</p> <p>The endpoint can be reached using: <code>http://localhost:8080/api/v1/users</code></p> <p><a href="https://i.stack.imgur.com/6ZsfV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6ZsfV.png" alt="enter image description here" /></a></p> <p>Then I build a war file using <code>war</code> Gradle Task and I deploy it using Tomcat.</p> <p><a href="https://i.stack.imgur.com/vgBo7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vgBo7.png" alt="enter image description here" /></a></p> <p>I try to reach the same endpoint using the URL: <code>http://localhost:8080/user-service-api-0.0.1-SNAPSHOT-plain/api/v1/users</code>, but it fails. The Tomcat is up, the app is deployed, but the endpoint is not accessible.</p> <p>In addition to that I have in <code>build.gradle</code> entry: <code>org.springframework.boot:spring-boot-starter-tomcat</code> and a class:</p> <pre><code>package net.bean.userserviceapi; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; public class ServletInitializer extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(UserServiceApiApplication.class); } } </code></pre> <p>What am I doing wrong?</p> <p>Thank you.</p>
[ { "answer_id": 74270012, "author": "Harry Coder", "author_id": 893952, "author_profile": "https://Stackoverflow.com/users/893952", "pm_score": 1, "selected": false, "text": "war" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74268806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3126929/" ]
74,268,807
<p>I want to close or at least decrease the distance between these three elements ( distance is shown in red between each element and the other ) <code>h4</code>, <code>h1</code> and <code>p</code>. I tried the CSS grid <code>row-gap:</code> but it didn't seem to be working and I don't think the problem is in the gaps. Can anyone tell me how to make these three elements closer to each other. <strong>Ps : the part of css that I'm working on is the one for desktops, withing the media queries.</strong></p> <p><a href="https://i.stack.imgur.com/yXPit.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yXPit.png" alt="enter image description here" /></a></p> <p><strong>Link to my whole source code in Github :</strong> <a href="https://github.com/IssamAth/Waitlist-page" rel="nofollow noreferrer">https://github.com/IssamAth/Waitlist-page</a></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>/* MEDIA QUERIES ================ ( For desktops ) ================ */ @media screen and (min-width: 1024px) { .content { display: grid; grid-template-areas: 'one four' 'two four' 'three .'; margin-top: 0; } .image { display: inline-block; grid-area: four; } .image img { width: 25rem; height: 28rem; } h1 { /* margin-bottom: 8rem; */ padding: 2rem 10rem 1rem 0rem; font-size: 3.5rem; text-align: start; grid-area: two; /* font-size: 3.1rem; */ } p { text-align: start; grid-area: three; font-size: 1.1rem; padding-right: 20rem; /* font-size: 0.99em; */ } h4 { margin: 0; margin-top: 4rem; text-align: start; height: 3.2rem; width: 34rem; padding: 0.6rem 1rem 0.6rem 1rem; grid-area: one; } }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;section class="content"&gt; &lt;h4&gt;We are now allowing early-access for users. &lt;a class="learn"&gt;Learn more.&lt;/a&gt;&lt;/h4&gt; &lt;h1&gt;Build a highly engaged community with no effort.&lt;/h1&gt; &lt;p&gt;Commune offers the tools you need to build a highly engaged community with little to no effort. Simply setup your Commune workspace, and manage everything from members to content from one central dashboard.&lt;/p&gt; &lt;div class="image"&gt; &lt;img src="https://via.placeholder.com/300" alt="illustration" /&gt; &lt;/div&gt; &lt;/section&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74270012, "author": "Harry Coder", "author_id": 893952, "author_profile": "https://Stackoverflow.com/users/893952", "pm_score": 1, "selected": false, "text": "war" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74268807", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17345724/" ]
74,268,826
<p>I want to check if my string has 3 <em>different</em> vowels. Mine code below counts every vowel regardless if they are the same.</p> <pre class="lang-js prettyprint-override"><code>function hasThreeVowels(str) { let vowelCount = 0; let vowels = &quot;aeiou&quot; for (let char of str) { if(vowels.includes(char)) { vowelCount++ } } return vowelCount &gt;= 3; } </code></pre>
[ { "answer_id": 74270012, "author": "Harry Coder", "author_id": 893952, "author_profile": "https://Stackoverflow.com/users/893952", "pm_score": 1, "selected": false, "text": "war" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74268826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20362724/" ]
74,268,840
<p>Working on a CS class - C course problem. Part of the problem is to create a function to print the specified length from a char buffer, given a char pointer to print from.</p> <p>Signature of the function to be called in loop:</p> <pre><code>bool printLine(char cbuffer, char *ptr, int bufferFillLength) </code></pre> <p>where <code>cbuffer</code> is the pointer to the beginning of the buffer, <code>ptr</code> is the pointer to the start of the string to print. Variable <code>bufferFillLength</code> is the number of characters to print from the buffer starting at <code>ptr</code>.</p> <p>The function should be called in loop until the end of the line is reached (i.e function returns false).</p> <p>Here is my attempt but not working and looking for help.</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; #include &lt;stdbool.h&gt; #define BUFFER_SIZE 300 bool printLine (char cbuffer, char *ptr, int printLength){ char *bufferprinttext; strncpy (bufferprinttext, &amp;cbuffer[ptr], printLength); printf(&quot;%s&quot;, bufferprinttext); if(bufferprinttext[strlen(bufferprinttext)-1] == '\n') { //end of line reasched - return false; return false; } return true; } int main(int argc, char *argv[]) { char cbuffer[BUFFER_SIZE]; int printLength = 25; bool isItEndOfBuffer = false; int bufferCounter = 0; cbuffer = &quot;Fusce dignissim facilisis ligula consectetur hendrerit. Vestibulum porttitor aliquam luctus. Nam pharetra lorem vel ornare condimentum. Praesent et nunc at libero vulputate convallis. Cras egestas nunc vitae eros vehicula hendrerit. Pellentesque in est et sapien dignissim molestie.&quot;; while(isItEndOfBuffer == false) { ++bufferCounter; isItEndOfBuffer = printLine(cbuffer, &amp;cbuffer[printLength * bufferCounter], printLength); } } </code></pre>
[ { "answer_id": 74270012, "author": "Harry Coder", "author_id": 893952, "author_profile": "https://Stackoverflow.com/users/893952", "pm_score": 1, "selected": false, "text": "war" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74268840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3741611/" ]
74,268,852
<p><a href="https://i.stack.imgur.com/tmGbH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tmGbH.png" alt="how the website looks like" /></a></p> <p>Hi, I am trying to make a panel that changes the color of my background,when you click on a specific color the background should change accordingly.I managed to code the panel with help of a :target, but i struggle with background change. I tried using :focus, :checked and some more pseudo-classes but i can not make it work. I am not allowed to use JS.</p> <p>HTML BODY</p> <pre><code>&lt;div class=&quot;shoe-background&quot;&gt; &lt;div id=&quot;niketext&quot;&gt;NIKE&lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;textpanel&quot;&gt; &lt;div id=&quot;header&quot;&gt; &lt;div id=&quot;title&quot;&gt;Nike Zoom KD 12&lt;/div&gt; &lt;div class=&quot;button&quot;&gt;NEW&lt;/div&gt; &lt;div style=&quot;font-size:15px;font-weight:300;&quot;&gt;Men's Running Shoes&lt;/div&gt; &lt;br&gt; &lt;div style=&quot;font-size:20px;font-weight:500&quot;&gt;Product Info&lt;/div&gt; &lt;div style=&quot;font-size:13px;font-weight:300&quot;&gt;Lorem, ipsum dolor sit amet consectetur adipisicing elit. Nobis distinctio odit praesentium tempora commodi ea iusto veniam fuga minima, tenetur sequi voluptatibus voluptas id! Minima perferendis voluptatibus sint molestias quisquam!&lt;/div&gt; &lt;br&gt; &lt;div style=&quot;font-size:20px;font-weight:500&quot;&gt;Color&lt;/div&gt; &lt;div class=&quot;colors-selector&quot;&gt; &lt;a href=&quot;#red&quot; class=&quot;picker&quot; id=&quot;red&quot;&gt;&lt;/a&gt; //I am using :target for color select effect &lt;a href=&quot;#green&quot; class=&quot;picker&quot; id=&quot;green&quot;&gt;&lt;/a&gt; &lt;a href=&quot;#blue&quot; class=&quot;picker&quot; id=&quot;blue&quot;&gt;&lt;/a&gt; &lt;a href=&quot;#orange&quot; class=&quot;picker&quot; id=&quot;orange&quot;&gt;&lt;/a&gt; &lt;a href=&quot;#gray&quot; class=&quot;picker&quot; id=&quot;gray&quot;&gt;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I've been struggling with CSS, tried something like this:</p> <pre><code>.colors-selector a#red:focus .shoe-background{ background: red; } .colors-selector a#red:focus ~.shoe-background{ background: red; } .picker ~.shoe-background{ background: red; } #red:target .shoe-background{ background:red; } //and so on... </code></pre> <p>but I cant make it working, I know it is an issue with a parent-child-sibling specifiers, but I do know what to even search for to have a grasp on the issue. Any help appreciated!</p>
[ { "answer_id": 74270012, "author": "Harry Coder", "author_id": 893952, "author_profile": "https://Stackoverflow.com/users/893952", "pm_score": 1, "selected": false, "text": "war" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74268852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14994322/" ]
74,268,864
<p>I’m updating the environment on Heroku and one of the <a href="https://github.com/thoughtbot/heroku-buildpack-mysql" rel="nofollow noreferrer">buildpack</a> we use is based on Ruby, which is no longer available by default in the <a href="https://devcenter.heroku.com/articles/heroku-22-stack" rel="nofollow noreferrer">new <code>heroku-22</code> environment/stack</a> (nor required by our PHP app).</p> <p><a href="https://devcenter.heroku.com/articles/heroku-22-stack#upgrade-notes" rel="nofollow noreferrer">From the docs</a>:</p> <blockquote> <p>[...] end users should add the Ruby buildpack prior to the buildpack in question (they will also need to ensure minimal <code>Gemfile</code> / <code>Gemfile.lock</code> files exist, so that the Ruby buildpack passes detection).</p> </blockquote> <p>However I have no clue what those files should include as I have zero experience with Ruby. What would be a valid set of minimal <code>Gemfile</code>s to trigger Ruby installation on Heroku?</p>
[ { "answer_id": 74270012, "author": "Harry Coder", "author_id": 893952, "author_profile": "https://Stackoverflow.com/users/893952", "pm_score": 1, "selected": false, "text": "war" } ]
2022/10/31
[ "https://Stackoverflow.com/questions/74268864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4530144/" ]
74,268,896
<p>My goal is to create an output that has a Series datatype and following output:</p> <p><a href="https://i.stack.imgur.com/oteyl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oteyl.png" alt="enter image description here" /></a></p> <p>I tried to achieve this by using the code below:</p> <pre><code>series_structure = pd.Series() for i in table_dtypes[0]: if i == &quot;object&quot;: type_dict = {'type': 'categorical'} series_structure.append(type_dict) elif i == &quot;boolean&quot;: type_dict = {'type': 'boolean'} series_structure.append(type_dict) elif i == &quot;datetime64&quot;: # revisit here type_dict = {'type': 'datetime', 'format': '%Y-%m-%d'} series_structure.append(type_dict) elif i == &quot;int64&quot;: type_dict = {'type': 'id', 'subtype': 'integer'} series_structure.append(type_dict) elif i == &quot;float64&quot;: # revisit here type_dict = {'type': 'numerical', 'subtype': 'float'} series_structure.append(type_dict) </code></pre> <p>But I get the error below:</p> <pre><code>TypeError: cannot concatenate object of type '&lt;class 'dict'&gt;'; only Series and DataFrame objs are valid </code></pre> <p>For reference my input dataset looks like this (table_dtypes): <a href="https://i.stack.imgur.com/68iCF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/68iCF.png" alt="enter image description here" /></a></p> <p>What can I do?</p>
[ { "answer_id": 74269083, "author": "Z Li", "author_id": 14751619, "author_profile": "https://Stackoverflow.com/users/14751619", "pm_score": 0, "selected": false, "text": "pd.Series" }, { "answer_id": 74269149, "author": "ouroboros1", "author_id": 18470692, "author_pro...
2022/10/31
[ "https://Stackoverflow.com/questions/74268896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7077532/" ]
74,268,905
<p>I am not certain how to correct the SQL below to stop receiving the following error, Conversion failed when converting Nvarchar value 'Dist00' to int. Here is the Sql:</p> <pre><code>SELECT g.[Period], g.BuyingGroup, g.NonJDEGroup, g.GroupCode, g.Percentage, c.DistributorId as CustomerNumber, ci.CustomerName, ri.ShipTo, ci.ShipToTiedTo, b.BidId, b.Account, ri.InvoiceNumber, ri.InvoiceDate, ri.DateModified, i.ItemId, CASE WHEN ri.NetBilled=0 THEN round(ri.SalePrice * ri.Quantity, 2) ELSE 0 END AS SaleTotal, CASE WHEN ri.NetBilled=1 THEN round(ri.BidPrice * ri.Quantity, 2) ELSE 0 END AS BidTotal, CASE WHEN ri.SalePrice &lt;= ri.BidPrice THEN 0 ELSE (ri.SalePrice - ri.BidPrice) * ri.Quantity END AS RebateTotal, ri.NetBilled, ri.Quantity, b.Bid_TypeId, b.Bid_ClassId, CAST(CASE WHEN (ri.DateModified &gt;= @SalesStartDate and ri.DateModified &lt;= @SalesEndDate) THEN 1 ELSE 0 END AS bit) AS isCurrent, CAST(CASE WHEN (ri.DateModified &gt;= @LateStartDate and ri.DateModified &lt;= @LateEndDate) THEN 1 ELSE 0 END AS bit) AS isLate FROM [BQM_Dev].dbo.Claims c INNER JOIN [BQM_Dev].dbo.Claim_Items i ON c.ClaimId=i.ClaimId INNER JOIN [BQM_Dev].dbo.Rebate_Items ri ON ri.Claim_ItemId = i.Claim_ItemId INNER JOIN [BQM_Dev].dbo.Bids b on b.BidId = i.BidId INNER JOIN [BQM_Dev].dbo.Bid_Classes bc ON bc.Bid_ClassId=b.Bid_ClassId LEFT OUTER JOIN #CustomerInformation ci ON ci.CustomerNumber=c.DistributorId AND ci.RecordType='C' LEFT OUTER JOIN #CustomerInformation si ON si.CustomerNumber=c.DistributorId AND si.RecordType IN ('SF','BH') INNER JOIN [BQM_Dev].dbo.FunctionalGroupings g on b.DistributorId=g.CustomerNumber WHERE bc.IncludeInReporting=1 AND ri.DateModified between @LateStartDate and @SalesEndDate AND ri.InvoiceDate &gt; @SalesCutOffDate </code></pre> <p>When I have changed the Select statement is '*', it works fine. The following joins may be where the problem is, as they are joining on fields that are int on one side and nvarchar on the other side. These are lines:</p> <pre><code>LEFT OUTER JOIN #CustomerInformation ci ON ci.CustomerNumber=c.DistributorId AND ci.RecordType='C' LEFT OUTER JOIN #CustomerInformation si ON si.CustomerNumber=c.DistributorId AND si.RecordType IN ('SF','BH') INNER JOIN [BQM_Dev].dbo.FunctionalGroupings g on b.DistributorId=g.CustomerNumber </code></pre> <p>So, ci.CustomerNumber in int but c.DistributorId is nvarchar, Also b.DistributorId is Nvarchar and g.CustomerNumber is int.</p> <p>I have tried Convert, I am just not certain what to do. any advice would be helpful.</p>
[ { "answer_id": 74269083, "author": "Z Li", "author_id": 14751619, "author_profile": "https://Stackoverflow.com/users/14751619", "pm_score": 0, "selected": false, "text": "pd.Series" }, { "answer_id": 74269149, "author": "ouroboros1", "author_id": 18470692, "author_pro...
2022/10/31
[ "https://Stackoverflow.com/questions/74268905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2325351/" ]
74,268,966
<p>I am making a simple game where two moons orbit around a planet. I want to make it so that with the press of a button:</p> <pre><code> public KeyCode switch_rotation_moon_a; private bool rotating_left = false; private void Update() { if (Input.GetKeyDown(switch_rotation_moon_a)) { rotating_left = !rotating_left; } } </code></pre> <p>where rotating_left is what decides the rotation direction. I then have this for the actual implementation of the rotation:</p> <pre><code> private void FixedUpdate() { planet_position = radius * Vector3.Normalize(this.transform.position - planet.transform.position) + planet.transform.position; this.transform.position = planet_position; if (rotating_left) { transform.RotateAround(planet.transform.position, new Vector3(0, 0, 1), rotation_speed); } transform.RotateAround(planet.transform.position, new Vector3(0, 0, -1), rotation_speed); } </code></pre> <p>When starting the game, the planet seems to rotate just fine in one direction, but inverting the z-axis just stops the rotation.</p> <p>I've looked into transform.RotateAround(), but I have a hard time understanding the exact math behind it. I would also appreciate a simple explanation of the math behind it, I don't expect ready-to-copy code! Thank you! :)</p>
[ { "answer_id": 74269095, "author": "jdewi", "author_id": 14003151, "author_profile": "https://Stackoverflow.com/users/14003151", "pm_score": 3, "selected": true, "text": "else" }, { "answer_id": 74270821, "author": "CS1061", "author_id": 20378590, "author_profile": "h...
2022/10/31
[ "https://Stackoverflow.com/questions/74268966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15695995/" ]
74,268,972
<p>My XML file looks like below,</p> <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;File fileId=&quot;123&quot; xmlns=&quot;abc:XYZ&quot; &gt; ABC123411/10/20 XBC128911/10/20 BCD456711/23/22 &lt;/File&gt; </code></pre> <p>This is a fixed length flat xml file, and I need to parse this file as For ex,</p> <pre><code>ABC123411/10/20 </code></pre> <p>as create Content object.</p> <pre><code>public class Content { private id; private name; private date; // getters } </code></pre> <p>Ex:</p> <pre><code>name: ABC id: 1234 Date: 11/10/20 </code></pre> <p>This is what I'm trying</p> <pre><code>&lt;bean id=&quot;reader&quot; class=&quot;org.springframework.batch.item.xml.StaxEventItemReader&quot; scope=&quot;step&quot;&gt; &lt;property name=&quot;resource&quot; value=&quot;file:#{jobExecutionContext['source.download.filePath']}&quot; /&gt; &lt;property name=&quot;unmarshaller&quot; ref=&quot;jaxb2Marshaller&quot; /&gt; &lt;property name=&quot;fragmentRootElementNames&quot; value=&quot;File&quot;&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id=&quot;jaxb2Marshaller&quot; class=&quot;org.springframework.oxm.jaxb.Jaxb2Marshaller&quot;&gt; &lt;property name=&quot;packagesToScan&quot;&gt; &lt;list&gt; &lt;value&gt;com.test.model&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; </code></pre> <p>and my pojo,</p> <pre><code>@XmlAccessorType(XmlAccessType.FIELD) @XmlRootElement(name = &quot;File&quot;, namespace = &quot;//namespace&quot;) public class TestRecord { @XmlValue private String data; public String getData() { return data; } } </code></pre> <p>Now this code parses the xml file and sets the value as String in <strong>TestRecord.data</strong> as below</p> <pre><code>ABC123411/10/20 XBC128911/10/20 BCD456711/23/22 </code></pre> <p>With this method, we need to write a mapper again to parse this string (from TestRecord.data) by new line and then tokenize each String and assign to Content object.</p> <p>I just want to check if this is something we can do it in XML configuration using readers available or any other better options? thanks!</p>
[ { "answer_id": 74278605, "author": "pete_bc", "author_id": 13041661, "author_profile": "https://Stackoverflow.com/users/13041661", "pm_score": 0, "selected": false, "text": " @Bean\n public static RegexLineTokenizer regexpTokenizer() {\n RegexLineTokenizer tok = new RegexLineToke...
2022/10/31
[ "https://Stackoverflow.com/questions/74268972", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3966963/" ]
74,269,037
<p>I'm using javascript to check required fields in a form, so that a field is styled and an error message appears if it's empty on <code>focusout</code>. (This is to supplement a Kirby CMS form plugin that validates on submit only.)</p> <p>The behaviour I'm trying to create is...</p> <ul> <li>When a required field is left empty, styling and message appear on <code>focusout</code>.</li> <li>Styling and message remain visible until either (a) the field is in focus state again or (b) the field is populated.</li> <li>If a required field is 'refocussed', left blank and focus left again, the message and styling reappear.</li> </ul> <p>My problem is that the input styling (red border-bottom) works as intended but the error message, which is based in the <code>appendChild</code> function, does not. The error message only appears one at a time with the last focussed required field and I can't figure out how to get the message to stay in place the same way the styling does.</p> <p>Because, in practice, forms will be created by content-managers using the CMS, I want the script to be vanilla JS and as generic as possible, avoiding targeting specific IDs. Instead, I'm trying to do this based on the <code>required</code> attribute and the <code>querySelectorAll</code> function. I have some variables to specity the error message text and a <code>for</code> loop to target just the 'offending' fields that don't meet the criteria of an <code>if</code> statement.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function reqdCheck() { const reqdFields = document.querySelectorAll("main input[required], main textarea[required]"); const reqdPara = document.createElement("p"); const reqdText = document.createTextNode("This field is required."); reqdPara.appendChild(reqdText); for (const reqdField of reqdFields) { reqdField.addEventListener ("focusout", function() { if (reqdField.value == "" || reqdField.value == null) { reqdField.style.borderBottom = "1px solid red"; reqdField.style.boxShadow = "0 1px 0 0 red"; reqdField.parentNode.appendChild(reqdPara); } else { reqdField.style.borderBottom = "1px solid black"; reqdField.style.boxShadow = "none"; } }) reqdField.addEventListener ("focusin", function() { if (reqdField.value == "" || reqdField.value == null) { reqdField.style.borderBottom = "1px solid orange"; reqdField.style.boxShadow = "0 1px 0 0 orange"; reqdField.parentNode.removeChild(reqdPara); } }) } } reqdCheck()</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>input:not([type="submit"]), textarea { border: none; border-bottom: 1px solid black; display: block; width: calc(100% - 40px); } input:not([type="submit"]):focus, textarea:focus { outline: none; border-bottom: 1px solid orange; box-shadow: 0 1px 0 0 orange; } .field-group { margin-bottom: 20px; } .field-group p { color: red; line-height: 1; margin: 5px 0 0; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;main&gt; &lt;form id="a2a64e93-2b60-4ad9-9445-ce61f5852594" action="#"&gt; &lt;div class="field-group"&gt; &lt;label for="fname"&gt;First name:*&lt;/label&gt;&lt;br&gt; &lt;input type="text" id="fname" name="fname" placeholder="John" required&gt; &lt;/div&gt; &lt;div class="field-group"&gt; &lt;label for="lname"&gt;Last name:&lt;/label&gt;&lt;br&gt; &lt;input type="text" id="lname" name="lname" placeholder="Doe"&gt; &lt;/div&gt; &lt;div class="field-group"&gt; &lt;label for="company"&gt;Company:&lt;/label&gt;&lt;br&gt; &lt;input type="text" id="fname" name="company" placeholder="Acme Ltd"&gt; &lt;/div&gt; &lt;div class="field-group"&gt; &lt;label for="email"&gt;Email:*&lt;/label&gt;&lt;br&gt; &lt;input type="email" id="email" name="email" placeholder="john@acme.com" required&gt; &lt;/div&gt; &lt;div class="field-group"&gt; &lt;label for="email"&gt;Message:*&lt;/label&gt;&lt;br&gt; &lt;textarea id="message" name="message" placeholder="Message" required&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;input type="submit" value="Submit"&gt; &lt;/form&gt; &lt;/main&gt;</code></pre> </div> </div> </p> <p>What am I missing to get the appendChild error message to stay visible as intended? Is there a more efficient way to achieve what I'm after? Thanks.</p>
[ { "answer_id": 74270243, "author": "score30", "author_id": 12521653, "author_profile": "https://Stackoverflow.com/users/12521653", "pm_score": 2, "selected": true, "text": "p" }, { "answer_id": 74290297, "author": "zer00ne", "author_id": 2813224, "author_profile": "ht...
2022/10/31
[ "https://Stackoverflow.com/questions/74269037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20382598/" ]
74,269,043
<p>I'm trying to force Node to wait for either a success or a failure. I understood fetch to return a promise and I thought I told it how to handle both.</p> <p>The following code does not honor the <em><strong>await</strong></em> I asked it to do:</p> <pre><code>async function getAccessToken() { ... let fetchResult = await fetch(argumentParserResult.authorizationUrl, { method: 'POST', body: formData, headers: headers }).then(success =&gt; { console.log(&quot;Success reached. &quot; + JSON.stringify(success)); process.exit(2); }, other =&gt; { console.log(&quot;Other reached. &quot; + JSON.stringify(other)); process.exit(3); }); console.log('@@ after fetch fetchResult=' + fetchResult); ... } </code></pre> <p>You might think that the await would cause it to, wait for the Promise to complete, but instead it leaves the whole function, and goes back to the caller. It does <em>not</em> print the '@@ after fetch fetchResult=' line. Neither the failure, nor success handler is executed.</p> <p>I should point out that it also does not appear to make the requested POST call either. Instead, it sees that request and does something completely different without raising any exception.</p> <p>Why is it not honoring the 'await' keyword whatsoever?</p> <p>--- If I try the try/catch approach as follows:</p> <pre><code>async function getAccessToken() { console.log('@@getAccessToken BP1'); if (argumentParserResult.authenticationScheme == 'OAUTH2') { console.log('@@getAccessToken BP2'); const fetch = require('node-fetch'); const url = argumentParserResult.resourceUrl; console.log('@@getAccessToken BP3'); let formData = new URLSearchParams({ 'grant_type': 'client_credentials', 'client_id': argumentParserResult.clientId, 'scope': argumentParserResult.clientScope, 'client_secret': argumentParserResult.clientSecret }) console.log('@@getAccessToken BP4'); let headers = { 'Content-Type': 'application/x-www-form-urlencoded' }; console.log('@@getAccessToken BP5'); console.log('POST ' + argumentParserResult.authorizationUrl); console.log(JSON.stringify(formData)); console.log('@@getAccessToken BP6'); try { console.log('@@getAccessToken BP7'); const response = await fetch(argumentParserResult.authorizationUrl, { method: 'POST', body: formData, headers, }); console.log('@@getAccessToken BP8'); console.log(`Success reached.`, JSON.stringify(response)); const json = await response.json(); console.log('@@getAccessToken BP9'); console.log(`Other reached.`, json); return json; } catch (error) { console.log('@@getAccessToken BP10'); console.log(`!! something went wrong`, error.message); console.error(error); return error; } finally { console.log('@@getAccessToken BP11'); console.log(`fetch finished`); } console.log('@@getAccessToken BP12'); } console.log('@@getAccessToken BP13'); return &quot;Should not have reached this point&quot;; } </code></pre> <p>I get</p> <pre><code>@@getAccessToken BP1 @@getAccessToken BP2 @@getAccessToken BP3 @@getAccessToken BP4 @@getAccessToken BP5 POST https://some-url {} @@getAccessToken BP6 @@getAccessToken BP7 </code></pre> <p>As you can see, it goes just inside of the try block, then goes back to the caller without triggering the finally, error handlers or the logging after the fetch.</p> <p>Using the .then approach as follows:</p> <pre><code>async function getAccessToken() { console.log('@@getAccessToken BP1'); if (argumentParserResult.authenticationScheme == 'OAUTH2') { console.log('@@getAccessToken BP2'); const fetch = require('node-fetch'); const url = argumentParserResult.resourceUrl; console.log('@@BP1.9'); let formData = new URLSearchParams({ 'grant_type': 'client_credentials', 'client_id': argumentParserResult.clientId, 'scope': argumentParserResult.clientScope, 'client_secret': argumentParserResult.clientSecret }) console.log('@@getAccessToken BP3'); let headers = { 'Content-Type': 'application/x-www-form-urlencoded' }; console.log('@@getAccessToken BP4'); console.log('POST ' + argumentParserResult.authorizationUrl); console.log(JSON.stringify(formData)); let response = await fetch(argumentParserResult.authorizationUrl, { method: 'POST', body: formData, headers: headers }).then(success =&gt; { console.log('@@getAccessToken BP5'); console.log(&quot;Success reached. &quot; + JSON.stringify(success)); return success // !--&gt; LOOK HERE, you should return the success variable }).catch(e =&gt; { console.log('@@getAccessToken BP6'); console.log(e) // !--&gt; LOOK HERE, if you catch the error, no error will be thrown to the caller return e }); console.log('@@getAccessToken BP7'); console.log('@@ after fetch fetchResult=', fetchResult); // !--&gt; LOOK HERE, this log will always log something now, it could be the responso or the error } console.log('@@getAccessToken BP8'); } </code></pre> <p>I get these logs:</p> <pre><code>@@getAccessToken BP1 @@getAccessToken BP2 @@BP1.9 @@getAccessToken BP3 @@getAccessToken BP4 POST https://login.microsoftonline.com/5a9bb941-ba53-48d3-b086-2927fea7bf01/oauth2/v2.0/token {} </code></pre> <p>As you can see above, it goes just to the point of the fetch, then returns to the calling function.</p> <p>In neither case, can I see any evidence that the fetch was ever called.</p>
[ { "answer_id": 74270243, "author": "score30", "author_id": 12521653, "author_profile": "https://Stackoverflow.com/users/12521653", "pm_score": 2, "selected": true, "text": "p" }, { "answer_id": 74290297, "author": "zer00ne", "author_id": 2813224, "author_profile": "ht...
2022/10/31
[ "https://Stackoverflow.com/questions/74269043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10855224/" ]
74,269,076
<p>I notice that sometimes compilers keep <em>garbage data</em> in the call stack. Call stack consists of function stack frames, which is the activation record of a function call. Ideally, the stack frame of a function should contain only <em>necessary data</em>, including spilled callee-saved registers, local variables that must be preserved across nested function calls, return address, etc.</p> <p>Consider a situation where function <code>foo()</code> calls into several other functions. Across these nested function calls, the activation record size of <code>foo()</code> may change. Below is an example:</p> <pre class="lang-c prettyprint-override"><code>extern long f(long x); extern void bar(long x); extern void tail(void); void foo(long x) { long fx = f(x); // x must be preserved across the f(x) call // because x is later used again. bar(x + fx); // No need to preserve anything. x and fx will // no longer be used again. tail(); // Just to prevent tail call optimization on bar(...). } </code></pre> <p>However, the code compiled by Clang (version 14.0.4) doesn't optimize its stack frame usage, as shown below. GCC (version 9.4.0) is similar. Optimization <code>-O2</code> is enabled for both.</p> <pre><code>foo: push %rbx // preserve %rbx mov %rdi,%rbx // %rbx &lt;- %rdi (%rbx preserves argument x) call f // %rax &lt;- f(%rdi) add %rax,%rbx // %rbx &lt;- %rax + %rbx mov %rbx,%rdi // %rdi &lt;- %rbx (from now on, %rbx is garbage) (because x will never be used again) call bar // bar(%rdi) pop %rbx // restore %rbx (this should occur earlier) jmp tail // tail() </code></pre> <p>Ideally, when the argument <code>x</code> in <code>foo()</code> is no longer useful, we should discard it as soon as possible so that the stack frame memory footprint is kept as small as possible.</p> <pre><code>foo: push %rbx // preserve %rbx mov %rdi,%rbx // %rbx &lt;- %rdi call f // %rax &lt;- f(%rdi) add %rax,%rbx // %rbx &lt;- %rax + %rbx mov %rbx,%rdi // %rdi &lt;- %rbx pop %rbx // restore %rbx (pop out 8 bytes from stack) (before calling bar!) call bar // bar(%rdi) jmp tail // tail() </code></pre> <p><strong>So here is my question: is there any compiler option that allow us to have as compact stack frame as possible?</strong></p> <p>In the case shown above, the compiler definitely misses the optimization opportunity. In general, however, keeping the stack frame as compact as possible may introduce extra instructions to manipulate the stack pointer or even data copying inside the stack frame, which poses a trade-off between the call stack memory footprint and the runtime performance.</p> <p>Having a smaller call stack memory footprint is valuable on embedded systems, where the RAM is pretty limited. On PC, smaller memory footprint can lead to better cache locality and thus potentially faster execution speed.</p> <p>I'm aware of the <code>-fstack-reuse</code> option in GCC. The default value is <code>all</code>. Changing it to other values will only make the stack memory footprint even worse.</p> <p><strong>Update 1:</strong></p> <p>Jonathan expressed the concern regarding <code>x</code> being an argument, whose allocation is managed by the caller of <code>foo()</code>. If <code>x</code> is instead passed on stack, then things might be different.</p> <p>So I update with a better example that needs to preserve an intermediate value across nested function calls.</p> <pre class="lang-c prettyprint-override"><code>extern long f(long x); extern void bar(long x); extern void tail(void); void foo(long x) { long fx = f(x); bar(fx); // fx must be preserved across this call // because it will be used again later long ffx = f(fx); // fx used again here // no need to preserve anything from now on // ideally the stack frame should be // set to 0 before calling f() bar(ffx); tail(); } </code></pre> <p>And the assembly code by Clang (similar to GCC)</p> <pre><code>foo: push %rbx // preserve %rbx call f // %rax &lt;- f(%rdi) mov %rax,%rbx // %rbx &lt;- %rax (fx is preserved in %rbx) mov %rax,%rdi // %rdi &lt;- %rax call bar // bar(%rdi) mov %rbx,%rdi // %rdi &lt;- %rbx (use fx again here) // (ideally should pop here) call f // %rax &lt;- f(%rdi) ^ mov %rax,%rdi // %rdi &lt;- %rax | call bar // bar(%rdi) | pop %rbx // restore %rbx ---------------------+ jmp tail </code></pre> <p><strong>Update 2</strong>:</p> <p>Unfortunately, <code>-fconserve-stack</code>, <code>-fno-defer-pop</code> and <code>-foptimize-sibling-calls</code> don't help the examples above.</p>
[ { "answer_id": 74269302, "author": "John Bollinger", "author_id": 2402272, "author_profile": "https://Stackoverflow.com/users/2402272", "pm_score": 1, "selected": false, "text": "-fno-defer-pop" }, { "answer_id": 74328797, "author": "Jeff Garrett", "author_id": 3242146, ...
2022/10/31
[ "https://Stackoverflow.com/questions/74269076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8626243/" ]
74,269,119
<p>I have the following dataframe:</p> <pre><code>id phone email 10352897 10352897 10225967 10352897 user@gmail.com 10352897 10225967 user@gmail.com 10225967 10225967 user@gmail.com user@gmail.com 23578910 23578910 38256789 23578910 user2@gmail.com 23578910 38256789 user2@gmail.com 38256789 38256789 user2@gmail.com user2@gmail.com 65287930 user3@gmail.com 65287930 user3@gmail.com 65287930 70203065 70203065 70203065 user4@gmail.com user4@gmail.com user4@gmail.com </code></pre> <p><strong>Not all the fields are always filled in, but they are related to each other in at least one column.</strong></p> <p><a href="https://i.stack.imgur.com/zm0g7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zm0g7.png" alt="enter image description here" /></a></p> <p>I would like that when it coincides in at least one of the three columns, the record joins and prioritizes the filled fields over the empty ones, in the end in this example I would expect the following output:</p> <pre><code>id phone email 10352897 10225967 user@gmail.com 23578910 38256789 user2@gmail.com 65287930 user3@gmail.com 70203065 user4@gmail.com </code></pre> <p>How would you go about doing this?</p>
[ { "answer_id": 74269302, "author": "John Bollinger", "author_id": 2402272, "author_profile": "https://Stackoverflow.com/users/2402272", "pm_score": 1, "selected": false, "text": "-fno-defer-pop" }, { "answer_id": 74328797, "author": "Jeff Garrett", "author_id": 3242146, ...
2022/10/31
[ "https://Stackoverflow.com/questions/74269119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18400415/" ]
74,269,124
<p>I have a data frame with multiple variables that have similar endings (&quot;0m&quot;,&quot;6m&quot; or &quot;12m&quot;). These refer to the month of the data. Some of the variables are only collected once, whilst others at 3 time points (&quot;0m&quot;,&quot;6m&quot; or &quot;12m&quot;). The data looks like this:</p> <pre><code>wide= data.frame(id = c(1:5), agree = c(&quot;y&quot;,&quot;n&quot;,&quot;n&quot;,&quot;y&quot;,&quot;y&quot;), test1_0m = c(2,3,4,3,5), test1_6m = c(3,5,2,6,7), test1_12m = c(6,7,8,4,5), score_0m = c(55,44,33,22,11), score_6m = c(77,66,55,44,33), score_12m = c(99,88,77,66,55)) &gt; wide id agree test1_0m test1_6m test1_12m score_0m score_6m score_12m 1 1 y 2 3 6 55 77 99 2 2 n 3 5 7 44 66 88 3 3 n 4 2 8 33 55 77 4 4 y 3 6 4 22 44 66 5 5 y 5 7 5 11 33 55 </code></pre> <p>I want to <code>pivot_longer</code> to get a column <code>Month</code> which has <code>0m</code>, <code>6m</code>, or <code>12m</code> as entries, plus columns called <code>test1</code> and <code>score</code> which have the result for the corresponding person and month.</p> <p>I've found a really helpful answer here: <a href="https://www.stackoverflow.com/">https://stackoverflow.com/questions/69798752/pivot-longer-for-multiple-sets-having-the-same-names-to </a></p> <p>But I don't know how to specifiy the correct <code>regex</code> to get the values I want.</p> <p>I've tried this, which is wrong:</p> <pre><code>wide%&gt;% pivot_longer(cols = contains(&quot;_&quot;), names_to = c(&quot;Month&quot;, &quot;.value&quot;), names_pattern = &quot;(.*\\_)(.*)&quot;, values_drop_na = TRUE ) </code></pre> <p>This is the output I want:</p> <pre><code>long id agree Month test1 score 1 1 y 0m 2 55 2 2 n 0m 3 44 3 3 n 0m 4 33 4 4 y 0m 3 22 5 5 y 0m 5 11 6 1 y 6m 3 77 7 2 n 6m 5 66 8 3 n 6m 2 55 9 4 y 6m 6 44 10 5 y 6m 7 33 11 1 y 12m 6 99 12 2 n 12m 7 88 13 3 n 12m 8 77 14 4 y 12m 4 66 15 5 y 12m 5 55 </code></pre>
[ { "answer_id": 74269272, "author": "Anoushiravan R", "author_id": 14314520, "author_profile": "https://Stackoverflow.com/users/14314520", "pm_score": 2, "selected": false, "text": ".value" }, { "answer_id": 74269291, "author": "neilfws", "author_id": 89482, "author_pr...
2022/10/31
[ "https://Stackoverflow.com/questions/74269124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12452893/" ]
74,269,132
<p>I've scoured the web for this one.</p> <p>What I'm trying to do:</p> <p>I have a table that has a primary <code>id</code>. I need to add a column called ex. <code>order_number</code> that automatically increments starting at 1000 and up from there.</p> <hr /> <p>The Issue:</p> <p>PHP doesn't seem to like this, it throws an error</p> <pre><code> SQLSTATE[42P16]: Invalid table definition: 7 ERROR: multiple primary keys for table &quot;orders&quot; are not allowed (SQL: alter table &quot;orders&quot; add column &quot;order_number&quot; serial primary key not null) </code></pre> <hr /> <p>My Code:</p> <pre class="lang-php prettyprint-override"><code> public function up() { Schema::table('orders', function (Blueprint $table) { $last_id = Order::orderBy('id', 'desc')-&gt;first()-&gt;id; $table-&gt;integer('order_number', true, true)-&gt;from($last_id + 10001); }); foreach (Order::get() as $order) { $order-&gt;update([ 'order_number' =&gt; 10000 + $order-&gt;id ]); } } </code></pre>
[ { "answer_id": 74269272, "author": "Anoushiravan R", "author_id": 14314520, "author_profile": "https://Stackoverflow.com/users/14314520", "pm_score": 2, "selected": false, "text": ".value" }, { "answer_id": 74269291, "author": "neilfws", "author_id": 89482, "author_pr...
2022/10/31
[ "https://Stackoverflow.com/questions/74269132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13777922/" ]
74,269,163
<p>I am trying to send form data to php using ajax but it's not working and I searshed alot without fining anyy solution `</p> <p>this is the ajax code in my index.js `</p> <pre><code>$(&quot;#reg_form&quot;).submit(function (event) { alert(&quot;clicked&quot;) var registerData = { ajxfname: document.getElementById(&quot;fnameInput&quot;).value, ajxlname: document.getElementById(&quot;lnameInput&quot;).value, ajxemail: document.getElementById(&quot;emailInput&quot;).value, test: &quot;this is test text&quot; }; $.ajax({ type: &quot;POST&quot;, url: &quot;server.php&quot;, data: registerData, dataType: &quot;json&quot;, success: function (response) { alert(&quot;success&quot;); } }); event.preventDefault(); }); </code></pre> <p>`</p> <p>this is the code I use to print the data that I got in server.php</p> <p>`</p> <pre><code>foreach ($_POST as $key =&gt; $value) { echo $key; echo &quot; : &quot;; echo $value; echo &quot;&lt;br&gt;&quot;; } </code></pre> <p>`</p> <p>it just print the names and the data of the input in the form(fname,lname,email) in the html</p> <p>and this is the form in the html `</p> <pre><code> &lt;form id=&quot;reg_form&quot; action=&quot;server.php&quot; method=&quot;post&quot; &gt; &lt;input id=&quot;fnameInput&quot; name=&quot;fname&quot; placeholder=&quot;First name&quot; type=&quot;text&quot;&gt; &lt;input id=&quot;lnameInput&quot; name=&quot;lname&quot; placeholder=&quot;Last name&quot; type=&quot;text&quot;&gt; &lt;input id=&quot;emailInput&quot; name=&quot;email&quot; placeholder=&quot;E-mail&quot; type=&quot;text&quot;&gt; &lt;button class=&quot;btn&quot; type=&quot;submit&quot; &gt;Sign up&lt;/button&gt; </code></pre> <p>`</p> <p>thanks in advance</p>
[ { "answer_id": 74269293, "author": "Isfhan Ahmed", "author_id": 20250802, "author_profile": "https://Stackoverflow.com/users/20250802", "pm_score": -1, "selected": false, "text": "$(\"#reg_form\").submit(function (event) {\n event.preventDefault();\n\n alert(\"clicked\")\n cons...
2022/10/31
[ "https://Stackoverflow.com/questions/74269163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20382782/" ]
74,269,175
<p>I have a dataset like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ICD_10</th> <th>diagnosis</th> </tr> </thead> <tbody> <tr> <td>A00</td> <td>Cholera</td> </tr> <tr> <td>A01-A03</td> <td>Other Intestinal infectious diseases</td> </tr> <tr> <td>A15</td> <td>Respiratory tuberculosis</td> </tr> <tr> <td>A17-A19</td> <td>Other tuberculosis</td> </tr> </tbody> </table> </div> <p>...</p> <p>On row 2 and 4, there are multiple ICD-10 codes, and I want to expand them into multiple rows, like below:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ICD_10</th> <th>diagnosis</th> </tr> </thead> <tbody> <tr> <td>A00</td> <td>Cholera</td> </tr> <tr> <td>A01</td> <td>Other Intestinal infectious diseases</td> </tr> <tr> <td>A02</td> <td>Other Intestinal infectious diseases</td> </tr> <tr> <td>A03</td> <td>Other Intestinal infectious diseases</td> </tr> <tr> <td>A15</td> <td>Respiratory tuberculosis</td> </tr> <tr> <td>A17</td> <td>Other tuberculosis</td> </tr> <tr> <td>A18</td> <td>Other tuberculosis</td> </tr> <tr> <td>A19</td> <td>Other tuberculosis</td> </tr> </tbody> </table> </div> <p>How can I accomplish this in R using tidyverse?</p> <p>Thanks for your help!</p>
[ { "answer_id": 74269286, "author": "r2evans - GO NAVY BEAT ARMY", "author_id": 3358272, "author_profile": "https://Stackoverflow.com/users/3358272", "pm_score": 2, "selected": true, "text": "fun <- function(vec) {\n ltr <- substring(vec, 1, 1)\n L <- lapply(strsplit(gsub(\"[^-0-9]\", \...
2022/10/31
[ "https://Stackoverflow.com/questions/74269175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14415113/" ]
74,269,181
<p>I am trying to call SOAP service that receives DateTime in format &quot;yyyy-MM-ddTHH:mm:ss&quot;. I managed to set format to &quot;yyyy-MM-dd HH:mm:ss&quot;, but &quot;T&quot; between Date and Time is mandatory for call to SOAP service.</p> <p>I tried with</p> <pre><code>int lcid = CultureInfo.CurrentCulture.LCID; var formatInfo = new CultureInfo(lcid).DateTimeFormat; formatInfo.DateSeparator = &quot;-&quot;; formatInfo.ShortDatePattern = &quot;yyyy-MM-dd&quot;; formatInfo.LongTimePattern = &quot;HH:mm:ss&quot;; formatInfo.FullDateTimePattern = &quot;yyyy-MM-dd'T'HH:mm:ss&quot;; Thread.CurrentThread.CurrentCulture = new CultureInfo(lcid, true); Thread.CurrentThread.CurrentCulture.DateTimeFormat = formatInfo; string sd = &quot;2022-10-31T13:00:00&quot;; DateTime sdConverted = DateTime.ParseExact(sd, &quot;yyyy-MM-ddTHH:mm:ss&quot;, Thread.CurrentThread.CurrentCulture); </code></pre> <p>result is DateTime in format &quot;2022-10-01 13:00:00&quot;.</p> <p>EDIT: SOAP request creation</p> <pre><code>async Task&lt;GetTimeResponse&gt; GetTimeAsync(DateTime startDate, DateTime endDate, string username, string password) { ServiceClient client = new ServiceClient(); client.ClientCredentials.UserName.UserName = username; client.ClientCredentials.UserName.Password = password; TimeRequest timeRequest = new TimeRequest { From = startDate, Until = endDate, }; GetTimeRequest request = new GetTimeRequest(timeRequest); GetTimeResponse response = await client.GetTimeAsync(request); return response; } </code></pre> <p>Thank you :)</p>
[ { "answer_id": 74269286, "author": "r2evans - GO NAVY BEAT ARMY", "author_id": 3358272, "author_profile": "https://Stackoverflow.com/users/3358272", "pm_score": 2, "selected": true, "text": "fun <- function(vec) {\n ltr <- substring(vec, 1, 1)\n L <- lapply(strsplit(gsub(\"[^-0-9]\", \...
2022/10/31
[ "https://Stackoverflow.com/questions/74269181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20381061/" ]
74,269,200
<p>We have an issue that I have been able to recreate with this sample code:</p> <pre><code>int main() { double d = -2; // ... cout &lt;&lt; &quot;d: &quot; &lt;&lt; d &lt;&lt; endl; cout &lt;&lt; &quot;-d: &quot; &lt;&lt; -d &lt;&lt; endl; cout &lt;&lt; &quot;Conditional Operator (expect value 2): &quot; &lt;&lt; (d &lt; 0)? -d : d; cout &lt;&lt; endl; return 0; } </code></pre> <hr /> <p>The output is as follows:</p> <pre><code>d: -2 -d: 2 Conditional Operator (expect value 2): 1 </code></pre>
[ { "answer_id": 74269286, "author": "r2evans - GO NAVY BEAT ARMY", "author_id": 3358272, "author_profile": "https://Stackoverflow.com/users/3358272", "pm_score": 2, "selected": true, "text": "fun <- function(vec) {\n ltr <- substring(vec, 1, 1)\n L <- lapply(strsplit(gsub(\"[^-0-9]\", \...
2022/10/31
[ "https://Stackoverflow.com/questions/74269200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5651468/" ]
74,269,212
<p>I have a pandas dataframe that looks like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Type</th> <th>Status</th> </tr> </thead> <tbody> <tr> <td>typeA</td> <td>New</td> </tr> <tr> <td>typeA</td> <td>Working</td> </tr> <tr> <td>typeA</td> <td>Working</td> </tr> <tr> <td>typeA</td> <td>Closed</td> </tr> <tr> <td>typeA</td> <td>Closed</td> </tr> <tr> <td>typeA</td> <td>Closed</td> </tr> <tr> <td>typeB</td> <td>New</td> </tr> <tr> <td>typeB</td> <td>Working</td> </tr> <tr> <td>typeC</td> <td>Closed</td> </tr> <tr> <td>typeC</td> <td>Closed</td> </tr> <tr> <td>typeC</td> <td>Closed</td> </tr> </tbody> </table> </div> <p>I'd like to group the dataframe by the 'Type' field and get the count of each status as a column, like so:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Type</th> <th>New</th> <th>Working</th> <th>Closed</th> </tr> </thead> <tbody> <tr> <td>typeA</td> <td>1</td> <td>2</td> <td>3</td> </tr> <tr> <td>typeB</td> <td>1</td> <td>1</td> <td>0</td> </tr> <tr> <td>typeC</td> <td>0</td> <td>0</td> <td>3</td> </tr> </tbody> </table> </div> <p>I'd also like columns for statuses that could exist (I have a list all possibilities), but may not be represented in the input dataframe, so the final result would be something like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Type</th> <th>New</th> <th>Working</th> <th>Closed</th> <th>Escalate</th> </tr> </thead> <tbody> <tr> <td>typeA</td> <td>1</td> <td>2</td> <td>3</td> <td>0</td> </tr> <tr> <td>typeB</td> <td>1</td> <td>1</td> <td>0</td> <td>0</td> </tr> <tr> <td>typeC</td> <td>0</td> <td>0</td> <td>3</td> <td>0</td> </tr> </tbody> </table> </div> <p>I'm able to get the counts per status by using:</p> <pre><code>closureCodeCounts = closureCodes.groupby(['type','status'],as_index=False).size() </code></pre> <p>I've also tried</p> <pre><code>closureCodeCounts = closureCodeCounts.groupby('type').value_counts() closureCodeCounts = closureCodeCounts.unstack() </code></pre> <p>But nothing seems to come out right.</p> <p>I'm pretty lost. What's the best way to do this?</p>
[ { "answer_id": 74269341, "author": "ouroboros1", "author_id": 18470692, "author_profile": "https://Stackoverflow.com/users/18470692", "pm_score": 2, "selected": true, "text": "pd.crosstab" }, { "answer_id": 74269432, "author": "Community", "author_id": -1, "author_pro...
2022/10/31
[ "https://Stackoverflow.com/questions/74269212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2469633/" ]
74,269,263
<p>As I try to add a logo image to the carousel, I have a hard time making sure the logo remains stationary at all times without moving inside the carousel.</p> <pre><code>&lt;!--logo--&gt; &lt;div class=&quot;logo-image&quot;&gt; &lt;img src=&quot;Aaron%20Murillo-Black.png&quot; class=&quot;img-fluid&quot;&gt; &lt;/div&gt; &lt;!--Carousel image slider--&gt; &lt;div id=&quot;carouselExampleControls&quot; class=&quot;carousel slide&quot; data-bs-ride=&quot;carousel&quot;&gt; &lt;div class=&quot;carousel-inner&quot;&gt; &lt;div class=&quot;logo-image&quot;&gt; &lt;img src=&quot;Aaron%20Murillo-Black.png&quot; class=&quot;img-fluid&quot; alt=&quot;Web Site Logo&quot;&gt; &lt;/div&gt; &lt;div class=&quot;carousel-item active&quot;&gt; &lt;img src=&quot;Dress.jpg&quot; class=&quot;d-block w-100&quot; alt=&quot;Dress&quot;&gt; &lt;/div&gt; &lt;div class=&quot;carousel-item&quot;&gt; &lt;img src=&quot;Balloon.jpg&quot; class=&quot;d-block w-100&quot; alt=&quot;Balloon Fiesta&quot;&gt; &lt;/div&gt; &lt;div class=&quot;carousel-item&quot;&gt; &lt;img src=&quot;DarkChurch.jpg&quot; class=&quot;d-block w-100&quot; alt=&quot;Dark Church&quot;&gt; &lt;/div&gt; &lt;div class=&quot;carousel-item&quot;&gt; &lt;img src=&quot;River%20Falls.jpg&quot; class=&quot;d-block w-100&quot; alt=&quot;River Cave&quot;&gt; &lt;/div&gt; &lt;div class=&quot;carousel-item&quot;&gt; &lt;img src=&quot;Wedding.jpg&quot; class=&quot;d-block w-100&quot; alt=&quot;Couples&quot;&gt; &lt;/div&gt; &lt;/div&gt; &lt;button class=&quot;carousel-control-prev&quot; type=&quot;button&quot; data-bs-target=&quot;#carouselExampleControls&quot; data-bs-slide=&quot;prev&quot;&gt; &lt;span class=&quot;carousel-control-prev-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; &lt;span class=&quot;visually-hidden&quot;&gt;Previous&lt;/span&gt; &lt;/button&gt; &lt;button class=&quot;carousel-control-next&quot; type=&quot;button&quot; data-bs-target=&quot;#carouselExampleControls&quot; data-bs-slide=&quot;next&quot;&gt; &lt;span class=&quot;carousel-control-next-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; &lt;span class=&quot;visually-hidden&quot;&gt;Next&lt;/span&gt; &lt;/button&gt; &lt;/div&gt; </code></pre> <p>all my css with this had been a bust.</p> <pre><code>.logo-image{ width: 10%; height: 100px; border-radius: 10%; overflow: hidden; margin: auto; position: relative; } </code></pre>
[ { "answer_id": 74269341, "author": "ouroboros1", "author_id": 18470692, "author_profile": "https://Stackoverflow.com/users/18470692", "pm_score": 2, "selected": true, "text": "pd.crosstab" }, { "answer_id": 74269432, "author": "Community", "author_id": -1, "author_pro...
2022/10/31
[ "https://Stackoverflow.com/questions/74269263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20380348/" ]
74,269,279
<p>I'm building a site for a project,I have a divided into 50% 50% with display grid, on the right side there is the form, once sent I would like it to show a confirmation or error message , what can I do? i am using nextjs the form must disappear and show the message</p> <p>i could use display none, is there a better method? maybe using the components. Thank you</p>
[ { "answer_id": 74269341, "author": "ouroboros1", "author_id": 18470692, "author_profile": "https://Stackoverflow.com/users/18470692", "pm_score": 2, "selected": true, "text": "pd.crosstab" }, { "answer_id": 74269432, "author": "Community", "author_id": -1, "author_pro...
2022/10/31
[ "https://Stackoverflow.com/questions/74269279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16593935/" ]
74,269,282
<p>I have a CSV file which I want to normalize for SQL input. I want to drop every line, where's the column count not equal to a certain number within a row, this way I can ignore the bad lines, where column shift can happen. In the past, I used AWK to normalize this CSV dataset, but I want to implement this program in Python for easier parallelization other than GNU Parallel + AWK solution.</p> <p>I tried the following codes to drop the lines:</p> <pre class="lang-python prettyprint-override"><code>df.drop(df[df.count(axis='columns') != len(usecols)].index, inplace=True) df = df[df.count(axis=1) == len(usecols)] df = df[len(df.index) == len(usecols)] </code></pre> <p>None of this work, I need some help, Thank You!</p> <p><strong>EDIT:</strong></p> <ul> <li>I'm working on a single CSV file on a single worker.</li> </ul> <p><strong>EDIT 2:</strong></p> <p>Here is the awk script for reference:</p> <pre class="lang-awk prettyprint-override"><code>{ line = $0; # ... if (line ~ /^$/) next; # if line is blank, then remove it if (NF != 13) next; # if column count is not equal to 13, then remove it } </code></pre>
[ { "answer_id": 74277028, "author": "SultanOrazbayev", "author_id": 10693596, "author_profile": "https://Stackoverflow.com/users/10693596", "pm_score": 2, "selected": false, "text": "pandas" }, { "answer_id": 74284762, "author": "SultanOrazbayev", "author_id": 10693596, ...
2022/10/31
[ "https://Stackoverflow.com/questions/74269282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1442219/" ]
74,269,299
<p>I have a simple .NET MAUI application and am trying to implement a login page. The goal is nothing more than to show the login page and when the user submits name and password it will go to a view model that will then pass the user along to MainPage. This works, but when it gets to MainPage there are no tabs. My Appshell.xaml looks like this:</p> <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt; </code></pre> <p></p> <pre><code>&lt;ShellItem&gt; &lt;ShellContent ContentTemplate=&quot;{DataTemplate view:Login}&quot; /&gt; &lt;/ShellItem&gt; &lt;TabBar &gt; &lt;ShellContent Title=&quot;Home&quot; ContentTemplate=&quot;{DataTemplate local:MainPage}&quot; Icon=&quot;icon_home&quot; /&gt; &lt;ShellContent Title=&quot;About&quot; ContentTemplate=&quot;{DataTemplate local:About}&quot; Icon=&quot;icon_about&quot; /&gt; &lt;/TabBar&gt; </code></pre> <p>Is there an obvious solution to this issue?</p>
[ { "answer_id": 74277028, "author": "SultanOrazbayev", "author_id": 10693596, "author_profile": "https://Stackoverflow.com/users/10693596", "pm_score": 2, "selected": false, "text": "pandas" }, { "answer_id": 74284762, "author": "SultanOrazbayev", "author_id": 10693596, ...
2022/10/31
[ "https://Stackoverflow.com/questions/74269299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2184077/" ]
74,269,320
<p>I have been trying to figure out this mismatched input error and i just cant seem to find it. The error is pointing to line 22 stopDistance = strategy.position_size &gt; 0 ? ((buyPrice - close) / close)</p> <p>`</p> <pre><code>strategy(&quot;My strategy&quot;, overlay=true, initial_capital = 500, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, commission_type = strategy.commission.cash_per_contract, commission_value = .005) i_ma1 = input.int(title = &quot;MA 1 Length&quot;, defval = 200, step = 10, group = &quot;Strategy Parameters&quot;, tooltip = &quot;Long-term MA&quot;) i_ma2 = input.int(title = &quot;MA 2 Length&quot;, defval = 10, step = 10, group = &quot;Strategy Parameters&quot;, tooltip = &quot;Short-term MA&quot;) i_stopPercent = input.float(title = &quot;Stop Loss Percent&quot;, defval = 0.10, step = 0.10, group = &quot;Strategy Parameters&quot;, tooltip = &quot;Failsafe Stop Loss Percent Decline&quot;) i_startTime = input.time(title = &quot;Start Filter&quot;, defval = timestamp(&quot;01 Jan 1995 13:30 +0000&quot;), group = &quot;Time Filter&quot;, tooltip = &quot;Start Date and Time&quot;) i_endTime = input.time(title = &quot;End Filter&quot;, defval = timestamp(&quot;1 Jan 2099 19:30 +0000&quot;), group = &quot;Time Filter&quot;, tooltip = &quot;End Date and Time&quot;) ma1 = ta.sma(close, i_ma1) ma2 = ta.sma(close, i_ma2) f_dateFilter = time &gt;= i_startTime and time &lt;= i_endTime var float buyPrice = 0 buyCondition = close &gt; ma1 and close &lt; ma2 and strategy.position_size == 0 and f_dateFilter sellCondition = close &gt; ma2 and strategy.position_size &gt; 0 stopDistance = strategy.position_size &gt; 0 ? ((buyPrice - close) / close) stopPrice = strategy.position_size &gt; 0 ? buyPrice - (buyPrice * i_stopPercent) stopCondition = strategy.position_size &gt; 0 and stopDistance &gt; i_stopPercent if buyCondition strategy.entry(id=&quot;Long&quot;, direction = strategy.long) if buyCondition[1] buyPrice := open if sellCondition or stopCondition strategy.close(id = &quot;Long&quot;, comment = &quot;Exit&quot; +(stopComdition ? &quot;SL=True&quot; : &quot;&quot;)) buyPrice := na </code></pre> <p>`</p> <p>I have tried searching for indentation errors but i haven't found anything</p>
[ { "answer_id": 74277028, "author": "SultanOrazbayev", "author_id": 10693596, "author_profile": "https://Stackoverflow.com/users/10693596", "pm_score": 2, "selected": false, "text": "pandas" }, { "answer_id": 74284762, "author": "SultanOrazbayev", "author_id": 10693596, ...
2022/10/31
[ "https://Stackoverflow.com/questions/74269320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19253863/" ]
74,269,328
<p>I faced with a problem. I have a simple drf project with car-entrance permits application.</p> <p>views.py `</p> <pre><code>class PermitViewSet(ModelViewSet): queryset = Permit.objects.filter() serializer_class = PermitSerializer filter_backends = [DjangoFilterBackend] filter_fields = ['car_number'] </code></pre> <p>serializers.py `</p> <pre><code>class PermitSerializer(serializers.ModelSerializer): class Meta: model = Permit fields = ['car_number', 'is_active'] </code></pre> <p>models.py `</p> <pre><code>class Permit(models.Model): car_number = models.CharField(max_length=15) customer = models.ForeignKey(User, on_delete=models.CASCADE) created = models.DateTimeField(auto_now_add=True) is_active = models.BooleanField(default=True) </code></pre> <p><code>urls.py</code></p> <pre><code>router = SimpleRouter() router.register(r'permit', PermitViewSet) urlpatterns = [ path('admin/', admin.site.urls), ] urlpatterns += router.urls </code></pre> <p>`</p> <p>i type in my browser <code>http://127.0.0.1:8000/api/v1/permits/?car_number=555</code></p> <p>and i recieve full list of cars `</p> <pre><code>[{&quot;car_number&quot;:&quot;555&quot;,&quot;is_active&quot;:true},{&quot;car_number&quot;:&quot;666&quot;,&quot;is_active&quot;:true},{&quot;car_number&quot;:&quot;777&quot;,&quot;is_active&quot;:true}] </code></pre> <p>` It doesn't work, what's the problem?</p>
[ { "answer_id": 74269384, "author": "Willem Van Onsem", "author_id": 67579, "author_profile": "https://Stackoverflow.com/users/67579", "pm_score": 2, "selected": false, "text": "filterset_fields" }, { "answer_id": 74272530, "author": "Genzo Ito", "author_id": 10227835, ...
2022/10/31
[ "https://Stackoverflow.com/questions/74269328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20382943/" ]
74,269,390
<p>I need to solve this task using library string functions and without them.</p> <p>I solved without special functions:</p> <pre><code>void without_functions(string str) { int* how_many_num = new int[10]; for (int i = 0; i &lt; 10; ++i) how_many_num[i] = 0; for (int i = 0; i &lt; str.size(); ++i) { if (str[i] &gt;= '0' &amp;&amp; str[i] &lt;= '9') { ++how_many_num[int(str[i]) - 48]; } } for (int i = 0; i &lt;= 9; ++i) { if (how_many_num[i] != 0) { cout &lt;&lt; &quot;Digit &quot; &lt;&lt; i &lt;&lt; &quot; is founded&quot; &lt;&lt; how_many_num[i] &lt;&lt; &quot; times&quot; &lt;&lt; endl; } } for (int i = 0; i &lt; str.size(); ++i) { if ((int(str[i]) &gt;= 65 &amp;&amp; int(str[i]) &lt;= 90) || (int(str[i]) &gt;= 97 &amp;&amp; str[i] &lt;= '122')) { str[i] = ' '; } } cout &lt;&lt; endl &lt;&lt; &quot;New string: &quot; &lt;&lt; str &lt;&lt; endl; } </code></pre> <p>I cannot come up with how to implement this task with string functions (methods).</p>
[ { "answer_id": 74269384, "author": "Willem Van Onsem", "author_id": 67579, "author_profile": "https://Stackoverflow.com/users/67579", "pm_score": 2, "selected": false, "text": "filterset_fields" }, { "answer_id": 74272530, "author": "Genzo Ito", "author_id": 10227835, ...
2022/10/31
[ "https://Stackoverflow.com/questions/74269390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20361895/" ]
74,269,393
<p>I have an app that is essentially a random number gen and assigns it to some horse breeds. I need to have a condition that checks if ANY variable AND only 1 variable is equal to 1.</p> <p>I want something like this that assigns the value that is passed to a variable and then checks it to a user-inputted variable</p> <p>I tried to mockup something like this, but it seems to only pass boolean results</p> <pre><code>var balance = '' var target = getText(&quot;horseIn&quot;) var leverage = getNumber(&quot;levIn&quot;) var horses = { Appaloosa: getNumber(&quot;h1pos&quot;), frenchTrotter: getNumber(&quot;h2pos&quot;), Fresian: getNumber(&quot;h3pos&quot;), Hackney: getNumber(&quot;h4pos&quot;), Faflinger: getNumber(&quot;h5pos&quot;), pasoFino: getNumber(&quot;h6pos&quot;), } var winner = null; onEvent(&quot;startM&quot;, &quot;click&quot;, function( ) { setScreen(&quot;selectAmount&quot;); }); onEvent(&quot;submitBet&quot;, &quot;click&quot;, function( ) { if (getNumber(&quot;userAmount&quot;) &gt;0){ setScreen(&quot;horseScreen&quot;); updateScreen(); console.log(horses) while (winner == null) { for (i in horses) { if (horses[i] == 1){ winner = i; } } } } else { setText(&quot;userAmount&quot;,&quot;Please input an amount!&quot;); } console.log(winner) }); function updateScreen(){ setText(&quot;h1pos&quot;, Math.floor(Math.random() * 6) + 1); setText(&quot;h2pos&quot;, Math.floor(Math.random() * 6) + 1); setText(&quot;h3pos&quot;, Math.floor(Math.random() * 6) + 1); setText(&quot;h4pos&quot;, Math.floor(Math.random() * 6) + 1); setText(&quot;h5pos&quot;, Math.floor(Math.random() * 6) + 1); setText(&quot;h6pos&quot;, Math.floor(Math.random() * 6) + 1); } function pnl(){ setScreen(&quot;endScreen&quot;); if (target == winner) { console.log(&quot;Winner&quot;); } } </code></pre> <p>I am setting the variables like this:</p> <pre><code>let Appaloosa = Math.floor(Math.random() * 6) + 1; let frenchTrotter = Math.floor(Math.random() * 6) + 1; let Fresian = Math.floor(Math.random() * 6) + 1; let Hackney = Math.floor(Math.random() * 6) + 1; let Faflinger = Math.floor(Math.random() * 6) + 1; let pasoFino = Math.floor(Math.random() * 6) + 1; </code></pre> <p>so I need to repeat the process if none of them work.</p>
[ { "answer_id": 74270003, "author": "Angel Figuera", "author_id": 20382647, "author_profile": "https://Stackoverflow.com/users/20382647", "pm_score": 1, "selected": false, "text": "function getWinnerHorse() {\n const horses = {\n Appaloosa: 1 === Math.floor(Math.random() * 6) + 1,\n ...
2022/10/31
[ "https://Stackoverflow.com/questions/74269393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17130550/" ]
74,269,395
<p>I am begineer in Android Development. I am making a XML layout but the property of textSize not showing also the code which generated automatically when we type not generating like if we type match then studio will show match_parent that is not generating. How to solve this?</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;// this line is showing in black android:id=&quot;@+id/container&quot; android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;match_parent&quot; android:paddingTop=&quot;?attr/actionBarSize&quot;&gt; &lt;com.google.android.material.bottomnavigation.BottomNavigationView android:id=&quot;@+id/nav_view&quot; android:layout_width=&quot;0dp&quot; android:layout_height=&quot;wrap_content&quot; android:layout_marginStart=&quot;0dp&quot; android:layout_marginEnd=&quot;0dp&quot; android:background=&quot;?android:attr/windowBackground&quot; app:layout_constraintBottom_toBottomOf=&quot;parent&quot; app:layout_constraintLeft_toLeftOf=&quot;parent&quot; app:layout_constraintRight_toRightOf=&quot;parent&quot; app:menu=&quot;@menu/bottom_nav_menu&quot; /&gt; &lt;TextView android:layout_height=&quot;wrap_content&quot; android:layout_width=&quot;match_parent&quot;/&gt; &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt; </code></pre> <p>also when I tried to drag and drop it again not showing attributes of textview like textstyle, textsize etc.</p> <p><a href="https://i.stack.imgur.com/1OOr2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1OOr2.jpg" alt="enter image description here" /></a></p> <p>I am trying to increase my text size but the property in attributes not showing it.</p>
[ { "answer_id": 74270003, "author": "Angel Figuera", "author_id": 20382647, "author_profile": "https://Stackoverflow.com/users/20382647", "pm_score": 1, "selected": false, "text": "function getWinnerHorse() {\n const horses = {\n Appaloosa: 1 === Math.floor(Math.random() * 6) + 1,\n ...
2022/10/31
[ "https://Stackoverflow.com/questions/74269395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16991614/" ]