qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,439,607
<p>I'm trying to save the summary of a model as a data frame in R. The model is a stepwise regression model using the MASS package. I'm primarily interested in saving the coefficients, their t value and the R-squared of the model.</p> <p><a href="https://i.stack.imgur.com/737p0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/737p0.png" alt="Model summary output" /></a></p> <p>I tried</p> <pre><code>ModelSummary &lt;- data.frame(unclass(summary(step.model)), check.names = FALSE, stringsAsFactors = FALSE) </code></pre> <p>But had the error</p> <blockquote> </blockquote> <pre><code>Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) : cannot coerce class ‘&quot;lm&quot;’ to a data.frame </code></pre>
[ { "answer_id": 74439745, "author": "shaun_m", "author_id": 18289387, "author_profile": "https://Stackoverflow.com/users/18289387", "pm_score": 1, "selected": false, "text": "$" }, { "answer_id": 74440453, "author": "Shawn Hemelstrand", "author_id": 16631565, "author_profile": "https://Stackoverflow.com/users/16631565", "pm_score": 3, "selected": true, "text": "broom" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74439607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8730970/" ]
74,439,608
<p>So my endpoint is only expecting this schema:</p> <pre><code>{ A: &quot;number&quot;, B: &quot;number } </code></pre> <p>The sender sends:</p> <pre><code>{ A: &quot;number&quot;, B: &quot;number, C: &quot;number } </code></pre> <p>What do I do with <code>C</code>? What if the sender is my UI, which means that there is a bug in the UI.</p> <p>Are there standard protocols to handle this situation?</p>
[ { "answer_id": 74439745, "author": "shaun_m", "author_id": 18289387, "author_profile": "https://Stackoverflow.com/users/18289387", "pm_score": 1, "selected": false, "text": "$" }, { "answer_id": 74440453, "author": "Shawn Hemelstrand", "author_id": 16631565, "author_profile": "https://Stackoverflow.com/users/16631565", "pm_score": 3, "selected": true, "text": "broom" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74439608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5432156/" ]
74,439,620
<p>Data:</p> <pre><code>import numpy as np import pandas as pd import matplotlib.pyplot as plt data = pd.DataFrame(np.random.normal(size=(15,4))) #Rename columns data.set_axis(['Column A', 'Column B', 'Column C', 'Column D'], axis=1, inplace=True) data Column A Column B Column C Column D 0 0.786186 -0.416792 0.174680 2.487244 1 -0.252369 -0.342730 0.205828 -1.321883 2 -2.000831 -1.710470 1.230441 1.151613 3 1.589489 -0.735494 -1.427740 -0.291532 4 0.162657 0.091248 -1.166623 -1.702915 5 -2.046027 0.538372 1.799922 -1.283141 6 -0.046736 -0.100009 -0.775107 1.778775 7 -0.205502 -1.033712 0.335681 0.178957 8 -0.598907 1.863979 -0.828703 -0.977883 9 -0.532970 -0.964670 -1.618440 0.169850 10 2.123033 0.472480 2.307614 -0.397944 11 1.149670 -0.906352 0.409004 -1.322099 12 0.618216 -1.181656 0.342085 -0.853023 13 -1.108748 -0.546607 -3.468131 -0.382351 14 -0.404277 -1.612273 0.787983 1.033892 #Create figure fig, axs = plt.subplots(2, figsize = (15,15)) #Colors I want to use colors = ['#002072', '#00BDF2'] </code></pre> <p><strong>I want to create a box plot of my data in the axs[0] subplot (the top subplot in the figure I have created) and fill in the bar colors as shown below. Notice how the colors alternate.</strong> I have provided the hex color codes of the colors I want. <strong>I also want to change the color of the median/mean line so that it's easier to see in the dark blue bars.</strong> I really appreciate any help. I've been struggling with this for hours. You would think it would be as simple as passing an argument, but I have not had success with the example code I've found online. I get more confused the more examples I come across.</p> <p>Thank you!</p> <p><a href="https://i.stack.imgur.com/JlQNP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JlQNP.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74439745, "author": "shaun_m", "author_id": 18289387, "author_profile": "https://Stackoverflow.com/users/18289387", "pm_score": 1, "selected": false, "text": "$" }, { "answer_id": 74440453, "author": "Shawn Hemelstrand", "author_id": 16631565, "author_profile": "https://Stackoverflow.com/users/16631565", "pm_score": 3, "selected": true, "text": "broom" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74439620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20188834/" ]
74,439,647
<p>Hi i have a txt file with loads of numbers each number is randomly scattered across the file and when i read the file in as a string and try to subdivide it into individual numbers in an array i get the issue of ie my file contains</p> <pre><code> 1234 3467 22222 </code></pre> <p>i didvide the numbers into string array String sub[] however every number goes into sub[0] ie sub[0] = 1234 3467 22222</p> <p>whereas my desired output for sub[0] would be 1234 my code is below `</p> <pre><code>File file = new File(s); String gg; try { Scanner in = new Scanner(file); while (in.hasNext()) { gg = in.nextLine(); // String temp = gg.replaceAll(&quot;\\s*[\\r\\n]+\\s*&quot;, &quot;&quot;).trim(); String temp = gg.replace('\n', ' '); String[] sub = temp.split(&quot; &quot;); System.out.println(sub[0]); </code></pre> <p>`</p> <p>and the output im getting for sub[0] is a whole bunch of numbers when i only want one which in above example it should be 1234</p> <p>the comment is one of the ways i tried i also tried using .replaceall the char one '\n' but it didnt work and .replaceall &quot;\s&quot;</p>
[ { "answer_id": 74439745, "author": "shaun_m", "author_id": 18289387, "author_profile": "https://Stackoverflow.com/users/18289387", "pm_score": 1, "selected": false, "text": "$" }, { "answer_id": 74440453, "author": "Shawn Hemelstrand", "author_id": 16631565, "author_profile": "https://Stackoverflow.com/users/16631565", "pm_score": 3, "selected": true, "text": "broom" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74439647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,439,663
<p>I want to use data from a list of dictionaries in a string. For example</p> <pre><code>dict = [{'name':'Matt', 'age':'21'},{'name':'Sally','age':'28'}] print(f&quot;His name is {??} and he is {??} years old&quot;) </code></pre> <p>I need to know what to replace the question marks with to make it work.</p> <p>I have looked a lot of stack overflow and found some things, but nothing to get one specific item. I found</p> <pre><code>print([item[&quot;name&quot;]for item in dict]) </code></pre>
[ { "answer_id": 74439745, "author": "shaun_m", "author_id": 18289387, "author_profile": "https://Stackoverflow.com/users/18289387", "pm_score": 1, "selected": false, "text": "$" }, { "answer_id": 74440453, "author": "Shawn Hemelstrand", "author_id": 16631565, "author_profile": "https://Stackoverflow.com/users/16631565", "pm_score": 3, "selected": true, "text": "broom" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74439663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19722528/" ]
74,439,665
<p>I have a basic Web API written in Node.js that writes an object as an HSET to a Redis cache. Both are running in docker containers.</p> <p>I have a Python script running on the same VM which needs to watch the Redis cache and then run some code when there is a new HSET or a change to a field in the HSET.</p> <p>I came across Redis Pub/Sub but I'm not sure if this is really the proper way to use it.</p> <p>To test, I created two Python scripts. The first subscribes to the messaging system:</p> <pre><code>import redis import json print (&quot;Redis Subscriber&quot;) redis_conn = redis.Redis( host='localhost', port=6379, password='xxx', charset=&quot;utf-8&quot;, decode_responses=True) def sub(): pubsub = redis_conn.pubsub() pubsub.subscribe(&quot;broadcast&quot;) for message in pubsub.listen(): if message.get(&quot;type&quot;) == &quot;message&quot;: data = json.loads(message.get(&quot;data&quot;)) print(data) if __name__ == &quot;__main__&quot;: sub() </code></pre> <p>The second publishes to the messaging system:</p> <pre><code>import redis import json print (&quot;Redis Publisher&quot;) redis_conn = redis.Redis( host='localhost', port=6379, password='xxx', charset=&quot;utf-8&quot;, decode_responses=True) def pub(): data = { &quot;message&quot;: &quot;id:3&quot; } redis_conn.publish(&quot;broadcast&quot;, json.dumps(data)) if __name__ == &quot;__main__&quot;: pub() </code></pre> <p>I will rewrite the publisher in Node.js and it will simply published the HSET key, like id:3. Then the subscriber will run in Python and when it received a new message, it will use that HSET key &quot;id:3&quot; to look up the actual HSET and do stuff.</p> <p>This doesn't seem like the right way to do this but Redis watch doesn't support HSET. Is there a better way to accomplish this?</p>
[ { "answer_id": 74439745, "author": "shaun_m", "author_id": 18289387, "author_profile": "https://Stackoverflow.com/users/18289387", "pm_score": 1, "selected": false, "text": "$" }, { "answer_id": 74440453, "author": "Shawn Hemelstrand", "author_id": 16631565, "author_profile": "https://Stackoverflow.com/users/16631565", "pm_score": 3, "selected": true, "text": "broom" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74439665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1624184/" ]
74,439,712
<p><a href="https://i.stack.imgur.com/9daiy.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9daiy.gif" alt="enter image description here" /></a></p> <p>As the GIF above shows, running <code>git log</code> in my WSL2 Ubuntu suddenly became noninteractive. It would show all the logs at once (while the Windows counterpart seemed to be working fine). <code>git</code> has already been updated to the latest version, and this behavior is also present when running WSL2 by itself, i.e., not using the Windows Terminal app. Any ideas on what caused the issue? Any help is appreciated. Thanks!</p>
[ { "answer_id": 74439737, "author": "Noscere", "author_id": 10728583, "author_profile": "https://Stackoverflow.com/users/10728583", "pm_score": 0, "selected": false, "text": "git log" }, { "answer_id": 74439794, "author": "ElpieKay", "author_id": 6330106, "author_profile": "https://Stackoverflow.com/users/6330106", "pm_score": 2, "selected": false, "text": "git -c core.pager=more log" }, { "answer_id": 74442616, "author": "LeGEC", "author_id": 86072, "author_profile": "https://Stackoverflow.com/users/86072", "pm_score": 3, "selected": true, "text": "git config core.pager" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74439712", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7783806/" ]
74,439,722
<p>I was looking at some code which came with the following short-hand statement</p> <pre><code>score = ((initialPlayer == player) ? CAPTURE_SCORE : -CAPTURE_SCORE) + recursive_solver(lastMap, initialPlayer, findOpponent(player), 1 + rounds); </code></pre> <p>I think that I understand the first portion of the code,</p> <pre><code>if(initialPlayer == player){ score = CAPTURE_SCORE; } else score = -CAPTURE_SCORE; </code></pre> <p>but im confused to how the +recursive_solver function is added to this, any help would be greatly appreciated :)</p> <p>As stated above I tried to write out the statement in a longer from thats easier for me to read. My best guess is that the recursive solver function is then added to the score of the if-else statement?</p>
[ { "answer_id": 74439730, "author": "273K", "author_id": 6752050, "author_profile": "https://Stackoverflow.com/users/6752050", "pm_score": 3, "selected": true, "text": "if(initialPlayer == player)\n score = CAPTURE_SCORE + recursive_solver(lastMap, initialPlayer, findOpponent(player), 1 + rounds);\nelse\n score = -CAPTURE_SCORE + recursive_solver(lastMap, initialPlayer, findOpponent(player), 1 + rounds);\n" }, { "answer_id": 74439768, "author": "sxu", "author_id": 19694882, "author_profile": "https://Stackoverflow.com/users/19694882", "pm_score": 0, "selected": false, "text": "score = ((initialPlayer == player) ? CAPTURE_SCORE : -CAPTURE_SCORE) + recursive_solver(lastMap, initialPlayer, findOpponent(player), 1 + rounds);\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74439722", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14965389/" ]
74,439,747
<p>I'm trying to figure out how/if possible to execute a truncate table command in a remote sql server from databricks. I'm using databricks for an ETL script, but it is loading into a remote ms sql server.</p> <p>The original script truncates the table, and then appends repeatedly to it. It truncates it like:</p> <pre><code>engine.execution_options(autocommit=True).execute(&quot;TRUNCATE TABLE my_table;&quot;) </code></pre> <p>I don't know how to replicate that using pyspark. I'm trying to avoid doing something like:</p> <pre><code>first_iteration = True for item in items_to_query: df = f(...) if first_iteration: df.write.option(&quot;mode&quot;,&quot;overwrite&quot;).... first_iteration = False else: df.write.option(&quot;mode&quot;,&quot;append&quot;)... </code></pre> <p>it would be nicer if I could have something like</p> <pre><code>truncate_remote_table(&quot;table&quot;,&quot;database&quot;) for item in items_to_query: df = f(...) df.write.option(&quot;mode&quot;,&quot;append&quot;).... </code></pre> <p>I hope I'm explaining this well. If you want to recommend just doing it completely differently that's fine. Just I work with a lot of people that are (rightfully) frightened/easily spooked about moving the script to databricks, so I'd really like to change as little as possible at each step. Rock and a hard place.</p> <p>I've searched on google, but the search results seem to always start with an existing dataframe and then having it do a mode=&quot;overwrite&quot; to truncate the table. Nothing is just a simple &quot;TRUNCATE TABLE&quot; command.</p>
[ { "answer_id": 74439730, "author": "273K", "author_id": 6752050, "author_profile": "https://Stackoverflow.com/users/6752050", "pm_score": 3, "selected": true, "text": "if(initialPlayer == player)\n score = CAPTURE_SCORE + recursive_solver(lastMap, initialPlayer, findOpponent(player), 1 + rounds);\nelse\n score = -CAPTURE_SCORE + recursive_solver(lastMap, initialPlayer, findOpponent(player), 1 + rounds);\n" }, { "answer_id": 74439768, "author": "sxu", "author_id": 19694882, "author_profile": "https://Stackoverflow.com/users/19694882", "pm_score": 0, "selected": false, "text": "score = ((initialPlayer == player) ? CAPTURE_SCORE : -CAPTURE_SCORE) + recursive_solver(lastMap, initialPlayer, findOpponent(player), 1 + rounds);\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74439747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19871699/" ]
74,439,763
<p>I want to read a text file that contains the following:</p> <pre><code>-------------------- ---+---+---+--+----- -------------+------ ++-----------+------ -+-+----+------+---- -------------------- -----------+-------+ ------+----+-------+ +------------------- --+--------+------+- </code></pre> <p>I want to not only split this data into separate lines, but I want to split it into separate characters as well. For example, I want the data to read into the matrix as follows:</p> <p>[ ['-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'], ['-','-','-','+','-','-','-','+','-','-','-','+''-','-','+','-','-','-','-','-',], ... ] This would end up being a 10 by 20 matrix</p> <p>I am willing and able to use any libraries at my disposal.</p> <p>I have tried looping through the file after reading it, and making a list of characters, and storing the list of characters into a parent list, but this just makes a list of a list, but I want to make a list of many lists (in this case, a list of 10 rows with 20 columns (or characters) in each list)</p>
[ { "answer_id": 74439730, "author": "273K", "author_id": 6752050, "author_profile": "https://Stackoverflow.com/users/6752050", "pm_score": 3, "selected": true, "text": "if(initialPlayer == player)\n score = CAPTURE_SCORE + recursive_solver(lastMap, initialPlayer, findOpponent(player), 1 + rounds);\nelse\n score = -CAPTURE_SCORE + recursive_solver(lastMap, initialPlayer, findOpponent(player), 1 + rounds);\n" }, { "answer_id": 74439768, "author": "sxu", "author_id": 19694882, "author_profile": "https://Stackoverflow.com/users/19694882", "pm_score": 0, "selected": false, "text": "score = ((initialPlayer == player) ? CAPTURE_SCORE : -CAPTURE_SCORE) + recursive_solver(lastMap, initialPlayer, findOpponent(player), 1 + rounds);\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74439763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20505729/" ]
74,439,769
<p>I am following the example for terra::intersect</p> <pre><code>library(terra) f &lt;- system.file(&quot;ex/lux.shp&quot;, package=&quot;terra&quot;) v &lt;- vect(f) e &lt;- ext(5.6, 6, 49.55, 49.7) x &lt;- intersect(v, e) p &lt;- vect(c(&quot;POLYGON ((5.8 49.8, 6 49.9, 6.15 49.8, 6 49.6, 5.8 49.8))&quot;, &quot;POLYGON ((6.3 49.9, 6.2 49.7, 6.3 49.6, 6.5 49.8, 6.3 49.9))&quot;), crs=crs(v)) values(p) &lt;- data.frame(pid=1:2, area=expanse(p)) y &lt;- intersect(v, p) </code></pre> <p>and what I ultimately want it so summarise the land area of all the polygons created by joining p and v. What I mean is, for each polygon in p, how many ha of polygon is in Diekirch, Grevenmacher, and Luxembourg.</p> <p>I try this:</p> <pre><code>lapply(y, FUN=expanse, unit=&quot;ha&quot;) expanse(v) yy &lt;- union(v,p) lapply(yy, FUN=expanse, unit=&quot;ha&quot;) </code></pre> <p>but in both cases, expanse returns the same values as</p> <pre><code>expanse(v) </code></pre>
[ { "answer_id": 74439730, "author": "273K", "author_id": 6752050, "author_profile": "https://Stackoverflow.com/users/6752050", "pm_score": 3, "selected": true, "text": "if(initialPlayer == player)\n score = CAPTURE_SCORE + recursive_solver(lastMap, initialPlayer, findOpponent(player), 1 + rounds);\nelse\n score = -CAPTURE_SCORE + recursive_solver(lastMap, initialPlayer, findOpponent(player), 1 + rounds);\n" }, { "answer_id": 74439768, "author": "sxu", "author_id": 19694882, "author_profile": "https://Stackoverflow.com/users/19694882", "pm_score": 0, "selected": false, "text": "score = ((initialPlayer == player) ? CAPTURE_SCORE : -CAPTURE_SCORE) + recursive_solver(lastMap, initialPlayer, findOpponent(player), 1 + rounds);\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74439769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5108251/" ]
74,439,781
<p>How to Make transparent background on canvas android.?</p> <p>I want to make a transparent background like this (see picture), does this kind of background use a bitmap?</p> <p><a href="https://i.stack.imgur.com/gfh3O.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gfh3O.jpg" alt="background like pixels" /></a></p>
[ { "answer_id": 74439730, "author": "273K", "author_id": 6752050, "author_profile": "https://Stackoverflow.com/users/6752050", "pm_score": 3, "selected": true, "text": "if(initialPlayer == player)\n score = CAPTURE_SCORE + recursive_solver(lastMap, initialPlayer, findOpponent(player), 1 + rounds);\nelse\n score = -CAPTURE_SCORE + recursive_solver(lastMap, initialPlayer, findOpponent(player), 1 + rounds);\n" }, { "answer_id": 74439768, "author": "sxu", "author_id": 19694882, "author_profile": "https://Stackoverflow.com/users/19694882", "pm_score": 0, "selected": false, "text": "score = ((initialPlayer == player) ? CAPTURE_SCORE : -CAPTURE_SCORE) + recursive_solver(lastMap, initialPlayer, findOpponent(player), 1 + rounds);\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74439781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13785339/" ]
74,439,793
<p>I am using nextcord and I am trying to check if a user has a role when they run a command. I have no idea how to do this so I cannot provide an MRE. I imagine that the code will be something like this:</p> <pre class="lang-py prettyprint-override"><code>@client.slash_command(name=&quot;test&quot;) async def test(interaction:nextcord.Interaction): if interaction.user.has_role(&quot;Cool&quot;): await interaction.send(&quot;You are cool!&quot;) else: await interaction.send(&quot;You are not cool.&quot;) </code></pre>
[ { "answer_id": 74448440, "author": "Sam Shields", "author_id": 19261069, "author_profile": "https://Stackoverflow.com/users/19261069", "pm_score": 1, "selected": false, "text": "from nextcord.utils import get\n\nrole = get(ctx.guild.roles, name='search for role by name')\n\nif interaction.user in role:\n do something\nelse:\n do a different thing\n" }, { "answer_id": 74469006, "author": "Anthony", "author_id": 19779047, "author_profile": "https://Stackoverflow.com/users/19779047", "pm_score": 1, "selected": true, "text": "@client.slash_command(name=\"check_role\", description=\"Check if a user has a role\", guild_ids=GUILD_IDS)\nasync def check_role(interaction:nextcord.Interaction, user:nextcord.Member):\n if nextcord.utils.get(interaction.guild.roles, name=\"Role Name\") in user.roles:\n await interaction.send(\"True!\")\n else:\n await interaction.send(\"False.\")\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74439793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19779047/" ]
74,439,795
<p>I have a dataset with varying observations per ID, and these participants are also in different treatment status (Group). I wonder if I can use proc means to quickly calculate the number of participants and visits to clinic per group status by using proc means? Ideally, I can use proc means sum function quickly capture those with 0 and 1 based on group status and gain the total number? However, I got stuck in how to proceed.</p> <pre><code>ID Visit Group 1 1 0 1 2 0 2 1 1 2 2 1 2 3 1 3 1 0 4 1 1 4 2 1 5 1 0 5 2 0 6 1 1 6 2 1 6 3 1 6 4 1 </code></pre> <p>Specifically, I am interested in 1) the total number of participants in each group status. In this case we can 3 participants (ID:1,3,and 5)in the control group (0) and another 3 participants (ID:2,4,and 6) in the treatment group (1). 2) the total number of visits per group status. In this case, the total visits in the control group (0) will be 5 (2+1+2=5) and the total visits in the treatment group (1) will be 9 (3+2+4=9). I wonder if proc means procedure can help quickly calculate such values? Thanks.</p>
[ { "answer_id": 74448440, "author": "Sam Shields", "author_id": 19261069, "author_profile": "https://Stackoverflow.com/users/19261069", "pm_score": 1, "selected": false, "text": "from nextcord.utils import get\n\nrole = get(ctx.guild.roles, name='search for role by name')\n\nif interaction.user in role:\n do something\nelse:\n do a different thing\n" }, { "answer_id": 74469006, "author": "Anthony", "author_id": 19779047, "author_profile": "https://Stackoverflow.com/users/19779047", "pm_score": 1, "selected": true, "text": "@client.slash_command(name=\"check_role\", description=\"Check if a user has a role\", guild_ids=GUILD_IDS)\nasync def check_role(interaction:nextcord.Interaction, user:nextcord.Member):\n if nextcord.utils.get(interaction.guild.roles, name=\"Role Name\") in user.roles:\n await interaction.send(\"True!\")\n else:\n await interaction.send(\"False.\")\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74439795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17413705/" ]
74,439,831
<blockquote> <p>Hi,</p> </blockquote> <p>I'm trying to build an app using Tailwind and NextJs with some style in SCSS. Everything was working find and I was tweaking some Tailwind class in my components until the app suddenly crashed with this message</p> <blockquote> <p>./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[3].oneOf[10].use[1]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[3].oneOf[10].use[2]!./node_modules/next/dist/build/webpack/loaders/resolve-url-loader/index.js??ruleSet[1].rules[3].oneOf[10].use[3]!./node_modules/next/dist/compiled/sass-loader/cjs.js??ruleSet[1].rules[3].oneOf[10].use[4]!./styles/globals.scss TypeError: Cannot read properties of undefined (reading '5')</p> </blockquote> <p>It appeared just like this, it worked for 3 hours and then just stopped, I did not changed any config files or anything else. I don't understand. After some time looking trough my code I've found that if I remove these import at the top of my global.scss the app works fine, but I don't know where this undefined variable is..</p> <blockquote> <p>@tailwind base; @tailwind components; @tailwind utilities;</p> </blockquote> <p>here is my tailwind config</p> <pre><code>module.exports = { purge: ['./pages/**/*.{js,ts,jsx,tsx}', './components/**/*.{js,ts,jsx,tsx}'], darkMode: false, theme: { extend: { spacing: { '2/3': '66.666667%', }, colors: { 'lavander-grey': '#625F63', 'lavander-indigo': '#9893DA' }, }, }, variants: { extend: {}, }, plugins: [], }; </code></pre> <pre><code> package.json </code></pre> <pre><code> &quot;engines&quot;: { &quot;node&quot;: &quot;&gt;=14.0&quot; }, &quot;engineStrict&quot;: true, &quot;scripts&quot;: { &quot;dev&quot;: &quot;next dev&quot;, &quot;build&quot;: &quot;next build&quot;, &quot;start&quot;: &quot;next start&quot;, &quot;lint&quot;: &quot;next lint&quot; }, &quot;dependencies&quot;: { &quot;graphql&quot;: &quot;^16.6.0&quot;, &quot;graphql-request&quot;: &quot;^5.0.0&quot;, &quot;html-react-parser&quot;: &quot;^3.0.4&quot;, &quot;moment&quot;: &quot;^2.29.4&quot;, &quot;next&quot;: &quot;13.0.3&quot;, &quot;react&quot;: &quot;18.2.0&quot;, &quot;react-dom&quot;: &quot;18.2.0&quot;, &quot;react-multi-carousel&quot;: &quot;^2.8.2&quot;, &quot;sass&quot;: &quot;^1.56.1&quot;, &quot;swr&quot;: &quot;^1.3.0&quot; }, &quot;devDependencies&quot;: { &quot;autoprefixer&quot;: &quot;^10.4.13&quot;, &quot;eslint&quot;: &quot;^8.27.0&quot;, &quot;eslint-config-airbnb&quot;: &quot;^19.0.4&quot;, &quot;eslint-config-next&quot;: &quot;13.0.3&quot;, &quot;eslint-plugin-import&quot;: &quot;^2.26.0&quot;, &quot;eslint-plugin-jsx-a11y&quot;: &quot;^6.6.1&quot;, &quot;eslint-plugin-react&quot;: &quot;^7.31.10&quot;, &quot;eslint-plugin-react-hooks&quot;: &quot;^4.6.0&quot;, &quot;postcss&quot;: &quot;^8.4.19&quot;, &quot;tailwindcss&quot;: &quot;^3.2.4&quot; </code></pre> <p>Postcss.config.js</p> <pre><code></code></pre> <pre><code>module.exports = { plugins: { tailwindcss: {}, autoprefixer: {}, }, } </code></pre> <pre><code> thanks for your help I've tried to install some older Tailwind packages, wiped node_modules, made sure this was not my components the culprit, tried some Tailwind configurations,started a fresh dev server, did some intense googling </code></pre>
[ { "answer_id": 74448440, "author": "Sam Shields", "author_id": 19261069, "author_profile": "https://Stackoverflow.com/users/19261069", "pm_score": 1, "selected": false, "text": "from nextcord.utils import get\n\nrole = get(ctx.guild.roles, name='search for role by name')\n\nif interaction.user in role:\n do something\nelse:\n do a different thing\n" }, { "answer_id": 74469006, "author": "Anthony", "author_id": 19779047, "author_profile": "https://Stackoverflow.com/users/19779047", "pm_score": 1, "selected": true, "text": "@client.slash_command(name=\"check_role\", description=\"Check if a user has a role\", guild_ids=GUILD_IDS)\nasync def check_role(interaction:nextcord.Interaction, user:nextcord.Member):\n if nextcord.utils.get(interaction.guild.roles, name=\"Role Name\") in user.roles:\n await interaction.send(\"True!\")\n else:\n await interaction.send(\"False.\")\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74439831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11951973/" ]
74,439,839
<p>I am building a web application, some HTML elements might take some time to be fetched. So I decided to render the layout of the element, without the data from the backend. But I want to indicate to the user, that the data is loading with a CSS animation. I want it to look like this, but I want the transition of the color change to be smooth so that the lighter area travels from one side to the other. Any ideas?</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>body { animation: 2000ms infinite color-loading; } @keyframes color-loading { 0% { background: linear-gradient( to right, #363644, #282933 ); } 100% { background: linear-gradient( to right, #282933, #363644 ); } }</code></pre> </div> </div> </p>
[ { "answer_id": 74439924, "author": "Kairav Thakar", "author_id": 20447312, "author_profile": "https://Stackoverflow.com/users/20447312", "pm_score": 0, "selected": false, "text": "animation-timing-function" }, { "answer_id": 74440106, "author": "AtomicUs5000", "author_id": 17934914, "author_profile": "https://Stackoverflow.com/users/17934914", "pm_score": 1, "selected": false, "text": ".div1 {\n display: block;\n width: 200px;\n height: 20px;\n background-color: #282933;\n overflow: hidden;\n}\n.div2 {\n display: block;\n width: 700px;\n height: 20px;\n background: \n linear-gradient(\n to right, \n rgba(255, 255, 255, 0) 0%, \n rgba(255, 255, 255, 0) 40%, \n rgba(255, 255, 255, 0.5) 50%, \n rgba(255, 255, 255, 0) 60%, \n rgba(255, 255, 255, 0) 100%\n );\n position:relative;\n left: -700px;\n animation: color-loading 2000ms ease 0s normal infinite none;\n}\n@keyframes color-loading {\n 0% {\n left: -700px;\n }\n 100% {\n left: 0px;\n }\n}\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74439839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17744228/" ]
74,439,850
<p>I'm using WordPress with ACF, and I need to use a value of custom fields for CSS. For example, if the value of ACF 'Name' is YES, then CSS style just background around that field, if the value of the field is NO, then the background will be red.</p>
[ { "answer_id": 74440842, "author": "Monzur Alam", "author_id": 11748128, "author_profile": "https://Stackoverflow.com/users/11748128", "pm_score": 1, "selected": false, "text": "<?php\n// Get field data\n$data = get_field('wifi');\nif( 'yes' == $data ){\n ?>\n <style>\n .entry-title{\n color: green;\n } \n </style>\n <?php\n}else{\n ?>\n <style>\n .entry-title{\n color: red;\n } \n </style>\n <?php\n}\n?>\n" }, { "answer_id": 74446310, "author": "Riccardo LV", "author_id": 19921297, "author_profile": "https://Stackoverflow.com/users/19921297", "pm_score": 0, "selected": false, "text": ".no_wifi {\n background-color: red;\n}\n.wifi {\n background-color: green;\n}" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74439850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9214388/" ]
74,439,916
<p>I am currently trying to add a delete and edit button on each row of a table, I currently am able to make the buttons run the functions just fine but the big issue i am having is that I cannot for the life of me figure out how to get the id of that row and make it into a variable for me to plug into the function.`</p> <pre><code> function deletePet() { fetch(&quot;http://localhost:3001/api?act=delete&amp;id=&quot;+pet.id+&quot;&quot;) .then(res =&gt; res.json()) .then( (result) =&gt; { fetchPets(); }) } function updatePet() { fetch(&quot;http://localhost:3001/api?act=update&amp;id=2&amp;animal=&quot; + name + &quot;&amp;description=&quot;+desc+&quot;&amp;age=&quot;+age+&quot;&amp;price=&quot;+price+&quot;&quot;) .then(res =&gt; res.json()) .then( (result) =&gt; { fetchPets(); }); } return (&lt;div&gt; &lt;table&gt; &lt;tbody&gt; &lt;tr&gt; &lt;th&gt;Animal&lt;/th&gt; &lt;th&gt;Description&lt;/th&gt; &lt;th&gt;Age&lt;/th&gt; &lt;th&gt;Price&lt;/th&gt; &lt;th&gt;Action&lt;/th&gt; &lt;/tr&gt; {pets.map(pet =&gt; ( &lt;tr key={pet.id}&gt; &lt;td&gt;{pet.animal}&lt;/td&gt; &lt;td&gt;{pet.description}&lt;/td&gt; &lt;td&gt;{pet.age}&lt;/td&gt; &lt;td&gt;{pet.price}&lt;/td&gt; &lt;td&gt;&lt;Button variant=&quot;contained&quot; onClick={updatePet}&gt;Edit&lt;/Button&gt;&lt;Button variant=&quot;contained&quot; onClick={deletePet}&gt;Delete&lt;/Button&gt;&lt;/td&gt; &lt;/tr&gt; ))} </code></pre> <p>so basically I want to click on the delete button on x row and I want it to be deleted with the delete pet function as you can see I tried just putting in pet.id (which obviously doesnt work hahahaha). Any help will be appreciated!</p> <p>I have tried to make the key into a variable and the pet.id into a variable within the table, as well as create a nested function within the button that will just remove the row but that also didnt work.</p>
[ { "answer_id": 74439959, "author": "Franco Gabriel", "author_id": 19499461, "author_profile": "https://Stackoverflow.com/users/19499461", "pm_score": -1, "selected": true, "text": "onClick={() => deletePet(pet.id)}" }, { "answer_id": 74439968, "author": "Bikas Lin", "author_id": 17582798, "author_profile": "https://Stackoverflow.com/users/17582798", "pm_score": 0, "selected": false, "text": "function deletePet(pet) {\n // do some with pet\n}\n\nfunction updatePet(pet) {\n // do some with pet\n} \n\n... ... ...\n\n<td><Button variant=\"contained\" onClick={() => updatePet(pet)}>Edit</Button><Button variant=\"contained\" onClick={() => deletePet(pet)}>Delete</Button></td>\n \n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74439916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14297891/" ]
74,439,994
<p>I have a function that takes data from a 2D array and stores it in a Hashmap. I just want to know that how can I input a 2D int array correctly in my main function. Here is what I have so far:</p> <pre><code>public class Sorted { public static void countSort(List&lt;List&lt;Integer&gt;&gt; inputData) { Map&lt;Integer, List&lt;Integer&gt;&gt; dataAsMap = new HashMap&lt;&gt;(); for(List&lt;Integer&gt; row : inputData) { Integer id = row.get(0); Integer item = row.get(1); List&lt;Integer&gt; rowInMap = dataAsMap.get(item); if (rowInMap == null) { rowInMap = new ArrayList&lt;&gt;(); dataAsMap.put(item, rowInMap); } rowInMap.add(id); } } public static void main(String[] args) { int[][] newArray = {{ 1, 2, 3}, {101, 102, 103}}; Arrays.countSort(newArray); } } </code></pre> <p>Unless you haven't noticed already, this code wouldn't even compile. I believe that <code>[[1, 2, 3], [100, 101, 102]]</code> is indeed a 2D integer array but my issue is that I have no idea how to implement it in the <code>countsort()</code> function. Can anyone please help?</p>
[ { "answer_id": 74439959, "author": "Franco Gabriel", "author_id": 19499461, "author_profile": "https://Stackoverflow.com/users/19499461", "pm_score": -1, "selected": true, "text": "onClick={() => deletePet(pet.id)}" }, { "answer_id": 74439968, "author": "Bikas Lin", "author_id": 17582798, "author_profile": "https://Stackoverflow.com/users/17582798", "pm_score": 0, "selected": false, "text": "function deletePet(pet) {\n // do some with pet\n}\n\nfunction updatePet(pet) {\n // do some with pet\n} \n\n... ... ...\n\n<td><Button variant=\"contained\" onClick={() => updatePet(pet)}>Edit</Button><Button variant=\"contained\" onClick={() => deletePet(pet)}>Delete</Button></td>\n \n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74439994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18984687/" ]
74,439,998
<p>I am trying to achieve a loop with the condition but no luck yet. Just trying if host name is A then add 1.1.1.1 ip address in commands and if host name of the device is B then add 2.2.2.2 ip address.</p> <p>Can you please help.</p> <pre><code> - name: logs ios_command: commands: - show ip bgp vpnv4 vrf SIG neighbors {{item.ip}} routes - show ip bgp vpnv4 vrf SIG neighbors {{item.ip}} advertised-routes register: grx_cfg when: &quot;item.when&quot; with_items: - { ip: '1.1.1.1', when &quot;{{ ansible_host =='A' }}&quot; } - { ip: '2.2.2.2', when &quot;{{ ansible_host =='B' }}&quot; } </code></pre>
[ { "answer_id": 74439959, "author": "Franco Gabriel", "author_id": 19499461, "author_profile": "https://Stackoverflow.com/users/19499461", "pm_score": -1, "selected": true, "text": "onClick={() => deletePet(pet.id)}" }, { "answer_id": 74439968, "author": "Bikas Lin", "author_id": 17582798, "author_profile": "https://Stackoverflow.com/users/17582798", "pm_score": 0, "selected": false, "text": "function deletePet(pet) {\n // do some with pet\n}\n\nfunction updatePet(pet) {\n // do some with pet\n} \n\n... ... ...\n\n<td><Button variant=\"contained\" onClick={() => updatePet(pet)}>Edit</Button><Button variant=\"contained\" onClick={() => deletePet(pet)}>Delete</Button></td>\n \n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74439998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11634220/" ]
74,440,014
<p>Let's say I have table A with an alphanumeric string primary key. The code used to create the table and how the table looks are shown below.</p> <pre><code>CREATE TABLE A ( ID CHAR(7) NOT NULL, ... CONSTRAINT PK_A PRIMARY KEY (ID) ) </code></pre> <pre><code>| ID | ... | | -------- | -------- | | C000001 | ... | | C000002 | ... | </code></pre> <p>I want to insert a new row into Table A and I don't want to type out <code>C000003</code> or <code>C000004</code> every time. Is there a way to auto increment this?</p> <p>I have thought about getting the latest id using</p> <pre><code>select top 1 CustId from Customer order by CustId desc </code></pre> <p>For splitting, I used <code>SUBSTRING(ID, 2, 7)</code>. For joining back, I can use <code>concat('C', ID + 1)</code>.</p> <p>The issue is, if I add one to the numeric portion, it would give me 3 instead of 000003. Is there a way to save the 0's?</p> <p>I just need help with incrementing.</p> <p>My current code is like this:</p> <pre><code>declare @lastid varchar(7), @newID varchar(7) set @lastid = (select top 1 ID from A order by ID desc) set @newID = SUBSTRING(@lastid, 2, 7) select CONCAT('C', @newID + 1) -- need help with the increment </code></pre> <p>Any help appreciated</p> <p><strong>EDIT 1:</strong> If the numbers are less than 10 (ie one digit), I can manually add in 0's to fill up the gaps. But if the number has 2 digits or more, I can't do that so I'm thinking of a solution for this.</p>
[ { "answer_id": 74440105, "author": "Parth M. Dave", "author_id": 12119351, "author_profile": "https://Stackoverflow.com/users/12119351", "pm_score": -1, "selected": false, "text": "Insert into stminternal values(1,'C',6,0)\n" }, { "answer_id": 74440841, "author": "marc_s", "author_id": 13302, "author_profile": "https://Stackoverflow.com/users/13302", "pm_score": 2, "selected": true, "text": "SELECT MAX() + 1" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20505744/" ]
74,440,023
<p>I was taking a lesson on Udemy about inputs and dropdown buttons for bootstrap. The lesson was well until I decided to try and make a simple selection of albums for one of my favorite artists. The buttons separate from each other the moment I try getting them to the center underneath the photo of the artist. Can someone please tell me where I went wrong?</p> <p>I tried several things to have the buttons together. I tried mx-auto, justify-content-center, margins, and nothing really worked for me. Here is my code</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css"&gt; &lt;script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"&gt;&lt;/script&gt; &lt;div class="container mt-3"&gt; &lt;div class="row justify-content-center"&gt; &lt;form&gt; &lt;div class="mb-3"&gt; &lt;div class="input-group flex-nowrap"&gt; &lt;div class="mx-auto d-block"&gt; &lt;img class="mx-auto d-block" src="https://yt3.ggpht.com/7tCfeCWH4arhsTM-4Rz4IxWieQbegzibeXlG-kbytAujdk5dr2K0gBb8NG0Cvk6lB1dPkjyd=s900-c-k-c0x00ffffff-no-rj" width="250px" height="250px" alt=""&gt; &lt;div class="input-group"&gt; &lt;button class="btn btn-dark m-3"&gt;Bad Bunny Albums&lt;/button&gt; &lt;button class="mx-auto d-block btn btn-dark dropdown-toggle dropdown-toggle-split m-3" type="button" data-bs-toggle="dropdown"&gt; &lt;span class="visually-hidden"&gt;Dropdown&lt;/span&gt; &lt;/button&gt; &lt;ul class="dropdown-menu"&gt; &lt;li&gt;&lt;a class="dropdown-item" href="#"&gt;X 100pre&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a class="dropdown-item" href="#"&gt;Oasis&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a class="dropdown-item" href="#"&gt;YHLQMDLG&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a class="dropdown-item" href="#"&gt;Las que no iban a salir&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a class="dropdown-item" href="#"&gt;El Ultimo Tour Del Mundo&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a class="dropdown-item" href="#"&gt;Un Verano Sin Ti&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74441612, "author": "Kairav Thakar", "author_id": 20447312, "author_profile": "https://Stackoverflow.com/users/20447312", "pm_score": 1, "selected": false, "text": "<div class=\"input-group justify-content-center\">\n <button class=\"btn btn-dark m-0\">Bad Bunny Albums</button>\n <button class=\"d-block btn btn-dark dropdown-toggle dropdown-toggle-split m-0\" type=\"button\" data-bs-toggle=\"dropdown\" aria-expanded=\"false\">\n <span class=\"visually-hidden\">Dropdown</span>\n </button>\n <ul class=\"dropdown-menu\" style=\"\">\n <li><a class=\"dropdown-item\" href=\"#\">X 100pre</a></li>\n <li><a class=\"dropdown-item\" href=\"#\">Oasis</a></li>\n <li><a class=\"dropdown-item\" href=\"#\">YHLQMDLG</a></li>\n <li><a class=\"dropdown-item\" href=\"#\">Las que no iban a salir</a></li>\n <li><a class=\"dropdown-item\" href=\"#\">El Ultimo Tour Del Mundo</a></li>\n <li><a class=\"dropdown-item\" href=\"#\">Un Verano Sin Ti</a></li>\n </ul>\n</div>\n" }, { "answer_id": 74444002, "author": "Hemant Singh Yadav", "author_id": 20470646, "author_profile": "https://Stackoverflow.com/users/20470646", "pm_score": 2, "selected": false, "text": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta content=\"IE=edge\" http-equiv=\"X-UA-Compatible\">\n <meta content=\"width=device-width, initial-scale=1.0\" name=\"viewport\">\n <title>Document</title>\n <link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css\" rel=\"stylesheet\">\n <script crossorigin=\"anonymous\"\n integrity=\"sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p\"\n src=\"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js\"></script>\n</head>\n<body>\n<div class=\"container mt-3\">\n <div class=\"row justify-content-center\">\n <form>\n <div class=\"mb-3\">\n <div class=\"input-group flex-nowrap\">\n <div class=\"mx-auto d-block\">\n <img alt=\"\"\n class=\"mx-auto d-block\"\n height=\"250px\" src=\"https://yt3.ggpht.com/7tCfeCWH4arhsTM-4Rz4IxWieQbegzibeXlG-kbytAujdk5dr2K0gBb8NG0Cvk6lB1dPkjyd=s900-c-k-c0x00ffffff-no-rj\" width=\"250px\">\n <div class=\"input-group\">\n <button class=\"btn btn-dark m-3 me-0\">Bad Bunny Albums</button>\n <button\n class=\"mx-auto d-block btn btn-dark dropdown-toggle dropdown-toggle-split m-3 ms-0\"\n data-bs-toggle=\"dropdown\"\n type=\"button\">\n <span class=\"visually-hidden\">Dropdown</span>\n </button>\n <ul class=\"dropdown-menu\">\n <li><a class=\"dropdown-item\" href=\"#\">X 100pre</a></li>\n <li><a class=\"dropdown-item\" href=\"#\">Oasis</a></li>\n <li><a class=\"dropdown-item\" href=\"#\">YHLQMDLG</a></li>\n <li><a class=\"dropdown-item\" href=\"#\">Las que no iban a salir</a></li>\n <li><a class=\"dropdown-item\" href=\"#\">El Ultimo Tour Del Mundo</a></li>\n <li><a class=\"dropdown-item\" href=\"#\">Un Verano Sin Ti</a></li>\n </ul>\n </div>\n </div>\n </div>\n </div>\n </form>\n </div>\n</div>\n</body>\n</html>" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17391992/" ]
74,440,043
<p>EDIT: the original title of this question was '<strong>Unable to multiply two python arrays together</strong>',and the corresponding question is below. The error arose from the fact that list2 contained data that had implicit units of 'astropy.Time' and each element in the list was a 'time object'. The answer provided is a standard quick fix to enable regular numpy operations to be performed on such data (e.g., in the below case, where the time series output was from a lightkurve process)</p> <p>I have two lists of numpy arrays in Python, one of which has 36 elements and the other one has 5, i.e.</p> <pre><code>list1 = [array1, array2, array3, array4, array5], list2 = [arrayA, arrayB, arrayC, arrayD, ...] </code></pre> <p>I am trying to multiply every element in list2 by, for instance, element 0 in list 1 (so array1 * list2). However, no matter how I try to implement this (for loop, while loop), Python returns the error '<em>Fatal Python error: Segmentation fault</em>'. The same thing happens even if I try the test case: <code>list1[0]*list2[0]</code>, or alternatively, <code>np.multiply(list1[0], list2[0])</code> I have checked the length and dimensions of all the pertaining elements and they all are the same as each other (they're both 1D numpy arrays, and for e.g. <code>len(list1[0]) = 2000</code> and <code>len(list2[0]) = 2000</code> ), so I'm really confused on why I can't perform this basic multiplication? I am using the Spyder IDE, if that makes any difference, and would be super grateful for any advice, thanks!</p>
[ { "answer_id": 74440085, "author": "R Walser", "author_id": 17889492, "author_profile": "https://Stackoverflow.com/users/17889492", "pm_score": 0, "selected": false, "text": "np.outer" }, { "answer_id": 74443981, "author": "Robby", "author_id": 20505964, "author_profile": "https://Stackoverflow.com/users/20505964", "pm_score": 1, "selected": false, "text": "converted_times = []\n\nfor i in range(len(list2)):\n newlist = [x.to_value('jd') for x in list2[i]]\n converted_times.append(newlist)\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20505964/" ]
74,440,063
<p>I enabled the skip login, wherein I am not able to get the email of the account I was logged in to.</p> <p>How can I still get the email if skip login is enabled in the second launch of the app?</p>
[ { "answer_id": 74441156, "author": "Priyanka Singhal", "author_id": 9148371, "author_profile": "https://Stackoverflow.com/users/9148371", "pm_score": 0, "selected": false, "text": "AppPreferences.INSTANCE.initAppPreferences(ActivityName.this);\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20506025/" ]
74,440,090
<p>How can i put the number after calculated on the text view?? i can share more files if needed</p> <pre><code> fun calcularIdade() { val editTextHello = findViewById&lt;TextInputEditText&gt;(R.id.Date) var num= Integer.parseInt(editTextHello.toString()) num = 2022-num Toast.makeText(this, editTextHello.text, Toast.LENGTH_SHORT).show() findViewById&lt;TextView&gt;(R.id.textView1).setText(num.toString()) } } </code></pre> <pre><code> &lt;com.google.android.material.textfield.TextInputEditText android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;wrap_content&quot; android:id=&quot;@+id/Date&quot; android:hint=&quot;“Escreva o seu ano de nascimento!”&quot; android:inputType=&quot;number&quot;/&gt; &lt;/com.google.android.material.textfield.TextInputLayout&gt; &lt;LinearLayout android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;wrap_content&quot; android:layout_below=&quot;@id/textDT&quot; android:layout_marginStart=&quot;10dp&quot; android:layout_marginTop=&quot;10dp&quot; android:layout_marginEnd=&quot;10dp&quot; android:layout_marginBottom=&quot;10dp&quot; android:orientation=&quot;horizontal&quot;&gt; &lt;TextView android:id=&quot;@+id/textView1&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; android:layout_marginEnd=&quot;10dp&quot; android:layout_weight=&quot;1&quot; android:text=&quot;TextView&quot; /&gt; &lt;Button android:id=&quot;@+id/B1&quot; android:onClick=&quot;calcularIdade&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; android:layout_marginStart=&quot;10dp&quot; android:layout_weight=&quot;1&quot; android:text=&quot;Calcular&quot; /&gt; &lt;/LinearLayout&gt; &lt;/RelativeLayout&gt; </code></pre> <p><a href="https://i.stack.imgur.com/YV2vi.png" rel="nofollow noreferrer">activity_data_nascimento.xml</a> <a href="https://i.stack.imgur.com/Vp4BV.png" rel="nofollow noreferrer">mainactivity</a></p> <p>Android Studio</p> <p>Need to set a number on the text view after calculating I have tried everything but i cant my main problem is change the value from string to integer calculate and then write the value on the text view</p>
[ { "answer_id": 74440873, "author": "Kunu", "author_id": 3022836, "author_profile": "https://Stackoverflow.com/users/3022836", "pm_score": 1, "selected": false, "text": "var num= Integer.parseInt(editTextHello.text.toString())" }, { "answer_id": 74442349, "author": "Nrohpos", "author_id": 11082213, "author_profile": "https://Stackoverflow.com/users/11082213", "pm_score": 1, "selected": true, "text": "val num = editTextHello.text.toString().toInt()\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20505991/" ]
74,440,092
<p>I'm a noob, learning via Datacamp (which is really annoying and nitpicky... I could've sworn elements started from 0, counting the first element in the list as 0???? This is the problem.</p> <p>&quot;Create downstairs again, as the first 6 elements of areas. This time, simplify the slicing by omitting the begin index. Create upstairs again, as the last 4 elements of areas. This time, simplify the slicing by omitting the end index.</p> <p>I answered with</p> <pre><code># Create the areas list areas = [&quot;hallway&quot;, 11.25, &quot;kitchen&quot;, 18.0, &quot;living room&quot;, 20.0, &quot;bedroom&quot;, 10.75, &quot;bathroom&quot;, 9.50] # Alternative slicing to create downstairs downstairs = areas[:-4] # Alternative slicing to create upstairs upstairs = areas[5:] </code></pre> <p>*<em><strong>edited to include areas as I did answer with &quot;areas&quot;</strong></em></p> <p>Obviously this is wrong... but I could've sworn I just went through previous questions correctly..... starting with 0... as a rep of the first element... is this different when slicing? Thank you, if you have any resources for better study I would like to understand the syntax of this language better to become more intuitive with it.</p>
[ { "answer_id": 74440873, "author": "Kunu", "author_id": 3022836, "author_profile": "https://Stackoverflow.com/users/3022836", "pm_score": 1, "selected": false, "text": "var num= Integer.parseInt(editTextHello.text.toString())" }, { "answer_id": 74442349, "author": "Nrohpos", "author_id": 11082213, "author_profile": "https://Stackoverflow.com/users/11082213", "pm_score": 1, "selected": true, "text": "val num = editTextHello.text.toString().toInt()\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20506028/" ]
74,440,131
<p>I am new to rails and am trying to build a blog app where only signed in users can see the username of the person who created a post, however I keep getting this error NoMethodError in Posts#index undefined method `username' for nil:NilClass</p> <p><a href="https://i.stack.imgur.com/xpNAe.png" rel="nofollow noreferrer">screenshot of error in localhost:3000</a></p> <p>Here is my routes.rb</p> <pre><code>``` Rails.application.routes.draw do devise_for :users # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Defines the root path route (&quot;/&quot;) # root &quot;articles#index&quot; root &quot;posts#index&quot; resources :posts, only: [:new, :create, :index] get &quot;/posts/new.html.erb&quot;, to: &quot;posts#create&quot;, as: &quot;create&quot; get &quot;/posts/new.html.erb&quot;, to: &quot;posts#new&quot;, as: &quot;new&quot; end ``` </code></pre> <p>here is my posts_controller.rb</p> <pre><code> class PostsController &lt; ApplicationController before_action :authenticate_user!, except: [:index] def new @post = Post.new end def create @post = current_user.posts.build(post_params) @post.user = current_user respond_to do |format| if @post.save format.html { redirect_to user_post_path(current_user, @post), notice: 'Post was successfully created.' } format.json { render :show, status: :created, location: @post } else format.html { render :new } format.json { render json: @post.errors, status: :unprocessable_entity } end end end def index @posts = Post.all.order(created_at: :desc) end private def post_params params.require(:post).permit(:title, :description) end end ``` here is my post.rb model ``` class Post &lt; ApplicationRecord belongs_to :user end ``` here is my user.rb model ``` class User &lt; ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable has_many :posts validates :username, presence: true validates :email, presence: true validates :password, presence: true end `` here is my schema ``` ActiveRecord::Schema[7.0].define(version: 2022_11_14_173843) do create_table &quot;posts&quot;, force: :cascade do |t| t.string &quot;title&quot; t.text &quot;description&quot; t.datetime &quot;created_at&quot;, null: false t.datetime &quot;updated_at&quot;, null: false t.integer &quot;user_id&quot; end create_table &quot;users&quot;, force: :cascade do |t| t.string &quot;email&quot;, default: &quot;&quot;, null: false t.string &quot;encrypted_password&quot;, default: &quot;&quot;, null: false t.string &quot;reset_password_token&quot; t.datetime &quot;reset_password_sent_at&quot; t.datetime &quot;remember_created_at&quot; t.datetime &quot;created_at&quot;, null: false t.datetime &quot;updated_at&quot;, null: false t.string &quot;username&quot; t.index [&quot;email&quot;], name: &quot;index_users_on_email&quot;, unique: true t.index [&quot;reset_password_token&quot;], name: &quot;index_users_on_reset_password_token&quot;, unique: true end end ``` here is my AddNameToUsers migration ``` class AddNameToUsers &lt; ActiveRecord::Migration[7.0] def change add_column :users, :username, :string end end ``` Here is my AddUserIdToPosts migration ``` class AddUserIdToPosts &lt; ActiveRecord::Migration[7.0] def change add_column :posts, :user_id, :integer end end ``` Here is my CreatePosts Migration ``` class CreatePosts &lt; ActiveRecord::Migration[7.0] def change create_table :posts do |t| t.string :title t.text :description t.timestamps end end end ``` </code></pre>
[ { "answer_id": 74440725, "author": "Alok Swain", "author_id": 301419, "author_profile": "https://Stackoverflow.com/users/301419", "pm_score": 0, "selected": false, "text": "Post" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20170519/" ]
74,440,152
<p>I am tasked with creating two functions one that creates a list of 10 random integers and the other is supposed to find the highest number in the list using a loop (without using the max option). I am having difficulty with the second function (getHighest). Nothing is being returned/printed and I am also not getting an error. Please help!</p> <p>Here is what I have tried:</p> <pre><code>from random import randint def main() : MIN = -100 MAX = 100 LIST_SIZE = 10 scores = [] for i in range(LIST_SIZE): scores.append(randint(MIN, MAX)) print(scores) def getHighest(scores) : highest = scores[0] for score in range(0,len(scores)) : if highest &lt; score: highest = score print(f&quot;Highest value: {highest}&quot;) main() </code></pre>
[ { "answer_id": 74440725, "author": "Alok Swain", "author_id": 301419, "author_profile": "https://Stackoverflow.com/users/301419", "pm_score": 0, "selected": false, "text": "Post" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20506015/" ]
74,440,160
<p>i want to write a python code to do the categorisation of store names(chemist,restaurent etc) automatically.</p> <p>if the store name is Anand Medical store it should fall in chemist cat., if it is 7 General store it should fall in General store cat.</p>
[ { "answer_id": 74440725, "author": "Alok Swain", "author_id": 301419, "author_profile": "https://Stackoverflow.com/users/301419", "pm_score": 0, "selected": false, "text": "Post" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20506120/" ]
74,440,193
<p>I have a multipart form on my website which contains a few separate 'information popups'.</p> <p>In this stripped down example, I only included two of the popups... the 'Privacy Policy' popup and the 'Terms and Conditions' popup.</p> <p>I am trying to 'blur' or 'fade' everything except the popups, when they are individually displayed.</p> <p>I have tried a few code suggestions I found on the internet, but after a few days of extensive experimentation and failures with each of them, I decided to post my question without those examples, and see if anyone else has any better suggestions from scratch.</p> <p>If anyone can help or point me in the right direction... it would be much appreciated.</p> <p>I apologize in advance for the lengthy code.</p> <p>Thanks, Maddison</p> <p>HTML</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;head&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt; &lt;meta charset=&quot;utf-8&quot;&gt; &lt;!-- Start Stylesheet --&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;/css/fadetest2.css&quot;&gt; &lt;!-- End Stylesheet --&gt; &lt;!-- Start Font Codes --&gt; &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.googleapis.com&quot;&gt; &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.gstatic.com&quot; crossorigin&gt; &lt;link href=&quot;https://fonts.googleapis.com/css2?family=Niconne&amp;display=swap&quot; rel=&quot;stylesheet&quot;&gt; &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.googleapis.com&quot;&gt; &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.gstatic.com&quot; crossorigin&gt; &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.googleapis.com&quot;&gt; &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.gstatic.com&quot; crossorigin&gt; &lt;link href=&quot;https://fonts.googleapis.com/css2? family=Roboto+Flex:opsz,wght@8..144,100;8..144,700&amp;display=swap&quot; rel=&quot;stylesheet&quot;&gt; &lt;!-- End Font Codes --&gt; &lt;/head&gt; &lt;!-- // START BODY AND CONTENT // --&gt; &lt;body&gt; &lt;div class=&quot;pageContainer&quot;&gt; &lt;div class=&quot;blankSpace&quot;&gt;&lt;/div&gt; &lt;!-- // START FORM CONTAINER // --&gt; &lt;div class=&quot;formContainer&quot;&gt; &lt;!-- // START HEADER // --&gt; &lt;div class=&quot;center_Wrapper&quot;&gt;&lt;div class=&quot;formHeader&quot;&gt;Fade Test&lt;/div&gt;&lt;/div&gt; &lt;!-- // END HEADER // --&gt; &lt;!-- // START FORM INFORMATION // --&gt; &lt;div class=&quot;formInfo_Container&quot;&gt; &lt;div class=&quot;&quot;&gt;&lt;p class=&quot;formInstructions&quot;&gt; Please fill out the form below.&lt;br&gt;&lt;br&gt; &lt;/p&gt;&lt;/div&gt; &lt;/div&gt; &lt;!-- // END FORM INFORMATION // --&gt; &lt;!-- // START PRIVACY POLICY // --&gt; &lt;div class=&quot;privacy_Container&quot;&gt; &lt;div class=&quot;privacyPopup&quot;&gt; &lt;div class=&quot;privacyWrap&quot;&gt;&lt;a class=&quot;privacyLink&quot; onclick=&quot;privacyFunction()&quot;&gt;Privacy Policy&lt;/a&gt; &lt;/div&gt; &lt;p class=&quot;privacyPopup_text&quot; id=&quot;privacyPopup_text&quot;&gt; &lt;b&gt;PRIVACY POLICY&lt;/b&gt;&lt;br&gt;&lt;br&gt; This is some privacy policy information.&lt;br&gt;&lt;br&gt; This is some privacy policy information.&lt;br&gt;&lt;br&gt; This is some privacy policy information.&lt;br&gt;&lt;br&gt; This is some privacy policy information.&lt;br&gt;&lt;br&gt; This is some privacy policy information.&lt;br&gt;&lt;br&gt; This is some privacy policy information.&lt;br&gt;&lt;br&gt; This is some privacy policy information.&lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;a class=&quot;privacyPopup_close&quot; onclick=&quot;privacyFunction()&quot;&gt;Close &amp;#8999;&lt;/a&gt; &lt;/p&gt; &lt;/div&gt; &lt;script&gt; // Start - Privacy Popup function // function privacyFunction() { var popup = document.getElementById(&quot;privacyPopup_text&quot;); popup.classList.toggle(&quot;show&quot;); } // End - Privacy Popup function // &lt;/script&gt; &lt;/div&gt; &lt;!-- // END PRIVACY POLICY // --&gt; &lt;!-- // START USER INFORMATION // --&gt; &lt;div class=&quot;userInformation_Container&quot;&gt; &lt;div class=&quot;spacer&quot;&gt;&lt;/div&gt; &lt;div class=&quot;left_Wrapper&quot;&gt;&lt;div class=&quot;section_Header&quot;&gt;Contact Information&lt;/div&gt; &lt;/div&gt; &lt;!-- Start userName Field --&gt; &lt;div class=&quot;inputField_Wrapper&quot;&gt;&lt;input type=&quot;text&quot; id=&quot;userName&quot; name=&quot;userName&quot; class=&quot;inputField&quot; placeholder=&quot; Your Name&quot; required&gt;&lt;/div&gt; &lt;!-- End userName Field --&gt; &lt;!-- Start userEmail Field --&gt; &lt;div class=&quot;inputField_Wrapper&quot;&gt;&lt;input type=&quot;email&quot; id=&quot;userEmail&quot; name=&quot;userEmail&quot; class=&quot;inputField&quot; placeholder=&quot; your@email.com&quot; required&gt;&lt;/div&gt; &lt;!-- End userEmail Field --&gt; &lt;!-- // END USER INFORMATION // --&gt; &lt;!-- // START TERMS &amp; CONDITIONS // --&gt; &lt;div class=&quot;terms_Container&quot;&gt; &lt;div class=&quot;spacer&quot;&gt;&lt;/div&gt; &lt;div class=&quot;spacer&quot;&gt;&lt;/div&gt; &lt;div class=&quot;termsPopup&quot;&gt; &lt;div class=&quot;termsWrap&quot;&gt;&lt;input type=&quot;checkbox&quot; id=&quot;termsCheckbox&quot; name=&quot;termsCheckbox&quot; class=&quot;termsCheckbox&quot; value=&quot;Yes&quot; required&gt;&lt;a class=&quot;termsText&quot;&gt;I Agree to the&amp;nbsp;&lt;/a&gt;&lt;a class=&quot;termsLink&quot; onclick=&quot;termsFunction()&quot;&gt;Terms and Conditions&lt;/a&gt;&lt;/div&gt; &lt;p class=&quot;termsPopup_text&quot; id=&quot;termsPopup_text&quot;&gt; &lt;b&gt;TERMS and CONDITIONS&lt;/b&gt;&lt;br&gt;&lt;br&gt; By submitting this form, you agree that;&lt;br&gt;&lt;br&gt; This is some terms and conditions info.&lt;br&gt;&lt;br&gt; This is some terms and conditions info.&lt;br&gt;&lt;br&gt; This is some terms and conditions info.&lt;br&gt;&lt;br&gt; This is some terms and conditions info.&lt;br&gt;&lt;br&gt; This is some terms and conditions info.&lt;br&gt;&lt;br&gt; This is some terms and conditions info.&lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;a class=&quot;termsPopup_close&quot; onclick=&quot;termsFunction()&quot;&gt;Close &amp;#8999;&lt;/a&gt; &lt;/p&gt; &lt;/div&gt; &lt;script&gt; // Start - Terms Popup function // function termsFunction() { var popup = document.getElementById(&quot;termsPopup_text&quot;); popup.classList.toggle(&quot;show&quot;); } // End - Terms Popup function // &lt;/script&gt; &lt;/div&gt; &lt;!-- // END TERMS &amp; CONDITIONS // --&gt; &lt;!-- // START SUBMIT BUTTON // --&gt; &lt;div class=&quot;center_Wrapper&quot;&gt;&lt;input type=&quot;submit&quot; id=&quot;submitButton&quot; name=&quot;submitButton&quot; class=&quot;submit__button&quot; value=&quot;Submit&quot;&gt;&lt;/div&gt; &lt;!-- // END SUBMIT BUTTON // --&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>CSS</p> <pre><code>body{ margin: 0px; background-color: #ff78ae; background-image: url(&quot;https://img.freepik.com/free-vector/pattern-with-black-stars-white- background_1110-366.jpg?w=2000&quot;); background-repeat: round; display: flex; display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; } .pageContainer { width: 100%; margin: auto; position: relative; align-items: center; } .formContainer { width: 92%; max-width: 340px; margin: auto; margin-top: 10px; position: relative; background-color: #555555; padding-left: 8px; padding-right: 8px; border:solid 2pt; border-color: #cdcdcd; border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; box-shadow: 2px 4px 8px 2px rgba(0,0,0,0.5); } .left_Wrapper { display: flex; justify-content: left; align-items: left; width: 100%; margin: auto; } .center_Wrapper { display: flex; justify-content: center; align-items: center; width: 100%; margin: auto; } .formHeader { width:100%; margin-top: 10px; margin-bottom:10px; text-align: center; color: #cdcdcd; font-family: 'Roboto Flex', sans-serif; font-size: 14pt; font-weight:bold; } .spacer { width: 100%; height: 2px; background-color: #cdcdcd; margin-top: 10px; } .blankSpace { width: 100%; margin-top: 10px; } /* // START SECTION CONTAINERS // */ .formInfo_Container {width:100%;} .privacy_Container {width: 100%;} .userInformation_Container {width: 100%;} .terms_Container {width: 100%;} /* // END SECTION CONTAINERS // */ /* // START PRIVACY POLICY // */ /* privacyPopup Container */ .privacyPopup { display: flex; position: relative; justify-content: center; align-items: center; width: 100%; margin: auto; margin-top: 20px; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .privacyWrap{ width: 100%; margin-bottom: 10px; vertical-align: middle; } .privacyText{ font-family: arial; font-size: 12pt; color: #e6e6e6; vertical-align: middle; } .privacyLink{ font-family: arial; font-size: 12pt; color: #e6e6e6; text-decoration: underline; vertical-align: middle; cursor: pointer; } .privacyLink:hover{ color: #ffffff; } .privacyCheckbox{ vertical-align: middle; margin-right: 15px; } /* privacyPopup (actual popup) */ .privacyPopup .privacyPopup_text { visibility: hidden; width: 95%; height: 350px; background-color: #8f8f8f; font-family: arial; color: #e6e6e6; text-align: left; border-radius: 5px; padding: 8px 8px 8px 8px; position: absolute; z-index: 1; bottom: -1000%; overflow:auto; border: solid 2px; } /* Toggle this class - hide and show the popup */ .privacyPopup .show { visibility: visible; -webkit-animation: fadeIn 1s; animation: fadeIn 1s; } /* Add animation (fade in the popup) */ @-webkit-keyframes fadeIn { from {opacity: 0;} to {opacity: 1;} } @keyframes fadeIn { from {opacity: 0;} to {opacity:1 ;} } .privacyPopup_close{ color: #e6e6e6; cursor: pointer; } .privacyPopup_close:hover{ color: #ffffff; } /* // END PRIVACY POLICY // */ .formInstructions { width:100%; margin-top: 10px; margin-bottom:10px; text-align: left; color: #cdcdcd; font-family: arial; font-size: 12pt; } .inputField_Wrapper { display: flex; justify-content: center; align-items: center; width: 100%; margin: auto; } .inputField { width: 100%; margin-top: 10px; margin-bottom:10px; padding:5px; color: #8f8f8f; font-family: arial; font-size: 12pt; border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border: none; outline: none; background-color: #ffffff; } .inputField:hover { background-color: #ffffe0; } .inputField2 { width: 100%; margin-top: 10px; margin-bottom:10px; padding:5px; color: #8f8f8f; font-family: arial; font-size: 12pt; border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border: none; outline: none; background-color: #ffffff; cursor: pointer; } .inputField2:hover { background-color: #ffffe0; } .section_Header { width:100%; margin-top: 10px; margin-bottom:10px; text-align: left; color: #cdcdcd; font-family: 'Roboto Flex', sans-serif; font-size: 14pt; font-weight:bold; } /* // START TERMS AND CONDITIONS // */ /* termsPopup Container */ .termsPopup { display: flex; position: relative; justify-content: center; align-items: center; width: 100%; margin: auto; margin-top: 30px; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .termsWrap{ width: 100%; height: 20px; background-color: #8f8f8f; padding: 5px; color: #e6e6e6; border: solid 2px; border-radius: 4px; margin-bottom: 50px; vertical-align: middle; } .termsText{ font-family: arial; font-size: 12pt; color: #e6e6e6; vertical-align: middle; } .termsLink{ font-family: arial; font-size: 12pt; color: #e6e6e6; text-decoration: underline; vertical-align: middle; cursor: pointer; } .termsLink:hover{ color: #ffffff; } .termsCheckbox{ vertical-align: middle; margin-right: 15px; } /* termsPopup (actual popup) */ .termsPopup .termsPopup_text { visibility: hidden; width: 95%; height: 350px; background-color: #8f8f8f; font-family: arial; color: #e6e6e6; text-align: left; border-radius: 5px; padding: 8px 8px 8px 8px; position: absolute; z-index: 1; bottom: -10%; overflow:auto; border: solid 2px; } /* Toggle this class - hide and show the popup */ .termsPopup .show { visibility: visible; -webkit-animation: fadeIn 1s; animation: fadeIn 1s; } /* Add animation (fade in the popup) */ @-webkit-keyframes fadeIn { from {opacity: 0;} to {opacity: 1;} } @keyframes fadeIn { from {opacity: 0;} to {opacity:1 ;} } .termsPopup_close{ color: #e6e6e6; cursor: pointer; } .termsPopup_close:hover{ color: #ffffff; } /* // END TERMS AND CONDITIONS // */ /* // START SUBMIT BUTTON // */ .submit__button { width: 100%; height: 40px; background: #0c2d1c; border: solid 2px; border-radius: 8px; outline: none; color: #ffffff; font-size: 12pt; font-family: Arial; font-weight: bold; cursor: pointer; margin-bottom: 30px; box-shadow: 2px 4px 8px 2px rgba(0,0,0,0.5); } .submit__button:hover { background: #124429; } .submit__button:active { background: #185a37; } /* // END SUBMIT BUTTON // */ </code></pre>
[ { "answer_id": 74441196, "author": "Saad1430", "author_id": 19199222, "author_profile": "https://Stackoverflow.com/users/19199222", "pm_score": 2, "selected": true, "text": ".blurry{\n filter: blur(5px);\n }\n" }, { "answer_id": 74441244, "author": "Rain", "author_id": 20506415, "author_profile": "https://Stackoverflow.com/users/20506415", "pm_score": 0, "selected": false, "text": "* {\n margin: 0;\n padding: 0;\n}\n.box {\n height: 100vh;\n transition: background .25s ease;\n}\n.box:hover {\n background: #f00;\n}\n.modal {\n position: absolute;\n top: 50%;\n left: 50%;\n max-width: 50%;\n transform: translate(-50%, -50%);\n border: 1px solid grey;\n background: plum;\n box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);\n}\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8322896/" ]
74,440,207
<p>Please see the below <code>Makefile</code>:</p> <pre><code>SHELL=/bin/bash -euo pipefail REPO_ROOT = $(shell pwd) export VIRTUAL_ENV := ${REPO_ROOT}/venv # bin = POSIX, Scripts = Windows export PATH := ${VIRTUAL_ENV}/bin:${VIRTUAL_ENV}/Scripts:${PATH} show-python: ## Show path to python and version @echo -n &quot;python location: &quot; @python -c &quot;import sys; print(sys.executable, end='')&quot; @echo -n &quot;, version: &quot; @python -c &quot;import platform; print(platform.python_version())&quot; install: show-python install: ## Install all dev dependencies into a local virtual environment. export VIRTUAL_ENV=&quot;${VIRTUAL_ENV}&quot;; \ python -m pip install -r requirements-dev.txt --progress-bar off </code></pre> <p>The <code>install</code> recipe only works if I manually <code>export</code> the environment variable <code>VIRTUAL_ENV</code> inside the recipe with <code>;</code> chaining it into the next command. In other words, the first line of the <code>install</code> recipe is currently &quot;doing something special&quot; that I can't figure out.</p> <p>What is going on here with this <code>export</code> being required twice?</p>
[ { "answer_id": 74440942, "author": "Beta", "author_id": 128940, "author_profile": "https://Stackoverflow.com/users/128940", "pm_score": 1, "selected": false, "text": "export" }, { "answer_id": 74451199, "author": "Intrastellar Explorer", "author_id": 11163122, "author_profile": "https://Stackoverflow.com/users/11163122", "pm_score": 1, "selected": true, "text": "Makefile" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11163122/" ]
74,440,236
<p>I am very new to using React, but my gut tells me this concept has come up already and there are better tools or methods of dealing with it than what I used. I want to have a list of buttons to choose from, and when one is clicked, to display that menu and remove the other buttons. My current solution is to have a Options Menu component that has a switch to handle the buttons when they are clicked and exited (code included).</p> <p>Is this the best approach or is there a better way?</p> <pre><code> const options = [&quot;Monsters&quot;, &quot;Champions&quot;, &quot;Dice&quot;, &quot;Arena&quot;]; const closeHandler = () =&gt; { setSelected(&quot;&quot;); }; </code></pre> <pre><code> switch (selected) { case &quot;&quot;: return ( &lt;div&gt; &lt;ul&gt; {options.map(option =&gt; &lt;li&gt; &lt;button onClick={selectionHandler}&gt;{option}&lt;/button&gt; &lt;/li&gt; )} &lt;/ul&gt; &lt;/div&gt; ); case &quot;Monsters&quot;: return ( &lt;MonsterMenu onClose={closeHandler} /&gt; ); case &quot;Champions&quot;: return ( &lt;ChampionMenu onClose={closeHandler} /&gt; ); case &quot;Dice&quot;: return ( &lt;DiceMenu onClose={closeHandler} /&gt; ); case &quot;Arena&quot;: return ( &lt;ArenaMenu onClose={closeHandler} /&gt; ); </code></pre>
[ { "answer_id": 74440942, "author": "Beta", "author_id": 128940, "author_profile": "https://Stackoverflow.com/users/128940", "pm_score": 1, "selected": false, "text": "export" }, { "answer_id": 74451199, "author": "Intrastellar Explorer", "author_id": 11163122, "author_profile": "https://Stackoverflow.com/users/11163122", "pm_score": 1, "selected": true, "text": "Makefile" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4552258/" ]
74,440,312
<p>i have a screen file let say <code>screenA.blade.php</code>. inside this file, i want call a constant file that store some of string let say <code>constant.js</code>.</p> <p>is this possible?</p> <p>this is what i have inside <code>screenA.blade.php</code></p> <pre><code>&lt;head&gt; &lt;script&gt; ... // some of js code here // want call string from constant.js here // console.log(string from constant.js) ... &lt;script&gt; &lt;head&gt; </code></pre>
[ { "answer_id": 74440942, "author": "Beta", "author_id": 128940, "author_profile": "https://Stackoverflow.com/users/128940", "pm_score": 1, "selected": false, "text": "export" }, { "answer_id": 74451199, "author": "Intrastellar Explorer", "author_id": 11163122, "author_profile": "https://Stackoverflow.com/users/11163122", "pm_score": 1, "selected": true, "text": "Makefile" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20195612/" ]
74,440,338
<p>I don't know how to get data and fill into my word template. It's actually a long list, and I need to fill it on my table on word document. Am I doing it right? Here is my code:</p> <p><em>views.py</em></p> <pre><code>def save_sample_details(request): sample = SampleList.objects.all() doc = DocxTemplate(&quot;lab_management/word/sample_template.docx&quot;) context = { 'SNAME' : sample.sample_name, 'STYPE' : sample.sample_type, 'HVER' : sample.hardware_version, 'SVER' : sample.software_version, 'CS' : sample.config_status, 'NUM' : sample.number, 'SNUM' : sample.sample_number, } doc.render(context) doc.save('lab_management/word/sample.docx') return redirect('/lab/sample/details/') </code></pre> <p><em>models.py</em></p> <pre><code>class SampleList(models.Model): sample_name = models.CharField(max_length=32) sample_type = models.CharField(max_length=32) hardware_version = models.CharField(max_length=32) software_version = models.CharField(max_length=32) config_status = models.CharField(max_length=18) number = models.IntegerField(default=0) sample_number = models.CharField(max_length=17) </code></pre> <p>So if I run this, it shows <em>'QuerySet' object has no attribute 'sample_name'</em> etc.</p>
[ { "answer_id": 74440967, "author": "pzutils", "author_id": 13812770, "author_profile": "https://Stackoverflow.com/users/13812770", "pm_score": 2, "selected": false, "text": "SampleList" }, { "answer_id": 74441816, "author": "ilyasbbu", "author_id": 16475089, "author_profile": "https://Stackoverflow.com/users/16475089", "pm_score": 1, "selected": false, "text": "def save_sample_details(request):\n sample_list = SampleList.objects.all()\n doc = DocxTemplate(\"lab_management/word/sample_template.docx\")\n\n context_list = []\n for sample in sample_list:\n context = {\n 'SNAME' : sample.sample_name,\n 'STYPE' : sample.sample_type,\n 'HVER' : sample.hardware_version,\n 'SVER' : sample.software_version,\n 'CS' : sample.config_status,\n 'NUM' : sample.number,\n 'SNUM' : sample.sample_number,\n }\n context_list.append(context)\n\n doc.render(context_list)\n doc.save('lab_management/word/sample.docx')\n\n return redirect('/lab/sample/details/')\n" }, { "answer_id": 74456309, "author": "krisssz", "author_id": 12998295, "author_profile": "https://Stackoverflow.com/users/12998295", "pm_score": 0, "selected": false, "text": "def save_sample_details(request):\n sample = SampleList.objects.all()[0:15]\n template = DocxTemplate(\"lab_management/word/sample_template.docx\")\n\n context = {\n 'headers' : ['SNAME', 'STYPE', 'HVER', 'SVER', 'CS', 'NUM', 'SNUM'],\n 'list': [],\n }\n\n alist = ['a']\n\n for i in alist: \n for samples in sample:\n content= [samples.sample_name, samples.sample_type, samples.hardware_version,\n samples.software_version, samples.config_status, samples.number, \n samples.sample_number ]\n context['list'].append(content)\n\n template.render(context)\n template.save('lab_management/word/sample.docx')\n return redirect('/lab/sample/details/')\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12998295/" ]
74,440,357
<p>I have an order as <code>ORDER_1</code> which start from <code>MFG_1</code> and goes to <code>PORT_B</code>. Order moves via different location and in between at some locations it goes through processing AND MAINTENANCE.</p> <p>Here in this example it goes into 7 Shipments. Shipment Mode is PROCESS if it stays at same location for days.</p> <p><a href="https://i.stack.imgur.com/zLmcq.png" rel="nofollow noreferrer">Target Data</a></p> <pre><code>ORDER ORDER_1 SOURCE_LOCATION=MFG_1 DESTINATION_LOCATION=PORT_B SHIPMENT SOURCE_LOCATION DESTINATION_LOCATION MODE SHP_A MFG_1 WH_1 TRANSPORT SHP_B WH_1 WH_2 TRANSPORT SHP_C WH_2 WH_2 PROCESS SHP_D WH_2 BB_1 TRANSPORT SHP_E BB_1 BB_1 PROCESS SHP_F BB_1 PORT_A TRANSPORT SHP_G PORT_A PORT_B VESSEL </code></pre> <p>I need to have sequence number as given. Shipment sequence will be 1 if Order's Source Location is equal to Shipment Source Location (SHP_A) and if Order's destination location is equal to Shipment Destination Location then it will be last Shipment (COUNT(SHIPMENT))</p> <p>Here I need to have sequence for in between Shipments. Logic is: Sequence 2 will be the Shipment which Source Location is equal to SHP_A's DESTINATION_LOCATION and if there are 2 Shipments starting from SHP_A's DESTINATION_LOCATION then MODE of PROCESS will be given preference and so on.</p> <p><a href="https://i.stack.imgur.com/P3SZF.png" rel="nofollow noreferrer">Expected Sequence</a></p> <pre><code>SHIPMENT SEQUENCE SHP_A 1 SHP_B 2 SHP_C 3 SHP_D 4 SHP_F 5 SHP_E 6 SHP_G 7 </code></pre> <p>Thank You for your input.</p> <p>I am not able to find an easy logic for this sequencing.</p> <p>Here is my Raw Data:</p> <p><a href="https://i.stack.imgur.com/Z4jCu.png" rel="nofollow noreferrer">Raw Data</a></p> <p>Expected Result:</p> <p><a href="https://i.stack.imgur.com/LyfDt.png" rel="nofollow noreferrer">Expected Result</a></p> <p><a href="https://i.stack.imgur.com/HMNAx.png" rel="nofollow noreferrer">Result by D R Query</a> <a href="https://i.stack.imgur.com/wYgur.png" rel="nofollow noreferrer">enter image description here</a></p>
[ { "answer_id": 74441774, "author": "d r", "author_id": 19023353, "author_profile": "https://Stackoverflow.com/users/19023353", "pm_score": 2, "selected": false, "text": "WITH\n tbl AS\n (\n Select 'MFG_1' \"SHIPMENT_SOURCE_LOCATION\", 'PORT_B' \"SHIPMENT_DESTINATION_LOCAATION\", 'ORDER_1' \"AN_ORDER\", 'SHP_A' \"SHIPMENT\", 'MFG_1' \"SOURCE_LOCATION\", 'WH_1' \"DESTINATION_LOCATION\", 'TRANSPORT' \"MODE\" From Dual Union All\n Select 'MFG_1' \"SHIPMENT_SOURCE_LOCATION\", 'PORT_B' \"SHIPMENT_DESTINATION_LOCAATION\", 'ORDER_1' \"AN_ORDER\", 'SHP_B' \"SHIPMENT\", 'WH_1' \"SOURCE_LOCATION\", 'WH_2' \"DESTINATION_LOCATION\", 'TRANSPORT' \"MODE\" From Dual Union All\n Select 'MFG_1' \"SHIPMENT_SOURCE_LOCATION\", 'PORT_B' \"SHIPMENT_DESTINATION_LOCAATION\", 'ORDER_1' \"AN_ORDER\", 'SHP_C' \"SHIPMENT\", 'WH_2' \"SOURCE_LOCATION\", 'WH_2' \"DESTINATION_LOCATION\", 'PROCESS' \"MODE\" From Dual Union All\n Select 'MFG_1' \"SHIPMENT_SOURCE_LOCATION\", 'PORT_B' \"SHIPMENT_DESTINATION_LOCAATION\", 'ORDER_1' \"AN_ORDER\", 'SHP_D' \"SHIPMENT\", 'WH_2' \"SOURCE_LOCATION\", 'BB_1' \"DESTINATION_LOCATION\", 'TRANSPORT' \"MODE\" From Dual Union All\n Select 'MFG_1' \"SHIPMENT_SOURCE_LOCATION\", 'PORT_B' \"SHIPMENT_DESTINATION_LOCAATION\", 'ORDER_1' \"AN_ORDER\", 'SHP_E' \"SHIPMENT\", 'BB_1' \"SOURCE_LOCATION\", 'BB_1' \"DESTINATION_LOCATION\", 'PROCESS' \"MODE\" From Dual Union All\n Select 'MFG_1' \"SHIPMENT_SOURCE_LOCATION\", 'PORT_B' \"SHIPMENT_DESTINATION_LOCAATION\", 'ORDER_1' \"AN_ORDER\", 'SHP_F' \"SHIPMENT\", 'BB_1' \"SOURCE_LOCATION\", 'PORT_A' \"DESTINATION_LOCATION\", 'TRANSPORT' \"MODE\" From Dual Union All\n Select 'MFG_1' \"SHIPMENT_SOURCE_LOCATION\", 'PORT_B' \"SHIPMENT_DESTINATION_LOCAATION\", 'ORDER_1' \"AN_ORDER\", 'SHP_G' \"SHIPMENT\", 'PORT_A' \"SOURCE_LOCATION\", 'PORT_B' \"DESTINATION_LOCATION\", 'VESSEL' \"MODE\" From Dual \n )\n" }, { "answer_id": 74446203, "author": "MT0", "author_id": 1509264, "author_profile": "https://Stackoverflow.com/users/1509264", "pm_score": 0, "selected": false, "text": "SELECT shipment, sequence\nFROM (\n SELECT t.*,\n LEVEL AS sequence,\n MAX(LEVEL) OVER (PARTITION BY rowid) AS max_seq\n FROM table_name t\n START WITH shipment_source = source_location\n CONNECT BY\n PRIOR an_order = an_order\n AND PRIOR destination_location = source_location\n AND PRIOR ROWID != ROWID\n)\nWHERE sequence = max_seq;\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4693084/" ]
74,440,408
<p>I have an array with six values in it {1, 2, 3, 4, 5, 6}. I have been able to successfully push the values into a stack using a for loop. I am supposed to also write a for loop and pop each value from the stack until there is only one left. I can't find an example of it anywhere. Help, please?</p> <pre><code>int[] numbers = new int[] {1, 2, 3, 4, 5, 6}; Stack&lt;int&gt; myStack = new Stack&lt;int&gt;(); for (int i = 0; i &lt;numbers.Length; i++) { mystack.Push(numbers[i]); } foreach(int item in myStack) { Console.Write(item + &quot;, &quot;); } </code></pre> <p>This prints the pushed values in the array. We have been using the other properties such as Peek and Count with stack as well. I don't have an issue with those. I don't have an issue using Pop for a single value either.</p> <pre><code>Console.WriteLine(&quot;The value popped from the stack is: {0} &quot;, myStack.Pop()); </code></pre> <p>My issue is trying to use a for loop to pop each item from the stack one by one. My brain isn't translating this well at all. I have looked for examples. I have not been able to find one using a for loop.</p>
[ { "answer_id": 74440451, "author": "vivek nuna", "author_id": 6527049, "author_profile": "https://Stackoverflow.com/users/6527049", "pm_score": 0, "selected": false, "text": "int count = myStack.Count;\nfor (int i = 1; i < count; i++)\n{\n Console.WriteLine(\"The value popped from the stack is: {0} \", myStack.Pop());\n}\n" }, { "answer_id": 74440467, "author": "eloiz", "author_id": 16756296, "author_profile": "https://Stackoverflow.com/users/16756296", "pm_score": 0, "selected": false, "text": "// check stack count \nwhile (myStack.Count > 1)\n{\n // console\n Console.WriteLine($@\"POP VALUE: {myStack.Pop()}\");\n}\n" }, { "answer_id": 74440490, "author": "khaira777", "author_id": 14503866, "author_profile": "https://Stackoverflow.com/users/14503866", "pm_score": 1, "selected": false, "text": "while (myStack.Count > 1)\n{\n Console.WriteLine(\"The value popped from the stack is: {0} \", myStack.Pop());\n}\n" }, { "answer_id": 74440540, "author": "LarryTheMagicDragon", "author_id": 20506451, "author_profile": "https://Stackoverflow.com/users/20506451", "pm_score": 0, "selected": false, "text": " for (int i = myStack.Count; i > 0; i--)\n {\n Console.WriteLine($\"The value popped from the stack is: {myStack.Pop()}\");\n }\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16276238/" ]
74,440,422
<p>I am trying to stop some behaviour based on a condition if a mouse is hovering over a particular react component in my app.</p> <p>I can only find old answers referencing jQuery and JS vanilla. Is there another way to do this? Or is it not acceptable?</p> <p>Here is the component I interested in determining if the mouse is over:</p> <pre><code>&lt;ContentRightHandSide offset={bannerHidden ? 80 : 120}&gt; &lt;ContentTitle&gt; Activity &lt;img style={{ display: &quot;inline&quot;, position: &quot;relative&quot;, marginLeft: &quot;20px&quot;, width: &quot;35px&quot;, }} src={calendarIcon} /&gt; &lt;/ContentTitle&gt; {authStatus === &quot;authenticated&quot; ? ( &lt;ShareLogs linkShareLogs={activeShareLogs} isBannerHidden={bannerHidden} hovered={hoveredNode} selected={selectedNode} /&gt; ) : ( &lt;div style={{ position: &quot;relative&quot; }}&gt; &lt;img src={blurredScreenLinks} style={{ fontSize: &quot;24px&quot;, position: &quot;relative&quot;, margin: &quot;0 auto&quot;, width: &quot;100%&quot;, }} /&gt; &lt;button style={{ backgroundColor: &quot;#F7F1FF&quot;, color: &quot;#35373B&quot;, position: &quot;absolute&quot;, fontFamily: &quot;lato&quot;, left: &quot;0&quot;, right: &quot;0&quot;, marginLeft: &quot;auto&quot;, marginRight: &quot;auto&quot;, width: &quot;320px&quot;, top: &quot;100px&quot;, padding: &quot;0px 20px&quot;, display: &quot;flex&quot;, alignItems: &quot;center&quot;, borderRadius: &quot;60px&quot;, }} onClick={handleSignInClick} &gt; &lt;img style={{ display: &quot;inline&quot;, position: &quot;relative&quot;, width: &quot;80px&quot;, cursor: &quot;pointer&quot;, margin: &quot;-5px&quot;, }} src={slackIcon} /&gt; &lt;span style={{ textAlign: &quot;left&quot; }}&gt; Lorem Ipsum &lt;/span&gt; &lt;/button&gt; &lt;/div&gt; )} &lt;/ContentRightHandSide&gt; </code></pre>
[ { "answer_id": 74440493, "author": "John Li", "author_id": 20436957, "author_profile": "https://Stackoverflow.com/users/20436957", "pm_score": 1, "selected": false, "text": "onClick" }, { "answer_id": 74440531, "author": "user20506518", "author_id": 20506518, "author_profile": "https://Stackoverflow.com/users/20506518", "pm_score": 0, "selected": false, "text": "onmouseenter" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440422", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13831283/" ]
74,440,466
<p>Given the following df:</p> <pre><code> word1 word2 distance mango ola 25 mango johnkoo 33 apple ola 25 apple johnkoo 0 </code></pre> <p>I find the two largest values of distance per group in the following way:</p> <pre><code>res = df.groupby(['word1'])['distance'].nlargest(2) print(res) word1 apple 2 25 3 0 mango 1 33 0 25 </code></pre> <p>This is a pandas series with a multindex that contains the index of the position of word2, I would like to have word2 value instead of index , like</p> <pre><code>word1 apple ola 25 johnkoo 0 mango johnkoo 33 ola 25 </code></pre> <p>print(res,index) gives:</p> <pre><code>MultiIndex([('apple', 2), ('apple', 3), ('mango', 1), ('mango', 0)], names=['word1', None]) </code></pre> <p>I have tried using <a href="https://pandas.pydata.org/docs/reference/api/pandas.MultiIndex.set_levels.html" rel="nofollow noreferrer">set_levels</a>, but could not figure out the solution.</p>
[ { "answer_id": 74440526, "author": "BENY", "author_id": 7964527, "author_profile": "https://Stackoverflow.com/users/7964527", "pm_score": 2, "selected": false, "text": "(df.sort_values('distance',ascending=False)\n .groupby('word1').head(2).set_index(['word1','word2'])['distance'])\nOut[166]: \nword1 word2 \nmango johnkoo 33\n ola 25\napple ola 25\n johnkoo 0\nName: distance, dtype: int64\n" }, { "answer_id": 74441072, "author": "sammywemmy", "author_id": 7175713, "author_profile": "https://Stackoverflow.com/users/7175713", "pm_score": 2, "selected": true, "text": "res" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8176763/" ]
74,440,469
<p>I am trying to identify which groups in a column contain a specific sequence length of non-zero numbers. In the basic example below, where the goal is the find the groups with the a sequence length of 5, only group <code>b</code> would be the correct.</p> <pre class="lang-r prettyprint-override"><code>set.seed(123) df &lt;- data.frame( id = seq(1:40), grp = sort(rep(letters[1:4], 10)), x = c( c(0, sample(1:10, 3), rep(0, 6)), c(0, 0, sample(1:10, 5), rep(0, 3)), c(rep(0, 6), sample(1:10, 4)), c(0, 0, sample(1:10, 3), 0, sample(1:10, 2), 0, 0)) ) </code></pre> <p>One limited solution is using <code>cumsum</code> below, to find count the non-zero values but does not work when there are breaks in the sequence, such as the specific length being 5 and group <code>d</code> being incorrectly included.</p> <pre class="lang-r prettyprint-override"><code>library(dplyr) df %&gt;% group_by(grp) %&gt;% mutate(cc = cumsum(x != 0)) %&gt;% filter(cc == 5) %&gt;% distinct(grp) </code></pre> <p>Desired output for the example of a sequence length of 5, would identify only group <code>b</code>, not <code>d</code>.</p>
[ { "answer_id": 74440527, "author": "Ronak Shah", "author_id": 3962914, "author_profile": "https://Stackoverflow.com/users/3962914", "pm_score": 3, "selected": true, "text": "rle" }, { "answer_id": 74440759, "author": "Aron Strandberg", "author_id": 4885169, "author_profile": "https://Stackoverflow.com/users/4885169", "pm_score": 1, "selected": false, "text": "cumsum(x == 0)" }, { "answer_id": 74441058, "author": "onyambu", "author_id": 8380272, "author_profile": "https://Stackoverflow.com/users/8380272", "pm_score": 1, "selected": false, "text": "library(data.table)\nsetDT(df)[,.N==5,.(grp,rleid(!x))][(V1), .(grp)]\n\n grp\n1: b\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6168956/" ]
74,440,510
<p>I have a Sprint boot based Java server that exposes REST endpoints. I need to create documentation for external customers on the endpoints. I'm not a fan of the Swagger generated docs. I'd like to be able to generate documentation like the Stripe API's : <a href="https://stripe.com/docs/api" rel="nofollow noreferrer">https://stripe.com/docs/api</a></p> <p>Do you know what tool can be used to generate Stripe API like documentation?</p>
[ { "answer_id": 74440527, "author": "Ronak Shah", "author_id": 3962914, "author_profile": "https://Stackoverflow.com/users/3962914", "pm_score": 3, "selected": true, "text": "rle" }, { "answer_id": 74440759, "author": "Aron Strandberg", "author_id": 4885169, "author_profile": "https://Stackoverflow.com/users/4885169", "pm_score": 1, "selected": false, "text": "cumsum(x == 0)" }, { "answer_id": 74441058, "author": "onyambu", "author_id": 8380272, "author_profile": "https://Stackoverflow.com/users/8380272", "pm_score": 1, "selected": false, "text": "library(data.table)\nsetDT(df)[,.N==5,.(grp,rleid(!x))][(V1), .(grp)]\n\n grp\n1: b\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/235041/" ]
74,440,512
<p>I have made an app that fetches some data by API.</p> <p>In my emulator, the app fetches data perfectly and shows the data correctly too. But whenever I build an APK and install it on my phone the data doesn't show up.</p> <p>Why is it happening? In the emulator, it's works.</p> <p>For fetching data, I used future builder</p>
[ { "answer_id": 74440527, "author": "Ronak Shah", "author_id": 3962914, "author_profile": "https://Stackoverflow.com/users/3962914", "pm_score": 3, "selected": true, "text": "rle" }, { "answer_id": 74440759, "author": "Aron Strandberg", "author_id": 4885169, "author_profile": "https://Stackoverflow.com/users/4885169", "pm_score": 1, "selected": false, "text": "cumsum(x == 0)" }, { "answer_id": 74441058, "author": "onyambu", "author_id": 8380272, "author_profile": "https://Stackoverflow.com/users/8380272", "pm_score": 1, "selected": false, "text": "library(data.table)\nsetDT(df)[,.N==5,.(grp,rleid(!x))][(V1), .(grp)]\n\n grp\n1: b\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7597207/" ]
74,440,522
<p>I have an S3-hosted static website and a Cloud Front distribution. THere is an A record in Route 53 pointing to the Cloud Front distribution. When I created the distribution, I accepted the default setting for the certificate. That is, I did not enter a certificate ID or request a certificate. When I attempt to browse to the site with Chrome, I get NET::ERR_CERT_COMMON_NAME_INVALID.</p> <p>How can I view or modify the common name of the default certificate? It doesn't appear in Certificate Manager.</p>
[ { "answer_id": 74441052, "author": "dave_thompson_085", "author_id": 2868801, "author_profile": "https://Stackoverflow.com/users/2868801", "pm_score": 2, "selected": true, "text": "curl -v https://host" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14442297/" ]
74,440,532
<p>Im having a problem using an Api which i have a List in. When i try to show, it shows like <code>[Instance of 'Source']</code> on screen</p> <p>i had a problem like that with others data, but i was able to use a second source of call, like</p> <p><code>finalApi![widget.index].aspect.name</code></p> <p>but this one i can use only sources <code>finalApi![widget.index].sources.toString()</code></p> <p>i will show my api right below</p> <pre><code>import 'dart:convert'; List&lt;FinalApi&gt; finalApiFromMap(String str) =&gt; List&lt;FinalApi&gt;.from(json.decode(str).map((x) =&gt; FinalApi.fromMap(x))); String finalApiToMap(List&lt;FinalApi&gt; data) =&gt; json.encode(List&lt;dynamic&gt;.from(data.map((x) =&gt; x.toMap()))); class FinalApi { FinalApi({ required this.id, required this.name, required this.description, required this.tooltip, required this.order, required this.rank, required this.patch, required this.owned, required this.icon, required this.type, required this.aspect, required this.sources, }); int id; String name; String description; String tooltip; int order; int rank; String patch; String owned; String icon; Aspect type; Aspect aspect; List&lt;Source&gt; sources; factory FinalApi.fromMap(Map&lt;String, dynamic&gt; json) =&gt; FinalApi( id: json[&quot;id&quot;], name: json[&quot;name&quot;], description: json[&quot;description&quot;], tooltip: json[&quot;tooltip&quot;], order: json[&quot;order&quot;], rank: json[&quot;rank&quot;], patch: json[&quot;patch&quot;], owned: json[&quot;owned&quot;], icon: json[&quot;icon&quot;], type: Aspect.fromMap(json[&quot;type&quot;]), aspect: Aspect.fromMap(json[&quot;aspect&quot;]), sources: List&lt;Source&gt;.from(json[&quot;sources&quot;].map((x) =&gt; Source.fromMap(x))), ); Map&lt;String, dynamic&gt; toMap() =&gt; { &quot;id&quot;: id, &quot;name&quot;: name, &quot;description&quot;: description, &quot;tooltip&quot;: tooltip, &quot;order&quot;: order, &quot;rank&quot;: rank, &quot;patch&quot;: patch, &quot;owned&quot;: owned, &quot;icon&quot;: icon, &quot;type&quot;: type.toMap(), &quot;aspect&quot;: aspect.toMap(), &quot;sources&quot;: List&lt;dynamic&gt;.from(sources.map((x) =&gt; x.toMap())), }; } class Aspect { Aspect({ required this.id, required this.name, }); int id; Name? name; factory Aspect.fromMap(Map&lt;String, dynamic&gt; json) =&gt; Aspect( id: json[&quot;id&quot;], name: nameValues.map[json[&quot;name&quot;]], ); Map&lt;String, dynamic&gt; toMap() =&gt; { &quot;id&quot;: id, &quot;name&quot;: nameValues.reverse[name], }; } enum Name { WATER, FIRE, BLUNT, PIERCING, LIGHTNING, NONE, EARTH, SLASHING, ICE, WIND, PIERCING_FIRE, BLUNT_EARTH, MAGIC, PHYSICAL } final nameValues = EnumValues({ &quot;Blunt&quot;: Name.BLUNT, &quot;Blunt/Earth&quot;: Name.BLUNT_EARTH, &quot;Earth&quot;: Name.EARTH, &quot;Fire&quot;: Name.FIRE, &quot;Ice&quot;: Name.ICE, &quot;Lightning&quot;: Name.LIGHTNING, &quot;Magic&quot;: Name.MAGIC, &quot;None&quot;: Name.NONE, &quot;Physical&quot;: Name.PHYSICAL, &quot;Piercing&quot;: Name.PIERCING, &quot;Piercing/Fire&quot;: Name.PIERCING_FIRE, &quot;Slashing&quot;: Name.SLASHING, &quot;Water&quot;: Name.WATER, &quot;Wind&quot;: Name.WIND }); class Source { Source({ required this.type, required this.text, required this.relatedType, required this.relatedId, }); Type? type; String text; dynamic relatedType; dynamic relatedId; factory Source.fromMap(Map&lt;String, dynamic&gt; json) =&gt; Source( type: typeValues.map[json[&quot;type&quot;]], text: json[&quot;text&quot;], relatedType: json[&quot;related_type&quot;], relatedId: json[&quot;related_id&quot;], ); Map&lt;String, dynamic&gt; toMap() =&gt; { &quot;type&quot;: typeValues.reverse[type], &quot;text&quot;: text, &quot;related_type&quot;: relatedType, &quot;related_id&quot;: relatedId, }; } enum Type { OTHER, DUNGEON } final typeValues = EnumValues({&quot;Dungeon&quot;: Type.DUNGEON, &quot;Other&quot;: Type.OTHER}); class EnumValues&lt;T&gt; { Map&lt;String, T&gt; map; Map&lt;T, String&gt;? reverseMap; EnumValues(this.map); Map&lt;T, String&gt; get reverse { if (reverseMap == null) { reverseMap = map.map((k, v) =&gt; new MapEntry(v, k)); } return reverseMap!; } } </code></pre> <p>i dont understand much about Api and Json, but should be some information inside.</p> <p>how i tried:</p> <pre><code>ListView.builder( shrinkWrap: true, itemCount: finalApi![widget.index].sources.length, itemBuilder: (context, index) { return Text(finalApi![widget.index].sources.toString()); }, ), </code></pre>
[ { "answer_id": 74441052, "author": "dave_thompson_085", "author_id": 2868801, "author_profile": "https://Stackoverflow.com/users/2868801", "pm_score": 2, "selected": true, "text": "curl -v https://host" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20187271/" ]
74,440,536
<p>Send mail with php mail() function.</p> <p>Please review my code. It is not sending mail and the landing page is not being called. I have tested with another script to send mail on my host and it is working fine.</p> <pre><code>&lt;?php &gt; if (isset($_POST['submit'])) { &gt; &gt; $name=$_POST['name']; &gt; $mailFrom=$_POST['email']; &gt; $message=$_POST['message']; &gt; $mobile=$_POST['mobile']; &gt; &gt; &gt; $mailTo=&quot;xxxxx&quot;; &gt; $headers= &quot;From : &quot;.$mailFrom; &gt; $txt =&quot;You have received an email from&quot;.$name. &quot;.\n\n&quot;.$message. &quot;.\n\n Mobile :&quot;.$mobile; &gt; $subject=&quot;Information Request&quot;; &gt; mail($mailTo, $subject, $txt, $headers); &gt; &gt; header(&quot;Location: xxx.html&quot;); //to create a landing page and test &gt; } &gt; ?&gt; </code></pre>
[ { "answer_id": 74441052, "author": "dave_thompson_085", "author_id": 2868801, "author_profile": "https://Stackoverflow.com/users/2868801", "pm_score": 2, "selected": true, "text": "curl -v https://host" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20403674/" ]
74,440,550
<p>Today, I tried starting a new project using JHipster. My environment includes:</p> <pre><code>Windows 10 22H2 build 19045.2251 (64 bit) OpenJDK Runtime Environment Temurin-16.0.2+7 node 16.17.0 npm 8.19.1 Gradle 7.5.1 MariaDB 10.6.8 Chrome 107.0.5304.107 </code></pre> <p>Project configuration file (myapp.jh) is:</p> <pre><code>application { config { baseName myapp, packageName com.mycompany.app, applicationType monolith, authenticationType jwt, cacheProvider ehcache, enableHibernateCache true, databaseType sql, devDatabaseType mariadb, prodDatabaseType mariadb, buildTool gradle, clientPackageManager npm, clientFramework angular, clientTheme minty, clientThemeVariant primary, testFrameworks [protractor, cypress], nativeLanguage en, languages [en, es], jhiPrefix myapp, jwtSecretKey &quot;YjAwZDU2ODI3NzNjZjk0NjVhY2UzNGViZmY0YjY1ZGY2MDI5MTc5Y2FlZWYxNzE5Yjg5ZjMxOGZhZTgwZjA5NTFkN2VmNDM3ZGMyZDNjZTViNDAwYTg4NmNlMmM2ZDkxZTMwMDk5YmUxNWNkZmE0YTNiNDlhMGNhZmM4OTk1NmQ=&quot; } } </code></pre> <p>I carried out the following steps in a shell command line:</p> <ul> <li>Installed the latest version of JHipster: <code>npm install -g generator-jhipster</code> --&gt; <strong>v7.9.3</strong></li> <li>Imported the JDL: <code>jhipster jdl myapp.jh</code></li> <li>Built the application: <code>gradle build</code></li> </ul> <p><em>Result</em>: Everything appears to build nicely up until the integration tests which <strong>ALL fail</strong>!</p> <p>All integration tests for the latest version of JHipster fail in virtually the same way:</p> <pre><code>HibernateTimeZoneIT &gt; storeLocalDateTimeWithZoneIdConfigShouldBeStoredOnGMTTimeZone() FAILED java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:132 Caused by: org.springframework.beans.factory.BeanCreationException at AbstractAutowireCapableBeanFactory.java:1804 Caused by: java.lang.IllegalStateException at DockerClientProviderStrategy.java:257 </code></pre> <p>Naturally, the first line of each error varies according to each failing test, but the following lines (<code>java.lang.IllegalStateException ...</code> onward) are the same for ALL failed tests. I have never seen errors like this before. It appears to have something to do with Docker/MariadbTestContainer.</p> <p>I repeated the steps for JHipster 7.9.2, and 7.9.0 -- with the same results -- all integration tests fail. (I even tried the maintenance build for 7.9.3, and get the same failures.) I also get the same errors if I run the integration tests directly with: <code>gradle integrationTest</code></p> <p>You can see the <code>gradle --scan</code> output <a href="https://scans.gradle.com/s/ur5vwgh7clgxo" rel="nofollow noreferrer">here</a></p> <p>Finally, I downgraded to JHipster 7.8.1 (released in April), and everything works (no failures).</p> <p>Are the last three JHipster releases (7.9.0, 7.9.2 and 7.9.3) broken? Has there been a new requirement introduced after v7.8.1? Am I doing something wrong?</p> <p>Please help!</p> <p>(I'm happy to provide ANY additional information.)</p> <p><strong>NOTE</strong>: If I forego the integration tests, and just run the application (by typing <code>./gradlew</code> in one shell, and <code>npm start</code> in another shell, the application <em>does</em> run/work...)</p>
[ { "answer_id": 74451931, "author": "Matt Raible", "author_id": 65681, "author_profile": "https://Stackoverflow.com/users/65681", "pm_score": 1, "selected": false, "text": "openjdk 17.0.5 2022-10-18\nOpenJDK Runtime Environment Temurin-17.0.5+8 (build 17.0.5+8)\nOpenJDK 64-Bit Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode)\n" }, { "answer_id": 74463719, "author": "Mike Smith", "author_id": 9035446, "author_profile": "https://Stackoverflow.com/users/9035446", "pm_score": 1, "selected": true, "text": "./README.md" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9035446/" ]
74,440,582
<p>I was able to encrypt the password using <code>CryptoJS</code> library in Angular project. And want to implement same encryption using <code>java</code>. Can any one suggest the best approach?.</p> <p><strong>Below is with Angular <code>CryptoJS</code> library implementation</strong></p> <pre><code>let hash = CryptoJS.SHA256(&quot;3456&quot;); let passBase64 = CryptoJS.enc.Base64.stringify(hash); </code></pre> <p>I have implemeted in the following way in java but the values are different,</p> <pre><code>Sha256.toHexString(Sha256.getSHA(&quot;3456&quot;))); public class Sha256 { public static byte[] getSHA(String input) throws NoSuchAlgorithmException { // Static getInstance method is called with hashing SHA MessageDigest md = MessageDigest.getInstance(&quot;SHA-256&quot;); // digest() method called // to calculate message digest of an input // and return array of byte return md.digest(input.getBytes(StandardCharsets.UTF_8)); } public static String toHexString(byte[] hash) { // Convert byte array into signum representation BigInteger number = new BigInteger(1, hash); // Convert message digest into hex value StringBuilder hexString = new StringBuilder(number.toString(16)); // Pad with leading zeros while (hexString.length() &lt; 64) { hexString.insert(0, '0'); } return hexString.toString(); } </code></pre>
[ { "answer_id": 74440625, "author": "Joma", "author_id": 3158594, "author_profile": "https://Stackoverflow.com/users/3158594", "pm_score": 0, "selected": false, "text": "let hash = CryptoJS.SHA256(\"grape\");\nlet passBase64 = CryptoJS.enc.Base64.stringify(hash);\nconsole.log(passBase64)\n" }, { "answer_id": 74488875, "author": "vishnu", "author_id": 4376984, "author_profile": "https://Stackoverflow.com/users/4376984", "pm_score": 0, "selected": false, "text": " public static String fileSha256ToBase64(final String clearText) throws NoSuchAlgorithmException {\n if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {\n return new String(\n Base64.getEncoder().encode(MessageDigest.getInstance(\"SHA-256\").digest(clearText.getBytes(StandardCharsets.UTF_8))));\n }\n return clearText;\n }\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4376984/" ]
74,440,583
<p>RDF IRI such as:</p> <ul> <li><a href="https://www.w3.org/1999/02/22-rdf-syntax-ns" rel="nofollow noreferrer">https://www.w3.org/1999/02/22-rdf-syntax-ns</a></li> <li><a href="https://www.dublincore.org/specifications/dublin-core/dcmi-terms/dublin_core_terms.ttl" rel="nofollow noreferrer">https://www.dublincore.org/specifications/dublin-core/dcmi-terms/dublin_core_terms.ttl</a></li> <li><a href="http://dbpedia.org/resource/Resource_Description_Framework" rel="nofollow noreferrer">http://dbpedia.org/resource/Resource_Description_Framework</a></li> <li><a href="http://purl.obolibrary.org/obo/GENEPIO_0100155" rel="nofollow noreferrer">http://purl.obolibrary.org/obo/GENEPIO_0100155</a></li> <li><a href="http://purl.obolibrary.org/obo/NCBITaxon_2697049" rel="nofollow noreferrer">http://purl.obolibrary.org/obo/NCBITaxon_2697049</a></li> <li>......</li> </ul> <p>I know that RDF IRI returns RDF data.</p> <p>I want to parse arbitrary RDF IRI and show it as a list on the page.</p>
[ { "answer_id": 74491080, "author": "chenkun", "author_id": 19464739, "author_profile": "https://Stackoverflow.com/users/19464739", "pm_score": 1, "selected": true, "text": "HTTP RDF IRI" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19464739/" ]
74,440,616
<p>My problem is related to Angular <code>@Input()</code> decorator, as when I am using this decorator, typescript throwing error, not when using in regular code.</p> <p>In my <code>child.component.ts</code> file I am declaring this decorator to get props from parent component :</p> <pre><code>@Input() customColumns: { name: string; index: number; type: 'icon' | 'image' | 'link' | 'button'; icon?: any; url?: string; }[] = []; indexList: number[] = []; </code></pre> <p>And in my <code>parent.component.ts</code> file I am assigning the value for this variable like this :</p> <pre><code>customColumns = [ { name: 'permissions', index: 7, type: 'icon', icon: faSave }, { name: 'price list', index: 6, type: 'link', icon: faArrowDownWideShort }, { name: 'details', index: 5, type: 'button', icon: faArrowUpWideShort }, ]; </code></pre> <p>Lastly, in my <code>parent.component.html</code> file I am calling that child component:</p> <pre><code>&lt;app-child [customColumns]=&quot;customColumns&quot;&gt; &lt;/app-child&gt; </code></pre> <p>But I'm getting this error:</p> <blockquote> <p>Types of property 'type' are incompatible.<br /> Type 'string' is not assignable to type '&quot;button&quot; | &quot;link&quot; | &quot;image&quot; | &quot;icon&quot;'.</p> </blockquote> <p>But when I am doing same thing in normal typescript or ngOnInit() function it is working, can't figure out why it is happening, help me please, thanks in advance.</p> <pre><code> let customColumns: { name: string; index: number; type: 'icon' | 'image' | 'link' | 'button'; icon?: any; url?: string; }[] = []; customColumns = [ { name: 'permissions', index: 7, type: 'link', icon: '' }, { name: 'price list', index: 6, type: 'icon', icon: faArrowDownWideShort, }, { name: 'details', index: 5, type: 'icon', icon: faArrowUpWideShort }, ]; </code></pre> <p>My project dependencies:</p> <blockquote> <pre><code>&quot;@angular/cli&quot;: &quot;~14.2.7&quot;, &quot;typescript&quot;: &quot;~4.7.2&quot; </code></pre> </blockquote>
[ { "answer_id": 74440769, "author": "Dinuka Silva", "author_id": 20457576, "author_profile": "https://Stackoverflow.com/users/20457576", "pm_score": 1, "selected": false, "text": "export class CustomColumns {\nconstructor(\npublic name?: string,\npublic index?: number,\npublic type?: 'icon' | 'image' | 'link' | 'button',\npublic icon?: any,\npublic url?: string\n){}\n}\n" }, { "answer_id": 74440815, "author": "yurzui", "author_id": 5485167, "author_profile": "https://Stackoverflow.com/users/5485167", "pm_score": 3, "selected": true, "text": "let customColumns: {\n name: string;\n index: number;\n type: 'icon' | 'image' | 'link' | 'button';\n icon?: any;\n url?: string;\n}[] = [];\n\nconst anotherValue = [\n { name: 'permissions', index: 7, type: 'link', icon: '' },\n {\n name: 'price list',\n index: 6,\n type: 'icon',\n },\n { name: 'details', index: 5, type: 'icon', icon: '' },\n];\ncustomColumns = anotherValue;\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14610912/" ]
74,440,629
<p>I am trying to fetch User from my own API which needs a token (i can store the token in localStorage or in Cookies). As there is no localStorage access when using server side rendering, i have to use cookies. But the cookie is undefined in the server. I tried several NPM packages.</p> <p>I just want to fetch the user from Api with user token and all this in SSR.</p> <p>this the code i am trying to work with.</p> <pre><code>import axios from &quot;axios&quot;; import React from &quot;react&quot;; import { URLs } from &quot;../../../app.config&quot;; const getUser = async () =&gt; { axios.defaults.withCredentials = true; axios.defaults.baseURL = URLs.backend; const token = &quot;&quot;; // * i need that token here axios.defaults.headers.common[&quot;Authorization&quot;] = &quot;Bearer &quot; + token; try { return await ( await axios.get(&quot;/user/user&quot;) ).data.user; } catch (err: any) { console.log(token); console.log(err.response.data); return null; } }; export default async function Login() { const user = await getUser(); if (!user) return &lt;div className=&quot;text-red-500&quot;&gt;No user found&lt;/div&gt;; return &lt;div&gt;Logged in User:{JSON.stringify(user)}&lt;/div&gt;; } </code></pre> <p>this is my dependencies</p> <pre><code> &quot;dependencies&quot;: { &quot;@types/node&quot;: &quot;18.11.9&quot;, &quot;@types/react&quot;: &quot;18.0.25&quot;, &quot;@types/react-dom&quot;: &quot;18.0.8&quot;, &quot;axios&quot;: &quot;^1.1.3&quot;, &quot;cookies-next&quot;: &quot;^2.1.1&quot;, &quot;eslint&quot;: &quot;8.27.0&quot;, &quot;eslint-config-next&quot;: &quot;13.0.3&quot;, &quot;framer-motion&quot;: &quot;^7.6.6&quot;, &quot;next&quot;: &quot;13.0.3&quot;, &quot;react&quot;: &quot;18.2.0&quot;, &quot;react-dom&quot;: &quot;18.2.0&quot;, &quot;react-icons&quot;: &quot;^4.6.0&quot;, &quot;react-loader-spinner&quot;: &quot;^5.3.4&quot;, &quot;socket.io-client&quot;: &quot;^4.5.3&quot;, &quot;sweetalert2&quot;: &quot;^11.6.8&quot;, &quot;swr&quot;: &quot;^1.3.0&quot;, &quot;typescript&quot;: &quot;4.8.4&quot; }, </code></pre> <p>I tried npm packages</p> <pre><code>react-cookie cookies-next </code></pre> <p>Or is there any other way to get the cookie from users browser and use SSR? I found solutions of Next Js 12 but in version 13 there is no _app.js file or getServerSideProps functions. I want to get cookies with Next Js 13 App folder structure.</p>
[ { "answer_id": 74641989, "author": "Nicolai Lissau", "author_id": 1116508, "author_profile": "https://Stackoverflow.com/users/1116508", "pm_score": 0, "selected": false, "text": "next/headers" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16690055/" ]
74,440,632
<p>I have a png image of a person's head when I hover on it I want the head to get white outline about 5px I tried to use</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> imgOnHover: { filter: 'drop-shadow(5px 5px 5px #FFF)', },</code></pre> </div> </div> </p> <p>but it is kind of faded and it comes from one side.</p>
[ { "answer_id": 74641989, "author": "Nicolai Lissau", "author_id": 1116508, "author_profile": "https://Stackoverflow.com/users/1116508", "pm_score": 0, "selected": false, "text": "next/headers" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15357136/" ]
74,440,655
<p>I'm making an async call inside useEffect. When the promise resolves, I am able to successfully log the data in the response. However, after I set state and index into it, I get an empty array and an error. How come my array did not get set? I am using Typescript.</p> <pre><code>const [codeTemplate, setCodeTemplate] = useState([]) const [code, setCode] = useState(&quot;&quot;) useEffect(() =&gt; { getQuestion({questionName}.questionName) .then(resp =&gt; { console.log(resp.data.question_template) setCodeTemplate(resp.data.question_template) console.log(codeTemplate) setCode(codeTemplate[0]['boilerplate']) }) }, []) </code></pre> <p>Console output:</p> <pre><code>(3) [{...}, {...}, {...}] [] QuestionPage.tsx:79 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'boilerplate') </code></pre>
[ { "answer_id": 74641989, "author": "Nicolai Lissau", "author_id": 1116508, "author_profile": "https://Stackoverflow.com/users/1116508", "pm_score": 0, "selected": false, "text": "next/headers" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3030419/" ]
74,440,677
<p>so i have an array like this, that i want to find the unique value with then count:</p> <pre><code>users: [ '21000316', '21000316', '21000316', '21000316', '22000510', '22000510', '22000510', '22000510' ] </code></pre> <p>is it possible for me to get the unique value and count it from the array without using sort()? and turn it into this value i try some code but only get the count and the unique value separetely:</p> <pre><code>{'21000316':4,'21000510':4} </code></pre>
[ { "answer_id": 74440703, "author": "Finbar", "author_id": 17525834, "author_profile": "https://Stackoverflow.com/users/17525834", "pm_score": 3, "selected": true, "text": "const users = ['1', '1', '2', '3', '3', '3', '3'];\nconst result = {};\n\nfor(const user in users)\n result[users[user]] = (result[users[user]] || 0) + 1;\n\nconsole.log(result);" }, { "answer_id": 74440764, "author": "Allan Wind", "author_id": 9706, "author_profile": "https://Stackoverflow.com/users/9706", "pm_score": 1, "selected": false, "text": "const users = [\n '21000316',\n '21000316',\n '21000316',\n '21000316',\n '22000510',\n '22000510',\n '22000510',\n '22000510'\n];\nconsole.log(users.reduce((m, k) => { m[k] = m[k] + 1 || 1; return m }, {}));" }, { "answer_id": 74440798, "author": "dangerousmanleesanghyeon", "author_id": 14527497, "author_profile": "https://Stackoverflow.com/users/14527497", "pm_score": 1, "selected": false, "text": "let users = [ '21000316',\n '21000316',\n '21000316',\n '21000316',\n '22000510',\n '22000510',\n '22000510',\n '22000510' ];\n \nlet set = new Set(users);\n\nlet res = [...set.keys()].reduce((pre, cur) => {\n pre[cur] = users.filter(u => u === cur).length;\n return pre;\n}, {})\n\nconsole.log(res)" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16136595/" ]
74,440,680
<p>I am trying to compare two CSV files and print the differences in Python as a custom text file.</p> <p>For example:</p> <p>CSV 1:</p> <pre><code>Id, Customer, Status, Date 01, ABC, Good, Mar 2023 02, BAC, Good, Feb 2024 03, CBA, Bad, Apr 2022 </code></pre> <p>CSV 2:</p> <pre><code>Id, Customer, Status, Date 01, ABC, Bad, Mar 2023 02, BAC, Good, Feb 2024 03, CBA, Good, Apr 2024 </code></pre> <p>Expected Output:</p> <pre><code>Id 01 Status is changed to Bad Id 03 Status is changed to Good Id 03 Date changed is to Apr 2024 </code></pre> <p>Any suggestion/idea to code for the expected output. Thanks</p>
[ { "answer_id": 74440703, "author": "Finbar", "author_id": 17525834, "author_profile": "https://Stackoverflow.com/users/17525834", "pm_score": 3, "selected": true, "text": "const users = ['1', '1', '2', '3', '3', '3', '3'];\nconst result = {};\n\nfor(const user in users)\n result[users[user]] = (result[users[user]] || 0) + 1;\n\nconsole.log(result);" }, { "answer_id": 74440764, "author": "Allan Wind", "author_id": 9706, "author_profile": "https://Stackoverflow.com/users/9706", "pm_score": 1, "selected": false, "text": "const users = [\n '21000316',\n '21000316',\n '21000316',\n '21000316',\n '22000510',\n '22000510',\n '22000510',\n '22000510'\n];\nconsole.log(users.reduce((m, k) => { m[k] = m[k] + 1 || 1; return m }, {}));" }, { "answer_id": 74440798, "author": "dangerousmanleesanghyeon", "author_id": 14527497, "author_profile": "https://Stackoverflow.com/users/14527497", "pm_score": 1, "selected": false, "text": "let users = [ '21000316',\n '21000316',\n '21000316',\n '21000316',\n '22000510',\n '22000510',\n '22000510',\n '22000510' ];\n \nlet set = new Set(users);\n\nlet res = [...set.keys()].reduce((pre, cur) => {\n pre[cur] = users.filter(u => u === cur).length;\n return pre;\n}, {})\n\nconsole.log(res)" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20506563/" ]
74,440,706
<p>Because of my lack of understanding of Powershell objects my question may not be worded accurately. I take it from the documentation <a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/foreach-object?view=powershell-7.3" rel="nofollow noreferrer">Powershell 7.3 ForEach-Object</a> that I am using a script block &amp; utilizing the Powershell automatic variable <code>$_</code> But that is about as relevant to my example that these docs get.</p> <p>I'm trying to access each of two parts of a collection of text file type name/address listings. Namely the first three listings (001 - 003) or the second three (004 - 006)</p> <p>Using <code>$regexListings</code> and <code>$testListings</code> I have tested that I can access, the first three or second three listings, using references to the capture groups e.g <code>$1 $2</code> See this example running here: <a href="https://regex101.com/r/bQiCj1/1" rel="nofollow noreferrer">regex101</a></p> <p>When I run the following Powershell code:</p> <pre><code>$regexListings = '(?s)(001.*?003.*?$)|(004.*?006.*?$)' $testListings = '001 AALTON Alan 25 Every Street 002 BROWN James 101 Browns Road 003 BROWN Jemmima 101 Browns Road 004 BROWN John 101 Browns Road 005 CAMPBELL Colin 57 Camp Avenue 006 DONNAGAN Dolores 11 Main Road' $testListings | Select-String -AllMatches -Pattern $regexListings | ForEach-Object {$_.Matches} </code></pre> <p>Output is:</p> <pre><code>Groups : {0, 1, 2} Success : True Name : 0 Captures : {0} Index : 0 Length : 204 Value : 001 AALTON Alan 25 Every Street 002 BROWN James 101 Browns Road 003 BROWN Jemmima 101 Browns Road 004 BROWN John 101 Browns Road 005 CAMPBELL Colin 57 Camp Avenue 006 DONNAGAN Dolores 11 Main Road ValueSpan : </code></pre> <p>My interpretation of the Powershell output is:</p> <ul> <li>there are 3 match groups?</li> <li>no captures available</li> <li>the value is all of it?</li> </ul> <p>Why does the Powershell script output <code>Captures {0}</code> when the link page (regex101) above describes two capture groups which I can access?</p> <p>The documentation <a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_regular_expressions?view=powershell-7.3" rel="nofollow noreferrer">Groups, Captures, and Substitutions</a> is helpful but doesn't address this kind of issue. I have gone on using trial &amp; error examples like:</p> <pre><code>ForEach-Object {$_.Matches.Groups} ForEach-Object {$_.Matches.Captures} ForEach-Object {$_.Matches.Value} </code></pre> <p>And I'm still none the wiser.</p>
[ { "answer_id": 74440703, "author": "Finbar", "author_id": 17525834, "author_profile": "https://Stackoverflow.com/users/17525834", "pm_score": 3, "selected": true, "text": "const users = ['1', '1', '2', '3', '3', '3', '3'];\nconst result = {};\n\nfor(const user in users)\n result[users[user]] = (result[users[user]] || 0) + 1;\n\nconsole.log(result);" }, { "answer_id": 74440764, "author": "Allan Wind", "author_id": 9706, "author_profile": "https://Stackoverflow.com/users/9706", "pm_score": 1, "selected": false, "text": "const users = [\n '21000316',\n '21000316',\n '21000316',\n '21000316',\n '22000510',\n '22000510',\n '22000510',\n '22000510'\n];\nconsole.log(users.reduce((m, k) => { m[k] = m[k] + 1 || 1; return m }, {}));" }, { "answer_id": 74440798, "author": "dangerousmanleesanghyeon", "author_id": 14527497, "author_profile": "https://Stackoverflow.com/users/14527497", "pm_score": 1, "selected": false, "text": "let users = [ '21000316',\n '21000316',\n '21000316',\n '21000316',\n '22000510',\n '22000510',\n '22000510',\n '22000510' ];\n \nlet set = new Set(users);\n\nlet res = [...set.keys()].reduce((pre, cur) => {\n pre[cur] = users.filter(u => u === cur).length;\n return pre;\n}, {})\n\nconsole.log(res)" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15542245/" ]
74,440,727
<p>i have the following routes in my main</p> <pre><code>routes: { '/sign-in': (context) =&gt; BlocProvider( lazy: false, create: (_) =&gt; AuthCubit(), child: const LandingPage(), ), '/home': (context) =&gt; const HomeLandingPage(), '/sign-up': (context) =&gt; const SignUpLandingPage(), '/language-selection': (context) =&gt; const SelectionLanguageScreen(), '/camera-page': (context) =&gt; CameraPage(), '/web-add-page': (context) =&gt; const WebAddPage() }, </code></pre> <p>i'm having issues implementing Routes to my <code>WebAddPage()</code> because <code>WebAddPage()</code> is a widget that is threated as a screen.</p> <pre><code> final screens = [ //screens is a List&lt;Widget&gt; const WebAddPage(), const WebUpdateProducts(), const WebUpdateCategories(), const WebUpdateStores(), const WebUpdateUsers() ]; </code></pre> <p>i'm not using <code>Navigator.push</code> because i'm not changing to a new screen i'm just changing widgets. is there a way the implement the Routes system to this array. i also need the url path to matches the route.</p> <p><code>Navigator.push</code> apparently didn't work, also adding the key word of the route change the type of the <code>List&lt;Widget&gt;</code> to a <code>List&lt;object&gt;</code> but because im implementing the screens into a child i can't use the <code>List&lt;object&gt;</code> because the type 'Object' can't be assigned to the parameter type 'Widget?'</p>
[ { "answer_id": 74441849, "author": "An Nguyen", "author_id": 20507354, "author_profile": "https://Stackoverflow.com/users/20507354", "pm_score": -1, "selected": false, "text": "final List<Widget> pages = const [\n HomePage(),\n SearchPage(),\n NotificationsPage(),\n SettingPage() ];\n\n @override Widget build(BuildContext context) {\n return Scaffold(\n appBar: AppBar(\n title: Text(\n _title,\n style: Theme.of(context).textTheme.headline2,\n )),\n body: pages[_currentIndex],\n bottomNavigationBar: Container(\n decoration: BoxDecoration(\n boxShadow: [\n BoxShadow(color: ColorManager.lightGray, spreadRadius: 0.5)\n ],\n ),\n child: BottomNavigationBar(\n selectedItemColor: ColorManager.primary,\n unselectedItemColor: ColorManager.gray,\n currentIndex: _currentIndex,\n onTap: onTap,\n items: const [\n BottomNavigationBarItem(\n icon: Icon(Icons.home), label: AppStrings.home),\n BottomNavigationBarItem(\n icon: Icon(Icons.search), label: AppStrings.search),\n BottomNavigationBarItem(\n icon: Icon(Icons.notifications),\n label: AppStrings.notification),\n BottomNavigationBarItem(\n icon: Icon(Icons.settings), label: AppStrings.setting),\n ],\n ),\n ),\n ); }\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440727", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17110550/" ]
74,440,738
<p>In my controller, I got three parameters. (GET : /Class/List)</p> <pre><code>public class ClassController : Controller { public ActionResult List(string classCode = null, string className = null, List&lt;string&gt; semester = null) { ... } } </code></pre> <p>And I got this in my nav bar...</p> <pre><code>&lt;a class=&quot;nav-link text-dark&quot; asp-area=&quot;&quot; asp-controller=&quot;Class&quot; asp-action=&quot;List&quot;&gt;Classes&lt;/a&gt; </code></pre> <p>I would like to pass a value of the parameter semester so that the link will look like <code>localhost/Class/List?semester=9&amp;semester=1</code>. Thank you!</p> <p>I have tried ViewBag and asp-route-id but I failed.</p>
[ { "answer_id": 74441849, "author": "An Nguyen", "author_id": 20507354, "author_profile": "https://Stackoverflow.com/users/20507354", "pm_score": -1, "selected": false, "text": "final List<Widget> pages = const [\n HomePage(),\n SearchPage(),\n NotificationsPage(),\n SettingPage() ];\n\n @override Widget build(BuildContext context) {\n return Scaffold(\n appBar: AppBar(\n title: Text(\n _title,\n style: Theme.of(context).textTheme.headline2,\n )),\n body: pages[_currentIndex],\n bottomNavigationBar: Container(\n decoration: BoxDecoration(\n boxShadow: [\n BoxShadow(color: ColorManager.lightGray, spreadRadius: 0.5)\n ],\n ),\n child: BottomNavigationBar(\n selectedItemColor: ColorManager.primary,\n unselectedItemColor: ColorManager.gray,\n currentIndex: _currentIndex,\n onTap: onTap,\n items: const [\n BottomNavigationBarItem(\n icon: Icon(Icons.home), label: AppStrings.home),\n BottomNavigationBarItem(\n icon: Icon(Icons.search), label: AppStrings.search),\n BottomNavigationBarItem(\n icon: Icon(Icons.notifications),\n label: AppStrings.notification),\n BottomNavigationBarItem(\n icon: Icon(Icons.settings), label: AppStrings.setting),\n ],\n ),\n ),\n ); }\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20506452/" ]
74,440,749
<p>I'm trying to only validate React Hook Form when the <strong>is:</strong> is true then run the <strong>then:</strong> validation. What I have so far is showing isValid= true in React-hook-form which it should not until all statements have been validated.</p> <p>Sequance of validation should be: show invalid and when the <strong>is=true</strong> then run validation in the <strong>then:</strong> and update react hook form isValid based only on the then value ?</p> <pre><code>const regex = /^(([^&lt;&gt;()[\]\\.,;:\s@&quot;]+(\.[^&lt;&gt;()[\]\\.,;:\s@&quot;]+)*)|(&quot;.+&quot;))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ export const emailSchema = yup.object().shape({ email: yup .string() .when({ is: (val: string) =&gt; { console.log('val = ', val, ' test = ', /@.+/.test(val)) return /@.+/.test(val) }, then: yup.string().matches(regex, { message: 'Invalid Email' }), }), }) </code></pre>
[ { "answer_id": 74441849, "author": "An Nguyen", "author_id": 20507354, "author_profile": "https://Stackoverflow.com/users/20507354", "pm_score": -1, "selected": false, "text": "final List<Widget> pages = const [\n HomePage(),\n SearchPage(),\n NotificationsPage(),\n SettingPage() ];\n\n @override Widget build(BuildContext context) {\n return Scaffold(\n appBar: AppBar(\n title: Text(\n _title,\n style: Theme.of(context).textTheme.headline2,\n )),\n body: pages[_currentIndex],\n bottomNavigationBar: Container(\n decoration: BoxDecoration(\n boxShadow: [\n BoxShadow(color: ColorManager.lightGray, spreadRadius: 0.5)\n ],\n ),\n child: BottomNavigationBar(\n selectedItemColor: ColorManager.primary,\n unselectedItemColor: ColorManager.gray,\n currentIndex: _currentIndex,\n onTap: onTap,\n items: const [\n BottomNavigationBarItem(\n icon: Icon(Icons.home), label: AppStrings.home),\n BottomNavigationBarItem(\n icon: Icon(Icons.search), label: AppStrings.search),\n BottomNavigationBarItem(\n icon: Icon(Icons.notifications),\n label: AppStrings.notification),\n BottomNavigationBarItem(\n icon: Icon(Icons.settings), label: AppStrings.setting),\n ],\n ),\n ),\n ); }\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1096499/" ]
74,440,793
<p>I'm using updating out Exchange Mail Client written in .NET 4 Framework using Exchange Web Services (EWS) to .NET Core 6 using Microsoft.Graph. I've managed to port most of the functions but I'm having trouble working out how to Forward a Message as an Attachment.</p> <p>In EWS</p> <pre><code>// This method results in a GetItem call to EWS. var msgToAttach = EWS.EmailMessage.Bind( ServiceInstance, message.Source.Id, new EWS.PropertySet(EWS.ItemSchema.MimeContent, EWS.ItemSchema.Subject)); // Create an email message and set properties on the message. var forward = new EWS.EmailMessage(ServiceInstance); if (!bodyType.HasValue) bodyType = message.BodyType; forward.Subject = subject == null ? $&quot;FW: {message.Subject}&quot; : subject; forward.Body = new EWS.MessageBody( bodyType.Value == BodyTypes.Html ? EWS.BodyType.HTML : EWS.BodyType.Text, body ?? &quot;Please refer to the attachment message&quot;); // Add additional recipients to the reply email message. if (to?.Any() ?? false) forward.ToRecipients.AddRange(to); if (cc?.Any() ?? false) forward.CcRecipients.AddRange(cc); if (bcc?.Any() ?? false) forward.BccRecipients.AddRange(bcc); // before we can add the attachments, we need to save the draft // according to the docoumentation this isn't required but without // it throws an exception on Save/SendAndSaveCopy if the attachments // are added to a message which doesn't exist forward.Save(); // Add an email message item attachment and set properties on the item. EWS.ItemAttachment&lt;EWS.EmailMessage&gt; itemAttachment = forward.Attachments.AddItemAttachment&lt;EWS.EmailMessage&gt;(); itemAttachment.Item.MimeContent = msgToAttach.MimeContent; itemAttachment.Name = msgToAttach.Subject; // Send the mail and save a copy in the Sent Items folder. // This method results in a CreateItem and SendItem call to EWS. forward.Update(EWS.ConflictResolutionMode.AlwaysOverwrite); forward.Send(); </code></pre> <p><strong>UPDATE: Solution</strong> You can read the mime content using</p> <p>_serviceInstance.Users[UserId].Messages[message.Id].Content.GetAsync()</p> <p>which returns a stream that can be saved as .eml file. The attachment name must end with .eml or it doesn't work.</p> <pre><code> public void ForwardMessageAsAttachment( Message message, IEnumerable&lt;string&gt; to, string subject = null, string body = null, BodyType? bodyType = null) { // Download the mime content for the specific message var mimeContentStream = _serviceInstance .Users[UserId] .Messages[message.Id] .Content .Request() .GetAsync() .GetAwaiter() .GetResult(); // the mine content is returned as a Stream, so write it to buffer var buffer = new Span&lt;Byte&gt;(new byte[mimeContentStream.Length]); var mimeContent = mimeContentStream.Read(buffer); // The attachment Name must ends with .eml else Outlook wont recognize its an email // even with the contentType = message/rfc822 var messageAsAttachment = new FileAttachment { ContentBytes = buffer.ToArray(), ContentType = &quot;message/rfc822&quot;, Name = $&quot;{message.Subject}.eml&quot; }; // create a new message var forward = new Message() { Attachments = new MessageAttachmentsCollectionPage(), Subject = String.IsNullOrWhiteSpace(subject) ? subject : $&quot;FW: {message.Subject}&quot;.Trim(), Body = new ItemBody { ContentType = bodyType, Content = body }, ToRecipients = to.Select(x =&gt; new Recipient { EmailAddress = new EmailAddress { Address = x } }) }; // add the EML attachment forward.Attachments.Add(messageAsAttachment); _serviceInstance .Users[UserId] .SendMail(forward) .Request() .PostAsync() .GetAwaiter() .GetResult(); } </code></pre>
[ { "answer_id": 74441849, "author": "An Nguyen", "author_id": 20507354, "author_profile": "https://Stackoverflow.com/users/20507354", "pm_score": -1, "selected": false, "text": "final List<Widget> pages = const [\n HomePage(),\n SearchPage(),\n NotificationsPage(),\n SettingPage() ];\n\n @override Widget build(BuildContext context) {\n return Scaffold(\n appBar: AppBar(\n title: Text(\n _title,\n style: Theme.of(context).textTheme.headline2,\n )),\n body: pages[_currentIndex],\n bottomNavigationBar: Container(\n decoration: BoxDecoration(\n boxShadow: [\n BoxShadow(color: ColorManager.lightGray, spreadRadius: 0.5)\n ],\n ),\n child: BottomNavigationBar(\n selectedItemColor: ColorManager.primary,\n unselectedItemColor: ColorManager.gray,\n currentIndex: _currentIndex,\n onTap: onTap,\n items: const [\n BottomNavigationBarItem(\n icon: Icon(Icons.home), label: AppStrings.home),\n BottomNavigationBarItem(\n icon: Icon(Icons.search), label: AppStrings.search),\n BottomNavigationBarItem(\n icon: Icon(Icons.notifications),\n label: AppStrings.notification),\n BottomNavigationBarItem(\n icon: Icon(Icons.settings), label: AppStrings.setting),\n ],\n ),\n ),\n ); }\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/381582/" ]
74,440,803
<p>I am doing the EAT+ THAT= APPLE, where each letter represents a different number from 0-9. I need to find all combinations. I was wondering if there is a better way to write it, especially 'if' and 'for'</p> <p>I've tried writing it like this but it gave me infinite results</p> <pre><code>public class Main { public static void main(String[] args) { int count = 0; int E,A,T,P,L,H; for (E = 0; E &lt;=9; E++) { for (A = 0; A &lt;=9; A++) for (T = 0; T &lt;=9; T++) for (P = 0; P &lt;=9; P++) for (L = 0; L &lt;=9; L++) for (H = 0; H &lt;=9; H++) if (((E != A) &amp;&amp; (E != L) &amp;&amp; (E != T)&amp;&amp;(E !=P) &amp;&amp;(E!=L)&amp;&amp;(E!=H) &amp;&amp; (T != A) &amp;&amp; (T != L) &amp;&amp; (T != E) &amp;&amp;(T!=P)&amp;&amp;(T!=L)&amp;&amp;(T!=H))) { System.out.println(&quot;A&quot;+A+&quot;P&quot;+P+&quot;P&quot;+P+&quot;L&quot;+L+&quot;E&quot;+E); } else count = count +1; } System.out.println(count); } } </code></pre>
[ { "answer_id": 74441264, "author": "Syed Asad Manzoor", "author_id": 20477563, "author_profile": "https://Stackoverflow.com/users/20477563", "pm_score": -1, "selected": false, "text": "**Second Version of Code**\n\npublic class EatingApple {\n ArrayList<Permutation> eat = new ArrayList();\nstatic ArrayList<Permutation> that = new ArrayList();\nstatic ArrayList<Permutation> apples = new ArrayList();\n \n public static void main(String[] args) throws IOException {\n EatingApple apples = new EatingApple();\n apples.makePermutation();\n apples.searchAppleEqualsSum();\n \n \n \n }\n\n public void searchAppleEqualsSum() \n {\n for(Permutation eatP : eat)\n {\n int E_eat = (Integer) eatP.getCharacterValue(\"E\");\n int A_eat = (Integer) eatP.getCharacterValue(\"A\");\n int T_eat = (Integer) eatP.getCharacterValue(\"T\");\n for(Permutation thatP : that)\n {\n int T_that = (Integer) thatP.getCharacterValue(\"T\");\n int A_that = (Integer) thatP.getCharacterValue(\"A\");\n if(T_eat == T_that&&A_eat ==A_that)\n for(Permutation apple : apples)\n {\n int A_apple = (Integer) apple.getCharacterValue(\"A\");\n int E_apple = (Integer) apple.getCharacterValue(\"E\");\n if(A_apple==E_eat&&E_apple==E_eat)\n {\n int eat_value = Integer.parseInt(eatP.permutationString);\n int that_value = Integer.parseInt(thatP.permutationString);\n int apple_value = Integer.parseInt(apple.permutationString);\n if(apple_value == (that_value + eat_value)&&apple_value!=0)\n {\n System.out.println(\"EAT :\" + eatP.permutationString);\n System.out.println(\"THAT :\" + thatP.permutationString);\n System.out.println(\"Apple :\" + apple.permutationString);\n System.out.println(\".............\");\n }\n }\n }\n \n \n \n }\n \n }\n }\n public void makePermutation()\n {\n for(int e=0;e<10;e++)\n for(int a=0;a<10;a++)\n for(int t=0;t<10;t++)\n {\n String permutationString = \"\"+e+a+t;\n int value = e+a+t;\n Permutation eatCombination = new Permutation(permutationString,value);\n eatCombination.addCharToMap(\"E\", e);\n eatCombination.addCharToMap(\"A\", a);\n eatCombination.addCharToMap(\"T\", t);\n eatCombination.permutationValue=value;\n \n \n eat.add(eatCombination);\n \n }\n \n for (int t = 0; t < 10; t++)\n for (int h = 0; h < 10; h++) \n for(int a = 0; a < 10;a++)\n {\n String permutationString = \"\"+t+h+a+t;\n int value = t + h + a + t;\n \n Permutation thatCombination = new Permutation(permutationString,value);\n \n \n thatCombination.addCharToMap(\"T\", t);\n thatCombination.addCharToMap(\"H\", h);\n thatCombination.addCharToMap(\"A\", a);\n thatCombination.permutationValue=value;\n \n that.add(thatCombination);\n \n }\n for (int a = 0; a < 10; a++)\n for (int p = 0; p < 10; p++) \n for(int l = 0; l <10;l++)\n for(int e = 0; e < 10; e++)\n \n {\n String permutationString = \"\"+a+p+p+l+e;\n int value = a+p+p+l+e;\n \n \n Permutation appleCombination = new Permutation(permutationString,value);\n \n appleCombination.addCharToMap(\"A\", a);\n appleCombination.addCharToMap(\"P\", p);\n appleCombination.addCharToMap(\"L\", l);\n appleCombination.addCharToMap(\"E\", e);\n \n appleCombination.permutationValue=value;\n \n apples.add(appleCombination);\n \n \n }\n \n \n }\n class Permutation\n {\n String permutationString=\"\";\n int permutationValue =0;\n HashMap wordMap;\n\n public int getPermuttionValue() {\n return permutationValue;\n }\n Permutation(String pString, int pValue)\n {\n this.wordMap = new HashMap();\n this.permutationString=pString;\n this.permutationValue=pValue;\n }\n public int getCharacterValue(String character)\n {\n if(wordMap.get(character)==null)\n return -1;\n return (Integer) wordMap.get(character);\n \n \n }\n public void addCharToMap(String character, int value)\n {\n \n wordMap.put(character, value);\n }\n \n\n \n }\n}\n" }, { "answer_id": 74444873, "author": "Warm Red", "author_id": 14209943, "author_profile": "https://Stackoverflow.com/users/14209943", "pm_score": 3, "selected": true, "text": "THAT" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19705717/" ]
74,440,817
<p>I have a df1 with column values as below</p> <pre><code>names AB DC DE FG GG TR </code></pre> <p>Another df2 as</p> <pre><code>date names 2022-11-01 AB 2022-11-01 DE 2011-11-01 FG 2022-11-02 DC 2022-11-02 GG 2022-11-02 TR </code></pre> <p>I want to check if all values of df1 column exists in df2 names column, if yes update true else false in a new column.</p> <p>I am able to do it for a given single date using dataframes with flag column. Using when.otherwise to check the flag value. I am not to run this across many days.</p>
[ { "answer_id": 74441264, "author": "Syed Asad Manzoor", "author_id": 20477563, "author_profile": "https://Stackoverflow.com/users/20477563", "pm_score": -1, "selected": false, "text": "**Second Version of Code**\n\npublic class EatingApple {\n ArrayList<Permutation> eat = new ArrayList();\nstatic ArrayList<Permutation> that = new ArrayList();\nstatic ArrayList<Permutation> apples = new ArrayList();\n \n public static void main(String[] args) throws IOException {\n EatingApple apples = new EatingApple();\n apples.makePermutation();\n apples.searchAppleEqualsSum();\n \n \n \n }\n\n public void searchAppleEqualsSum() \n {\n for(Permutation eatP : eat)\n {\n int E_eat = (Integer) eatP.getCharacterValue(\"E\");\n int A_eat = (Integer) eatP.getCharacterValue(\"A\");\n int T_eat = (Integer) eatP.getCharacterValue(\"T\");\n for(Permutation thatP : that)\n {\n int T_that = (Integer) thatP.getCharacterValue(\"T\");\n int A_that = (Integer) thatP.getCharacterValue(\"A\");\n if(T_eat == T_that&&A_eat ==A_that)\n for(Permutation apple : apples)\n {\n int A_apple = (Integer) apple.getCharacterValue(\"A\");\n int E_apple = (Integer) apple.getCharacterValue(\"E\");\n if(A_apple==E_eat&&E_apple==E_eat)\n {\n int eat_value = Integer.parseInt(eatP.permutationString);\n int that_value = Integer.parseInt(thatP.permutationString);\n int apple_value = Integer.parseInt(apple.permutationString);\n if(apple_value == (that_value + eat_value)&&apple_value!=0)\n {\n System.out.println(\"EAT :\" + eatP.permutationString);\n System.out.println(\"THAT :\" + thatP.permutationString);\n System.out.println(\"Apple :\" + apple.permutationString);\n System.out.println(\".............\");\n }\n }\n }\n \n \n \n }\n \n }\n }\n public void makePermutation()\n {\n for(int e=0;e<10;e++)\n for(int a=0;a<10;a++)\n for(int t=0;t<10;t++)\n {\n String permutationString = \"\"+e+a+t;\n int value = e+a+t;\n Permutation eatCombination = new Permutation(permutationString,value);\n eatCombination.addCharToMap(\"E\", e);\n eatCombination.addCharToMap(\"A\", a);\n eatCombination.addCharToMap(\"T\", t);\n eatCombination.permutationValue=value;\n \n \n eat.add(eatCombination);\n \n }\n \n for (int t = 0; t < 10; t++)\n for (int h = 0; h < 10; h++) \n for(int a = 0; a < 10;a++)\n {\n String permutationString = \"\"+t+h+a+t;\n int value = t + h + a + t;\n \n Permutation thatCombination = new Permutation(permutationString,value);\n \n \n thatCombination.addCharToMap(\"T\", t);\n thatCombination.addCharToMap(\"H\", h);\n thatCombination.addCharToMap(\"A\", a);\n thatCombination.permutationValue=value;\n \n that.add(thatCombination);\n \n }\n for (int a = 0; a < 10; a++)\n for (int p = 0; p < 10; p++) \n for(int l = 0; l <10;l++)\n for(int e = 0; e < 10; e++)\n \n {\n String permutationString = \"\"+a+p+p+l+e;\n int value = a+p+p+l+e;\n \n \n Permutation appleCombination = new Permutation(permutationString,value);\n \n appleCombination.addCharToMap(\"A\", a);\n appleCombination.addCharToMap(\"P\", p);\n appleCombination.addCharToMap(\"L\", l);\n appleCombination.addCharToMap(\"E\", e);\n \n appleCombination.permutationValue=value;\n \n apples.add(appleCombination);\n \n \n }\n \n \n }\n class Permutation\n {\n String permutationString=\"\";\n int permutationValue =0;\n HashMap wordMap;\n\n public int getPermuttionValue() {\n return permutationValue;\n }\n Permutation(String pString, int pValue)\n {\n this.wordMap = new HashMap();\n this.permutationString=pString;\n this.permutationValue=pValue;\n }\n public int getCharacterValue(String character)\n {\n if(wordMap.get(character)==null)\n return -1;\n return (Integer) wordMap.get(character);\n \n \n }\n public void addCharToMap(String character, int value)\n {\n \n wordMap.put(character, value);\n }\n \n\n \n }\n}\n" }, { "answer_id": 74444873, "author": "Warm Red", "author_id": 14209943, "author_profile": "https://Stackoverflow.com/users/14209943", "pm_score": 3, "selected": true, "text": "THAT" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8375724/" ]
74,440,827
<p>I am currently studying CUDA and learned that there are global memory and shared memory.</p> <p>I have checked the CUDA document and found that GPUs can access shared memory and global memory using ld.shared/st.shared and ld.global/st.global instructions, respectively.</p> <p>What I am curious about is what instruction is used to load data from global memory to shared memory?</p> <p>It would be great if someone could let me know.</p> <p>Thanks!</p> <pre><code>__global__ void my_function(int* global_mem) { __shared__ int shared_mem[10]; for(int i = 0; i &lt; 10; i++) { shared_mem[i] = global_mem[i]; // What instrcuton is used for this load operation? } } </code></pre>
[ { "answer_id": 74440857, "author": "Kryrena", "author_id": 18229254, "author_profile": "https://Stackoverflow.com/users/18229254", "pm_score": 4, "selected": true, "text": "__shared__ float smem[2];\nsmem[0] = global_memory[0];\n" }, { "answer_id": 74442159, "author": "Abator Abetor", "author_id": 5206464, "author_profile": "https://Stackoverflow.com/users/5206464", "pm_score": 2, "selected": false, "text": "cp.async.ca.shared.global" }, { "answer_id": 74442307, "author": "einpoklum", "author_id": 1593077, "author_profile": "https://Stackoverflow.com/users/1593077", "pm_score": 2, "selected": false, "text": "#define NO_ZFILL 0\n\n// ...\n\nfor(int i = 0; i < 10; i++) {\n __pipeline_memcpy_async(&shared_mem[i], &global_mem[i], sizeof(int), NO_ZFILL);\n}\n__pipeline_commit();\n__pipeline_wait_prior(0); // wait for the first commited batch of pipeline ops\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440827", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12311185/" ]
74,440,828
<p>I am doing this exercise from the book Eloquent JavaScript and I am trying to <strong>subtract a list using the reduce function</strong> and show the sum at the end. This is what I have:</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 getRange(start, end, step) { let arraylist = []; if (start &lt; end) { for (let i = start; i &lt;= end; i += step) { arraylist.push(i); } let sum = arraylist.reduce(function(accumulator, n) { return accumulator + n; }, 0); return arraylist.join(" + ") + " = " + sum; } else { for (let i = start; i &gt;= end; i += step) { arraylist.push(i); } let sum2 = arraylist.reduce(function(accumulator, n) { return accumulator - n; }, 0); return arraylist.join(" - ") + " = " + sum2; } } console.log(getRange(10, 5, -1));</code></pre> </div> </div> </p> <p>this is what I get when I run the code.</p>
[ { "answer_id": 74440857, "author": "Kryrena", "author_id": 18229254, "author_profile": "https://Stackoverflow.com/users/18229254", "pm_score": 4, "selected": true, "text": "__shared__ float smem[2];\nsmem[0] = global_memory[0];\n" }, { "answer_id": 74442159, "author": "Abator Abetor", "author_id": 5206464, "author_profile": "https://Stackoverflow.com/users/5206464", "pm_score": 2, "selected": false, "text": "cp.async.ca.shared.global" }, { "answer_id": 74442307, "author": "einpoklum", "author_id": 1593077, "author_profile": "https://Stackoverflow.com/users/1593077", "pm_score": 2, "selected": false, "text": "#define NO_ZFILL 0\n\n// ...\n\nfor(int i = 0; i < 10; i++) {\n __pipeline_memcpy_async(&shared_mem[i], &global_mem[i], sizeof(int), NO_ZFILL);\n}\n__pipeline_commit();\n__pipeline_wait_prior(0); // wait for the first commited batch of pipeline ops\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20506688/" ]
74,440,829
<p>I have been trying to set a time limit for a certain form to not function past a specified date in a month, but I have been unsuccessful so far.</p> <p>I am working with a low-code windows interface software that does the majority of the actual coding in the background but since it has some limitations I need to code this Date limit in myself.</p> <p>The best thing I reached after looking around was this:</p> <pre><code>DateTime temp = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 15); </code></pre> <p>And I would add a rule in the program that the date shouldn't be higher than the above. But for some reason it doesn't work giving me an &quot;; expected&quot; error (in line 1 char 29).</p>
[ { "answer_id": 74440857, "author": "Kryrena", "author_id": 18229254, "author_profile": "https://Stackoverflow.com/users/18229254", "pm_score": 4, "selected": true, "text": "__shared__ float smem[2];\nsmem[0] = global_memory[0];\n" }, { "answer_id": 74442159, "author": "Abator Abetor", "author_id": 5206464, "author_profile": "https://Stackoverflow.com/users/5206464", "pm_score": 2, "selected": false, "text": "cp.async.ca.shared.global" }, { "answer_id": 74442307, "author": "einpoklum", "author_id": 1593077, "author_profile": "https://Stackoverflow.com/users/1593077", "pm_score": 2, "selected": false, "text": "#define NO_ZFILL 0\n\n// ...\n\nfor(int i = 0; i < 10; i++) {\n __pipeline_memcpy_async(&shared_mem[i], &global_mem[i], sizeof(int), NO_ZFILL);\n}\n__pipeline_commit();\n__pipeline_wait_prior(0); // wait for the first commited batch of pipeline ops\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20506645/" ]
74,440,850
<pre><code>export default function ChatButton({showScreen}) { const [active4, setActive4] = useState(false); const handleClick4 = () =&gt; { setActive4((prev) =&gt; !prev); showScreen(&quot;MessageScreen&quot;); }; return ( &lt;div id=&quot;chat-button&quot;&gt; &lt;div className=&quot;button-4&quot; type=&quot;button&quot; name=&quot;chat&quot; onClick={handleClick4} style={{ backgroundColor: active4 ? &quot;red&quot; : &quot;black&quot;, borderRadius: &quot;25px&quot;, border: active4 ? &quot;2px solid #e32828f7&quot; : &quot;none&quot;, }} &gt;&lt;/div&gt; &lt;/div&gt; ); } </code></pre> <p>in this picture it shows one component of a button the and the other four is , ,</p> <p>which is render in a Button component and almost same code</p> <pre><code>export default function Buttons({ showScreen}) { return ( &lt;div id=&quot;pda-buttons&quot;&gt; &lt;div className=&quot; row-1&quot;&gt; &lt;div className=&quot;buttns d-inline-flex&quot;&gt; &lt;li className=&quot;button-list d-flex justify-content-evenly mt-1&quot;&gt; &lt;MailButton showScreen={showScreen} /&gt; &lt;VoiceMailButton showScreen={showScreen} /&gt; &lt;PhoneButton showScreen={showScreen} /&gt; &lt;ChatButton showScreen={showScreen} /&gt; &lt;MapButton showScreen={showScreen} /&gt; &lt;/li&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; ); } </code></pre> <p>The propblem is everytime I click one of the the buttons it is working it changes the color of the button that i click but when I click another button it changes the color but the previous color doesnt return to its previuos color the main issue is I want to only one to changes color everytime i click and the other should return to its original form unless it is click</p> <p>is there a way to solve it in a simple way</p>
[ { "answer_id": 74440857, "author": "Kryrena", "author_id": 18229254, "author_profile": "https://Stackoverflow.com/users/18229254", "pm_score": 4, "selected": true, "text": "__shared__ float smem[2];\nsmem[0] = global_memory[0];\n" }, { "answer_id": 74442159, "author": "Abator Abetor", "author_id": 5206464, "author_profile": "https://Stackoverflow.com/users/5206464", "pm_score": 2, "selected": false, "text": "cp.async.ca.shared.global" }, { "answer_id": 74442307, "author": "einpoklum", "author_id": 1593077, "author_profile": "https://Stackoverflow.com/users/1593077", "pm_score": 2, "selected": false, "text": "#define NO_ZFILL 0\n\n// ...\n\nfor(int i = 0; i < 10; i++) {\n __pipeline_memcpy_async(&shared_mem[i], &global_mem[i], sizeof(int), NO_ZFILL);\n}\n__pipeline_commit();\n__pipeline_wait_prior(0); // wait for the first commited batch of pipeline ops\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20505486/" ]
74,440,870
<pre><code></code></pre> <p>i &lt;- 1 while(i&lt;10){ print(i) i&lt;-i+1 if(i==4){ next } }</p> <pre><code>[1] 1 [1] 2 [1] 3 [1] 4 [1] 5 [1] 6 [1] 7 [1] 8 [1] 9 </code></pre> <p>I execute this code, but still have number 4 in my result although I am using &quot;next&quot; in my code to skipp it</p>
[ { "answer_id": 74440857, "author": "Kryrena", "author_id": 18229254, "author_profile": "https://Stackoverflow.com/users/18229254", "pm_score": 4, "selected": true, "text": "__shared__ float smem[2];\nsmem[0] = global_memory[0];\n" }, { "answer_id": 74442159, "author": "Abator Abetor", "author_id": 5206464, "author_profile": "https://Stackoverflow.com/users/5206464", "pm_score": 2, "selected": false, "text": "cp.async.ca.shared.global" }, { "answer_id": 74442307, "author": "einpoklum", "author_id": 1593077, "author_profile": "https://Stackoverflow.com/users/1593077", "pm_score": 2, "selected": false, "text": "#define NO_ZFILL 0\n\n// ...\n\nfor(int i = 0; i < 10; i++) {\n __pipeline_memcpy_async(&shared_mem[i], &global_mem[i], sizeof(int), NO_ZFILL);\n}\n__pipeline_commit();\n__pipeline_wait_prior(0); // wait for the first commited batch of pipeline ops\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20306157/" ]
74,440,881
<p><a href="https://i.stack.imgur.com/2qNPU.jpg" rel="nofollow noreferrer">display</a></p> <pre><code> &lt;div class=&quot;slider&quot;&gt; &lt;div class=&quot;slides&quot;&gt; &lt;input type=&quot;radio&quot; name=&quot;radio-button&quot; id=&quot;radio1&quot;&gt; &lt;input type=&quot;radio&quot; name=&quot;radio-button&quot; id=&quot;radio2&quot;&gt; &lt;input type=&quot;radio&quot; name=&quot;radio-button&quot; id=&quot;radio3&quot;&gt; &lt;input type=&quot;radio&quot; name=&quot;radio-button&quot; id=&quot;radio4&quot;&gt; &lt;input type=&quot;radio&quot; name=&quot;radio-button&quot; id=&quot;radio5&quot;&gt; &lt;input type=&quot;radio&quot; name=&quot;radio-button&quot; id=&quot;radio6&quot;&gt; &lt;div&gt; </code></pre> <pre><code> &lt;div id=&quot;next&quot;&gt;&lt;&lt;/div&gt; &lt;div id=&quot;previous&quot;&gt;&gt;&lt;/div&gt; </code></pre> <pre><code> &lt;div class=&quot;navigation-manual&quot;&gt; &lt;label for=&quot;radio1&quot; class=&quot;manual-button&quot;&gt;&lt;/label&gt; &lt;label for=&quot;radio2&quot; class=&quot;manual-button&quot;&gt;&lt;/label&gt; &lt;label for=&quot;radio3&quot; class=&quot;manual-button&quot;&gt;&lt;/label&gt; &lt;label for=&quot;radio4&quot; class=&quot;manual-button&quot;&gt;&lt;/label&gt; &lt;label for=&quot;radio5&quot; class=&quot;manual-button&quot;&gt;&lt;/label&gt; &lt;label for=&quot;radio6&quot; class=&quot;manual-button&quot;&gt;&lt;/label&gt; &lt;/div&gt; &lt;/div </code></pre> <pre><code> var counter = 1; setInterval(function() {document.getElementById('radio' + counter).checked = true; counter++; if(counter &gt; 6){ counter = 1; } }, 5000); </code></pre> <p>I want to add the button next/previous function to my slider but I'm confused about writing the code, does anyone want to help?</p>
[ { "answer_id": 74440857, "author": "Kryrena", "author_id": 18229254, "author_profile": "https://Stackoverflow.com/users/18229254", "pm_score": 4, "selected": true, "text": "__shared__ float smem[2];\nsmem[0] = global_memory[0];\n" }, { "answer_id": 74442159, "author": "Abator Abetor", "author_id": 5206464, "author_profile": "https://Stackoverflow.com/users/5206464", "pm_score": 2, "selected": false, "text": "cp.async.ca.shared.global" }, { "answer_id": 74442307, "author": "einpoklum", "author_id": 1593077, "author_profile": "https://Stackoverflow.com/users/1593077", "pm_score": 2, "selected": false, "text": "#define NO_ZFILL 0\n\n// ...\n\nfor(int i = 0; i < 10; i++) {\n __pipeline_memcpy_async(&shared_mem[i], &global_mem[i], sizeof(int), NO_ZFILL);\n}\n__pipeline_commit();\n__pipeline_wait_prior(0); // wait for the first commited batch of pipeline ops\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20464434/" ]
74,440,895
<p>I have an array of objects with duplicates:</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>[ { "code": "d1", "title": "Title 1" }, { "code": "d2", "title": "Title 2" }, { "code": "d3", "title": "Title 3" }, { "code": "d4", "title": "Title 4" }, { "code": "d4", "title": "Title 4" }, { "code": "d3", "title": "Title 3" } ]</code></pre> </div> </div> </p> <p>So i want the output to be having only the once which doesn't have duplicates included like below:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>[ { "code": "d1", "title": "Title 1" }, { "code": "d2", "title": "Title 2" } ]</code></pre> </div> </div> </p> <p>Any help would be appreciated, Thanks!</p>
[ { "answer_id": 74440985, "author": "Dreamy Player", "author_id": 15319747, "author_profile": "https://Stackoverflow.com/users/15319747", "pm_score": 1, "selected": false, "text": "const ressult = YourArray.filter(\n (value, index, array) => array.findIndex((v) => v.code === value.code) === index\n);\n" }, { "answer_id": 74441073, "author": "Carsten Massmann", "author_id": 2610061, "author_profile": "https://Stackoverflow.com/users/2610061", "pm_score": 1, "selected": true, "text": "const products=[\n {\n\"code\": \"d1\",\n\"title\": \"Title 1\"\n },\n {\n\"code\": \"d2\",\n\"title\": \"Title 2\"\n },\n {\n\"code\": \"d3\",\n\"title\": \"Title 3\"\n },\n {\n\"code\": \"d4\",\n\"title\": \"Title 4\"\n },\n {\n\"code\": \"d4\",\n\"title\": \"Title 4\"\n },\n {\n\"code\": \"d3\",\n\"title\": \"Title 3\"\n }\n];\n\nconst res=Object.entries(products.reduce((a,c)=>{\n (a[c.code+\"|\"+c.title]??=[]).push(c);\n return a;\n },{})).reduce((a,[k,v])=>{\n if(v.length==1) a.push(v[0]);\n return a;\n },[]);\n\nconsole.log(res);" }, { "answer_id": 74445163, "author": "Muthulakshmi M", "author_id": 8350081, "author_profile": "https://Stackoverflow.com/users/8350081", "pm_score": 0, "selected": false, "text": " let val = [\n {\n \"code\": \"d1\",\n \"title\": \"Title 1\"\n },\n {\n \"code\": \"d2\",\n \"title\": \"Title 2\"\n },\n {\n \"code\": \"d3\",\n \"title\": \"Title 3\"\n },\n {\n \"code\": \"d4\",\n \"title\": \"Title 4\"\n },\n {\n \"code\": \"d4\",\n \"title\": \"Title 4\"\n },\n {\n \"code\": \"d3\",\n \"title\": \"Title 3\"\n }\n ];\n let distinctVal = getDistincts(val);\n function getDistincts(val){\n let obj={};\n for (let i = 0; i < val.length; i++) {\n obj[`${val[i][\"code\"]}`]=val[i][\"title\"];\n }\n return obj;\n }\n console.log(distinctVal);" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4911440/" ]
74,440,897
<p>react-refresh-runtime.development.js:315 Uncaught TypeError: Cannot read properties of undefined (reading 'map')</p> <pre><code>const Exchange = () =&gt; { const { exchanges, setExchanges } = useState([]); const { loading, setLoading } = useState(true); useEffect(() =&gt; { const fetchExchanges = async () =&gt; { const { data } = await axios.get(`${server}/exchanges`); // console.log(data); setExchanges(data); setLoading(false); }; fetchExchanges(); }); return ( &lt;Container maxW={&quot;container.xl&quot;}&gt;{loading ? ( &lt;Loader /&gt; ): (&lt;&gt; &lt;HStack&gt; {exchanges.map((i) =&gt; ( &lt;div&gt;{i.name}&lt;/div&gt; ))} &lt;/HStack&gt; &lt;/&gt;)} &lt;/Container&gt; ); }; </code></pre>
[ { "answer_id": 74440934, "author": "Ahmet Ulutaş", "author_id": 17040927, "author_profile": "https://Stackoverflow.com/users/17040927", "pm_score": 1, "selected": false, "text": "exchanges.map" }, { "answer_id": 74441013, "author": "Ashley Ferns", "author_id": 15840945, "author_profile": "https://Stackoverflow.com/users/15840945", "pm_score": 3, "selected": true, "text": "const { exchanges, setExchanges } = useState([]);\n const { loading, setLoading } = useState(true);\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15840945/" ]
74,440,927
<p>Have a Dataframe:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Column_A</th> <th>Column_B</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>20</td> </tr> <tr> <td>2</td> <td>25</td> </tr> <tr> <td>1</td> <td>52</td> </tr> <tr> <td>2</td> <td>22</td> </tr> <tr> <td>4</td> <td>67</td> </tr> <tr> <td>1</td> <td>34</td> </tr> <tr> <td>3</td> <td>112</td> </tr> <tr> <td>5</td> <td>55</td> </tr> <tr> <td>4</td> <td>33</td> </tr> <tr> <td>5</td> <td>87</td> </tr> <tr> <td>1</td> <td>108</td> </tr> </tbody> </table> </div> <p>Looking to create 2 groups from Column_A, and find the average of those groups in Column_B:</p> <p>So first group might be 1, 2 and 3, second group 4 and 5.</p> <p>I get the basics behind groupby()</p> <pre><code>df.groupby(&quot;Column_A&quot;)[&quot;Column_B&quot;].mean() </code></pre> <p>and calling certain values in columns</p> <pre><code>df[df[&quot;Column_A&quot;] == 1].groupby()[].mean() </code></pre> <p>But is there a way to include the group of (1, 2 and 3) and (4, 5) from Column_A? Somehow doing:</p> <pre><code>[[&quot;Column_A&quot;] == 1, 2, 3].groupby(Column_B).mean() </code></pre> <p>And:</p> <pre><code>[[&quot;Column_A&quot;] == 4, 5].groupby(Column_B).mean() </code></pre> <p>Thanks in advance</p>
[ { "answer_id": 74441032, "author": "Panda Kim", "author_id": 20430449, "author_profile": "https://Stackoverflow.com/users/20430449", "pm_score": 0, "selected": false, "text": "df[df[\"Column_A\"] <= 3].groupby(\"Column_A\")[\"Column_B\"].mean()\ndf[df[\"Column_A\"] > 3].groupby(\"Column_A\")[\"Column_B\"].mean()\n" }, { "answer_id": 74441125, "author": "iamjaydev", "author_id": 10968621, "author_profile": "https://Stackoverflow.com/users/10968621", "pm_score": 0, "selected": false, "text": "isin" }, { "answer_id": 74441261, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 1, "selected": false, "text": "cut" }, { "answer_id": 74444705, "author": "DarrylG", "author_id": 3066077, "author_profile": "https://Stackoverflow.com/users/3066077", "pm_score": 1, "selected": true, "text": "df.groupby(df['Column_A'].isin([1, 2, 3]))['Column_B'].mean()\n\nOutput:\nColumn_A\nFalse 60.500000\nTrue 53.285714\nName: Column_B, dtype: float64\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18757560/" ]
74,440,931
<p>I have a multidimensional array like this</p> <p><code>Owner[0].dog[0].typeOfDog = &quot;shiba inu&quot;, Owner[0].dog[1].typeOfDog = &quot;poodle&quot;, Owner[0].dog[2].typeOfDog = &quot;samoyan&quot;, Owner[1].dog[0].typeOfDog = &quot;poodle&quot;, Owner[1].dog[1].typeOfDog = &quot;poodle&quot;, Owner[1].dog[2].typeOfDog = &quot;samoyan&quot;, Owner[2].dog[0].typeOfDog = &quot;poodle&quot;</code></p> <p>I want to create a variable that contains this exact data structure and returns the same list but without any poodles.</p> <p>For example:</p> <p><code>Owner[0].dog[0].typeOfDog = &quot;shiba inu&quot;, Owner[0].dog[0].typeOfDog = &quot;samoyan&quot;, Owner[1].dog[0].typeOfDog = &quot;samoyan&quot;</code></p> <p>I managed to filter it out using Map and Filter but I am unable to keep the same structure. How would I do this?</p> <p><code>owners.Map(owner =&gt; owner.dogs.filter(dog =&gt; dog.typeOfDog !== &quot;poodle&quot;));</code></p> <p>This is returning an array of dogs that are not poodles but I would like to get a array of owners each of which have an array of dogs that are not poodles.</p>
[ { "answer_id": 74440982, "author": "Adrian Brand", "author_id": 1679126, "author_profile": "https://Stackoverflow.com/users/1679126", "pm_score": 1, "selected": false, "text": "const OwnersNoPoodles = Owner.map(o => ({...o, dog: o.dog.filter(d => d.typeOfDog !== 'poodle' )}));\n" }, { "answer_id": 74441006, "author": "Gohchi", "author_id": 5000827, "author_profile": "https://Stackoverflow.com/users/5000827", "pm_score": 0, "selected": false, "text": "owners.map(owner => (\n Object.assign({}, owner, {\n dogs: owner.dogs.filter(dog => dog.typeOfDog !== \"poodle\")\n })\n));\n" }, { "answer_id": 74441461, "author": "Mister Jojo", "author_id": 10669010, "author_profile": "https://Stackoverflow.com/users/10669010", "pm_score": 0, "selected": false, "text": "const Owner = \n [ { dog :\n [ { typeOfDog : 'shiba inu' }\n , { typeOfDog : 'poodle' } \n , { typeOfDog : 'samoyan' } \n ] }\n , { dog :\n [ { typeOfDog : 'poodle' }\n , { typeOfDog : 'poodle' } \n , { typeOfDog : 'samoyan' } \n ] }\n , { dog :\n [ { typeOfDog : 'poodle' }\n ] }\n ]\n, NoPoodles = Owner\n .map(({dog})=>({dog: dog.filter(({typeOfDog})=>typeOfDog!=='poodle')}))\n .filter(({dog})=>dog.length)\n ;\n \nconsole.log( 'result length =', NoPoodles.length )\nconsole.log( NoPoodles )" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20506515/" ]
74,440,940
<h1>Background</h1> <p>So I have a validator:</p> <ol> <li>To determine whether an email format is correct or not</li> <li>Does the <strong>email already exist</strong> in the database</li> <li>Along with some other column validation (<em>just ignore this</em>) Like this:</li> </ol> <pre><code>$validator = Validator::make($request-&gt;all(), [ 'name' =&gt; 'required|string|max:255', 'email' =&gt; 'required|string|email|max:255|unique:MyTable,email', 'mobile' =&gt; ['required', 'regex:/^(62)8[1-9][0-9]{6,9}$/'], // Valid: 6281234567890 'birthdate' =&gt; 'required|date', 'password' =&gt; ['required', 'confirmed', Password::min(8)-&gt;mixedCase()-&gt;numbers()], 'allow_received_information' =&gt; 'integer', ]); </code></pre> <p>Error messages will be displayed one by one if there is an error in the input form with this code:</p> <pre><code>if ($validator-&gt;stopOnFirstFailure()-&gt;fails()) { return ResponseFormatter::error(null, implode(&quot;,&quot;, $validator-&gt;messages()-&gt;all())); } </code></pre> <h2>Question</h2> <p>So my question is, how to catch the event <strong>if an email already exists in the database or not</strong> among other validations? Maybe it's as simple as this:</p> <pre><code>if ('email' == alreadyExistFunc()) { # if already exist in db } else { # if not } </code></pre> <h2>Trial 1</h2> <p>I found some functionality from <a href="https://laravel.com/docs/9.x/validation#after-validation-hook" rel="nofollow noreferrer">Laravel's After Validation Hook</a>, but I don't know if this is the exact function I need, and I don't know how to use it either..</p> <pre><code>$validator = Validator::make(); $validator-&gt;after(function ($validator) { if ($this-&gt;somethingElseIsInvalid()) { $validator-&gt;errors()-&gt;add( 'field', 'Something is wrong with this field!' ); } }); if ($validator-&gt;fails()) { // } </code></pre> <h2>Trial 2</h2> <p>I could just remove the email validation <code>'email' =&gt; 'required|string|email|max:255|unique:MyTable,email'</code> from the rule code line, and do it manually like this:</p> <pre><code>$isExist = MyTable::where('email', $request-&gt;email)-&gt;first(); if ($isExist != null) { # code... } else { # code... } </code></pre> <p>But is it best practice?<br /> I think there is a way automatically..</p> <p>Please for suggestions or answers, thank you</p>
[ { "answer_id": 74440982, "author": "Adrian Brand", "author_id": 1679126, "author_profile": "https://Stackoverflow.com/users/1679126", "pm_score": 1, "selected": false, "text": "const OwnersNoPoodles = Owner.map(o => ({...o, dog: o.dog.filter(d => d.typeOfDog !== 'poodle' )}));\n" }, { "answer_id": 74441006, "author": "Gohchi", "author_id": 5000827, "author_profile": "https://Stackoverflow.com/users/5000827", "pm_score": 0, "selected": false, "text": "owners.map(owner => (\n Object.assign({}, owner, {\n dogs: owner.dogs.filter(dog => dog.typeOfDog !== \"poodle\")\n })\n));\n" }, { "answer_id": 74441461, "author": "Mister Jojo", "author_id": 10669010, "author_profile": "https://Stackoverflow.com/users/10669010", "pm_score": 0, "selected": false, "text": "const Owner = \n [ { dog :\n [ { typeOfDog : 'shiba inu' }\n , { typeOfDog : 'poodle' } \n , { typeOfDog : 'samoyan' } \n ] }\n , { dog :\n [ { typeOfDog : 'poodle' }\n , { typeOfDog : 'poodle' } \n , { typeOfDog : 'samoyan' } \n ] }\n , { dog :\n [ { typeOfDog : 'poodle' }\n ] }\n ]\n, NoPoodles = Owner\n .map(({dog})=>({dog: dog.filter(({typeOfDog})=>typeOfDog!=='poodle')}))\n .filter(({dog})=>dog.length)\n ;\n \nconsole.log( 'result length =', NoPoodles.length )\nconsole.log( NoPoodles )" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9039350/" ]
74,440,961
<p>I created anchor tag in which I use heart icon which change the color after click. But I want to remain same the color after reloading or restaring the page. when I restart or reload the page it comes back on their default color.</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 btnvar = document.getElementById('favorite') function Fav() { if (btnvar.style.color == "red") { btnvar.style.color = "grey" } else { btnvar.style.color = "red" } };</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;a href="#" class="phone_number" id="favorite" onclick="Fav()"&gt; hello &lt;/a&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74441223, "author": "Vivek K.", "author_id": 3802484, "author_profile": "https://Stackoverflow.com/users/3802484", "pm_score": 0, "selected": false, "text": "unset" }, { "answer_id": 74469571, "author": "Xinran Shen", "author_id": 17438579, "author_profile": "https://Stackoverflow.com/users/17438579", "pm_score": 0, "selected": false, "text": "var btnvar = document.getElementById('favorite')\n\n window.onload=function(){\n if (typeof(Storage) !== \"undefined\" && localStorage.getItem(\"color\")!= null) {\n \n // Retrieve\n btnvar.style.color = localStorage.getItem(\"color\");\n } \n }\n\nfunction Fav() {\n if (btnvar.style.color == \"red\") {\n btnvar.style.color = \"grey\"\n localStorage.setItem(\"color\",\"grey\");\n } else { \n btnvar.style.color = \"red\"\n localStorage.setItem(\"color\",\"red\");\n }\n};\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74440961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20467305/" ]
74,441,140
<p>I'm trying to design this view.</p> <p><a href="https://i.stack.imgur.com/MpOJ3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MpOJ3.png" alt="enter image description here" /></a></p> <p>I already have the basic design of the cards, but i would like to know how to change the card's background color, the card's border color and add the little green square according to the width size of the current card when the user click one of them. It's important to know that only one card can be painted in green when the user clicked it.</p> <p>Here is my code:</p> <p><strong>CategoryCardModel</strong></p> <pre><code>class CategoryCardModel { final String? categoryCardModelName; CategoryCardModel(this.categoryCardModelName); } </code></pre> <p><strong>CategoryCard</strong></p> <pre><code>import 'dart:ffi'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; class CategoryCard extends StatelessWidget { final String? categoryCardName; final Function()? wasPressed; const CategoryCard({ super.key, required this.categoryCardName, this.wasPressed, }); @override Widget build(BuildContext context) { return GestureDetector( onTap: wasPressed, child: Card( shape: RoundedRectangleBorder( side: const BorderSide( color: Color.fromRGBO(212, 213, 215, 100), width: 3, ), borderRadius: BorderRadius.circular(20.0), ), child: Container( decoration: BoxDecoration( color: const Color.fromRGBO(242, 243, 243, 100), borderRadius: BorderRadius.circular(20.0)), padding: const EdgeInsets.all(10), child: Text( categoryCardName ?? 'Todas', style: const TextStyle( fontSize: 25, fontWeight: FontWeight.bold, color: Color.fromRGBO(91, 94, 99, 100)), ), ), ), ); } } </code></pre> <p><strong>MyHomePage</strong></p> <pre><code>import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'category_card.dart'; import 'category_card_model.dart'; class MyHomePage extends StatefulWidget { MyHomePage({super.key, required this.title}); final String title; @override State&lt;MyHomePage&gt; createState() =&gt; _MyHomePageState(); } class _MyHomePageState extends State&lt;MyHomePage&gt; { // List of models final categoryCardModelList = &lt;CategoryCardModel&gt;[ CategoryCardModel(&quot;Todas&quot;), CategoryCardModel(&quot;Smartphones&quot;), CategoryCardModel(&quot;Accesorios para celular&quot;), CategoryCardModel(&quot;TV&quot;) ]; List&lt;CategoryCardModel&gt;? _categoryCardModelListOf; @override void initState() { super.initState(); setState(() { _categoryCardModelListOf = List.of(categoryCardModelList); }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.title), ), body: SingleChildScrollView( scrollDirection: Axis.horizontal, padding: const EdgeInsets.fromLTRB(10.0, 0.0, 10.0, 0.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: _categoryCardModelListOf! .map&lt;Widget&gt;((categoryCardModel) =&gt; CategoryCard( wasPressed: () { print(&quot;Hello World&quot;); setState(() {}); }, categoryCardName: categoryCardModel.categoryCardModelName)) .toList()))); } } </code></pre> <p><strong>main</strong></p> <pre><code>import 'package:flutter/material.dart'; import 'my_home_page.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: MyHomePage(title: &quot;Caregory Cards&quot;), ); } } </code></pre>
[ { "answer_id": 74441620, "author": "manhtuan21", "author_id": 8921450, "author_profile": "https://Stackoverflow.com/users/8921450", "pm_score": 2, "selected": false, "text": "class CategoryCard extends StatelessWidget {\n final String? categoryCardName;\n final Function()? wasPressed;\n final bool isSelected;\n\n const CategoryCard({\n super.key,\n required this.categoryCardName,\n this.wasPressed,\n this.isSelected = false,\n });\n\n @override\n Widget build(BuildContext context) {\n return GestureDetector(\n onTap: wasPressed,\n child: Card(\n shape: RoundedRectangleBorder(\n side: BorderSide(\n color: isSelected ? Colors.green : Color.fromRGBO(212, 213, 215, 100),\n width: 3,\n ),\n borderRadius: BorderRadius.circular(20.0),\n ),\n child: Container(\n decoration: BoxDecoration(\n color: isSelected ? Colors.greenAccent : const Color.fromRGBO(242, 243, 243, 100),\n borderRadius: BorderRadius.circular(20.0),\n ),\n padding: const EdgeInsets.all(10),\n child: Text(\n categoryCardName ?? 'Todas',\n style: const TextStyle(fontSize: 25, fontWeight: FontWeight.bold, color: Color.fromRGBO(91, 94, 99, 100)),\n ),\n ),\n ),\n );\n }\n}\n" }, { "answer_id": 74441651, "author": "Yeasin Sheikh", "author_id": 10157127, "author_profile": "https://Stackoverflow.com/users/10157127", "pm_score": 3, "selected": true, "text": "class CategoryCard extends StatelessWidget {\n final String? categoryCardName;\n final Function()? wasPressed;\n final bool isActive;\n\n const CategoryCard(\n {super.key,\n required this.categoryCardName,\n this.wasPressed,\n this.isActive = false});\n\n @override\n Widget build(BuildContext context) {\n return GestureDetector(\n onTap: wasPressed,\n child: Card(\n shape: const StadiumBorder(),\n child: Container(\n decoration: BoxDecoration(\n color: (isActive ? Colors.green : Colors.grey).withOpacity(.1),\n borderRadius: BorderRadius.circular(24.0),\n border: Border.all(\n width: 2, color: isActive ? Colors.green : Colors.grey)),\n padding: const EdgeInsets.all(10),\n child: Text(\n categoryCardName ?? 'Todas',\n style: const TextStyle(\n fontSize: 25,\n fontWeight: FontWeight.bold,\n color: Color.fromRGBO(91, 94, 99, 100)),\n ),\n ),\n ),\n );\n }\n}\n" }, { "answer_id": 74442636, "author": "Irfan Ganatra", "author_id": 18817235, "author_profile": "https://Stackoverflow.com/users/18817235", "pm_score": 1, "selected": false, "text": "\nclass CategoryCard extends StatelessWidget {\n final String? categoryCardName;\n final Function()? wasPressed;\n final bool? isselected;\n\n const CategoryCard({\n super.key,\n required this.categoryCardName,\n this.wasPressed,\n this.isselected=false\n });\n\n @override\n Widget build(BuildContext context) {\n return GestureDetector(\n onTap: wasPressed,\n child: IntrinsicWidth(\n child: Padding(\n padding: EdgeInsets.symmetric(horizontal: 10),\n child: Column(children: [\n Card(\n shape: RoundedRectangleBorder(\n side: BorderSide(\n color:isselected==true?Colors.red: Color.fromRGBO(212, 213, 215, 100),\n width: 3,\n ),\n borderRadius: BorderRadius.circular(20.0),\n ),\n child: Container(\n decoration: BoxDecoration(\n color: const Color.fromRGBO(242, 243, 243, 100),\n borderRadius: BorderRadius.circular(20.0)),\n padding: const EdgeInsets.all(10),\n child: Text(\n categoryCardName ?? 'Todas',\n style: const TextStyle(\n fontSize: 25,\n fontWeight: FontWeight.bold,\n color: Color.fromRGBO(91, 94, 99, 100)),\n ),\n ),\n ),\n if(isselected==true)\n Padding(\n padding: EdgeInsets.symmetric(horizontal: 20),\n child: Container(\n color: Colors.red[200],\n height: 5,\n ),\n ),\n ],),\n ),\n ),\n );\n }\n}\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20395420/" ]
74,441,162
<p>the code: shop.vue</p> <pre class="lang-html prettyprint-override"><code>&lt;template&gt; &lt;div class=&quot;shop&quot;&gt; &lt;div class=&quot;products&quot; v-for=&quot;Product in items&quot; :key=&quot;Product.id&quot; :Product=&quot;Product&quot; v-on:add-To-Cart=&quot;addToCart($event)&quot;&gt; &lt;h1&gt;{{ Product.name }}&lt;/h1&gt; &lt;img :src=&quot;Product.pic&quot; width=&quot;400&quot; /&gt; &lt;br&gt; {{ Product.description }} &lt;br&gt; {{ &quot;$&quot; + Product.price }} &lt;br&gt; &lt;button class=&quot;addToCart&quot; @click=&quot;$emit('add-To-Cart', Product)&quot;&gt;Add to Cart&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/template&gt; &lt;script&gt; import Product from '../db.json'; export default { name: 'shop', data() { return { items: Product } }, methods: { addToCart(Product) { this.Product=Product console.log(this.Product) } } } &lt;/script&gt; </code></pre> <p>when I click the add to cart button it is not logging the product to the console</p> <p>how can I fix that? and implement a shopping cart to my website?</p>
[ { "answer_id": 74441620, "author": "manhtuan21", "author_id": 8921450, "author_profile": "https://Stackoverflow.com/users/8921450", "pm_score": 2, "selected": false, "text": "class CategoryCard extends StatelessWidget {\n final String? categoryCardName;\n final Function()? wasPressed;\n final bool isSelected;\n\n const CategoryCard({\n super.key,\n required this.categoryCardName,\n this.wasPressed,\n this.isSelected = false,\n });\n\n @override\n Widget build(BuildContext context) {\n return GestureDetector(\n onTap: wasPressed,\n child: Card(\n shape: RoundedRectangleBorder(\n side: BorderSide(\n color: isSelected ? Colors.green : Color.fromRGBO(212, 213, 215, 100),\n width: 3,\n ),\n borderRadius: BorderRadius.circular(20.0),\n ),\n child: Container(\n decoration: BoxDecoration(\n color: isSelected ? Colors.greenAccent : const Color.fromRGBO(242, 243, 243, 100),\n borderRadius: BorderRadius.circular(20.0),\n ),\n padding: const EdgeInsets.all(10),\n child: Text(\n categoryCardName ?? 'Todas',\n style: const TextStyle(fontSize: 25, fontWeight: FontWeight.bold, color: Color.fromRGBO(91, 94, 99, 100)),\n ),\n ),\n ),\n );\n }\n}\n" }, { "answer_id": 74441651, "author": "Yeasin Sheikh", "author_id": 10157127, "author_profile": "https://Stackoverflow.com/users/10157127", "pm_score": 3, "selected": true, "text": "class CategoryCard extends StatelessWidget {\n final String? categoryCardName;\n final Function()? wasPressed;\n final bool isActive;\n\n const CategoryCard(\n {super.key,\n required this.categoryCardName,\n this.wasPressed,\n this.isActive = false});\n\n @override\n Widget build(BuildContext context) {\n return GestureDetector(\n onTap: wasPressed,\n child: Card(\n shape: const StadiumBorder(),\n child: Container(\n decoration: BoxDecoration(\n color: (isActive ? Colors.green : Colors.grey).withOpacity(.1),\n borderRadius: BorderRadius.circular(24.0),\n border: Border.all(\n width: 2, color: isActive ? Colors.green : Colors.grey)),\n padding: const EdgeInsets.all(10),\n child: Text(\n categoryCardName ?? 'Todas',\n style: const TextStyle(\n fontSize: 25,\n fontWeight: FontWeight.bold,\n color: Color.fromRGBO(91, 94, 99, 100)),\n ),\n ),\n ),\n );\n }\n}\n" }, { "answer_id": 74442636, "author": "Irfan Ganatra", "author_id": 18817235, "author_profile": "https://Stackoverflow.com/users/18817235", "pm_score": 1, "selected": false, "text": "\nclass CategoryCard extends StatelessWidget {\n final String? categoryCardName;\n final Function()? wasPressed;\n final bool? isselected;\n\n const CategoryCard({\n super.key,\n required this.categoryCardName,\n this.wasPressed,\n this.isselected=false\n });\n\n @override\n Widget build(BuildContext context) {\n return GestureDetector(\n onTap: wasPressed,\n child: IntrinsicWidth(\n child: Padding(\n padding: EdgeInsets.symmetric(horizontal: 10),\n child: Column(children: [\n Card(\n shape: RoundedRectangleBorder(\n side: BorderSide(\n color:isselected==true?Colors.red: Color.fromRGBO(212, 213, 215, 100),\n width: 3,\n ),\n borderRadius: BorderRadius.circular(20.0),\n ),\n child: Container(\n decoration: BoxDecoration(\n color: const Color.fromRGBO(242, 243, 243, 100),\n borderRadius: BorderRadius.circular(20.0)),\n padding: const EdgeInsets.all(10),\n child: Text(\n categoryCardName ?? 'Todas',\n style: const TextStyle(\n fontSize: 25,\n fontWeight: FontWeight.bold,\n color: Color.fromRGBO(91, 94, 99, 100)),\n ),\n ),\n ),\n if(isselected==true)\n Padding(\n padding: EdgeInsets.symmetric(horizontal: 20),\n child: Container(\n color: Colors.red[200],\n height: 5,\n ),\n ),\n ],),\n ),\n ),\n );\n }\n}\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20317198/" ]
74,441,166
<p>I have many Java flaky tests using testNG, which may fail randomly. Now I'd like to run them repeatly until failure and see the log output. Can testNG do this?</p> <p>Seems there are many questions about how to retry fail tests, but no solution about how to retry tests until failure.</p>
[ { "answer_id": 74441620, "author": "manhtuan21", "author_id": 8921450, "author_profile": "https://Stackoverflow.com/users/8921450", "pm_score": 2, "selected": false, "text": "class CategoryCard extends StatelessWidget {\n final String? categoryCardName;\n final Function()? wasPressed;\n final bool isSelected;\n\n const CategoryCard({\n super.key,\n required this.categoryCardName,\n this.wasPressed,\n this.isSelected = false,\n });\n\n @override\n Widget build(BuildContext context) {\n return GestureDetector(\n onTap: wasPressed,\n child: Card(\n shape: RoundedRectangleBorder(\n side: BorderSide(\n color: isSelected ? Colors.green : Color.fromRGBO(212, 213, 215, 100),\n width: 3,\n ),\n borderRadius: BorderRadius.circular(20.0),\n ),\n child: Container(\n decoration: BoxDecoration(\n color: isSelected ? Colors.greenAccent : const Color.fromRGBO(242, 243, 243, 100),\n borderRadius: BorderRadius.circular(20.0),\n ),\n padding: const EdgeInsets.all(10),\n child: Text(\n categoryCardName ?? 'Todas',\n style: const TextStyle(fontSize: 25, fontWeight: FontWeight.bold, color: Color.fromRGBO(91, 94, 99, 100)),\n ),\n ),\n ),\n );\n }\n}\n" }, { "answer_id": 74441651, "author": "Yeasin Sheikh", "author_id": 10157127, "author_profile": "https://Stackoverflow.com/users/10157127", "pm_score": 3, "selected": true, "text": "class CategoryCard extends StatelessWidget {\n final String? categoryCardName;\n final Function()? wasPressed;\n final bool isActive;\n\n const CategoryCard(\n {super.key,\n required this.categoryCardName,\n this.wasPressed,\n this.isActive = false});\n\n @override\n Widget build(BuildContext context) {\n return GestureDetector(\n onTap: wasPressed,\n child: Card(\n shape: const StadiumBorder(),\n child: Container(\n decoration: BoxDecoration(\n color: (isActive ? Colors.green : Colors.grey).withOpacity(.1),\n borderRadius: BorderRadius.circular(24.0),\n border: Border.all(\n width: 2, color: isActive ? Colors.green : Colors.grey)),\n padding: const EdgeInsets.all(10),\n child: Text(\n categoryCardName ?? 'Todas',\n style: const TextStyle(\n fontSize: 25,\n fontWeight: FontWeight.bold,\n color: Color.fromRGBO(91, 94, 99, 100)),\n ),\n ),\n ),\n );\n }\n}\n" }, { "answer_id": 74442636, "author": "Irfan Ganatra", "author_id": 18817235, "author_profile": "https://Stackoverflow.com/users/18817235", "pm_score": 1, "selected": false, "text": "\nclass CategoryCard extends StatelessWidget {\n final String? categoryCardName;\n final Function()? wasPressed;\n final bool? isselected;\n\n const CategoryCard({\n super.key,\n required this.categoryCardName,\n this.wasPressed,\n this.isselected=false\n });\n\n @override\n Widget build(BuildContext context) {\n return GestureDetector(\n onTap: wasPressed,\n child: IntrinsicWidth(\n child: Padding(\n padding: EdgeInsets.symmetric(horizontal: 10),\n child: Column(children: [\n Card(\n shape: RoundedRectangleBorder(\n side: BorderSide(\n color:isselected==true?Colors.red: Color.fromRGBO(212, 213, 215, 100),\n width: 3,\n ),\n borderRadius: BorderRadius.circular(20.0),\n ),\n child: Container(\n decoration: BoxDecoration(\n color: const Color.fromRGBO(242, 243, 243, 100),\n borderRadius: BorderRadius.circular(20.0)),\n padding: const EdgeInsets.all(10),\n child: Text(\n categoryCardName ?? 'Todas',\n style: const TextStyle(\n fontSize: 25,\n fontWeight: FontWeight.bold,\n color: Color.fromRGBO(91, 94, 99, 100)),\n ),\n ),\n ),\n if(isselected==true)\n Padding(\n padding: EdgeInsets.symmetric(horizontal: 20),\n child: Container(\n color: Colors.red[200],\n height: 5,\n ),\n ),\n ],),\n ),\n ),\n );\n }\n}\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10523820/" ]
74,441,179
<p>I need help figuring out how to ask the user if they would like to repeat the program. Any help is much appreciated. I am relatively new to Python and it would be great to receive some advice!</p> <pre><code>X = int(input(&quot;How many numbers would you like to enter? &quot;)) Sum = 0 sumNeg = 0 sumPos = 0 for i in range(0,X,1): number = float(input(&quot;Please enter number %i : &quot; %(i+1) )) # add every number to Sum Sum = Sum + number # Sum += number #only add negative numbers to sumNeg if number &lt; 0: sumNeg += number # sumNeg = sumNeg + number #only add positive numbers to sumPos if number &gt; 0: sumPos += number # sumPos = sumPos + number print (&quot;------&quot;) print (&quot;The sum of all numbers = &quot;, Sum) print (&quot;The sum of negative numbers = &quot;, sumNeg) print (&quot;The sum of positive numbers = &quot;, sumPos) </code></pre> <p>I'm not sure if I need to use a while loop, but how would I enter a (y/n) into my code because I am asking for an integer from the user in the beginning.</p>
[ { "answer_id": 74441460, "author": "0x0fba", "author_id": 20339407, "author_profile": "https://Stackoverflow.com/users/20339407", "pm_score": 1, "selected": true, "text": "break" }, { "answer_id": 74441471, "author": "Muhammad Wasif Ijaz", "author_id": 11528341, "author_profile": "https://Stackoverflow.com/users/11528341", "pm_score": 0, "selected": false, "text": "while True: \n X = int(input(\"How many numbers would you like to enter? \"))\n Sum, sumNeg, sumPos = 0\n for i in range(X):\n number = float(input(\"Please enter number %i : \" %(i+1) ))\n Sum += number\n if number < 0:\n sumNeg += number\n if number > 0:\n sumPos += number\n print (\"------\")\n \n print (\"The sum of all numbers = \", Sum)\n print (\"The sum of negative numbers = \", sumNeg)\n print (\"The sum of positive numbers = \", sumPos)\n \n print (\"------\")\n trigger = int(input(\"The close the program enter 0: \"))\n \n if trigger == 0:\n break\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18320598/" ]
74,441,183
<p>I am planning to start development and I don't know which method of analysis to take as a basis. Perhaps you have some ideas?</p> <p>In the Forex market:</p> <pre><code>Volume = the number of price changes over a period of time. </code></pre> <p>In the stock market:</p> <pre><code>Volume = trading volume * price. </code></pre> <p>For example, the volume for a particular stock is 1000 shares at $10. The Volume indicator would then be as follows:</p> <pre><code>Volume = 1000 * $10 = $10,000. </code></pre> <p>The difference in calculations is due to the fact that Forex market is decentralized as opposed to stock market.</p> <p>And that's why I don't understand how to calculate volume on forex to be accurate.</p> <pre><code></code></pre>
[ { "answer_id": 74441460, "author": "0x0fba", "author_id": 20339407, "author_profile": "https://Stackoverflow.com/users/20339407", "pm_score": 1, "selected": true, "text": "break" }, { "answer_id": 74441471, "author": "Muhammad Wasif Ijaz", "author_id": 11528341, "author_profile": "https://Stackoverflow.com/users/11528341", "pm_score": 0, "selected": false, "text": "while True: \n X = int(input(\"How many numbers would you like to enter? \"))\n Sum, sumNeg, sumPos = 0\n for i in range(X):\n number = float(input(\"Please enter number %i : \" %(i+1) ))\n Sum += number\n if number < 0:\n sumNeg += number\n if number > 0:\n sumPos += number\n print (\"------\")\n \n print (\"The sum of all numbers = \", Sum)\n print (\"The sum of negative numbers = \", sumNeg)\n print (\"The sum of positive numbers = \", sumPos)\n \n print (\"------\")\n trigger = int(input(\"The close the program enter 0: \"))\n \n if trigger == 0:\n break\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441183", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20507083/" ]
74,441,235
<p>This is input file: <code>input.txt</code></p> <pre><code>PS name above bit below bit original 1_info 2_info new PS_AS_0 PS_00[31] PS_00[00] 0x00000000 0x156A17[00] 0x156A17[31] 0x0003F4a1 PS_RST_D2 PS_03[05] PS_03[00] 0x00000003 0x1678A1[00] 0x1678A1[05] 0x0a56F001 PS_N_YD_C PS_03[06] PS_03[06] 0x00000000 0x1678A1[06] 0x1678A1[06] 0x0a56F001 PS_1_FG PS_03[31] PS_03[07] 0x000000FF 0x1678A1[07] 0x1678A1[31] 0x0a56F001 PS_F_23_ASD PS_04[07] PS_03[00] 0x00000000 0x18C550[00] 0x18C550[07] 0x00000000 PS_A_0_STR PS_04[15] PS_04[08] 0x00000FFF 0x18C550[08] 0x18C550[15] 0x00000000 PS_AD_0 PS_04[31] PS_04[16] 0x00000000 0x18C550[16] 0x18C550[31] 0x00000000 </code></pre> <p>here i need to extract the bits in this way:</p> <p>if value of <code>new</code> = <strong>0x0a56F001</strong> then first i need that to be converted to binary <strong>0000 1010 0101 0110 1111 0000 0000 0001</strong> .</p> <p>Then check <strong>above bit</strong> and <strong>below bit</strong> column.</p> <p>for eg: <code>PS_03[05] PS_03[00]</code> then take 0 to 5th bit of new binary value which is <code>000001</code> which is <code>0x1</code> and then convert this to 32 bit value i.e <code>0x00000001</code>. and replace <strong>new</strong> column of that row with this value.</p> <pre><code>PS_RST_D2 PS_03[05] PS_03[00] 0x00000003 0x1678A1[00] 0x1678A1[05] 0x00000001 </code></pre> <p>similarly for all and finally the output file should look like this:</p> <pre><code>PS name above bit below bit original 1_info 2_info new PS_AS_0 PS_00[31] PS_00[00] 0x00000000 0x156A17[00] 0x156A17[31] 0x0003F4a1 PS_RST_D2 PS_03[05] PS_03[00] 0x00000003 0x1678A1[00] 0x1678A1[05] 0x00000001 PS_N_YD_C PS_03[06] PS_03[06] 0x00000000 0x1678A1[06] 0x1678A1[06] 0x00000000 PS_1_FG PS_03[31] PS_03[07] 0x000000FF 0x1678A1[07] 0x1678A1[31] 0x0014ADE0 PS_F_23_ASD PS_04[07] PS_03[00] 0x00000000 0x18C550[00] 0x18C550[07] 0x00000000 PS_A_0_STR PS_04[15] PS_04[08] 0x00000FFF 0x18C550[08] 0x18C550[15] 0x00000000 PS_AD_0 PS_04[31] PS_04[16] 0x00000000 0x18C550[16] 0x18C550[31] 0x00000000 </code></pre> <p>Is this possible in Python? This is current attempt:</p> <pre><code>with open(&quot;input.txt&quot;) as fin: with open(&quot;output.txt&quot;, &quot;w&quot;) as fout: for line in fin: if line.strip(): line = line.strip(&quot;\n' '&quot;) cols = l.split(&quot; &quot;) cols[6] = int(cols[6],16) </code></pre> <p>i tried by selecting specific column but it is not working.</p>
[ { "answer_id": 74441751, "author": "Thomas Weller", "author_id": 480982, "author_profile": "https://Stackoverflow.com/users/480982", "pm_score": 0, "selected": false, "text": "import re\nline = re.sub(' +', ' ', line)\n" }, { "answer_id": 74442104, "author": "Zaby1990", "author_id": 13078405, "author_profile": "https://Stackoverflow.com/users/13078405", "pm_score": 1, "selected": false, "text": "sAboveBit =\"PS_03[05]\"\niAboveBit = int(sAboveBit[-3:-1])\n" }, { "answer_id": 74443233, "author": "Serge Ballesta", "author_id": 3545273, "author_profile": "https://Stackoverflow.com/users/3545273", "pm_score": 2, "selected": true, "text": "split" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441235", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20273554/" ]
74,441,240
<p>I have a timestamp <code>2022-11-20 21:00:00+0900</code> now I need to convert this to IST. So I tried this</p> <pre><code> loc, _ := time.LoadLocation(&quot;Asia/Calcutta&quot;) format := &quot;Jan _2 2006 3:04:05 PM&quot; timestamp := &quot;2022-11-20 21:00:00+0900&quot; ISTformat, err := time.ParseInLocation(format, timestamp, loc) fmt.Println(ISTformat, err) </code></pre> <p>but it was not worked and giving error <code>cannot parse</code></p> <p>what type of golang time format i need to use to do this?</p>
[ { "answer_id": 74441415, "author": "Navjot Sharma", "author_id": 20201743, "author_profile": "https://Stackoverflow.com/users/20201743", "pm_score": 0, "selected": false, "text": "package main\n\nimport (\n \"fmt\"\n \"time\"\n)\n\nfunc main() {\n loc, _ := time.LoadLocation(\"Asia/Calcutta\")\n\n // This will look for the name CEST in the Asia/Calcutta time zone.\n\n const longForm = \"Jan 2, 2006 at 3:04pm (MST)\"\n t, _ := time.ParseInLocation(longForm, \"Jul 9, 2012 at 5:02am (CEST)\", loc)\n fmt.Println(t)\n\n // Note: without explicit zone, returns time in given location.\n\n const shortForm = \"2006-Jan-02\"\n t, _ = time.ParseInLocation(shortForm, \"2012-Jul-09\", loc)\n fmt.Println(t)\n return\n}\n" }, { "answer_id": 74444296, "author": "0x4e696b68696c", "author_id": 18285304, "author_profile": "https://Stackoverflow.com/users/18285304", "pm_score": 3, "selected": true, "text": " loc, _ := time.LoadLocation(\"Asia/Calcutta\")\n format := \"2006-01-02 15:04:05-0700\"\n timestamp := \"2022-11-20 21:00:00+0900\"\n // ISTformat, _ := time.ParseInLocation(format, timestamp, loc)\n // fmt.Println(ISTformat)\n parsed_time, _ := time.Parse(format, timestamp)\n IST_time := parsed_time.In(loc)\n fmt.Println(\"Time in IST\", IST_time)\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20196947/" ]
74,441,292
<p>I tried to put margin to separate text and icon using this code</p> <pre><code> {% load static %} &lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot; dir=&quot;ltr&quot;&gt; &lt;head&gt; &lt;meta charset=&quot;UTF-8&quot;&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;{% static 'css/styles.css'%}&quot;&gt; &lt;!-- &lt;link href=&quot;{% static 'css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot; integrity=&quot;sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC&quot; crossorigin=&quot;anonymous&quot;&gt; &lt;script src=&quot;{% static '/js/bootstrap.bundle.min.js&quot; integrity=&quot;sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt; --&gt; &lt;link href=&quot;{% static 'css/bootstrap.min.css'%}&quot; rel=&quot;stylesheet&quot; integrity=&quot;sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC&quot; crossorigin=&quot;anonymous&quot;&gt; &lt;script src=&quot;{% static 'fontawesomefree/js/all.min.js' %}&quot;&gt;&lt;/script&gt; &lt;title&gt;Document&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div class=&quot;sidebar&quot;&gt; &lt;header&gt;Menu&lt;/header&gt; &lt;a href=&quot;#&quot; class=&quot;active&quot;&gt;&lt;i class=&quot;fas fa-qrcode&quot;&gt;&lt;/i&gt;&lt;span&gt;Dashboard&lt;/span&gt;&lt;/a&gt; &lt;a href=&quot;#&quot;&gt;&lt;i class=&quot;fas fa-link&quot;&gt;&lt;/i&gt;&lt;span&gt;Data Entry&lt;/span&gt;&lt;/a&gt; &lt;a href=&quot;#&quot;&gt;&lt;i class=&quot;fas fa-stream&quot;&gt;&lt;/i&gt;&lt;span&gt;List&lt;/span&gt;&lt;/a&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>CSS code</p> <pre><code>a.active,a:hover{ border-left: 5px solid #019321; color: #bfeb74; } .sidebar a i{ margin-right: 300px; </code></pre> <p><a href="https://i.stack.imgur.com/dmktL.png" rel="nofollow noreferrer">enter image description here</a></p> <p>It should look like this. Same code that put in codepen.io. <a href="https://i.stack.imgur.com/rbb5F.png" rel="nofollow noreferrer">enter image description here</a></p>
[ { "answer_id": 74441318, "author": "kamil", "author_id": 17498928, "author_profile": "https://Stackoverflow.com/users/17498928", "pm_score": 2, "selected": true, "text": "span { padding-left: 20px; }\n" }, { "answer_id": 74441322, "author": "Manoj Tolagekar", "author_id": 17808039, "author_profile": "https://Stackoverflow.com/users/17808039", "pm_score": 0, "selected": false, "text": ".sidebar a i{\n margin-right: 300px;\n" }, { "answer_id": 74441324, "author": "Roby Cigar", "author_id": 12402567, "author_profile": "https://Stackoverflow.com/users/12402567", "pm_score": 0, "selected": false, "text": "a.active,a:hover{\n border-left: 5px solid #019321;\n color: #bfeb74;\n }\n\n.sidebar a i {\n margin: 300px;\n}\n\n.sidebar a * {\n display: block;\n}\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20476548/" ]
74,441,308
<p>When you press the full-screen button of the youtube player it goes to landscape mode when you press it again it's come back to portrait mode but the status bar hides permanently throughout the app.</p> <p>If anyone knows <strong>how to show the status bar persistent in Portrait mode.</strong> Please let me know. Thanks!</p> <p>Here is the code:</p> <pre><code>import 'package:flutter/material.dart'; import 'package:youtube_player_flutter/youtube_player_flutter.dart'; /// Creates list of video players class VideoList extends StatefulWidget { @override _VideoListState createState() =&gt; _VideoListState(); } class _VideoListState extends State&lt;VideoList&gt; { final List&lt;YoutubePlayerController&gt; _controllers = [ 'K4TOrB7at0Y', ] .map&lt;YoutubePlayerController&gt;( (videoId) =&gt; YoutubePlayerController( initialVideoId: videoId, flags: const YoutubePlayerFlags( autoPlay: false, ), ), ) .toList(); @override Widget build(BuildContext context) { return YoutubePlayerBuilder( player: YoutubePlayer(controller: _controllers.first), builder: (p0, p1) { return Scaffold( appBar: AppBar( title: Text('Video Player'), ), body: Column(children: [ p1, ]), ); }, ); } } </code></pre> <p>Output: <a href="https://drive.google.com/file/d/1TkuDkLVflFGBNv90Tywh6CuCN3BK0EG_/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1TkuDkLVflFGBNv90Tywh6CuCN3BK0EG_/view?usp=sharing</a> <a href="https://i.stack.imgur.com/kWxEz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kWxEz.png" alt="enter image description here" /></a> Thanks!</p>
[ { "answer_id": 74441318, "author": "kamil", "author_id": 17498928, "author_profile": "https://Stackoverflow.com/users/17498928", "pm_score": 2, "selected": true, "text": "span { padding-left: 20px; }\n" }, { "answer_id": 74441322, "author": "Manoj Tolagekar", "author_id": 17808039, "author_profile": "https://Stackoverflow.com/users/17808039", "pm_score": 0, "selected": false, "text": ".sidebar a i{\n margin-right: 300px;\n" }, { "answer_id": 74441324, "author": "Roby Cigar", "author_id": 12402567, "author_profile": "https://Stackoverflow.com/users/12402567", "pm_score": 0, "selected": false, "text": "a.active,a:hover{\n border-left: 5px solid #019321;\n color: #bfeb74;\n }\n\n.sidebar a i {\n margin: 300px;\n}\n\n.sidebar a * {\n display: block;\n}\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5917068/" ]
74,441,329
<p>I am new to Android Studio and have been pulling my hair out for the past hour trying to figure this out.</p> <p>So I have a MainActivity java class which has two separate onClick methods each with an intent that opens a certain activity depending on the button (in activity_main.mxml) pressed.</p> <p>For whatever reason, the newUser.setOnClickListener() will not open SignupActivity.</p> <p>The strangest part is that if I change the destination activity in that same block to SplashActivity, it works. This tells me that it's a problem with my SignupActivity and its corresponding.xml file maybe.</p> <p>Any help is greatly appreciated.</p> <p>Here are the files in my project:</p> <p><strong>MainActvitiy.java:</strong></p> <pre><code>package com.example.neurow; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.Window; import android.view.WindowManager; import android.widget.Button; public class MainActivity extends AppCompatActivity { // Declare buttons Button existingUser, newUser; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); // Hide Action bar and Status bar this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); getSupportActionBar().hide(); setContentView(R.layout.activity_main); // Define buttons existingUser = findViewById(R.id.btnExistingUser); newUser = findViewById(R.id.btnNewUser); // Existing user button listener existingUser.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(MainActivity.this, SignupActivity.class); startActivity(i); overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); } }); // New user button listener newUser.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(MainActivity.this, SignupActivity.class); startActivity(i); overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); } }); } } </code></pre> <p><strong>SignupActivity.java:</strong></p> <pre><code>package com.example.neurow; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.WindowManager; public class SignupActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Hide Action bar and Status bar this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getSupportActionBar().hide(); setContentView(R.layout.activity_login); } // Launch MainActivity when back button is pressed public void launchMain (View v) { // Launch Log-in activity Intent i = new Intent(this, MainActivity.class); startActivity(i); overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right); } } </code></pre> <p><strong>LoginActivity.java:</strong></p> <pre><code>package com.example.neurow; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.WindowManager; public class LoginActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Hide Action bar and Status bar this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getSupportActionBar().hide(); setContentView(R.layout.activity_login); } // Launch MainActivity when back button is pressed public void launchMain (View v) { // Launch Log-in activity Intent i = new Intent(this, MainActivity.class); startActivity(i); overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right); } } </code></pre> <p><strong>activity_signup.xml:</strong></p> <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot; xmlns:tools=&quot;http://schemas.android.com/tools&quot; android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;match_parent&quot; android:background=&quot;@drawable/gradient_background&quot; tools:context=&quot;.SignupActivity&quot;&gt; &lt;!-- Welcome Back Text --&gt; &lt;TextView android:id=&quot;@+id/txtWelcome&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; android:layout_marginTop=&quot;330dp&quot; android:fontFamily=&quot;sans-serif-light&quot; android:text=&quot;Create User&quot; android:textColor=&quot;@color/white&quot; android:textSize=&quot;60sp&quot; android:textStyle=&quot;normal&quot; app:layout_constraintEnd_toEndOf=&quot;parent&quot; app:layout_constraintStart_toStartOf=&quot;parent&quot; app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt; &lt;!-- User ID Field --&gt; &lt;EditText android:id=&quot;@+id/edtTxtPromptUserID&quot; android:layout_width=&quot;332dp&quot; android:layout_height=&quot;69dp&quot; android:layout_marginTop=&quot;468dp&quot; android:backgroundTint=&quot;@color/white&quot; android:hint=&quot;@string/prompt_userID&quot; android:inputType=&quot;text&quot; android:selectAllOnFocus=&quot;true&quot; android:textColor=&quot;@color/white&quot; android:textColorHint=&quot;@color/white&quot; android:textSize=&quot;30dp&quot; app:layout_constraintEnd_toEndOf=&quot;parent&quot; app:layout_constraintHorizontal_bias=&quot;0.497&quot; app:layout_constraintStart_toStartOf=&quot;parent&quot; app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt; &lt;!-- Password Field --&gt; &lt;EditText android:id=&quot;@+id/edtTxtPromptPassword&quot; android:layout_width=&quot;332dp&quot; android:layout_height=&quot;69dp&quot; android:layout_marginTop=&quot;8dp&quot; android:backgroundTint=&quot;@color/white&quot; android:hint=&quot;@string/prompt_password&quot; android:inputType=&quot;textPassword&quot; android:selectAllOnFocus=&quot;true&quot; android:textColor=&quot;@color/white&quot; android:textColorHint=&quot;@color/white&quot; android:textSize=&quot;30dp&quot; app:layout_constraintEnd_toEndOf=&quot;parent&quot; app:layout_constraintHorizontal_bias=&quot;0.497&quot; app:layout_constraintStart_toStartOf=&quot;parent&quot; app:layout_constraintTop_toBottomOf=&quot;@+id/edtTxtPromptUserID&quot; /&gt; &lt;!-- Register Button --&gt; &lt;Button android:id=&quot;@+id/btnRegister&quot; android:layout_width=&quot;242dp&quot; android:layout_height=&quot;83dp&quot; android:layout_marginTop=&quot;40dp&quot; android:backgroundTint=&quot;#00A36C&quot; android:text=&quot;Register&quot; android:textSize=&quot;30sp&quot; android:textColor=&quot;@color/white&quot; app:layout_constraintEnd_toEndOf=&quot;parent&quot; app:layout_constraintStart_toStartOf=&quot;parent&quot; app:layout_constraintTop_toBottomOf=&quot;@+id/edtTxtPromptPassword&quot; /&gt; &lt;!-- Back button --&gt; &lt;Button android:id=&quot;@+id/btnBack2&quot; android:layout_width=&quot;134dp&quot; android:layout_height=&quot;57dp&quot; android:layout_marginTop=&quot;24dp&quot; android:onClick=&quot;launchMain&quot; android:text=&quot;Back&quot; android:textColor=&quot;@color/white&quot; android:textSize=&quot;20dp&quot; android:backgroundTint=&quot;@color/purple_200&quot; app:layout_constraintEnd_toEndOf=&quot;parent&quot; app:layout_constraintStart_toStartOf=&quot;parent&quot; app:layout_constraintTop_toBottomOf=&quot;@+id/btnRegister&quot; /&gt; &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt; </code></pre> <p>I have gone back and looked at all my files to make sure they are unique and consistent with naming, but I haven't been able to find the reason why it won't work.</p>
[ { "answer_id": 74441318, "author": "kamil", "author_id": 17498928, "author_profile": "https://Stackoverflow.com/users/17498928", "pm_score": 2, "selected": true, "text": "span { padding-left: 20px; }\n" }, { "answer_id": 74441322, "author": "Manoj Tolagekar", "author_id": 17808039, "author_profile": "https://Stackoverflow.com/users/17808039", "pm_score": 0, "selected": false, "text": ".sidebar a i{\n margin-right: 300px;\n" }, { "answer_id": 74441324, "author": "Roby Cigar", "author_id": 12402567, "author_profile": "https://Stackoverflow.com/users/12402567", "pm_score": 0, "selected": false, "text": "a.active,a:hover{\n border-left: 5px solid #019321;\n color: #bfeb74;\n }\n\n.sidebar a i {\n margin: 300px;\n}\n\n.sidebar a * {\n display: block;\n}\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20259005/" ]
74,441,354
<p>This is a hackerrank program which I tried last week. There is a list of Items in the shopping cart, each having a cost associated with it.</p> <p>There are <code>n</code> items, the cost of the <code>ith</code> item is <code>i</code> dollars and <code>m</code> items have already been bought and represented in the array <code>arr</code>. Currently, there are <code>k</code> dollars, find the maximum number of distinct items one can have in total after purchasing any number of items from that money.</p> <p><strong>Example:</strong></p> <pre><code>Consider n=10,m=3,k=10,arr=[1,3, 8]. </code></pre> <p>So, the task is to find the maximum number of distinct items which can be purchased out 10 items within 10 dollars apart from items {1,3,8}. At max, 2 items can be purchased apart from the given 3 , let's say Item - 2 and Item - 5. Total cost=2+5=7, which is less than 10 .</p> <p>Let us consider three items - Item - 2, Item - 4, 200,</p> <p><strong>The answer is 5</strong> (3 already purchased, and 2 purchased just now).</p> <p>The function must return an integer denoting the maximum count of distinct items that can be purchased.</p> <p>The function has the following parameter(s):</p> <pre><code>n : an integer denoting the number of items arr[m]: an integer array denoting already purchased items k : an integer denoting amount in dollars Constraints </code></pre> <p><strong>Constraints -</strong></p> <pre><code>1≤n≤10^6 1≤m≤10^5 1≤k≤10^9 1≤a[i]≤10^6 </code></pre> <p>This question is already posted by someone <a href="https://www.chegg.com/homework-help/questions-and-answers/2-distinct-items-list-items-shopping-cart-cost-associated--n-items-cost-th-item-idollars-m-q103071883" rel="nofollow noreferrer">here</a>, just in case if anyone wants to look at the exact question.</p> <p>Now, my thought process. As I have K dollars and I have to find the maximum elements to collect whose sum is up to k. I start a number from 1 till n and check if that number is missing in the input list, if yes then add to a sum, and do this process until the sum is less than or equal to <code>k</code>.</p> <pre><code>public int process(int n, int k, List&lt;Integer&gt; arr) { Set&lt;Integer&gt; set = new HashSet&lt;&gt;(arr); long sum = 0; int result = arr.size(); for(int i=1; i&lt;=n; i++) { if(set.contains(i) == false) { if(sum + i &lt;= k) { sum += i; result++; } } } return result; } </code></pre> <p>Now, this program works for the given sample test cases.</p> <p>Some other test cases are:</p> <pre><code>n=5, k=8, arr=[3,6] . Expected answer = 5 n=8, k=5, arr=[1,2] . Expected answer = 3 n=1, k=10, arr=[1] . Expected answer = 1 </code></pre> <p>My program works with these sample testcases. But hackerrank has 11 other hidden test cases which are all hidden that are failing with wrong result, i don't see any memory errors or time out errors for these hidden testcases.</p> <p>Now my question is, what is the right approach to solve this problem? As the question says to find the maximum elements to collect, I started from 1 till n to find the missing elements which is valid approach but still it is failing.</p>
[ { "answer_id": 74441318, "author": "kamil", "author_id": 17498928, "author_profile": "https://Stackoverflow.com/users/17498928", "pm_score": 2, "selected": true, "text": "span { padding-left: 20px; }\n" }, { "answer_id": 74441322, "author": "Manoj Tolagekar", "author_id": 17808039, "author_profile": "https://Stackoverflow.com/users/17808039", "pm_score": 0, "selected": false, "text": ".sidebar a i{\n margin-right: 300px;\n" }, { "answer_id": 74441324, "author": "Roby Cigar", "author_id": 12402567, "author_profile": "https://Stackoverflow.com/users/12402567", "pm_score": 0, "selected": false, "text": "a.active,a:hover{\n border-left: 5px solid #019321;\n color: #bfeb74;\n }\n\n.sidebar a i {\n margin: 300px;\n}\n\n.sidebar a * {\n display: block;\n}\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3181365/" ]
74,441,383
<p>I have multiple columns in a pandas dataframe that I want to reduce from wide form to long form so that it essentially multiplies the number of rows in my dataframe by 2 and also adds a new column to indicate where each row comes from originally.</p> <p>I have the following dataframe <code>df</code> where cols <code>a1</code>, <code>b1</code>, <code>c1</code>, and <code>d1</code> all belong to one group:</p> <pre><code>name a1 b1 c1 d1 a2 b2 c2 d2 joe x y x y z e e f lily x o x y z o e f john o y x q z f e q </code></pre> <p>I want to transform it into the <strong>following final table</strong> with a new column to indicate where the values originated from</p> <pre><code>name a1 b1 c1 d1 new_col joe x y x y group1 lily x o x y group1 john o y x q group1 joe z e e f group2 lily z o e f group2 john z f e q group2 </code></pre> <p>I've tried using melt functions but can't seem to figure out how to do it for multiple variable pairs. For instance, I can do it for 2 columns but not all 8:</p> <pre><code>import pandas as pd pd.melt(df, id_vars = 'name', var_name = 'a_var', value_vars = ['a1', 'a2']) </code></pre> <p>which results in</p> <pre><code>name a_var value joe a1 x lily a1 x john a1 o joe a2 z lily a2 z john a2 z </code></pre>
[ { "answer_id": 74441408, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 3, "selected": true, "text": "wide_to_long" }, { "answer_id": 74442145, "author": "sammywemmy", "author_id": 7175713, "author_profile": "https://Stackoverflow.com/users/7175713", "pm_score": 1, "selected": false, "text": "names_pattern" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12148545/" ]
74,441,388
<p>I wanted to create a new column, let say named &quot;group id&quot; on the basis of:</p> <ol> <li>compare the nth row with (n-1)th row.</li> <li>if both the records are equal then in a &quot;group id&quot;, previous &quot;group id&quot; is copied</li> <li>If these records are not equal, then 1 should be added to &quot;group id column&quot;.</li> </ol> <p>I wanted to have the result in the following way:</p> <p><a href="https://i.stack.imgur.com/W1ju7.png" rel="nofollow noreferrer">The expected result </a></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Column A</th> <th>Column B</th> </tr> </thead> <tbody> <tr> <td>6-Aug-10</td> <td>0</td> </tr> <tr> <td>30-Aug-11</td> <td>1</td> </tr> <tr> <td>31-Aug-11</td> <td>2</td> </tr> <tr> <td>31-Aug-11</td> <td>2</td> </tr> <tr> <td>6-Sep-12</td> <td>3</td> </tr> <tr> <td>30-Aug-13</td> <td>4</td> </tr> </tbody> </table> </div> <p>Looking for the result, similar to this excel function =IF(T3=T2, U2, U2+1)</p>
[ { "answer_id": 74441408, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 3, "selected": true, "text": "wide_to_long" }, { "answer_id": 74442145, "author": "sammywemmy", "author_id": 7175713, "author_profile": "https://Stackoverflow.com/users/7175713", "pm_score": 1, "selected": false, "text": "names_pattern" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20507143/" ]
74,441,405
<p>In one table I have such column with data</p> <p><a href="https://i.stack.imgur.com/bX6dq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bX6dq.png" alt="Source data" /></a></p> <p>Is there possible way to make a query that return this data in this format:</p> <pre><code>_IDS_ 71554 99188 69337 70534 73575 </code></pre> <p>as separate ids that then I can use it for example in query</p> <p><code>WHERE table.o_id NOT IN (_IDS_)</code></p>
[ { "answer_id": 74441570, "author": "bigtheo", "author_id": 13567984, "author_profile": "https://Stackoverflow.com/users/13567984", "pm_score": 0, "selected": false, "text": "Sélect * from table1 where id not in (sélect cast(strcol as int) from table2);\n" }, { "answer_id": 74441736, "author": "Lewis E", "author_id": 1724627, "author_profile": "https://Stackoverflow.com/users/1724627", "pm_score": -1, "selected": false, "text": "SELECT * FROM demotbl2 where id not in (SELECT GROUP_CONCAT(TRIM(',' FROM WebImages__images)) FROM demotbl1);" }, { "answer_id": 74441858, "author": "Akina", "author_id": 10138734, "author_profile": "https://Stackoverflow.com/users/10138734", "pm_score": 2, "selected": false, "text": "SELECT *\nFROM data_table\nWHERE NOT EXISTS ( SELECT NULL\n FROM CSV_table\n WHERE FIND_IN_SET(data_table.o_id, CSV_table.WebImages__images) \n );\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5686432/" ]
74,441,486
<p>I am having a complex nested json</p> <pre><code>{ ... &quot;key1&quot;: { &quot;key2&quot; : [ { ... &quot;base_score&quot; :4.5 } ] &quot;key3&quot;: { &quot;key4&quot;: [ { ... &quot;base_score&quot; : 0.5 ... } ] } ... } } </code></pre> <p>There maybe multiple &quot;base_score&quot; in the json(&quot;base_score&quot; path is unknown) and the corresponding value will be a number, I have to check if at least one such value is greater than some known value 7.0, and if there is, I have to do &quot;exit 1&quot;. I have to write this query in shell script.</p>
[ { "answer_id": 74441642, "author": "peak", "author_id": 997358, "author_profile": "https://Stackoverflow.com/users/997358", "pm_score": 2, "selected": false, "text": "jq --argjson limit 7.0 '\n any(.. | select(type==\"object\" and (.base_score|type==\"number\")) | .base_score; . > $limit)\n | halt_error(if . then 1 else 0 end)\n' input.json\n" }, { "answer_id": 74441746, "author": "knittl", "author_id": 112968, "author_profile": "https://Stackoverflow.com/users/112968", "pm_score": 1, "selected": false, "text": "base_score" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14996394/" ]
74,441,510
<pre><code> mpdf.create_pvf(card, mpImgBytes, mlen, L&quot;&quot;); int inDoc = mpdf.open_pdi_document(card, L&quot;&quot;); </code></pre> <p>I am using pdflib version 9.3.</p> <blockquote> <p>open_pdi_document returns -1</p> </blockquote> <blockquote> <p>create_pvf creates an empty file of size 0. Any idea on what could be wrong?</p> </blockquote> <p>I am running pdflib on Windows 10, using C++.</p>
[ { "answer_id": 74443860, "author": "Rainer", "author_id": 2862406, "author_profile": "https://Stackoverflow.com/users/2862406", "pm_score": 2, "selected": false, "text": "open_pdi_document()" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17021954/" ]
74,441,561
<p>Can someone please explain me how the below epoch time</p> <ul> <li>epoch time/unix-timestamp :<strong>1668443121840</strong></li> <li>converts to the date : <strong>2022-11-14T16:25:21.840+0000</strong></li> </ul> <p>How is the conversion taking place and additionally how to identify an epoch timestamp if it is mentioned in seconds, milliseconds, microseconds or nanoseconds?</p> <p>Additionally, is there a function in pyspark to convert the date back to epoch timestamp?</p> <p>Thanks! in advance.</p> <p>I tried a number of methods but I am not achieving the expected result:</p> <pre><code>t = datetime.datetime.strptime('2021-11-12 02:12:23', '%Y-%m-%d %H:%M:%S') print(t.strftime('%s')) </code></pre> <p>As I am not able to control the format or accuracy in terms of seconds, milliseconds, microseconds or nanoseconds.</p>
[ { "answer_id": 74443860, "author": "Rainer", "author_id": 2862406, "author_profile": "https://Stackoverflow.com/users/2862406", "pm_score": 2, "selected": false, "text": "open_pdi_document()" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20475188/" ]
74,441,578
<p>Did anyone try this?</p> <p>I have a custom module I created a field next visit, I want to make an event after saving my record in my custom module based on next visit field date. here's the following code tried.</p> <pre><code>public function process(Vtiger_Request $request) { try { $CustomSaveEvents= $this-&gt;saveAppointmentRecord(); } catch (Exception $e) { throw new Exception($e-&gt;getMessage()); } } public function saveAppointmentRecord() { try { $linkModule =&quot;Events&quot;; $recordModel1 = Vtiger_Record_Model::getCleanInstance($linkModule); $recordModel1-&gt;set('subject', &quot;Sample&quot;); $recordModel1-&gt;set('mentorid',&quot;6411&quot;); $recordModel1-&gt;set('apprenticeid',&quot;10849&quot;); $recordModel1-&gt;set('due_date', '2022-10-24'); $recordModel1-&gt;set('time_end','2022-10-24'); $recordModel1-&gt;set('mode', 'create'); $recordModel1-&gt;save(); $this-&gt;savedRecordId = $recordModel1-&gt;getId(); return $recordModel1; }catch (Exception $e) { throw new Exception($e-&gt;getMessage()); } } </code></pre> <p>But it didn't work. any can help me? Thank you in advance!</p> <p>calendar will show new record</p>
[ { "answer_id": 74443860, "author": "Rainer", "author_id": 2862406, "author_profile": "https://Stackoverflow.com/users/2862406", "pm_score": 2, "selected": false, "text": "open_pdi_document()" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10471397/" ]
74,441,582
<p>Is there any way to stop all nested describes in case one of the Iterations (Test case) is failing inside one of the nested describes</p> <p>how to achieve this anyone have any idea</p> <p>Example</p> <pre><code>Test Describe 1 it() {} Describe 1.1 It1() {} It2() {} (On Error) It3() {} (Skip this) Describe 1.2 (Skip this) It12() {} (Skip this) It22() {} (Skip this) It33() {} (Skip this) Describe 2 (Don't Skip this) it() {} (Don't Skip this) Describe 1.1 It21() {} (Don't Skip this) It22() {} (Don't Skip this) It23() {} (Don't Skip this) </code></pre>
[ { "answer_id": 74443860, "author": "Rainer", "author_id": 2862406, "author_profile": "https://Stackoverflow.com/users/2862406", "pm_score": 2, "selected": false, "text": "open_pdi_document()" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5097541/" ]
74,441,607
<p>how to get substring from</p> <pre class="lang-none prettyprint-override"><code> 42 45 47 49 4e 21 40 23 47 68 6a 6b 2c 47 68 6a BEGIN!@#Ghjk,Ghj 6b 45 4e 44 23 40 21 kEND#@! </code></pre> <p>to be</p> <pre class="lang-none prettyprint-override"><code>BEGIN!@#Ghjk,GhjkEND#@! </code></pre> <p><strong>Note:</strong> there is whitespaces at end of lines, I tried removing whitespaces at end of lines but I cant.</p> <p>I tried</p> <pre class="lang-bash prettyprint-override"><code>#!/bin/bash s=$(awk '/BEGIN!@#/,/END#@!/' switch.log ) while IFS= read -r line do h=$(echo &quot;$line&quot; | awk '{$1=$1;print}') for i in {0..100} do zzz=$(echo &quot;$h&quot; | awk '{print $(NF-$i)}') if [ ! -z &quot;$zzz&quot; -a &quot;$zzz&quot; != &quot; &quot; ]; then hh=$(echo &quot;$h&quot; | awk '{print $(NF-$i)}') echo &quot;$zzz&quot; echo -e &quot;$zzz&quot; &gt;&gt; ggg.txt break fi done done &lt;&lt;&lt; &quot;$s&quot; </code></pre> <p>I got</p> <pre class="lang-none prettyprint-override"><code>BEGIN!@#Ghjk,Ghj </code></pre>
[ { "answer_id": 74441833, "author": "user1934428", "author_id": 1934428, "author_profile": "https://Stackoverflow.com/users/1934428", "pm_score": 1, "selected": false, "text": "if [[ $line =~ (BEGIN[^ ]+)\\ .*([^ ]+END[^ ]+) ]]\nthen\n substring=${BASH_REMATCH[1]}${BASH_REMATCH[2]}\nelse\n echo Pattern not found in line 1>&2\nfi\n" }, { "answer_id": 74441877, "author": "David C. Rankin", "author_id": 3422102, "author_profile": "https://Stackoverflow.com/users/3422102", "pm_score": 2, "selected": false, "text": "sed" }, { "answer_id": 74442297, "author": "HatLess", "author_id": 16372109, "author_profile": "https://Stackoverflow.com/users/16372109", "pm_score": 2, "selected": false, "text": "sed" }, { "answer_id": 74444309, "author": "Daweo", "author_id": 10785975, "author_profile": "https://Stackoverflow.com/users/10785975", "pm_score": 0, "selected": false, "text": "file.txt" }, { "answer_id": 74468719, "author": "Dave Pritlove", "author_id": 2005666, "author_profile": "https://Stackoverflow.com/users/2005666", "pm_score": 0, "selected": false, "text": "awk" }, { "answer_id": 74502148, "author": "karakfa", "author_id": 1435869, "author_profile": "https://Stackoverflow.com/users/1435869", "pm_score": 0, "selected": false, "text": "$ grep -oE '(BEGIN|END)\\S*' file | paste -sd'\\0'\n\nBEGIN!@#Ghjk,GhjEND#@!\n" }, { "answer_id": 74530069, "author": "RARE Kpop Manifesto", "author_id": 14672114, "author_profile": "https://Stackoverflow.com/users/14672114", "pm_score": 0, "selected": false, "text": "echo ' 42 45 47 49 4e 21 40 23 47 68 6a 6b 2c 47 68 ' \\\n '6a BEGIN!@#Ghjk,Ghj 6b 45 4e 44 23 40 21 kEND#@!' | \n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20507322/" ]
74,441,616
<p>Is there a way to copy data from all tables in a Synapse instance to another?</p> <p>Considered Data Migration Assistant, but it doesn't allow to select Synapse as Source.</p> <p>Also, I am considering to use Copy activity in a pipeline, but the number of tables is not small.</p>
[ { "answer_id": 74441833, "author": "user1934428", "author_id": 1934428, "author_profile": "https://Stackoverflow.com/users/1934428", "pm_score": 1, "selected": false, "text": "if [[ $line =~ (BEGIN[^ ]+)\\ .*([^ ]+END[^ ]+) ]]\nthen\n substring=${BASH_REMATCH[1]}${BASH_REMATCH[2]}\nelse\n echo Pattern not found in line 1>&2\nfi\n" }, { "answer_id": 74441877, "author": "David C. Rankin", "author_id": 3422102, "author_profile": "https://Stackoverflow.com/users/3422102", "pm_score": 2, "selected": false, "text": "sed" }, { "answer_id": 74442297, "author": "HatLess", "author_id": 16372109, "author_profile": "https://Stackoverflow.com/users/16372109", "pm_score": 2, "selected": false, "text": "sed" }, { "answer_id": 74444309, "author": "Daweo", "author_id": 10785975, "author_profile": "https://Stackoverflow.com/users/10785975", "pm_score": 0, "selected": false, "text": "file.txt" }, { "answer_id": 74468719, "author": "Dave Pritlove", "author_id": 2005666, "author_profile": "https://Stackoverflow.com/users/2005666", "pm_score": 0, "selected": false, "text": "awk" }, { "answer_id": 74502148, "author": "karakfa", "author_id": 1435869, "author_profile": "https://Stackoverflow.com/users/1435869", "pm_score": 0, "selected": false, "text": "$ grep -oE '(BEGIN|END)\\S*' file | paste -sd'\\0'\n\nBEGIN!@#Ghjk,GhjEND#@!\n" }, { "answer_id": 74530069, "author": "RARE Kpop Manifesto", "author_id": 14672114, "author_profile": "https://Stackoverflow.com/users/14672114", "pm_score": 0, "selected": false, "text": "echo ' 42 45 47 49 4e 21 40 23 47 68 6a 6b 2c 47 68 ' \\\n '6a BEGIN!@#Ghjk,Ghj 6b 45 4e 44 23 40 21 kEND#@!' | \n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2881345/" ]
74,441,622
<p>Trying to find duplicates in an array where each list inside the list is a different row of a document. Im trying to find the words where that are the same</p> <pre><code>def helper(a): for x in range(len(a)-1): for y in range(len(a[x])): for i in range(len(a)): for j in range(len(a[x])-1): if(a[x][y]==a[i][j]): if(x!=i and y!=j): print(a[i][j]) </code></pre> <p>a=[[i, will, always, be, very, happy][happy,people, are, cool, very]]</p> <p>only prints out happy when I want happy and very to be printed if I change the -1 in the for loops it gets an index out of bounds error</p>
[ { "answer_id": 74441693, "author": "JohnyCapo", "author_id": 19335841, "author_profile": "https://Stackoverflow.com/users/19335841", "pm_score": -1, "selected": false, "text": "for" }, { "answer_id": 74441705, "author": "Tr3ate", "author_id": 14793476, "author_profile": "https://Stackoverflow.com/users/14793476", "pm_score": 1, "selected": false, "text": "a =[[\"i\", \"will\", \"always\", \"be\", \"very\", \"happy\"],[\"happy\",\"people\", \"are\", \"cool\", \"very\"]]\nfor i in range(len(a)-1):\n res = set(a[i]) & set(a[i+1])\n print(res)\n" }, { "answer_id": 74441719, "author": "0x0fba", "author_id": 20339407, "author_profile": "https://Stackoverflow.com/users/20339407", "pm_score": 1, "selected": false, "text": "word for word in a[0]" }, { "answer_id": 74441851, "author": "Rajarshi Bandopadhyay", "author_id": 9548172, "author_profile": "https://Stackoverflow.com/users/9548172", "pm_score": 0, "selected": false, "text": "functools.reduce" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20506902/" ]
74,441,662
<p>I am trying to save roughly 20,000 records and it takes an unforgivable amount of time to finish. What is the more optimal way of achieving this?</p> <p>Here's what I currently have:</p> <pre><code>public async Task SaveOrUpdateItemAsync(List&lt;DepartmentalizedItem&gt; departmentalizedItems) { using(WarehouseContext dbContext = new WarehouseContext()) { using(SemaphoreSlim throttler = new SemaphoreSlim(20)) { var tasks = departmentalizedItems.Select(async item =&gt; { await throttler.WaitAsync(); if (item.PK_DepartmentalizedItemId == 0) dbContext.DepartmentalizedItems.Add(item); else { var deptItem = await dbContext.DepartmentalizedItems.FindAsync(item.PK_DepartmentalizedItemId); dbContext.Entry(deptItem).CurrentValues.SetValues(item); } throttler.Release(); }); await Task.WhenAll(tasks); } await dbContext.SaveChangesAsync(); } } </code></pre> <p>I've also tried Parallel.ForEach but I'm having synchronization issues.</p> <p>Thank you.</p>
[ { "answer_id": 74441788, "author": "Kiran Joshi", "author_id": 9760311, "author_profile": "https://Stackoverflow.com/users/9760311", "pm_score": 2, "selected": false, "text": "AddRange" }, { "answer_id": 74442939, "author": "JonasH", "author_id": 12342238, "author_profile": "https://Stackoverflow.com/users/12342238", "pm_score": 1, "selected": false, "text": "var ids = departmentalizedItems.Select(i => i.PK_DepartmentalizedItemId).ToList();\nvar itemsById = dbContext.DepartmentalizedItems.Where(i => ids.Contains(i)).ToDictionary(i => i.PK_DepartmentalizedItemId, i => i);\n" }, { "answer_id": 74469279, "author": "redz0323", "author_id": 9589439, "author_profile": "https://Stackoverflow.com/users/9589439", "pm_score": 1, "selected": true, "text": "public async Task BulkSaveAndUpdateAsync(List<DepartmentalizedItem> departmentalizedItems, CancellationToken cancellationToken)\n {\n using (WarehouseContext dbContext = new WarehouseContext())\n {\n var toAddItems = departmentalizedItems.Where(i => i.PK_DepartmentalizedItemId == 0);\n var toUpdateItems = departmentalizedItems.Where(i => i.PK_DepartmentalizedItemId > 0);\n await dbContext.BulkInsertAsync(toAddItems, cancellationToken);\n await dbContext.BulkUpdateAsync(toUpdateItems, cancellationToken);\n }\n }\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9589439/" ]
74,441,730
<p>I can install modules, such as the 'requests' module. However, if I try and import them, python tells me it's missing. I can use native modules such as the json module, however.</p> <p>I tried to install and import third-party modules in python on visualstudio code, but I'm stuck trying to figure out how to import them.</p>
[ { "answer_id": 74441788, "author": "Kiran Joshi", "author_id": 9760311, "author_profile": "https://Stackoverflow.com/users/9760311", "pm_score": 2, "selected": false, "text": "AddRange" }, { "answer_id": 74442939, "author": "JonasH", "author_id": 12342238, "author_profile": "https://Stackoverflow.com/users/12342238", "pm_score": 1, "selected": false, "text": "var ids = departmentalizedItems.Select(i => i.PK_DepartmentalizedItemId).ToList();\nvar itemsById = dbContext.DepartmentalizedItems.Where(i => ids.Contains(i)).ToDictionary(i => i.PK_DepartmentalizedItemId, i => i);\n" }, { "answer_id": 74469279, "author": "redz0323", "author_id": 9589439, "author_profile": "https://Stackoverflow.com/users/9589439", "pm_score": 1, "selected": true, "text": "public async Task BulkSaveAndUpdateAsync(List<DepartmentalizedItem> departmentalizedItems, CancellationToken cancellationToken)\n {\n using (WarehouseContext dbContext = new WarehouseContext())\n {\n var toAddItems = departmentalizedItems.Where(i => i.PK_DepartmentalizedItemId == 0);\n var toUpdateItems = departmentalizedItems.Where(i => i.PK_DepartmentalizedItemId > 0);\n await dbContext.BulkInsertAsync(toAddItems, cancellationToken);\n await dbContext.BulkUpdateAsync(toUpdateItems, cancellationToken);\n }\n }\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15790774/" ]
74,441,753
<p>I have an invaild view on my PROD system:</p> <pre><code>PROD.CLIENT </code></pre> <p>I found out that is invalid with following statement:</p> <pre><code>select owner c1, object_type c3, object_name c2 from dba_objects where status != 'VALID' order by owner, object_type; </code></pre> <p>I tried recompiling it but when I try the first statement it still shows up:</p> <pre><code>ALTER VIEW PROD.CLIENT COMPILE; </code></pre> <p>I also tried searching for user errors, but there are none:</p> <pre><code>SELECT * FROM user_errors; </code></pre> <p>How can I find the problem or error with my invalid view?</p>
[ { "answer_id": 74441823, "author": "lavantho0508_java_dev", "author_id": 18500877, "author_profile": "https://Stackoverflow.com/users/18500877", "pm_score": 0, "selected": false, "text": " CREATE VIEW example AS\n select\n owner c1,\n object_type c3,\n object_name c2\nfrom\n dba_objects\nwhere\n status != 'VALID'\norder by\n owner,\n object_type;\n--- and then \nSELECT * FROM example; -- call view\n" }, { "answer_id": 74442456, "author": "MT0", "author_id": 1509264, "author_profile": "https://Stackoverflow.com/users/1509264", "pm_score": 1, "selected": false, "text": "SELECT * FROM user_errors;\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441753", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18297879/" ]
74,441,758
<p>I am trying to teach myself linked lists, so I have managed to put together a small piece of code that should create three linked nodes and then print them out. Except it only prints out the first element, and I don't understand why not the other two.</p> <p>Also, I am pretty sure I am supposed to free memory when I use malloc? but I don't know where?</p> <p>Anyway, what am I doing wrong?? here is the code...</p> <p>I know that there are similar answers out there, but I have checked them out, and would prefer an answer to my specific situation, because I wouldn't get it otherwise...</p> <pre><code>#include&lt;stdio.h&gt; #include &lt;stdlib.h&gt; struct Node { int data; struct Node *next; }; void printList(struct Node *ptr); int main(void) { struct Node* head = NULL; struct Node* second = NULL; struct Node* third = NULL; head = (struct Node*)malloc(sizeof(struct Node)); second = (struct Node*)malloc(sizeof(struct Node)); third = (struct Node*)malloc(sizeof(struct Node)); head-&gt;data = 10; head-&gt;next = second; second-&gt;data = 20; head-&gt;next = third; third-&gt;data = 30; head-&gt;next = NULL; printList(head); } void printList(struct Node *ptr) { struct Node *listPtr; listPtr = ptr; int count = 1; if (listPtr == NULL) { printf(&quot;No elements in list.\n&quot;); return; } while (listPtr!=NULL) { printf(&quot;element %d = %d\n&quot;,count,listPtr-&gt;data); listPtr = listPtr-&gt;next; count++; } } </code></pre> <p>I have looked into similar code examples, and they (at least a couple of them), look similar to mine, so I don't really know what I am doing wrong...</p>
[ { "answer_id": 74441823, "author": "lavantho0508_java_dev", "author_id": 18500877, "author_profile": "https://Stackoverflow.com/users/18500877", "pm_score": 0, "selected": false, "text": " CREATE VIEW example AS\n select\n owner c1,\n object_type c3,\n object_name c2\nfrom\n dba_objects\nwhere\n status != 'VALID'\norder by\n owner,\n object_type;\n--- and then \nSELECT * FROM example; -- call view\n" }, { "answer_id": 74442456, "author": "MT0", "author_id": 1509264, "author_profile": "https://Stackoverflow.com/users/1509264", "pm_score": 1, "selected": false, "text": "SELECT * FROM user_errors;\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20224183/" ]
74,441,806
<p>I am having an issue when trying to define my routes to controller classes in Laravel.</p> <p>My web.php route looks like this:</p> <pre><code>use App\Http\Controllers\Frontend\ArticlesController as FrontEndArticlesController; Route::get('/articles/{article:slug}', [FrontendArticlesController::class, 'show']); </code></pre> <p>The controller looks like this:</p> <pre><code>namespace App\Http\Controllers; use App\Models\Article; use Illuminate\Http\Request; use Inertia\Inertia; class ArticlesController extends Controller { public function index() { $articles = Article::orderBy('created_at', 'desc')-&gt;paginate(5); return Inertia::render('Article/Index', compact('articles')); } public function show($slug) { $article = Article::where('slug', $slug)-&gt;firstOrFail(); return Inertia::render('Article/Show', compact('article')); } } </code></pre> <p>I keep getting the following errors no matter what I do, please help.</p> <pre><code>Cannot declare class App\Http\Controllers\ArticlesController, because the name is already in use </code></pre>
[ { "answer_id": 74441823, "author": "lavantho0508_java_dev", "author_id": 18500877, "author_profile": "https://Stackoverflow.com/users/18500877", "pm_score": 0, "selected": false, "text": " CREATE VIEW example AS\n select\n owner c1,\n object_type c3,\n object_name c2\nfrom\n dba_objects\nwhere\n status != 'VALID'\norder by\n owner,\n object_type;\n--- and then \nSELECT * FROM example; -- call view\n" }, { "answer_id": 74442456, "author": "MT0", "author_id": 1509264, "author_profile": "https://Stackoverflow.com/users/1509264", "pm_score": 1, "selected": false, "text": "SELECT * FROM user_errors;\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20413406/" ]
74,441,878
<p>I have pushed 2 commits in my feature branch(remote) but now I have to revert back the latest commit for the branch.</p> <p>e.g commit A latest commit B first</p> <p>here I want to delete commit A and want to leave changes as it was in commit B</p> <p>I can see many solution in google but not sure what to do? Some says make the changes and again push the changes in remote. Some says to delete the last commit and rewrite the history.</p> <p>I don't want to loose the changes from the first commit. and just want to delete the latest commit from remote branch.</p>
[ { "answer_id": 74441823, "author": "lavantho0508_java_dev", "author_id": 18500877, "author_profile": "https://Stackoverflow.com/users/18500877", "pm_score": 0, "selected": false, "text": " CREATE VIEW example AS\n select\n owner c1,\n object_type c3,\n object_name c2\nfrom\n dba_objects\nwhere\n status != 'VALID'\norder by\n owner,\n object_type;\n--- and then \nSELECT * FROM example; -- call view\n" }, { "answer_id": 74442456, "author": "MT0", "author_id": 1509264, "author_profile": "https://Stackoverflow.com/users/1509264", "pm_score": 1, "selected": false, "text": "SELECT * FROM user_errors;\n" } ]
2022/11/15
[ "https://Stackoverflow.com/questions/74441878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14237523/" ]