qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,152,947
<p>I want to print out the response of my fetch request in react native.</p> <p>How would I do this to get the response inside a Text?</p> <pre><code>function Nft() { fetch( &quot;https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&amp;vs_currencies=usd&quot; ); return ( &lt;View&gt; &lt;Text style={style.header}&gt;Bitcoin Price&lt;/Text&gt; &lt;/View&gt; ); } export default Nft; </code></pre>
[ { "answer_id": 74153185, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 1, "selected": false, "text": "# get max multiple\nMAX = input_df['Max'].div(input_df['Size'])\n\nNEW = (input_df['Space']\n .div(input_df['...
2022/10/21
[ "https://Stackoverflow.com/questions/74152947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20300547/" ]
74,152,957
<p>First off: I don't really know how to correctly phrase this question, the idea is as follows:</p> <p>I have a standard dictionary that I want to check values in, with different objects using that dictionary to check items to. Now if I'm working in a specific object and append data to the dictionary of that object, the data gets appended to all dictionaries within all objects... How do I change this so that working in one object does not alter the dictionaries in another object? Below you can find the general gist of what I would like to do:</p> <pre><code>def main(): class Header: dict = {1: [], 2: []} l = [1, 1, 1] headerDicts = [] for item in l: if item in Header.dict: headerDicts.append(Header.dict) headerDicts[len(headerDicts)-1][item].append(5) print(headerDicts) if __name__ == '__main__': main() </code></pre> <p>Running this produces the following:</p> <pre><code>[{1: [5, 5, 5], 2: []}, {1: [5, 5, 5], 2: []}, {1: [5, 5, 5], 2: []}] </code></pre> <p>What I would like is the following:</p> <pre><code>[{1: [5], 2: []}, {1: [5], 2: []}, {1: [5], 2: []}] </code></pre> <p>So that each dictionary in the list I'm creating has its own independent dictionary I can work in. So far, I've not found a solution to this problem</p>
[ { "answer_id": 74153185, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 1, "selected": false, "text": "# get max multiple\nMAX = input_df['Max'].div(input_df['Size'])\n\nNEW = (input_df['Space']\n .div(input_df['...
2022/10/21
[ "https://Stackoverflow.com/questions/74152957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19292048/" ]
74,152,960
<p>I have a simple table and I want to navigate to the <code>user.id</code> but it throws off the formatting. Is there another way to do this or do I move LinkToUser?</p> <p>I have removed all styling so there is nothing conflicting.</p> <pre><code>import styled from 'styled-components' import { Link } from 'react-router-dom' export const LinkToUser = styled(Link)` ` export const StyledTable = styled.table` `; export const THead = styled.thead` `; export const TR = styled.tr` `; export const TBody = styled.tbody` `; export const TH = styled.th` `; export const TD = styled.td` `; </code></pre> <pre><code> &lt;StyledTable&gt; &lt;THead&gt; &lt;TR&gt; &lt;TH&gt;{copy.tableHeaderA}&lt;/TH&gt; &lt;TH&gt;{copy.tableHeaderB}&lt;/TH&gt; &lt;TH&gt;{copy.tableHeaderC}&lt;/TH&gt; &lt;/TR&gt; &lt;/THead&gt; &lt;TBody&gt; {fetchedUsersData?.map((user: Users) =&gt; ( &lt;LinkToUser to={`/users/${user.id}`}&gt; &lt;TR key={user.id}&gt; &lt;TD&gt; &lt;p&gt;{user.username}&lt;/p&gt; &lt;/TD&gt; &lt;TD&gt; &lt;p&gt;{user.name}&lt;/p&gt; &lt;/TD&gt; &lt;TD&gt; &lt;p&gt;{user.company.name}&lt;/p&gt; &lt;/TD&gt; &lt;/TR&gt; &lt;/LinkToUser&gt; ))} &lt;/TBody&gt; &lt;/StyledTable &gt; </code></pre> <p><a href="https://i.stack.imgur.com/VoHf4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VoHf4.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74152981, "author": "Wings", "author_id": 6912349, "author_profile": "https://Stackoverflow.com/users/6912349", "pm_score": 0, "selected": false, "text": "{fetchedUsersData?.map((user: Users) => (\n <LinkToUser to={`/users/${user.id}`}>\n ...
2022/10/21
[ "https://Stackoverflow.com/questions/74152960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19932692/" ]
74,152,964
<p>I'm trying to figure out where my problem comes from in my algorithm.</p> <p>I am trying to give the information about the connection status of a data sender with its data table.</p> <p>I have translated it like this: if new data is received ( new_id different from id_from_last_request) then I set the connection status to &quot;connected&quot; otherwise I set it to &quot;disconnected&quot;</p> <pre class="lang-html prettyprint-override"><code>&lt;script&gt; export default { data() { return { search: '', tag_id: ['bts_d02c2b7d9098aaa2', 'bts_c077ffaa9098aaa2'], headers: [ { text: 'Tags', align: 'start', sortable: false, value: 'name', }, { text: 'wifi', value: 'wifi' }, ], val_ia: 0, desserts: [], id_memory: [], } }, mounted() { this.CreateTable(); setInterval(this.getDatafor, 1000) }, methods: { CreateTable() { for (let i = 0; i &lt; this.tag_id.length; i++) { this.desserts.push( { name: this.tag_id[i], }, ) } }, async getDatafor() { for (let i = 0; i &lt; this.desserts.length; i++) { this.val_ia = i; await Promise.all([this.getAllData()]); } }, async getAllData() { const tag_id_name = encodeURIComponent(this.tag_id[this.val_ia]); const url = this.$api.getRESTApiUri() + `/all/last_id/${tag_id_name}`; return fetch(url) .then(res =&gt; res.text()) .then((result) =&gt; { console.log(tag_id_name) console.log(this.id_memory[this.val_ia]); console.log(data[0].id) const b = this.Test(this.id_memory[this.val_ia], data[0].id); console.log(b) if(b){ this.desserts[this.val_ia].wifi = 'connecté' console.log('connecté') }else{ this.desserts[this.val_ia].wifi = 'déconnecté' console.log('déconnecté') } this.id_memory[this.val_ia] = data[0].id }) .catch((error) =&gt; { console.log(error) }); }, Test(x, y) { const a = x !== y return a }, } } &lt;/script&gt; </code></pre> <p>Only in case I have no new data const b = false</p> <p>here is my console:</p> <p><a href="https://i.stack.imgur.com/HsWhU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HsWhU.png" alt="enter image description here" /></a></p> <p>I should have the disconnected status only it shows me the connected status</p> <p><a href="https://i.stack.imgur.com/bBA2E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bBA2E.png" alt="enter image description here" /></a></p> <p>There should be a logical explanation to it but I can't see it..</p>
[ { "answer_id": 74152981, "author": "Wings", "author_id": 6912349, "author_profile": "https://Stackoverflow.com/users/6912349", "pm_score": 0, "selected": false, "text": "{fetchedUsersData?.map((user: Users) => (\n <LinkToUser to={`/users/${user.id}`}>\n ...
2022/10/21
[ "https://Stackoverflow.com/questions/74152964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19623890/" ]
74,153,025
<p><code>os.date(&quot;!*t&quot;)</code> in lua return a table like this:</p> <pre><code>year a full year month 01-12 day 01-31 hour 00-23 min 00-59 sec 00-59 isdst a boolean, true if daylight saving </code></pre> <p>But we have some variable that not present in this table like timezone, start week etc... We can get them by <code>os.date(%z %p)</code>, but is there any way to get a more complete version of the above table with <code>os.date</code> or any other internal library?</p> <p>I want just run one time <code>os.date()</code> inside my code, and avoid running that for second time to get ‍‍‍‍<code>os.date(%z %p)</code> is there any way to get a complete table of all available tags?</p> <p>Base of <a href="https://www.lua.org/pil/22.1.html" rel="nofollow noreferrer">lua document</a> avilabel tag is</p> <pre><code>%a abbreviated weekday name (e.g., Wed) %A full weekday name (e.g., Wednesday) %b abbreviated month name (e.g., Sep) %B full month name (e.g., September) %c date and time (e.g., 09/16/98 23:48:10) %d day of the month (16) [01-31] %H hour, using a 24-hour clock (23) [00-23] %I hour, using a 12-hour clock (11) [01-12] %M minute (48) [00-59] %m month (09) [01-12] %p either &quot;am&quot; or &quot;pm&quot; (pm) %S second (10) [00-61] %w weekday (3) [0-6 = Sunday-Saturday] %x date (e.g., 09/16/98) %X time (e.g., 23:48:10) %Y full year (1998) %y two-digit year (98) [00-99] %% the character `%´ </code></pre>
[ { "answer_id": 74154187, "author": "marsgpl", "author_id": 5622901, "author_profile": "https://Stackoverflow.com/users/5622901", "pm_score": 2, "selected": true, "text": "struct tm" }, { "answer_id": 74158234, "author": "koyaanisqatsi", "author_id": 11740758, "author_...
2022/10/21
[ "https://Stackoverflow.com/questions/74153025", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3907606/" ]
74,153,027
<p>So I need to add different string variables to array and then split each of them by whitespace into array <code>splitted[]</code></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var books = new Array() var a = "Lorem Ipsum dolor sit amet" var b = "never gonna give you up" var c = "another string variable" books.push(a); books.push(b); books.push(c) var splitted = [] for (let i = 0; i &lt; books.length; i++) { splitted = books[i].split(/[\s]+/) } console.log(splitted)</code></pre> </div> </div> </p> <p>Expected result: <code>(13)['Lorem', 'Ipsum', ... 'string', 'variable']</code><br> Actual result: <code>(3)['another', 'string', 'variable']</code><br> So only the last variable <code>c</code> is splitted, while all three vars are in <code>books[]</code>.</p>
[ { "answer_id": 74153059, "author": "flyingfox", "author_id": 3176419, "author_profile": "https://Stackoverflow.com/users/3176419", "pm_score": 2, "selected": false, "text": "splitted = books[i].split(/[\\s]+/)\n" }, { "answer_id": 74153565, "author": "Bqardi", "author_id"...
2022/10/21
[ "https://Stackoverflow.com/questions/74153027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,153,039
<p>I have a <code>.net mvc core 6</code> application with the following area on it <code>Dashboard</code></p> <p>I added the following configuration to <code>Configure</code> in <code>startup</code></p> <pre><code> public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler(&quot;/Home/Error&quot;); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints =&gt; { endpoints.MapDefaultControllerRoute(); endpoints.MapAreaControllerRoute( name: &quot;Dashboard&quot;, areaName: &quot;Dashboard&quot;, pattern: &quot;D/{controller=Home}/{action=Index}/{id?}&quot; ); // other areas configurations goes here endpoints.MapControllerRoute( name: &quot;areas&quot;, pattern: &quot;{area:exists}/{controller}/{action}/{id?}&quot; ); }); } </code></pre> <p>the above code works fine to identify each area route and it will work like this <code>http://localhost/d/dashboard</code> will redirect to <code>Dashboard</code> area the issue is on how to use this with the normal routing of the mvc like</p> <pre><code> Url.Action(&quot;Index&quot;, &quot;Dashboard&quot;, new { area = &quot;d&quot; }) </code></pre> <p>this will generate the following link <code>https://localhost/Dashboard?area=d</code> not <code>http://localhost/d/dashboard</code> even when changing the code to be like this</p> <pre><code> Url.Action(&quot;Index&quot;, &quot;Dashboard&quot;, new { area = &quot;Dashboard&quot; }) </code></pre> <p>this will generate the following link <code>https://localhost/Dashboard?area=Dashboard</code> not <code>http://localhost/d/dashboard</code></p> <p>Any help with this issue?</p>
[ { "answer_id": 74176813, "author": "Chen", "author_id": 18789859, "author_profile": "https://Stackoverflow.com/users/18789859", "pm_score": 1, "selected": false, "text": "endpoints.MapDefaultControllerRoute();" }, { "answer_id": 74187586, "author": "Mohamed Salah", "autho...
2022/10/21
[ "https://Stackoverflow.com/questions/74153039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1026611/" ]
74,153,044
<pre><code>from datetime import datetime from datetime import timedelta #this is the start day day = input() #this is number of days input num=int(input()) #this is the start date of the shipment temp = input() #this is the date format the string into a day using the strptime object start_day = datetime.strptime(day, '%A') #this line will format the string input into a date format1 = datetime.strptime(temp, '%d-%m-%Y') #this line will add number input onto the date arrival = format1 + timedelta(days=num) for i in range(num): a = arrival - timedelta(days=i) if a.weekday() &lt;5 : print(a.strftime('%d-%m-%Y')) </code></pre> <p>The above code gives me three weekday dates but I am expecting four.</p> <p>This is my output:</p> <pre class="lang-none prettyprint-override"><code>05-03-2019 04-03-2019 01-03-2019 </code></pre> <p>but I need this:</p> <pre class="lang-none prettyprint-override"><code>01-03-2019 04-03-2019 05-03-2019 06-03-2019 </code></pre> <p>All dates starting with the oldest first e.g. ascending order.</p> <p>Here is the assignment I have:</p> <blockquote> <p>Radan Logistics is a mid sized Shipping Company known for its Customer oriented delivery services. The Company Management intended to place an information kiosk in their Head Office which would help their Customers to fetch all the desired information with regards to their shipment. One such vital information that Customers would prefer to know is the details of the working days of the Company which would help them track their shipments.</p> <p>Help the Management write a program for the kiosk, that when given the start day, number of days 'n' and the start date, will output the dates of the 'n' business days (excluding Saturday and Sunday).</p> </blockquote> <p>Input Format:</p> <ul> <li>The first line of input is a String, the start day.</li> <li>The second line of the input is the number of days.</li> <li>Third line is a string that correponds to the start date of the shipment.</li> </ul> <p>Output Format:</p> <p>Output is list of dates of <em>n</em> working days separated by new line.</p> <p>Sample Input 1:</p> <pre class="lang-none prettyprint-override"><code>Monday 7 03-12-2007 </code></pre> <p>Sample Output 1:</p> <pre class="lang-none prettyprint-override"><code>04-12-2007 05-12-2007 06-12-2007 07-12-2007 10-12-2007 11-12-2007 </code></pre> <p>Sample Input 2:</p> <pre class="lang-none prettyprint-override"><code>Thursday 10 25-02-2012 </code></pre> <p>Sample Output 2:</p> <pre class="lang-none prettyprint-override"><code>26-02-2012 29-02-2012 01-03-2012 02-03-2012 03-03-2012 04-03-2012 07-03-2012 08-03-2012 09-03-2012 </code></pre>
[ { "answer_id": 74153169, "author": "Kyle Alm", "author_id": 9237842, "author_profile": "https://Stackoverflow.com/users/9237842", "pm_score": 2, "selected": false, "text": "for i in reversed(range(num + 1)):\n a = arrival - timedelta(days=i)\n if a.weekday() <5 : \n p...
2022/10/21
[ "https://Stackoverflow.com/questions/74153044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20300531/" ]
74,153,057
<pre><code>def sort_dictionary(dict: dict) -&gt; dict: return {k: sorted(v) for k, v in dict.items()} def create_dictionary_with_hobbies(data: str) -&gt; dict: &quot;&quot;&quot;Create dictionary about hobbies and their hobbyists ie. {hobby1: [name1, name2, ...], hobby2: [...]}.&quot;&quot;&quot; result = {} for line in data.split('\n'): name, hobby = line.split(&quot;:&quot;) result.setdefault(hobby, []).append(name) result = sort_dictionary(result) return result if __name__ == '__main__': sample_data = &quot;&quot;&quot;Jack:crafting\nPeter:hiking\nWendy:gaming\nMonica:tennis\nChris:origami\nSophie:sport\nMonica:design\nCarmen:sport\nChris:sport\nMonica:skateboarding\nCarmen:cooking\nWendy:photography\nMonica:tennis\nCooper:yoga\nWendy:sport\nCooper:movies\nMonica:theatre\nCooper:yoga\nChris:gaming\nMolly:fishing\nJack:skateboarding\nWendy:fishing\nJack:drawing\nMonica:baking\nSophie:baking\nAlfred:driving\nAlfred:shopping\nAlfred:crafting\nJack:drawing\nCarmen:shopping\nCarmen:driving\nPeter:drawing\nCarmen:shopping\nWendy:fitness\nAlfred:travel\nJack:origami\nSophie:design\nJack:pets\nCarmen:dance\nAlfred:baking\nSophie:sport\nPeter:gaming\nJack:skateboarding\nCooper:football\nAlfred:sport\nCooper:fitness\nChris:yoga\nWendy:football\nMolly:design\nJack:hiking\nMonica:pets\nCarmen:photography\nJack:baking\nPeter:driving\nChris:driving\nCarmen:driving\nPeter:theatre\nMolly:hiking\nWendy:puzzles\nJack:crafting\nPeter:photography\nCarmen:theatre\nSophie:crafting\nCarmen:cooking\nAlfred:gaming\nPeter:theatre\nCooper:hiking\nChris:football\nChris:pets\nJack:football\nMonica:skateboarding\nChris:driving\nCarmen:pets\nCooper:gaming\nChris:hiking\nJack:cooking\nPeter:fishing\nJack:gaming\nPeter:origami\nCarmen:movies\nSophie:driving\nJack:sport\nCarmen:theatre\nWendy:shopping\nCarmen:pets\nWendy:gaming\nSophie:football\nWendy:theatre\nCarmen:football\nMolly:theatre\nPeter:theatre\nMonica:flowers\nMolly:skateboarding\nPeter:driving\nSophie:travel\nMonica:photography\nCooper:cooking\nJack:fitness\nPeter:cooking\nChris:gaming&quot;&quot;&quot; print(create_dictionary_with_hobbies(sample_data)) </code></pre> <p>Result:</p> <pre><code>{'crafting': ['Alfred', 'Jack', 'Jack', 'Sophie'], 'hiking': ['Chris', 'Cooper', 'Jack', 'Molly', 'Peter'], 'gaming': ['Alfred', 'Chris', 'Chris', 'Cooper', 'Jack', 'Peter', 'Wendy', 'Wendy'], 'tennis': ['Monica', 'Monica'], 'origami': ['Chris', 'Jack', 'Peter'], 'sport': ['Alfred', 'Carmen', 'Chris', 'Jack', 'Sophie', 'Sophie', 'Wendy'], 'design': ['Molly', 'Monica', 'Sophie'], 'skateboarding': ['Jack', 'Jack', 'Molly', 'Monica', 'Monica'], 'cooking': ['Carmen', 'Carmen', 'Cooper', 'Jack', 'Peter'], 'photography': ['Carmen', 'Monica', 'Peter', 'Wendy'], 'yoga': ['Chris', 'Cooper', 'Cooper'], 'movies': ['Carmen', 'Cooper'], 'theatre': ['Carmen', 'Carmen', 'Molly', 'Monica', 'Peter', 'Peter', 'Peter', 'Wendy'], 'fishing': ['Molly', 'Peter', 'Wendy'], 'drawing': ['Jack', 'Jack', 'Peter'], 'baking': ['Alfred', 'Jack', 'Monica', 'Sophie'], 'driving': ['Alfred', 'Carmen', 'Carmen', 'Chris', 'Chris', 'Peter', 'Peter', 'Sophie'], 'shopping': ['Alfred', 'Carmen', 'Carmen', 'Wendy'], 'fitness': ['Cooper', 'Jack', 'Wendy'], 'travel': ['Alfred', 'Sophie'], 'pets': ['Carmen', 'Carmen', 'Chris', 'Jack', 'Monica'], 'dance': ['Carmen'], 'football': ['Carmen', 'Chris', 'Cooper', 'Jack', 'Sophie', 'Wendy'], 'puzzles': ['Wendy'], 'flowers': ['Monica']} </code></pre> <p>Maybe you could suggest what function can add to remove duplicates. Let's say in the first crafting answer there are two Jacks, but there should be one. But the alphabetical order of names should also be preserved, like it now is. I understand that no one will write the code for me, but it would be nice to get an answer to this question.</p>
[ { "answer_id": 74153169, "author": "Kyle Alm", "author_id": 9237842, "author_profile": "https://Stackoverflow.com/users/9237842", "pm_score": 2, "selected": false, "text": "for i in reversed(range(num + 1)):\n a = arrival - timedelta(days=i)\n if a.weekday() <5 : \n p...
2022/10/21
[ "https://Stackoverflow.com/questions/74153057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20030803/" ]
74,153,098
<p>This is my existing django model</p> <pre class="lang-py prettyprint-override"><code>class Account(models.Model): env = CharField(max_length=10) </code></pre> <p>now I need to add <code>period</code> field to my model based on the value of the <code>env</code> field in model. I can get the <code>period</code> value based on the <code>env</code> from following dict in my <code>settings</code> file</p> <pre><code>mydict = { 'dev':1, 'prd':2 } </code></pre> <p>How do I add my period field to model?</p> <pre class="lang-py prettyprint-override"><code>period = Integerfield(default=setvalue from dict) </code></pre>
[ { "answer_id": 74153169, "author": "Kyle Alm", "author_id": 9237842, "author_profile": "https://Stackoverflow.com/users/9237842", "pm_score": 2, "selected": false, "text": "for i in reversed(range(num + 1)):\n a = arrival - timedelta(days=i)\n if a.weekday() <5 : \n p...
2022/10/21
[ "https://Stackoverflow.com/questions/74153098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9396756/" ]
74,153,109
<p>I am using the <code>Expand-Archive</code> command to unzip some .zip files. I want this process to generate a log and I am trying to use the parameter -PassThru.</p> <pre><code>Expand-Archive D:\Users\user1\Desktop\Zip\de23.zip -DestinationPath D:\Users\user1\Desktop\result -Force -PassThru </code></pre> <p>Result:</p> <blockquote> <p>Expand-Archive : A parameter cannot be found that matches parameter name 'PassThru'.</p> </blockquote> <p>Reference: <a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.archive/expand-archive?view=powershell-7.2" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.archive/expand-archive?view=powershell-7.2</a></p>
[ { "answer_id": 74153514, "author": "Mathias R. Jessen", "author_id": 712649, "author_profile": "https://Stackoverflow.com/users/712649", "pm_score": 2, "selected": false, "text": "-PassThru" }, { "answer_id": 74153718, "author": "zett42", "author_id": 7571258, "author...
2022/10/21
[ "https://Stackoverflow.com/questions/74153109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19957972/" ]
74,153,135
<blockquote> <p>Write a sql query that prints domain interest and number students who are interested in that domain.</p> <pre><code>+------+----------+----------+ | sno | sub1 | sub2 | +------+----------+----------+ | s1 | ds | networks | | s2 | os | ds | | s3 | ds | os | | s4 | networks | db | | s5 | os | networks | | s6 | db | ds | | s7 | networks | os | | s8 | db | os | +------+----------+----------+ </code></pre> <p>Expected output:</p> <pre><code>+----------+-------------+ | sub1 |Totalstudents| +----------+-------------+ | db | 3 | | ds | 4 | | networks | 4 | | ob | 5 | +----------+-------------+ </code></pre> </blockquote> <p>This is what he/she has tried:</p> <pre><code>select sub1, count(sub1) from student group by sub1; </code></pre> <p>then tried subquery as</p> <pre><code>select a.sub1 , count(a.sub1) ,count(b.sub1) from student a, student b where a.sub1=b.sub2 group by a.sub1, b.sub2; </code></pre>
[ { "answer_id": 74153378, "author": "Sash Sinha", "author_id": 6328256, "author_profile": "https://Stackoverflow.com/users/6328256", "pm_score": 0, "selected": false, "text": "UNION ALL" }, { "answer_id": 74155116, "author": "Swifty", "author_id": 20267366, "author_pro...
2022/10/21
[ "https://Stackoverflow.com/questions/74153135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20300665/" ]
74,153,149
<p>I am using Google_Nav_Bar and i didn't know how to put code on the page should i create a new file for everypage? and how to control it?</p> <p>google_nav_bar: ^5.0.6 here is my code in homepage <a href="https://imgur.com/NFeVPES" rel="nofollow noreferrer">enter link description here</a></p>
[ { "answer_id": 74153378, "author": "Sash Sinha", "author_id": 6328256, "author_profile": "https://Stackoverflow.com/users/6328256", "pm_score": 0, "selected": false, "text": "UNION ALL" }, { "answer_id": 74155116, "author": "Swifty", "author_id": 20267366, "author_pro...
2022/10/21
[ "https://Stackoverflow.com/questions/74153149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20167830/" ]
74,153,162
<p>My asp.net core web application has redirection applied on statup.cs as:</p> <pre><code>app.UseHttpsRedirection(); </code></pre> <p>The problem arises when I host it on kubernetes where this redirection does not happens. The app opens on both http and https url.</p> <p><strong>I am hosting the app on local kubernetes cluster on my pc having kali linus.</strong></p> <p>This is the ingress which i am using:</p> <pre><code>apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: first-ingress annotations: nginx.ingress.kubernetes.io/rewrite-target: / spec: tls: - secretName: ssl rules: - http: paths: - path: / pathType: Prefix backend: service: name: first-service port: number: 8080 </code></pre> <p>The ingress on opens 2 ports which are - 80, 443.</p> <p>How should the redirection be done in such a case?</p> <p>The deployment is:</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: first-dep labels: app: aspnet-core-app spec: replicas: 1 selector: matchLabels: component: web template: metadata: labels: component: web spec: containers: - name: csimpleweb image: simpleweb imagePullPolicy: Never ports: - containerPort: 80 </code></pre> <p>The Service is:</p> <pre><code>apiVersion: v1 kind: Service metadata: name: first-service spec: type: NodePort selector: component: web ports: - port: 8080 targetPort: 80 </code></pre> <p>So in summary I want to ask the following:</p> <ol> <li>How redirection works in k8s + ASP.NET Core. The redirection does not work in my case where I have applied the redirection on the app.</li> <li>Should the redirection be done on ingress if so how. In that case I think we have remove <strong>app.UseHttpsRedirection()</strong> from the app.</li> <li>What docker container ports, which the pods will host, we have to open and how?</li> </ol> <p>Thank you</p>
[ { "answer_id": 74153378, "author": "Sash Sinha", "author_id": 6328256, "author_profile": "https://Stackoverflow.com/users/6328256", "pm_score": 0, "selected": false, "text": "UNION ALL" }, { "answer_id": 74155116, "author": "Swifty", "author_id": 20267366, "author_pro...
2022/10/21
[ "https://Stackoverflow.com/questions/74153162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4356300/" ]
74,153,175
<p>See line 91 of code,</p> <p>array&lt;double,size1&gt; poundData; //PROBLEM HERE array declared</p> <p>Global constant size1 can be used to represent integer value 5 everywhere else in code but returns an error if used for declaring the array length.</p> <p>If size1 is replaced with 5 on this line, code runs perfectly, but need size1 to be used for flexibility. Cannot see why it won't allow size1 to be used, but am very much a beginner so may be something very basic i'm missing.</p> <pre><code>#include&lt;iostream&gt; #include &lt;cstdlib&gt; #include&lt;time.h&gt; #include &lt;array&gt; using namespace std; const int size1 = 5; // declare global constant double randValInRange (double min,double max,int size1,int i); //Declare functions array&lt;double,size1&gt; fillArray(double min,double max,int size1); int main (int argc, char *argv[]) { if (argc &gt;= 3) //Determine if there are at least 3 command line arguments { double min; double max; double input1; double input2; input1 = atof (argv[1]); input2 = atof (argv[2]); if (input1 &lt;= 0.0||input2 &lt;= 0.0) { // Determine that both inputs are positive cout &lt;&lt; &quot; \n min and max must both be positive values\n&quot;; return EXIT_SUCCESS; } if (input1 &lt; input2){ min = input1; max = input2; }else{ min = input2; max = input1; } cout &lt;&lt; min &lt;&lt; &quot; lbs is min \n&quot;; cout &lt;&lt; max &lt;&lt; &quot; lbs is max \n\n&quot;; srand(static_cast&lt;unsigned int&gt;(time(nullptr))); // std:: array&lt;double,size1&gt; poundData; poundData = fillArray(min,max,size1); for (int i=0;i&lt;size1;i++) { cout&lt;&lt;poundData[i]&lt;&lt;&quot; &quot;; cout&lt;&lt;&quot;\n&quot;; } } else { cout &lt;&lt; &quot;Incorrect number of arguments - please call as follows: &quot; &lt;&lt;argv[0] &lt;&lt; &quot; min max\n&quot;; } return 0; } double randValInRange (double min,double max,int size1,int i ){ double scale = 100000.0; double range = max - min; double rangeScaled = range*scale; int rangeScaledInt = (static_cast&lt;int&gt;(rangeScaled)); double minScaled = min * scale; int minScaledInt = (static_cast&lt;int&gt;(minScaled)); int randIntScaled = rand()%(rangeScaledInt); int outputValueScaled = minScaledInt + randIntScaled; double outputValueScaledD = static_cast&lt;double&gt;(outputValueScaled); double outputValue = outputValueScaledD/scale; return outputValue; } array&lt;double,size1&gt; fillArray (double min,double max,int size1) //function with return type array { array&lt;double,size1&gt; poundData; //**PROBLEM HERE** array declared for (int i=0;i&lt;size1;i++) { double outputValue = randValInRange (min,max,size1,i); poundData[i] = outputValue; } return poundData; } </code></pre>
[ { "answer_id": 74153260, "author": "jls28", "author_id": 17043790, "author_profile": "https://Stackoverflow.com/users/17043790", "pm_score": 1, "selected": false, "text": "array<double,size1> fillArray (double min,double max,int size1/*!!!*/)\n{ \n// here size1 ...
2022/10/21
[ "https://Stackoverflow.com/questions/74153175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20300660/" ]
74,153,216
<p>company.service.ts:`</p> <pre><code>async get(id: FindOneOptions&lt;Company&gt;): Promise&lt;Company | null&gt;{ console.log(id) return await this.companyRespository.findOne(id); } </code></pre> <p>company.controller.ts:</p> <pre><code>@Get(':id') findOneCompany(@Param('id') id: FindOneOptions&lt;Company&gt;){ return this.companyService.get(id); } </code></pre> <p>I have written the following code but whenever I try to get by FindOne my console says that &quot;You must provide selection conditions in order to find a single row.&quot;. I tried all possible solution on the web including adding curly braces and also using other FindOptions nothing seems to make this error go away. My API platform shows an internal server error.</p>
[ { "answer_id": 74153260, "author": "jls28", "author_id": 17043790, "author_profile": "https://Stackoverflow.com/users/17043790", "pm_score": 1, "selected": false, "text": "array<double,size1> fillArray (double min,double max,int size1/*!!!*/)\n{ \n// here size1 ...
2022/10/21
[ "https://Stackoverflow.com/questions/74153216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20300737/" ]
74,153,240
<p>I study API OLX <a href="https://developer.olx.ua/api/doc" rel="nofollow noreferrer">https://developer.olx.ua/api/doc</a>. I'm trying to implement authorization and getting a token in Python. Stuck at the moment of receiving the Authorization Code. I am a beginner, I have never worked with this type of authorization.</p> <p>Here is my piece of code</p> <pre><code>client_id = 'xxxx' client_secret = 'xxxx' authorization_base_url = 'https://www.olx.ua/oauth/authorize' token_url = 'https://www.olx.ua/api/open/oauth/token' redirect_uri = 'http://www.example.com/' # Should match Site URL scope = 'v2 write read' grant_type='authorization_code' import hashlib import requests from authlib.integrations.requests_client import OAuth2Session olx = OAuth2Session(client_id, client_secret, scope=scope,redirect_uri=redirect_uri) authorization_uri, state = olx.create_authorization_url(authorization_base_url) user_agent_val = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36' payload={'username': 'example@gmail.com','password': hashlib.md5(b&quot;xxxxx&quot;)} headers = {'User-Agent':user_agent_val} response = requests.request(&quot;GET&quot;, authorization_uri, headers=headers, data=payload) print(response.url) </code></pre> <p>I expect to receive in a variable response a string of the redirect_url/code&amp;state, but I get string authorization_uri If I enter line authorization_uri into the browser after authorization, I am redirected to the required redirect_url/code&amp;state What am I doing wrong?</p>
[ { "answer_id": 74153260, "author": "jls28", "author_id": 17043790, "author_profile": "https://Stackoverflow.com/users/17043790", "pm_score": 1, "selected": false, "text": "array<double,size1> fillArray (double min,double max,int size1/*!!!*/)\n{ \n// here size1 ...
2022/10/21
[ "https://Stackoverflow.com/questions/74153240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20300453/" ]
74,153,250
<p>I have just started using Spring boot and I am using the default repository api to retrieve db data as json. I have added a <code>@ManyToOne</code> relation to my Song and Artist Entity.</p> <p>But now i am not getting the Artist object in my json response from the server and its not really clear to me, how I can include it without missing out on the pagination functions from the PagingAndSorting repository.</p> <p>I am using the spring-data-rest-jpa.</p> <p>My response now looks like:</p> <pre><code> &quot;_embedded&quot;: { &quot;songs&quot;: [ { &quot;id&quot;: 1, &quot;title&quot;: &quot;SongTitle&quot;, &quot;genre&quot;: &quot;Rap&quot;, &quot;length&quot;: 500, &quot;_links&quot;: { &quot;self&quot;: { &quot;href&quot;: &quot;http://localhost:8080/api/songs/1&quot; }, &quot;song&quot;: { &quot;href&quot;: &quot;http://localhost:8080/api/songs/1&quot; }, &quot;artist&quot;: { &quot;href&quot;: &quot;http://localhost:8080/api/songs/1/artist&quot; } } } ] }, &quot;_links&quot;: { &quot;first&quot;: { &quot;href&quot;: &quot;http://localhost:8080/api/songs?page=0&amp;size=1&quot; }, &quot;self&quot;: { &quot;href&quot;: &quot;http://localhost:8080/api/songs?size=1&quot; }, &quot;next&quot;: { &quot;href&quot;: &quot;http://localhost:8080/api/songs?page=1&amp;size=1&quot; }, &quot;last&quot;: { &quot;href&quot;: &quot;http://localhost:8080/api/songs?page=19&amp;size=1&quot; }, &quot;profile&quot;: { &quot;href&quot;: &quot;http://localhost:8080/api/profile/songs&quot; } }, &quot;page&quot;: { &quot;size&quot;: 1, &quot;totalElements&quot;: 20, &quot;totalPages&quot;: 20, &quot;number&quot;: 0 } } </code></pre> <p>But I want it rather to be like this:</p> <pre><code>&quot;_embedded&quot;: { &quot;songs&quot;: [ { &quot;id&quot;: 1, &quot;title&quot;: &quot;SongTitle&quot;, &quot;genre&quot;: &quot;Rap&quot;, &quot;length&quot;: 500, &quot;artist&quot;: { &quot;id&quot;: 1, &quot;name&quot;: &quot;Artistname&quot; } &quot;_links&quot;: { &quot;self&quot;: { &quot;href&quot;: &quot;http://localhost:8080/api/songs/1&quot; }, &quot;song&quot;: { &quot;href&quot;: &quot;http://localhost:8080/api/songs/1&quot; }, &quot;artist&quot;: { &quot;href&quot;: &quot;http://localhost:8080/api/songs/1/artist&quot; } } } ] }, &quot;_links&quot;: { &quot;first&quot;: { &quot;href&quot;: &quot;http://localhost:8080/api/songs?page=0&amp;size=1&quot; }, &quot;self&quot;: { &quot;href&quot;: &quot;http://localhost:8080/api/songs?size=1&quot; }, &quot;next&quot;: { &quot;href&quot;: &quot;http://localhost:8080/api/songs?page=1&amp;size=1&quot; }, &quot;last&quot;: { &quot;href&quot;: &quot;http://localhost:8080/api/songs?page=19&amp;size=1&quot; }, &quot;profile&quot;: { &quot;href&quot;: &quot;http://localhost:8080/api/profile/songs&quot; } }, &quot;page&quot;: { &quot;size&quot;: 1, &quot;totalElements&quot;: 20, &quot;totalPages&quot;: 20, &quot;number&quot;: 0 } } </code></pre> <p>Song.java</p> <pre class="lang-java prettyprint-override"><code>@Getter @Setter @Entity @Table(name = &quot;song&quot;) public class Song { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = &quot;id&quot;, nullable = false, unique = true) private Long id; @NotNull @NotBlank(message = &quot;The song has to have a title&quot;) private String title; @NotNull @NotBlank(message = &quot;The song has to have a genre&quot;) private String genre; @NotNull @Min(value = 1, message = &quot;The song has to have a song length in seconds&quot;) private int length; @ManyToOne(cascade = CascadeType.ALL) @JoinColumn(name = &quot;artist_id&quot;, referencedColumnName = &quot;id&quot;) private Artist artist; /* @Version private long version;*/ public Song() { } public Song(String title, Artist artist, String genre, int length) { this.title = title; this.artist = artist; this.genre = genre; this.length = length; } public void setArtist(Artist artist) { this.artist = artist; } public Artist getArtist() { return artist; } } </code></pre> <p>Artist.java</p> <pre class="lang-java prettyprint-override"><code>@Getter @Setter @Entity @Table(name = &quot;artist&quot;) public class Artist { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = &quot;id&quot;, nullable = false) private Long id; @NotNull @NotBlank(message = &quot;The artist has to have a name&quot;) private String name; @JsonIgnore @OneToMany(mappedBy = &quot;artist&quot;) private List&lt;Song&gt; songs; public Artist() { } public Artist(String name) { this.name = name; } </code></pre> <p>For the sake of testing I wrote a method in my SongController:</p> <pre class="lang-java prettyprint-override"><code>@GetMapping List&lt;Song&gt; getSongs() { return songRepository.findAll(); } </code></pre> <p>The result includes the Artist object, but won't have any pagination to it. How could I include it?</p> <p>Json Result:</p> <pre><code>[ { &quot;id&quot;: 1, &quot;title&quot;: &quot;SongTitle&quot;, &quot;genre&quot;: &quot;Rap&quot;, &quot;length&quot;: 500, &quot;artist&quot;: { &quot;id&quot;: 1, &quot;name&quot;: &quot;ArtistName&quot; } } ] </code></pre>
[ { "answer_id": 74153482, "author": "y434y", "author_id": 1068222, "author_profile": "https://Stackoverflow.com/users/1068222", "pm_score": 0, "selected": false, "text": "public class Artist {\n public Long id;\n public String name;\n\n public List<Song> songs;\n}\n\npublic class...
2022/10/21
[ "https://Stackoverflow.com/questions/74153250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17644712/" ]
74,153,263
<p>I am trying to calculate distance of points within a country to country boundary</p> <pre><code>library(terra) library(geodata) library(ggplot2) library(geodata) # get a shapefile of a country gabon &lt;- geodata::gadm('GAB', level = 0, path = getwd()) canvas &lt;- terra::rast(xmin = ext(gabon)[1], xmax = ext(gabon)[2], ymin = ext(gabon)[3], ymax = ext(gabon)[4], resolution = 0.08, crs = crs(gabon), vals = 0) pts &lt;- as.points(canvas) pts &lt;- terra::crop(pts, gabon) # extract the points in the limits of Gabon plot(pts) plot(gabon, border = &quot;blue&quot;, add = T) </code></pre> <p><a href="https://i.stack.imgur.com/UasAM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UasAM.png" alt="enter image description here" /></a></p> <p>I want to calculate shortest distance of each point in <code>pts</code> to the boundary of the country</p> <pre><code>gabon_lines &lt;- terra::as.lines(gabon) # calculation of the distance between the boundary and points dis_pts &lt;- terra::distance(pts, gabon_lines, pairwise = FALSE, unit=&quot;km&quot;) range(dis_pts) # 0.00000046 1.63706213. seems quite low dat &lt;- data.frame(dist = as.vector(dis_pts), crds(pts)) col_dist &lt;- brewer.pal(11, &quot;RdGy&quot;) ggplot(dat, aes(x, y, fill = dist)) + #variables geom_tile() + #geometry scale_fill_gradientn(colours = rev(col_dist))+ # colors for plotting the distance labs(fill = &quot;Distance (km)&quot;)+ #legend name theme_void()+ #map theme theme(legend.position = &quot;bottom&quot;) #legend position </code></pre> <p><a href="https://i.stack.imgur.com/QEmz6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QEmz6.png" alt="enter image description here" /></a></p> <p>I think the range of distance I am getting is very low since Gabon is quite big so I was expecting distance of points in the middle to be larger. Is there anything I am doing wrong here?</p>
[ { "answer_id": 74153482, "author": "y434y", "author_id": 1068222, "author_profile": "https://Stackoverflow.com/users/1068222", "pm_score": 0, "selected": false, "text": "public class Artist {\n public Long id;\n public String name;\n\n public List<Song> songs;\n}\n\npublic class...
2022/10/21
[ "https://Stackoverflow.com/questions/74153263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3227302/" ]
74,153,314
<p>I am trying to enter data for each row into a SQL Database table but keep getting this error</p> <pre><code>'Conversion from string &quot;VisitorID&quot; to type 'Integer' is not valid.' </code></pre> <p>This is the code i have got</p> <pre><code>Dim url As String url = bcintegration.GetInfoForIntegration(DropDownList1.SelectedValue).Rows(0)(1) ServicePointManager.Expect100Continue = True ServicePointManager.SecurityProtocol = CType(3072, SecurityProtocolType) Dim json As String = (New WebClient).DownloadString(url) IntegrationGridView.DataSource = JsonConvert.DeserializeObject(Of DataTable)(json) IntegrationGridView.DataBind() For Each row As GridViewRow In IntegrationGridView.Rows If DropDownList1.SelectedValue = &quot;SignInSystemEntityIntegration&quot; Then THIS IS THE LINE WITH THE ERROR - bcintegration.SubmitDataForSignInSystemEntity(CInt(row.Cells(&quot;VisitorID&quot;).Text), Nothing, Nothing, Nothing, Nothing, Nothing, True, False, Nothing, Nothing, Nothing, 1) Else End If Next </code></pre> <p>The 'Nothing' statement is just for testing - that will have data later on.</p> <p>Please Help</p> <p>Thanks</p>
[ { "answer_id": 74155046, "author": "jmcilhinney", "author_id": 584183, "author_profile": "https://Stackoverflow.com/users/584183", "pm_score": 2, "selected": false, "text": "Item" }, { "answer_id": 74231974, "author": "Hao Yu-MSFT", "author_id": 19818478, "author_prof...
2022/10/21
[ "https://Stackoverflow.com/questions/74153314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19984223/" ]
74,153,330
<p>The code below works, but I'm getting the following warning by PyCharm:</p> <blockquote> <p>Cannot find reference <code>__annotations__</code> in '(...) -&gt; Any'.</p> </blockquote> <p>I guess it's because I'm using <code>Callable</code>. I didn't find something like <code>Dataclass</code>. Which type should I use instead?</p> <pre><code>from __future__ import annotations from dataclasses import dataclass from typing import Callable @dataclass class Fruit: color: str taste: str def get_cls() -&gt; Callable: return Fruit attrs = get_cls().__annotations__ # &lt;- IDE warning print(attrs) </code></pre>
[ { "answer_id": 74153466, "author": "2e0byo", "author_id": 15452601, "author_profile": "https://Stackoverflow.com/users/15452601", "pm_score": 3, "selected": true, "text": "from dataclasses import dataclass\n\n@dataclass\nclass Fruit:\n x: str\n\ndef get_cls() -> type[Fruit]:\n retu...
2022/10/21
[ "https://Stackoverflow.com/questions/74153330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1792858/" ]
74,153,334
<p>I want to construct a very basic shortcode solution in a simple non-WordPress website I am maintaining, to allow users to enter content that will be pulled from a database and rendered to screen, allowing them to create a href buttons.</p> <p>I've seen various classes for this but want to do this in just a line or two of code if possible.</p> <p>Only they will enter via a shortcode with this format:</p> <p>[BUTTON link=&quot;www.test.com&quot; label=&quot;Click here&quot;]</p> <p>So far I have this which doesn't extract the attributes properly:</p> <pre><code>$copy=preg_replace('/\[(BUTTON )(.*?)\]/', '&lt;a href=&quot;$2&quot;&gt;$1&lt;/a&gt;', $copy); </code></pre> <p>Can anyone advise?</p>
[ { "answer_id": 74155149, "author": "mickmackusa", "author_id": 2943403, "author_profile": "https://Stackoverflow.com/users/2943403", "pm_score": 3, "selected": true, "text": "echo preg_replace(\n '/\\[button link=\"([^\"]+)\" label=\"([^\"]+)\"]/i',\n '<a href=\"$1\">$2</...
2022/10/21
[ "https://Stackoverflow.com/questions/74153334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1022861/" ]
74,153,337
<p>For my website, I am trying to embed stackoverflow.com and google.com, but it isn't working. So I started to work with PHP, but that didn't work. Does PHP work in html, or is it because I am using chromebook? Please help.</p> <pre><code>&lt;iframe src=&quot;https://google.com&quot; width=&quot;925&quot; height=&quot;2400&quot; frameborder=&quot;0&quot; &gt;&lt;/iframe&gt;&lt;httpProtocol&gt; &lt;customHeaders&gt; &lt;add name=&quot;X-Frame-Options&quot; value=&quot;*&quot; /&gt; &lt;/customHeaders&gt; &lt;/httpProtocol&gt;&lt;LocationMatch &quot;/your_relative_path&quot;&gt; ProxyPass absolute_path_of_your_application/your_relative_path ProxyPassReverse absolute_path_of_your_application/your_relative_path &lt;/LocationMatch&gt; </code></pre>
[ { "answer_id": 74153971, "author": "ranjanistic", "author_id": 10624674, "author_profile": "https://Stackoverflow.com/users/10624674", "pm_score": 1, "selected": false, "text": "X-Frame-Options" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74153337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19815296/" ]
74,153,344
<p>I want to export the <code>&lt;a&gt;</code> tag or link inside a cell in DataTables using <code>pdfhtml5</code>.</p> <p>As of now the link is showing as plain text. How can I print it including its format?</p>
[ { "answer_id": 74153971, "author": "ranjanistic", "author_id": 10624674, "author_profile": "https://Stackoverflow.com/users/10624674", "pm_score": 1, "selected": false, "text": "X-Frame-Options" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74153344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20300734/" ]
74,153,360
<p>I'm working on a shortcode to display a custom post type, which mostly works. I don't control the feed this data is coming from, hence the need to split up the title based on delimiters. The problem I'm experiencing is that the variables first, second, third, and fourth can be null, and I don't know how to account for this in this context.</p> <pre><code>function display_custom_post_type() { // ... irrelevant code ... $title = (get_the_title ()); $str = preg_split('(\||\[|\]|=)', $title,-1, PREG_SPLIT_NO_EMPTY); print_r($title); $first = $str[0]; $second = $str[1]; $third = $str[2]; $fourth = $str[3]; $string .= '&lt;h3 class=&quot;test-parl-title&quot;&gt;&lt;div&gt;' . $first . '&lt;/div&gt;&lt;/h3&gt;'; $string .= '&lt;h5&gt;' . $second . ' ' . $third . ' ' . $fourth . '&lt;/h5&gt;'; // ... irrelevant code ... return $string; } </code></pre>
[ { "answer_id": 74153418, "author": "Abdel Rahman Yosry", "author_id": 16260445, "author_profile": "https://Stackoverflow.com/users/16260445", "pm_score": 1, "selected": false, "text": "foreach($_POST as $key => $value){\n if($value === \"\"){\n $_POST[$key] = null;\n}\n}\n" }, ...
2022/10/21
[ "https://Stackoverflow.com/questions/74153360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/116479/" ]
74,153,369
<p>this is more so a question asking about how to approach a problem vs me posting code and asking where the error is.</p> <p>But I am building a paging system in flutter (to work on both android and ios). As a result, I am using custom sounds in my application (so that I can have sounds stronger than the default OS sound). Because this sounds are naturally louder, I want to give the user the option to control the sound level of the notification (from 0 to 100%). I cannot seem to find any resources that speak on this, but I do know it is possible because I have apps on my phone that allow that (amazon pager app for instance).</p> <p><strong>Is there a way to allow a user control the volume level of a notification through the app that was built in flutter?</strong> If it's possible, could i get pointed to a tutorial or article or even sample code?</p>
[ { "answer_id": 74320573, "author": "Henrique Guimarães", "author_id": 12642729, "author_profile": "https://Stackoverflow.com/users/12642729", "pm_score": 0, "selected": false, "text": " late AudioManager audioManager;\n dynamic maxVol,\n currentVol; // Value will be int type on An...
2022/10/21
[ "https://Stackoverflow.com/questions/74153369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18363550/" ]
74,153,370
<p>I'm trying to add pthreads extension on PHP 8.1 TS and it doesn't seem to work, It's sayin that it is not installed while in fact it is.</p> <pre><code>PHP -v PHP 8.1.10 (cli) (built: Aug 30 2022 18:05:49) (ZTS Visual C++ 2019 x64) Copyright (c) The PHP Group Zend Engine v4.1.10, Copyright (c) Zend Technologies with Xdebug v3.1.5, Copyright (c) 2002-2022, by Derick Rethans </code></pre> <p>Here are the steps I used to install it -&gt;</p> <ol> <li>Get the latest release from here -&gt; <a href="https://windows.php.net/downloads/pecl/releases/pthreads/" rel="nofollow noreferrer">https://windows.php.net/downloads/pecl/releases/pthreads/</a></li> <li>Extract php_pthreads.dll to /php/ext</li> <li>Add extension=pthreads to php.ini</li> <li>Extract pthreadVC2 in to /php</li> </ol> <p>And when I try to install Laravel Horizon this is what I get -&gt;</p> <pre><code>Root composer.json requires PHP extension ext-pthreads * but it is missing from your system. Install or enable PHP's pthreads extension. </code></pre>
[ { "answer_id": 74153606, "author": "Abdel Rahman Yosry", "author_id": 16260445, "author_profile": "https://Stackoverflow.com/users/16260445", "pm_score": 0, "selected": false, "text": "phpinfo();" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74153370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14156743/" ]
74,153,374
<p>I have a dataframe like so:</p> <pre><code>id year month val 1 2020 1 50 1 2020 7 80 1 2021 1 40 1 2021 7 70 . . </code></pre> <p>Now, I want to index all the values using Jan 2020 as index year for each id. Essentially group by id, then divide val with val at Jan 2020 * 100. So the final dataframe would look something like this:</p> <pre><code>id year month val 1 2020 1 100 1 2020 7 160 1 2021 1 80 1 2021 7 140 . . </code></pre> <p>This is what I tried till now:</p> <pre><code>df %&gt;% group_by(id) %&gt;% mutate(val = 100*val/[val at Jan 2020]) </code></pre> <p>I can separately get val at Jan 2020 like so:</p> <pre><code>df %&gt;% filter(year==2020, month==1) %&gt;% select(val) </code></pre> <p>But it doesn't work together:</p> <pre><code>df %&gt;% group_by(id) %&gt;% mutate(val = 100*val/(df %&gt;% filter(year==2020, month==1) %&gt;% select(val))) </code></pre> <p>The above throws error</p>
[ { "answer_id": 74153485, "author": "user2974951", "author_id": 2974951, "author_profile": "https://Stackoverflow.com/users/2974951", "pm_score": 2, "selected": false, "text": "do.call(\n rbind,\n lapply(\n split(df,df$id),\n function(x){\n cbind(\n subset(x,select=-c(...
2022/10/21
[ "https://Stackoverflow.com/questions/74153374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5181947/" ]
74,153,407
<p>I'm getting stuck on this TS error created at build time. Does anyone has any suggestions?</p> <p>TypeError: Cannot destructure property 'site' of '(intermediate value)' as it is undefined.</p> <pre><code>export default function Project({ data, preview, }: { data: any preview: any }) { const { site, page } = data?.post return ( &lt;Layout site={site} page={page}&gt; // Stuff &lt;/Layout&gt; ) } export async function getStaticProps({ params, preview = false }) { const { post, morePosts } = await getClient(preview).fetch(projectQuery, { slug: params.slug, }) return { props: { preview, data: { post, morePosts: overlayDrafts(morePosts), }, }, } } export async function getStaticPaths() { const paths = await sanityClient.fetch(projectSlugsQuery) return { paths: paths.map((slug) =&gt; ({ params: { slug } })), fallback: true, } } </code></pre>
[ { "answer_id": 74153425, "author": "kind user", "author_id": 6695924, "author_profile": "https://Stackoverflow.com/users/6695924", "pm_score": 2, "selected": false, "text": "data?.post" }, { "answer_id": 74153434, "author": "T.J. Crowder", "author_id": 157247, "author...
2022/10/21
[ "https://Stackoverflow.com/questions/74153407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11645609/" ]
74,153,430
<p>I have a <code>v-data-table</code> that has an alphanumeric ID with JSON key name aid (ie, AZ-0001). I also have a field in the JSON array called id which is basically just the numeric version (ie, 0001). When I sort the datatable it always puts the A's first and is not really numerically sorting which is what I want so I created a v-slot template to adjust what is displayed so that ID is the item slot and AID is whats actually displayed in the <code>v-slot</code> template. However, even doing this when pressing the sort icon for ID column it still sorts alphanumerically on what is actually being displayed (AID) so A's first rather than numerically just going by id which is the actual value for that column. I have another column similar to this that displays the date as Calendar year or Fiscal Year (ie, CY2022 and FY2022) so I run into a similar issue with this alphanumberic sorting doing alphabetically. So the simple example I show below I am hoping to use it for multiple fields. I plan to use the solution to this problem on another column I am running into a similar issue that I did not include in this example. My code is as follows:</p> <pre class="lang-html prettyprint-override"><code>&lt;v-data-table :headers=&quot;headerset&quot; :items=&quot;filteredData&quot; :search=&quot;searchTable&quot; height=&quot;inherit&quot; :loading=&quot;loading&quot; loading-text=&quot;Loading... Please wait&quot; style=&quot;cursor: pointer&quot; &gt; &lt;template v-slot:item.id=&quot;{ item }&quot;&gt; {{ item.aid }} &lt;/template&gt; &lt;/v-data-table&gt; </code></pre>
[ { "answer_id": 74153425, "author": "kind user", "author_id": 6695924, "author_profile": "https://Stackoverflow.com/users/6695924", "pm_score": 2, "selected": false, "text": "data?.post" }, { "answer_id": 74153434, "author": "T.J. Crowder", "author_id": 157247, "author...
2022/10/21
[ "https://Stackoverflow.com/questions/74153430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5021945/" ]
74,153,494
<p>Im developing a script in awk to convert a tex document into html, according to my preferences.</p> <pre><code>#!/bin/awk -f BEGIN { FS=&quot;\n&quot;; print &quot;&lt;html&gt;&lt;body&gt;&quot; } # Function to print a row with one argument to handle either a 'th' tag or 'td' tag function printRow(tag) { for(i=1; i&lt;=NF; i++) print &quot;&lt;&quot;tag&quot;&gt;&quot;$i&quot;&lt;/&quot;tag&quot;&gt;&quot;; } NR&gt;1 { [conditions] printRow(&quot;p&quot;) } END { print &quot;&lt;/body&gt;&lt;/html&gt;&quot; } </code></pre> <p>Its in a very young stage of development, as seen.</p> <pre><code>\documentclass[a4paper, 11pt, titlepage]{article} \usepackage{fancyhdr} \usepackage{graphicx} \usepackage{imakeidx} [...] \begin{document} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla placerat lectus sit amet augue facilisis, eget viverra sem pellentesque. Nulla vehicula metus risus, vel condimentum nunc dignissim eget. Vivamus quis sagittis tellus, eget ullamcorper libero. Nulla vitae fringilla nunc. Vivamus id suscipit mi. Phasellus porta lacinia dolor, at congue eros rhoncus vitae. Donec vel condimentum sapien. Curabitur est massa, finibus vel iaculis id, dignissim nec nisl. Sed non justo orci. Morbi quis orci efficitur sem porttitor pulvinar. Duis consectetur rhoncus posuere. Duis cursus neque semper lectus fermentum rhoncus. \end{document} </code></pre> <p>What I want, is that the script only interprets the lines that are between <code>\begin{document}</code> and <code>\end{document}</code>, since before they are imports of libraries, variables, etc; which at the moment do not interest me.</p> <p>How do I make it so that it only processes the text within that pattern?</p>
[ { "answer_id": 74153786, "author": "Daweo", "author_id": 10785975, "author_profile": "https://Stackoverflow.com/users/10785975", "pm_score": 3, "selected": true, "text": "AWK" }, { "answer_id": 74153879, "author": "dawg", "author_id": 298607, "author_profile": "https:...
2022/10/21
[ "https://Stackoverflow.com/questions/74153494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12074079/" ]
74,153,499
<p>I have 2 queries.</p> <p>For <code>table1</code>,</p> <pre><code>SELECT codesTable.code_id,COUNT(*) FROM table1,codesTable WHERE table1.codeid=CodeTable.code_id AND table1.type_no IN (1,2,3,4,5,6,7,8,9,10) AND table1.recoverd_value IN (0,1) GROUP BY table1.code_id </code></pre> <p>For <code>Table2</code></p> <pre><code>SELECT codesTable.code_id,COUNT(*) FROM table2,codesTable WHERE table2.codeid=CodeTable.code_id AND table2.type_no IN (1,2,3,4,5,6,7,8,9,10) AND table2.recoverd_value IN (0,1) GROUP BY table2.code_id </code></pre> <p>Need to combine this as one query.</p> <p><strong>Note</strong>:</p> <p>Result for 1st query: code_id and count of Table1 and</p> <p>Result for 2nd query: code_id, count of table2.</p> <p>Current output like code_id,count of table(1,2)</p>
[ { "answer_id": 74153612, "author": "Nithish Kumar", "author_id": 20290233, "author_profile": "https://Stackoverflow.com/users/20290233", "pm_score": 0, "selected": false, "text": "(SELECT code_id,COUNT(*) FROM table1,codesTable\nWHERE table1.codeid=CodeTable.code_id \nAND table1.type_no ...
2022/10/21
[ "https://Stackoverflow.com/questions/74153499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20213572/" ]
74,153,521
<p>I have a C# script performing create/update operations to EA diagrams. It's working good with EA 15. But when I run it with EA 16, it fails with the error - &quot;No such diagram found having diagram GUID:&quot;</p> <p>Here is the details of example user case. Script is connecting with one user to EA and creating diagram. Now next time script runs and connects with another user to EA and try to update earlier created diagram.</p> <p>Based on the new version 16 document, I know that it's required to be reloaded. When I try to update the same diagram from the EA UI, I get the error and it asked to reload that diagram. After reload I am able to update the diagram from the UI.</p> <p>Same thing I tried from the code to reload the diagram (using <strong>Repository.ReloadDiagram (currentDiagram.DiagramID);</strong>) and then update (<strong>diagram.Update()</strong>), but still I am getting same error.</p> <p>Also tried to login with 2nd user in UI and set the reload changed diagram to true from <strong>Design-&gt;Diagram-&gt;Options-&gt;auto reload changed diagram</strong>. This also does not reload the diagram and shows pop up to reload before updating entity.</p> <p><strong>Update:</strong> Here is the code snippet that I am using. It gives error on second diagram.Update() i.e. after connecting to user2 and trying to update diagram from his connection with following error &quot;No such diagram found having diagram GUID: &quot;</p> <pre><code>{ //connect to user1 EAConnection connection = new EAConnection(); connection.EARepository = new Repository(); connection.EARepository.SuppressSecurityDialog = true; connection.EARepository.SuppressEADialogs = true; bool isOpened = connection.EARepository.OpenFile2(&quot;path&quot;, &quot;user1&quot;, &quot;password&quot;); //update diagram with user1 diagram = repository.GetDiagramByGuid(guid); repository.ReloadDiagram(diagram.DiagramID); //reload diagram object //update attribute values diagram.Name = &quot;xyz&quot;; diagram.Update(); //connect to user2 EAConnection connection = new EAConnection(); connection.EARepository = new Repository(); connection.EARepository.SuppressSecurityDialog = true; connection.EARepository.SuppressEADialogs = true; bool isOpened = connection.EARepository.OpenFile2(&quot;path&quot;, &quot;user2&quot;, &quot;password&quot;); //update diagram with user2 diagram = repository.GetDiagramByGuid(guid); repository.ReloadDiagram(diagram.DiagramID); //reload diagram object diagram.Name = &quot;abc&quot;; diagram.Update(); } </code></pre>
[ { "answer_id": 74221278, "author": "Geert Bellekens", "author_id": 2018133, "author_profile": "https://Stackoverflow.com/users/2018133", "pm_score": 1, "selected": false, "text": "namespace EA_console_app\n{\n internal class Program\n {\n static void Main(string[] args)\n ...
2022/10/21
[ "https://Stackoverflow.com/questions/74153521", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2399470/" ]
74,153,526
<p>I want to transform duplicated values of index adding a counter like -01, -02, -0n, etc. for every duplicated item, skipping unduplicated indices.</p> <p>That is to transform index values from these:</p> <pre><code>one one two three three four </code></pre> <p>to these:</p> <pre><code>one-01 one-02 two three-01 three-02 four </code></pre> <p>What approach can I resort to?</p>
[ { "answer_id": 74153547, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 2, "selected": true, "text": "GroupBy.cumcount" }, { "answer_id": 74153552, "author": "Bernward Sanchez", "author_id": 20300978, ...
2022/10/21
[ "https://Stackoverflow.com/questions/74153526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3455918/" ]
74,153,531
<p>Let's say i have this code:</p> <pre><code>$test = @(&quot;apple&quot; , &quot;orange&quot;, &quot;pear&quot;) </code></pre> <p>If i do <code>write-host $test[0]</code> i will get <code>apple</code> returned.</p> <p>If i do <code>write-host $test[0] $test[1] $test[2]</code> i will get this returned:</p> <pre><code>apple orange pear </code></pre> <p>When i try getting in 1 line as just a single string I am doing:</p> <pre><code>write-host &quot;$test[0] $test[1] $test[2]&quot; </code></pre> <p>But this returns:</p> <pre><code>apple orange pear[0] apple orange pear[1] apple orange pear[2] </code></pre> <p>It can't seem to recognise the index now that i Have added quotations</p> <p><strong>Question:</strong></p> <p>Anyone know how i can just get my result to look like:</p> <pre><code>&quot;apple orange pear&quot; </code></pre> <p>Note: i do need to wrap this in quotations as i will be using it a script elsewhere which would require this - this is just a simple example for what i need</p>
[ { "answer_id": 74153561, "author": "Abdul Niyas P M", "author_id": 6699447, "author_profile": "https://Stackoverflow.com/users/6699447", "pm_score": 2, "selected": false, "text": "Write-Host ($test -Join \" \")\n" }, { "answer_id": 74153626, "author": "Mathias R. Jessen", ...
2022/10/21
[ "https://Stackoverflow.com/questions/74153531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18683782/" ]
74,153,556
<p>How do I check whether the row values is matching some conditions and modify the values? For example, if value1 and value2 are matched with the conditions, then I change them by another value.</p> <p>I am using this method:</p> <pre><code>df['column'] = df['column'].replace(['matching1', 'matching2'], 'value1') df['column'] = df['column'].replace(['matching3', 'matching4'], 'value2') ... df['column'] = df['column'].replace(['matching999', 'matching1000'], 'value500') </code></pre> <p>But I need to handle many conditions so writing many commands like this may seem too clumsy since the whole dataframe has to be rechecked one time by every condition.</p> <p>Is there any way to complete it faster? For example, the row that has been modified after the condition is met does not need to be checked again</p>
[ { "answer_id": 74155328, "author": "Yusuke Matsubara", "author_id": 4473141, "author_profile": "https://Stackoverflow.com/users/4473141", "pm_score": 1, "selected": false, "text": "df = pd.DataFrame(['Apple','Apple','Orange','Lemon','Banana','Apple'], columns=['column'])\n\ndf['column']....
2022/10/21
[ "https://Stackoverflow.com/questions/74153556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20077124/" ]
74,153,602
<p>how would I go about sorting a vector alphabetically and then getting the first 10 names and last 10 names printed according to the new alphabetical order?</p> <p>i know to use sort(names) to get the vector in alphabetical order, and i know to use tail(names,10) and head(names,10) to get the first and last names but how to I combine these functions?</p> <p>thanks for any help</p>
[ { "answer_id": 74153738, "author": "stefan", "author_id": 12993861, "author_profile": "https://Stackoverflow.com/users/12993861", "pm_score": 2, "selected": false, "text": "ht_sort <- function(x, n) {\n x <- sort(x)\n c(head(x, n), tail(x, n))\n}\n\nnames <- rownames(mtcars)\n\nht_sort...
2022/10/21
[ "https://Stackoverflow.com/questions/74153602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20285663/" ]
74,153,625
<p>How can I change the function of the back button in de app bar? So I want to go to the home page when you click on the back button how can I make this work?</p> <pre><code> appBar: AppBar( backgroundColor: Colors.transparent, elevation: 0, leading: const BackButton( color: Color(0xFFFD879A), ), ), </code></pre>
[ { "answer_id": 74153668, "author": "eamirho3ein", "author_id": 10306997, "author_profile": "https://Stackoverflow.com/users/10306997", "pm_score": 3, "selected": true, "text": "onPressed" }, { "answer_id": 74153669, "author": "mfrischbutter", "author_id": 8971539, "au...
2022/10/21
[ "https://Stackoverflow.com/questions/74153625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18400997/" ]
74,153,635
<p><em><strong>Linux MInt 21</strong></em>, I try to instal MongoDB for like 3 days but apparently I'm not doing something right. I would greatly appreciate it if you could tell me what I am doing wrong :)) I post what i did in the terminal, I removed it and install it again but and that went wrong too</p> <pre><code>Lenovo-Y520-15IKBM:~$ sudo apt install mongodb Reading package lists... Done Building dependency tree... Done Reading state information... Done Package mongodb is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package 'mongodb' has no installation candidate Lenovo-Y520-15IKBM:~$ ^C Lenovo-Y520-15IKBM:~$ sudo apt-get purge mongo* Reading package lists... Done Building dependency tree... Done Reading state information... Done Note, selecting 'mongodb-server' for glob 'mongo*' Note, selecting 'mongodb-dev' for glob 'mongo*' Note, selecting 'mongodb' for glob 'mongo*' Note, selecting 'mongoose' for glob 'mongo*' Package 'mongodb-dev' is not installed, so not removed Package 'mongodb' is not installed, so not removed Package 'mongodb-server' is not installed, so not removed Package 'mongoose' is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 63 not upgraded. Lenovo-Y520-15IKBM:~$ sudo apt install mongodb Reading package lists... Done Building dependency tree... Done Reading state information... Done Package mongodb is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package 'mongodb' has no installation candidate Lenovo-Y520-15IKBM:~$ ^C Lenovo-Y520-15IKBM:~$ sudo apt remove --autoremove mongodb-org Reading package lists... Done Building dependency tree... Done Reading state information... Done E: Unable to locate package mongodb-org Lenovo-Y520-15IKBM:~$ ^C Lenovo-Y520-15IKBM:~$ sudo apt install mongodb Reading package lists... Done Building dependency tree... Done Reading state information... Done Package mongodb is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package 'mongodb' has no installation candi </code></pre>
[ { "answer_id": 74333700, "author": "Ashutosh Patole", "author_id": 11283638, "author_profile": "https://Stackoverflow.com/users/11283638", "pm_score": -1, "selected": false, "text": "wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -\n\necho \"deb [ arch=am...
2022/10/21
[ "https://Stackoverflow.com/questions/74153635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20301009/" ]
74,153,659
<p>I want to filter data in the html table based on 3 dropdown list values (standort, status and infrastructure). --&gt; ddlStandort, ddlStatus, ddlInfrastruktur My below code is not working, I don't know why.....</p> <p><strong>JavaScript</strong></p> <pre><code>&lt;script type=&quot;text/javascript&quot; src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js&quot;&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt; $(document).ready(function () { $(&quot;#ddlStandort,#ddlStatus,#ddlInfrastruktur&quot;).on(&quot;change&quot;, function () { var standort = $('#ddlStandort').find(&quot;option:selected&quot;).val(); var status = $('#ddlStatus').find(&quot;option:selected&quot;).val(); var infrastructure = $('#ddlInfrastruktur').find(&quot;option:selected&quot;).val(); SearchData(standort, status, infrastructure) }); }); function SearchData(standort, status, infrastructure) { if (standort.toUpperCase() == 'All' &amp;&amp; status.toUpperCase() == 'All' &amp;&amp; infrastructure.toUpperCase() == 'All') { $('#table11 tbody tr').show(); } else { $('#table11 tbody tr:has(td)').each(function () { var rowStandort = $.trim($(this).find('td:eq(9)').text()); var rowStatus = $.trim($(this).find('td:eq(5)').text()); var rowInfrastructure = $.trim($(this).find('td:eq(10)').text()); if (standort.toUpperCase() != 'All' &amp;&amp; status.toUpperCase() != 'All' &amp;&amp; infrastructure.toUpperCase() != 'ALL') { if (rowStandort.toUpperCase() == standort.toUpperCase() &amp;&amp; rowStatus == status &amp;&amp; rowInfrastructure == infrastructure) { $(this).show(); } else { $(this).hide(); } } else if ($(this).find('td:eq(9)').text() != '' || $(this).find('td:eq(5)').text() != '' || $(this).find('td:eq(10)').text() != '') { if (standort != 'All') { if (rowStandort.toUpperCase() == standort.toUpperCase()) { $(this).show(); } else { $(this).hide(); } } if (status != 'All') { if (rowStatus == status) { $(this).show(); } else { $(this).hide(); } } if (infrastructure != 'All') { if (rowInfrastructure == infrastructure) { $(this).show(); } else { $(this).hide(); } } } }); } } &lt;/script&gt; </code></pre> <p><strong>HTML/PHP</strong></p> <pre><code>&lt;?php require(&quot;db_conn.php&quot;); $sql = &quot;SELECT * FROM `dspia_ip_state` ORDER BY state_id&quot;; $all_states = mysqli_query($conn,$sql); ?&gt; &lt;select id=&quot;ddlStatus&quot; name=&quot;ddlStatus&quot;&gt;&lt;br&gt; &lt;option value=&quot;All&quot;&gt;Status&lt;/option&gt; &lt;?php while ($state = mysqli_fetch_array( $all_states,MYSQLI_ASSOC)):; ?&gt; &lt;option value=&quot;&lt;?php echo $state[&quot;state&quot;]; ?&gt;&quot;&gt; &lt;?php echo $state[&quot;state&quot;]; ?&gt; &lt;/option&gt; &lt;?php endwhile; ?&gt; &lt;/select&gt; &lt;?php require(&quot;db_conn.php&quot;); $sql = &quot;SELECT * FROM `dspia_location` ORDER BY location_id&quot;; $all_location = mysqli_query($conn,$sql); ?&gt; &lt;select id=&quot;ddlStandort&quot; name=&quot;ddlStandort&quot;&gt; &lt;option value=&quot;All&quot;&gt;Standort&lt;/option&gt; &lt;?php while ($location = mysqli_fetch_array( $all_location,MYSQLI_ASSOC)):; ?&gt; &lt;option value=&quot;&lt;?php echo $location[&quot;location&quot;]; ?&gt;&quot;&gt; &lt;?php echo $location[&quot;location&quot;]; ?&gt; &lt;/option&gt; &lt;?php endwhile; ?&gt; &lt;/select&gt; &lt;?php require(&quot;db_conn.php&quot;); $sql = &quot;SELECT * FROM `dspia_infrastructure` ORDER BY infrastructure_id&quot;; $all_infrastructure = mysqli_query($conn,$sql); ?&gt; &lt;select id=&quot;ddlInfrastruktur&quot; name=&quot;ddlInfrastruktur&quot;&gt; &lt;option value=&quot;All&quot;&gt;Infrastruktur&lt;/option&gt; &lt;?php while ($infrastructure = mysqli_fetch_array( $all_infrastructure,MYSQLI_ASSOC)):; ?&gt; &lt;option value=&quot;&lt;?php echo $infrastructure[&quot;infrastructure&quot;]; ?&gt;&quot;&gt; &lt;?php echo $infrastructure[&quot;infrastructure&quot;]; ?&gt; &lt;/option&gt; &lt;?php endwhile; ?&gt; &lt;/select&gt; </code></pre> <p>the table data is selected from a database</p> <p><strong>Whole Code</strong></p> <pre><code>&lt;body&gt; &lt;div class=&quot;row header&quot;&gt; &lt;a href=&quot;home.php&quot;&gt;&lt;img id=&quot;drv&quot; src=&quot;img/neueip/logo_drv_berlin-brandenburg_web.jpg&quot;&gt;&lt;/a&gt; &lt;div class= &quot;header-text&quot;&gt; &lt;h2&gt;IP-Adressverwaltung&lt;/h2&gt; &lt;/div&gt; &lt;div class= &quot;header-line&quot;&gt; &lt;h1&gt;|&lt;/h1&gt; &lt;/div&gt; &lt;div class=&quot;col-50 rechts&quot;&gt; &lt;?php if($_SESSION['is_admin'] =='1'){ ?&gt; &lt;div class=&quot;verwaltung&quot;&gt; &lt;button class=&quot;dropbtn&quot;&gt;&lt;b&gt;Verwaltung&lt;/b&gt;&lt;/button&gt; &lt;div class=&quot;dropdown-content&quot;&gt; &lt;a href=&quot;home.php&quot;&gt;IP-Adresse&lt;/a&gt; &lt;a href=&quot;benutzer.php&quot;&gt;Benutzer&lt;/a&gt; &lt;a href=&quot;status.php&quot;&gt;Status&lt;/a&gt; &lt;a href=&quot;standort.php&quot;&gt;Standort&lt;/a&gt; &lt;a href=&quot;betriebssystem.php&quot;&gt;Betriebssystem&lt;/a&gt; &lt;a href=&quot;infrastruktur.php&quot;&gt;Infrastruktur&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php } ?&gt; &lt;a href=&quot;logout.php&quot;&gt;&lt;img src=&quot;img/home/logout.png&quot; class=&quot;logout&quot;&gt;&lt;/a&gt; &lt;div class= &quot;user&quot;&gt; &lt;h3&gt;| Benutzer: &lt;?php print_r($_SESSION['login_name']); ?&gt; |&lt;/h3&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- &lt;div class=&quot;gesamtPapierkorb&quot;&gt; &lt;a href=&quot;home.php&quot;&gt;&lt;img src=&quot;img/home/gesamtPapierkorb.png&quot;&gt;&lt;/a&gt; &lt;/div&gt; --&gt; &lt;/div&gt; &lt;div class=&quot;reload&quot;&gt; &lt;a href=&quot;home.php&quot;&gt;&lt;img src=&quot;img/home/refresh.png&quot;&gt;&lt;/a&gt; &lt;/div&gt; &lt;div class=&quot;filtern&quot;&gt; &lt;?php $sql = &quot;SELECT * FROM `dspia_ip_state` ORDER BY state_id&quot;; $all_states = mysqli_query($conn,$sql); ?&gt; &lt;select id=&quot;ddlStatus&quot; name=&quot;ddlStatus&quot;&gt;&lt;br&gt; &lt;option value=&quot;All&quot;&gt;Status&lt;/option&gt; &lt;?php while ($state = mysqli_fetch_array( $all_states,MYSQLI_ASSOC)):; ?&gt; &lt;option value=&quot;&lt;?php echo $state[&quot;state&quot;]; ?&gt;&quot;&gt; &lt;?php echo $state[&quot;state&quot;]; ?&gt; &lt;/option&gt; &lt;?php endwhile; ?&gt; &lt;/select&gt; &lt;?php $sql = &quot;SELECT * FROM `dspia_location` ORDER BY location_id&quot;; $all_location = mysqli_query($conn,$sql); ?&gt; &lt;select id=&quot;ddlStandort&quot; name=&quot;ddlStandort&quot;&gt; &lt;option value=&quot;All&quot;&gt;Standort&lt;/option&gt; &lt;?php while ($location = mysqli_fetch_array( $all_location,MYSQLI_ASSOC)):; ?&gt; &lt;option value=&quot;&lt;?php echo $location[&quot;location&quot;]; ?&gt;&quot;&gt; &lt;?php echo $location[&quot;location&quot;]; ?&gt; &lt;/option&gt; &lt;?php endwhile; ?&gt; &lt;/select&gt; &lt;?php $sql = &quot;SELECT * FROM `dspia_infrastructure` ORDER BY infrastructure_id&quot;; $all_infrastructure = mysqli_query($conn,$sql); ?&gt; &lt;select id=&quot;ddlInfrastruktur&quot; name=&quot;ddlInfrastruktur&quot;&gt; &lt;option value=&quot;All&quot;&gt;Infrastruktur&lt;/option&gt; &lt;?php while ($infrastructure = mysqli_fetch_array( $all_infrastructure,MYSQLI_ASSOC)):; ?&gt; &lt;option value=&quot;&lt;?php echo $infrastructure[&quot;infrastructure&quot;]; ?&gt;&quot;&gt; &lt;?php echo $infrastructure[&quot;infrastructure&quot;]; ?&gt; &lt;/option&gt; &lt;?php endwhile; ?&gt; &lt;/select&gt; &lt;/div&gt; &lt;input type=&quot;text&quot; id=&quot;suchleiste&quot; onkeyup=&quot;myFunction()&quot; placeholder=&quot;Suchen...&quot;&gt; &lt;/div&gt; &lt;div class=&quot;IPbutton&quot;&gt; &lt;form action=&quot;newip.php&quot; method=&quot;post&quot;&gt; &lt;button class=&quot;IP&quot; type=&quot;submit&quot;&gt;&lt;b&gt;+ Neue IP-Adresse&lt;/b&gt;&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css&quot;&gt; &lt;div class=&quot;tabelle&quot;&gt; &lt;div style=&quot;overflow-x:auto;&quot;&gt; &lt;table id=table11&gt; &lt;tr&gt; &lt;th&gt;&lt;/th&gt; &lt;th onclick=&quot;sortID()&quot;&gt;ID&lt;/th&gt; &lt;th onclick=&quot;sortTable(1)&quot;&gt;IP-Adresse ↕&lt;/th&gt; &lt;th onclick=&quot;sortTable(2)&quot;&gt;Hostname ↕&lt;/th&gt; &lt;th onclick=&quot;sortTable(3)&quot;&gt;MAC-Adresse ↕&lt;/th&gt; &lt;th onclick=&quot;sortTable(4)&quot;&gt;PW_Neu ↕&lt;/th&gt; &lt;th onclick=&quot;sortTable(5)&quot;&gt;Status ↕&lt;/th&gt; &lt;th onclick=&quot;sortTable(6)&quot;&gt;Beschreibung ↕&lt;/th&gt; &lt;th onclick=&quot;sortTable(7)&quot;&gt;Betriebssystem ↕&lt;/th&gt; &lt;th onclick=&quot;sortTable(8)&quot;&gt;Admin ↕&lt;/th&gt; &lt;th onclick=&quot;sortTable(9)&quot;&gt;Standort ↕&lt;/th&gt; &lt;th onclick=&quot;sortTable(10)&quot;&gt;Infrastruktur ↕&lt;/th&gt; &lt;th onclick=&quot;sortTable(11)&quot;&gt;Workorder ↕&lt;/th&gt; &lt;th onclick=&quot;sortTable(12)&quot;&gt;Anmerkungen ↕&lt;/th&gt; &lt;/tr&gt; &lt;?php if(isset($_GET[&quot;del&quot;])){ if(!empty($_GET[&quot;del&quot;])){ $main_id = $_GET[&quot;del&quot;]; $stmt = $conn-&gt;prepare(&quot;DELETE FROM dspia_main WHERE main_id = '&quot;.$main_id.&quot;'&quot;); if($stmt-&gt;execute()){ ?&gt; &lt;div class=&quot;alert&quot;&gt; &lt;span class=&quot;closebtn&quot; onclick=&quot;this.parentElement.style.display='none';&quot;&gt;&amp;times;&lt;/span&gt; &lt;strong&gt; &lt;?php print &quot;Die IP-Adresse wurde gelöscht.&quot;; ?&gt; &lt;/strong&gt; &lt;/div&gt; &lt;?php }else{ print $conn-&gt;error; } } } $sql = &quot;SELECT * FROM v_dspia_main&quot;; $result = mysqli_query($conn, $sql); while($dsatz = mysqli_fetch_assoc($result)){ ?&gt; &lt;tbody id=&quot;myTable&quot;&gt; &lt;tr&gt; &lt;th&gt;&lt;a href=&quot;editIP.php?id=&lt;?php echo $dsatz[&quot;main_id&quot;] ?&gt;&quot;&gt;&lt;img src=&quot;img/home/stift.png&quot; class=&quot;Stift&quot; width=&quot;auto&quot; height=&quot;30&quot;&gt;&lt;/a&gt;&lt;a href=&quot;home.php?del=&lt;?php echo $dsatz[&quot;main_id&quot;] ?&gt;&quot;onclick='return confirmSubmit()'&gt;&lt;img src=&quot;img/home/mülleimer.png&quot; class=&quot;Mülleimer&quot; width=&quot;auto&quot; height=&quot;33&quot; class=&quot;Mülleimer&quot;&gt;&lt;/th&gt; &lt;td&gt;&lt;?php echo $dsatz[&quot;main_id&quot;] ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $dsatz[&quot;ip_v4&quot;] ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $dsatz[&quot;hostname&quot;] ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $dsatz[&quot;mac_address&quot;] ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php if($dsatz[&quot;pw_new&quot;] == &quot;1&quot;) { echo &quot;Ja&quot;; }else if($dsatz[&quot;pw_new&quot;] == &quot;0&quot;){ echo &quot;Nein&quot;; } ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $dsatz[&quot;state&quot;] ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $dsatz[&quot;description&quot;] ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $dsatz[&quot;op_system&quot;] ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $dsatz[&quot;operator&quot;] ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $dsatz[&quot;location&quot;] ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $dsatz[&quot;infrastructure&quot;] ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $dsatz[&quot;workorder&quot;] ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $dsatz[&quot;remarks&quot;] ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php } ?&gt; &lt;colgroup&gt; &lt;col width=&quot;5%&quot;&gt; &lt;/colgroup&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Tables = main_dspia (main table) v_main_dspia (view to show the table on website) dspia_ip_state (for the Dropdown state) dspia_location (for the Dropdown location) dspia_infrastructure (for the Dropdown infrastructure)</p> <p><a href="https://i.stack.imgur.com/1ikn4.png" rel="nofollow noreferrer">Table with DropDown Filter and Content</a></p> <p><a href="https://i.stack.imgur.com/bC7VH.png" rel="nofollow noreferrer">dspia_infrastructure</a></p> <p><a href="https://i.stack.imgur.com/2NLrU.png" rel="nofollow noreferrer">dspia_ip_state</a></p> <p><a href="https://i.stack.imgur.com/darPU.png" rel="nofollow noreferrer">dspia_location</a></p> <p><a href="https://i.stack.imgur.com/ZH4oY.png" rel="nofollow noreferrer">dspia_op_system</a></p> <p><a href="https://i.stack.imgur.com/aQEy3.png" rel="nofollow noreferrer">dspia_user</a></p>
[ { "answer_id": 74333700, "author": "Ashutosh Patole", "author_id": 11283638, "author_profile": "https://Stackoverflow.com/users/11283638", "pm_score": -1, "selected": false, "text": "wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -\n\necho \"deb [ arch=am...
2022/10/21
[ "https://Stackoverflow.com/questions/74153659", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20298312/" ]
74,153,737
<p>How to List the largerst city population for each country<br /> -- Use country column (not country_code), order the results by the decreasing largerst city population.</p> <p><a href="https://i.stack.imgur.com/LjyDl.jpg" rel="nofollow noreferrer">enter image description here</a></p>
[ { "answer_id": 74153960, "author": "Adelino Silva", "author_id": 18620602, "author_profile": "https://Stackoverflow.com/users/18620602", "pm_score": -1, "selected": false, "text": "SELECT MAX(population) largerst, city\nFROM <tablename>\nGROUP BY country\nORDER BY largerst DESC, city;\n"...
2022/10/21
[ "https://Stackoverflow.com/questions/74153737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19945069/" ]
74,153,752
<p>Im trying to stop a function that loads images to a combobox but when i want to cancell, it takes a lot of time, it always downlod images from a server so the connection can fail, when it happens i cancell the process with a cancellation token but it still &quot;working&quot; inclusive when i cancell the token. tose are my functions:</p> <pre><code> private async Task FillModels() { var token = comboBox_utils._cancellSource = new(); try { await comboBox_utils.FillModelList(cb_model_list, _downloadedModels, new Size(500, 180), token.Token); } catch { comboBox_utils._isLoadingModels = false; MessageBox.Show(&quot;Cancelado&quot;); } } </code></pre> <pre><code> public async Task FillModelList(ComboBox cb, List&lt;DefaultModelDropdown&gt; modelList, Size size, CancellationToken cancell) { if (_isLoadingModels) { return; } _isLoadingModels = true; Visor_de_imágenes.CheckConection.CheckConection check = new(); int amountDownloadedModels = modelList.Count; //crea los modelos faltantes DefaultModelDropdown dropdownContent = new(); List&lt;modelo&gt; xmlModels = xml.Serialize_xml(xml.getXmlFolder()); int amountModels = xmlModels.Count; if (amountDownloadedModels == amountModels) { return; } int amountListbox = cb.Items.Count; for (int i = amountListbox; i &lt; amountModels; i++) { try { var model = await Task.Run(async () =&gt; { return await dropdownContent.NewDedfaultModel(xmlModels[i], cancell); }, cancell); if (cancell.IsCancellationRequested) { cancell.ThrowIfCancellationRequested(); } modelList.Add(model); cb.Items.Add(panel.CreatePanelModel(model, size)); } catch { break; } } _isLoadingModels = false; } </code></pre> <pre><code> public async Task&lt;DefaultModelDropdown&gt; NewDedfaultModel(modelo model, CancellationToken cancell) { var io = new Image_options(); var def = new DefaultModelDropdown(); def.Name = model.nombre; def.extra = model.nombre_clave; BitmapImage bi; try { bi = await io.AsyncPathToImage(model.imagen, cancell); }catch { bi = new(); } def.image = bi; return def; } </code></pre> <pre><code> public async Task&lt;BitmapImage&gt; AsyncPathToImage(string path, CancellationToken cancell = default) { return await Task.Run(() =&gt; { BitmapImage bi = new(new Uri(path, UriKind.RelativeOrAbsolute)); bi.Freeze(); return bi; },cancell); } </code></pre> <p>i dont know why it takes like 5 or 10 secs after get cancelled.</p>
[ { "answer_id": 74154618, "author": "Clemens", "author_id": 1136211, "author_profile": "https://Stackoverflow.com/users/1136211", "pm_score": 2, "selected": true, "text": "public static async Task<BitmapSource> LoadBitmapSourceAsync(\n string path, CancellationToken cancellationToken)\...
2022/10/21
[ "https://Stackoverflow.com/questions/74153752", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17573097/" ]
74,153,774
<p>This is the first time I use axios for queries ... but now I don't know any further, I hope someone can give me an advice.</p> <p>In order to develop a dictionary app with React Native, I want to query wiktionary like this</p> <pre><code>let url = &quot;https://en.wiktionary.org/w/api.php?format=json&amp;action=query&amp;titles={word}&amp;rvprop=content&amp;prop=revisions&amp;redirects=1&amp;callback=?&quot;.replace(&quot;{word}&quot;, word); ... axios({ method: 'get', url: url, }).then((response) =&gt; { var results = { title: &quot;&quot;, definitions: [], examples: [] } .... let data = response.data; ... </code></pre> <p>This query itself works ... now I would like to adapt this for my purposes: <a href="https://github.com/PalmerAL/wiktionary-parser/blob/gh-pages/wiktionary-parser.js" rel="nofollow noreferrer">wiktionary-parser</a>.</p> <p>The problem occurs here:</p> <pre><code> if(!data || !data.query || !data.query.pages || data.query.pages[-1]) { return callback({}); } </code></pre> <p>It says</p> <pre><code>TypeError: Cannot read property 'pages' of undefined </code></pre> <p>The way the data from my query are organized must differ from the data received by this &quot;$.getJSON...&quot;-query of the Wiktionary parser mentioned above ...</p> <p>But how?</p> <p>I tried to work with</p> <pre><code>JSON.stringify(response.data) </code></pre> <p>and</p> <pre><code>JSON.parse(response.data) </code></pre> <p>What am I doing wrong? Any proposals?</p> <p>Thank you in advance, Frank</p> <p>The complete code of the query is</p> <pre><code> function getENWiktionaryInfo(word, wordLanguage, callback) { // getJSON(&quot;https://en.wiktionary.org/w/api.php?format=json&amp;action=query&amp;titles={word}&amp;rvprop=content&amp;prop=revisions&amp;redirects=1&amp;callback=?&quot;.replace(&quot;{word}&quot;, word), function (data) { // $.getJSON(&quot;https://en.wiktionary.org/wiki/abdico#Latin&quot;, function (data) { let url = &quot;https://en.wiktionary.org/w/api.php?format=json&amp;action=query&amp;titles={word}&amp;rvprop=content&amp;prop=revisions&amp;redirects=1&amp;callback=?&quot;.replace(&quot;{word}&quot;, word); console.log(&quot;getENWiktionaryInfo &quot; + url); axios({ method: 'get', url: url, }).then((response) =&gt; { var results = { title: &quot;&quot;, definitions: [], examples: [] } let data = response.data; console.log(&quot;DATA &quot;+data); const jsonObj= JSON.stringify(response.data) //let data = jsonObj; var title, content; if (!data || !data.query || !data.query.pages || data.query.pages[-1]) { return callback({}); } callback(results); }); } </code></pre> <p>The pure call for the (latin) word &quot;res&quot; is:</p> <pre><code>https://en.wiktionary.org/w/api.php?format=json&amp;action=query&amp;titles=res&amp;rvprop=content&amp;prop=revisions&amp;redirects=1&amp;callback=? </code></pre>
[ { "answer_id": 74169984, "author": "Metamorphosis", "author_id": 19269707, "author_profile": "https://Stackoverflow.com/users/19269707", "pm_score": 0, "selected": false, "text": "Access to XMLHttpRequest at 'https://en.wiktionary.org/w/api.php?format=json&action=query&titles=res&rvprop=...
2022/10/21
[ "https://Stackoverflow.com/questions/74153774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19269707/" ]
74,153,816
<p>In my powerbuilder 2021 devolvement environment the web control works fine and it navigates to the desired URLs Correctly. when I release complied version of my application to the user this web browser control does not work. sometimes it displays blank space and another time application closed. I put all the web browser related dll's in application path its is not work. I use Windows10 OS. what can I try doing here?</p>
[ { "answer_id": 74169984, "author": "Metamorphosis", "author_id": 19269707, "author_profile": "https://Stackoverflow.com/users/19269707", "pm_score": 0, "selected": false, "text": "Access to XMLHttpRequest at 'https://en.wiktionary.org/w/api.php?format=json&action=query&titles=res&rvprop=...
2022/10/21
[ "https://Stackoverflow.com/questions/74153816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20077075/" ]
74,153,857
<p>I want to get the amount written in <code>p</code> tag under <code>td</code> tag , but I am getting <code>p</code> element content as a string, I only want to extract the amount written.</p> <p>The HTML code: <a href="https://i.stack.imgur.com/qhK8h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qhK8h.png" alt="The HTML code" /></a></p> <p>The command I used: <a href="https://i.stack.imgur.com/zKZkl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zKZkl.png" alt="enter image description here" /></a></p> <pre class="lang-py prettyprint-override"><code>response.css(&quot;#__next &gt; div &gt; div:nth-child(2) &gt; div &gt; div.data-table_container__pPKXQ &gt; table &gt; tbody &gt; tr:nth-child(1) &gt; td:nth-child(3) &gt; p: nth-child(1)&quot;).get() </code></pre>
[ { "answer_id": 74169984, "author": "Metamorphosis", "author_id": 19269707, "author_profile": "https://Stackoverflow.com/users/19269707", "pm_score": 0, "selected": false, "text": "Access to XMLHttpRequest at 'https://en.wiktionary.org/w/api.php?format=json&action=query&titles=res&rvprop=...
2022/10/21
[ "https://Stackoverflow.com/questions/74153857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15942235/" ]
74,153,861
<p>I want to concatenate strings in <code>List</code> using different delimiters according to list size and element's position.</p> <p>Here's my code with a sample-data:</p> <pre><code>final List&lt;String&gt; names = Arrays.asList(&quot;Alice&quot;,&quot;Bob&quot;,&quot;Kevin&quot;); if (names.size() &lt; 3) { System.out.println(String.join(&quot; and &quot;, names)); } else { String joinedNames = String.join(&quot;, &quot;, names.subList(0, names.size() - 1)); joinedNames += &quot; and &quot; + names.get(names.size() - 1); System.out.println(joinedNames); } </code></pre> <p><em>Expected outputs:</em></p> <pre class="lang-none prettyprint-override"><code>// List of size 2 Alice and Bob // List of size 3 Alice, Bob and Kevin </code></pre> <p>Is there a better and more readable way to do it?</p>
[ { "answer_id": 74154164, "author": "Alexander Ivanchenko", "author_id": 17949945, "author_profile": "https://Stackoverflow.com/users/17949945", "pm_score": 3, "selected": true, "text": "public static String joinNames(List<String> names) {\n \n if (names.isEmpty()) throw new Illegal...
2022/10/21
[ "https://Stackoverflow.com/questions/74153861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6171025/" ]
74,153,886
<p>I have one component in which I calculate price based on model and extras that go with it. it looks like this:</p> <p>product.jsx:</p> <pre><code> const name = productData.name; const modelPrice = productData.modelPrice; {/*Array that must contain: [key: number, model: string, price: number] */} {/*NewExtras START */} const extrasList = productData.extras; {/*Array that must contain: [ key: number, name: string, price: number, active: boolean (default: false) ] */} const [extrasListP, setExtrasListP] = useState(extrasList); const toggleExtras = (extra) =&gt; { const updatedExtrasList = extrasListP.map((ex) =&gt; { extra.name === ex.name ? ex.active = !ex.active : ex.active = ex.active; return ex; }); setExtrasListP(updatedExtrasList); }; const activeExtras = extrasListP.filter((extra) =&gt; { return extra.active; }); const aExtrasList = activeExtras.map((extra) =&gt; { return ( &lt;div key={extra.key}&gt;{extra.name},&amp;nbsp;&lt;/div&gt; ); }) const sumExtras = activeExtras.reduce((previousValue, object) =&gt; { return previousValue + object.price; }, 0); {/*NewExtras END */} const [quantity, setQuantity] = useState(1); {/*Model variables START */} const [activeModel, setActiveModel] = useState(modelPrice[0].model); const [activePrice, setActivePrice] = useState(modelPrice[0].price); const modelPriceList = modelPrice.map((item) =&gt; { return ( &lt;div key = {item.key} className={ activePrice === item.price ? styles.activeModelItem : styles.modelItem} onClick={() =&gt; {setActiveModel(item.model); setActivePrice(item.price)}} &gt; | {item.model} | &lt;/div&gt; ); }); {/*Model variables END */} const [buttonText, setButtonText] = useState(&quot;Dodaj u korpu&quot;); const finalPrice = (activePrice + sumExtras) * quantity; const [korpa, setKorpa] = useState([]); const toSend = &lt;&gt;proizvod: {name} - Model: {activeModel} - Dodatno: - {aExtrasList} - Količina: {quantity} - Ukupno: {finalPrice}&lt;/&gt;; </code></pre> <p>I want to create component called Cart.jsx to which I will send: <strong>toSend</strong> variable. I also want it to stay chached so it stays when user refreshes page.</p> <p>I was searching the internet for week and a half now and cant seem to find suitable answer for my situation. I hope that somebody will at least point me at right direction.</p>
[ { "answer_id": 74154163, "author": "David", "author_id": 13019276, "author_profile": "https://Stackoverflow.com/users/13019276", "pm_score": 0, "selected": false, "text": "const [total, setTotal] = useState(0);\n\nconst addTotalSum = () => {\n // Logic here for getting the total.\n ...
2022/10/21
[ "https://Stackoverflow.com/questions/74153886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20137771/" ]
74,153,908
<p>I have two columns in PostgreSQL that store time values (H:M:S) and I use SQLAlchemy. How can I make a select using SQLAlchemy for values that are not between the two values?</p> <p>Example 1:</p> <ul> <li>current time in the interrogation = 10:00:01</li> <li>start_time = 16:00:12</li> <li>end_time = 22:00:00 Return the value because is outside of this time interval</li> </ul> <p>2:</p> <ul> <li>current time = 10:00:01</li> <li>start_time = 07:00:12</li> <li>end_time = 22:00:00 Return nothing because is within this interval.</li> </ul>
[ { "answer_id": 74154163, "author": "David", "author_id": 13019276, "author_profile": "https://Stackoverflow.com/users/13019276", "pm_score": 0, "selected": false, "text": "const [total, setTotal] = useState(0);\n\nconst addTotalSum = () => {\n // Logic here for getting the total.\n ...
2022/10/21
[ "https://Stackoverflow.com/questions/74153908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2134910/" ]
74,153,912
<p>My application is working perfectly, but I'm trying to keep my code as simple and clean as possible.</p> <p>I have a Controller that is receiving most of the data automatically, but I have 3 inputs that gonna be added to the request, more specifically,</p> <ul> <li>if the course is active(optional)</li> <li>is highlighted(optional),</li> <li>and the user id.</li> </ul> <p>The first and second are being treated with <code>isset()</code>, and the third is defined by the authenticated user.</p> <p>I would like to know if there is a better way to improve my code and simplify and remove useless lines of code. I have been reading about <code>merge()</code> in the Laravel requests section of the documentation, but I couldn't apply it for some reason. My requests are located in the $data variable, and the course is created at the final by passing this variable to the model Course with method create.</p> <p>The question is: is it possible to remove the $data declaration for the other cases and keep it only for <code>$data['is_active']</code>, <code>$data['is_highlighted']</code> and <code>$data['user_id']</code>, without missing the other parameters?</p> <pre class="lang-php prettyprint-override"><code> public function store(Request $request){ $this-&gt;validate($request, []); try{ $data[&quot;user_id&quot;] = Auth::user()-&gt;id; $data[&quot;name&quot;] = $request-&gt;name; $data[&quot;objectives&quot;] = $request-&gt;objectives; $data[&quot;requirements&quot;] = $request-&gt;requirements; $data[&quot;description&quot;] = $request-&gt;description; $data[&quot;content&quot;] = $request-&gt;content; $data[&quot;duration&quot;] = $request-&gt;duration; $data[&quot;video_link&quot;] = $request-&gt;video_link; $data[&quot;is_active&quot;] = isset($request-&gt;is_active) ? 1 : 0; $data[&quot;is_highlighted&quot;] = isset($request-&gt;is_is_highlighted) ? 1 : 0; $imageName = time().'.'.$request-&gt;image-&gt;extension(); $request-&gt;image-&gt;move(public_path('uploads/images/courses/'), $imageName); $image = Image::create([ 'path' =&gt; ('uploads/images/courses/'.$imageName), 'alt_text' =&gt; $request-&gt;alt ? $request-&gt;alt : $request-&gt;title, ]); $data[&quot;image_id&quot;] = $image-&gt;id; if(isset($request-&gt;is_published)) $data[&quot;published_at&quot;] = Carbon::now()-&gt;toDateTimeString(); $course = Course::create($data); return redirect()-&gt;route('courses.index')-&gt;withMessage(trans('crud.record_created')); </code></pre>
[ { "answer_id": 74154163, "author": "David", "author_id": 13019276, "author_profile": "https://Stackoverflow.com/users/13019276", "pm_score": 0, "selected": false, "text": "const [total, setTotal] = useState(0);\n\nconst addTotalSum = () => {\n // Logic here for getting the total.\n ...
2022/10/21
[ "https://Stackoverflow.com/questions/74153912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19018636/" ]
74,153,915
<p>I have following problem</p> <p>Lets assume there is a library that have two versions</p> <p>Version 1 have declared enum such as this</p> <pre><code>enum colors { RED, GREEN, BLUE } </code></pre> <p>Version 2 looks like this</p> <pre><code>enum colors { RED, GREEN, BLUE, TURQUOISE } </code></pre> <p>What I would like to do is to perform compile time check with preprocessor as to which enum value I can use, which would look something like this</p> <pre><code>#include &lt;colors_library.h&gt; int main() { #if TURQUOISE some_function(TURQUOISE); #else some_function(BLUE); #endif } </code></pre> <p>But so far I no success making it work with neither #if and #ifdef directives</p>
[ { "answer_id": 74153968, "author": "DeiDei", "author_id": 5212827, "author_profile": "https://Stackoverflow.com/users/5212827", "pm_score": -1, "selected": false, "text": "#define COLORS_TURQUOISE 0\n" }, { "answer_id": 74154010, "author": "Jeffrey", "author_id": 4474230,...
2022/10/21
[ "https://Stackoverflow.com/questions/74153915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17526232/" ]
74,153,952
<p>I am extracting the OU value from a csv and getting the DC name from it</p> <pre><code> $TOD_Data= @(Import-Csv -Path &quot;C:\data.csv&quot;) $OU = $TOD_Data.oupath $DC = ($OU -split '(?&lt;![\\]),' | Where-Object { $_ -match '^DC=' }) -join ',' </code></pre> <p>the output I am able to extract the values like below</p> <pre><code>DC=ab,DC=if,DC=csg,DC=net </code></pre> <p>But I need to convert this value like this</p> <pre><code>ab.if.csg.net </code></pre> <p>Please let me know how can I do this</p>
[ { "answer_id": 74153968, "author": "DeiDei", "author_id": 5212827, "author_profile": "https://Stackoverflow.com/users/5212827", "pm_score": -1, "selected": false, "text": "#define COLORS_TURQUOISE 0\n" }, { "answer_id": 74154010, "author": "Jeffrey", "author_id": 4474230,...
2022/10/21
[ "https://Stackoverflow.com/questions/74153952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14177485/" ]
74,153,955
<p>SELECT * from <code>dbfs:/FileStore/shared_uploads/prasanth/Company.csv</code></p> <p>I am trying to select the records from folder in azure data bricks but I am facing this Error <strong>SQL statement: AnalysisException: Table or view not found</strong></p>
[ { "answer_id": 74153968, "author": "DeiDei", "author_id": 5212827, "author_profile": "https://Stackoverflow.com/users/5212827", "pm_score": -1, "selected": false, "text": "#define COLORS_TURQUOISE 0\n" }, { "answer_id": 74154010, "author": "Jeffrey", "author_id": 4474230,...
2022/10/21
[ "https://Stackoverflow.com/questions/74153955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5963105/" ]
74,153,974
<p>I have a dataframe with information about a stock that looks like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Product ID</th> <th>Initial stock</th> <th>Initial unit cost</th> <th>Reference</th> <th>Quantity</th> <th>Unit cost</th> <th>Current stock</th> </tr> </thead> <tbody> <tr> <td>a</td> <td>5</td> <td>22</td> <td>Purch.</td> <td>4</td> <td>24</td> <td>9</td> </tr> <tr> <td>a</td> <td>5</td> <td>22</td> <td>Purch.</td> <td>8</td> <td>21</td> <td>17</td> </tr> <tr> <td>a</td> <td>5</td> <td>22</td> <td>Sale</td> <td>-4</td> <td>25</td> <td>13</td> </tr> <tr> <td>a</td> <td>5</td> <td>22</td> <td>Purch.</td> <td>10</td> <td>20</td> <td>23</td> </tr> <tr> <td>a</td> <td>5</td> <td>22</td> <td>Sale</td> <td>-15</td> <td>22</td> <td>8</td> </tr> <tr> <td>b</td> <td>14</td> <td>3.5</td> <td>Sale</td> <td>10</td> <td>4</td> <td>4</td> </tr> <tr> <td>b</td> <td>14</td> <td>3.5</td> <td>Purch.</td> <td>20</td> <td>3</td> <td>24</td> </tr> <tr> <td>b</td> <td>14</td> <td>3.5</td> <td>Sale</td> <td>5</td> <td>4</td> <td>19</td> </tr> <tr> <td>b</td> <td>14</td> <td>3.5</td> <td>Purch.</td> <td>2</td> <td>3.5</td> <td>21</td> </tr> <tr> <td>c</td> <td>27</td> <td>1</td> <td>Purch.</td> <td>100</td> <td>0.95</td> <td>127</td> </tr> <tr> <td>c</td> <td>27</td> <td>1</td> <td>Purch.</td> <td>3</td> <td>1.1</td> <td>130</td> </tr> </tbody> </table> </div> <p>Each row represents a purchase/sale of a certain product. <code>Quantity</code> represents the number of units purchased/sold at a given <code>Unit cost</code>. <code>Current stock</code> is the remaining stock after the purchase/sale. For every product, I want to calculate the Weighted Average Cost (WAC) after each sale/purchase. The procedure is the following:</p> <ul> <li><p>For the first row of every product, <code>WAC = (Initial stock * Initial unit cost + Quantity * Unit cost) / Current stock</code> just if <code>Reference == 'Purch.'</code>. If not, <code>WAC = Initial unit cost</code>.</p> </li> <li><p>For the next rows, <code>WAC[i] = (Current stock[i-1] * WAC[i-1] + Quantity[i] * Unit cost[i]) / Current stock[i]</code> just if <code>Reference[i] == 'Purch.'</code>. If not, <code>WAC[i] = WAC[i-1]</code>.</p> </li> </ul> <p>The next table shows what I'm looking for (<code>WAC</code> column and how to calculate it):</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Product ID</th> <th>Initial stock</th> <th>Initial unit cost</th> <th>Reference</th> <th>Quantity</th> <th>Unit cost</th> <th>Current stock</th> <th>(how to) WAC</th> <th>WAC</th> </tr> </thead> <tbody> <tr> <td>a</td> <td>5</td> <td>22</td> <td>Purch.</td> <td>4</td> <td>24</td> <td>9</td> <td>(5*22 + 4*24)/9</td> <td>22.89</td> </tr> <tr> <td>a</td> <td>5</td> <td>22</td> <td>Purch.</td> <td>8</td> <td>21</td> <td>17</td> <td>(9*22.89 + 8*21)/17</td> <td>22</td> </tr> <tr> <td>a</td> <td>5</td> <td>22</td> <td>Sale</td> <td>-4</td> <td>25</td> <td>13</td> <td>-</td> <td>22</td> </tr> <tr> <td>a</td> <td>5</td> <td>22</td> <td>Purch.</td> <td>10</td> <td>20</td> <td>23</td> <td>(13*22 + 10*20)/23</td> <td>21.13</td> </tr> <tr> <td>a</td> <td>5</td> <td>22</td> <td>Sale</td> <td>-15</td> <td>22</td> <td>8</td> <td>-</td> <td>21.13</td> </tr> <tr> <td>b</td> <td>14</td> <td>3.5</td> <td>Sale</td> <td>10</td> <td>4</td> <td>4</td> <td>-</td> <td>3.5</td> </tr> <tr> <td>b</td> <td>14</td> <td>3.5</td> <td>Purch.</td> <td>20</td> <td>3</td> <td>24</td> <td>(4*3.5 + 20*3)/24</td> <td>3.08</td> </tr> <tr> <td>b</td> <td>14</td> <td>3.5</td> <td>Sale</td> <td>5</td> <td>4</td> <td>19</td> <td>-</td> <td>3.08</td> </tr> <tr> <td>b</td> <td>14</td> <td>3.5</td> <td>Purch.</td> <td>2</td> <td>3.5</td> <td>21</td> <td>(19*3.08 + 2*3.5)/21</td> <td>3.12</td> </tr> <tr> <td>c</td> <td>27</td> <td>1</td> <td>Purch.</td> <td>100</td> <td>0.95</td> <td>127</td> <td>(27*1 + 100*0.95)/127</td> <td>0.96</td> </tr> <tr> <td>c</td> <td>27</td> <td>1</td> <td>Purch.</td> <td>3</td> <td>1.1</td> <td>130</td> <td>(127*0.96 + 3*1.1)/130</td> <td>0.96</td> </tr> </tbody> </table> </div> <p>How would you do it using Pandas? I've tried to use a groupby and a cumsum, but I don't know how to introduce the &quot;if&quot; statement. After that, I want to summarize the information and just get the <code>Product ID</code> along with the final <code>Stock</code> and <code>WAC</code>, just like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Product ID</th> <th>Current stock</th> <th>WAC</th> </tr> </thead> <tbody> <tr> <td>a</td> <td>8</td> <td>21.13</td> </tr> <tr> <td>b</td> <td>21</td> <td>3.12</td> </tr> <tr> <td>c</td> <td>130</td> <td>0.96</td> </tr> </tbody> </table> </div> <p>Thank you in advance!</p>
[ { "answer_id": 74154236, "author": "R. Baraiya", "author_id": 13888486, "author_profile": "https://Stackoverflow.com/users/13888486", "pm_score": 0, "selected": false, "text": "#Create new columns using lambda function\ndf['(how to)WAC']= df.apply(lambda row: (row['Intial stock']*row['In...
2022/10/21
[ "https://Stackoverflow.com/questions/74153974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20159960/" ]
74,154,050
<p>I am facing a problem with my database. Context: Web application referencing members, where it is possible to import members via an xls file repository, a processing is done to save it in database. I try to execute a command that is supposed to run in the background on the production environment, but on the development environment it must be executed manually, to perform the import of the files that have as states &quot;to import&quot;. Problem during the execution, the command displays that there are driver problems with PDO, it can't find them. Any idea where the problem could come from? You will find here with the detailed errors, as well as the config.yml of the symfony 5 project</p> <pre><code>In AbstractMySQLDriver.php line 128: An exception occurred in driver: could not find driver In Exception.php line 18: could not find driver In PDOConnection.php line 40: could not find driver </code></pre> <pre><code>doctrine: dbal: driver: pdo_mysql host: '%database_host%' port: '%database_port%' dbname: '%database_name%' user: '%database_user%' password: '%database_password%' charset: UTF8 types: phone_number: Misd\PhoneNumberBundle\Doctrine\DBAL\Types\PhoneNumberType server_version: &quot;%doctrine_server_version%&quot; options: 1002: 'SET sql_mode=(SELECT REPLACE(@@sql_mode, &quot;ONLY_FULL_GROUP_BY&quot;, &quot;&quot;))' orm: auto_generate_proxy_classes: '%kernel.debug%' naming_strategy: doctrine.orm.naming_strategy.underscore auto_mapping: true dql: string_functions: MONTH: DoctrineExtensions\Query\Mysql\Month YEAR: DoctrineExtensions\Query\Mysql\Year regexp: DoctrineExtensions\Query\Mysql\Regexp replace: DoctrineExtensions\Query\Mysql\Replace DATE_FORMAT: DoctrineExtensions\Query\Mysql\DateFormat mappings: gedmo_tree: type: annotation prefix: Gedmo\Tree\Entity dir: &quot;%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity&quot; alias: GedmoTree # (optional) it will default to the name set for the mapping is_bundle: false </code></pre>
[ { "answer_id": 74154236, "author": "R. Baraiya", "author_id": 13888486, "author_profile": "https://Stackoverflow.com/users/13888486", "pm_score": 0, "selected": false, "text": "#Create new columns using lambda function\ndf['(how to)WAC']= df.apply(lambda row: (row['Intial stock']*row['In...
2022/10/21
[ "https://Stackoverflow.com/questions/74154050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18746710/" ]
74,154,051
<p>I have a table like below:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ID</th> <th>Date</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>2022-01-01</td> </tr> <tr> <td>2</td> <td>2022-03-21</td> </tr> </tbody> </table> </div> <p>I want to add a new column based on the date and it should look like this</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ID</th> <th>Date</th> <th>NewCol</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>2022-01-01</td> <td>2022-02-01</td> </tr> <tr> <td>1</td> <td>2022-01-01</td> <td>2022-03-01</td> </tr> <tr> <td>1</td> <td>2022-01-01</td> <td>2022-04-01</td> </tr> <tr> <td>1</td> <td>2022-01-01</td> <td>2022-05-01</td> </tr> <tr> <td>2</td> <td>2022-03-21</td> <td>2022-04-21</td> </tr> <tr> <td>2</td> <td>2022-03-21</td> <td>2022-05-21</td> </tr> </tbody> </table> </div> <p>Let's say that there is a <em>@EndDate = 2022-05-31</em> (that's where it should stop)</p> <p>I'm having a hard time trying to figure out how to do it in SSMS. Would appreciate any insights! Thanks :)</p>
[ { "answer_id": 74154274, "author": "Stuck at 1337", "author_id": 20091109, "author_profile": "https://Stackoverflow.com/users/20091109", "pm_score": 0, "selected": false, "text": "DECLARE @endpoint date = '20220531';\n\nDECLARE @prev date = DATEADD(MONTH, -1, @endpoint);\n\nWITH x AS\n(\...
2022/10/21
[ "https://Stackoverflow.com/questions/74154051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20301237/" ]
74,154,055
<p>How do I ignore styling on the top row of my table? I want all rows under the top row to not be red.</p> <pre><code>import styled from 'styled-components' export const StyledTable = styled.table` margin-bottom: 40px; `; export const TR = styled.tr` background-color: red; &amp;:hover { background-color: #EAEAEA; } `; </code></pre> <p>Edit: I want to provide additional clarity. I want to change color of my rows on hover. But not do this on the top row, for example:</p> <p><a href="https://i.stack.imgur.com/LUh6Z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LUh6Z.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74154143, "author": "Mohamad Ahmadi", "author_id": 11039101, "author_profile": "https://Stackoverflow.com/users/11039101", "pm_score": 0, "selected": false, "text": "export const TR = styled.tr`\n background-color: red;\n &:hover {\n background-color: #EAEAEA;...
2022/10/21
[ "https://Stackoverflow.com/questions/74154055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19932692/" ]
74,154,097
<p>I have recently started studying R. Help to make custom signatures on the diagram, as in the second picture.</p> <pre><code>library(tidyverse) data &lt;- data.frame( quarter=c(&quot;Q1&quot;, &quot;Q1&quot;, &quot;Q1&quot;, &quot;Q2&quot;, &quot;Q2&quot;, &quot;Q2&quot;, &quot;Q3&quot;, &quot;Q3&quot;, &quot;Q3&quot;), product=c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;A&quot;, &quot;B&quot;, &quot;C&quot;), profit=c(10, 12, 13, 10, 12, 13, 10, 12, 0) ) p &lt;- ggplot(data, aes(x = quarter, y = profit, fill = product)) + geom_col(position = 'fill') p </code></pre> <p>Fig. 1. <a href="https://i.stack.imgur.com/l1OsT.png" rel="nofollow noreferrer">https://i.stack.imgur.com/l1OsT.png</a> Fig. 2. <a href="https://i.stack.imgur.com/SMr0i.png" rel="nofollow noreferrer">https://i.stack.imgur.com/SMr0i.png</a></p>
[ { "answer_id": 74154143, "author": "Mohamad Ahmadi", "author_id": 11039101, "author_profile": "https://Stackoverflow.com/users/11039101", "pm_score": 0, "selected": false, "text": "export const TR = styled.tr`\n background-color: red;\n &:hover {\n background-color: #EAEAEA;...
2022/10/21
[ "https://Stackoverflow.com/questions/74154097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18073129/" ]
74,154,130
<pre><code>version: &quot;3.7&quot; services: api_service: build: . restart: always ports: - 8080:8080 depends_on: - postgres_db links: - postgres_db:database postgres_db: image: &quot;postgres:11.4&quot; restart: always ports: - 5435:5432 environment: POSTGRES_DB: testDb POSTGRES_PASSWORD: admin </code></pre> <p>this is my YAML file.</p> <p>and I got properties</p> <pre><code>spring.datasource.platform=postgres spring.datasource.url=jdbc:postgresql://database:5432/testDb spring.datasource.username=postgres spring.datasource.password=admin </code></pre> <p>if my Postgres is <code>rds</code> then do I need to compose them or I just can go with Dockerfile for <code>jar</code> only and not YAML file?</p>
[ { "answer_id": 74154143, "author": "Mohamad Ahmadi", "author_id": 11039101, "author_profile": "https://Stackoverflow.com/users/11039101", "pm_score": 0, "selected": false, "text": "export const TR = styled.tr`\n background-color: red;\n &:hover {\n background-color: #EAEAEA;...
2022/10/21
[ "https://Stackoverflow.com/questions/74154130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20240435/" ]
74,154,166
<pre><code>string1 = str(input(&quot;Type a word&quot;)) for i in range(len(string1)): print(string1[-1+i], end= &quot;&quot;) print('') for i in range(len(string1)): print (string1[-2+i] , end= &quot;&quot;) print('') for i in range(len(string1)): print (string1[-3+i] , end= &quot;&quot;) print('') for i in range(len(string1)): print (string1[-4+i] , end= &quot;&quot;) print('') for i in range(len(string1)): print (string1[-5+i] , end= &quot;&quot;) </code></pre> <p>How can I shorten this code? It seems highly inefficient, and I think it could be much much shorter. Also the amount of letters is limited because you have to add another loop for an additional letter. Any help would be much appreciated, thanks.</p>
[ { "answer_id": 74154301, "author": "D Malan", "author_id": 3486675, "author_profile": "https://Stackoverflow.com/users/3486675", "pm_score": -1, "selected": false, "text": "step" }, { "answer_id": 74154354, "author": "ILS", "author_id": 10017662, "author_profile": "ht...
2022/10/21
[ "https://Stackoverflow.com/questions/74154166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20301365/" ]
74,154,172
<p>I was using Prime Vue's tab panel (<a href="https://primefaces.org/primevue/tabview" rel="nofollow noreferrer">https://primefaces.org/primevue/tabview</a>) and I'm trying to render the vue file for each tab content only with a <code>v-for</code> loop. The <code>{{ tab.content }}</code> is an external vue file. Is that possible for me to render the html view of it?</p> <p>This is my code so far:</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;TabView scrollable&gt; &lt;TabPanel v-for="tab in tabs" :key="tab.title"&gt; &lt;template #header&gt; &lt;img :src="tab.src" :width="tab.width" :height="tab.height" /&gt; &lt;span x-style="margin-left: 10px;"&gt;{{ tab.title }}&lt;/span&gt; &lt;/template&gt; &lt;div&gt;{{ tab.content }}&lt;/div&gt; &lt;/TabPanel&gt; &lt;/TabView&gt;</code></pre> </div> </div> </p> <p>I imported the external vue file <code>(CreateEmployee.vue)</code> which is the one that should be rendered. The <code>tabs</code> array is in the script tag 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-html lang-html prettyprint-override"><code>&lt;script setup lang="ts"&gt; import { ref, reactive, onMounted } from 'vue' import * as yup from 'yup' import FormWizard from '@/components/stepper/FormWizard.vue' import FormStep from '@/components/stepper/FormStep.vue' import TabView from 'primevue/tabview' import TabPanel from 'primevue/tabpanel' import { useConfirm } from 'primevue/useconfirm' import KustomerCreateEmployee from '@/views/apps/kustomer/CreateEmployee.vue' let tabs: string[] = reactive([ { src: '/src/assets/apps/logo-1password.svg', width: '30', height: '30', title: '1Password', content: KustomerCreateEmployee }, ]); &lt;/script&gt;</code></pre> </div> </div> </p> <p>And lastly, this is the external vue file that should render on the loop:</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;template&gt; &lt;input type="text" placeholder="Sample" /&gt; &lt;/template&gt;</code></pre> </div> </div> </p> <p>I did try with these code but was only getting this result:</p> <pre><code>{ &quot;__hmrId&quot;: &quot;0429c5db&quot;, &quot;__file&quot;: &quot;/Users/jumarj.multiplymii/Documents/Jumar's Files/Work Related/Projects/Web Development/sandbox/dev-boarding-pass/client/src/views/apps/kustomer/CreateEmployee.vue&quot; } </code></pre> <p>Any help please?</p>
[ { "answer_id": 74154301, "author": "D Malan", "author_id": 3486675, "author_profile": "https://Stackoverflow.com/users/3486675", "pm_score": -1, "selected": false, "text": "step" }, { "answer_id": 74154354, "author": "ILS", "author_id": 10017662, "author_profile": "ht...
2022/10/21
[ "https://Stackoverflow.com/questions/74154172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19578760/" ]
74,154,181
<p>When I compile my code, I get:</p> <pre><code> &quot;src/gameObject.cpp:8:13: error: expected unqualified-id before 'class' GameObject::class Component&amp; getComponent(const std::string &amp;name)&quot; </code></pre> <p>alongside several other errors of a similar type. I'm not sure if the problem has to do with the abstract class or the forward declaration of the class. I have tried troubleshooting for the past day and I cannot for the life of me figure out how to fix this dependency. The intention is for &quot;Components&quot; to contain a pointer that points to the <code>gameObject</code> that they are owned by and for <code>gameObjects</code> to contain a list of different implementations of the Component abstract class. Any help would be appreciated.</p> <p>Here is the code:</p> <p>Component.h</p> <pre><code> #include &lt;iostream&gt; #include &lt;SDL.h&gt; #include &lt;SDL_image.h&gt; #include &lt;string&gt; class GameObject; class Component{ public: GameObject* gameObject; std::string name; virtual void update(const float &amp;dt) = 0; virtual void draw() = 0; virtual void start() = 0; virtual ~Component(); }; </code></pre> <p>GameObject.h</p> <pre><code> #include &lt;iostream&gt; #include &lt;SDL.h&gt; #include &lt;SDL_image.h&gt; #include &lt;vector&gt; #include &lt;string&gt; #include &lt;typeinfo&gt; #include &quot;Transform.h&quot; class GameObject{ public: Transform transform; GameObject(const std::string &amp;name, const Transform &amp;transform); class Component&amp; getComponent(const std::string &amp;name); void addComponent(const class Component &amp;c); std::vector&lt;class Component&gt; getAllComponents(); class Component&amp; removeComponent(const std::string &amp;name); void update(const float &amp;dt); private: std::vector&lt;class Component&gt; components; std::string name; }; </code></pre> <p>gameObject.cpp</p> <pre><code>#include &quot;Component.h&quot; GameObject::GameObject(const std::string &amp;name, const Transform &amp;transform) :name(name), transform(transform) {} GameObject::class Component&amp; getComponent(const std::string &amp;name) { for(Component&amp; c : components) { if(c.name == name) return c; else return nullptr; } } GameObject::void addComponent(const Component &amp;c) { components.push_back(c); c.gameObject = this; } GameObject::class Component&amp; removeComponent(const std::string &amp;name) { for (int i = 0; i &lt; components.size(); i++) { if(components[i].name == name) components.erase(i); } GameObject::std::vector&lt;class Component&gt; getAllComponents() { return components; } GameObject::void update(const float &amp;dt) { for(Component c : components) { c.update(dt); } } </code></pre>
[ { "answer_id": 74154326, "author": "user17732522", "author_id": 17732522, "author_profile": "https://Stackoverflow.com/users/17732522", "pm_score": 1, "selected": false, "text": "class" }, { "answer_id": 74154344, "author": "Jason Liam", "author_id": 12002570, "author...
2022/10/21
[ "https://Stackoverflow.com/questions/74154181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20269741/" ]
74,154,209
<p>Every time when I try to extend the abtract class <code>Command</code> and I try to compile I get the error: <code>Error: Cannot find module 'src/classes/commandBase'</code></p> <p>My project has the following structure:</p> <pre><code> ├────tsconfig.json └────src ├───classes │ └───commandBase.ts ├───commands │ └───ping.ts ├───handlers ├───listeners └───models </code></pre> <p>commandBase.ts</p> <pre><code>abstract class Command { name: string; abstract execute(client: Client, message: Message, args: string[]): void; constructor(name: string) { this.name = name; } } export default Command; </code></pre> <p>ping.ts</p> <pre><code>import Command from &quot;src/classes/commandBase&quot;; class Ping extends Command { constructor() { super(&quot;ping&quot;); } async execute( client: Client, message: Message, args: string[] ): Promise&lt;void&gt; { // ... } } export default Ping; </code></pre> <p>tsconfig.json</p> <pre><code>{ &quot;compilerOptions&quot;: { &quot;target&quot;: &quot;ESNext&quot;, &quot;module&quot;: &quot;CommonJS&quot;, &quot;rootDir&quot;: &quot;./src/&quot;, &quot;outDir&quot;: &quot;./dist/&quot;, &quot;strict&quot;: true, &quot;moduleResolution&quot;: &quot;node&quot;, &quot;importHelpers&quot;: true, &quot;experimentalDecorators&quot;: true, &quot;esModuleInterop&quot;: true, &quot;skipLibCheck&quot;: true, &quot;allowSyntheticDefaultImports&quot;: true, &quot;resolveJsonModule&quot;: true, &quot;forceConsistentCasingInFileNames&quot;: true, &quot;removeComments&quot;: true, &quot;typeRoots&quot;: [&quot;node_modules/@types&quot;], &quot;sourceMap&quot;: true, &quot;baseUrl&quot;: &quot;.&quot;, &quot;paths&quot;: {} }, &quot;include&quot;: [&quot;./**/**/*.ts&quot;], &quot;exclude&quot;: [&quot;node_modules&quot;, &quot;dist&quot;] } </code></pre> <hr /> <h2>However</h2> <p>If I change <code>import Command from &quot;src/classes/commandBase&quot;;</code> to <code>import Command from &quot;../classes/commandBase&quot;;</code> everything is <strong>working fine</strong>, no errors appear. The thing is I use autocompletion (VS Code) and everytime I import &quot;Command&quot; it automatically writes <code>&quot;src/classes/commandBase&quot;;</code></p> <p>Another thing is if I create a new file which doesnt extend Command but imports it everything is also working as intended. So I am very confused about this behavior.</p> <p>File foo.ts</p> <pre><code>import Command from &quot;src/classes/commandBase&quot;; const foo: Command = { name: &quot;&quot;, execute: function (client: Client, message: Message, args: string[]): void { throw new Error(&quot;Function not implemented.&quot;); } } </code></pre>
[ { "answer_id": 74154326, "author": "user17732522", "author_id": 17732522, "author_profile": "https://Stackoverflow.com/users/17732522", "pm_score": 1, "selected": false, "text": "class" }, { "answer_id": 74154344, "author": "Jason Liam", "author_id": 12002570, "author...
2022/10/21
[ "https://Stackoverflow.com/questions/74154209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11985806/" ]
74,154,264
<p>I have two object arrays. One is main array and another one is temp array. I need to compare main array with temp array and based on matching id, I have update the value in the main array from temp array.</p> <p>For example, id 2 &amp; 3 is matching in both the arrays. So I need to update value in the main array from temp array.</p> <pre><code>// Main array this.MyArray = [ { id: &quot;0&quot;, value: &quot;Car&quot; }, { id: &quot;1&quot;, value: &quot;Bike&quot; }, { id: &quot;2&quot;, value: &quot;Train&quot; }, { id: &quot;3&quot;, value: &quot;Bus&quot; }, { id: &quot;4&quot;, value: &quot;Van&quot; } ] // temp array this.tempArray =[ { id: &quot;2&quot;, value: &quot;Car&quot; }, { id: &quot;3&quot;, value: &quot;Jet&quot; }, ] //Expected Output in the Main array: this.MyArray = [ { id: &quot;0&quot;, value: &quot;Car&quot; }, { id: &quot;1&quot;, value: &quot;Bike&quot; }, { id: &quot;2&quot;, value: &quot;Car&quot; }, { id: &quot;3&quot;, value: &quot;Jet&quot; }, { id: &quot;4&quot;, value: &quot;Van&quot; } ] </code></pre>
[ { "answer_id": 74154667, "author": "Max Lysenko", "author_id": 13845709, "author_profile": "https://Stackoverflow.com/users/13845709", "pm_score": 3, "selected": true, "text": "this.myArray = this.myArray.map((mainObject) => {\n const tempObject = this.tempArray.find((tempObject) => tem...
2022/10/21
[ "https://Stackoverflow.com/questions/74154264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3881070/" ]
74,154,294
<p>I'm learning python, and I have a simple question. I have a file, and I need to read it, the file contains a header, and its divided by the size of the structures in the file, and the top of the pile, like this:</p> <pre><code>size=86 top=-1 </code></pre> <p>so far, I only read the line, and it's working</p> <pre><code>def readinput(input): line = [] line = input1.readline() print(line) with open(sys.argv[1],'r') as input1: readinput(input1) </code></pre> <p>That's it, can you help me to get the size and the top in the header?</p>
[ { "answer_id": 74154667, "author": "Max Lysenko", "author_id": 13845709, "author_profile": "https://Stackoverflow.com/users/13845709", "pm_score": 3, "selected": true, "text": "this.myArray = this.myArray.map((mainObject) => {\n const tempObject = this.tempArray.find((tempObject) => tem...
2022/10/21
[ "https://Stackoverflow.com/questions/74154294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20301403/" ]
74,154,299
<p>I have two dataframes as follows:</p> <pre><code>df1 Year Column1 Column2 Column3 2022 1 2 3 2022 5 7 9 df2 Year Column1 Column4 Column5 2022 1 2 4 </code></pre> <p>What I want to achieve is that in df2, I want to detect the missing columns (in this case it would be <code>Column2</code> and <code>Column3</code> and fill <code>0</code>) So my <code>df2</code> would ultimately look like:</p> <pre><code>df2 Year Column1 Column4 Column5 Column2 Column3 2022 1 2 4 0 0 </code></pre> <p>How do I achieve this? I tried <code>map</code> but wasnt able to get it to work. Thanks!</p>
[ { "answer_id": 74154366, "author": "scotscotmcc", "author_id": 15804190, "author_profile": "https://Stackoverflow.com/users/15804190", "pm_score": 1, "selected": true, "text": "for col in df1.columns:\n if col not in df2.columns:\n df2[col] = 0\n" }, { "answer_id": 7415...
2022/10/21
[ "https://Stackoverflow.com/questions/74154299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6075349/" ]
74,154,325
<p>We are in the process of upgrading our React v17 app to v18. Currently we use react-app-polyfill as well as bowser to check if users are using a supported browser, and show a simple alert if they aren't. The app doesn't work properly on IE11 but the alert at least appears.</p> <p>Now that we don't have any specific requirements to support IE11 it would be nice to remove the polyfill dependency, but obviously nothing within the React app will render without it, alert included. Aside from the hacky solution of hardcoding text into the index.html root div, does anyone have a simple way of notifying users of a) IE11 and / or b) any unsuitable browser that their browser is not supported?</p>
[ { "answer_id": 74154452, "author": "Valentin", "author_id": 1654241, "author_profile": "https://Stackoverflow.com/users/1654241", "pm_score": 3, "selected": true, "text": "<script>" }, { "answer_id": 74154482, "author": "T.J. Crowder", "author_id": 157247, "author_pro...
2022/10/21
[ "https://Stackoverflow.com/questions/74154325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8607541/" ]
74,154,337
<p>I want to select one specific element of a column of lists based on another columns cell value in a Pandas Dataframe.</p> <pre><code> list_column value 0 [a, b, c] 0 1 [a, b, c] 2 2 [a, b, c] 1 </code></pre> <p>so the desired output will be:</p> <pre><code> list_column value selected 0 [a, b, c] 0 a 1 [a, b, c] 2 c 2 [a, b, c] 1 b </code></pre> <p>I tried using the <code>df[&quot;selected&quot;] = df['list'].str[df[&quot;value&quot;]]</code> but was not managing to apply this correctly.</p>
[ { "answer_id": 74154452, "author": "Valentin", "author_id": 1654241, "author_profile": "https://Stackoverflow.com/users/1654241", "pm_score": 3, "selected": true, "text": "<script>" }, { "answer_id": 74154482, "author": "T.J. Crowder", "author_id": 157247, "author_pro...
2022/10/21
[ "https://Stackoverflow.com/questions/74154337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20301408/" ]
74,154,343
<p>I have a large data.frame that looks like this. I want to group by data.frame based on tissue and for each tissue to create a list</p> <pre class="lang-r prettyprint-override"><code>library(tidyverse) df &lt;- tibble(tissue=c(&quot;A&quot;,&quot;A&quot;,&quot;B&quot;,&quot;B&quot;), genes=c('CD79B','CD79A','CD19','CD180')) df #&gt; # A tibble: 4 × 2 #&gt; tissue genes #&gt; &lt;chr&gt; &lt;chr&gt; #&gt; 1 A CD79B #&gt; 2 A CD79A #&gt; 3 B CD19 #&gt; 4 B CD180 </code></pre> <p><sup>Created on 2022-10-21 with <a href="https://reprex.tidyverse.org" rel="nofollow noreferrer">reprex v2.0.2</a></sup></p> <p>I want my data to look like this</p> <pre><code>#&gt; # A tibble: 2 × 1 #&gt; tissue genes #&gt; &lt;chr&gt; &lt;chr&gt; #&gt; 1 A CD79B #&gt; 2 A CD79A #&gt; #&gt; [[2]] #&gt; # A tibble: 2 × 1 #&gt; tissue genes #&gt; &lt;chr&gt; &lt;chr&gt; #&gt; 1 B CD19 #&gt; 2 B CD180 </code></pre> <p>What have I tried so far? I have used <code>group_map</code> but I am missing the tissue column!</p> <pre class="lang-r prettyprint-override"><code>library(tidyverse) df &lt;- tibble(tissue=c(&quot;A&quot;,&quot;A&quot;,&quot;B&quot;,&quot;B&quot;), genes=c('CD79B','CD79A','CD19','CD180')) df1 &lt;- df |&gt; group_by(tissue) |&gt; group_map(~.) df1 #&gt; [[1]] #&gt; # A tibble: 2 × 1 #&gt; genes #&gt; &lt;chr&gt; #&gt; 1 CD79B #&gt; 2 CD79A #&gt; #&gt; [[2]] #&gt; # A tibble: 2 × 1 #&gt; genes #&gt; &lt;chr&gt; #&gt; 1 CD19 #&gt; 2 CD180 </code></pre> <p><sup>Created on 2022-10-21 with <a href="https://reprex.tidyverse.org" rel="nofollow noreferrer">reprex v2.0.2</a></sup></p> <p>Any help or guidance are appreciated</p>
[ { "answer_id": 74154421, "author": "Megazord", "author_id": 8116399, "author_profile": "https://Stackoverflow.com/users/8116399", "pm_score": 2, "selected": false, "text": "split()" }, { "answer_id": 74154569, "author": "Matt", "author_id": 12967938, "author_profile":...
2022/10/21
[ "https://Stackoverflow.com/questions/74154343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7179299/" ]
74,154,351
<p>I have SharedPreferencesHelper class where I stored simple data that I need. I came across an issue. I need to store 3-4 strings in the list in shared preferences. How can I do the setter and getter for it?</p> <p>SharedPreferencesHelper class:</p> <pre><code>class SharedPreferencesHelper { static SharedPreferences? _preferences; Future&lt;void&gt; init() async { _preferences ??= await SharedPreferences.getInstance(); } String get username =&gt; _preferences?.getString(keyUsername) ?? ''; set username(String value) { _preferences?.setString(keyUsername, value); } // get aliases List&lt;String&gt;? get aliases =&gt; _preferences?.getStringList(keyAliases); // set aliases } </code></pre>
[ { "answer_id": 74154421, "author": "Megazord", "author_id": 8116399, "author_profile": "https://Stackoverflow.com/users/8116399", "pm_score": 2, "selected": false, "text": "split()" }, { "answer_id": 74154569, "author": "Matt", "author_id": 12967938, "author_profile":...
2022/10/21
[ "https://Stackoverflow.com/questions/74154351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19531945/" ]
74,154,388
<p>I have a dataframe for inventory like the following,</p> <pre><code>tidx = pd.date_range('2022-10-01', periods=15, freq='D') data_frame = pd.DataFrame(1, columns=['inventory'], index=tidx) data_frame.iloc[-2:] = 0 print(data_frame) inventory 2022-10-01 1 2022-10-02 1 2022-10-03 1 2022-10-04 1 2022-10-05 1 2022-10-06 1 2022-10-07 1 2022-10-08 1 2022-10-09 1 2022-10-10 1 2022-10-11 1 2022-10-12 1 2022-10-13 1 2022-10-14 0 2022-10-15 0 </code></pre> <p>I want to aggregate for 7 days from any day of the week (here <code>2020-10-15</code>). If I do the following, I don't know why the results start from <code>2020-10-13</code></p> <pre><code>data_frame.resample(&quot;7D&quot;, closed = 'right', origin='2020-10-15').sum() inventory 2022-09-29 6 2022-10-06 7 2022-10-13 0 </code></pre> <p>My desired output is,</p> <pre><code>inventory 2022-09-01 1 2022-10-08 7 2022-10-15 5 </code></pre> <p><strong>Note:</strong> My panda's version is '1.3.5'</p>
[ { "answer_id": 74154917, "author": "Phoenix", "author_id": 10178162, "author_profile": "https://Stackoverflow.com/users/10178162", "pm_score": 0, "selected": false, "text": "data_frame.resample(\"W-SAT\", closed = 'right').sum()\n\ninventory\n2022-10-01 1\n2022-10-08 7\n2022-10-15 5\n...
2022/10/21
[ "https://Stackoverflow.com/questions/74154388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10178162/" ]
74,154,394
<p>I have an array of products amount, and another array of products ID's.</p> <p>I'm trying to do something like this:</p> <pre><code>arrayOfAmount = [2,3,4] arrayOfId = [1,2,3] </code></pre> <p>resulting the third array of ID's:</p> <pre><code>arrayOfProducts = [1,1,2,2,2,3,3,3,3] </code></pre> <p>how can I do that?</p> <p>thank you in advance!</p>
[ { "answer_id": 74154917, "author": "Phoenix", "author_id": 10178162, "author_profile": "https://Stackoverflow.com/users/10178162", "pm_score": 0, "selected": false, "text": "data_frame.resample(\"W-SAT\", closed = 'right').sum()\n\ninventory\n2022-10-01 1\n2022-10-08 7\n2022-10-15 5\n...
2022/10/21
[ "https://Stackoverflow.com/questions/74154394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19534178/" ]
74,154,429
<p>I have these tables:</p> <p><strong>tblPart</strong></p> <pre><code>ID, field1, field2, ecc </code></pre> <p><strong>tblUserFreeProperty</strong></p> <pre><code>ID_tblPart, ID, identname, val </code></pre> <p>I need to write a query to update <code>tblUserFreeProperty</code>, but only the val filed when <code>tblPart.ID = tblUserFreeProperty.ID</code> and <code>identname</code> has a specific value.</p> <p>In the database, <code>identname</code> has one of 8 possible values, and I need to update all of them.</p> <p>I have wrote a query for only one value at time:</p> <pre><code>UPDATE tblUserFreeProperty SET val = N'??_??@True;' FROM tblUserFreeProperty LEFT OUTER JOIN tblPart ON tblUserFreeProperty.id = tblPart.id WHERE tblUserFreeProperty.id = N'3' AND (tblUserFreeProperty.identname = N'DSR_Mag.Gestito') </code></pre> <p>Is there a way to write the update query for all 8 different values at the same time?</p> <p>Added explanation: I need a query like this:</p> <pre><code>UPDATE tblUserFreeProperty SET val1 = N'??_??@True;, val2 = N'??_??@False;', val3 = N'5', val4 = N'BK',...val8 FROM tblUserFreeProperty LEFT OUTER JOIN tblPart ON tblUserFreeProperty.id = tblPart.id WHERE (tblUserFreeProperty.id = N'3' AND (tblUserFreeProperty.identname = N'DSR_Mag.Gestito'))-&gt;SET Val1 OR (tblUserFreeProperty.id = N'3' AND (tblUserFreeProperty.identname = N'DSR_Mag.Done'))-&gt;SET Val2 OR (tblUserFreeProperty.id = N'3' AND (tblUserFreeProperty.identname = N'Something Else'))-&gt;SET val3 </code></pre> <p>I hope it is more clear</p>
[ { "answer_id": 74154917, "author": "Phoenix", "author_id": 10178162, "author_profile": "https://Stackoverflow.com/users/10178162", "pm_score": 0, "selected": false, "text": "data_frame.resample(\"W-SAT\", closed = 'right').sum()\n\ninventory\n2022-10-01 1\n2022-10-08 7\n2022-10-15 5\n...
2022/10/21
[ "https://Stackoverflow.com/questions/74154429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5575430/" ]
74,154,453
<p>I have a simple question, say I have the following json</p> <pre><code>{ &quot;ALPHA&quot;:[ .... ], &quot;BETA&quot;:[ .... ], &quot;GAMMA&quot;:[ ..... ] } </code></pre> <p>how do I access the subroot elements, I mean just the names: <code>&quot;ALPHA&quot;,&quot;BETA&quot;,&quot;GAMMA&quot; </code>using jsonPath? <strong>Be aware that I mean their names not their array!!!</strong></p> <p>I tried <code>jsonPath(&quot;$[*]&quot;, ...)</code> but it doesn't work, any sugesstions?</p>
[ { "answer_id": 74154917, "author": "Phoenix", "author_id": 10178162, "author_profile": "https://Stackoverflow.com/users/10178162", "pm_score": 0, "selected": false, "text": "data_frame.resample(\"W-SAT\", closed = 'right').sum()\n\ninventory\n2022-10-01 1\n2022-10-08 7\n2022-10-15 5\n...
2022/10/21
[ "https://Stackoverflow.com/questions/74154453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5029103/" ]
74,154,455
<p>I am developping a dashboard using dash. The user can select different parameters and a dataframe is updated (6 parameters).</p> <p>The idea was to do :</p> <pre><code>filtering = [] if len(filter1)&gt;0: filtering.append(&quot;df['col1'].isin(filter1)&quot;) if len(filter2)&gt;0: filtering.append(&quot;df['col2'].isin(filter2)&quot;) condition = ' &amp; '.join(filtering) df.loc[condition] </code></pre> <p>But I have a key error, what i understand, as condition is a string. Any advice on how I can do it ? What is the best practise ?</p> <p>NB : I have a solution with <code>if</code> condition but I would like to maximise this part, avoiding the copy of the dataframe (&gt;10 millions of rows).</p> <pre><code>dff = df.copy() if len(filter1)&gt;0: dff = dff.loc[dff.col1.isin(filter1)] if len(filter2)&gt;0: dff = dff.loc[dff.col2.isin(filter2)] </code></pre>
[ { "answer_id": 74154917, "author": "Phoenix", "author_id": 10178162, "author_profile": "https://Stackoverflow.com/users/10178162", "pm_score": 0, "selected": false, "text": "data_frame.resample(\"W-SAT\", closed = 'right').sum()\n\ninventory\n2022-10-01 1\n2022-10-08 7\n2022-10-15 5\n...
2022/10/21
[ "https://Stackoverflow.com/questions/74154455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1845261/" ]
74,154,463
<p>I have a list:</p> <pre><code>num = ['9', '9', '2', '3'] </code></pre> <p>So, how do i get a number 9923, for example in a variable?</p>
[ { "answer_id": 74154487, "author": "Hunter Boyd", "author_id": 12945274, "author_profile": "https://Stackoverflow.com/users/12945274", "pm_score": 2, "selected": true, "text": "n = ''.join(num)\nn = int(n)\nprint(n)\n" }, { "answer_id": 74154505, "author": "Ryno_XLI", "au...
2022/10/21
[ "https://Stackoverflow.com/questions/74154463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18692348/" ]
74,154,466
<p>I want to make a screen with buttons responsively, these buttons are square, they should be next to each other, but as soon as the line breaks they should start on the left side, but always stay in the center. I'm using bootstrap-5, but I don't know how to do that. I tried with flex-box.</p> <p><a href="https://i.stack.imgur.com/Ta9og.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ta9og.png" alt="enter image description here" /></a></p> <p>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-css lang-css prettyprint-override"><code>.box { height: 65px; width: 60px; background: black; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!doctype html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;title&gt;Bootstrap demo&lt;/title&gt; &lt;link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous"&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="d-flex flex-wrap gap-4 w-50 border border-primary"&gt; &lt;div class="box"&gt; &lt;/div&gt; &lt;div class="box"&gt; &lt;/div&gt; &lt;div class="box"&gt; &lt;/div&gt; &lt;div class="box"&gt; &lt;/div&gt; &lt;div class="box"&gt; &lt;/div&gt; &lt;div class="box"&gt; &lt;/div&gt; &lt;div class="box"&gt; &lt;/div&gt; &lt;/div&gt; &lt;script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74154713, "author": "Remco Kersten", "author_id": 13029349, "author_profile": "https://Stackoverflow.com/users/13029349", "pm_score": 3, "selected": true, "text": "mx-auto" }, { "answer_id": 74154970, "author": "Ali Hamed", "author_id": 20277138, "autho...
2022/10/21
[ "https://Stackoverflow.com/questions/74154466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20061059/" ]
74,154,477
<pre class="lang-py prettyprint-override"><code>html = 'https://en.wikipedia.org/wiki/List_of_largest_banks' html_data = requests.get('https://en.wikipedia.org/wiki/List_of_largest_banks') html_data_text = html_data.text soup = bs(html_data_text, 'html.parser') table = soup.find_all('table', {id : &quot;By_market_capitalization&quot;}) print(table) </code></pre> <p>returns empty bracket. I have to only use BS for this assignment. I've seen other libraries help but i can't use them. Any idea whats going wrong with trying to get this table?</p>
[ { "answer_id": 74154632, "author": "0stone0", "author_id": 5625547, "author_profile": "https://Stackoverflow.com/users/5625547", "pm_score": 1, "selected": false, "text": "findNext()" }, { "answer_id": 74154689, "author": "Adithyapranav Gupta Kolluru", "author_id": 198867...
2022/10/21
[ "https://Stackoverflow.com/questions/74154477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20301563/" ]
74,154,491
<p>I want to send a File in my request using React Js, but I am unable to append file in object of FormData using typescript. Here's my React Js Code</p> <pre><code> const [imageFile, setImageFile] = React.useState(); const [productImageMutation, productImageMutationResult]=useAddProductImageMutation(); const handleUploadClick = (e: any) =&gt; { var file = e.target.files[0]; setImageFile(file); }; const handleOnSubmit = (values: Picture) =&gt; { const formData = new FormData(); formData.append(&quot;formFile&quot;, imageFile); //It Gives Error there. productImageMutation({ data: formData}); }; </code></pre> <p><a href="https://i.stack.imgur.com/OusZ6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OusZ6.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74154530, "author": "Ali Faiz", "author_id": 15280808, "author_profile": "https://Stackoverflow.com/users/15280808", "pm_score": 0, "selected": false, "text": "const [imageFile, setImageFile] = React.useState('');\n" }, { "answer_id": 74154683, "author": "Dulaj...
2022/10/21
[ "https://Stackoverflow.com/questions/74154491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12554672/" ]
74,154,533
<p>In Snowflake, how do I define a custom sorting order.</p> <pre><code>ID Language Text 0 ENU a 0 JPN b 0 DAN c 1 ENU d 1 JPN e 1 DAN f 2 etc... </code></pre> <p>here I want to return all rows sorted by Language in this order: Language = ENU comes first, then JPN and lastly DAN.</p> <p>Is this even possible?</p> <p>I would like to order by language, in this order: ENU, JPN, DNA, and so on: ENU, JPN, DNA,ENU,JPN, DAN,ENU, JPN, DAN</p> <p>NOT: ENU,ENU,ENU,JPN,JPN,JPN,DAN,DAN,DAN</p>
[ { "answer_id": 74155321, "author": "Rajat", "author_id": 9947159, "author_profile": "https://Stackoverflow.com/users/9947159", "pm_score": 1, "selected": false, "text": "array_position" }, { "answer_id": 74155818, "author": "Gokhan Atil", "author_id": 12550965, "autho...
2022/10/21
[ "https://Stackoverflow.com/questions/74154533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3461502/" ]
74,154,549
<p>I have a data frame that has a column with unique names and then another column that has factors/char (can do either). I want to be able to filter out duplicate names and IF one of the duplicates has a certain value for a factor I want to keep that one, if there are two duplicates with the same factor, then I don't care which one it keeps.</p> <pre><code> Name Status 1. John A 2. John B 3. Sally A 4. Alex A 5. Sarah B 6. Joe A 7. Joe A 8. Sue B 9. Sue B </code></pre> <p>I want to keep the duplicate if the factor/char is set to B. If there are two As or two Bs I don't care which one it keeps.</p> <p>This is the result I want:</p> <pre><code>1. John B 2. Sally A 3. Alex A 4. Sarah B 5. Joe A 6. Sue B </code></pre> <p>I have tried the following but it's still keeping both A and B for John:</p> <pre><code>Name &lt;- c(&quot;John&quot;,&quot;John&quot;,&quot;Sally&quot;,&quot;Alex&quot;, &quot;Sarah&quot;, &quot;Joe&quot;, &quot;Joe&quot;, &quot;Sue&quot;, &quot;Sue&quot;) Status &lt;- c('A', 'B', 'A', 'A', 'B', 'A', 'A', 'B', 'B') df_reddit &lt;- data.frame(Name,Status) df_reddit[, 'Status'] &lt;- as.factor(df_reddit[, 'Status']) df_reddit$Status &lt;- factor(df_reddit$Status, levels = c(&quot;A&quot;, &quot;B&quot;)) df_reddit &lt;- df_reddit[order(df_reddit$Status),] df_reddit[!duplicated(df_reddit[,c('Name')]),] </code></pre> <p>Any help is appreciated! Would a loop or something be better for this?</p>
[ { "answer_id": 74154643, "author": "Matt", "author_id": 12967938, "author_profile": "https://Stackoverflow.com/users/12967938", "pm_score": 2, "selected": true, "text": "dplyr" }, { "answer_id": 74154781, "author": "stefan", "author_id": 12993861, "author_profile": "h...
2022/10/21
[ "https://Stackoverflow.com/questions/74154549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20113373/" ]
74,154,551
<p>I want to make a button that makes the download of a DataTable object using an HTTP request. I already have this code that can print .xls files by changing the contentType as indicated in comment. However, this does not work with xlsx file.</p> <pre><code> private void DownloadExcel(DataSet ds, string excelFileNameNowDateTime) { System.IO.StringWriter tw = new System.IO.StringWriter(); ; System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw); System.Web.UI.WebControls.DataGrid dgGrid = new System.Web.UI.WebControls.DataGrid(); dgGrid.DataSource = ds.Tables[0]; // Get the HTML for the control. dgGrid.HeaderStyle.Font.Bold = false; dgGrid.DataBind(); dgGrid.RenderControl(hw); string contentType = &quot;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet&quot;; //string contentType = &quot;application/vnd.ms-excel&quot;; Response.ContentType = contentType; this.EnableViewState = true; Response.Clear(); //Response.ContentEncoding = System.Text.Encoding.Default; Response.AddHeader(&quot;content-disposition&quot;, String.Format(@&quot;attachment; filename={0}&quot;, excelFileNameNowDateTime + &quot;.xlsx&quot;)); Response.Write(tw.ToString()); CloseHTTPResponse(); } </code></pre> <p>While opening the file is giving me the error</p> <blockquote> <p>Excel cannot open the file .xlsx because the file format is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.</p> </blockquote> <p>Any idea on why this does not work?</p>
[ { "answer_id": 74179387, "author": "Panagiotis Kanavos", "author_id": 134204, "author_profile": "https://Stackoverflow.com/users/134204", "pm_score": 1, "selected": false, "text": "XLSX" }, { "answer_id": 74207726, "author": "federico", "author_id": 11557579, "author_...
2022/10/21
[ "https://Stackoverflow.com/questions/74154551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11557579/" ]
74,154,558
<p>Because of the error, I cannot drop the duplicates using following code:</p> <pre><code>cc.drop_duplicates(subset=&quot;StateAbb&quot;) </code></pre> <p>How can I sole the issue?</p>
[ { "answer_id": 74179387, "author": "Panagiotis Kanavos", "author_id": 134204, "author_profile": "https://Stackoverflow.com/users/134204", "pm_score": 1, "selected": false, "text": "XLSX" }, { "answer_id": 74207726, "author": "federico", "author_id": 11557579, "author_...
2022/10/21
[ "https://Stackoverflow.com/questions/74154558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19562955/" ]
74,154,573
<p>Just to implement a custom Batch Configuration for Spring Batch 5, following the official documentation on <a href="https://spring.io/blog/2022/09/22/spring-batch-5-0-0-m6-and-4-3-7-are-out" rel="nofollow noreferrer">Blog: Spring Batch 5 Milestone 6</a> and <a href="https://docs.spring.io/spring-batch/docs/5.0.0-M8/api/org/springframework/batch/core/configuration/support/DefaultBatchConfiguration.html" rel="nofollow noreferrer">JavaDoc Spring Batch 5 Milestone 8</a>, I wrote this code, using Spring Batch 5 via Spring Boot 3 RC1:</p> <pre><code> @Configuration class MyBatchConfiguration extends DefaultBatchConfiguration { @Override protected DataFieldMaxValueIncrementerFactory getIncrementerFactory() { return new MyDataFieldMaxValueIncrementerFactory(); } } </code></pre> <p>But I only get an error about my <code>MyBatchConfiguration#jobRepository</code> Bean, illegally overriding the <code>JobRepositoryFactoryBean#jobRepository</code> Bean. Which is weird, because <code>JobRepositoryFactoryBean</code> has no <code>jobRepository</code>.</p> <p>Does anyone know how to solve this?</p> <p>Error: <br>ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'jobRepository' defined in class path resource [my/package/MyBatchConfiguration.class]: @Bean definition illegally overridden by existing bean definition: Generic bean: class [org.springframework.batch.core.repository.support.JobRepositoryFactoryBean]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodNames=null; destroyMethodNames=null</p> <p>Edit: I built a demo project under <a href="https://github.com/JD-CSTx/SpringBatchBugJobRepo" rel="nofollow noreferrer">https://github.com/JD-CSTx/SpringBatchBugJobRepo</a>.</p>
[ { "answer_id": 74179387, "author": "Panagiotis Kanavos", "author_id": 134204, "author_profile": "https://Stackoverflow.com/users/134204", "pm_score": 1, "selected": false, "text": "XLSX" }, { "answer_id": 74207726, "author": "federico", "author_id": 11557579, "author_...
2022/10/21
[ "https://Stackoverflow.com/questions/74154573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1534698/" ]
74,154,595
<p>TLDR Question:</p> <pre><code>class MyClass { public: void Modify() { //How can I modify MyData here } public: static const int* const MyData; }; </code></pre> <p>Lore:</p> <p>I have a class like this:</p> <pre><code>class Window { public: const int* GetKeyboard() { return m_Keyboard; } private: const int* const m_Keyboard = 0; }; </code></pre> <p>With this I would access keyboard as <code>WindowObjectPtr-&gt;GetKeyboard()</code> but I want to access it as <code>Input::Keyboard</code>. So I wrote something like this:</p> <pre><code>class Window { public: const int* GetKeyboard() { return m_Keyboard; } private: const int* const m_Keyboard = 0; }; const int* Input::Keyboard = 0; class Application; class Input { friend class Application; private: static void SetKeyboard(const int* k) { Keyboard = k; } public: static const int* Keyboard; }; class Application { public: void Init() { Input::SetKeyboard(m_Window.GetKeyboard()); } private: Window m_Window; }; int main() { Application application; application.Init(); //Input::Keyboard } </code></pre> <p>The only problem with the above code is that I can do Input::Keyboaord = nullptr;</p> <p>So I want to change definition of keyboard to <code>static const int* const Keyboard;</code> but then <code>Input::SetKeyboard</code> cannot set it anymore.</p> <p>Is there a valid version of something like <code>mutable static const int* const Keyboard;</code> ? or a different method of achieving what I am trying to do?</p>
[ { "answer_id": 74154817, "author": "user17732522", "author_id": 17732522, "author_profile": "https://Stackoverflow.com/users/17732522", "pm_score": 3, "selected": true, "text": "const" }, { "answer_id": 74154877, "author": "463035818_is_not_a_number", "author_id": 4117728...
2022/10/21
[ "https://Stackoverflow.com/questions/74154595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15991365/" ]
74,154,604
<p>Note: Do guide me if something is missing.</p> <p>So, I wanted to install a package from <a href="https://rnfirebase.io/auth/usage" rel="nofollow noreferrer">https://rnfirebase.io/auth/usage</a>, but I have an npm project. The command on the website has only for yarn. I don't want to add yarn to project because (<a href="https://stackoverflow.com/questions/49589493/is-there-any-harm-in-using-npm-and-yarn-in-the-same-project">Is there any harm in using NPM and Yarn in the same project?</a>) it states that it is not recommended.</p> <p>So, then how do I install it with npm?</p>
[ { "answer_id": 74154817, "author": "user17732522", "author_id": 17732522, "author_profile": "https://Stackoverflow.com/users/17732522", "pm_score": 3, "selected": true, "text": "const" }, { "answer_id": 74154877, "author": "463035818_is_not_a_number", "author_id": 4117728...
2022/10/21
[ "https://Stackoverflow.com/questions/74154604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19661579/" ]
74,154,629
<p>I am having trouble getting my for loop to fill in the correct cells and I am hoping someone can help me understand how to only fill certain cells.</p> <p>Currently, I have a list of names in a sheet called &quot;3 - Task Listing&quot; and I am using an array formula to pull the list of names into my &quot;5 - Task Compatibility&quot; sheet starting in cell B11 and going down the column and D9 going across that row.</p> <p>So, if there are two names on the list, Clinic AM and Clinic PM - Clinic AM would be in cells D9 and B11. What I am hoping to achieve with my macro is having it fill in the cell where those meet up, D11, turn a dark grey and input the name in that cell. Then moving over one column and down one row (cell E12) would then also be dark grey and would say Clinic PM. It would continue on like this based on the number of names creating a diagonal line of dark grey cells with the names from the list in them.</p> <p>The code I have below has the column length hard coded as 2 for now so I will need to adjust that to look at the length of the list of names.</p> <p>The other issue I am having is it did fill in cells D11:E12 with the names and turned them dark grey. However, I need it to only change the cells on the diagonal line so cells E11 and D12 should be blank but are also turning grey and having the name from the list inserted into them.</p> <p>If someone could help me with making my for loop move on the diagonal rather than filling every cell in the range that would be greatly appreciated! Thanks!</p> <pre><code> Sub Gen_Grid() Worksheets(&quot;5 - Task Compatibility&quot;).Range(&quot;D11:EZ1000&quot;).ClearContents With Worksheets(&quot;5 - Task Compatibility&quot;).Range(&quot;D11:EZ1000&quot;) .Interior.Color = RGB(192, 192, 192) .Borders.ColorIndex = 15 End With Dim CL As Integer CL = 2 For i = 11 To 10 + CL For y = 4 To 3 + CL With Worksheets(&quot;5 - Task Compatibility&quot;).Cells(i, y) .Interior.Color = RGB(150, 150, 150) .Borders.ColorIndex = 48 End With Worksheets(&quot;5 - Task Compatibility&quot;).Cells(i, y) = Worksheets(&quot;5 - Task Compatibility&quot;).Range(&quot;B&quot; &amp; i).Value Next y Next i End Sub </code></pre>
[ { "answer_id": 74154817, "author": "user17732522", "author_id": 17732522, "author_profile": "https://Stackoverflow.com/users/17732522", "pm_score": 3, "selected": true, "text": "const" }, { "answer_id": 74154877, "author": "463035818_is_not_a_number", "author_id": 4117728...
2022/10/21
[ "https://Stackoverflow.com/questions/74154629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20217183/" ]
74,154,649
<p>I have two habitat types, forest and bog, but need to change them into categorical values so I can plot a log function with it. I just want to code forest as 0 and habitat as 1. How would I do this?</p> <p>Here is what some of my data looks like:</p> <pre><code>Site Lat Long Elev nSpp Habitat 1 TPB 42.00333 73 389 6 forest 2 TPB 42.00333 73 389 5 bog 3 HBC 42.02889 70 8 16 forest 4 HBC 42.02889 70 8 6 bog 5 CKB 42.04944 71 152 18 forest 6 CKB 42.04944 71 152 14 bog </code></pre>
[ { "answer_id": 74154817, "author": "user17732522", "author_id": 17732522, "author_profile": "https://Stackoverflow.com/users/17732522", "pm_score": 3, "selected": true, "text": "const" }, { "answer_id": 74154877, "author": "463035818_is_not_a_number", "author_id": 4117728...
2022/10/21
[ "https://Stackoverflow.com/questions/74154649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,154,654
<p>I'm observing the Pasteboard for changes, that include images. The amount of memory I can use is limited, so most images make the program result in a jetsam crash due to their size. Is it possible to store them more efficiently?</p> <p>Currently I'm using this code to store them:</p> <pre class="lang-objectivec prettyprint-override"><code>for (UIImage* image in [_pasteboard images]) { [UIImagePNGRepresentation(image) writeToFile:path atomically:YES]; } </code></pre>
[ { "answer_id": 74157313, "author": "Tom Harrington", "author_id": 43832, "author_profile": "https://Stackoverflow.com/users/43832", "pm_score": 1, "selected": false, "text": "for (UIImage* image in [_pasteboard images]) {\n @autoreleasepool {\n [UIImagePNGRepresentation(image) ...
2022/10/21
[ "https://Stackoverflow.com/questions/74154654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18482403/" ]
74,154,732
<p>I have some csv files including array columns. For example:</p> <pre><code>a,b,c 1,1|2|3,4.5|5.5|6.5 2,7|8|9,10.5|11.5|12.5 </code></pre> <p>Delimter 1 is <code>,</code> to sepperate fields a, b and c. Delimiter 2 is <code>|</code> in this case, but could be changed.</p> <p>Is there a possibility in python to read this as a pandas dataframe directly? Field b and c should be an array/series inside the dataframe.</p> <p>What I do now is reading the csv as strings:</p> <pre><code>df = pd.read_csv('data.csv', dtype='str') </code></pre> <p>Then use <code>np.fromstring</code> to convert all strings to numpy arrays:</p> <pre><code>type_dict = { &quot;a&quot;: &quot;int&quot;, &quot;b&quot;: &quot;int&quot;, &quot;c&quot;: &quot;float&quot; } def make_split(text, dt): return np.fromstring(text, sep=&quot;|&quot;, dtype=dt) df = df.apply(lambda x: x.apply(make_split, dt=type_dict[x.name])) </code></pre> <p>But this takes several minutes for my files. Is there a faster option?</p>
[ { "answer_id": 74154903, "author": "Naveed", "author_id": 3494754, "author_profile": "https://Stackoverflow.com/users/3494754", "pm_score": 1, "selected": false, "text": "df=pd.read_csv(r'csv2.txt', sep=',')\n\n\ndf['b']=df['b'].str.split('|').apply(lambda x: [int(i) for i in x])\ndf['c'...
2022/10/21
[ "https://Stackoverflow.com/questions/74154732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5663623/" ]
74,154,735
<p>I'm using Tailwind CSS to make a grid. In the parent div, I'm using the classes <code>space-x-1</code> and <code>space-y-1</code> to automatically align the child divs.</p> <p>This works well except the first element is slightly misaligned. The first element has a computed margin of 0, while every other element has a computed margin of 4px. When I remove the <code>space-x-1</code> and <code>space-y-1</code> from the parent div, the child divs have the same margins.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!-- Tailwind 3 --&gt; &lt;script src="https://cdn.tailwindcss.com"&gt;&lt;/script&gt; &lt;!-- Body --&gt; &lt;div class="grid grid-cols-5 space-x-1 space-y-1"&gt; &lt;div class="text-white text-center p-2 bg-green-700"&gt;wood 1&lt;/div&gt; &lt;div class="text-white text-center p-2 bg-gray-700"&gt;ore 2&lt;/div&gt; &lt;div class="text-white text-center p-2 bg-green-700"&gt;wood 3&lt;/div&gt; &lt;div class="text-white text-center p-2 bg-purple-800"&gt;sheep 4&lt;/div&gt; &lt;div class="text-white text-center p-2 bg-yellow-500"&gt;wheat 5&lt;/div&gt; &lt;div class="text-white text-center p-2 bg-yellow-900"&gt;brick 6&lt;/div&gt; &lt;div class="text-white text-center p-2 bg-pink-700"&gt;desert 7&lt;/div&gt; &lt;div class="text-white text-center p-2 bg-yellow-900"&gt;brick 8&lt;/div&gt; &lt;div class="text-white text-center p-2 bg-gray-700"&gt;ore 9&lt;/div&gt; &lt;div class="text-white text-center p-2 bg-green-700"&gt;wood 10&lt;/div&gt; &lt;div class="text-white text-center p-2 bg-purple-800"&gt;sheep 11&lt;/div&gt; &lt;div class="text-white text-center p-2 bg-yellow-500"&gt;wheat 12&lt;/div&gt; &lt;div class="text-white text-center p-2 bg-yellow-900"&gt;brick 13&lt;/div&gt; &lt;div class="text-white text-center p-2 bg-green-700"&gt;wood 14&lt;/div&gt; &lt;div class="text-white text-center p-2 bg-gray-700"&gt;ore 15&lt;/div&gt; &lt;div class="text-white text-center p-2 bg-yellow-500"&gt;wheat 16&lt;/div&gt; &lt;div class="text-white text-center p-2 bg-purple-800"&gt;sheep 17&lt;/div&gt; &lt;div class="text-white text-center p-2 bg-yellow-500"&gt;wheat 18&lt;/div&gt; &lt;div class="text-white text-center p-2 bg-yellow-900"&gt;brick 19&lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74154923, "author": "rrr63", "author_id": 20059789, "author_profile": "https://Stackoverflow.com/users/20059789", "pm_score": 1, "selected": false, "text": "gap-x-1" }, { "answer_id": 74154983, "author": "J-P-Robin", "author_id": 4249882, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74154735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1491213/" ]
74,154,796
<p>Good morning:</p> <p>This time I have a spreadsheet in Google Sheets, in which in column &quot;A&quot;, users will be entering their identity document. Ideally, numerical or alphanumeric values should be entered in the case of foreign documents. But, many times these users paste the data from other forms, so they may come with special characters (&quot;.&quot; ;&quot;,&quot;; &quot;-&quot;; &quot;_&quot;). The idea is that when the user enters a data, a macro is run, which removes the format of that entire column, cleans it and eliminates those special characters, only leaving numbers and letters to have.</p> <p>The easy step is to do it with a formula in a contiguous column, the formula is REGEXREPLACE(), but already the document becomes heavier and such. That's why I wanted to use the macro option, since it would be acting on the same value of the cell and reducing it in many cases.</p> <p>I still have no knowledge of Appscript and have been searching on Youtube, but I did not find anything.</p> <p>Could you help me create this macro?</p> <p>I thank you very much for being so!!!</p> <p>Miguel.-</p>
[ { "answer_id": 74154923, "author": "rrr63", "author_id": 20059789, "author_profile": "https://Stackoverflow.com/users/20059789", "pm_score": 1, "selected": false, "text": "gap-x-1" }, { "answer_id": 74154983, "author": "J-P-Robin", "author_id": 4249882, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74154796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20301749/" ]
74,154,797
<p>I have a vector</p> <pre><code>x &lt;- c(0, 25, 0, 75, 50, 50, 0) </code></pre> <p>I would like to convert it so the 0's and only the zeroes are double, as so:</p> <pre><code>x &lt;- c(00, 25, 00, 75, 50, 50, 00) </code></pre> <p>Anyone have a neat idea how to do this?</p>
[ { "answer_id": 74154923, "author": "rrr63", "author_id": 20059789, "author_profile": "https://Stackoverflow.com/users/20059789", "pm_score": 1, "selected": false, "text": "gap-x-1" }, { "answer_id": 74154983, "author": "J-P-Robin", "author_id": 4249882, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74154797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12018662/" ]
74,154,839
<p>I am making a button using flutter, but i don't know how to make it bigger. Here is the code:</p> <p>'''</p> <pre><code> ElevatedButton( onPressed: () {}, style: ButtonStyle( foregroundColor: MaterialStateProperty.all&lt;Color&gt;(Colors.blue), backgroundColor: MaterialStateProperty.all&lt;Color&gt;(Colors.white), minimumSize: MaterialStateProperty.all(Size(80, 40)), shape: MaterialStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular(30.0), side: BorderSide(width: 3, color: Color.fromARGB(0, 0, 0, 0)), ), ), </code></pre> <p>'''</p> <p>This is how it looks like:</p> <p><a href="https://i.stack.imgur.com/9ZFgR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9ZFgR.png" alt="enter image description here" /></a></p> <p>This is how I want:</p> <p><a href="https://i.stack.imgur.com/R4ZTR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R4ZTR.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74154923, "author": "rrr63", "author_id": 20059789, "author_profile": "https://Stackoverflow.com/users/20059789", "pm_score": 1, "selected": false, "text": "gap-x-1" }, { "answer_id": 74154983, "author": "J-P-Robin", "author_id": 4249882, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74154839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20218212/" ]
74,154,869
<p>I dont understand what is happening in the code below. Please explain to me step by step</p> <p>In the output Console, for the 1st printf, I get a smiley face. WHY? If i'm not mistaken, it is supposed to print the 257th ASCII, but there is no ASCII value after 255. So where is it getting the smiley face from?</p> <p>Similarly for the 2nd printf i got a smiley face. WHY?</p> <p>3rd printf: value is 323 as it is printing the integer value of variable d</p> <p>lastly, the 4th printf: WHY does the output show 0?</p> <pre><code>int main() { char b; int i = 257; double d = 323.142; b = i; printf(&quot;%c\n&quot;, b); b = (char) i; printf(&quot;%c\n&quot;, b); i = (int) d; printf(&quot;%d\n&quot;, i); b = (char) d; printf(&quot;%c\n&quot;, b); } </code></pre> <p>OUTPUT:</p> <p><a href="https://i.stack.imgur.com/pZZYL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pZZYL.png" alt="console output" /></a></p>
[ { "answer_id": 74154923, "author": "rrr63", "author_id": 20059789, "author_profile": "https://Stackoverflow.com/users/20059789", "pm_score": 1, "selected": false, "text": "gap-x-1" }, { "answer_id": 74154983, "author": "J-P-Robin", "author_id": 4249882, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74154869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20292136/" ]
74,154,880
<p>I am trying to connect to the Microsoft Graph API without user intervention, and am following <a href="https://learn.microsoft.com/en-us/graph/auth-v2-service" rel="nofollow noreferrer">this</a> guide on how to do so. I am able to get past step 4, where I receive my access token. However, I continue to receive an error saying that my access token is empty.</p> <p>The first part of my code successfully gets the access token:</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>import urllib3 uri = "https://login.microsoftonline.com/companyID/oauth2/v2.0/token" payload= { 'Content-Type': 'application/x-www-form-urlencoded', 'Host': 'login.microsoftonline.com', 'client_id': 'xxxxxxxxxxxxxxxxxxxxx', 'scope': 'https://graph.microsoft.com/.default', 'client_secret': 'xxxxxxxxxxxxxxxxxxxxx', 'grant_type': 'client_credentials' } http = urllib3.PoolManager() response = http.request('POST', uri, payload) print(response.data) my_dict = eval(response.data) token = f"{my_dict['token_type']} {my_dict['access_token']}"</code></pre> </div> </div> </p> <p>When I try running this second part to connect to the Graph API:</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>import urllib3 uri2 = 'https://graph.microsoft.com/v1.0/users/12345678-73a6-4952-a53a-e9916737ff7f' payload2 = { 'Authorization':token, 'Host':'graph.microsoft.com' } https = urllib3.PoolManager() response2 = http.request ('GET', uri2, payload2) print(response2.data)</code></pre> </div> </div> </p> <p>I get this error:</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>b'{"error":{"code":"InvalidAuthenticationToken","message":"Access token is empty.","innerError":{"date":"2022-10-21T13:55:42","request-id":"xxxxxxxxx-aced-469c-a68c-xxxxxxxx","client-request-id":"xxxxx-aced-469c-a68c-xxxxxxxxxxxx"}}}'</code></pre> </div> </div> </p> <p>All of the permissions are correctly set up on the app's end, I'm scratching my head on why the token is saying it's empty. Any and all help is greatly appreciated!</p>
[ { "answer_id": 74160925, "author": "Gaurav Mantri", "author_id": 188096, "author_profile": "https://Stackoverflow.com/users/188096", "pm_score": 1, "selected": true, "text": "response2 = http.request ('GET', uri2, payload2)\n" }, { "answer_id": 74160934, "author": "Sridevi", ...
2022/10/21
[ "https://Stackoverflow.com/questions/74154880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11364550/" ]
74,154,909
<p>I'm trying to call 2 functions that depend on the input choice in the selector.</p> <p>I tried with this sample code but I get an error when compiling</p> <pre><code>[long , short] = choice_opt == 'option 1' ? function_1(obv) : function_2(obv) </code></pre> <p>And here is the error I got:</p> <pre><code>Cannot call 'operator ?:' with argument 'expr2'='call 'function_2(obv)' ([series bool, series bool])'. An argument of '[series bool, series bool]' type was used but a 'input bool' is expected </code></pre>
[ { "answer_id": 74157235, "author": "mr_statler", "author_id": 17978157, "author_profile": "https://Stackoverflow.com/users/17978157", "pm_score": 1, "selected": true, "text": "//@version=5\nstrategy(\"My strategy\", overlay=true)\n\nchoice_opt_long = input.string(\"option 1\", \"Options\...
2022/10/21
[ "https://Stackoverflow.com/questions/74154909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20301840/" ]
74,154,921
<p>I just made a program that makes you choose if you want to register or login to a user that is already in the collections or user array list that I made. What my problem is that i can't find a way where i put a username and password that is already registered and to verify it using the list that i made.</p> <p>This is my Main Class:</p> <pre><code>import java.util.ArrayList; import java.util.Collection; import java.util.Scanner; import java.time.LocalDate; import java.util.stream.Collectors; public class Main { public static void main(String[] args) { Collection&lt;User&gt; c = new ArrayList&lt;User&gt;(); Scanner sc1 = new Scanner(System.in); Scanner sc2 = new Scanner(System.in); int ch; do{ System.out.println(&quot;1. Register&quot;); System.out.println(&quot;2. Login&quot;); System.out.print(&quot;Enter your Choice: &quot;); ch = sc1.nextInt(); switch(ch) { case 1: System.out.println(&quot;Enter New Username:&quot;); String username = sc2.nextLine(); System.out.println(&quot;Enter New Password:&quot;); String pass = sc2.nextLine(); c.add(new User(username, pass)); System.out.println(&quot;Your account has been registered to the system!&quot;); break; case 2: System.out.println(&quot;Enter your Username:&quot;); String loginusername = sc2.nextLine(); System.out.println(&quot;Enter your Password:&quot;); String loginpassword = sc2.nextLine(); } }while(ch!=0); } } </code></pre> <p>and this is my User class:</p> <pre><code>public class User { private String username; private String pass; User(String username, String pass){ this.username = username; this.pass = pass; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } } </code></pre>
[ { "answer_id": 74155290, "author": "mexslacker", "author_id": 13000645, "author_profile": "https://Stackoverflow.com/users/13000645", "pm_score": 0, "selected": false, "text": "Collection<User> c = new ArrayList<User>();\n\nSystem.out.println(\"Enter New Username:\");\nString username = ...
2022/10/21
[ "https://Stackoverflow.com/questions/74154921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20301823/" ]
74,154,930
<p>I have this code in Oracle:</p> <pre><code>SELECT * FROM USER_OBJECTS WHERE TEMPORARY = 'N' </code></pre> <p>I know that the USER_OBJECT table in Postgres is pg_catalog.pg_class, but what's the equivalent of the TEMPORARY column? Thanks</p>
[ { "answer_id": 74155290, "author": "mexslacker", "author_id": 13000645, "author_profile": "https://Stackoverflow.com/users/13000645", "pm_score": 0, "selected": false, "text": "Collection<User> c = new ArrayList<User>();\n\nSystem.out.println(\"Enter New Username:\");\nString username = ...
2022/10/21
[ "https://Stackoverflow.com/questions/74154930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20301801/" ]
74,154,932
<p><img src="https://i.stack.imgur.com/b3xDq.png" alt="Code" /></p> <p>I can't figure out how to get the first days of every year so that I can show the change.</p>
[ { "answer_id": 74155315, "author": "Rodrigo Cava", "author_id": 6797569, "author_profile": "https://Stackoverflow.com/users/6797569", "pm_score": 0, "selected": false, "text": "date" }, { "answer_id": 74157156, "author": "Jamiu Shaibu", "author_id": 19290081, "author_...
2022/10/21
[ "https://Stackoverflow.com/questions/74154932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20042749/" ]
74,154,966
<p>I would like to put 2 buttons on top of each other while still keeping both of them centered. I managed to put them on top of each other through the display: block, and through the flex-direction: column. However, I still don't know how to center them. The text-align doesn't seem to work. could somebody explain to me why this doesn't work, please?</p> <pre><code>button{ border: none; padding-top: 10px; padding-bottom: 10px ; color: white; font-weight: bold; width: 200px; margin-bottom: 5px; border-radius: 5px; } .btn-group{ display: flex; flex-direction: column; text-align: center; } #increment-btn{ background: darkred; } #save-btn{ background-color: green; } </code></pre> <p>This is the HTML:</p> <pre><code>&lt;div class=&quot;btn-group&quot;&gt; &lt;button id=&quot;save-btn&quot; onclick=&quot;save()&quot;&gt;SAVE&lt;/button&gt; &lt;button id=&quot;increment-btn&quot; onclick=&quot;increment()&quot;&gt;INCREMENT&lt;/button&gt; &lt;/div&gt; </code></pre>
[ { "answer_id": 74155014, "author": "OttherCreek", "author_id": 13261694, "author_profile": "https://Stackoverflow.com/users/13261694", "pm_score": 0, "selected": false, "text": "align-items: center;" }, { "answer_id": 74155015, "author": "G-Cyrillus", "author_id": 2442099...
2022/10/21
[ "https://Stackoverflow.com/questions/74154966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20198352/" ]