qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,434,147
<p>I tried convert 2018-08-22 11:13:00 (datetime64[ns]) to only 20180822 (object).</p> <p>I have this code:</p> <pre><code>df_ICF_news['date'] = df_ICF_news['date'].apply(lambda x: pd.to_datetime(str(x), format='%Y%m%d')) </code></pre> <p>but don`t work:</p> <pre><code>ValueError: time data '2022-10-28 11:09:00' does not match format '%Y%m%d' (match) </code></pre>
[ { "answer_id": 74434176, "author": "Barmar", "author_id": 1491895, "author_profile": "https://Stackoverflow.com/users/1491895", "pm_score": 3, "selected": true, "text": "zip()" }, { "answer_id": 74434194, "author": "KillerRebooted", "author_id": 18554284, "author_profile": "https://Stackoverflow.com/users/18554284", "pm_score": 0, "selected": false, "text": "newl = [1, 8, 10, 16, 19, 22, 27, 33, 36, 40, 47, 52, 56, 61, 63, 71, 72, 75, 81, 81, 84, 88, 96, 98, 103, 110, 113, 118, 124, 128, 129, 134, 134, 139, 148, 157, 157, 160, 162, 164]\n\nlst = []\n\nfor i in range(len(newl)):\n try:\n lst.append((newl[i], newl[i+1]))\n except:\n pass\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20390958/" ]
74,434,150
<p>So i have a class exercice that i have to make a program that gives me all the information about the youngest person of a group, i could do the age, it gives me the youngest age but with the names and citizen cards could not get what i've wanted.</p> <p>thats the code the way i tried do make it.</p> <pre><code>persons = [] ages = [] numbers_of_citizen_card = [] i = int(input('type the number of people in the group: ')) for i in range (0, i): name = input('Type your name: ') age = int(input('Type your age: ')) n_cc = int(input('Type the number of your citizen card: ')) persons.append(name) ages.append(age) numbers_of_citizen_card.append(n_cc) if (i &gt; 999): print('It is not possible to sign up more people. ') else: print('The youngest person in the group with {} years old, is named {} with the number of citizen card of {}.'.format(min(ages), min(persons), min(numbers_of_citizen_card))) </code></pre>
[ { "answer_id": 74434253, "author": "Kraigolas", "author_id": 11659881, "author_profile": "https://Stackoverflow.com/users/11659881", "pm_score": 2, "selected": false, "text": "min" }, { "answer_id": 74434276, "author": "Panos Savvaidis", "author_id": 14048001, "author_profile": "https://Stackoverflow.com/users/14048001", "pm_score": 1, "selected": false, "text": "min" }, { "answer_id": 74434369, "author": "tripleee", "author_id": 874188, "author_profile": "https://Stackoverflow.com/users/874188", "pm_score": 1, "selected": false, "text": "persons = [] # list of dict\n\nwhile True:\n name = input('Type your name, or an empty line to quit: ')\n if name:\n age = int(input('Type your age: '))\n n_cc = int(input('Type the number of your citizen card: '))\n persons.append({'name': name, 'age': age, 'n_cc': n_cc})\n else:\n break\n\nyoungest = min(persons, key=lambda x: x['age'])\n\nprint('The youngest person in the group with {} years old, is named {} with the number of citizen card of {}.'.format(youngest['age'], youngest['name'], youngest['n_cc']))\n" }, { "answer_id": 74434371, "author": "wallbloggerbeing", "author_id": 16581025, "author_profile": "https://Stackoverflow.com/users/16581025", "pm_score": 1, "selected": false, "text": "youngest = min(ages)\ni = index(ages)\n" }, { "answer_id": 74434389, "author": "Shmack", "author_id": 3155240, "author_profile": "https://Stackoverflow.com/users/3155240", "pm_score": 0, "selected": false, "text": "min" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20502058/" ]
74,434,160
<pre><code>#include&lt;stdio.h&gt; int main() { int a=10,b=4,c=2; b != !a; c =! !a; printf(&quot;b = %d\t c = %d&quot;,b,c); } </code></pre> <p><strong>I need output of this question explain me the outcome??</strong></p>
[ { "answer_id": 74434370, "author": "Lundin", "author_id": 584518, "author_profile": "https://Stackoverflow.com/users/584518", "pm_score": 1, "selected": false, "text": "i+++" }, { "answer_id": 74434497, "author": "askinmert", "author_id": 12478084, "author_profile": "https://Stackoverflow.com/users/12478084", "pm_score": -1, "selected": false, "text": "b != !a;\nc = !!a;\n" }, { "answer_id": 74434973, "author": "THE_CHOODICK", "author_id": 17587784, "author_profile": "https://Stackoverflow.com/users/17587784", "pm_score": 1, "selected": false, "text": "#include <stdio.h>" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20502118/" ]
74,434,162
<p>I want to convert a nested JSON like this</p> <pre><code>{ &quot;dateSession&quot;: &quot;14/11/2022&quot;, &quot;HRdata&quot;: { &quot;1&quot;: 86, &quot;2&quot;: 88, &quot;3&quot;: 86, &quot;4&quot;: 85 }, &quot;SPO2data&quot;: { &quot;1&quot;: 98, &quot;2&quot;: 97, &quot;3&quot;: 97, &quot;4&quot;: 96 } } </code></pre> <p>to something like this:</p> <pre><code>{ &quot;dateSession&quot;: &quot;14/11/2022&quot;, &quot;HRdata-1&quot;: 86, &quot;HRdata-2&quot;: 88, &quot;HRdata-3&quot;: 86, &quot;HRdata-4&quot;: 85, &quot;SPO2data-1&quot;: 98, &quot;SPO2data-2&quot;: 97, &quot;SPO2data-3&quot;: 97, &quot;SPO2data-4&quot;: 96, } </code></pre> <p>where each fields in nested object will be named to field+key which represents its actual path.</p> <p>I want to generate a csv with all the data so first, I need a simple json to get arrays exported as well.</p>
[ { "answer_id": 74434392, "author": "Jonathon Hibbard", "author_id": 1244184, "author_profile": "https://Stackoverflow.com/users/1244184", "pm_score": 0, "selected": false, "text": "typeof key === 'object' && !Array.isArray(key)" }, { "answer_id": 74434496, "author": "Yosvel Quintero", "author_id": 1932552, "author_profile": "https://Stackoverflow.com/users/1932552", "pm_score": 2, "selected": false, "text": "string" }, { "answer_id": 74434569, "author": "Yarden Buzaglo", "author_id": 19441159, "author_profile": "https://Stackoverflow.com/users/19441159", "pm_score": 1, "selected": false, "text": "const data = {\n dateSession: '14/11/2022',\n HRdata: {\n 1: 86,\n 2: 88,\n 3: 86,\n 4: 85,\n },\n SPO2data: {\n 1: 98,\n 2: 97,\n 3: 97,\n 4: 96,\n },\n}\n\nconst flattenedData = {}\nconst flatten = (obj, oldName = '') => {\n //we are counting on the fact that we will get an object at first - you can add a condition to check it here\n const entries = Object.entries(obj)\n //iterate through the object. If we are encountering another object - send it again in recursion. If it's a value - add it to the flattened object\n for (const [key, value] of entries) {\n typeof value === 'object' && !Array.isArray(value)\n ? flatten(value, key + '-')\n : (flattenedData[oldName + key] = value)\n }\n}\n\nflatten(data)\nconsole.log(flattenedData)" }, { "answer_id": 74436678, "author": "Bhavya Dhiman", "author_id": 4167172, "author_profile": "https://Stackoverflow.com/users/4167172", "pm_score": 0, "selected": false, "text": "const obj = {\n \"dateSession\": \"14/11/2022\",\n \"HRdata\": {\n \"1\": 86,\n \"2\": 88,\n \"3\": 86,\n \"4\": 85\n },\n \"SPO2data\": {\n \"1\": 98,\n \"2\": 97,\n \"3\": 97,\n \"4\": 96,\n }\n};\n\nlet newObj = {};\n\nfunction modifyJson(obj, newObj, count, upperKey) {\n for (const key of Object.keys(obj)) {\n if (typeof obj[key] === 'object') {\n newObj = modifyJson(obj[key], newObj, count + 1, key);\n } else if (count > 0) {\n newObj[`${upperKey}-${key}`] = obj[key];\n } else {\n newObj[key] = obj[key];\n }\n }\n return newObj;\n}\n\nnewObj = modifyJson(obj, {}, 0, '');\nconsole.log(newObj);\n" }, { "answer_id": 74459059, "author": "Rohìt Jíndal", "author_id": 4116300, "author_profile": "https://Stackoverflow.com/users/4116300", "pm_score": 0, "selected": false, "text": "const obj = {\n \"dateSession\": \"14/11/2022\",\n \"HRdata\": {\n \"1\": 86,\n \"2\": 88,\n \"3\": 86,\n \"4\": 85\n },\n \"SPO2data\": {\n \"1\": 98,\n \"2\": 97,\n \"3\": 97,\n \"4\": 96\n }\n};\n\nconst finalObj = {};\n\nObject.keys(obj).forEach(key => {\n if (typeof obj[key] === 'object') {\n Object.keys(obj[key]).forEach(innerObjKey => {\n finalObj[`${key}-${innerObjKey}`] = obj[key][innerObjKey]\n })\n } else {\n finalObj[key] = obj[key]\n }\n});\n\nconsole.log(finalObj);" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16786547/" ]
74,434,168
<p>I have a dataset with a categorical variable that is not nicely coded. The same category appears sometimes with upper case letters and sometimes with lower case (and several variations of it). Since I have a large dataset, I would like to harmonize the categories taking advantage of the categorical dtype - therefore exclude any <code>replace</code> solution. The only solutions I found are <a href="https://stackoverflow.com/questions/28836137/merging-pandas-categorical-series-with-renaming">this</a> and <a href="https://stackoverflow.com/questions/57929076/how-to-replace-different-categorical-variables-with-another-list-of-categorical">this</a>, but I feel they implicitly make use of replace.</p> <p>I report a toy example below and the solutions I tried</p> <pre><code>from pandas import Series # Create dataset df = Series([&quot;male&quot;, &quot;female&quot;,&quot;Male&quot;, &quot;FEMALE&quot;, &quot;MALE&quot;, &quot;MAle&quot;], dtype=&quot;category&quot;, name = &quot;NEW_TEST&quot;) # Define the old, the &quot;new&quot; and the desired categories original_categories = list(df.cat.categories) standardised_categories = list(map(lambda x: x.lower(), df.cat.categories)) desired_new_cat = list(set(standardised_categories)) # Failed attempt to change categories df.cat.categories = standardised_categories df = df.cat.rename_categories(standardised_categories) # Error message: Categorical categories must be unique </code></pre>
[ { "answer_id": 74434392, "author": "Jonathon Hibbard", "author_id": 1244184, "author_profile": "https://Stackoverflow.com/users/1244184", "pm_score": 0, "selected": false, "text": "typeof key === 'object' && !Array.isArray(key)" }, { "answer_id": 74434496, "author": "Yosvel Quintero", "author_id": 1932552, "author_profile": "https://Stackoverflow.com/users/1932552", "pm_score": 2, "selected": false, "text": "string" }, { "answer_id": 74434569, "author": "Yarden Buzaglo", "author_id": 19441159, "author_profile": "https://Stackoverflow.com/users/19441159", "pm_score": 1, "selected": false, "text": "const data = {\n dateSession: '14/11/2022',\n HRdata: {\n 1: 86,\n 2: 88,\n 3: 86,\n 4: 85,\n },\n SPO2data: {\n 1: 98,\n 2: 97,\n 3: 97,\n 4: 96,\n },\n}\n\nconst flattenedData = {}\nconst flatten = (obj, oldName = '') => {\n //we are counting on the fact that we will get an object at first - you can add a condition to check it here\n const entries = Object.entries(obj)\n //iterate through the object. If we are encountering another object - send it again in recursion. If it's a value - add it to the flattened object\n for (const [key, value] of entries) {\n typeof value === 'object' && !Array.isArray(value)\n ? flatten(value, key + '-')\n : (flattenedData[oldName + key] = value)\n }\n}\n\nflatten(data)\nconsole.log(flattenedData)" }, { "answer_id": 74436678, "author": "Bhavya Dhiman", "author_id": 4167172, "author_profile": "https://Stackoverflow.com/users/4167172", "pm_score": 0, "selected": false, "text": "const obj = {\n \"dateSession\": \"14/11/2022\",\n \"HRdata\": {\n \"1\": 86,\n \"2\": 88,\n \"3\": 86,\n \"4\": 85\n },\n \"SPO2data\": {\n \"1\": 98,\n \"2\": 97,\n \"3\": 97,\n \"4\": 96,\n }\n};\n\nlet newObj = {};\n\nfunction modifyJson(obj, newObj, count, upperKey) {\n for (const key of Object.keys(obj)) {\n if (typeof obj[key] === 'object') {\n newObj = modifyJson(obj[key], newObj, count + 1, key);\n } else if (count > 0) {\n newObj[`${upperKey}-${key}`] = obj[key];\n } else {\n newObj[key] = obj[key];\n }\n }\n return newObj;\n}\n\nnewObj = modifyJson(obj, {}, 0, '');\nconsole.log(newObj);\n" }, { "answer_id": 74459059, "author": "Rohìt Jíndal", "author_id": 4116300, "author_profile": "https://Stackoverflow.com/users/4116300", "pm_score": 0, "selected": false, "text": "const obj = {\n \"dateSession\": \"14/11/2022\",\n \"HRdata\": {\n \"1\": 86,\n \"2\": 88,\n \"3\": 86,\n \"4\": 85\n },\n \"SPO2data\": {\n \"1\": 98,\n \"2\": 97,\n \"3\": 97,\n \"4\": 96\n }\n};\n\nconst finalObj = {};\n\nObject.keys(obj).forEach(key => {\n if (typeof obj[key] === 'object') {\n Object.keys(obj[key]).forEach(innerObjKey => {\n finalObj[`${key}-${innerObjKey}`] = obj[key][innerObjKey]\n })\n } else {\n finalObj[key] = obj[key]\n }\n});\n\nconsole.log(finalObj);" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20501720/" ]
74,434,203
<p>Below is a simplified example of a larger piece of code. Basically I'm calling one or more API endpoints and downloading a CSV file that gets written to an Azure Blob Container. If there's multiple files, the blob is appended for every new csv file loaded.</p> <p>The issue is when I append the target blob I ended up with a multiple header rows scattered throughout the file depending on how may CSVs I consumed. All the CSVs have the same header row and I know the first row will always have a line feed. Is there a way to read the stream, skip the content until after the first line feed and then copy the stream to the blob?</p> <p>It seemed simple in my head, but I'm having trouble finding my way there code-wise. I don't want to wait for the whole file to download and then in-memory delete the header row since some of these files can be several gigabytes.</p> <p>I am using .net core v6 if that helps</p> <pre><code>using Stream blobStream = await blockBlobClient.OpenWriteAsync(true); { for (int i = 0; i &lt; 3; i++) { using HttpResponseMessage response = await client.GetAsync(downloadUrls[i], HttpCompletionOption.ResponseHeadersRead); Stream sourceStream = response.Content.ReadAsStream(); sourceStream.CopyTo(blobStream); } } </code></pre>
[ { "answer_id": 74434392, "author": "Jonathon Hibbard", "author_id": 1244184, "author_profile": "https://Stackoverflow.com/users/1244184", "pm_score": 0, "selected": false, "text": "typeof key === 'object' && !Array.isArray(key)" }, { "answer_id": 74434496, "author": "Yosvel Quintero", "author_id": 1932552, "author_profile": "https://Stackoverflow.com/users/1932552", "pm_score": 2, "selected": false, "text": "string" }, { "answer_id": 74434569, "author": "Yarden Buzaglo", "author_id": 19441159, "author_profile": "https://Stackoverflow.com/users/19441159", "pm_score": 1, "selected": false, "text": "const data = {\n dateSession: '14/11/2022',\n HRdata: {\n 1: 86,\n 2: 88,\n 3: 86,\n 4: 85,\n },\n SPO2data: {\n 1: 98,\n 2: 97,\n 3: 97,\n 4: 96,\n },\n}\n\nconst flattenedData = {}\nconst flatten = (obj, oldName = '') => {\n //we are counting on the fact that we will get an object at first - you can add a condition to check it here\n const entries = Object.entries(obj)\n //iterate through the object. If we are encountering another object - send it again in recursion. If it's a value - add it to the flattened object\n for (const [key, value] of entries) {\n typeof value === 'object' && !Array.isArray(value)\n ? flatten(value, key + '-')\n : (flattenedData[oldName + key] = value)\n }\n}\n\nflatten(data)\nconsole.log(flattenedData)" }, { "answer_id": 74436678, "author": "Bhavya Dhiman", "author_id": 4167172, "author_profile": "https://Stackoverflow.com/users/4167172", "pm_score": 0, "selected": false, "text": "const obj = {\n \"dateSession\": \"14/11/2022\",\n \"HRdata\": {\n \"1\": 86,\n \"2\": 88,\n \"3\": 86,\n \"4\": 85\n },\n \"SPO2data\": {\n \"1\": 98,\n \"2\": 97,\n \"3\": 97,\n \"4\": 96,\n }\n};\n\nlet newObj = {};\n\nfunction modifyJson(obj, newObj, count, upperKey) {\n for (const key of Object.keys(obj)) {\n if (typeof obj[key] === 'object') {\n newObj = modifyJson(obj[key], newObj, count + 1, key);\n } else if (count > 0) {\n newObj[`${upperKey}-${key}`] = obj[key];\n } else {\n newObj[key] = obj[key];\n }\n }\n return newObj;\n}\n\nnewObj = modifyJson(obj, {}, 0, '');\nconsole.log(newObj);\n" }, { "answer_id": 74459059, "author": "Rohìt Jíndal", "author_id": 4116300, "author_profile": "https://Stackoverflow.com/users/4116300", "pm_score": 0, "selected": false, "text": "const obj = {\n \"dateSession\": \"14/11/2022\",\n \"HRdata\": {\n \"1\": 86,\n \"2\": 88,\n \"3\": 86,\n \"4\": 85\n },\n \"SPO2data\": {\n \"1\": 98,\n \"2\": 97,\n \"3\": 97,\n \"4\": 96\n }\n};\n\nconst finalObj = {};\n\nObject.keys(obj).forEach(key => {\n if (typeof obj[key] === 'object') {\n Object.keys(obj[key]).forEach(innerObjKey => {\n finalObj[`${key}-${innerObjKey}`] = obj[key][innerObjKey]\n })\n } else {\n finalObj[key] = obj[key]\n }\n});\n\nconsole.log(finalObj);" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4599104/" ]
74,434,227
<p>I have multiple select fields as star rating field for the users to select while giving a review like the below 2 select fields ( Though I have 5 in my code, adding only 2 here ). Now I am trying to get the values of each selections and attach the average of the selection in the hidden field with the name rating. How can I do it?</p> <pre><code> &lt;select name=&quot;multi_rating_item_service&quot; id=&quot;multi_rating_item_service&quot; class=&quot;star-rating&quot; required=&quot;&quot;&gt; &lt;option value=&quot;&quot;&gt;Rate…&lt;/option&gt; &lt;option value=&quot;5&quot;&gt;Perfect&lt;/option&gt; &lt;option value=&quot;4&quot;&gt;Good&lt;/option&gt; &lt;option value=&quot;3&quot;&gt;Average&lt;/option&gt; &lt;option value=&quot;2&quot;&gt;Not that bad&lt;/option&gt; &lt;option value=&quot;1&quot;&gt;Very poor&lt;/option&gt; &lt;/select&gt; &lt;select name=&quot;multi_rating_item_delivery&quot; id=&quot;multi_rating_item_delivery&quot; class=&quot;star-rating&quot; required=&quot;&quot;&gt; &lt;option value=&quot;&quot;&gt;Rate…&lt;/option&gt; &lt;option value=&quot;5&quot;&gt;Perfect&lt;/option&gt; &lt;option value=&quot;4&quot;&gt;Good&lt;/option&gt; &lt;option value=&quot;3&quot;&gt;Average&lt;/option&gt; &lt;option value=&quot;2&quot;&gt;Not that bad&lt;/option&gt; &lt;option value=&quot;1&quot;&gt;Very poor&lt;/option&gt; &lt;/select&gt; &lt;input type=&quot;hidden&quot; name=&quot;rating&quot; id=&quot;rating&quot; value=&quot;here goes the average&quot; /&gt; </code></pre> <p>I tried to use jquery but was not able to do it after multiple tries and was fed up with it. So, I removed all the jquery I did and instead calculated the average in PHP while submitting the form. Though it works but for some reason, there were some unintentional issues that came with it. So, I think we need to submit the value of the rating using the hidden field to eliminate those issues. If you can help, that will be very beneficial for me.</p> <p><strong>Update:</strong> I think you may not have gotten enough information in the original post. So, here is an update. I have multiple Add Review forms on the same order page( that ask for reviews from customers for each product in that order ). So, this creates a level of complexity to work on all the forms.</p> <p>Then, another complexity is that the admin can configure what ratings s/he wants to add( S/he also sets the ID of the type of rating in the admin panel ) that will be displayed to the customers as select fields. So, this adds another level of complexity where we don't know the ID names of the select fields so that we can hard code the ID values in a variable.</p>
[ { "answer_id": 74434392, "author": "Jonathon Hibbard", "author_id": 1244184, "author_profile": "https://Stackoverflow.com/users/1244184", "pm_score": 0, "selected": false, "text": "typeof key === 'object' && !Array.isArray(key)" }, { "answer_id": 74434496, "author": "Yosvel Quintero", "author_id": 1932552, "author_profile": "https://Stackoverflow.com/users/1932552", "pm_score": 2, "selected": false, "text": "string" }, { "answer_id": 74434569, "author": "Yarden Buzaglo", "author_id": 19441159, "author_profile": "https://Stackoverflow.com/users/19441159", "pm_score": 1, "selected": false, "text": "const data = {\n dateSession: '14/11/2022',\n HRdata: {\n 1: 86,\n 2: 88,\n 3: 86,\n 4: 85,\n },\n SPO2data: {\n 1: 98,\n 2: 97,\n 3: 97,\n 4: 96,\n },\n}\n\nconst flattenedData = {}\nconst flatten = (obj, oldName = '') => {\n //we are counting on the fact that we will get an object at first - you can add a condition to check it here\n const entries = Object.entries(obj)\n //iterate through the object. If we are encountering another object - send it again in recursion. If it's a value - add it to the flattened object\n for (const [key, value] of entries) {\n typeof value === 'object' && !Array.isArray(value)\n ? flatten(value, key + '-')\n : (flattenedData[oldName + key] = value)\n }\n}\n\nflatten(data)\nconsole.log(flattenedData)" }, { "answer_id": 74436678, "author": "Bhavya Dhiman", "author_id": 4167172, "author_profile": "https://Stackoverflow.com/users/4167172", "pm_score": 0, "selected": false, "text": "const obj = {\n \"dateSession\": \"14/11/2022\",\n \"HRdata\": {\n \"1\": 86,\n \"2\": 88,\n \"3\": 86,\n \"4\": 85\n },\n \"SPO2data\": {\n \"1\": 98,\n \"2\": 97,\n \"3\": 97,\n \"4\": 96,\n }\n};\n\nlet newObj = {};\n\nfunction modifyJson(obj, newObj, count, upperKey) {\n for (const key of Object.keys(obj)) {\n if (typeof obj[key] === 'object') {\n newObj = modifyJson(obj[key], newObj, count + 1, key);\n } else if (count > 0) {\n newObj[`${upperKey}-${key}`] = obj[key];\n } else {\n newObj[key] = obj[key];\n }\n }\n return newObj;\n}\n\nnewObj = modifyJson(obj, {}, 0, '');\nconsole.log(newObj);\n" }, { "answer_id": 74459059, "author": "Rohìt Jíndal", "author_id": 4116300, "author_profile": "https://Stackoverflow.com/users/4116300", "pm_score": 0, "selected": false, "text": "const obj = {\n \"dateSession\": \"14/11/2022\",\n \"HRdata\": {\n \"1\": 86,\n \"2\": 88,\n \"3\": 86,\n \"4\": 85\n },\n \"SPO2data\": {\n \"1\": 98,\n \"2\": 97,\n \"3\": 97,\n \"4\": 96\n }\n};\n\nconst finalObj = {};\n\nObject.keys(obj).forEach(key => {\n if (typeof obj[key] === 'object') {\n Object.keys(obj[key]).forEach(innerObjKey => {\n finalObj[`${key}-${innerObjKey}`] = obj[key][innerObjKey]\n })\n } else {\n finalObj[key] = obj[key]\n }\n});\n\nconsole.log(finalObj);" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434227", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6021828/" ]
74,434,240
<p>I am trying to send an email with html code. In it I place my image. But when receiving a letter in the mail, the image is not displayed.</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;div class="header__container "&gt; &lt;img src="mysite/logo.svg" alt="logo" class="header_img"&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>However, it does not appear in the email.</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;img src="https://ci6.googleusercontent.com/proxy/c33cuVIg8CI8ogTZFezJa6bgoZ97KqPgefyR9YPF6vSGfi1zqQFXkx3AMyB0h8hD338LoBPvMR7JTyIt3F0Y=s0-d-e1-ft#https://sherf201.pythonanywhere.com/logo.svg" alt="logo" class="CToWUd" data-bit="iit" jslog="138226; u014N:xr6bB; 53:W2ZhbHNlLDJd"&gt;</code></pre> </div> </div> </p> <p>And I get this line in the Img tag. My email sending code</p> <pre><code>server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() try: server.login(EMAIL_BOT, PASSWORD_BOT) msg = MIMEMultipart('alternative') part1 = MIMEText(message, 'html') msg.attach(part1) msg['From'] = EMAIL_BOT msg['To'] = email msg[&quot;Subject&quot;] = name server.sendmail(EMAIL_BOT, email, msg.as_string()) except Exception as ex: print(ex) </code></pre> <p>How do I send an image in my html code?</p>
[ { "answer_id": 74434924, "author": "Eugene Astafiev", "author_id": 1603351, "author_profile": "https://Stackoverflow.com/users/1603351", "pm_score": 3, "selected": true, "text": "Content-ID" }, { "answer_id": 74436460, "author": "Sherlock_201", "author_id": 18680342, "author_profile": "https://Stackoverflow.com/users/18680342", "pm_score": 0, "selected": false, "text": " server.login(EMAIL_BOT, PASSWORD_BOT)\n \n msg = MIMEMultipart('alternative')\n part1 = MIMEText(message, 'html')\n msg.attach(part1)\n\n img_data = open('filename', 'rb').read()\n img = MIMEImage(img_data, name = os.path.basename('filename'))\n img.add_header('Content-ID', '<image>'.format('filename'))\n msg.attach(img)\n\n msg['From'] = EMAIL_BOT\n msg['To'] = email\n msg[\"Subject\"] = name\n server.sendmail(EMAIL_BOT, email, msg.as_string())\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18680342/" ]
74,434,242
<p>I'm trying to install the package 'semPlot' in RStudio, and keep getting errors:</p> <pre><code>** testing if installed package can be loaded from temporary location *** arch - i386 Error: package or namespace load failed for 'rockchalk' in library.dynam(lib, package, package.lib): DLL 'zip' not found: maybe not installed for this architecture? Error: loading failed Execution halted *** arch - x64 ERROR: loading failed for 'i386' * removing 'C:/Documents/R/win-library/4.0/rockchalk' Warning in install.packages : installation of package ‘rockchalk’ had non-zero exit status ERROR: failed to lock directory 'C:/Documents/R/win-library/4.0' for modifying Try removing 'C:/Documents/R/win-library/4.0/00LOCK-OpenMx' Warning in install.packages : installation of package ‘OpenMx’ had non-zero exit status ERROR: dependencies 'rockchalk', 'OpenMx' are not available for package 'semPlot' * removing 'C:/Documents/R/win-library/4.0/semPlot' Warning in install.packages : installation of package ‘semPlot’ had non-zero exit status The downloaded source packages are in ‘C:\AppData\Local\Temp\RtmpE9qK0s\downloaded_packages’ </code></pre> <p>I already installed the package ‘rockchalk’, but it didn't help. The first time I tried to install 'semPlot' there was an almost endless process which also ended with an error.</p>
[ { "answer_id": 74434924, "author": "Eugene Astafiev", "author_id": 1603351, "author_profile": "https://Stackoverflow.com/users/1603351", "pm_score": 3, "selected": true, "text": "Content-ID" }, { "answer_id": 74436460, "author": "Sherlock_201", "author_id": 18680342, "author_profile": "https://Stackoverflow.com/users/18680342", "pm_score": 0, "selected": false, "text": " server.login(EMAIL_BOT, PASSWORD_BOT)\n \n msg = MIMEMultipart('alternative')\n part1 = MIMEText(message, 'html')\n msg.attach(part1)\n\n img_data = open('filename', 'rb').read()\n img = MIMEImage(img_data, name = os.path.basename('filename'))\n img.add_header('Content-ID', '<image>'.format('filename'))\n msg.attach(img)\n\n msg['From'] = EMAIL_BOT\n msg['To'] = email\n msg[\"Subject\"] = name\n server.sendmail(EMAIL_BOT, email, msg.as_string())\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434242", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20502023/" ]
74,434,245
<p>I found there is <a href="https://docs.python.org/3/library/functions.html#object" rel="nofollow noreferrer"><strong>object()</strong></a> which is a built-in function in Python. *You can find <a href="https://docs.python.org/3/library/functions.html#object" rel="nofollow noreferrer"><strong>object()</strong></a> in <a href="https://docs.python.org/3/library/functions.html#built-in-functions" rel="nofollow noreferrer"><strong>Built-in Functions</strong></a></p> <p>And, the documentation says below:</p> <blockquote> <p>Return a new featureless object. object is a base for all classes. It has methods that are common to all instances of Python classes. This function does not accept any arguments.</p> </blockquote> <p>As the documentation says, <a href="https://docs.python.org/3/library/functions.html#object" rel="nofollow noreferrer"><strong>object()</strong></a> can create an object but I don't know how to do it.</p> <p>My questions:</p> <ul> <li>How to create an object with <a href="https://docs.python.org/3/library/functions.html#object" rel="nofollow noreferrer"><strong>object()</strong></a>?</li> <li>When to use <a href="https://docs.python.org/3/library/functions.html#object" rel="nofollow noreferrer"><strong>object()</strong></a>? or What are the use cases of <a href="https://docs.python.org/3/library/functions.html#object" rel="nofollow noreferrer"><strong>object()</strong></a>?</li> </ul>
[ { "answer_id": 74434336, "author": "jthulhu", "author_id": 5956261, "author_profile": "https://Stackoverflow.com/users/5956261", "pm_score": 2, "selected": false, "text": "object" }, { "answer_id": 74564485, "author": "Kai - Kazuya Ito", "author_id": 8172439, "author_profile": "https://Stackoverflow.com/users/8172439", "pm_score": 0, "selected": false, "text": "print(type(object()))\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8172439/" ]
74,434,247
<p>I am trying to download a report that is generated daily on the first request to the report's endpoint.</p> <p>When the report is being created, the endpoint returns a <code>HTTP 202</code>.</p> <p>I have the following code to handle some errors and redirects, as well as trying to &quot;sleep&quot; for 60 seconds before continuing try the endpoint again. Unfortunately, the second console log to tell me the download completed is never called, though the file does indeed download successfully and the filestream closes.</p> <hr /> <pre class="lang-js prettyprint-override"><code>// Main function run() async function run() { await getReport() await processReport() } async function getReport() { console.log(`Downloading ${reportFileName}`) await downloadFile(url, reportFileName) console.log(`Downloaded ${reportFileName} successfully.`) // This is never called? } </code></pre> <pre class="lang-js prettyprint-override"><code>async function downloadFile (url, targetFile) { return await new Promise((resolve, reject) =&gt; { https.get(url, async response =&gt; { const code = response.statusCode ?? 0 if (code &gt;= 400) { return reject(new Error(response.statusMessage)) } // handle redirects if (code &gt; 300 &amp;&amp; code &lt; 400 &amp;&amp; !!response.headers.location) { resolve(downloadFile(response.headers.location, targetFile)) return } // handle file creation pending if (code == 202) { console.log(`Report: ${reportFileName} is still being generated, trying again in ${timeToSleepMs/1000} seconds...`) await sleep(timeToSleepMs) resolve(downloadFile(url, targetFile)) return } // make download directory regardless of if it exists fs.mkdirSync(outputPath, { recursive: true }, (err) =&gt; { if (error) throw error; }); // save the file to disk const fileWriter = fs .createWriteStream(`${outputPath}/${targetFile}`) .on('finish', () =&gt; { resolve({}) }) response.pipe(fileWriter) }).on('error', error =&gt; { reject(error) }) }) } </code></pre> <p>Finally my sleep function:</p> <pre class="lang-js prettyprint-override"><code>let timeToSleepMs = (60 * 1000) function sleep(ms) { return new Promise((resolve) =&gt; { setTimeout(resolve, ms); }); } </code></pre> <p>I'm pretty sure this has to do with some sort of async issue because that always seems to be my issue with Node, but I'm not sure how to handle it. I just want to fetch a file and download it locally, retrying if I get a <code>HTTP 202</code>. If there's a better way, please let me know!</p> <p>tl;dr - How do I properly handle waiting for a <code>HTTP 202</code> response to turn into a <code>HTTP 200</code> when the file is generated, then continue executing code after the file is downloaded?</p>
[ { "answer_id": 74434866, "author": "Heiko Theißen", "author_id": 16462950, "author_profile": "https://Stackoverflow.com/users/16462950", "pm_score": 3, "selected": true, "text": "await downloadFile(url, reportFileName)" }, { "answer_id": 74437713, "author": "Bergi", "author_id": 1048572, "author_profile": "https://Stackoverflow.com/users/1048572", "pm_score": 1, "selected": false, "text": "return" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7242101/" ]
74,434,255
<p>It is possible to create a QR code which contains both some text and photo (which is small logo) in python?</p> <p>I mean text, which is not part of the photo. But I will have separately text (string variable) and photo (e.g. *.png).</p> <p>So far I saw only the examples where it was possible to create a QR code from text or photo. I couldn't find example with both used at the same time.</p> <p>Basically when I scan my QR code, I would like for it to show my photo (logo) and text information.</p>
[ { "answer_id": 74437527, "author": "JNevill", "author_id": 2221001, "author_profile": "https://Stackoverflow.com/users/2221001", "pm_score": 2, "selected": true, "text": "import base64\n\n#open image and convert to b64 string\nwith open(\"small.png\", \"rb\") as img_file:\n my_string = base64.b64encode(img_file.read())\n\n#append a message to b64 encoded image\nmy_string = my_string + b'\\0' + base64.b64encode(b'some text')\n\n#write out the qrcode\nimport qrcode\nqr = qrcode.QRCode(\n version=2,\n error_correction=qrcode.constants.ERROR_CORRECT_M,\n)\nqr.add_data(my_string, optimize=0)\nqr.make()\nqr.make_image().save(\"qrcode.png\")\n\n#--------Now when reading the qr code:-------#\n#open qr code and read in with cv2 (as an example), decode with pyzbar\nfrom pyzbar.pyzbar import decode\nimport cv2 #importing opencv\nimg = cv2.imread('qrcode.png', 0) \nbarcodes = decode(img)\n\nfor barcode in barcodes:\n barcodeData = barcode.data.decode(\"utf-8\")\n\n#split the b64 string by the null byte we wrote\ndata = barcodeData.split('\\x00')\n\n#save image to file after decoding b64\nfilename = 'some_image.jpg' \nwith open(filename, 'wb') as f:\n f.write(base64.b64decode(data[0]))\n\n#print out message after decoding\nprint(base64.b64decode(data[1]))\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18582965/" ]
74,434,278
<p><strong>This is my sonar.properties file</strong></p> <pre><code>sonar.host.url=https://sonar.cloud.health.ge.com/ sonar.projectKey=ils sonar.projectName=ILS sonar.projectVersion=1.0.0 sonar.sources=library/core sonar.java.binaries=library/core/target/classes sonar.exclusions=library/core/target/**/*, library/core/src/test/**/* sonar.tests=library/core/src/test/ sonar.java.test.libraries=library/core/target/test-classes/ &gt; sonar.junit.reportsPath=library/core/target/surefire-reports/CalculatorTest.xml // test cases are generated fine but sonarqube is not taking the junit reports in the pipeline sonar.coverage.jacoco.xmlReportPaths=library/core/target/site/jacoco/jacoco.xml </code></pre> <blockquote> <p>I have pushed the testreports manually and Below is the unit-test command in Jenkins File</p> </blockquote> <pre><code>unitTestCommand = 'cd library/core &amp;&amp; mvn test &amp;&amp; mvn surefire-report:report' unitTestReportDir = 'library/core/target/site' arch = 'hc-eu-west-aws-artifactory.cloud.health.ge.com/docker-eis-all/build-tools-eis-repo:1.0.0' </code></pre>
[ { "answer_id": 74437527, "author": "JNevill", "author_id": 2221001, "author_profile": "https://Stackoverflow.com/users/2221001", "pm_score": 2, "selected": true, "text": "import base64\n\n#open image and convert to b64 string\nwith open(\"small.png\", \"rb\") as img_file:\n my_string = base64.b64encode(img_file.read())\n\n#append a message to b64 encoded image\nmy_string = my_string + b'\\0' + base64.b64encode(b'some text')\n\n#write out the qrcode\nimport qrcode\nqr = qrcode.QRCode(\n version=2,\n error_correction=qrcode.constants.ERROR_CORRECT_M,\n)\nqr.add_data(my_string, optimize=0)\nqr.make()\nqr.make_image().save(\"qrcode.png\")\n\n#--------Now when reading the qr code:-------#\n#open qr code and read in with cv2 (as an example), decode with pyzbar\nfrom pyzbar.pyzbar import decode\nimport cv2 #importing opencv\nimg = cv2.imread('qrcode.png', 0) \nbarcodes = decode(img)\n\nfor barcode in barcodes:\n barcodeData = barcode.data.decode(\"utf-8\")\n\n#split the b64 string by the null byte we wrote\ndata = barcodeData.split('\\x00')\n\n#save image to file after decoding b64\nfilename = 'some_image.jpg' \nwith open(filename, 'wb') as f:\n f.write(base64.b64decode(data[0]))\n\n#print out message after decoding\nprint(base64.b64decode(data[1]))\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14458837/" ]
74,434,311
<p>I am trying to write down unit test for my repository which is interacting with MongoDb but facing a problem/exception in mocking the objects. This is what I have tried so far;</p> <p>This is how my class looks like i.e. I have create a repository class and extend it from interface;</p> <pre><code>public class UserManagementRepository : IUserManagementRepository { private readonly IMongoCollection&lt;UserModel&gt; _users; public UserManagementRepository(IDatabaseSettings dbSettings, IApplicationSettings applicationSettings, IMongoClient mongoClient) { IMongoDatabase database = mongoClient.GetDatabase(dbSettings.DatabaseName); _users = database.GetCollection&lt;UserModel&gt;(applicationSettings.UserCollectionName); } public async Task&lt;GeneralResponse&gt; Get(string id) { GeneralResponse response = new GeneralResponse(); try { IAsyncCursor&lt;UserModel&gt; userModel = await _users.FindAsync(user =&gt; user.Id == id); if (userModel != null) { response.Message = &quot;User exists!&quot;; response.Data = userModel.FirstOrDefault(); response.ResponseCode = ResponseCode.Success; } else { response.Message = $&quot;User with Id: {id} not found!&quot;; response.ResponseCode = ResponseCode.Success; } } catch (Exception ex) { response.Message = &quot;Failure&quot;; response.ResponseCode = ResponseCode.Error; } return response; } } </code></pre> <p>This is how my Test class look like</p> <pre><code>public class UserManagmentRepositoryTests { private Mock&lt;IDatabaseSettings&gt; _mockDbSettings; private Mock&lt;IApplicationSettings&gt; _mockApplicationSettings; private Mock&lt;IMongoClient&gt; _mockClient; public UserManagmentRepositoryTests() { _mockDbSettings = new Mock&lt;IDatabaseSettings&gt;(); _mockApplicationSettings = new Mock&lt;IApplicationSettings&gt;(); _mockClient = new Mock&lt;IMongoClient&gt;(); } [Fact] public async Task GetUserWithId_Test() { // Arrange var repo = new Mock&lt;IUserManagementRepository&gt;(); IDatabaseSettings dbSettings = new DatabaseSettings() { ConnectionString = &quot;mongodb:connectionstring&quot;, DatabaseName = &quot;dbname&quot; }; _mockDbSettings.Setup(x =&gt; x).Returns(dbSettings); IApplicationSettings applicationSettings = new ApplicationSettings() { UserCollectionName = &quot;users&quot; }; _mockApplicationSettings.Setup(app =&gt; applicationSettings).Returns(applicationSettings); MongoClientSettings clientSettings = MongoClientSettings.FromConnectionString(dbSettings.ConnectionString); MongoClient client = new MongoClient(clientSettings); _mockClient.Setup(c =&gt; client); var ctr = new UserManagementRepository(_mockDbSettings.Object, _mockApplicationSettings.Object, _mockClient.Object); // Act var result = ctr.Get(&quot;132&quot;); // Assert //result.StatusCode.Should().NotBeNull(); } } </code></pre> <p>I get an exception on every setup</p> <p><a href="https://i.stack.imgur.com/CA4LN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CA4LN.png" alt="Exception" /></a></p>
[ { "answer_id": 74434745, "author": "Caveman74", "author_id": 2032864, "author_profile": "https://Stackoverflow.com/users/2032864", "pm_score": 0, "selected": false, "text": " IApplicationSettings applicationSettings = new ApplicationSettings() { UserCollectionName = \"users\" };\n _mockApplicationSettings.Setup(app => applicationSettings).Returns(applicationSettings);\n\n" }, { "answer_id": 74466667, "author": "Heehaaw", "author_id": 2050652, "author_profile": "https://Stackoverflow.com/users/2050652", "pm_score": 1, "selected": false, "text": "ApplicationSettings" }, { "answer_id": 74494066, "author": "Aym003", "author_id": 20471079, "author_profile": "https://Stackoverflow.com/users/20471079", "pm_score": -1, "selected": false, "text": " public class UserManagmentRepositoryTests\n{\n private Mock<IMongoClient> _mockClient;\n public UserManagmentRepositoryTests()\n {\n _mockClient = new Mock<IMongoClient>();\n }\n\n [Fact]\n public async Task GetUserWithId_Test()\n {\n // Arrange\n var repo = new Mock<IUserManagementRepository>();\n IDatabaseSettings dbSettings = new DatabaseSettings()\n {\n ConnectionString = \"mongodb:connectionstring\",\n DatabaseName = \"dbname\"\n };\n\n IApplicationSettings applicationSettings = new ApplicationSettings() { UserCollectionName = \"users\" };\n\n MongoClientSettings clientSettings = MongoClientSettings.FromConnectionString(dbSettings.ConnectionString);\n MongoClient client = new MongoClient(clientSettings);\n _mockClient.Setup(c => client);\n\n var ctr = new UserManagementRepository(dbSettings, applicationSettings, _mockClient.Object);\n\n // Act\n var result = ctr.Get(\"132\");\n\n // Assert\n //result.StatusCode.Should().NotBeNull();\n }\n}\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7167486/" ]
74,434,334
<p><strong>Background</strong></p> <p>I wrote an exact, short yet complete example of a Parent component with a nested Child component which simply attempts:</p> <ol> <li>Alter a string in the Parent's state</li> <li>See the Child component updated when the Parent's state value is altered (<code>this.state.name</code>)</li> </ol> <p><strong>Here's What It Looks Like</strong> When the app loads a <code>default value</code> is passed from Parent state to child props.</p> <p><a href="https://i.stack.imgur.com/FUSjB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FUSjB.png" alt="Parent / Child component" /></a></p> <p><strong>Change The Name</strong></p> <p>All I want to do is allow the change of the name after the user adds a new name in the Parent's <code>&lt;input&gt;</code> and clicks the Parent's <code>&lt;button&gt;</code></p> <p>However, as you can see, when the user clicks the button only the Parent is rendered again.</p> <h2>Questions</h2> <ol> <li>Is it possible to get the Child to render the new value?</li> <li>What am i doing wrong in this example -- why isn't it updating or rendering the new value?</li> </ol> <p><a href="https://i.stack.imgur.com/8abON.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8abON.png" alt="Parent change is rendered" /></a></p> <h3>All Source Code</h3> <p>Here is all of the source code and you can <a href="https://parentchildrx.stackblitz.io" rel="nofollow noreferrer">view it and try it in my StackBlitz project</a>.</p> <p>I've kept it as simple as possible.</p> <p><strong>Parent component</strong> (<code>DataLoader</code>)</p> <pre><code>import * as React from 'react'; import { useState } from 'react'; import { Grid } from './Grid.tsx'; interface LoaderProps { name: string; } export class DataLoader extends React.Component&lt;LoaderProps, {}&gt; { state: any = {}; constructor(props: LoaderProps) { super(props); this.state.name = this.props.name; this.changeName = this.changeName.bind(this); } render() { const { name } = this.state; let parentOutput = &lt;span&gt;{name}&lt;/span&gt;; return ( &lt;div&gt; &lt;button onClick={this.changeName}&gt;Change Name&lt;/button&gt; &lt;input id=&quot;mapvalue&quot; type=&quot;text&quot; placeholder=&quot;name&quot; /&gt; &lt;hr id=&quot;parent&quot; /&gt; &lt;div&gt;### Parent ###&lt;/div&gt; &lt;strong&gt;Name&lt;/strong&gt;: {parentOutput} &lt;hr id=&quot;child&quot; /&gt; &lt;Grid childName={name} /&gt; &lt;/div&gt; ); } changeName() { let newValue = document.querySelector('#mapvalue').value.toString(); console.log(newValue); this.setState({ name: newValue, }); } } </code></pre> <p>Child component (<code>Grid</code>)</p> <pre><code>import * as React from 'react'; interface PropsParams { childName: string; } export class Grid extends React.Component&lt;PropsParams, {}&gt; { state: any = {}; constructor(props: PropsParams) { super(props); let counter = 0; this.state = { childName: this.props.childName }; console.log(`CHILD -&gt; this.state.name : ${this.state.childName}`); } render() { const { childName } = this.state; let mainChildOutput = &lt;span&gt;{childName}&lt;/span&gt;; return ( &lt;div&gt; &lt;div&gt;### Child ####&lt;/div&gt; &lt;strong&gt;Name&lt;/strong&gt;: {mainChildOutput} &lt;/div&gt; ); } } </code></pre> <p><strong>App.tsx</strong> is set up like the following -- this is where default value comes in on props</p> <pre><code>import * as React from 'react'; import { DataLoader } from './DataLoader.tsx'; import './style.css'; export default function App() { return ( &lt;div&gt; &lt;DataLoader name={'default value'} /&gt; &lt;/div&gt; ); } </code></pre>
[ { "answer_id": 74434406, "author": "David", "author_id": 328193, "author_profile": "https://Stackoverflow.com/users/328193", "pm_score": 2, "selected": false, "text": "export class Grid extends React.Component<PropsParams, {}> {\n render() {\n const { childName } = this.props; // <--- read the value from props, not local state\n let mainChildOutput = <span>{childName}</span>;\n return (\n <div>\n <div>### Child ####</div>\n <strong>Name</strong>: {mainChildOutput}\n </div>\n );\n }\n}\n" }, { "answer_id": 74434450, "author": "Sennen Randika", "author_id": 11489268, "author_profile": "https://Stackoverflow.com/users/11489268", "pm_score": 1, "selected": false, "text": "childName" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/255243/" ]
74,434,368
<p>I have this code:</p> <pre><code>string.replace(/[~!@#$%^&amp;*()_\-+={}[\]|&quot;':;?,/&gt;&lt;,\\]/g,''); </code></pre> <p>I want to remove all invalid characters from domain. It's working fine, but additionally I want to remove <code>-</code> character from the end if it is here.</p> <p>So, <code>te-!#$#@$@#st-.com</code> will be <code>te-st.com</code>.</p> <p>I tried added something like that <code>[-]$</code>, so the code looks like this:</p> <pre><code>string.replace(/[~!@#$%^&amp;`*()_\+={}[\]|&quot;':;?,/&gt;&lt;,\\][-]$/g,'') </code></pre> <p>But this doesn't work, any ideas?</p>
[ { "answer_id": 74434489, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 3, "selected": true, "text": "string.replace(/[~!@#$%^&`*()_\\+={}[\\]|\"':;?,\\/><,\\\\]|-+(?=\\.)/g, '')\n" }, { "answer_id": 74434648, "author": "Albair", "author_id": 5179608, "author_profile": "https://Stackoverflow.com/users/5179608", "pm_score": 0, "selected": false, "text": "const firstIndex = string.indexOf('-');\nstring.replace(/[~!@#$%^&*()_\\-+={}[\\]|\"':;?,/><,\\\\]/g,\n (match,offset) => offset === firstIndex ? match : ''\n);\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20499064/" ]
74,434,404
<p>I'm struggling a little bit to find a solution for a specific problem where I've been trying to solve by using HTML grid or flex-box. I want to build a two columns layout container where the row item height should be dynamic and if there's a gap, fill it with a new row item which is not part of the original list.</p> <p>Let's suppose that I have a list of 6 items where I want to display in a container of two columns, like this:</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>.row { display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-start; } .column { flex-basis: 50%; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="row"&gt; &lt;div class="column" style="background-color:#aaa;"&gt; &lt;img src="https://revistacarro.com.br/wp-content/uploads/2021/03/aston-vantage-safety-car.jpg" alt="Girl in a jacket" width="100" height="100"&gt; &lt;/div&gt; &lt;div class="column" style="background-color:#bbb;"&gt; &lt;img src="https://revistacarro.com.br/wp-content/uploads/2021/03/aston-vantage-safety-car.jpg" alt="Girl in a jacket" width="100" height="100"&gt; &lt;/div&gt; &lt;div class="column" style="background-color:#bbb;"&gt; &lt;img src="https://revistacarro.com.br/wp-content/uploads/2021/03/aston-vantage-safety-car.jpg" alt="Girl in a jacket" width="100" height="100"&gt; &lt;/div&gt; &lt;div class="column" style="background-color:#bbb;"&gt; &lt;img src="https://revistacarro.com.br/wp-content/uploads/2021/03/aston-vantage-safety-car.jpg" alt="Girl in a jacket" width="100" height="100"&gt; &lt;/div&gt; &lt;div class="column" style="background-color:#bbb;"&gt; &lt;img src="https://revistacarro.com.br/wp-content/uploads/2021/03/aston-vantage-safety-car.jpg" alt="Girl in a jacket" width="100" height="100"&gt; &lt;/div&gt; &lt;div class="column" style="background-color:#bbb;"&gt; &lt;img src="https://revistacarro.com.br/wp-content/uploads/2021/03/aston-vantage-safety-car.jpg" alt="Girl in a jacket" width="100" height="100"&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>But in my problem I can have different image height, something like this:</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>.row { display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-start; } .column { flex-basis: 50%; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="row"&gt; &lt;div class="column" style="background-color:#aaa;"&gt; &lt;img src="https://revistacarro.com.br/wp-content/uploads/2021/03/aston-vantage-safety-car.jpg" alt="Girl in a jacket" width="100" height="100"&gt; &lt;/div&gt; &lt;div class="column" style="background-color:#bbb;"&gt; &lt;img src="https://revistacarro.com.br/wp-content/uploads/2021/03/aston-vantage-safety-car.jpg" alt="Girl in a jacket" width="100" height="50"&gt; &lt;/div&gt; &lt;div class="column" style="background-color:#bbb;"&gt; &lt;img src="https://revistacarro.com.br/wp-content/uploads/2021/03/aston-vantage-safety-car.jpg" alt="Girl in a jacket" width="100" height="100"&gt; &lt;/div&gt; &lt;div class="column" style="background-color:#bbb;"&gt; &lt;img src="https://revistacarro.com.br/wp-content/uploads/2021/03/aston-vantage-safety-car.jpg" alt="Girl in a jacket" width="100" height="50"&gt; &lt;/div&gt; &lt;div class="column" style="background-color:#bbb;"&gt; &lt;img src="https://revistacarro.com.br/wp-content/uploads/2021/03/aston-vantage-safety-car.jpg" alt="Girl in a jacket" width="100" height="100"&gt; &lt;/div&gt; &lt;div class="column" style="background-color:#bbb;"&gt; &lt;img src="https://revistacarro.com.br/wp-content/uploads/2021/03/aston-vantage-safety-car.jpg" alt="Girl in a jacket" width="100" height="100"&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>I would like that the row item to not use the whole row height, basically behaving as tiles when needed. The extra effort is to on the end of the column (neither left or right) to fill an extra gap with a new row item, which in my use case will be an advertisement tile.</p> <p>This is one example where the tile height is dynamically set based on the image and the idea is to have an extra tile in case there's a gap.</p> <p><a href="https://i.stack.imgur.com/iCK09.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iCK09.png" alt="enter image description here" /></a></p> <p>Thanks in advance for any help!</p>
[ { "answer_id": 74434489, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 3, "selected": true, "text": "string.replace(/[~!@#$%^&`*()_\\+={}[\\]|\"':;?,\\/><,\\\\]|-+(?=\\.)/g, '')\n" }, { "answer_id": 74434648, "author": "Albair", "author_id": 5179608, "author_profile": "https://Stackoverflow.com/users/5179608", "pm_score": 0, "selected": false, "text": "const firstIndex = string.indexOf('-');\nstring.replace(/[~!@#$%^&*()_\\-+={}[\\]|\"':;?,/><,\\\\]/g,\n (match,offset) => offset === firstIndex ? match : ''\n);\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3444041/" ]
74,434,407
<p>I am using the standard <code>collections.deque</code> to write a LIFO stack where each object may occur multiple times, but now I am cornered around the use case for removing the <strong>last occurrence of a given object</strong> (but not whatever is the rightmost object of the stack!).</p> <p>While <code>appendleft</code>, <code>extendleft</code> and <code>popleft</code> counterparts exist for these three methods, no <code>removeright</code> (nor <code>indexright</code>) exist. So the following is not possible.</p> <pre class="lang-py prettyprint-override"><code>import collections stack = collections.deque() a = object() b = object() c = object() stack.append(a) stack.append(b) stack.append(c) stack.append(a) stack.append(b) stack.append(c) list(stack) # [a, b, c, a, b, c] stack.removeright(b) # Fat chance list(stack) # Whish: [a, b, c, a, c] and *NOT* [a, c, a, b, c] </code></pre> <p>Am I missing something obvious?</p> <p>Right now I am going with a double reverse call like</p> <pre class="lang-py prettyprint-override"><code>def removeright(stack, item): stack.reverse() try: stack.remove(item) finally: stack.reverse() </code></pre> <p>but this feels wrong. I am worried about both inefficiency and potential pitfalls down the road for this approach.</p> <p>I could always use the queue &quot;backwards&quot; (actually quite conventional), using <code>appendleft</code> and <code>remove</code>, but I'd like to retain the &quot;append&quot; semantics and still not have to write a thin wrapper patching every right/left stack method to a left/right queue method.</p> <p>Would someone share their insights/experience on the subject?</p>
[ { "answer_id": 74434489, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 3, "selected": true, "text": "string.replace(/[~!@#$%^&`*()_\\+={}[\\]|\"':;?,\\/><,\\\\]|-+(?=\\.)/g, '')\n" }, { "answer_id": 74434648, "author": "Albair", "author_id": 5179608, "author_profile": "https://Stackoverflow.com/users/5179608", "pm_score": 0, "selected": false, "text": "const firstIndex = string.indexOf('-');\nstring.replace(/[~!@#$%^&*()_\\-+={}[\\]|\"':;?,/><,\\\\]/g,\n (match,offset) => offset === firstIndex ? match : ''\n);\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11715259/" ]
74,434,418
<p>I have two dataframes and a function, which works when I use it on a single variable.</p> <pre><code>library(tidyverse) iris1&lt;-iris iris2&lt;-iris iris_fn&lt;-function(df,species_type){ df1&lt;-df%&gt;% filter((Species==species_type)) return(df1)} new_df&lt;-iris_fn(df=iris1, species_type=&quot;setosa&quot;) </code></pre> <p>I want to pass a vector of variables to the function with the expected output being a list of dataframes (3), one filtered to each variable, for which I have been experimenting using lapply:</p> <pre><code>variables&lt;-c(&quot;setosa&quot;,&quot;versicolor&quot;,&quot;virginica&quot;) new_df&lt;-lapply(df=iris1, species_type=&quot;setosa&quot;, FUN= iris_fn) </code></pre> <p>The error message is <code>Error in is.vector(X) : argument &quot;X&quot; is missing, with no default</code> which I dont understand because I have stated the variables of the function and what the name of the function is.</p> <p>Can anyone suggest a solution to get the desired output? I essentially need a version of lapply or purrr function that will allow a dataframe and a vector as inputs.</p>
[ { "answer_id": 74434489, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 3, "selected": true, "text": "string.replace(/[~!@#$%^&`*()_\\+={}[\\]|\"':;?,\\/><,\\\\]|-+(?=\\.)/g, '')\n" }, { "answer_id": 74434648, "author": "Albair", "author_id": 5179608, "author_profile": "https://Stackoverflow.com/users/5179608", "pm_score": 0, "selected": false, "text": "const firstIndex = string.indexOf('-');\nstring.replace(/[~!@#$%^&*()_\\-+={}[\\]|\"':;?,/><,\\\\]/g,\n (match,offset) => offset === firstIndex ? match : ''\n);\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434418", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10107805/" ]
74,434,503
<p>As the title says, when I pass over a quoted URL to background-image or cursor, it simply doesn't load the file. <br/> I work with Vue and have the <strong>following libraries installed</strong>: Vuetify, SASS, SASS-Loader, Node-SASS. <br/> I cannot uninstall Node-SASS as my project fails to run without it.</p> <p>Here are some examples:</p> <pre><code>// This works #app { cursor: url(../public/graphics/Nights_Edge.png), auto; } // This doesn't work #app { cursor: url('../public/graphics/Nights_Edge.png'), auto; } // This also doesn't work #app { cursor: &quot;url(../public/graphics/Nights_Edge.png)&quot;, auto; } </code></pre> <p>My follow up question is, how do I pass over such a URL with Javascript, if a quoted URL doesn't load?<br/> What I tried to do:<br/></p> <pre><code>document.getElementById(&quot;app&quot;).style.cursor = &quot;url(../public/graphics/Nights_Edge.png) auto&quot;; </code></pre> <p><br/>Obviously deleting the quote marks leaves me in a sea of red.</p>
[ { "answer_id": 74434550, "author": "Ben Borchard", "author_id": 4054720, "author_profile": "https://Stackoverflow.com/users/4054720", "pm_score": -1, "selected": false, "text": "\\" }, { "answer_id": 74450956, "author": "Patryk Dajos", "author_id": 20011501, "author_profile": "https://Stackoverflow.com/users/20011501", "pm_score": 0, "selected": false, "text": "document.getElementById(\"app\").style.cursor = 'unset';" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20011501/" ]
74,434,507
<p>I am running the examples at this <a href="https://r-graph-gallery.com/308-interactive-circle-packing.html" rel="nofollow noreferrer">link</a>. After re-installing ggiraph, the same code that was working before, returns this error</p> <pre><code>Error: ! Problem while converting geom to grob. ℹ Error occurred in the 1st layer. Caused by error in `check.length()`: ! 'gpar' element 'lwd' must not be length 0 Run `rlang::last_error()` to see where the error occurred. </code></pre> <p>Any suggestion?</p>
[ { "answer_id": 74434550, "author": "Ben Borchard", "author_id": 4054720, "author_profile": "https://Stackoverflow.com/users/4054720", "pm_score": -1, "selected": false, "text": "\\" }, { "answer_id": 74450956, "author": "Patryk Dajos", "author_id": 20011501, "author_profile": "https://Stackoverflow.com/users/20011501", "pm_score": 0, "selected": false, "text": "document.getElementById(\"app\").style.cursor = 'unset';" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11662862/" ]
74,434,516
<p>I have a task that is configured to retry 3 times. I would like to perform some logic if the exception of the original failure is of a certain type. Is it possible from run 2 of the task for example, to extract the exception from the first attempt?</p>
[ { "answer_id": 74434550, "author": "Ben Borchard", "author_id": 4054720, "author_profile": "https://Stackoverflow.com/users/4054720", "pm_score": -1, "selected": false, "text": "\\" }, { "answer_id": 74450956, "author": "Patryk Dajos", "author_id": 20011501, "author_profile": "https://Stackoverflow.com/users/20011501", "pm_score": 0, "selected": false, "text": "document.getElementById(\"app\").style.cursor = 'unset';" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3517647/" ]
74,434,520
<pre><code>&lt;li class=&quot;menu pbar&quot;&gt;Rank: &lt;?php echo createBalk($rank['procenten']); ?&gt;&lt;/li&gt; &lt;li class=&quot;menu pbar&quot;&gt;leven: &lt;?php echo createBalk($leven); ?&gt;&lt;/li&gt; </code></pre> <pre><code>function createBalk($score) { if($score &gt;= 100) { return &quot;&lt;div class='progress-bar'&gt; &lt;div class='pfull' width='$score'&gt;{$score}%&lt;/div&gt; &lt;/div&gt;&quot;; } elseif($score &gt;= 50 &amp;&amp; $score &lt; 100) { return &quot;&lt;div class='progress-bar'&gt; &lt;div class='pfull' width='$score'&gt;{$score}%&lt;/div&gt; &lt;div class='pempty' width='100 - $score'&gt;&lt;/div&gt; &lt;/div&gt;&quot;; } elseif($score &lt; 50 &amp;&amp; $score &gt; 0) { return &quot;&quot;; } elseif($score == 0) { return &quot;&quot;; } } </code></pre> <pre><code>.pbar { display: flex; width: 100%; } .progress-bar { max-width: 100px; width: 100%; display: flex; } .pfull { background-color: #00ff00; height: 100%; } .pempty { background-color: #008000; height: 100%; } </code></pre> <p>If i try make a balk for my website but somehow the balk never show up in the right way. From the function createBalk.</p> <p>Lets say $score is 60. then balk must be 60 light green 40 dark green. This normally gives me a balk off 100% width.</p> <p>Somehow that doesnt happen if i dont give it any text it wont show up at all. For some reason the div width doesnt work.</p> <p>Can someone help me thx for having look/crack at it.</p>
[ { "answer_id": 74434550, "author": "Ben Borchard", "author_id": 4054720, "author_profile": "https://Stackoverflow.com/users/4054720", "pm_score": -1, "selected": false, "text": "\\" }, { "answer_id": 74450956, "author": "Patryk Dajos", "author_id": 20011501, "author_profile": "https://Stackoverflow.com/users/20011501", "pm_score": 0, "selected": false, "text": "document.getElementById(\"app\").style.cursor = 'unset';" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16828751/" ]
74,434,535
<p>I'm trying to display a very simple array in the template. I can't get my head around why this does not work.</p> <p>I get the data with a try/catch statement. The data is JSON and it has an array inside, so I guess that clarifies as multilevel array.</p> <p>The constant displays correctly in <code>console.log</code>, but not in the template.</p> <p>Trying to display the data</p> <pre class="lang-html prettyprint-override"><code>&lt;template&gt; &lt;!-- This doesn't return anything --&gt; {{modules}} &lt;!-- Neither does this --&gt; &lt;span v-for=&quot;(item, index) in modules&quot; :key=&quot;index&quot;&gt;{{item}}&lt;/a&gt; &lt;!-- This works as it should --&gt; &lt;li v-for=&quot;company in companies&quot; :key=&quot;companies.company_name&quot;&gt; {{ company.company_name }} {{ company.app_modules }} &lt;pre&gt;{{ company }}&lt;/pre&gt; &lt;/li&gt; &lt;/template&gt; </code></pre> <p>Get the data</p> <pre class="lang-js prettyprint-override"><code>const companies = ref([]) try { // Await and get the data companies.value = data const modules = data[0].app_modules // This logs the array console.log(modules) } catch (e) { console.error(e) } </code></pre> <p>The &quot;modules&quot; Array is this simple</p> <pre class="lang-js prettyprint-override"><code>[ &quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;, &quot;5&quot;, &quot;6&quot;, &quot;7&quot;, &quot;8&quot;, &quot;9&quot; ] </code></pre>
[ { "answer_id": 74453173, "author": "Nikola Gava", "author_id": 19656174, "author_profile": "https://Stackoverflow.com/users/19656174", "pm_score": 0, "selected": false, "text": "const modules" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2385394/" ]
74,434,542
<p>I am using a panel data set and intent to model this as a dynamic affiliation network using SAOMs. The data is unfortunately very messy and a pain to deal with.</p> <p>I have managed to create adjacency matrices for each panel wave. However, over time the panel grew in size / people left. I need the number of rows in each matrix to be the same and in the same order according to the unique IDs, which are present when inspecting the objects in R. All &quot;added IDs&quot; should show 10s across the whole row.</p> <p>Here is a reproducible example that should make the issue clear and also shows what I aim for. I assume this can be solved by smart use of the merge() function, but I could not get it to work:</p> <pre><code>wave1 &lt;- matrix(c(0,0,1,1,0,1,1,0,1,1), nrow = 5, ncol = 2, dimnames = list(c(&quot;1&quot;,&quot;2&quot;,&quot;4&quot;,&quot;5&quot;,&quot;9&quot;), c(&quot;group1&quot;,&quot;group2&quot;))) wave2 &lt;- matrix(c(0,1,1,0,1,0,1,1), nrow = 4, ncol = 2, dimnames = list(c(&quot;1&quot;,&quot;4&quot;,&quot;8&quot;,&quot;9&quot;), c(&quot;group1&quot;,&quot;group2&quot;))) wave1_c &lt;- matrix(c(0,0,1,1,10,0,1,1,0,0,10,1), nrow = 6, ncol = 2, dimnames = list(c(&quot;1&quot;,&quot;2&quot;,&quot;4&quot;,&quot;5&quot;,&quot;8&quot;,&quot;9&quot;), c(&quot;group1&quot;,&quot;group2&quot;))) wave2_c &lt;- matrix(c(0,10,1,10,1,0,1,10,0,10,1,1), nrow = 6, ncol = 2, dimnames = list(c(&quot;1&quot;,&quot;2&quot;,&quot;4&quot;,&quot;5&quot;,&quot;8&quot;,&quot;9&quot;), c(&quot;group1&quot;,&quot;group2&quot;))) </code></pre> <p>Thanks in advance. Numbers in the matrices are arbitrary except for the 10s.</p>
[ { "answer_id": 74453173, "author": "Nikola Gava", "author_id": 19656174, "author_profile": "https://Stackoverflow.com/users/19656174", "pm_score": 0, "selected": false, "text": "const modules" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434542", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7471427/" ]
74,434,544
<p>I am working on angular app and I have a progress bar and code is as follows :</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>.bar { --d: 1rem; /* arrow depth */ --gap: 0.3rem; /* arrow thickness, gap */ display: flex; margin-right: var(--d); } .bar-step { flex: 1; display: flex; justify-content: center; align-items: center; text-align: center; padding: 0.6rem var(--d); margin-right: calc(var(--d) * -1 + var(--gap)); background: #d9e3f7; color: #23468c; clip-path: polygon( 0% 0%, calc(100% - var(--d)) 0%, 100% 50%, calc(100% - var(--d)) 100%, 0% 100%, var(--d) 50%); } .bar-step:first-child { clip-path: polygon( 0% 0%, calc(100% - var(--d)) 0%, 100% 50%, calc(100% - var(--d)) 100%, 0% 100%); } .bar-step.active { background: #23468c; color: #fff; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="bar"&gt; &lt;div class="bar-step active"&gt;Step 1&lt;/div&gt; &lt;div class="bar-step"&gt;Step 2 text&lt;/div&gt; &lt;div class="bar-step"&gt;Step 3&lt;/div&gt; &lt;div class="bar-step"&gt;Step 4&lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>How I can make right border of last child same as left border of first child?</p>
[ { "answer_id": 74434622, "author": "Harrison", "author_id": 15291770, "author_profile": "https://Stackoverflow.com/users/15291770", "pm_score": 1, "selected": false, "text": "clip-path" }, { "answer_id": 74434690, "author": "aflyzer", "author_id": 8356856, "author_profile": "https://Stackoverflow.com/users/8356856", "pm_score": 3, "selected": true, "text": ".bar {\n --d: 1rem;\n /* arrow depth */\n --gap: 0.3rem;\n /* arrow thickness, gap */\n display: flex;\n margin-right: var(--d);\n}\n\n.bar-step {\n flex: 1;\n display: flex;\n justify-content: center;\n align-items: center;\n text-align: center;\n padding: 0.6rem var(--d);\n margin-right: calc(var(--d) * -1 + var(--gap));\n background: #d9e3f7;\n color: #23468c;\n clip-path: polygon( 0% 0%, calc(100% - var(--d)) 0%, 100% 50%, calc(100% - var(--d)) 100%, 0% 100%, var(--d) 50%);\n}\n\n.bar-step:first-child {\n clip-path: polygon( 0% 0%, calc(100% - var(--d)) 0%, 100% 50%, calc(100% - var(--d)) 100%, 0% 100%);\n}\n\n.bar-step:last-child {\n clip-path: polygon( 0% 0%, calc(100% - var(--d)) 0%, calc(100% - var(--d)) 0%, calc(100% - var(--d)) 100%, 0% 100%, var(--d) 50%)\n}\n\n.bar-step.active {\n background: #23468c;\n color: #fff;\n}" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17800542/" ]
74,434,557
<pre><code>public static double readNumber(String prompt,double min, double max){ Scanner scanner = new Scanner(System.in); double value; while (true){ System.out.print(prompt); value = scanner.nextFloat(); if (value &gt;= min &amp;&amp; value &lt;= max) { break; } else System.out.println(&quot;Enter a value between &quot;+min+&quot; and &quot;+max); } return value; } </code></pre> <p>The upper one works. But the following one doesn't jump out of the loop.</p> <pre><code>def readnumber(prompt, minimum, maximum): while True: value = float(input(prompt)) if minimum &lt;= value &lt;= maximum: return value else: print(f&quot;a valid value needed between {minimum} and {maximum}&quot;) break </code></pre> <p>It doesn't work the same way. HELP the new beginner please</p>
[ { "answer_id": 74434706, "author": "wallbloggerbeing", "author_id": 16581025, "author_profile": "https://Stackoverflow.com/users/16581025", "pm_score": 0, "selected": false, "text": "print(readnumber(\"input a number: \", 2, 4))\n" }, { "answer_id": 74435024, "author": "diliGentt", "author_id": 15612188, "author_profile": "https://Stackoverflow.com/users/15612188", "pm_score": 0, "selected": false, "text": "flag = true\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20502344/" ]
74,434,572
<p>I searched the whole web, but was not able to find the reason <em>why</em> <code>strftime</code> is being removed from php. From my point of view it was the perfect function for easy access to custom date formats. The &quot;alternative&quot; <code>IntlDateFormatter::format()</code> feels so cumbersome.</p> <p>Can anyone explain why <code>strftime</code> is no longer part of php?</p>
[ { "answer_id": 74434640, "author": "Alexander Santos", "author_id": 10473393, "author_profile": "https://Stackoverflow.com/users/10473393", "pm_score": 2, "selected": false, "text": "IntlDateFormatter::format" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1635166/" ]
74,434,592
<p>I want to to display this reversed pyramid next to each other but the problem is the right side of my pyramid is different in the left side of my pyramid. How can I fix this? <img src="https://i.stack.imgur.com/jmakq.png" alt="Here is the lopsided image" /> and <img src="https://i.stack.imgur.com/A2iJd.png" alt="this is what it should look like" />.</p> <pre><code>package proj; public class Looping { public static void main(String[]args) { for (int r=5; r&gt;0; r--) { for (int s=5-r; s&gt;0; s--) { System.out.print(&quot; &quot;); } for (int k=2*r-1; k&gt;0; k--) { System.out.print(&quot;*&quot;); } for (int s=5-r; s&gt;0; s--) { System.out.print(&quot; &quot;); } for (int k=2*r-1; k&gt;0; k--) { System.out.print(&quot;*&quot;); } System.out.println(); } } } </code></pre>
[ { "answer_id": 74434750, "author": "Maarten Bodewes", "author_id": 589259, "author_profile": "https://Stackoverflow.com/users/589259", "pm_score": 0, "selected": false, "text": "for" }, { "answer_id": 74434874, "author": "Mr. Polywhirl", "author_id": 1762224, "author_profile": "https://Stackoverflow.com/users/1762224", "pm_score": -1, "selected": false, "text": "public class Pyramids {\n public static void main(String[] args) {\n System.out.println(render(2, 9)); // 2 pyramids with a base of 9\n System.out.println(render(4, 5)); // 4 pyramids with a base of 5\n }\n \n public static String render(int count, int size) {\n StringBuffer buffer = new StringBuffer();\n int rows = (int) Math.floor(size / 2) + 1;\n for (int row = 0; row < rows; row++) {\n for (int pyramid = 0; pyramid < count; pyramid++) {\n int indentSize = pyramid == 0 ? row : row * 2;\n for (int indent = 0; indent < indentSize; indent++) {\n buffer.append(\" \"); // indent\n }\n int starCount = size - (row * 2);\n for (int star = 0; star < starCount; star++) {\n buffer.append(\"*\"); // star\n }\n buffer.append(\" \");; // separator\n }\n buffer.append(System.lineSeparator()); // new-line\n }\n return buffer.toString();\n }\n}\n" }, { "answer_id": 74435060, "author": "Arvind Kumar Avinash", "author_id": 10819573, "author_profile": "https://Stackoverflow.com/users/10819573", "pm_score": 2, "selected": false, "text": "String#repeat" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20422766/" ]
74,434,593
<p>Is it possible to filter null values from a map?</p> <pre><code>const myMap = new Map&lt;string, string|undefined&gt;([ ['id1', 'value1'], ['id2', null], ['id3', 'value3'], ['id4', null], ]); </code></pre> <p>I would like my map with id1 and id4 only because the other ids have null values.</p> <p>Thanks</p>
[ { "answer_id": 74434660, "author": "Yarden Buzaglo", "author_id": 19441159, "author_profile": "https://Stackoverflow.com/users/19441159", "pm_score": 2, "selected": true, "text": "const myMap = new Map([\n ['id1', 'value1'],\n ['id2', null],\n ['id3', 'value3'],\n ['id4', null],\n]);\nconst res = new Map(Array.from(myMap).filter(val => val[1]))" }, { "answer_id": 74434661, "author": "Warm Red", "author_id": 14209943, "author_profile": "https://Stackoverflow.com/users/14209943", "pm_score": 2, "selected": false, "text": ".filter()" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11068392/" ]
74,434,603
<p>Okay, I am new to coding so please bear with me. I appreciate all the help.</p> <p>I want to create my own Twitter Scraper using Edge as my browser. My fist problem is that some words arent coloured. For example .webdriver.common.keys should be blue like in the video. (I put a link to the video in the file at the bottom I was watching for reference .</p> <p>2nd Problem I keep getting the error message to upgrade my selenium from 3 to 4 and I am pretty sure I already have the selenium 4 version. So I dont get why I get this error message.</p> <p>3rd problem how do I use/apply xpath on here to search right element. Do i need to import from library or update anaconda navigator? I am lost.</p> <p>Appreciate all the help.</p> <p>Kind regards,</p> <p>Squaddo.</p> <p>BELOW IS MY CODE:</p> <pre><code>import csv from getpass import getpass from time import sleep from selenium.webdriver.common.keys import Keys from selenium.common.exceptions import NoSuchElementException from msedge.selenium_tools import Edge, EdgeOptions options = EdgeOptions() options.use_chromium = True driver = Edge(options=options) C:\Users\Cagri\AppData\Local\Temp\ipykernel_13256\875207683.py:3: DeprecationWarning: Selenium Tools for Microsoft Edge is deprecated. Please upgrade to Selenium 4 which has built-in support for Microsoft Edge (Chromium): https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/#upgrading-from-selenium-3 driver = Edge(options=options) driver.get('https://www.twitter.com/login') username = driver.find_element_by_xpath('//input[@name=&quot;text&quot;]') username.send_keys('DataForCagri') --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_13256\3481032478.py in ----&gt; 1 username = driver.find_element_by_xpath('//input[@name=&quot;text&quot;]') 2 username.send_keys('DataForCagri') AttributeError: 'WebDriver' object has no attribute 'find_element_by_xpath' LINK TO THE YOUTUBE VIDEO!!!! https://www.youtube.com/watch?v=3KaffTIZ5II&amp;t=250s </code></pre> <p>I am really lost, dont have any friends nor family that does coding. So here I am requesting help from strangers. I appreciate all the help!</p>
[ { "answer_id": 74434660, "author": "Yarden Buzaglo", "author_id": 19441159, "author_profile": "https://Stackoverflow.com/users/19441159", "pm_score": 2, "selected": true, "text": "const myMap = new Map([\n ['id1', 'value1'],\n ['id2', null],\n ['id3', 'value3'],\n ['id4', null],\n]);\nconst res = new Map(Array.from(myMap).filter(val => val[1]))" }, { "answer_id": 74434661, "author": "Warm Red", "author_id": 14209943, "author_profile": "https://Stackoverflow.com/users/14209943", "pm_score": 2, "selected": false, "text": ".filter()" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20085742/" ]
74,434,608
<p>I am trying to find a way to find the closest value in a vector, from elements in the SAME vector, but excluding the row in question. For example, suppose I have dataframe A with one column (column_1):</p> <pre><code>column_1 1 5 6 2 3 0 5 2 1 9 </code></pre> <p>I want to add a second column which, for every element in column_1 finds the closest value in THAT SAME vector <em><strong>excluding</strong></em> the row in question. Desired output is below:</p> <pre><code>column_1 column_2 1 1 5 5 6 5 2 2 3 2 0 1 5 5 2 2 1 1 9 6 </code></pre> <p>I have seen people discuss how to do this where the closest value for each element in a vector (a) is identified from <em><strong>another</strong></em> vector (b) via the following:</p> <pre><code>which(abs(a-b)==min(a-b)) </code></pre> <p>Does anyone know how to modify the above, or do this in some other way, so that I can look within the same vector and exclude the row in question (example: the third row in column_1 is closest to 5 not 6, since I exclude its own row from the search vector. However, the fourth row in column_1 is closest to 2 since even when excluding the fourth row, there is another 2 value in the 8th row)</p>
[ { "answer_id": 74435172, "author": "Gregor Thomas", "author_id": 903061, "author_profile": "https://Stackoverflow.com/users/903061", "pm_score": 2, "selected": false, "text": "# sample data\nx = c(1, 5, 6, 2, 3, 0, 5, 2, 1, 9)\n\n# make a distance matrix and set diagonal to Inf\ndist = outer(x, x, FUN = \\(a, b) abs(a - b))\ndiag(dist) = Inf\n\n# find the index of the min value on each row\n# (which is the index of the max negative value\n# so we can use the convenient max.col)\nmins = max.col(-dist)\n\n# show the result\ny = x[mins]\ncbind(x, y)\n# x y\n# [1,] 1 1\n# [2,] 5 5\n# [3,] 6 5\n# [4,] 2 2\n# [5,] 3 2\n# [6,] 0 1\n# [7,] 5 5\n# [8,] 2 2\n# [9,] 1 1\n# [10,] 9 6\n" }, { "answer_id": 74435260, "author": "Rui Barradas", "author_id": 8245406, "author_profile": "https://Stackoverflow.com/users/8245406", "pm_score": 1, "selected": false, "text": "Inf" }, { "answer_id": 74436386, "author": "onyambu", "author_id": 8380272, "author_profile": "https://Stackoverflow.com/users/8380272", "pm_score": 3, "selected": true, "text": "y <- sort(x)\nz <- c(-Inf, y, Inf)\nb <- cbind(head(z, -2), tail(z, -2)) \nx[order(x)] <- b[cbind(seq_along(y), max.col(-abs(b - y)))]\nx\n[1] 1 5 5 2 2 1 5 2 1 6\n" }, { "answer_id": 74438157, "author": "jblood94", "author_id": 9463489, "author_profile": "https://Stackoverflow.com/users/9463489", "pm_score": 2, "selected": false, "text": "get.knn" }, { "answer_id": 74438535, "author": "ThomasIsCoding", "author_id": 12158757, "author_profile": "https://Stackoverflow.com/users/12158757", "pm_score": 1, "selected": false, "text": "dist" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17706204/" ]
74,434,650
<p>I am trying to set the iOS UIDatePicker to have a blank default date instead of the current date. is this possible?</p>
[ { "answer_id": 74435172, "author": "Gregor Thomas", "author_id": 903061, "author_profile": "https://Stackoverflow.com/users/903061", "pm_score": 2, "selected": false, "text": "# sample data\nx = c(1, 5, 6, 2, 3, 0, 5, 2, 1, 9)\n\n# make a distance matrix and set diagonal to Inf\ndist = outer(x, x, FUN = \\(a, b) abs(a - b))\ndiag(dist) = Inf\n\n# find the index of the min value on each row\n# (which is the index of the max negative value\n# so we can use the convenient max.col)\nmins = max.col(-dist)\n\n# show the result\ny = x[mins]\ncbind(x, y)\n# x y\n# [1,] 1 1\n# [2,] 5 5\n# [3,] 6 5\n# [4,] 2 2\n# [5,] 3 2\n# [6,] 0 1\n# [7,] 5 5\n# [8,] 2 2\n# [9,] 1 1\n# [10,] 9 6\n" }, { "answer_id": 74435260, "author": "Rui Barradas", "author_id": 8245406, "author_profile": "https://Stackoverflow.com/users/8245406", "pm_score": 1, "selected": false, "text": "Inf" }, { "answer_id": 74436386, "author": "onyambu", "author_id": 8380272, "author_profile": "https://Stackoverflow.com/users/8380272", "pm_score": 3, "selected": true, "text": "y <- sort(x)\nz <- c(-Inf, y, Inf)\nb <- cbind(head(z, -2), tail(z, -2)) \nx[order(x)] <- b[cbind(seq_along(y), max.col(-abs(b - y)))]\nx\n[1] 1 5 5 2 2 1 5 2 1 6\n" }, { "answer_id": 74438157, "author": "jblood94", "author_id": 9463489, "author_profile": "https://Stackoverflow.com/users/9463489", "pm_score": 2, "selected": false, "text": "get.knn" }, { "answer_id": 74438535, "author": "ThomasIsCoding", "author_id": 12158757, "author_profile": "https://Stackoverflow.com/users/12158757", "pm_score": 1, "selected": false, "text": "dist" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9525218/" ]
74,434,683
<p>I wanted to list all the products in the database and all the images, today each product can have several images and this way I did it, it returns 1 product object for each image</p> <p>I tried to do this, but I didn't get what I expected as I said above</p> <pre><code>async getAllProductAndImages() { const productsDatabase = await client.query(` SELECT products.*, products_images.id AS imageId, products_images.name AS imageName, products_images.product_id AS productImgId FROM products INNER JOIN products_images ON products.id = products_images.product_id`) const products = productsDatabase.rows.map(products =&gt; { const urlImage = `${process.env.APP_API_URL}/files/${products.imagename}` const productImage = new ProductImage(products.imagename, products.id) productImage.id = products.imageid productImage.url = urlImage const product = new Product( products.name, products.description, products.price, products.amount ) product.id = products.id product.productsImages = productImage return product }) return products } </code></pre> <p>productsDatabase.rows return</p> <pre><code>[ { &quot;id&quot;: &quot;3f671bc1-5163-44c8-88c9-4430d45f1471&quot;, &quot;name&quot;: &quot;a&quot;, &quot;description&quot;: &quot;a&quot;, &quot;price&quot;: &quot;10&quot;, &quot;amount&quot;: 5, &quot;imageid&quot;: &quot;78eb77d4-bf5a-44c1-a37a-0a28eb0f85ad&quot;, &quot;imagename&quot;: &quot;21bb52fa-9822-4732-88c4-8c00165185d6-sunrise-illustration-digital-art-uhdpaper.com-hd-4.1963.jpg&quot; }, { &quot;id&quot;: &quot;3f671bc1-5163-44c8-88c9-4430d45f1471&quot;, &quot;name&quot;: &quot;a&quot;, &quot;description&quot;: &quot;a&quot;, &quot;price&quot;: &quot;10&quot;, &quot;amount&quot;: 5, &quot;imageid&quot;: &quot;2157284b-34fd-41a4-ac3e-aa4d3f46b883&quot;, &quot;imagename&quot;: &quot;96afbbc7-c604-4cfd-b634-0f39a4f20601-starry_sky_boat_reflection_125803_1280x720.jpg&quot; } ] </code></pre> <p>return that I have using the code above</p> <pre><code>[ { &quot;id&quot;: &quot;3f671bc1-5163-44c8-88c9-4430d45f1471&quot;, &quot;name&quot;: &quot;a&quot;, &quot;description&quot;: &quot;a&quot;, &quot;price&quot;: &quot;10&quot;, &quot;amount&quot;: 5, &quot;productsImages&quot;: { &quot;id&quot;: &quot;78eb77d4-bf5a-44c1-a37a-0a28eb0f85ad&quot;, &quot;name&quot;: &quot;21bb52fa-9822-4732-88c4-8c00165185d6-sunrise-illustration-digital-art-uhdpaper.com-hd-4.1963.jpg&quot;, &quot;url&quot;: &quot;http://localhost:3000/files/21bb52fa-9822-4732-88c4-8c00165185d6-sunrise-illustration-digital-art-uhdpaper.com-hd-4.1963.jpg&quot;, &quot;product_id&quot;: &quot;3f671bc1-5163-44c8-88c9-4430d45f1471&quot; } }, { &quot;id&quot;: &quot;3f671bc1-5163-44c8-88c9-4430d45f1471&quot;, &quot;name&quot;: &quot;a&quot;, &quot;description&quot;: &quot;a&quot;, &quot;price&quot;: &quot;10&quot;, &quot;amount&quot;: 5, &quot;productsImages&quot;: { &quot;id&quot;: &quot;2157284b-34fd-41a4-ac3e-aa4d3f46b883&quot;, &quot;name&quot;: &quot;96afbbc7-c604-4cfd-b634-0f39a4f20601-starry_sky_boat_reflection_125803_1280x720.jpg&quot;, &quot;url&quot;: &quot;http://localhost:3000/files/96afbbc7-c604-4cfd-b634-0f39a4f20601-starry_sky_boat_reflection_125803_1280x720.jpg&quot;, &quot;product_id&quot;: &quot;3f671bc1-5163-44c8-88c9-4430d45f1471&quot; } ] </code></pre> <p>this is the return I expect and maybe there will be more stuff inside the productImages array there in the future</p> <pre><code>[ { &quot;id&quot;: &quot;3f671bc1-5163-44c8-88c9-4430d45f1471&quot;, &quot;name&quot;: &quot;a&quot;, &quot;description&quot;: &quot;a&quot;, &quot;price&quot;: &quot;10&quot;, &quot;amount&quot;: 5, &quot;productImages&quot;: [ { &quot;url&quot;: &quot;http://localhost:3000/files/21bb52fa-9822-4732-88c4-8c00165185d6-sunrise-illustration-digital-art-uhdpaper.com-hd-4.1963.jpg&quot;, &quot;url&quot;: &quot;http://localhost:3000/files/96afbbc7-c604-4cfd-b634-0f39a4f20601-starry_sky_boat_reflection_125803_1280x720.jpg&quot; } ] } ] </code></pre>
[ { "answer_id": 74435172, "author": "Gregor Thomas", "author_id": 903061, "author_profile": "https://Stackoverflow.com/users/903061", "pm_score": 2, "selected": false, "text": "# sample data\nx = c(1, 5, 6, 2, 3, 0, 5, 2, 1, 9)\n\n# make a distance matrix and set diagonal to Inf\ndist = outer(x, x, FUN = \\(a, b) abs(a - b))\ndiag(dist) = Inf\n\n# find the index of the min value on each row\n# (which is the index of the max negative value\n# so we can use the convenient max.col)\nmins = max.col(-dist)\n\n# show the result\ny = x[mins]\ncbind(x, y)\n# x y\n# [1,] 1 1\n# [2,] 5 5\n# [3,] 6 5\n# [4,] 2 2\n# [5,] 3 2\n# [6,] 0 1\n# [7,] 5 5\n# [8,] 2 2\n# [9,] 1 1\n# [10,] 9 6\n" }, { "answer_id": 74435260, "author": "Rui Barradas", "author_id": 8245406, "author_profile": "https://Stackoverflow.com/users/8245406", "pm_score": 1, "selected": false, "text": "Inf" }, { "answer_id": 74436386, "author": "onyambu", "author_id": 8380272, "author_profile": "https://Stackoverflow.com/users/8380272", "pm_score": 3, "selected": true, "text": "y <- sort(x)\nz <- c(-Inf, y, Inf)\nb <- cbind(head(z, -2), tail(z, -2)) \nx[order(x)] <- b[cbind(seq_along(y), max.col(-abs(b - y)))]\nx\n[1] 1 5 5 2 2 1 5 2 1 6\n" }, { "answer_id": 74438157, "author": "jblood94", "author_id": 9463489, "author_profile": "https://Stackoverflow.com/users/9463489", "pm_score": 2, "selected": false, "text": "get.knn" }, { "answer_id": 74438535, "author": "ThomasIsCoding", "author_id": 12158757, "author_profile": "https://Stackoverflow.com/users/12158757", "pm_score": 1, "selected": false, "text": "dist" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20502425/" ]
74,434,710
<p>First of all, some data similar to what I am working with.</p> <pre><code>rawdata &lt;- data.frame(Score = rnorm(1000, seq(1, 0, length.out = 10), sd = 1), Group = rep(LETTERS[1:3], 10000)) rawdata$Score &lt;- ifelse(rawdata$Group == &quot;A&quot;, rawdata$Score+2,rawdata$Score) rawdata$Score &lt;- ifelse(rawdata$Group == &quot;C&quot;, rawdata$Score-2,rawdata$Score) stdev &lt;- c(10.78,10.51,9.42) col &lt;- c(&quot;#004d8d&quot;, &quot;#cc2701&quot;, &quot;#e5b400&quot;) </code></pre> <p>Now, the code of my <code>geom_density_ridges</code> with quantile lines, which in this case they will be white.</p> <pre><code>p &lt;- ggplot(rawdata, aes(x = Score, y = Group)) + scale_y_discrete() + geom_rect(inherit.aes = FALSE, mapping = aes(ymin = 0, ymax = Inf, xmin = -0.1 * min(stdev), xmax = 0.1 * max(stdev)), fill = &quot;grey&quot;, alpha = 0.5) + geom_density_ridges(scale = -0.5, size = 1, alpha=0.5, show.legend = FALSE, quantile_lines = TRUE, quantiles = c(0.025, 0.975), vline_color = &quot;white&quot;, aes(fill = Group)) + scale_color_manual(values = col) + scale_fill_manual(values = col) + labs(title=&quot;Toy Graph&quot;, y=&quot;Group&quot;, x=&quot;Value&quot;) + coord_flip(xlim = c(-8, 8), ylim = NULL, expand = TRUE, clip = &quot;on&quot;) p </code></pre> <p>An we obtain the following plot, which is perfectly adjusted to expectation.</p> <p><a href="https://i.stack.imgur.com/atx1v.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/atx1v.png" alt="enter image description here" /></a></p> <p>Now I was wondering if there was a way to make only this little white quantile line transparent to the background. I tried first to set the <code>vline_color = &quot;transparent&quot;</code> and leaving the <code>aes(fill = Group)</code> at the end of <code>geom_density_ridges</code> at the logic that options where drew in order but it gets transparent not to the different shades of grey background but to the density fill (so the quantile line disappears), which is not what I am trying to achieve.</p> <p>Thanks in advance for your ideas!</p>
[ { "answer_id": 74435117, "author": "Ottie", "author_id": 17732851, "author_profile": "https://Stackoverflow.com/users/17732851", "pm_score": 1, "selected": false, "text": "ggplot(rawdata, aes(x = Score, y = Group)) +\n scale_y_discrete() +\n geom_density_ridges(scale = -0.5, size = 1, alpha=0.5, show.legend = FALSE,\n quantile_lines = TRUE, quantiles = c(0.025, 0.975), \n vline_color = \"grey90\", aes(fill = Group)) +\n scale_color_manual(values = col) + \n scale_fill_manual(values = col) +\n labs(title=\"Toy Graph\", y=\"Group\", x=\"Value\") +\n geom_rect(data=data.frame(), inherit.aes = FALSE, mapping = aes(\n ymin = 0, ymax = Inf, xmin = -0.1 * min(stdev), xmax = 0.1 * max(stdev)\n ), fill = \"black\", alpha = 0.25) +\n coord_flip(xlim = c(-8, 8), ylim = NULL, expand = TRUE, clip = \"on\")\n" }, { "answer_id": 74435345, "author": "tjebo", "author_id": 7941188, "author_profile": "https://Stackoverflow.com/users/7941188", "pm_score": 3, "selected": true, "text": "scales::alpha" }, { "answer_id": 74435455, "author": "Allan Cameron", "author_id": 12500315, "author_profile": "https://Stackoverflow.com/users/12500315", "pm_score": 1, "selected": false, "text": "library(tidyverse) \n\nrawdata %>%\n mutate(GroupNum = as.numeric(as.factor(Group))) %>%\n group_by(GroupNum, Group) %>%\n summarise(yval = first(GroupNum) - density(Score)$y,\n xval = density(Score)$x,\n q025 = quantile(Score, 0.025),\n q975 = quantile(Score, 0.975)) %>%\n mutate(Q = ifelse(xval < q025, 'low', ifelse(xval > q975, 'hi', 'mid'))) %>%\n ggplot(aes(xval, yval, group = interaction(Group, Q))) +\n geom_line(size = 1) +\n geom_ribbon(aes(ymax = GroupNum, ymin = yval, fill = Group),\n color = NA, alpha = 0.5, outline.type = 'full',\n data = . %>% filter(abs(q025 - xval) > 0.03 & \n abs(q975 - xval) > 0.03)) +\n coord_flip() +\n scale_fill_manual(values = col) +\n scale_y_continuous(breaks = 1:3, labels = levels(factor(rawdata$Group)),\n name = 'Group') +\n labs(x = 'Score')\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7453444/" ]
74,434,788
<p>Let's say I have</p> <pre><code>val asd = mutableListOf(&quot;lulu&quot;,&quot;bubu&quot;,&quot;gugu&quot;,&quot;bubu&quot;) </code></pre> <p>If I use <code>asd.remove(&quot;bubu&quot;)</code>, it only removes the first bubu.</p> <p>How to remove all bubu in asd without a loop?</p>
[ { "answer_id": 74434996, "author": "Tenfour04", "author_id": 506796, "author_profile": "https://Stackoverflow.com/users/506796", "pm_score": 2, "selected": false, "text": "remove()" }, { "answer_id": 74435145, "author": "abhishekrajak", "author_id": 8879652, "author_profile": "https://Stackoverflow.com/users/8879652", "pm_score": 3, "selected": true, "text": "asd.removeAll(mutableListOf(\"bubu\"))\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20222240/" ]
74,434,797
<p>I want to validate that all <code>values</code> in a dictionary adhere to a schema while the <code>keys</code> can be whatever. Is there a better way to do this than just using a pattern that matches everything:</p> <pre class="lang-json prettyprint-override"><code>&quot;foo&quot;: { &quot;type&quot;: &quot;object&quot;, &quot;patternProperties&quot;: { &quot;^.*$&quot;: { &quot;$ref&quot;: &quot;#/$defs/bar&quot; } } } </code></pre>
[ { "answer_id": 74435458, "author": "Clemens", "author_id": 227785, "author_profile": "https://Stackoverflow.com/users/227785", "pm_score": 1, "selected": false, "text": "additionalProperties" }, { "answer_id": 74435479, "author": "Jason Desrosiers", "author_id": 1320693, "author_profile": "https://Stackoverflow.com/users/1320693", "pm_score": 3, "selected": true, "text": "patternProperties" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16543731/" ]
74,434,800
<pre><code>import React, { useEffect, useState } from &quot;react&quot;; import Loading from &quot;./Loading&quot;; function App() { const url = &quot;https://course-api.com/react-tabs-project&quot;; const [loading, setLoading] = useState(true); const [data, setData] = useState([]); async function setCompany(companyName) { await getData(); const newData = data.filter((info) =&gt; info.company === companyName); setData(newData); } async function getData() { try { const response = await fetch(url); const data = await response.json(); setData(data); setLoading(false); } catch (err) { setLoading(false); console.error(`ERROR ==&gt; ${err}`); } } useEffect(() =&gt; { getData(); }, []); if (loading) { return &lt;Loading&gt;&lt;/Loading&gt;; // simple loading screen } return ( &lt;main&gt; &lt;div className=&quot;top-wrapper&quot;&gt; &lt;h2&gt;Experience&lt;/h2&gt; &lt;div className=&quot;underline&quot;&gt;&lt;/div&gt; &lt;/div&gt; {data.map((item) =&gt; { const { id, order, title, dates, duties, company } = item; return ( &lt;article key={id}&gt; &lt;h3&gt;{title}&lt;/h3&gt; &lt;span className=&quot;company&quot;&gt;{company}&lt;/span&gt; &lt;p&gt;{dates}&lt;/p&gt; &lt;ul&gt; {duties.map((duty, index) =&gt; { return &lt;li key={index}&gt;{duty}&lt;/li&gt;; })} &lt;/ul&gt; &lt;button&gt;MORE INFO&lt;/button&gt; &lt;/article&gt; ); })} &lt;div className=&quot;nav-buttons&quot;&gt; &lt;button onClick={() =&gt; { setCompany(&quot;TOMMY&quot;); }} className=&quot;nav-btn&quot; &gt; TOMMY &lt;/button&gt; &lt;button onClick={() =&gt; { setCompany(&quot;BIGDROP&quot;); }} className=&quot;nav-btn&quot; &gt; BIGDROP &lt;/button&gt; &lt;button onClick={() =&gt; { setCompany(&quot;CUKER&quot;); }} className=&quot;nav-btn&quot; &gt; CUKER &lt;/button&gt; &lt;/div&gt; &lt;/main&gt; ); } export default App; </code></pre> <p>Sooo... basically I'm trying to filter the array returned by <strong>Fetch</strong> and have it display only the category I want (I called it &quot;company instead of category in my code&quot;) depending on which button I click as shown in the &quot;nav-buttons&quot; div down in the code. The first time I click on a button it works fine, but the second time it doesn't show anything as if it's <strong>filtering</strong> from an <strong>already filtered array</strong> which return no results obviously.</p>
[ { "answer_id": 74435458, "author": "Clemens", "author_id": 227785, "author_profile": "https://Stackoverflow.com/users/227785", "pm_score": 1, "selected": false, "text": "additionalProperties" }, { "answer_id": 74435479, "author": "Jason Desrosiers", "author_id": 1320693, "author_profile": "https://Stackoverflow.com/users/1320693", "pm_score": 3, "selected": true, "text": "patternProperties" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20302920/" ]
74,434,850
<p>I have</p> <pre><code>var x: Int var invert: Boolean </code></pre> <p>and I need the value of the expression</p> <pre><code>if (invert) -x else x </code></pre> <p>Is there any more succinct way to write that expression in Kotlin?</p>
[ { "answer_id": 74436949, "author": "aSemy", "author_id": 4161471, "author_profile": "https://Stackoverflow.com/users/4161471", "pm_score": 0, "selected": false, "text": "invert" }, { "answer_id": 74438646, "author": "gidds", "author_id": 10134209, "author_profile": "https://Stackoverflow.com/users/10134209", "pm_score": 2, "selected": false, "text": "fun Int.negateIf(condition: Boolean) = if (condition) -this else this\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2452723/" ]
74,434,862
<p>I am kind of a beginner in python and stuck with the part where I have to access methods from a class which reside in a different file. Here, in File1 i am trying to access find_method from file2 to and do some operation and return values. But somehow its not accessing &quot;find_method&quot; from file2.</p> <pre><code>id_1.py (File1): from base_file import base_file class id_1: def condition(): day_part_response = ...some response... current_time = ...some value... abc = basefile.find_method(x=day_part_response, y=current_time) base_file.py (File2) class basefile: def find_method(self, x, y): for day in day_response: start = day[&quot;start_time&quot;] end = day[&quot;end_time&quot;] if (condition): --&gt;(consider this condition is satisfied) self.start_time = start self.end_time = end day_id = day[&quot;_id&quot;] self.entity_ID = day[&quot;entity_id&quot;] self.restore = True self.create_entity() return self.start_time, self.end_time, day_id, self.day_part_entity_ID, self.restore </code></pre>
[ { "answer_id": 74436949, "author": "aSemy", "author_id": 4161471, "author_profile": "https://Stackoverflow.com/users/4161471", "pm_score": 0, "selected": false, "text": "invert" }, { "answer_id": 74438646, "author": "gidds", "author_id": 10134209, "author_profile": "https://Stackoverflow.com/users/10134209", "pm_score": 2, "selected": false, "text": "fun Int.negateIf(condition: Boolean) = if (condition) -this else this\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6433588/" ]
74,434,879
<p>Even though it is odd and non-canonical, I would like to concatenate two <code>__m256d</code> and a <code>double</code> in a single <code>__m512d</code>. Specifically, I have</p> <pre><code>__m256d a = _mm256_set_pd(1, 2, 3, 0); __m256d b = _mm256_set_pd(4, 5, 6, 0); double c = 7; </code></pre> <p>At the end, I would like to have</p> <pre><code>__m512d d {1, 2, 3, 4, 5, 6, 7, 0} </code></pre> <p>Is there a fast way of doing this with Intel intrinsics?</p>
[ { "answer_id": 74435230, "author": "Sven Nilsson", "author_id": 4847311, "author_profile": "https://Stackoverflow.com/users/4847311", "pm_score": 1, "selected": false, "text": "__m256d a;\n__m256d b;\n__m512d c = _mm512_insertf64x4(_mm512_castpd256_pd512(a), b, 1);\n" }, { "answer_id": 74444462, "author": "Andrey Semashev", "author_id": 4636534, "author_profile": "https://Stackoverflow.com/users/4636534", "pm_score": 0, "selected": false, "text": "// Note: _mm256_set_pd lists elements from top to bottom, meaning in this case\n// the lowest elements are zero.\n__m256d a = _mm256_set_pd(1, 2, 3, 0);\n__m256d b = _mm256_set_pd(4, 5, 6, 0);\ndouble c = 7;\n\n// Expected result is:\n// __m512d d {1, 2, 3, 4, 5, 6, 7, 0}\n// Note: Here the elements are listed from bottom to top, meaning that the\n// last (i.e. upper) element is zero.\n\n// Insert c into the lower element of b.\n// We rely on that c is already in an xmm register and all upper elements are\n// likely zero, so _mm_set_sd and _mm256_zextpd128_pd256 are likely optimized\n// away. We also rely on that the lowest element of b is zero.\n// If the lowest element of b is not zero, use _mm256_blend_pd here instead.\n// If the order of elements in b is different, use _mm256_permutex2var_pd or,\n// as suggested by Peter Cordes in the comments, _mm512_insertf64x2\n// or _mm256_mask_broadcastsd_pd.\n__m256d bc = _mm256_or_pd(b, _mm256_zextpd128_pd256(_mm_set_sd(c)));\n\n// Merge and reorder elements of a and bc.\n// We rely on that the lowest element of a is zero, which we move to the top\n// element of d. If that is not the case and you still want zero in the top\n// element of d, you can use _mm512_maskz_permutex2var_pd here with a mask\n// of 0b01111111.\nconst __m512i d_perm_idx = _mm512_setr_epi64(3, 2, 1, 11, 10, 9, 8, 0);\n__m512d d = _mm512_permutex2var_pd(\n _mm512_castpd256_pd512(a), d_perm_idx, _mm512_castpd256_pd512(bc));\n" }, { "answer_id": 74446439, "author": "Peter Cordes", "author_id": 224132, "author_profile": "https://Stackoverflow.com/users/224132", "pm_score": 1, "selected": true, "text": "a" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11769441/" ]
74,434,927
<p>split dataframe character into small set of character list in dataframe?</p> <p>This is a dataframe, I need to split into as 10 10 character in a list of dataframe.</p> <pre><code>| contact_num | | -------------------------------| | 01111784885788634878 | | 247782788869775178889785427889 | | not available | | 2478544756 | </code></pre> <p>expected output:</p> <pre><code>| contact_num | | ------------------------------- --| | [0111178488,5788634878] | | [2477827888,6977517888,9785427889]| | not available | | [2478544756] | </code></pre>
[ { "answer_id": 74435230, "author": "Sven Nilsson", "author_id": 4847311, "author_profile": "https://Stackoverflow.com/users/4847311", "pm_score": 1, "selected": false, "text": "__m256d a;\n__m256d b;\n__m512d c = _mm512_insertf64x4(_mm512_castpd256_pd512(a), b, 1);\n" }, { "answer_id": 74444462, "author": "Andrey Semashev", "author_id": 4636534, "author_profile": "https://Stackoverflow.com/users/4636534", "pm_score": 0, "selected": false, "text": "// Note: _mm256_set_pd lists elements from top to bottom, meaning in this case\n// the lowest elements are zero.\n__m256d a = _mm256_set_pd(1, 2, 3, 0);\n__m256d b = _mm256_set_pd(4, 5, 6, 0);\ndouble c = 7;\n\n// Expected result is:\n// __m512d d {1, 2, 3, 4, 5, 6, 7, 0}\n// Note: Here the elements are listed from bottom to top, meaning that the\n// last (i.e. upper) element is zero.\n\n// Insert c into the lower element of b.\n// We rely on that c is already in an xmm register and all upper elements are\n// likely zero, so _mm_set_sd and _mm256_zextpd128_pd256 are likely optimized\n// away. We also rely on that the lowest element of b is zero.\n// If the lowest element of b is not zero, use _mm256_blend_pd here instead.\n// If the order of elements in b is different, use _mm256_permutex2var_pd or,\n// as suggested by Peter Cordes in the comments, _mm512_insertf64x2\n// or _mm256_mask_broadcastsd_pd.\n__m256d bc = _mm256_or_pd(b, _mm256_zextpd128_pd256(_mm_set_sd(c)));\n\n// Merge and reorder elements of a and bc.\n// We rely on that the lowest element of a is zero, which we move to the top\n// element of d. If that is not the case and you still want zero in the top\n// element of d, you can use _mm512_maskz_permutex2var_pd here with a mask\n// of 0b01111111.\nconst __m512i d_perm_idx = _mm512_setr_epi64(3, 2, 1, 11, 10, 9, 8, 0);\n__m512d d = _mm512_permutex2var_pd(\n _mm512_castpd256_pd512(a), d_perm_idx, _mm512_castpd256_pd512(bc));\n" }, { "answer_id": 74446439, "author": "Peter Cordes", "author_id": 224132, "author_profile": "https://Stackoverflow.com/users/224132", "pm_score": 1, "selected": true, "text": "a" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20502506/" ]
74,434,935
<pre><code>public static void main(String[] args){ boolean year = isLeapYear(9999); System.out.println(&quot;Is Leap Year: &quot; + year); } public static boolean isLeapYear(int year){ int rem4 = year % 4; int rem100 = year % 100; int rem400 = year % 400; if ((year &gt;= 1 &amp;&amp; year &lt;= 9999) &amp;&amp; (rem4 == 0) &amp;&amp; (rem100 == 0 &amp;&amp; rem400 == 0) || (rem100 != 0) &amp;&amp; (rem4 == 0)){ return true; } return false; } </code></pre> <p>When I enter a negative year (so far only -1024) my range condition doesn't work. But if I enter any other negative leap year it works(-2020). So I don't know what I'm possibly missing, or if the structure of the algorithm is quite right. Any help will be appreciated.</p> <p>What is expected is that when I enter a year that is not a leap year, and if it is a negative leap year, it returns false.</p>
[ { "answer_id": 74435006, "author": "thicchead", "author_id": 19815385, "author_profile": "https://Stackoverflow.com/users/19815385", "pm_score": 2, "selected": true, "text": "|| (rem100 != 0) && (rem4 == 0))" }, { "answer_id": 74435791, "author": "Alejandro Rojas", "author_id": 20501559, "author_profile": "https://Stackoverflow.com/users/20501559", "pm_score": 0, "selected": false, "text": "(year >= 1 && year <= 9999 && rem4 == 0 && rem100 == 0 && rem400 == 0 || year >= 1 && year <= 9999 && rem100 != 0 && rem4 == 0)\n" }, { "answer_id": 74437632, "author": "Jim Mischel", "author_id": 56778, "author_profile": "https://Stackoverflow.com/users/56778", "pm_score": 2, "selected": false, "text": "if (year < 1 || year > 9999)\n return false;\nif (rem4 != 0)\n return false;\nif (rem100 == 0 && rem400 != 0)\n return false;\nreturn true;\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20501559/" ]
74,434,980
<p>I am fairly new to <code>React</code> and still wrapping my head around <code>custom-hooks</code>. I cam across a code where a custom hook was created to handle the component imports.</p> <p><code>useComponentPalette.js</code></p> <pre><code>import {TodoEditor} from './components/TodoEditor' import {TodoItem} from './components/TodoItem' import {TodoList} from './components/TodoList' import {CheckBox} from './components/CheckBox' const defaultComponents = { TodoEditor, TodoItem, TodoList, CheckBox } export function useComponentPalette(){ return defaultComponents } </code></pre> <p>And then in order to use the hook,</p> <pre><code>const {TodoItem, TodoList, Checkbox } = useComponentPalette() </code></pre> <p><strong>My Question :-</strong> Does this approach provides any advantage over the regular imports in the component ? or this is an anti-pattern ?</p> <p>How I usually import the components is as follows</p> <pre><code>import {TodoEditor} from './components/TodoEditor' import {TodoItem} from './components/TodoItem' import {TodoList} from './components/TodoList' import {CheckBox} from './components/CheckBox' function App(){ return( &lt;&gt; &lt;TodoList/&gt; &lt;/&gt; ) } </code></pre>
[ { "answer_id": 74537931, "author": "Moufeed Juboqji", "author_id": 4399730, "author_profile": "https://Stackoverflow.com/users/4399730", "pm_score": 1, "selected": false, "text": "// first file name.js\nimport {TodoEditor} from './components/TodoEditor'\nimport {TodoItem} from './components/TodoItem'\nimport {TodoList} from './components/TodoList'\nimport {CheckBox} from './components/CheckBox'\n\nexport default {\nTodoEditor,\nTodoItem,\nTodoList,\nCheckBox\n}\n//component file\n\nimport * as Component form 'first file name'; \n//<Component.TodoEditor/>\n//or\nimport {TodoEditor} form 'first file name'; \n" }, { "answer_id": 74589214, "author": "DSDmark", "author_id": 16517581, "author_profile": "https://Stackoverflow.com/users/16517581", "pm_score": 0, "selected": false, "text": "import { Header, Footer, Sider } from \"./components\"" }, { "answer_id": 74615609, "author": "Hanan Mehmood", "author_id": 7118209, "author_profile": "https://Stackoverflow.com/users/7118209", "pm_score": 0, "selected": false, "text": "// components/index.tsx\n\nimport {Todo} from './todo'\nimport {CheckBox} from './components/CheckBox'\n\nexport {\n Todo,\n CheckBox\n}\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74434980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17393772/" ]
74,435,045
<p>For the below table is it possible to replace the date in 'DL_INC' column for 'PEN' in 'PEN_TYPE' column to the date in 'DL_INC' for 'PIP' in 'PEN_TYPE'? e.g. for MEM_REF 304852 for PEN_TYPE PEN the date should be updated from 06/04/2020 to 11/06/2020. The table is much larger but I've added a small section.</p> <p>I've tried using merge and insert into with no luck.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>MEM_REF</th> <th>PEN_TYPE</th> <th>DL_INC</th> </tr> </thead> <tbody> <tr> <td>304852</td> <td>PEN</td> <td>06/04/2020</td> </tr> <tr> <td>304582</td> <td>MODF</td> <td>06/04/2020</td> </tr> <tr> <td>304852</td> <td>PIP</td> <td>11/06/2020</td> </tr> <tr> <td>403523</td> <td>PEN</td> <td>06/04/2020</td> </tr> <tr> <td>403523</td> <td>MODF</td> <td>06/04/2020</td> </tr> <tr> <td>403523</td> <td>PIP</td> <td>20/07/2020</td> </tr> <tr> <td>503114</td> <td>PEN</td> <td>11/06/2020</td> </tr> <tr> <td>503114</td> <td>PIP</td> <td>20/02/2020</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74537931, "author": "Moufeed Juboqji", "author_id": 4399730, "author_profile": "https://Stackoverflow.com/users/4399730", "pm_score": 1, "selected": false, "text": "// first file name.js\nimport {TodoEditor} from './components/TodoEditor'\nimport {TodoItem} from './components/TodoItem'\nimport {TodoList} from './components/TodoList'\nimport {CheckBox} from './components/CheckBox'\n\nexport default {\nTodoEditor,\nTodoItem,\nTodoList,\nCheckBox\n}\n//component file\n\nimport * as Component form 'first file name'; \n//<Component.TodoEditor/>\n//or\nimport {TodoEditor} form 'first file name'; \n" }, { "answer_id": 74589214, "author": "DSDmark", "author_id": 16517581, "author_profile": "https://Stackoverflow.com/users/16517581", "pm_score": 0, "selected": false, "text": "import { Header, Footer, Sider } from \"./components\"" }, { "answer_id": 74615609, "author": "Hanan Mehmood", "author_id": 7118209, "author_profile": "https://Stackoverflow.com/users/7118209", "pm_score": 0, "selected": false, "text": "// components/index.tsx\n\nimport {Todo} from './todo'\nimport {CheckBox} from './components/CheckBox'\n\nexport {\n Todo,\n CheckBox\n}\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19084672/" ]
74,435,080
<p>I have a Parent component which two child components. All three components use accordion-group. My styles have a class as below and I want this class to apply only to the parent component. For some reason :not is not working for me. The class gets applied to the whole page so child components also get it</p> <p>Class</p> <pre><code>accordion-group :not(app-child){ .panel-heading { height: 44px; display: flex; align-items: center; width: 100%; padding-left: 20px; } .panel-body { padding-top: 0 !important; padding-left: 0 !important; padding-right: 0 !important; } .panel-title { width: 100%; } } </code></pre> <p>My html</p> <pre><code> &lt;accordian&gt; &lt;accordion-group&gt; &lt;div class=&quot;panel-heading&quot;&gt; &lt;div class=&quot;panel-title&quot;&gt; &lt;app-child&gt; &lt;accordian&gt; &lt;accordion-group&gt; &lt;div class=&quot;panel-heading&quot;&gt; &lt;div class=&quot;panel-title&quot;&gt; ... &lt;/div&gt; &lt;/div&gt; &lt;/accordion-group&gt; &lt;/accordian&gt; &lt;/app-child&gt; &lt;/div&gt; &lt;/div&gt; &lt;/accordion-group&gt; &lt;/accordian&gt; </code></pre> <p>Updates with another simple example</p> <p>html</p> <pre><code>&lt;div class=&quot;acc&quot;&gt; &lt;span class=&quot;acc&quot;&gt;span1&lt;/span&gt;&lt;br&gt; &lt;span class=&quot;acc&quot;&gt;span2&lt;/span&gt; &lt;div&gt; &lt;span class=&quot;acc&quot;&gt;span3&lt;/span&gt;&lt;br&gt; &lt;span class=&quot;acc&quot;&gt;span4&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Css</p> <pre><code>div:not(div){ border:solid black; } </code></pre> <p>I want only span1 and span2 to have the class applied.</p>
[ { "answer_id": 74435978, "author": "Lord-JulianXLII", "author_id": 19529102, "author_profile": "https://Stackoverflow.com/users/19529102", "pm_score": 0, "selected": false, "text": ".acc:not(span) {\n border: solid black;\n }" }, { "answer_id": 74436876, "author": "Mr. Stash", "author_id": 13625800, "author_profile": "https://Stackoverflow.com/users/13625800", "pm_score": 2, "selected": true, "text": ".acc>:not(div) {\n border: solid black;\n}" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2837961/" ]
74,435,136
<p>I have an Java web application which had an internal identity and access management. It was now suspended with the integration of Keycloak.</p> <p>Next to its web interface, my application has also a REST endpoint like <code>/api/authentication/login</code> (among others but this is the starting point) which could be called previously to get a token via: <code>curl -X POST http://localhost:8080/api/authentication/login -H 'Authorization: admin:admin'</code>.</p> <p>With the integration of Keycloak here, I cannot any longer login via that REST endpoint. I always get redirected to the login page of Keycloak which might makes sense in the way that it protects my app. But here I want to bypass the Keycloak login page and directly check the credentials and return a token if they match.</p> <p>What are my options to achieve this?</p> <p>Btw: the app does <strong>not</strong> use Spring Boot.</p> <p>I've tried to add a new Keycloak OpenID Client which would cover the <code>/api</code> Home URL and I also set the option &quot;Client Authentication&quot; to <code>false</code> but with no effect, i.e. I still get redirected to the Keycloak login page.</p>
[ { "answer_id": 74435523, "author": "Dhaval Gajjar", "author_id": 20142156, "author_profile": "https://Stackoverflow.com/users/20142156", "pm_score": 1, "selected": false, "text": "Direct Grant Flow" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5985343/" ]
74,435,159
<p>this is the <code>BehaviorSubject</code> getting value:</p> <p><code> private searchClinicByParams$: BehaviorSubject&lt;SearchClinicByParamsProps&gt; = new BehaviorSubject(initialSearchParams);</code></p> <p>here is my method needs to compose the vaues:</p> <pre><code>getParams() { const values = this.searchClinicByParams$.pipe( map((data) =&gt; data) ); console.log('values', values); } </code></pre> <p>at present above map not returns any value.</p> <p>here is my get method:</p> <pre><code> clinicList$ = this.http .get&lt;AddClinicProps[] | null&gt;( this.URL + `hfs-admin/customer-application/clinics?name=OUS&amp;adminUserName=${this.getParams()}` ) .pipe( map((clinics) =&gt; clinics), catchError(this.handleError) ); </code></pre> <p>how can i get return value at <code>this.getParams()</code> or what is the correct way to do it?</p>
[ { "answer_id": 74435862, "author": "Andres2142", "author_id": 2841091, "author_profile": "https://Stackoverflow.com/users/2841091", "pm_score": 2, "selected": false, "text": "getParams()" }, { "answer_id": 74436998, "author": "alex", "author_id": 379241, "author_profile": "https://Stackoverflow.com/users/379241", "pm_score": 0, "selected": false, "text": "getParams()" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/218349/" ]
74,435,161
<p>I've been working with Python for a while, but now I got curious if there is a way to see the code inside the built-in functions or methods of Python. I know that is not really necessary to know this, but some time I'm a curious person.</p> <p>Thanks for your help.</p>
[ { "answer_id": 74435862, "author": "Andres2142", "author_id": 2841091, "author_profile": "https://Stackoverflow.com/users/2841091", "pm_score": 2, "selected": false, "text": "getParams()" }, { "answer_id": 74436998, "author": "alex", "author_id": 379241, "author_profile": "https://Stackoverflow.com/users/379241", "pm_score": 0, "selected": false, "text": "getParams()" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17719806/" ]
74,435,173
<p>Input data:</p> <pre class="lang-py prettyprint-override"><code>data = [ ['0039384', [{'A': 415}, {'A': 228}, {'B': 360}, {'B': 198}, {'C': 300}, {'C': 165}]], ['0035584', [{'A': 345}, {'A': 117}, {'B': 223}, {'B': 554}, {'C': 443}, {'C': 143}]] ] df = pd.DataFrame(data=data, columns=['id', 'prices']) </code></pre> <p>I want to get this resut:</p> <pre><code>id CurrentPrice_A LastPrice_C CurrentPrice_B LastPrice_B CurrentPrice_C LastPrice_C 0039384 415 228 360 198 300 165 </code></pre> <p>I have tried to separate the dict and then every column to replace and rename than get the price, but it takes around 10 lines code. Do you know any short and fast way to do this.</p>
[ { "answer_id": 74435862, "author": "Andres2142", "author_id": 2841091, "author_profile": "https://Stackoverflow.com/users/2841091", "pm_score": 2, "selected": false, "text": "getParams()" }, { "answer_id": 74436998, "author": "alex", "author_id": 379241, "author_profile": "https://Stackoverflow.com/users/379241", "pm_score": 0, "selected": false, "text": "getParams()" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19846285/" ]
74,435,179
<p>I created a service account: <code>name@project.iam.gserviceaccount.com</code> and a custom role <code>mycustomrole</code>.</p> <p>How with <code>gcloud</code> command can I add the custom role to this service account?</p> <p>When I try</p> <pre><code>gcloud projects add-iam-policy-binding my-project \ --member=&quot;serviceAccount:myserviceaccount@myproject.iam.gserviceaccount.com&quot; \ --role=projects/myproject/roles/mycustomrole \ --verbosity=debug </code></pre> <p>I get an error:</p> <pre><code>ERROR: (gcloud.projects.add-iam-policy-binding) INVALID_ARGUMENT: The role name must be in the form &quot;roles/{role}&quot;, &quot;organizations/{organization_id}/roles/{role}&quot;, or &quot;projects/{project_id}/roles/{role}&quot;. </code></pre> <p>I tried already:</p> <pre><code> --role=roles/mycustomrole --role=projects/myproject/roles/mycustomrole --role=projects/myproject/roles/customrole/mycustomrole </code></pre>
[ { "answer_id": 74435410, "author": "Mazlum Tosun", "author_id": 9261558, "author_profile": "https://Stackoverflow.com/users/9261558", "pm_score": 2, "selected": false, "text": "gcloud projects add-iam-policy-binding my-project \\\n --member=\"serviceAccount:my-sa@my-project.iam.gserviceaccount.com\" \\\n --role=projects/my-project/roles/my.role.name \\\n --verbosity=debug\n" }, { "answer_id": 74450287, "author": "tr53", "author_id": 8552543, "author_profile": "https://Stackoverflow.com/users/8552543", "pm_score": 1, "selected": true, "text": "gcloud iam roles list --project=<PROJECT ID> --format=\"value(name)\"\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8552543/" ]
74,435,189
<p>I am using wxWebView in my application. Since this widget consumes all keyboard events internally, I have to create a synthetic keyboard event and process it. This is the code that I am using for creating a synthetic keyboard event:</p> <pre><code> // create a synthetic keyboard event and handle it wxKeyEvent keyEvent( wxEVT_KEY_DOWN ); keyEvent.SetEventObject( ctrl_ ); auto key = url.substr( keyCodePrefix_.length() ); if( key == &quot;Escape&quot; ) keyEvent.m_keyCode = WXK_ESCAPE; else if( key == &quot;F1&quot; ) keyEvent.m_keyCode = WXK_F1; else keyEvent.m_keyCode = WXK_NONE; ctrl_-&gt;ProcessWindowEvent( keyEvent ); </code></pre> <p>As you could see, I only handle <code>Escape</code> and <code>F1</code> keys for now. The type of keyboard event that I am using is <code>wxEVT_KEY_DOWN</code>. Everything works fine. According to the doc, the keyboard is processed in the widget then is sent to the application. However it does not trigger the shortcuts are set in the parent window ( that contains wxWebView widget ) via <a href="https://docs.wxwidgets.org/trunk/classwx_accelerator_table.html" rel="nofollow noreferrer">wxAcceleratorTable</a>.</p> <p>How should I create a keyboard event that trigger shortcuts in my accelerator table?</p> <p>I tried to set the type of keyboard event to <code>wxEVT_CHAR</code> but it also did not work.</p> <p>Update: my event handler is like below:</p> <pre><code>class MyApp : public wxApp { public: MyApp(); bool OnInit() override; // ... bool ProcessEvent(wxEvent&amp; event) override { if( event.GetEventType() == wxEVT_KEY_DOWN ) { wxKeyEvent&amp; ke = (wxKeyEvent&amp;)event; if( ke.GetKeyCode() == WXK_ESCAPE ) { // handle keyboard event } event.Skip(); // this does not help! } return wxApp::ProcessEvent( event ); } // ... DECLARE_EVENT_TABLE() }; </code></pre>
[ { "answer_id": 74435410, "author": "Mazlum Tosun", "author_id": 9261558, "author_profile": "https://Stackoverflow.com/users/9261558", "pm_score": 2, "selected": false, "text": "gcloud projects add-iam-policy-binding my-project \\\n --member=\"serviceAccount:my-sa@my-project.iam.gserviceaccount.com\" \\\n --role=projects/my-project/roles/my.role.name \\\n --verbosity=debug\n" }, { "answer_id": 74450287, "author": "tr53", "author_id": 8552543, "author_profile": "https://Stackoverflow.com/users/8552543", "pm_score": 1, "selected": true, "text": "gcloud iam roles list --project=<PROJECT ID> --format=\"value(name)\"\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435189", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3235404/" ]
74,435,191
<p>The first csv file contains a list of hostnames. The second csv file contains hostnames and logs. I would like to compare if the list of hostname exist in the second csv file using a batch file.</p> <p>I am working on a batch file using fc command but no luck yet to get my desired results.</p>
[ { "answer_id": 74436280, "author": "MVPxCoder", "author_id": 5114136, "author_profile": "https://Stackoverflow.com/users/5114136", "pm_score": -1, "selected": false, "text": "foreach($line in Get-Content .\\Hosts.csv) {\n if(Get-Content .\\Logs.csv | Select-String $line){\n echo \"The host $line exists!\"\n }\n else{\n echo \"The host $line doesn't exist.\"\n }\n}\n" }, { "answer_id": 74436616, "author": "Magoo", "author_id": 2128947, "author_profile": "https://Stackoverflow.com/users/2128947", "pm_score": 1, "selected": true, "text": "for /f %e in (file1) do findstr \"%e\" file2 >nul&if errorlevel 1 (echo %e>>missing) else (echo %e>>found)\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20502632/" ]
74,435,194
<p>is there any method that can return the fileID and corresponding guid of m_Mesh property in a prefab file? The m_Mesh is the mesh that used by the meshfilter component.</p> <p>How can i get the two values, 4300000 and 8b73e8872ca76104bbca4ee2b704a1b4 via script?</p> <p><a href="https://i.stack.imgur.com/Spkva.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Spkva.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74436280, "author": "MVPxCoder", "author_id": 5114136, "author_profile": "https://Stackoverflow.com/users/5114136", "pm_score": -1, "selected": false, "text": "foreach($line in Get-Content .\\Hosts.csv) {\n if(Get-Content .\\Logs.csv | Select-String $line){\n echo \"The host $line exists!\"\n }\n else{\n echo \"The host $line doesn't exist.\"\n }\n}\n" }, { "answer_id": 74436616, "author": "Magoo", "author_id": 2128947, "author_profile": "https://Stackoverflow.com/users/2128947", "pm_score": 1, "selected": true, "text": "for /f %e in (file1) do findstr \"%e\" file2 >nul&if errorlevel 1 (echo %e>>missing) else (echo %e>>found)\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10999049/" ]
74,435,209
<p>I have a variable that contains dates and data on each line, and wanted to know how to sort by date? I've tried lsort after splitting the variable, but that only sorts by the day (date format DD/MM/YYYY).</p> <p>eg the variable has the following:</p> <pre><code>01/11/2020,$239,Sandy 05/12/2019,$19,Boe 14/09/2022,$22,Fred 06/02/2021,$55,Andrew ...etc... </code></pre> <p>I've used [lsort -unique -index 0 [split $mylist &quot;\n&quot;]], but that only sorts by the day (DD), not the whole date (DD/MM/YYYY)</p> <p>ie</p> <pre><code>01/11/2020,$239,Sandy 05/12/2019,$19,Boe 06/02/2021,$55,Andrew 14/09/2022,$22,Fred ...etc. </code></pre> <p>needs to sort it by date</p> <pre><code>05/12/2019,$19,Boe 01/11/2020,$239,Sandy 06/02/2021,$55,Andrew 14/09/2022,$22,Fred ...etc </code></pre> <p><strong>UPDATE/ADDITIONAL</strong>:</p> <p>The code to load the data is as follows:</p> <pre><code>set fr [open &quot;${currentdir}/test.csv&quot; r] set mylist [read $fr] close $fr </code></pre> <p>The file is just a text file and has many lines of of data, each line starting with a date column (date format can be either 22/01/2019, 01/03/2019, 1/3/2019 - (ie &lt;day 1-2 digits&gt;/&lt;month 1-2 digits&gt;/&lt;year 4 digits&gt;). The other columns can have any data, spaces, values, $dollars, etc. but they all have the same number of elements (ie 12 columns)</p> <p>test.csv example file</p> <pre><code>19/12/2008,Some test values,1,Some other test values,1,43.90050622 16/12/2008,Some test values,2,Some other test values,2,69.0326854 11/12/2008,Some test values,3,Some other test values,3,20.03514637 10/12/2008,Some test values,4,Some other test values,4,31.89534427 10/12/2008,Some test values,5,Some other test values,5,45.16309485 9/12/2008,Some test values,6,Some other test values,6,80.15651004 27/11/2008,Some test values,7,Some other test values,7,14.68529885 27/11/2008,Some test values,8,Some other test values,8,37.59341648 25/11/2008,Some test values,9,Some other test values,9,44.36159437 25/11/2008,Some test values,10,Some other test values,10,44.960349 </code></pre>
[ { "answer_id": 74436042, "author": "Chris Heithoff", "author_id": 16350882, "author_profile": "https://Stackoverflow.com/users/16350882", "pm_score": 2, "selected": false, "text": "lsort -command" }, { "answer_id": 74436229, "author": "glenn jackman", "author_id": 7552, "author_profile": "https://Stackoverflow.com/users/7552", "pm_score": 2, "selected": true, "text": "set l {01/11/2020,$239,Sandy\n05/12/2019,$19,Boe\n14/09/2022,$22,Fred\n06/02/2021,$55,Andrew\n}\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6400605/" ]
74,435,228
<p>I am trying to pass a boolean value from one service to other service file , in that I am getting boolean value is undefined and I do not find any examples and documents related to it in angular, can anyone guide me to this</p> <p>need to pass a boolean value from this file:</p> <pre><code>Auth.service.ts public Data: boolean; passValueFunction(){ this.Data =true } </code></pre> <p>in this service file, i need to get that boolean value(Data variable in auth.service file) come from auth service file</p> <pre><code>second.service.ts constructor(private authService: Authservice){ } ngOninit(){ console.log(this.authService.Data) } </code></pre> <p>in second service file, I am not getting the Data value as true. I want this.authService.Data = true in second service file. I do not have any idea why am getting this.authservice.Data= undefined.</p>
[ { "answer_id": 74436042, "author": "Chris Heithoff", "author_id": 16350882, "author_profile": "https://Stackoverflow.com/users/16350882", "pm_score": 2, "selected": false, "text": "lsort -command" }, { "answer_id": 74436229, "author": "glenn jackman", "author_id": 7552, "author_profile": "https://Stackoverflow.com/users/7552", "pm_score": 2, "selected": true, "text": "set l {01/11/2020,$239,Sandy\n05/12/2019,$19,Boe\n14/09/2022,$22,Fred\n06/02/2021,$55,Andrew\n}\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19716192/" ]
74,435,251
<p>I made a shortcode in order to display the loop on my custom homepage :</p> <pre><code>function home_loop_shortcode() { $args = array( 'post_type' =&gt; 'post', 'post_status' =&gt; 'publish', 'posts_per_page' =&gt; '8', 'cat' =&gt; '3, 6', 'orderby' =&gt; 'date' ); $query = new WP_Query($args); if ($query-&gt;have_posts()) { while ($query-&gt;have_posts()) { $query-&gt;the_post(); $postlink = get_permalink(get_the_ID()); $html = '&lt;li&gt;&lt;a href=&quot;' . $postlink . '&quot;&gt;' . get_the_title() . '&lt;/a&gt;&lt;/li&gt;'; } } return $html; wp_reset_postdata(); } add_shortcode( 'loop', 'home_loop_shortcode' ); </code></pre> <p>I actually have 8 posts in category ID 3 and 6, but only the first post is displayed. The code is nested inside this HTML:</p> <pre><code>&lt;div class=&quot;home-loop&quot;&gt; &lt;h3&gt;Latest posts&lt;/h3&gt; &lt;ul&gt; [loop] &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>Even if I remove <code>'cat'</code> line, or replace it by <code>'category_name' =&gt; 'foo'</code>, or if I set <code>'posts_per_page' =&gt; -1</code>, nothing change. I probably miss something obvious... Help!</p>
[ { "answer_id": 74435457, "author": "Moishy", "author_id": 1810810, "author_profile": "https://Stackoverflow.com/users/1810810", "pm_score": 3, "selected": true, "text": "$html" }, { "answer_id": 74435489, "author": "Krunal Bhimajiyani", "author_id": 19587288, "author_profile": "https://Stackoverflow.com/users/19587288", "pm_score": 1, "selected": false, "text": "function home_loop_shortcode() {\n $html = '';\n $args = array(\n 'post_type' => 'post', \n 'post_status' => 'publish', \n 'posts_per_page' => '8',\n 'cat' => '3, 6',\n 'orderby' => 'date'\n );\n $query = new WP_Query($args);\n if ($query->have_posts()) {\n while ($query->have_posts()) {\n $query->the_post();\n $postlink = get_permalink(get_the_ID());\n $html .= '<li><a href=\"' . $postlink . '\">' . get_the_title() . '</a></li>';\n }\n }\n return $html;\n wp_reset_postdata();\n}\nadd_shortcode( 'loop', 'home_loop_shortcode' );\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435251", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2734491/" ]
74,435,255
<p>I am very new to Flutter.</p> <p>I am currently writing a simple memo app, with a list of titles shown like this: <a href="https://i.stack.imgur.com/jAM9U.png" rel="nofollow noreferrer">titles</a></p> <p>Those Text widgets should be separate, but I have no idea how to break text line. Being specific, which widget should be used for the code below?</p> <pre class="lang-dart prettyprint-override"><code>import 'package:flutter/material.dart'; void main() =&gt; runApp(const AppMain()); class AppMain extends StatelessWidget { const AppMain({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Memo', home: Scaffold( body: SafeArea( child: &lt;WHICH WIDGET SHOULD I USE&gt;( children: [ Text(&quot;The first text&quot;), Text(&quot;Second Memo Title&quot;), Text(&quot;Third One&quot;), Text(&quot;and so on&quot;), ], ), debugShowCheckedModeBanner: false, ); } } </code></pre> <p>I have tried <strong>Wrap</strong> widget, but it does not break the <strong>Text</strong> in it.</p> <p>Thanks.</p>
[ { "answer_id": 74435457, "author": "Moishy", "author_id": 1810810, "author_profile": "https://Stackoverflow.com/users/1810810", "pm_score": 3, "selected": true, "text": "$html" }, { "answer_id": 74435489, "author": "Krunal Bhimajiyani", "author_id": 19587288, "author_profile": "https://Stackoverflow.com/users/19587288", "pm_score": 1, "selected": false, "text": "function home_loop_shortcode() {\n $html = '';\n $args = array(\n 'post_type' => 'post', \n 'post_status' => 'publish', \n 'posts_per_page' => '8',\n 'cat' => '3, 6',\n 'orderby' => 'date'\n );\n $query = new WP_Query($args);\n if ($query->have_posts()) {\n while ($query->have_posts()) {\n $query->the_post();\n $postlink = get_permalink(get_the_ID());\n $html .= '<li><a href=\"' . $postlink . '\">' . get_the_title() . '</a></li>';\n }\n }\n return $html;\n wp_reset_postdata();\n}\nadd_shortcode( 'loop', 'home_loop_shortcode' );\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6744240/" ]
74,435,276
<p>In GitHub issue <a href="https://github.com/primefaces/primefaces/issues/5840" rel="nofollow noreferrer">PanelGrid: No way to manage style or identifiers of panelgrid cells except for tabular mode #5840</a>, says it is possible to do it but doesn't say how.</p> <p>I want to &quot;hide&quot; some cells. I have partially solved the problem using <code>p:row</code> and <code>p:column</code>; but those components don't work well inside a <code>p:wizard</code>. So I was wondering if there is another way to do it. Right now, I'm only hiding the cell content, but I'd also like to remove the padding and borders from the generated <code>td</code>.</p> <p>I will really appreciate if someone can tell me how to set the style of specific cells without using <code>p:row</code> and <code>p:column</code>.</p> <p><strong>EDITED ON 11/15/22</strong></p> <p>Following the advice here is some code:</p> <pre><code>&lt;p:panelGrid columns=&quot;2&quot; columnClasses=&quot;xs-width-fit-content,xs-width-100&quot; styleClass=&quot;xs-width-100&quot;&gt; ... &lt;h:panelGroup id=&quot;otraPaginaPanelDetalleWritingLabelGroup&quot; style=&quot;#{usuario22.writingGridOtraPaginaVisible ? 'visibility: visible' : 'display: none'}&quot;&gt; ... &lt;/h:panelGroup&gt; &lt;h:panelGroup id=&quot;otraPaginaPanelDetalleWritingFieldGroup&quot; style=&quot;#{usuario22.writingGridOtraPaginaVisible ? 'visibility: visible' : 'display: none'}&quot;&gt; ... &lt;/h:panelGroup&gt; ... &lt;/p:panelGrid&gt; </code></pre> <p>The <code>p:panelGrid</code> has 2 columns, one for labels, etc, and other for input fields, etc. Each column contains a single <code>h:panelGroup</code>. Each pair of consecutive panelGroups would be a &quot;row&quot;; such &quot;rows&quot; are shown and hidden dynamically using AJAX. When the panelGroups of a &quot;row&quot; are hidden, I would like to change the style of their containing <code>td</code>, to set padding and borders to 0.</p>
[ { "answer_id": 74450160, "author": "Jasper de Vries", "author_id": 880619, "author_profile": "https://Stackoverflow.com/users/880619", "pm_score": 3, "selected": true, "text": ":empty" }, { "answer_id": 74454467, "author": "Jorge Campins", "author_id": 2734938, "author_profile": "https://Stackoverflow.com/users/2734938", "pm_score": 1, "selected": false, "text": ":has()" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2734938/" ]
74,435,358
<p>Null check operator used on a null value</p> <p>When the exception was thrown, this was the stack:</p> <pre><code>#0 StatefulElement.state (package:flutter/src/widgets/framework.dart:4999:44) #1 Navigator.of (package:flutter/src/widgets/navigator.dart:2543:47) #2 Navigator.pushReplacement (package:flutter/src/widgets/navigator.dart:2105:22) #3 Splashservice.isLogin.&lt;anonymous closure&gt; (package:shridungargarh/service/splashservice.dart:15:19) #4 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1175:15) #5 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1104:9) </code></pre> <p>Does Flutter need to be updated</p>
[ { "answer_id": 74450160, "author": "Jasper de Vries", "author_id": 880619, "author_profile": "https://Stackoverflow.com/users/880619", "pm_score": 3, "selected": true, "text": ":empty" }, { "answer_id": 74454467, "author": "Jorge Campins", "author_id": 2734938, "author_profile": "https://Stackoverflow.com/users/2734938", "pm_score": 1, "selected": false, "text": ":has()" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20484339/" ]
74,435,400
<p>Suppose that I work with an external company that sends me folios for an invoice every time they are due. For example, we started from folio 1 to 999. As we were very successful, we reached invoice 999, for which the entity gave me new billing codes ranging from 1000 to 10000. This is the base, so for this I have created a table that will store these folios as follows, idEntity (refers to the foreign external entity), folioInicio, folioTermino, folioActual. The current folio field has the last folio used by the invoice, then through a trigger every time a product or service is invoiced, it increases and changes the field in the table.</p> <p>This is the base, but in reality that folio when printing it in a pdf document or in the operation is transformed into a 7-digit alphanumeric by prefixing an F. For example, folio 1 would be F000001. and so on.</p> <p>For this, create a function that is executed in the trigger as follows.</p> <pre><code>CREATE FUNCTION dbo.GenerateFolioNumber(@FOLIO BIGINT) RETURN VARCHAR(7) ACE START DECLARE @NROFOLIO VARCHAR(7); IF(LEN(CONVERT(VARCHAR(7), @FOLIO)) = 1) set @NROFOLIO ='F00000'+ CONVERT(VARCHAR(7), @FOLIO); IF(LEN(CONVERT(VARCHAR(7), @FOLIO)) = 2) set @NROFOLIO ='F0000'+ CONVERT(VARCHAR(7), @FOLIO); IF(LEN(CONVERT(VARCHAR(7), @FOLIO)) = 3) set @NROFOLIO ='F000'+CONVERT(VARCHAR(7), @FOLIO); IF(LEN(CONVERT(VARCHAR(7), @FOLIO)) = 4) set @NROFOLIO ='F00'+CONVERT(VARCHAR(7), @FOLIO); IF(LEN(CONVERT(VARCHAR(7), @FOLIO)) = 5) set @NROFOLIO ='F0'+CONVERT(VARCHAR(7), @FOLIO); IF(LEN(CONVERT(VARCHAR(7), @FOLIO)) = 6) set @NROFOLIO ='F'+CONVERT(VARCHAR(7), @FOLIO); RETURN @NROFOLIO; END; </code></pre> <p>The thing is that so many IFs seem redundant to me, and I don't have much experience programming SQL but it seems to me that maybe it could be solved in another way, that's why I turn to this community to listen to their experience and see if there is another way to do this.</p>
[ { "answer_id": 74450160, "author": "Jasper de Vries", "author_id": 880619, "author_profile": "https://Stackoverflow.com/users/880619", "pm_score": 3, "selected": true, "text": ":empty" }, { "answer_id": 74454467, "author": "Jorge Campins", "author_id": 2734938, "author_profile": "https://Stackoverflow.com/users/2734938", "pm_score": 1, "selected": false, "text": ":has()" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14141630/" ]
74,435,414
<p>hi im having this problem this is my code rn but it wont do anything or just say its a int or a str</p> <pre class="lang-py prettyprint-override"><code>b=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] c=['&amp;','!','@','#','$','%'] a = input(&quot;Enter here :&quot;) if type(a) ==int: print(&quot;number&quot;) if a==b: print(&quot;word&quot;) if a ==c: print(&quot;symbol&quot;) </code></pre> <p>I tried putting a int or a str behind a input thing but that didn't solve the prob i wanna write a code as clean as possible and not with list cuz they are long and hard to make.</p>
[ { "answer_id": 74450160, "author": "Jasper de Vries", "author_id": 880619, "author_profile": "https://Stackoverflow.com/users/880619", "pm_score": 3, "selected": true, "text": ":empty" }, { "answer_id": 74454467, "author": "Jorge Campins", "author_id": 2734938, "author_profile": "https://Stackoverflow.com/users/2734938", "pm_score": 1, "selected": false, "text": ":has()" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20502817/" ]
74,435,423
<p>I am wondering if there was an efficient <a href="/questions/tagged/data.table" class="post-tag" title="show questions tagged &#39;data.table&#39;" aria-label="show questions tagged &#39;data.table&#39;" rel="tag" aria-labelledby="data.table-container">data.table</a> solution for the following problem.</p> <p>Suppose, that I have the following dataset:</p> <pre><code>library(data.table) DT &lt;- data.table(emp = c(1,2,3), start_time = c(90,90,540), duration = c(480, 480,480 )) DT[, end_time := start_time + duration] </code></pre> <p>which looks like:</p> <pre><code> emp start_time duration end_time &lt;num&gt; &lt;num&gt; &lt;num&gt; &lt;num&gt; 1: 1 90 480 570 2: 2 90 480 570 3: 3 540 480 1020 </code></pre> <p>Here, <code>emp</code> is the employee id, and the start time, duration, and end times of each employee's shift are given by the three columns. I am attempting to determine the amount of overlap that each employee has with each other in minutes. Thus, the output should look something like:</p> <pre><code> emp emp_1 emp_2 emp_3 &lt;num&gt; &lt;num&gt; &lt;num&gt; &lt;num&gt; 1: 1 480 480 30 2: 2 480 480 30 3: 3 30 30 480 </code></pre> <p>where the columns are based on the full set of employees.</p> <p>I am looking for a data.table solution since the number of employees is quite large.</p>
[ { "answer_id": 74450160, "author": "Jasper de Vries", "author_id": 880619, "author_profile": "https://Stackoverflow.com/users/880619", "pm_score": 3, "selected": true, "text": ":empty" }, { "answer_id": 74454467, "author": "Jorge Campins", "author_id": 2734938, "author_profile": "https://Stackoverflow.com/users/2734938", "pm_score": 1, "selected": false, "text": ":has()" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9684184/" ]
74,435,435
<p>Table 1:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Column C</th> <th>Column D</th> </tr> </thead> <tbody> <tr> <td>1234hj</td> <td>Bob</td> <td>1</td> <td>1</td> </tr> <tr> <td>nkj234</td> <td>Joe</td> <td>2</td> <td>2</td> </tr> <tr> <td>ji3251</td> <td>Schmoe</td> <td>3</td> <td>3</td> </tr> </tbody> </table> </div> <p>Table 2:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ID</th> <th>Name</th> </tr> </thead> <tbody> <tr> <td></td> <td>Bob</td> </tr> <tr> <td></td> <td>Joe</td> </tr> <tr> <td></td> <td>Sam</td> </tr> </tbody> </table> </div> <p>I currently have 2 dataframes like so. How do i extract the ID from table 1 and set it as ID in table 2 IF the name matches?</p> <p>I've tried this code but requires same labelling. (This may not even be correct)</p> <pre><code>df2['ID'] = np.where(df['Name'] == df2['Name'], df['Prompt'], df2['ID']) </code></pre>
[ { "answer_id": 74450160, "author": "Jasper de Vries", "author_id": 880619, "author_profile": "https://Stackoverflow.com/users/880619", "pm_score": 3, "selected": true, "text": ":empty" }, { "answer_id": 74454467, "author": "Jorge Campins", "author_id": 2734938, "author_profile": "https://Stackoverflow.com/users/2734938", "pm_score": 1, "selected": false, "text": ":has()" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20480003/" ]
74,435,452
<p>I want to be able to start a timer when the space bar is released and to stop it when the space bar is pressed. The code I am using right now initially achieves this. However it does not work on subsequent attempts. I am using a boolean to store whether the key has been pressed in the last .5 seconds (in order to not trigger the event again when the user releases the space bar). This code only works on the first attempt</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const timer = document.querySelector('#timer') const playArea = document.querySelector('#play-area') let timerStarted = false // starts timer when spacebar is released playArea.addEventListener('keyup', (e) =&gt; { if (e.keyCode === 32 &amp;&amp; !timerStarted) startTimer() }) // start timer function function startTimer() { // assigning time values to zero let [milliseconds, seconds, minutes] = [0, 0, 0] let Interval // actual timer code Interval = setInterval(() =&gt; { milliseconds++ if (milliseconds % 100 === 0) { milliseconds = 0 seconds++ } if (seconds % 60 === 0 &amp;&amp; seconds !== 0) { seconds = 0 minutes++ } timer.innerText = `${minutes}:${seconds}.${milliseconds}` }, 10) playArea.addEventListener('keydown', (e) =&gt; { if (e.keyCode === 32) stopTimer(Interval) }) } function stopTimer(interval) { clearInterval(interval) timerStarted = true setTimeout(function () { timerStarted = false console.log(timerStarted) }, 500) console.log(timerStarted) }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt; &lt;link rel="stylesheet" href="/public/css/style.css"&gt; &lt;script src="/public/js/timer.js" defer&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;section id="play-area" tabindex="-1"&gt; &lt;h1 id="timer"&gt;00:00&lt;/h1&gt; &lt;/section&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74435736, "author": "Mohammed Shahed", "author_id": 19067773, "author_profile": "https://Stackoverflow.com/users/19067773", "pm_score": 1, "selected": false, "text": "const timer = document.querySelector(\"#timer\");\nconst playArea = document.querySelector(\"#play-area\");\nlet timerStarted = false;\nlet Interval;\nplayArea.addEventListener(\"keypress\", (e) => {\n if (e.keyCode == 32) {\n if (!timerStarted) {\n timerStarted = true;\n startTimer();\n } else {\n timerStarted = false;\n stopTimer(Interval);\n }\n }\n});\n// start timer function\nfunction startTimer() {\n timerStarted = true;\n let [milliseconds, seconds, minutes] = [0, 0, 0];\n Interval = setInterval(() => {\n milliseconds++;\n if (milliseconds % 100 === 0) {\n milliseconds = 0;\n seconds++;\n }\n if (seconds % 60 === 0 && seconds !== 0) {\n seconds = 0;\n minutes++;\n }\n timer.innerText = `${minutes}:${seconds}.${milliseconds}`;\n }, 10);\n}\n\nfunction stopTimer(interval) {\n clearInterval(interval);\n}\n\n" }, { "answer_id": 74435964, "author": "epascarello", "author_id": 14104, "author_profile": "https://Stackoverflow.com/users/14104", "pm_score": 1, "selected": false, "text": "class Timer {\n\n interval = null\n startTime = null\n\n constructor(outputElem) {\n this.outputElem = outputElem;\n }\n \n displayOutput () {\n this.outputElem.textContent = this.formatMS(Date.now() - this.startTime);\n }\n \n formatMS (ms) {\n return new Date(ms).toISOString().substring(11, 23);\n }\n \n start () {\n if (this.interval) return;\n this.startTime = Date.now();\n this.displayOutput();\n this.interval = window.setInterval(() => this.displayOutput(), 10);\n }\n \n stop () {\n if (!this.interval) return;\n window.clearInterval(this.interval);\n this.interval = null;\n this.displayOutput();\n }\n}\n\nconst timerElem = document.querySelector('#timer')\nconst playArea = document.querySelector('#play-area')\n\nconst myTimer = new Timer(timerElem);\n\nplayArea.addEventListener('keyup', (e) => {\n if (e.code === \"Space\") myTimer.start()\n});\n\nplayArea.addEventListener('keydown', (e) => {\n if (e.code === \"Space\") myTimer.stop();\n});" }, { "answer_id": 74436301, "author": "Bhavya Dhiman", "author_id": 4167172, "author_profile": "https://Stackoverflow.com/users/4167172", "pm_score": 0, "selected": false, "text": "timerStarted = true" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14144772/" ]
74,435,453
<p>I pull a row out of the database and I want to access it via a dynamic var</p> <pre><code>$prop = &quot;theProp&quot;; $test0 = $row[&quot;theProp&quot;]; // Works fine $test1 = $row-&gt;{$prop}; // Doesn't work $test2 = $row-&gt;$prop; // Doesn't work </code></pre> <p>I've looked all over the place, obviously doing something stupid, can someone enlighten me please.</p>
[ { "answer_id": 74435736, "author": "Mohammed Shahed", "author_id": 19067773, "author_profile": "https://Stackoverflow.com/users/19067773", "pm_score": 1, "selected": false, "text": "const timer = document.querySelector(\"#timer\");\nconst playArea = document.querySelector(\"#play-area\");\nlet timerStarted = false;\nlet Interval;\nplayArea.addEventListener(\"keypress\", (e) => {\n if (e.keyCode == 32) {\n if (!timerStarted) {\n timerStarted = true;\n startTimer();\n } else {\n timerStarted = false;\n stopTimer(Interval);\n }\n }\n});\n// start timer function\nfunction startTimer() {\n timerStarted = true;\n let [milliseconds, seconds, minutes] = [0, 0, 0];\n Interval = setInterval(() => {\n milliseconds++;\n if (milliseconds % 100 === 0) {\n milliseconds = 0;\n seconds++;\n }\n if (seconds % 60 === 0 && seconds !== 0) {\n seconds = 0;\n minutes++;\n }\n timer.innerText = `${minutes}:${seconds}.${milliseconds}`;\n }, 10);\n}\n\nfunction stopTimer(interval) {\n clearInterval(interval);\n}\n\n" }, { "answer_id": 74435964, "author": "epascarello", "author_id": 14104, "author_profile": "https://Stackoverflow.com/users/14104", "pm_score": 1, "selected": false, "text": "class Timer {\n\n interval = null\n startTime = null\n\n constructor(outputElem) {\n this.outputElem = outputElem;\n }\n \n displayOutput () {\n this.outputElem.textContent = this.formatMS(Date.now() - this.startTime);\n }\n \n formatMS (ms) {\n return new Date(ms).toISOString().substring(11, 23);\n }\n \n start () {\n if (this.interval) return;\n this.startTime = Date.now();\n this.displayOutput();\n this.interval = window.setInterval(() => this.displayOutput(), 10);\n }\n \n stop () {\n if (!this.interval) return;\n window.clearInterval(this.interval);\n this.interval = null;\n this.displayOutput();\n }\n}\n\nconst timerElem = document.querySelector('#timer')\nconst playArea = document.querySelector('#play-area')\n\nconst myTimer = new Timer(timerElem);\n\nplayArea.addEventListener('keyup', (e) => {\n if (e.code === \"Space\") myTimer.start()\n});\n\nplayArea.addEventListener('keydown', (e) => {\n if (e.code === \"Space\") myTimer.stop();\n});" }, { "answer_id": 74436301, "author": "Bhavya Dhiman", "author_id": 4167172, "author_profile": "https://Stackoverflow.com/users/4167172", "pm_score": 0, "selected": false, "text": "timerStarted = true" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2846531/" ]
74,435,484
<p>I have a User control and I bind the tooltip of that control into some object's property</p> <pre><code> &lt;usercontrols:ucButton x:Name=&quot;xSaveCurrentBtn&quot; ButtonType=&quot;ImageButton&quot; ButtonFontImageSize=&quot;16&quot; ButtonImageWidth=&quot;18&quot; ButtonImageHeight=&quot;18&quot; ButtonImageType=&quot;Save&quot; Click=&quot;xSaveSelectedButton_Click&quot; ButtonStyle=&quot;{StaticResource $ImageButtonStyle_Menu}&quot; DockPanel.Dock=&quot;Right&quot; HorizontalAlignment=&quot;Right&quot; VerticalAlignment=&quot;Center&quot; Margin=&quot;0,0,0,0&quot;&gt; &lt;usercontrols:ucButton.ToolTip&gt; &lt;ToolTip Content=&quot;{Binding ItemName, Mode=OneWay}&quot; ContentStringFormat=&quot;Save {0}&quot;/&gt; &lt;/usercontrols:ucButton.ToolTip&gt; &lt;/usercontrols:ucButton&gt; </code></pre> <p>from the code I set the data context of the ucButton to be my object:</p> <pre><code>xSaveCurrentBtn.DataContext = WorkSpace.Instance.CurrentSelectedItem; </code></pre> <p>sometimes the CurrentSelectedItem is null, and if this is the case I want the tooltip to display &quot;No Item Selected&quot; I tried doing this:</p> <pre><code>xSaveCurrentBtn.Tooltip = &quot;No Item Selected&quot;; </code></pre> <p>but when the CurrentSelectedItem isn't null and I reset the xSaveBtn.DataContext to that object, I am still seeing the No Item Selected tooltip as if my WPF tooltip section was overriden and its no longer binding into the datacontext ItemName Property</p>
[ { "answer_id": 74435671, "author": "EldHasp", "author_id": 13349759, "author_profile": "https://Stackoverflow.com/users/13349759", "pm_score": 3, "selected": true, "text": " xSaveCurrentBtn.Tooltip = new ToolTip() {.....};\n" }, { "answer_id": 74436425, "author": "ASh", "author_id": 1506454, "author_profile": "https://Stackoverflow.com/users/1506454", "pm_score": 1, "selected": false, "text": "null" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8855066/" ]
74,435,488
<p>I am quite new to programming so if this question is really silly please don't laugh at me :(</p> <p>I am looking for a function to ask for (yes or no) questions, just like the below:</p> <pre><code>if input(&quot;Question (y/n)&quot;) == &quot;y&quot;: print(&quot;y&quot;) if input(&quot;Question (y/n)&quot;) == &quot;n&quot;: print(&quot;n&quot;) </code></pre> <p>If the input equals &quot;y&quot; it would execute line 2, if it equals &quot;n&quot; it would execute line 4</p> <p>I tried using two ifs, like above, however the input function would've been executed twice if I did it like that, I also tried using elif like below:</p> <pre><code>if input(&quot;Question (y/n)&quot;) == &quot;y&quot;: print(&quot;y&quot;) elif input(&quot;Question (y/n)&quot;) == &quot;n&quot;: print(&quot;n&quot;) </code></pre> <p>But if I used the method shown above the input command would still be executed twice</p> <p>I also tried this:</p> <pre><code>if input(&quot;Question (y/n)&quot;) == &quot;y&quot;: print(&quot;y&quot;) elif &quot;n&quot;: print(&quot;n&quot;) </code></pre> <p>Doesn't work as everything other than &quot;y&quot; would execute line 4</p> <p>Is there a function that can be used in such situation or is there a specific method to use &quot;if&quot; &quot;elif&quot; &quot;else&quot; to achieve such requirements? Much thanks! :))</p>
[ { "answer_id": 74435573, "author": "Code-Apprentice", "author_id": 1440565, "author_profile": "https://Stackoverflow.com/users/1440565", "pm_score": 3, "selected": true, "text": "input()" }, { "answer_id": 74435645, "author": "Narcisse Doudieu Siewe", "author_id": 1438644, "author_profile": "https://Stackoverflow.com/users/1438644", "pm_score": 0, "selected": false, "text": "while True:\n x = input(\"y/n\")\n if x == \"y\":\n #do suitable stuff \n print(x)\n elif x == \"n\":\n #do suitable stuff\n print(x)\n else:\n #use \"break\" instead of \"pass\" if you want to get out the \"while\"\n pass \n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20502833/" ]
74,435,538
<p>i have JSON value as below :</p> <pre class="lang-json prettyprint-override"><code>{ &quot;table&quot;: &quot;table_name&quot;, &quot;op_type&quot;: &quot;U&quot;, &quot;before&quot;: { &quot;AAAA&quot;: &quot;1-1111&quot;, &quot;BBBB&quot;: &quot;2022-08-31 03:57:01&quot;, &quot;CCCC&quot;: &quot;2023-08-31 23:59:59&quot; }, &quot;after&quot;: { &quot;AAAA&quot;: &quot;1-1112&quot;, &quot;BBBB&quot;: &quot;2022-08-31 10:10:34&quot; } } </code></pre> <p>i want to do this how can i do?</p> <pre class="lang-json prettyprint-override"><code>{ &quot;AAAA&quot;: &quot;1-1112&quot;, &quot;BBBB&quot;: &quot;2022-08-31 10:10:34&quot;, &quot;CCCC&quot;: &quot;2023-08-31 23:59:59&quot; &quot;changed_columns&quot;: &quot;AAAA, BBBB&quot; } </code></pre> <p>AAAA: &quot;If you have after.AAAA, take AAAA else before.AAAA&quot;, BBBB: &quot;If you have after.BBBB, take BBBB else before.BBBB.</p> <p>AND I want to add changed_columns field like this :</p> <pre class="lang-json prettyprint-override"><code>,&quot;changed_columns&quot;: &quot;AAAA, BBBB&quot; </code></pre> <p>is there a way to do this?</p>
[ { "answer_id": 74437171, "author": "Barbaros Özhan", "author_id": 5841306, "author_profile": "https://Stackoverflow.com/users/5841306", "pm_score": 1, "selected": false, "text": "\"after|before\"" }, { "answer_id": 74441507, "author": "MohammadReza", "author_id": 8428397, "author_profile": "https://Stackoverflow.com/users/8428397", "pm_score": 3, "selected": true, "text": "shift" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8052213/" ]
74,435,562
<p>I have a school project where I have to make my structures and functions in a .h header file.</p> <p>I've created my structure but cannot use any of the variables within it as whenever I call it it highlights the structure name and tells me its not defined even though it clearly is in my structure and doesn't highlight or give me any syntax errors.</p> <pre><code>#include &lt;stdio.h&gt; typedef struct test1 { int array1[3]; int array2[3]; }; int main(void) { scanf_s(&quot; %d %d&quot;, &amp;test1.array1[1], &amp;test1.array2[1]); } </code></pre> <p>I have tried using typedef with and without and its the same result. if I create individual variables outside the structure I get no issues so i believe its some issue with how I'm creating my structures but I don't know what the issue is.</p>
[ { "answer_id": 74437171, "author": "Barbaros Özhan", "author_id": 5841306, "author_profile": "https://Stackoverflow.com/users/5841306", "pm_score": 1, "selected": false, "text": "\"after|before\"" }, { "answer_id": 74441507, "author": "MohammadReza", "author_id": 8428397, "author_profile": "https://Stackoverflow.com/users/8428397", "pm_score": 3, "selected": true, "text": "shift" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19987658/" ]
74,435,565
<p>My chat bubble looks like this:</p> <p><a href="https://i.stack.imgur.com/6HKM0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6HKM0.jpg" alt="enter image description here" /></a></p> <p>I want its timestamp to <strong>stick to the right side</strong> like the following:</p> <p><a href="https://i.stack.imgur.com/PXGiO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PXGiO.png" alt="enter image description here" /></a></p> <p>Here is my code:</p> <pre><code> return Align( alignment: alignment, child: Bubble( margin: BubbleEdges.only( top: 10, left: leftMargin, right: rightMargin, ), color: backgroundColor, nip: bubbleNip, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ content, const SizedBox(height: 5), Text(timeFormat01(timestamp)), ], ), ), ); </code></pre> <p>How do I do that?</p> <h1>What doesn't work?</h1> <p>Using Row <code>mainAxisAlignment: MainAxisAlignment.end</code> or Align <code>alignment: Alignment.centerRight</code> leads to stretching all bubbles to max width.</p> <p><a href="https://i.stack.imgur.com/9EYDQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9EYDQ.jpg" alt="enter image description here" /></a></p> <p>Adding <code>crossAxisAlignment: CrossAxisAlignment.end</code> to the Column will align all texts that are smaller than the timestamp text to the right side.</p> <p><a href="https://i.stack.imgur.com/1cPF8.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1cPF8.jpg" alt="enter image description here" /></a></p>
[ { "answer_id": 74435659, "author": "Yeasin Sheikh", "author_id": 10157127, "author_profile": "https://Stackoverflow.com/users/10157127", "pm_score": 0, "selected": false, "text": "crossAxisAlignment: CrossAxisAlignment.end," }, { "answer_id": 74442889, "author": "manhtuan21", "author_id": 8921450, "author_profile": "https://Stackoverflow.com/users/8921450", "pm_score": 0, "selected": false, "text": "Align" }, { "answer_id": 74481546, "author": "offworldwelcome", "author_id": 11760076, "author_profile": "https://Stackoverflow.com/users/11760076", "pm_score": 1, "selected": false, "text": "IntrinsicWidth" }, { "answer_id": 74486110, "author": "Khyati Modi", "author_id": 11647876, "author_profile": "https://Stackoverflow.com/users/11647876", "pm_score": 0, "selected": false, "text": "Row(\n crossAxisAlignment: CrossAxisAlignment.center,\n mainAxisSize: MainAxisSize.min,\n mainAxisAlignment: widget.isMyMessage! ? MainAxisAlignment.end : MainAxisAlignment.start,\n children: [ widget.isMyMessage! == true\n ? Padding(\n padding: const EdgeInsets.only(right: 4.0),\n child: Image.asset(\n icRead,\n height: 16,\n width: 16,\n ),\n )\n : Container(),\n timeData != null ? Text( timeForChatMsg( timeData ),\n style: TextStyle(\n fontSize: fontSize12,\n color: widget.isMyMessage! ? Colors.white : Colors.black,\n ),\n )\n : Container(); ,\n widget.isMyMessage! == false\n ? Padding(\n padding: const EdgeInsets.only(left: 4.0),\n child: Image.asset(\n icRead,\n color: primaryColor,\n height: 16,\n width: 16,\n ),\n )\n : Container(),\n ],\n )\n" }, { "answer_id": 74506579, "author": "genericUser", "author_id": 12695188, "author_profile": "https://Stackoverflow.com/users/12695188", "pm_score": 1, "selected": true, "text": "IntrinsicWidth" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12695188/" ]
74,435,589
<p>I have a question regarding how to craft a variable depending on two other variables. I need to create a dummy variable that will take the value of 1 if <code>Parameter1</code> is either A or B (but not C) and <code>Parameter2</code> has a positive value. The variable needs both assumptions to upheld, otherwise will take the value of zero. This will be categorized by countries.</p> <p>I have tried to illustrate this down below. What I am looking for is how to compute a variable that calculates the variable 'Result'.</p> <pre><code>read.table( text = &quot;Country, Year, Parameter1, Parameter2, Result, US, 1, A, 12, 1, US, 2, B, 4, 1, US, 3, C, 2, 0, US, 4, A, -4, 0, UK, 1, A, -1, 0, UK, 2, C, 2, 0, UK, 3, B, 3, 1, UK, 4, B, 2, 1, &quot;, sep = &quot;,&quot;, header = TRUE) </code></pre> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th></th> <th>Country</th> <th>Year</th> <th>Parameter1</th> <th>Parameter2</th> <th>Result</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>US</td> <td>1</td> <td>A</td> <td>12</td> <td>1</td> </tr> <tr> <td>2</td> <td>US</td> <td>2</td> <td>B</td> <td>4</td> <td>1</td> </tr> <tr> <td>3</td> <td>US</td> <td>3</td> <td>C</td> <td>2</td> <td>0</td> </tr> <tr> <td>4</td> <td>US</td> <td>4</td> <td>A</td> <td>-4</td> <td>0</td> </tr> <tr> <td>5</td> <td>UK</td> <td>1</td> <td>A</td> <td>-1</td> <td>0</td> </tr> <tr> <td>6</td> <td>UK</td> <td>2</td> <td>C</td> <td>2</td> <td>0</td> </tr> <tr> <td>7</td> <td>UK</td> <td>3</td> <td>B</td> <td>3</td> <td>1</td> </tr> <tr> <td>8</td> <td>UK</td> <td>4</td> <td>B</td> <td>2</td> <td>1</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74435637, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 4, "selected": true, "text": "%in%" }, { "answer_id": 74435665, "author": "Allan Cameron", "author_id": 12500315, "author_profile": "https://Stackoverflow.com/users/12500315", "pm_score": 2, "selected": false, "text": "within(df, Result <- as.numeric(!(Parameter1 == 'C' | Parameter2 < 0)))\n Country Year Parameter1 Parameter2 Result\n1 US 1 A 12 1\n2 US 2 B 4 1\n3 US 3 C 2 0\n4 US 4 A -4 0\n5 UK 1 A -1 0\n6 UK 2 C 2 0\n7 UK 3 B 3 1\n8 UK 4 B 2 1\n" }, { "answer_id": 74435803, "author": "M--", "author_id": 6461462, "author_profile": "https://Stackoverflow.com/users/6461462", "pm_score": 2, "selected": false, "text": "dplyr" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435589", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13227414/" ]
74,435,609
<p>What is the need of showing different URL path in react application, I can display all the react component conditionally on same URL path</p>
[ { "answer_id": 74435669, "author": "Gollasso", "author_id": 20412483, "author_profile": "https://Stackoverflow.com/users/20412483", "pm_score": 0, "selected": false, "text": "npm install react-router-dom" }, { "answer_id": 74435675, "author": "Drew Reese", "author_id": 8690857, "author_profile": "https://Stackoverflow.com/users/8690857", "pm_score": 2, "selected": true, "text": "react-router" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435609", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19370059/" ]
74,435,633
<p>I would like to solve the following problem:</p> <p>In Worksheet1 I have a range in text form from O3 to O4500. If the cells in this range contain certain words, I want an &quot;x&quot; to be put in the range U3:U4500 (in the same row). The words to be tested are in range B4:B15 in another Worksheet (Worksheet2).</p> <p>I made it work with the following code (solution1), but now I don't want to type the code manually for word1, word2, words3... instead it should be taken from the other range in Worksheet 2 (see my draft below in solution2). I believe the problem are the &quot;* *&quot; which are missing when I use the referral to the other range.</p> <p>Any help is very much appreciated!</p> <pre class="lang-vb prettyprint-override"><code>Sub solution1() Dim i As Long For i = 3 To 4500 If LCase$(Worksheet1.Range(&quot;O&quot; &amp; i).Value) Like &quot;*word1*&quot; Or _ LCase$(Worksheet1.Range(&quot;O&quot; &amp; i).Value) Like &quot;*word2*&quot; Or _ LCase$(Worksheet1.Range(&quot;O&quot; &amp; i).Value) Like &quot;*word3*&quot; Then Worksheet1.Range(&quot;U&quot; &amp; i).Value = &quot;x&quot; End If Next End Sub Sub solution2() Dim i As Long, c As Long For i = 3 To 4500 For c = 4 To 15 If LCase$(Worksheet1.Range(&quot;O&quot; &amp; i).Value) Like LCase$(Worksheet2.Range(&quot;B&quot; &amp; c).Value) Then Worksheet1.Range(&quot;U&quot; &amp; i).Value = &quot;x&quot; End If Next Next End Sub </code></pre>
[ { "answer_id": 74435669, "author": "Gollasso", "author_id": 20412483, "author_profile": "https://Stackoverflow.com/users/20412483", "pm_score": 0, "selected": false, "text": "npm install react-router-dom" }, { "answer_id": 74435675, "author": "Drew Reese", "author_id": 8690857, "author_profile": "https://Stackoverflow.com/users/8690857", "pm_score": 2, "selected": true, "text": "react-router" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435633", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20502973/" ]
74,435,634
<p>I have this code:</p> <pre><code>type X struct { y *X } func main() { x1 := &amp;X{y: nil} x2 := &amp;X{y: x1} fmt.Println(x1 == x2.y) // true x1 = nil fmt.Println(x1 == nil) fmt.Println(x2.y == nil) // true // false } </code></pre> <p>As you can see <code>x.y</code> is a <code>*X</code>.<br /> Why after setting <code>x1</code> to <code>nil</code>. The value of <code>x2.y</code> doesn't become <code>nil</code>?<br /> Sorry if my question is so silly.</p> <p>Here is the <a href="https://go.dev/play/p/O0ZRf9DqeNz" rel="nofollow noreferrer">link</a> of the code in Go playground.</p>
[ { "answer_id": 74435715, "author": "Burak Serdar", "author_id": 11923999, "author_profile": "https://Stackoverflow.com/users/11923999", "pm_score": 3, "selected": true, "text": "x1" }, { "answer_id": 74435900, "author": "Elias Van Ootegem", "author_id": 1230836, "author_profile": "https://Stackoverflow.com/users/1230836", "pm_score": 1, "selected": false, "text": "x2.y" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11487872/" ]
74,435,636
<p>I have a dictionary <code>&quot;A&quot;</code>:</p> <pre class="lang-py prettyprint-override"><code>A = { &quot;Industry1&quot;: 1, &quot;Industry2&quot;: 1, &quot;Industry3&quot;: 1, &quot;Customer1&quot;: 1, &quot;Customer2&quot;: 1, &quot;LocalShop1&quot;: 1, &quot;LocalShop2&quot;: 1, } </code></pre> <p>I want to group by key names and create new dictionaries for each &quot;category&quot;, the names should be generated automatically.</p> <h4>Expected Output:</h4> <pre><code>Industry = { &quot;Industry1&quot;: 1, &quot;Industry2&quot;: 1, &quot;Industry3&quot;: 1, } Customer = { &quot;Customer1&quot;: 1, &quot;Customer2&quot;: 1, } LocalShop = { &quot;LocalShop1&quot;: 1, &quot;LolcalShop2&quot;: 1, } </code></pre> <p>Can you guys give me a hint to achieve this output, please?</p>
[ { "answer_id": 74435850, "author": "Raddude", "author_id": 4551587, "author_profile": "https://Stackoverflow.com/users/4551587", "pm_score": 0, "selected": false, "text": "industries = {}\ncustomers = {}\nshops = {}\n\nfor key, value in A.items():\n if \"Industry\" in key:\n industries[key] = value\n elif \"Customer\" in key:\n customers[key] = value\n elif \"Shop\" in key:\n shops[key] = value\n" }, { "answer_id": 74435935, "author": "Rabinzel", "author_id": 15521392, "author_profile": "https://Stackoverflow.com/users/15521392", "pm_score": 0, "selected": false, "text": "itertools.groupby" }, { "answer_id": 74436353, "author": "S.B", "author_id": 13944524, "author_profile": "https://Stackoverflow.com/users/13944524", "pm_score": 2, "selected": true, "text": "(KEYNAME)(NUM)" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20502886/" ]
74,435,638
<p>So, I have enums:</p> <pre><code>export enum FilterName { Date = 'date', State = 'state', } export enum FilterField { CreatedAtStartDate = 'createdAtStartDate', CreatedAtEndDate = 'createdAtEndDate' State = 'state', } export type TDateFields = { min: FilterField.CreatedAtStartDate; max: FilterField.CreatedAtEndDate; }; </code></pre> <p>I have function:</p> <pre><code>export const getFilterField = (filterName: FilterName) =&gt; ({ [FilterName.Date]: { min: FilterField.CreatedAtStartDate, max: FilterField.CreatedAtEndDate, } as TDateFields, [FilterName.State]: FilterField.State, }[filterName]); </code></pre> <p>Now, I call the function like this:</p> <pre><code>const filterFields = getFilterField(FilterName.Date); </code></pre> <p>Doing <code>filterFields.min</code> will throw an error:</p> <pre><code>Property 'min' does not exist on type 'FilterField | TDateFields' </code></pre> <p>I can solve this by doing <code>const filterFields = getFilterField(filterName) as TDateFields</code>, but I would like to have type narrowing. Is that possible in a case like this and if yes, how?</p>
[ { "answer_id": 74435850, "author": "Raddude", "author_id": 4551587, "author_profile": "https://Stackoverflow.com/users/4551587", "pm_score": 0, "selected": false, "text": "industries = {}\ncustomers = {}\nshops = {}\n\nfor key, value in A.items():\n if \"Industry\" in key:\n industries[key] = value\n elif \"Customer\" in key:\n customers[key] = value\n elif \"Shop\" in key:\n shops[key] = value\n" }, { "answer_id": 74435935, "author": "Rabinzel", "author_id": 15521392, "author_profile": "https://Stackoverflow.com/users/15521392", "pm_score": 0, "selected": false, "text": "itertools.groupby" }, { "answer_id": 74436353, "author": "S.B", "author_id": 13944524, "author_profile": "https://Stackoverflow.com/users/13944524", "pm_score": 2, "selected": true, "text": "(KEYNAME)(NUM)" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2692863/" ]
74,435,644
<p>New to React here. Might be a n00b q but doing a project where I'm trying to build a recipe app and the api I'm using retrieves an object with this value:</p> <pre class="lang-html prettyprint-override"><code>&lt;ol&gt; &lt;li&gt;Place ingredients in a high speed blender like Blendtec for super smooth texture, blend on high.&lt;/li&gt; &lt;li&gt;If using a regular blender put milk and strawberries in then blend.&lt;/li&gt; &lt;li&gt;Next, add banana pieces and peanut butter, process until smooth.&lt;/li&gt; &lt;li&gt;Garnish with crushed peanuts and serve.&lt;/li&gt; &lt;/ol&gt; </code></pre> <p>How would I render it to make the ordered list and unordered list appear on my browser while using Jsx in React? Cause right now it is displaying as such when I render the data from the state object.</p> <p>Thank you!!</p>
[ { "answer_id": 74436117, "author": "codinn.dev", "author_id": 15755662, "author_profile": "https://Stackoverflow.com/users/15755662", "pm_score": 2, "selected": false, "text": "const yourString = `<ol><li>Place ingredients in a high speed blender like Blendtec for super smooth texture, blend on high.</li><li>If using a regular blender put milk and strawberries in then blend.</li><li>Next, add banana pieces and peanut butter, process until smooth.</li><li>Garnish with crushed peanuts and serve.</li></ol>`\n" }, { "answer_id": 74436424, "author": "Mr. Polywhirl", "author_id": 1762224, "author_profile": "https://Stackoverflow.com/users/1762224", "pm_score": 0, "selected": false, "text": "DOMParser" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19731470/" ]
74,435,653
<p>I have a html-element, that has the following attribute: <code>ng-reflect-name=&quot;arrow-down-circle&quot;</code></p> <p>How can I check with cypress, if this attribute has the text &quot;arrow-down-circle&quot;?</p> <p>Below is the whole html-element: <code>&lt;ion-icon _ngcontent-wyk-c151=&quot;&quot; slot=&quot;start&quot; name=&quot;arrow-down-circle&quot; color=&quot;primary&quot; ng-reflect-name=&quot;arrow-down-circle&quot; ng-reflect-color=&quot;primary&quot; aria-label=&quot;arrow down circle&quot; role=&quot;img&quot; class=&quot;md ion-color ion-color-primary hydrated&quot;&gt;&lt;/ion-icon&gt;</code></p> <p>(I am really new to cypress, so I apologize for any naive question!)</p> <p>I have tried two commands, but both were wrong:</p> <p>1.: <code>cy.get(filter_popover).find('#ng-reflect-name').should('contain.text', 'arrow-down-circle'); </code> 2.: <code>cy.get(filter_popover).find('[data-cy=btn_selectDesc]').invoke('attr', 'ng-reflect-name').should('contain.text', 'arrow-down-circle');</code></p> <p>(filter_popover is a constante, that contains a specific page where the html-element is located and data-cy=btn_selectDesc is the identifier of the html-element one hierarchy step above)</p>
[ { "answer_id": 74436020, "author": "artiomi", "author_id": 14394219, "author_profile": "https://Stackoverflow.com/users/14394219", "pm_score": 1, "selected": false, "text": "have.attr" }, { "answer_id": 74436354, "author": "Daniel", "author_id": 197546, "author_profile": "https://Stackoverflow.com/users/197546", "pm_score": 0, "selected": false, "text": "get" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20206386/" ]
74,435,661
<p>Consider the following setup:</p> <pre><code>using System; class Shelf : ScriptableObject // &lt;&lt; IS A SCRIPTABLE OBJECT { [SerializeField] List&lt;Jars&gt; jars = new(); public AddUniqueJar(Type typeOfJar) { //need to add a new object of type typeOfJar to jars. I currently do something like this: sentences.Add((Jar)Activator.CreateInstance(typeOfJar)); EditorUtility.SetDirty(this); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } } [Serializable] abstract class Jar// &lt;&lt; NOT A SCRIPTABLE OBJECT [Serializable] class JamJar:Jar{} [Serializable] class PickleJar:Jar{} [Serializable] class MoneyJar:Jar{} </code></pre> <p>I'd have imagined this would all be fine -, when the editor adds to the list the listview shows my new entry - but the next time my code compiles or restart a session my object loses the data for what is stored in the <code>jars</code> List and the ListView that queries it reports it as an empty list.</p> <p>How do I get my method to add a new object of this type to the list while also serializing and maintaining that information between sessions?</p>
[ { "answer_id": 74446813, "author": "derHugo", "author_id": 7111561, "author_profile": "https://Stackoverflow.com/users/7111561", "pm_score": 1, "selected": false, "text": "abstract" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20142415/" ]
74,435,664
<p>Before performing some statistical analysis I would like to add weights to my sample as a function of a variable (the population size for each areal unit) so that the higher the population size within each unit, the greater the weight it will get and the opposite. Do you have any suggestion on how to do this in R? Thanks in advance</p>
[ { "answer_id": 74435776, "author": "SamR", "author_id": 12545041, "author_profile": "https://Stackoverflow.com/users/12545041", "pm_score": 2, "selected": false, "text": "weighted.mean()" }, { "answer_id": 74436197, "author": "SteveM", "author_id": 3574156, "author_profile": "https://Stackoverflow.com/users/3574156", "pm_score": 1, "selected": true, "text": "weighted.mean" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15969268/" ]
74,435,709
<p>I am made a CMD batch file to generate the barcode numbers. Batch script generate the last ninth number of barcode by doing the calculation and generate the file named &quot;barcode.txt&quot;. The code is working fine. Only the problem is when the &quot;fn&quot; number &quot;Barcode Eight Digit &quot; start with zero then the code is not working properly.</p> <pre><code>@echo off setlocal EnableDelayedExpansion set /p al=Please enter Alfa two digit: set /p fn=Please enter Barcode Eight Digit: set /p no=Please enter number of Barode: set /a NUMBER=%fn% set /a to=%no% set /a count=1 pause :loop if %count% GTR %to% GOTO :end set var1=%NUMBER:~0, 1% set var2=%NUMBER:~1, 1% set var3=%NUMBER:~2, 1% set var4=%NUMBER:~3, 1% set var5=%NUMBER:~4, 1% set var6=%NUMBER:~5, 1% set var7=%NUMBER:~6, 1% set var8=%NUMBER:~7, 1% set /A B1 = %var1% * 8 set /A B2 = %var2% * 6 set /A B3 = %var3% * 4 set /A B4 = %var4% * 2 set /A B5 = %var5% * 3 set /A B6 = %var6% * 5 set /A B7 = %var7% * 9 set /A B8 = %var8% * 7 set /A B9 = %B1% + %B2% + %B3% + %B4% + %B5% + %B6% + %B7% + %B8% set /A B10 = (%B9%) %% 11 set /A B11 = 11- %B10% if &quot;%B11%&quot;==&quot;10&quot; (set B11=0) if &quot;%B11%&quot;==&quot;11&quot; (set B11=5) echo %al%%NUMBER%%B11%IN &gt;&gt; barcode.txt set /a NUMBER+=1 set /a count+=1 goto loop :end echo end it pause </code></pre> <p>I tried to find the solution but failed. Can please any one help me to fix the issue while number start with zero.</p>
[ { "answer_id": 74435776, "author": "SamR", "author_id": 12545041, "author_profile": "https://Stackoverflow.com/users/12545041", "pm_score": 2, "selected": false, "text": "weighted.mean()" }, { "answer_id": 74436197, "author": "SteveM", "author_id": 3574156, "author_profile": "https://Stackoverflow.com/users/3574156", "pm_score": 1, "selected": true, "text": "weighted.mean" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16325253/" ]
74,435,734
<p>For example:</p> <pre><code>def title(a,b): ... def movie( c = title, d): ... </code></pre> <p>But I get : NameError: name 'title' is not defined</p> <p>How can I use function 'title' in function 'movie' ?</p> <p>I have try:</p> <pre><code>def movie(title(a, b), c): </code></pre> <p>But SyntaxError: invalid syntax now.</p>
[ { "answer_id": 74435781, "author": "thicchead", "author_id": 19815385, "author_profile": "https://Stackoverflow.com/users/19815385", "pm_score": -1, "selected": false, "text": "movie(title(a, b), c)" }, { "answer_id": 74435872, "author": "Bourbon", "author_id": 19384213, "author_profile": "https://Stackoverflow.com/users/19384213", "pm_score": 0, "selected": false, "text": "def add(a, b):\n return a + b\n\ndef mult(c, d):\n return c * d\n\nprint(mult(add(2, 2), 3))\n# ^ ^ ^ ^\n# | | | |\n#function \"c\"=(a +b),*d\n\n# (2 + 2) x 3 = 12\n# ^ ^ ^\n# | | |\n# a b d\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18980860/" ]
74,435,773
<p>I have this HTML example:</p> <pre><code>&lt;d&gt; &lt;d&gt; &lt;t&gt;0&lt;/t&gt; &lt;p&gt;1. Question 1&lt;/p&gt; &lt;d&gt;12111&lt;/d&gt; &lt;r&gt; &lt;o&gt;A. aaa&lt;/o&gt; &lt;o&gt;B. Sol B&lt;/o&gt; &lt;o&gt;C. ccc&lt;/o&gt; &lt;o&gt;D. ddd&lt;/o&gt; &lt;o&gt;E. eee&lt;/o&gt; &lt;/r&gt; &lt;/d&gt; &lt;d&gt; &lt;t&gt;0&lt;/t&gt; &lt;p&gt;2. Question 2&lt;/p&gt; &lt;d&gt;11112&lt;/d&gt; &lt;r&gt; &lt;o&gt;A. aaa&lt;/o&gt; &lt;o&gt;B. bbb&lt;/o&gt; &lt;o&gt;C. ccc&lt;/o&gt; &lt;o&gt;D. ddd&lt;/o&gt; &lt;o&gt;E. Sol E&lt;/o&gt; &lt;/r&gt; &lt;/d&gt; &lt;d&gt; &lt;t&gt;0&lt;/t&gt; &lt;p&gt;3. Question 3&lt;/p&gt; &lt;d&gt;21111&lt;/d&gt; &lt;r&gt; &lt;o&gt;A. Sol A&lt;/o&gt; &lt;o&gt;B. bbb&lt;/o&gt; &lt;o&gt;C. ccc&lt;/o&gt; &lt;o&gt;D. ddd&lt;/o&gt; &lt;o&gt;E. eee&lt;/o&gt; &lt;/r&gt; &lt;/d&gt; &lt;/d&gt; </code></pre> <p>I want to parse it to obtain a table with two columns: <strong>question</strong> and <strong>answer</strong>.</p> <p>The question is in the p tag: <code>&lt;p&gt;1. Question 1&lt;/p&gt;</code>.</p> <p>The answer is defined by the position of the number 2 here: <code>&lt;d&gt;12111&lt;/d&gt;</code>. So, for question 1, the answer is the second tag: &quot;B. Sol B&quot;.</p> <p>The output should be: | Questions | Answers | | -------- | -------------- | | 1. Question 1 | B. Sol B | | 2. Question 2 | E. Sol E | | 3. Question 3 | A. Sol A |</p> <p>This is what I have tried, but it does not work very good:</p> <pre><code>library(dplyr) library(stringr) library(rvest) pg = read_html(' &lt;d&gt; &lt;d&gt; &lt;t&gt;0&lt;/t&gt; &lt;p&gt;1. Question 1&lt;/p&gt; &lt;d&gt;12111&lt;/d&gt; &lt;r&gt; &lt;o&gt;A. aaa&lt;/o&gt; &lt;o&gt;B. Sol B&lt;/o&gt; &lt;o&gt;C. ccc&lt;/o&gt; &lt;o&gt;D. ddd&lt;/o&gt; &lt;o&gt;E. eee&lt;/o&gt; &lt;/r&gt; &lt;/d&gt; &lt;d&gt; &lt;t&gt;0&lt;/t&gt; &lt;p&gt;2. Question 2&lt;/p&gt; &lt;d&gt;11112&lt;/d&gt; &lt;r&gt; &lt;o&gt;A. aaa&lt;/o&gt; &lt;o&gt;B. bbb&lt;/o&gt; &lt;o&gt;C. ccc&lt;/o&gt; &lt;o&gt;D. ddd&lt;/o&gt; &lt;o&gt;E. Sol E&lt;/o&gt; &lt;/r&gt; &lt;/d&gt; &lt;d&gt; &lt;t&gt;0&lt;/t&gt; &lt;p&gt;3. Question 3&lt;/p&gt; &lt;d&gt;21111&lt;/d&gt; &lt;r&gt; &lt;o&gt;A. Sol A&lt;/o&gt; &lt;o&gt;B. bbb&lt;/o&gt; &lt;o&gt;C. ccc&lt;/o&gt; &lt;o&gt;D. ddd&lt;/o&gt; &lt;o&gt;E. eee&lt;/o&gt; &lt;/r&gt; &lt;/d&gt; &lt;/d&gt;', encoding=&quot;UTF-8&quot;) pg2 &lt;- pg %&gt;% html_nodes('d') %&gt;% html_elements('d') long &lt;- length(pg2) long_loop &lt;- pg2 %&gt;% html_elements('d') %&gt;% length() df &lt;- data.frame('questions' = character(long), 'answers' = character(long), stringsAsFactors = FALSE) for( i in 1:long_loop) { if(i %% 2 == 1) { pg3 &lt;- pg2 %&gt;% `[[`(1) pg_question &lt;- pg3 %&gt;% html_elements('p') %&gt;% html_text2() pg_soltxt &lt;- pg3 %&gt;% html_elements('d') %&gt;% html_text2() pg_solpos &lt;- unlist(gregexpr('2', pg_soltxt))[1] pg_answer &lt;- pg3 %&gt;% html_element('r') %&gt;% html_elements(&quot;o&quot;) %&gt;% html_text2() %&gt;% `[[`(pg_solpos) df[i,1] &lt;- pg_question df[i,2] &lt;- pg_answer } } </code></pre> <p>Probably there is a better way to do it with out the loop, using rvest.</p>
[ { "answer_id": 74435781, "author": "thicchead", "author_id": 19815385, "author_profile": "https://Stackoverflow.com/users/19815385", "pm_score": -1, "selected": false, "text": "movie(title(a, b), c)" }, { "answer_id": 74435872, "author": "Bourbon", "author_id": 19384213, "author_profile": "https://Stackoverflow.com/users/19384213", "pm_score": 0, "selected": false, "text": "def add(a, b):\n return a + b\n\ndef mult(c, d):\n return c * d\n\nprint(mult(add(2, 2), 3))\n# ^ ^ ^ ^\n# | | | |\n#function \"c\"=(a +b),*d\n\n# (2 + 2) x 3 = 12\n# ^ ^ ^\n# | | |\n# a b d\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2314448/" ]
74,435,774
<p>I have a <code>.csv</code> file with 4 fields.</p> <p>Field 1, 2, and 3 are text boxes</p> <p>Field 4 is a number such as 1, 2, 3, etc.</p> <p>There are multiple instances of field 1, 2, and 3 being the exact same for multiple records. In these instances I want to remove all but one of these records and add the number from the other (now removed) records to the end of the one remaining record.</p> <p>To try and give an example:</p> <p>I have</p> <pre><code>A,B,C,1 A,B,C,2 A,B,C,3 D,E,F,1 D,E,F,3 </code></pre> <p>I Want</p> <pre><code>A,B,C,&quot;1,2,3&quot; D,E,F,&quot;1,3&quot; </code></pre> <p>I have been looking into solutions for hours at this point and have gotten next to nowhere (I am completely new to scripting) as far as I can tell, I probably need to be using a <code>for /f</code> command or a <code>findstr</code> command, with certain conditions, but I'm really struggling on where to even start.</p>
[ { "answer_id": 74435781, "author": "thicchead", "author_id": 19815385, "author_profile": "https://Stackoverflow.com/users/19815385", "pm_score": -1, "selected": false, "text": "movie(title(a, b), c)" }, { "answer_id": 74435872, "author": "Bourbon", "author_id": 19384213, "author_profile": "https://Stackoverflow.com/users/19384213", "pm_score": 0, "selected": false, "text": "def add(a, b):\n return a + b\n\ndef mult(c, d):\n return c * d\n\nprint(mult(add(2, 2), 3))\n# ^ ^ ^ ^\n# | | | |\n#function \"c\"=(a +b),*d\n\n# (2 + 2) x 3 = 12\n# ^ ^ ^\n# | | |\n# a b d\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20502988/" ]
74,435,782
<p>I have table with 3 columns:</p> <pre><code>ID, Cancellation_Policy_Type Cancellation_Policy_Hours. </code></pre> <p>The query I would like to get to will allow me to select:</p> <ul> <li>the min Cancellation_Policy_Hours which correspond to the Free Cancellation (if exists)</li> <li>if the above doesn't exist for the specific ID, then I want to check if there is a partially refundable</li> <li>if none of the above exist, then check if there is No Refundable.</li> </ul> <p>The below query is not correct but it may give a better idea about what I am trying to achieve:</p> <pre><code>IF (SELECT ID, Cancellation_Policy_Type, MIN(Cancellation_Policy_Hours) from MYTABLE WHERE Cancellation_Policy_Type = 'Free Cancellation') IS NOT NULL) THEN (SELECT ID, Cancellation_Policy_Type, MIN(Cancellation_Policy_Hours) from MYTABLE WHERE Cancellation_Policy_Type = 'Free Cancellation') ELSEIF (SELECT ID, Cancellation_Policy_Type, MIN(Cancellation_Policy_Hours) from MYTABLE WHERE Cancellation_Policy_Type = 'Free Cancellation') IS NULL AND (SELECT ID, Cancellation_Policy_Type, MIN(Cancellation_Policy_Hours from MYTABLE WHERE Cancellation_Policy_Type = 'Partially Refundable') IS NOT NULL Then (SELECT ID, Cancellation_Policy_Type, MIN(Cancellation_Policy_Hours) from MYTABLE WHERE Cancellation_Policy_Type = 'Partially Refundable') ELSEIF (SELECT ID, Cancellation_Policy_Type, MIN(Cancellation_Policy_Hours) from MYTABLE WHERE Cancellation_Policy_Type = 'Free Cancellation') IS NULL AND (SELECT ID, Cancellation_Policy_Type, MIN(Cancellation_Policy_Hours) from MYTABLE WHERE Cancellation_Policy_Type = 'Partially Refundable') IS NULL THEN (SELECT ID, Cancellation_Policy_Type, MIN(Cancellation_Policy_Hours) from MYTABLE WHERE Cancellation_Policy_Type = 'No Refundable') END </code></pre> <p>Below you will find an example of my dataset:</p> <p>This is the table which contains all data regarding the cancellation policies of every single ID:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: center;">ID</th> <th style="text-align: center;">Cancellation_Policy_Type</th> <th style="text-align: center;">Cancellation_Policy_Hours</th> </tr> </thead> <tbody> <tr> <td style="text-align: center;">1</td> <td style="text-align: center;">No Refundable</td> <td style="text-align: center;">17520</td> </tr> <tr> <td style="text-align: center;">1</td> <td style="text-align: center;">Partially Refunable</td> <td style="text-align: center;">168</td> </tr> <tr> <td style="text-align: center;">1</td> <td style="text-align: center;">Free Cancellation</td> <td style="text-align: center;">96</td> </tr> <tr> <td style="text-align: center;">2</td> <td style="text-align: center;">No Refundable</td> <td style="text-align: center;">17520</td> </tr> <tr> <td style="text-align: center;">2</td> <td style="text-align: center;">Partially Refunable</td> <td style="text-align: center;">336</td> </tr> <tr> <td style="text-align: center;">2</td> <td style="text-align: center;">Free Cancellation</td> <td style="text-align: center;">48</td> </tr> <tr> <td style="text-align: center;">3</td> <td style="text-align: center;">No Refundable</td> <td style="text-align: center;">17520</td> </tr> <tr> <td style="text-align: center;">3</td> <td style="text-align: center;">Partially Refunable</td> <td style="text-align: center;">336</td> </tr> <tr> <td style="text-align: center;">4</td> <td style="text-align: center;">No Refundable</td> <td style="text-align: center;">17520</td> </tr> </tbody> </table> </div> <p>Below is the desired result, that is a table which contains other pieces of information (including production) and the 2 columns where for every single ID repeats the best available cancellation policy type and hours:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: center;">ID</th> <th style="text-align: center;">Most Flexible Cancellation Type</th> <th style="text-align: center;">Most Flexible Cancellation Hours</th> <th style="text-align: left;">Other Columns (including buckets)</th> </tr> </thead> <tbody> <tr> <td style="text-align: center;">1</td> <td style="text-align: center;">Free Cancellation</td> <td style="text-align: center;">96</td> <td style="text-align: left;">a</td> </tr> <tr> <td style="text-align: center;">1</td> <td style="text-align: center;">Free Cancellation</td> <td style="text-align: center;">96</td> <td style="text-align: left;">b</td> </tr> <tr> <td style="text-align: center;">1</td> <td style="text-align: center;">Free Cancellation</td> <td style="text-align: center;">96</td> <td style="text-align: left;">c</td> </tr> <tr> <td style="text-align: center;">2</td> <td style="text-align: center;">Free Cancellation</td> <td style="text-align: center;">48</td> <td style="text-align: left;">a</td> </tr> <tr> <td style="text-align: center;">2</td> <td style="text-align: center;">Free Cancellation</td> <td style="text-align: center;">48</td> <td style="text-align: left;">b</td> </tr> <tr> <td style="text-align: center;">2</td> <td style="text-align: center;">Free Cancellation</td> <td style="text-align: center;">48</td> <td style="text-align: left;">c</td> </tr> <tr> <td style="text-align: center;">3</td> <td style="text-align: center;">Partially Refunable</td> <td style="text-align: center;">336</td> <td style="text-align: left;">a</td> </tr> <tr> <td style="text-align: center;">3</td> <td style="text-align: center;">Partially Refunable</td> <td style="text-align: center;">336</td> <td style="text-align: left;">b</td> </tr> <tr> <td style="text-align: center;">3</td> <td style="text-align: center;">Partially Refunable</td> <td style="text-align: center;">336</td> <td style="text-align: left;">c</td> </tr> <tr> <td style="text-align: center;">4</td> <td style="text-align: center;">No Refundable</td> <td style="text-align: center;">17520</td> <td style="text-align: left;">a</td> </tr> <tr> <td style="text-align: center;">4</td> <td style="text-align: center;">No Refundable</td> <td style="text-align: center;">17520</td> <td style="text-align: left;">b</td> </tr> <tr> <td style="text-align: center;">4</td> <td style="text-align: center;">No Refundable</td> <td style="text-align: center;">17520</td> <td style="text-align: left;">c</td> </tr> </tbody> </table> </div> <pre><code>SELECT a.ID , Most_Flexible_Policy_Type , Most_Flexible_Cancellation_Hours , a.BookingWindowBuckets FROM Production a LEFT JOIN Property b on a.ID = b.ID GROUP BY 1,2,3,4 </code></pre> <p>Thank you</p>
[ { "answer_id": 74436290, "author": "nnichols", "author_id": 1191247, "author_profile": "https://Stackoverflow.com/users/1191247", "pm_score": 0, "selected": false, "text": "SELECT\n ID,\n MIN(IF(Cancellation_Policy_Type = 'Free Cancellation', Cancellation_Policy_Hours, NULL)) AS minFreeCancellation,\n MIN(IF(Cancellation_Policy_Type = 'Partially Refundable', Cancellation_Policy_Hours, NULL)) AS minPartiallyRefundable,\n MIN(IF(Cancellation_Policy_Type = 'No Refundable', Cancellation_Policy_Hours, NULL)) AS minNoRefundable\nFROM MYTABLE\nWHERE ID = ?\nGROUP BY ID;\n" }, { "answer_id": 74439147, "author": "GMB", "author_id": 10676716, "author_profile": "https://Stackoverflow.com/users/10676716", "pm_score": 2, "selected": true, "text": "production" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4716032/" ]
74,435,801
<p>How can we know the no. of tasks that are waiting for processing on task server/app server in Marklogic. I can only see the max limit and no. of requests are processing right now. But I didn't find any option to know the no. of tasks that are waiting.</p> <p>Anyone please help.</p> <p>I tried with different manage APIs to get the info. But didn't find any information related to waiting tasks.</p>
[ { "answer_id": 74436290, "author": "nnichols", "author_id": 1191247, "author_profile": "https://Stackoverflow.com/users/1191247", "pm_score": 0, "selected": false, "text": "SELECT\n ID,\n MIN(IF(Cancellation_Policy_Type = 'Free Cancellation', Cancellation_Policy_Hours, NULL)) AS minFreeCancellation,\n MIN(IF(Cancellation_Policy_Type = 'Partially Refundable', Cancellation_Policy_Hours, NULL)) AS minPartiallyRefundable,\n MIN(IF(Cancellation_Policy_Type = 'No Refundable', Cancellation_Policy_Hours, NULL)) AS minNoRefundable\nFROM MYTABLE\nWHERE ID = ?\nGROUP BY ID;\n" }, { "answer_id": 74439147, "author": "GMB", "author_id": 10676716, "author_profile": "https://Stackoverflow.com/users/10676716", "pm_score": 2, "selected": true, "text": "production" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2493317/" ]
74,435,809
<p>I have tried to make a discord bot using python but thing is that the bot does not respond... So I just restarted from 0 and made this little code :</p> <pre><code>import discord bot = discord.Bot() @bot.event async def on_ready(): print(&quot; -----------------&quot;) print(&quot; H2H - Here 2 Help&quot;) print(&quot; -----------------&quot;) print(&quot; &quot;) print(&quot;--&gt; by ItsMoonlight_#3415&quot;) @bot.event async def on_message(message): if message.content.lower() == &quot;ping&quot;: await message.channel.send(&quot;pong&quot;) bot.run('my_incredible_token') </code></pre> <p>(i use a .bat file to start the bot. in the .bat there is</p> <pre><code>@echo off py H2H.py pause </code></pre> <p>and this work, i can see the &quot;on_ready&quot; text.)</p> <p>But the bot STILL DOESN'T WORK !!</p> <p><a href="https://i.stack.imgur.com/BfLRy.png" rel="nofollow noreferrer">proof xD</a></p> <p>My goal is to make a bot with simple commands (like /mute, /help, /clear, etc...).</p> <p>I tried to make the &quot;ping-pong&quot; command which is very simple to see if the bot works, and it does not...</p> <p>Help meeeee :'(</p>
[ { "answer_id": 74437416, "author": "McBrincie212", "author_id": 20503634, "author_profile": "https://Stackoverflow.com/users/20503634", "pm_score": 0, "selected": false, "text": "discord.Bot" }, { "answer_id": 74453090, "author": "DRags", "author_id": 16345314, "author_profile": "https://Stackoverflow.com/users/16345314", "pm_score": -1, "selected": false, "text": "message.content.lower()" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20502941/" ]
74,435,831
<p>I got this error. Any idea?</p> <p>Thank you.</p> <p>Error:</p> <pre><code>PHP Fatal error: Uncaught Error: Undefined constant &quot;CURLOPT_TCP_FASTOPEN&quot; </code></pre> <p>OS:</p> <pre><code>CentOs 7.x </code></pre> <p>Version:</p> <pre><code>3.10.0-1160.76.1.el7.x86_64 </code></pre> <p>$curl --tcp-fastopen -O <a href="http://google.com" rel="nofollow noreferrer">http://google.com</a></p> <pre><code>curl: option --tcp-fastopen: is unknown curl: try 'curl --help' or 'curl --manual' for more information </code></pre> <p>$ php -v</p> <pre><code>PHP 8.1.12 (cli) (built: Oct 25 2022 17:30:00) (NTS gcc x86_64) Copyright (c) The PHP Group Zend Engine v4.1.12, Copyright (c) Zend Technologies </code></pre> <p>$cat /proc/sys/net/ipv4/tcp_fastopen</p> <pre><code>3 </code></pre> <p>PHP has been installed using:</p> <pre><code>sudo yum-config-manager --disable 'remi-php*' sudo yum-config-manager --enable remi-php81 sudo yum repolist sudo yum -y install php php-{cli,mbstring,curl,json} </code></pre> <p>php.ini</p> <pre><code>cURL support =&gt; enabled cURL Information =&gt; 7.29.0 Age =&gt; 3 Features AsynchDNS =&gt; Yes CharConv =&gt; No Debug =&gt; No GSS-Negotiate =&gt; Yes IDN =&gt; Yes IPv6 =&gt; Yes krb4 =&gt; No Largefile =&gt; Yes libz =&gt; Yes NTLM =&gt; Yes NTLMWB =&gt; Yes SPNEGO =&gt; No SSL =&gt; Yes SSPI =&gt; No TLS-SRP =&gt; No Protocols =&gt; dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp Host =&gt; x86_64-redhat-linux-gnu SSL Version =&gt; NSS/3.53.1 ZLib Version =&gt; 1.2.7 libSSH Version =&gt; libssh2/1.8.0 </code></pre>
[ { "answer_id": 74444445, "author": "hanshenrik", "author_id": 1067003, "author_profile": "https://Stackoverflow.com/users/1067003", "pm_score": 0, "selected": false, "text": "git clone -b 'OpenSSL_1_1_1k' --single-branch --depth 1 https://github.com/openssl/openssl\ncd openssl\n./config\nmake -j $(nproc)\nmkdir lib\ncp *.a lib;\ncd ..\ngit clone -b 'curl-7_76_1' --single-branch --depth 1 https://github.com/curl/curl.git\ncd curl\n./buildconf\nLDFLAGS=\"-static\" ./configure --with-ssl=$(realpath ../openssl) --enable-static\nmake -j $(nproc)\ncd ..\ngit clone -b 'PHP-8.1' --single-branch --depth 1 'https://github.com/php/php-src.git'\ncd php-src;\n./buildconf;\n./configure --with-curl=$(realpath ../curl)\nmake -j $(nproc)\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8500616/" ]
74,435,838
<p>For a research project, I am building a web tool to track users' interactions with specific elements that I need for later analysis.</p> <p>Often, I have interactable containers that contain graphics or text elements, sometimes both. For instance:</p> <pre><code>&lt;div class=&quot;interaction-field trackable&quot; id=&quot;specific-interaction-id&quot;&gt; &lt;!-- This id is what I want to track --&gt; &lt;img id=&quot;img-id&quot; src=&quot;path/to/img.png&quot;/&gt; &lt;!-- But i am triggering either this... --&gt; &lt;p&gt; Some Text &lt;/p&gt; &lt;!--...or this --&gt; &lt;/div&gt; </code></pre> <p>I style the container by its <code>interaction-field</code> class and have a javascript function that logs all interactions based on the <code>trackable</code> class. Now, I got two issues.</p> <ol> <li>For the tracking, I want to store the container's id for simplicity, as in such cases the <code>&lt;img&gt;</code> and <code>&lt;p&gt;</code> belong together. However, most <code>click</code> events, for example, are only recognised on child elements.</li> <li>Because of this, the parents' <code>targetable</code> class is not triggering, denying any logging. Since I want the parents' id as a compound trackable element, I would like to avoid giving the children the <code>targetable</code> class to avoid ambiguity and redundancy.</li> </ol> <p>I do get the general layering problem and it is logical that I rather hit the children than their parents. But is there an elegant way to always pass the parents' classes and id's to make the logging easier? Or is there an even simpler solution that I am not seeing?</p> <p>Thanks in advance!</p>
[ { "answer_id": 74435987, "author": "imvain2", "author_id": 3684265, "author_profile": "https://Stackoverflow.com/users/3684265", "pm_score": 2, "selected": true, "text": "document.addEventListener(\"click\",(e)=>{\n let trackedEl = e.target.closest(\".trackable\");\n if(trackedEl){\n console.log(trackedEl.id)\n }\n});" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5915076/" ]
74,435,859
<p>I know this question is a repeated one. But what I am trying to do is, I want to iterate through a date range and for each iteration i need to set the fromDate and toDate.</p> <p>for ex: If I give the date range as startDate = '2022-10-31' and endDate = '2022-11-04'</p> <p>and for each iteration fromDate = '2022-10-31' and toDate = '2022-11-01' next iteration fromDate = '2022-11-01' and endDate = '2022-11-02' and so on.</p> <p>I did some research and got to know how to iterate through dateRange. sample code:</p> <pre><code>import datetime start_date = datetime.date(2022, 10, 31) end_date = datetime.date(2022, 11, 04) dates_2011_2013 = [ start_date + datetime.timedelta(n) for n in range(int ((end_date - start_date).days))] </code></pre> <p>This just prints the incremented dates in the date Range. Am new to Python language. Any help is appreciated.</p> <p>Thank you.</p>
[ { "answer_id": 74435930, "author": "Sreeram TP", "author_id": 7896849, "author_profile": "https://Stackoverflow.com/users/7896849", "pm_score": 1, "selected": false, "text": "import datetime\n\nstart_date = datetime.date(2022, 10, 31)\nend_date = datetime.date(2022, 11, 4)\n\ndates_2011_2013 = [ (start_date + datetime.timedelta(n), start_date + datetime.timedelta(n+1)) for n in range(int ((end_date - start_date).days))]\n\n\n[(datetime.date(2022, 10, 31), datetime.date(2022, 11, 1)),\n (datetime.date(2022, 11, 1), datetime.date(2022, 11, 2)),\n (datetime.date(2022, 11, 2), datetime.date(2022, 11, 3)),\n (datetime.date(2022, 11, 3), datetime.date(2022, 11, 4))]\n" }, { "answer_id": 74437767, "author": "SergFSM", "author_id": 18344512, "author_profile": "https://Stackoverflow.com/users/18344512", "pm_score": 1, "selected": true, "text": "while" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3222718/" ]
74,435,861
<p>Is there a known Java String with hashCode exactly equal to Integer.MIN_VALUE ? It would be helpful for writing a test for a hash table to help avoid a common mistake of running Math.Abs on the hashcode before performing the remainder operation.</p> <p>Ideally the string would include only ASCII characters, but I'm not sure if it woul dbe feasible.</p>
[ { "answer_id": 74437111, "author": "knittl", "author_id": 112968, "author_profile": "https://Stackoverflow.com/users/112968", "pm_score": 1, "selected": false, "text": "String#hashCode()" }, { "answer_id": 74437719, "author": "user16320675", "author_id": 16320675, "author_profile": "https://Stackoverflow.com/users/16320675", "pm_score": 4, "selected": true, "text": "StringLatin1" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2295812/" ]
74,435,870
<p>I know how I would do this using a temp table, but I want to know how to do this using both <code>ROW_NUMBER()</code> and <code>RANK()</code> for my own learning.</p> <p>Data:</p> <pre><code>Item Desc Qty Row ItemA ItemDescA 10 1 ItemA ItemDescA 20 2 ItemB ItemDescB 30 3 ItemB ItemDescB 40 4 ItemB ItemDescB 50 5 ItemC ItemDescC 60 6 </code></pre> <p>Desired Result:</p> <pre><code>Item Desc Qty Row ItemRow ItemA ItemDescA 10 1 1 ItemA ItemDescA 20 2 1 ItemB ItemDescB 30 3 2 ItemB ItemDescB 40 4 2 ItemB ItemDescB 50 5 2 ItemC ItemDescC 60 6 3 </code></pre> <p>My code:</p> <pre><code>select so.* , row_number() over(order by so.[Item], so.Qty) row --this gives me the Row column shown above --I want to add a single line here using ROW_NUMBER() or RANK() to accomplish this from #StockOrdersData so </code></pre>
[ { "answer_id": 74437111, "author": "knittl", "author_id": 112968, "author_profile": "https://Stackoverflow.com/users/112968", "pm_score": 1, "selected": false, "text": "String#hashCode()" }, { "answer_id": 74437719, "author": "user16320675", "author_id": 16320675, "author_profile": "https://Stackoverflow.com/users/16320675", "pm_score": 4, "selected": true, "text": "StringLatin1" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4838216/" ]
74,435,879
<p>I would like to create type from <code>key</code> in my code:</p> <pre><code>const arr = [{ key: &quot;a&quot;, nnumber: 11 }, { key: &quot;b&quot;, nnumber: 1 }]; function test&lt;Keys['key'] extends keyof string&gt;(keys: Keys): Keys[] { return arr.map((item) =&gt; item.key); } // should return &quot;a&quot;, &quot;b&quot; const tmp = test(arr); // ^? </code></pre> <p>Can anyone help me to create type for return [&quot;a&quot;, &quot;b&quot;].</p> <p>Thank you</p>
[ { "answer_id": 74435960, "author": "Matthieu Riegler", "author_id": 884123, "author_profile": "https://Stackoverflow.com/users/884123", "pm_score": 1, "selected": false, "text": "as const" }, { "answer_id": 74436758, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 0, "selected": false, "text": "const arr = [{ key: \"a\", nnumber: 11 }, { key: \"b\", nnumber: 1 }] as const;\n\nfunction test<K extends string>(keys: readonly { key: K }[]): K[] {\n return arr.map((item) => item.key as K);\n}\n\nconst tmp = test(arr);\n// ^? (\"a\" | \"b\")[]\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16768298/" ]
74,435,885
<p>I'm trying to query and correctly format an address made up of multiple values in Oracle when some of those values are NULL. Coalesce() works well for this but not when I add spacing/punctuation.</p> <p>Examples</p> <pre><code>address 1: 123 Main St address 2: Apt 1 City: New York State: NY Postal Code: 10001 Country: USA address 1: NULL address 2: NULL City: New York State: NULL Postal Code: 10001 Country: USA </code></pre> <p>When pulling in the full address, I'm wanting to ignore the subsequent punctuation if a value is NULL so there aren't excess commas/spaces.</p> <pre><code>select a.address1 || ' ' || a.address2 || ', ' || a.city || ', ' || a.state || ' ' || a.postal_code || ', ' || 'USA', Coalesce(a.address1, a.address2, a.city, a.state, a.postal_code,'USA') from address a </code></pre> <ul> <li>Example 1 Result: 123 Main St Apt 1, New York, NY 10001, USA</li> <li>Example 2 Result: , New York, 10001, USA</li> </ul> <p>Desired Result for example 2: New York, 10001, USA</p> <p>This is just one example but I'm wanting a still properly formatted line when any combination of the elements are missing.</p>
[ { "answer_id": 74435960, "author": "Matthieu Riegler", "author_id": 884123, "author_profile": "https://Stackoverflow.com/users/884123", "pm_score": 1, "selected": false, "text": "as const" }, { "answer_id": 74436758, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 0, "selected": false, "text": "const arr = [{ key: \"a\", nnumber: 11 }, { key: \"b\", nnumber: 1 }] as const;\n\nfunction test<K extends string>(keys: readonly { key: K }[]): K[] {\n return arr.map((item) => item.key as K);\n}\n\nconst tmp = test(arr);\n// ^? (\"a\" | \"b\")[]\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7999394/" ]
74,435,902
<p>I am trying to replace the &quot;o &quot; with &quot;• &quot; in this text:</p> <blockquote> <p>• Direct the Department’s technical</p> <p>• Perform supervisory and managerial responsibilities as leader of the program</p> <p>o Set direction to ensure goals and objectives</p> <p>o Select management and other key personnel</p> <p>o Collaborate with executive colleagues to develop and execute corporate initiatives and department strategy</p> <p>o Oversee the preparation and execution of department’s Annual Financial Plan and budget</p> <p>o Manage merit pay</p> <p>• Perform other duties as assigned</p> </blockquote> <p>Since these are at the beginning of the line I've tried</p> <pre><code>test&lt;- sub(test, pattern = &quot;o &quot;, replacement = &quot;• &quot;) # does not work test&lt;- gsub(test, pattern = &quot;^o &quot;, replacement = &quot;• &quot;) # does not work test&lt;- gsub(test, pattern = &quot;o &quot;, replacement = &quot;• &quot;) # works but it also replaces to to t• </code></pre> <p>Why does &quot;^o &quot; not work since it only appears at the beginning of each the line</p>
[ { "answer_id": 74435960, "author": "Matthieu Riegler", "author_id": 884123, "author_profile": "https://Stackoverflow.com/users/884123", "pm_score": 1, "selected": false, "text": "as const" }, { "answer_id": 74436758, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 0, "selected": false, "text": "const arr = [{ key: \"a\", nnumber: 11 }, { key: \"b\", nnumber: 1 }] as const;\n\nfunction test<K extends string>(keys: readonly { key: K }[]): K[] {\n return arr.map((item) => item.key as K);\n}\n\nconst tmp = test(arr);\n// ^? (\"a\" | \"b\")[]\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3482393/" ]
74,435,910
<p>Using <a href="https://www.jfrog.com/confluence/display/CLI/CLI+for+JFrog+Artifactory#CLIforJFrogArtifactory-Download,CopyandMoveCommandsSpecSchema" rel="nofollow noreferrer">JFrog CLI</a> (v1.48.1) I want to download the contents of a folder from an on-premise Artifactory instance (EnterpriseX license 7.41.7). The folder in question is on a specific sub-path in the Artifactory repo and has a specific property by which I can identify the folder.</p> <p>The overall repo structure is a follows:</p> <pre><code>product-repo |-- develop `-- releases |-- ProductX `-- ProductY |-- build01 [@release_ready = false] |-- build02 [@release_ready = false] `-- build03 [@release_ready = true] |-- x86 | `-- program.exe |-- x64 | `-- program64.exe `-- common `-- README.txt </code></pre> <p>All <code>buildXX</code> folders are identical in terms of content. All <code>buildXX</code> folders have a property named <code>release_ready</code> which is <code>true</code> for <code>build03</code> and <code>false</code> for the other two folders.</p> <p>In the example above, I want to download the folder <code>build03</code> including all its contents because this folder is on the <code>releases/ProductY</code> path of the <code>product-repo</code> repository and has <code>release_ready</code> = <code>true</code>.</p> <p>I have devised a <a href="https://www.jfrog.com/confluence/display/RTF4X/Using+File+Specs" rel="nofollow noreferrer">file spec</a> for this task:</p> <pre><code>{ &quot;files&quot;: [ { &quot;aql&quot;: { &quot;items.find&quot;: { &quot;repo&quot;: &quot;product-repo&quot;, &quot;path&quot;: {&quot;$match&quot;:&quot;*releases/ProductY*&quot;}, &quot;type&quot;: &quot;folder&quot;, &quot;@release_ready&quot;: {&quot;$eq&quot;: &quot;True&quot;} } }, &quot;recursive&quot;: &quot;true&quot;, &quot;target&quot;: &quot;some/folder/on/my/disk/&quot; } ] } </code></pre> <p>Using JFrog CLI to search this folder (<code>jfrog rt s --spec myfilespec.json</code>) works like a charm - as expected, Jfrog returns the folder <code>build03</code>.</p> <p>However, when I try to download the folder using <code>jfrog rt dl --spec myfilespec.json</code> Jfrog CLI only creates the folder structure releases/ProductY/build03 at the target path but never actually downloads any files. The exact log output is as follows:</p> <pre><code> Log path: C:\Users\myuser\.jfrog\logs\jfrog-cli.&lt;date&gt;.log { &quot;status&quot;: &quot;success&quot;, &quot;totals&quot;: { &quot;success&quot;: 0, &quot;failure&quot;: 0 } } </code></pre> <p>With the log file containing just the following lines:</p> <pre><code>[Info] Searching items to download... [Info] [Thread 2] Downloading procduct-repo/repeases/ProgramY/build03/ [Info] [Thread 2] Creating folder: releases\ProgramY\build03 </code></pre> <p>What am I missing?</p>
[ { "answer_id": 74435960, "author": "Matthieu Riegler", "author_id": 884123, "author_profile": "https://Stackoverflow.com/users/884123", "pm_score": 1, "selected": false, "text": "as const" }, { "answer_id": 74436758, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 0, "selected": false, "text": "const arr = [{ key: \"a\", nnumber: 11 }, { key: \"b\", nnumber: 1 }] as const;\n\nfunction test<K extends string>(keys: readonly { key: K }[]): K[] {\n return arr.map((item) => item.key as K);\n}\n\nconst tmp = test(arr);\n// ^? (\"a\" | \"b\")[]\n" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11289327/" ]
74,435,915
<p>I have a file that contains somehting like this:</p> <pre><code>[project] name = &quot;sinntelligence&quot; version = &quot;1.1.dev12&quot; dependencies = [ &quot;opencv-python&quot;, &quot;matplotlib&quot;, &quot;PySide6&quot;, &quot;numpy&quot;, &quot;numba&quot; ] </code></pre> <p>Now I want to find the &quot;version&quot; string and increment the last number after &quot;dev&quot;. Thus in the above example I would like to change</p> <pre><code>version = &quot;1.1.dev12&quot; </code></pre> <p>to</p> <pre><code>version = &quot;1.1.dev13&quot; </code></pre> <p>and so forth. With <code>grep</code> I was able to get this line with this regular expression:</p> <pre><code>grep -P &quot;^version.*dev[0-9]+&quot; </code></pre> <p>But since I want to replace something in a file I thought it would make more sense to use <code>sed</code> instead. However, with <code>sed</code> I don't even find that line (i.e. nothing is replaced) with this:</p> <pre><code>sed -i &quot;s/^version.*dev[0-9]+/test/g&quot; sed-test.txt </code></pre> <p>Any ideas 1) what I am doing wrong here with <code>sed</code> and 2) how can increase that &quot;dev&quot; number by one and write that back to the file (with just typical Ubuntu Linux command line tools)?</p>
[ { "answer_id": 74436007, "author": "Wiktor Stribiżew", "author_id": 3832970, "author_profile": "https://Stackoverflow.com/users/3832970", "pm_score": 2, "selected": true, "text": "grep" }, { "answer_id": 74436379, "author": "Arkadiusz Drabczyk", "author_id": 3691891, "author_profile": "https://Stackoverflow.com/users/3691891", "pm_score": 0, "selected": false, "text": "-E" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/514149/" ]
74,435,936
<p>My XML input looks like:</p> <pre><code>&lt;?xml version=&quot;1.0&quot; ?&gt; &lt;input&gt; &lt;record&gt; &lt;name&gt;James Smith&lt;/name&gt; &lt;country&gt;United Kingdom&lt;/country&gt; &lt;opt&gt; good social skills, &lt;qualification&gt;MSc&lt;/qualification&gt;, 10 years of experience &lt;/opt&gt; &lt;section&gt;1B&lt;/section&gt; &lt;/record&gt; &lt;record&gt; &lt;name&gt;Rafael Pérez&lt;/name&gt; &lt;country&gt;Spain&lt;/country&gt; &lt;section&gt;2A&lt;/section&gt; &lt;/record&gt; &lt;record&gt; &lt;name&gt;Marie-Claire Legrand&lt;/name&gt; &lt;country&gt;France&lt;/country&gt; &lt;opt&gt; clear voice, &lt;qualification&gt;MBA&lt;/qualification&gt;, 3 years of experience &lt;/opt&gt; &lt;section&gt;1B&lt;/section&gt; &lt;/record&gt; &lt;/input&gt; </code></pre> <p>I want to output the text nodes under the <code>&lt;opt&gt;</code> tag between parentheses, removing the starting and ending spaces and new lines around the contents of its children. This would be very easy if I had only a text child applying the function <code>normalise-space()</code> to it, but this function cannot be applied to a set of nodes.</p> <p>A MWE of my code looks as follows:</p> <pre><code>&lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&gt; &lt;xsl:output method=&quot;text&quot; indent=&quot;yes&quot; encoding=&quot;utf-8&quot;/&gt; &lt;xsl:template match=&quot;input&quot;&gt; &lt;xsl:text&gt;------------------------------------------&amp;#xa;&lt;/xsl:text&gt; &lt;xsl:for-each select=&quot;record&quot;&gt; &lt;xsl:apply-templates select=&quot;node()[not(self::text()[not(normalize-space())])]&quot;/&gt; &lt;xsl:text&gt;&amp;#xa;------------------------------------------&amp;#xa;&lt;/xsl:text&gt; &lt;/xsl:for-each&gt; &lt;/xsl:template&gt; &lt;xsl:template match=&quot;qualification&quot;&gt; &lt;xsl:choose&gt; &lt;xsl:when test=&quot;. = 'MBA'&quot;&gt;Master in Business Administration&lt;/xsl:when&gt; &lt;xsl:when test=&quot;. = 'MSc'&quot;&gt;Master in Sciences&lt;/xsl:when&gt; &lt;xsl:otherwise&gt;&lt;xsl:value-of select=&quot;.&quot;/&gt;&lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:template&gt; &lt;xsl:template match=&quot;name|country&quot;&gt; &lt;xsl:value-of select=&quot;.&quot;/&gt; &lt;xsl:text&gt;, &lt;/xsl:text&gt; &lt;/xsl:template&gt; &lt;xsl:template match=&quot;section&quot;&gt; &lt;xsl:text&gt;Section: &lt;/xsl:text&gt; &lt;xsl:value-of select=&quot;.&quot;/&gt; &lt;xsl:text&gt;.&lt;/xsl:text&gt; &lt;/xsl:template&gt; &lt;xsl:template match=&quot;opt&quot;&gt; &lt;xsl:text&gt;(&lt;/xsl:text&gt; &lt;xsl:apply-templates/&gt; &lt;xsl:text&gt;), &lt;/xsl:text&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>but gives me a wrong output, having spaces inside of the parentheses, as below:</p> <pre><code>------------------------------------------ James Smith, United Kingdom, ( good social skills, Master in Sciences, 10 years of experience ), Section: 1B. ------------------------------------------ Rafael Pérez, Spain, Section: 2A. ------------------------------------------ Marie-Claire Legrand, France, ( clear voice, Master in Business Administration, 3 years of experience ), Section: 1B. ------------------------------------------ </code></pre> <p>The output want is:</p> <pre><code>------------------------------------------ James Smith, United Kingdom, (good social skills, Master in Sciences, 10 years of experience), Section: 1B. ------------------------------------------ Rafael Pérez, Spain, Section: 2A. ------------------------------------------ Marie-Claire Legrand, France, (clear voice, Master in Business Administration, 3 years of experience), Section: 1B. ------------------------------------------ </code></pre> <p>I understand I have to modify the template <code>&quot;opt&quot;</code>, but I cannot find how.</p>
[ { "answer_id": 74436337, "author": "michael.hor257k", "author_id": 3016153, "author_profile": "https://Stackoverflow.com/users/3016153", "pm_score": 2, "selected": true, "text": "<xsl:stylesheet version=\"1.0\"\nxmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n<xsl:output method=\"text\" encoding=\"utf-8\"/>\n<xsl:strip-space elements=\"*\"/>\n\n<xsl:template match=\"/input\">\n <xsl:text>------------------------------------------&#xa;</xsl:text>\n <xsl:apply-templates/>\n</xsl:template>\n\n<xsl:template match=\"record\">\n <xsl:apply-templates/>\n <xsl:text>&#xa;------------------------------------------&#xa;</xsl:text>\n</xsl:template>\n\n<xsl:template match=\"qualification\">\n <xsl:text> </xsl:text>\n <xsl:choose>\n <xsl:when test=\". = 'MBA'\">Master in Business Administration</xsl:when>\n <xsl:when test=\". = 'MSc'\">Master in Sciences</xsl:when>\n <xsl:otherwise>\n <xsl:value-of select=\".\"/>\n </xsl:otherwise>\n </xsl:choose>\n</xsl:template>\n\n<xsl:template match=\"name|country\">\n <xsl:value-of select=\".\"/>\n <xsl:text>, </xsl:text>\n</xsl:template>\n\n<xsl:template match=\"section\">\n <xsl:text>Section: </xsl:text>\n <xsl:value-of select=\".\"/>\n <xsl:text>.</xsl:text>\n</xsl:template>\n\n<xsl:template match=\"opt\">\n <xsl:text>(</xsl:text>\n <xsl:apply-templates/>\n <xsl:text>), </xsl:text>\n</xsl:template>\n\n<xsl:template match=\"opt/text()\">\n <xsl:value-of select=\"normalize-space(.)\"/>\n</xsl:template>\n\n</xsl:stylesheet>\n" }, { "answer_id": 74464055, "author": "Pierre François", "author_id": 1782782, "author_profile": "https://Stackoverflow.com/users/1782782", "pm_score": 0, "selected": false, "text": "normalize-space()" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1782782/" ]
74,435,979
<p>So, I've got this view of animal cards called like this:</p> <pre><code> &lt;AnimalsCard {...elephant}/&gt; &lt;AnimalsCard {...hippo}/&gt; &lt;AnimalsCard {...sugar_glider}/&gt; </code></pre> <p><a href="https://i.stack.imgur.com/fLwmh.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fLwmh.jpg" alt="View" /></a></p> <p>My AnimalCard code looks like this:</p> <pre><code>export const AnimalsCard = ({ id, animal, img }) =&gt; { const { t } = useTranslation(); return ( &lt;&gt; &lt;CardContainer id={id} img={img}&gt; &lt;CardContent&gt; &lt;CardTitle&gt;{animal}&lt;/CardTitle&gt; &lt;CardButton to={`${id}`}&gt;Dowiedz się więcej&lt;/CardButton&gt; &lt;/CardContent&gt; &lt;/CardContainer&gt; &lt;/&gt; ) }; </code></pre> <p>And my animal objects look like that:</p> <pre><code>export const elephant = { animal: 'Słoń indyjski', id: 'slon_indyjski', species: 'mammals', img: require('../../../images/animals/mammals/elephant.jpg'), occurance: '', habitat: '', diet: '', reproduction: '', conservationStatus: '', funFactOne: '' } </code></pre> <p>When I click the button, new page of the animal id opens up:</p> <pre><code> &lt;Route path=&quot;/:id&quot; component={AnimalsDetails} /&gt; </code></pre> <p>On AnimalsDetails page, I would like to display all of the animal object data. I unfortunately have no idea how to pass it because I'm a beginner and hardly know anything about props and stuff. My current approach is that in the AnimalsDetails I retrieve the ID using useParams();</p> <pre><code>export const AnimalsDetails = () =&gt; { const [mammal, setMammal] = useState(null); let { id } = useParams(); useEffect(() =&gt; { const mammal = mammalsData.filter(thisMammal =&gt; thisMammal.id === id); setMammal(mammal); // console.log(mammal[0].animal); }, [id]); return ( &lt;AnimalsDetailsContainer&gt; {/* &lt;div&gt;{mammal[0].id}&lt;/div&gt; */} &lt;/AnimalsDetailsContainer&gt; ) }; export default AnimalsDetails; </code></pre> <p>And then using the ID from URL, I'm filtering my mammalsData array that I've created only to test if the approach works (I wish I could use the previously created objects but I don't know if it's possible). It looks like that:</p> <pre><code>export const mammalsData = [ { [...] }, { animal: 'abc', id: 'fgh', species: 'idontknow', img: require('whatimdoing.JPG'), occurance: '', habitat: '', diet: '', reproduction: '', conservationStatus: '', funFactOne: '' } ]; </code></pre> <p>For now it works only when I'm on the animals card page and click the button, so the ID is present. If I'm somewhere else on the page and my ID is not declared yet, I receive an error that the data I want to display is undefined, which makes sense obviously. I've tried wrapping the return of the AnimalsDetails to log an error if the ID is not present but it didn't work.</p> <p>I know there is some decent way to do that (probably with props or hooks defined differently), but I really tried many stuff and I'm utterly lost now. I wish I could pass the data to AnimalsDetails within clicking the button or something but have no idea how to do that. :-(</p> <p>I'll be grateful for any help. I know it's basic stuff, but it's my first website ever.</p>
[ { "answer_id": 74436105, "author": "DevAra", "author_id": 4122324, "author_profile": "https://Stackoverflow.com/users/4122324", "pm_score": 0, "selected": false, "text": "<Route path=\"/:id\" render={()=> <AnimalsDetails item={...animaldata} />} />\n" }, { "answer_id": 74436284, "author": "Stone-Giant", "author_id": 20502761, "author_profile": "https://Stackoverflow.com/users/20502761", "pm_score": 2, "selected": false, "text": "useEffect(() => {\n if(id != undefined)\n // console.log('error);\n return (\n <div>{'error'}</div>\n );\n const mammal = mammalsData.filter(thisMammal => thisMammal.id === id);\n setMammal(mammal);\n // console.log(mammal[0].animal);\n }, [id]);\n" }, { "answer_id": 74436363, "author": "Nikolay", "author_id": 929187, "author_profile": "https://Stackoverflow.com/users/929187", "pm_score": 0, "selected": false, "text": "element" }, { "answer_id": 74440005, "author": "Lakruwan Pathirage", "author_id": 12383492, "author_profile": "https://Stackoverflow.com/users/12383492", "pm_score": 1, "selected": false, "text": "react router v6" } ]
2022/11/14
[ "https://Stackoverflow.com/questions/74435979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17767762/" ]