qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,334,712
<p>I know this is probably a dumb question and I am missing something really simple, but I can't for the life of me figure out where I am going wrong... I am ultimately trying to generate a list of all possible letter combinations with a string of a given length. I know some of these letter combinations wont be pronounceable, but I am going to call them 'words' nonetheless for simplicity. For example, if I know my string is one letter long, I want to generate a list of letters, &quot;A&quot; though &quot;Z&quot;, 26 elements long. If I know my string is two letters long, I will need a list of &quot;words&quot; from &quot;AA&quot; to &quot;ZZ&quot;, 676 elements long. The rub comes where I do not know the number of letters ahead of time.</p> <p>If I know my 'word' will only be one letter, then I can do this:</p> <pre><code>letters = [&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, ... &quot;X&quot;, &quot;Y&quot;, &quot;Z&quot;] words = [] for x in range(26): words.append(letters[x]) print(words) </code></pre> <p>If I know my 'word' will be two letters long, I can do this:</p> <pre><code>letters = [&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, ... &quot;X&quot;, &quot;Y&quot;, &quot;Z&quot;] words = [] for x in range(26): for y in range(26): words.append(letters[x] + letters[y]) print(words) </code></pre> <p>What I can't for the life of me figure out is how to do this when I don't know ahead of time how many letters my word will have. I basically want a formula where I give it the number of letters, and it gives me a list of all the possible words, that number of letters long. Something to the effect of:</p> <pre><code>def possible_words(word_length): list_of_words = [] number_of_words = 26 ** word_length for x in range(number_of_words): '''generate the new word here''' list_of_words.append(new_word) return list_of_words </code></pre> <p>Where am I going wrong? What am I missing? I feel like I am so close, I know this has to be a simple problem, but I have been racking my brain for a few hours now and can't figure it out. I feel like the solution lies in something involving recursion? And I think I maybe can't get the numbers to line up with the words because of a combination of zero-indexing and the fact that a 'zero letter' doesn't exist? I don't know, the more I think the more confused I get... Please help! Thanks in advance!</p> <p>EDIT: Thanks to those who responded and specifically to njp and Thierry Lathuille who directed me towards itertools.product! The solutions was even more pythonic than I could have hoped for! Below is the code I ended up using, in case anyone else comes across the same issue:</p> <pre><code>import itertools alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' word_length = 2 # The 2 is just for testing, actual value will be determined programatically... letter_tuples = itertools.product(alphabet, repeat=word_length) words = [&quot;&quot;.join(letter_tuple) for letter_tuple in letter_tuples] print(words) </code></pre>
[ { "answer_id": 74334913, "author": "njp", "author_id": 14278409, "author_profile": "https://Stackoverflow.com/users/14278409", "pm_score": 2, "selected": true, "text": "itertools.product" }, { "answer_id": 74334949, "author": "OliDev", "author_id": 17194494, "author_profile": "https://Stackoverflow.com/users/17194494", "pm_score": 0, "selected": false, "text": "word_length = 1\nlist_of_words = []\nletters = [\"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\"]\nletter_on = 0\ncount = 0\nfor x in range(word_length*len(letters)):\n if letter_on != 27:\n if count != word_length:\n list_of_words.append(letters[letter_on])\n count+=1\n else:\n count=0\n letter_on+=1\n else:\n break\n\nprint(list_of_words)\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74334712", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4569795/" ]
74,334,723
<pre><code> import React from &quot;react&quot;; import ReactDOM from &quot;react-dom&quot;; import { createRoot } from 'react-dom/client'; import axios from &quot;axios&quot;; const BASEURL = &quot;https://jsonplaceholder.typicode.com/users&quot;; function axiosTest() { return axios.get(BASEURL).then(response =&gt; response.data) } function stepTwo(){ axiosTest() .then(data =&gt;{ var namesArray = data; //console.log(namesArray); return namesArray; }) } function Component1(){ var array2map = stepTwo(); console.log(array2map); return( &lt;div&gt; {array2map.map(item =&gt; &lt;p&gt;item.name&lt;/p&gt;)} &lt;/div&gt; ) } const root = ReactDOM.createRoot(document.getElementById('root')); root.render(&lt;Component1 /&gt;); </code></pre> <p>Why does array2map come back as undefined? That's what it says in the console log and what it says in the error I get as the result of trying to map something undefined. That's my question, I don't know how much more verbose about it I can be, but this site is forcing me to write more.</p>
[ { "answer_id": 74334913, "author": "njp", "author_id": 14278409, "author_profile": "https://Stackoverflow.com/users/14278409", "pm_score": 2, "selected": true, "text": "itertools.product" }, { "answer_id": 74334949, "author": "OliDev", "author_id": 17194494, "author_profile": "https://Stackoverflow.com/users/17194494", "pm_score": 0, "selected": false, "text": "word_length = 1\nlist_of_words = []\nletters = [\"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\"]\nletter_on = 0\ncount = 0\nfor x in range(word_length*len(letters)):\n if letter_on != 27:\n if count != word_length:\n list_of_words.append(letters[letter_on])\n count+=1\n else:\n count=0\n letter_on+=1\n else:\n break\n\nprint(list_of_words)\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74334723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9883126/" ]
74,334,735
<p>How do I check if multiple integers exists in a dictionary stored as a string in a columns in pandas dataframe?</p> <p><strong>Input dataframe</strong></p> <pre><code>| player | qualifier | | ------ | ---------------------------- | | John | &quot;{120: 'left', 107: True}&quot; | | Felix | {1: 'box centre', 120: 5.6}&quot; | </code></pre> <p>Check if 5, 6 and 107 exists as a key in the qualifier column</p> <p><strong>Desired output dataframe</strong></p> <pre><code> | player | qualifier | set_piece | | ------ | ----------------------------- | --------- | | John | &quot;{120: 'left', 107: True}&quot; | True | | Felix | &quot;{1: 'box centre', 120: 5.6}&quot; | False | </code></pre>
[ { "answer_id": 74334913, "author": "njp", "author_id": 14278409, "author_profile": "https://Stackoverflow.com/users/14278409", "pm_score": 2, "selected": true, "text": "itertools.product" }, { "answer_id": 74334949, "author": "OliDev", "author_id": 17194494, "author_profile": "https://Stackoverflow.com/users/17194494", "pm_score": 0, "selected": false, "text": "word_length = 1\nlist_of_words = []\nletters = [\"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\"]\nletter_on = 0\ncount = 0\nfor x in range(word_length*len(letters)):\n if letter_on != 27:\n if count != word_length:\n list_of_words.append(letters[letter_on])\n count+=1\n else:\n count=0\n letter_on+=1\n else:\n break\n\nprint(list_of_words)\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74334735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10570374/" ]
74,334,802
<p>I used win32com to read and send an outlook mail, but when i do it creates a pop up which asks me to deny or allow the program to do so, there is a python module which will allow me to press &quot;allow for 10 minutes,&quot; and then click allow?</p> <p>Just wanted to know if there a module which is able to do so similar to what selenium does on web</p>
[ { "answer_id": 74334913, "author": "njp", "author_id": 14278409, "author_profile": "https://Stackoverflow.com/users/14278409", "pm_score": 2, "selected": true, "text": "itertools.product" }, { "answer_id": 74334949, "author": "OliDev", "author_id": 17194494, "author_profile": "https://Stackoverflow.com/users/17194494", "pm_score": 0, "selected": false, "text": "word_length = 1\nlist_of_words = []\nletters = [\"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\"]\nletter_on = 0\ncount = 0\nfor x in range(word_length*len(letters)):\n if letter_on != 27:\n if count != word_length:\n list_of_words.append(letters[letter_on])\n count+=1\n else:\n count=0\n letter_on+=1\n else:\n break\n\nprint(list_of_words)\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74334802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17519718/" ]
74,334,807
<p>I have been trying to create a regex pattern to validate names which would support alphabets, acute accent characters and including these 2 special characters <strong>-</strong> <strong>.</strong></p> <p>This is the pattern and it works as expected but only after I enter a 3rd character!</p> <p>So, it doesn't work for 2 characters and returns <strong>false</strong>.</p> <pre><code>/^[a-zA-ZßẞüÜöÖäÄÑñÁáÀàÂâÉéÈèÊêËëÍíÌìÎîÏïIJijÓóÒòÔôÚúÙùÛûÝýŸÿ\.\-]([a-zA-ZßẞüÜöÖäÄÑñÁáÀàÂâÉéÈèÊêËëÍíÌìÎîÏïIJijÓóÒòÔôÚúÙùÛûÝýŸÿ\s\.\-]+)([a-zA-ZßẞüÜöÖäÄÑñÁáÀàÂâÉéÈèÊêËëÍíÌìÎîÏïIJijÓóÒòÔôÚúÙùÛûÝýŸÿ\s\.\-]$)/.test('RE') </code></pre> <p>It works perfectly for &gt;=3 characters and returns <strong>true</strong>.</p> <pre><code>/^[a-zA-ZßẞüÜöÖäÄÑñÁáÀàÂâÉéÈèÊêËëÍíÌìÎîÏïIJijÓóÒòÔôÚúÙùÛûÝýŸÿ\.\-]([a-zA-ZßẞüÜöÖäÄÑñÁáÀàÂâÉéÈèÊêËëÍíÌìÎîÏïIJijÓóÒòÔôÚúÙùÛûÝýŸÿ\s\.\-]+)([a-zA-ZßẞüÜöÖäÄÑñÁáÀàÂâÉéÈèÊêËëÍíÌìÎîÏïIJijÓóÒòÔôÚúÙùÛûÝýŸÿ\s\.\-]$)/.test('REG') </code></pre> <p>What could be going wrong with the pattern which doesn't work for chars less than 3?</p> <p>Does somebody here recognize this?</p>
[ { "answer_id": 74334837, "author": "T.J. Crowder", "author_id": 157247, "author_profile": "https://Stackoverflow.com/users/157247", "pm_score": 3, "selected": true, "text": "[a-zA-ZßẞüÜöÖäÄÑñÁáÀàÂâÉéÈèÊêËëÍíÌìÎîÏïIJijÓóÒòÔôÚúÙùÛûÝýŸÿ\\.\\-]" }, { "answer_id": 74334838, "author": "Nikolay", "author_id": 929187, "author_profile": "https://Stackoverflow.com/users/929187", "pm_score": 1, "selected": false, "text": "/^[<char>(<char>+)<char>$/\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74334807", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5336321/" ]
74,334,895
<p>I am looking to replace the NULL values that occur as a result of a SQL JOIN statement, with 'N/A'. I have tried to set the default value of both related columns from both tables to N/A, however, every time I execute the SQL JOIN statement, I still receive NULL values.</p> <p>The two tables I have are the clients and Medical_Aid tables, which I have connected using a foreign key called Reg_No. Below is my sql join query</p> <pre><code>SELECT clients.Id_Number, clients.Medical_No, medical_aid.Name AS Medical_Aid, clients.First_Name, clients.Last_Name, clients.Age, clients.Gender, clients.Email, clients.Telephone FROM clients LEFT OUTER JOIN medical_aid ON clients.Reg_No = medical_aid.Reg_No; </code></pre> <p>I have tried to set the default value of the <code>Medical_No</code> and Medical_Name as <code>'N/A'</code> but every time I execute a <code>JOIN</code> statement, NULL values are returned on the <code>Medical_Name</code> column only</p> <p>Therefore, I am expecting the JOIN Statement to return <code>'N/A'</code> for both the <code>Medical_No</code> and <code>medical_AidName</code></p>
[ { "answer_id": 74334837, "author": "T.J. Crowder", "author_id": 157247, "author_profile": "https://Stackoverflow.com/users/157247", "pm_score": 3, "selected": true, "text": "[a-zA-ZßẞüÜöÖäÄÑñÁáÀàÂâÉéÈèÊêËëÍíÌìÎîÏïIJijÓóÒòÔôÚúÙùÛûÝýŸÿ\\.\\-]" }, { "answer_id": 74334838, "author": "Nikolay", "author_id": 929187, "author_profile": "https://Stackoverflow.com/users/929187", "pm_score": 1, "selected": false, "text": "/^[<char>(<char>+)<char>$/\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74334895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19755909/" ]
74,334,905
<p>I'm trying to make a command when you mention the bot, it will send a message saying “Slash Command: /help”. I have tried to make it and I tried to find an answer but I can’t find anything that works for me.</p> <p>Here is the code (I use the code in <code>index.js</code>):</p> <pre class="lang-js prettyprint-override"><code>client.on(&quot;messageCreate&quot;, (message) =&gt; { if (message.author.bot) return false; if (message.content.includes(&quot;@here&quot;) || message.content.includes(&quot;@everyone&quot;) || message.type == &quot;REPLY&quot;) return false; if (message.mentions.has(client.user.id)) { message.channel.send(&quot;Hello there!&quot;); } }); </code></pre> <p>I added the <code>GatewayIntentBits.Guilds</code> intent to my intents array. I don't get any errors, it just doesn’t work.</p>
[ { "answer_id": 74334946, "author": "1ly4s0", "author_id": 18992689, "author_profile": "https://Stackoverflow.com/users/18992689", "pm_score": 0, "selected": false, "text": "client.on(\"messageCreate\", (message) => {\n if (message.author.bot) return;\n\n if (message.content.includes(\"@here\") || message.content.includes(\"@everyone\") || message.type == \"REPLY\") return;\n\n if (message.content.match(new RegExp(`^<@!?${client.user.id}>( |)$`))) {\n message.channel.send(\"Hello there!\");\n }\n});\n" }, { "answer_id": 74335889, "author": "Zsolt Meszaros", "author_id": 6126373, "author_profile": "https://Stackoverflow.com/users/6126373", "pm_score": 2, "selected": true, "text": "GatewayIntentBits.Guilds" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74334905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16127385/" ]
74,334,910
<p>I'm trying to learn backtesting.py, when I run the following sample code, it pops up these errors, anyone could help? I tried to uninstall the Bokeh package and reinstall an older version, but it doen't work.</p> <pre><code>BokehDeprecationWarning: Passing lists of formats for DatetimeTickFormatter scales was deprecated in Bokeh 3.0. Configure a single string format for each scale C:\Users\paul_\AppData\Local\Programs\Python\Python310\lib\site-packages\bokeh\models\formatters.py:399: UserWarning: DatetimeFormatter scales now only accept a single format. Using the first prodvided: '%d %b' warnings.warn(f&quot;DatetimeFormatter scales now only accept a single format. Using the first prodvided: {fmt[0]!r} &quot;) BokehDeprecationWarning: Passing lists of formats for DatetimeTickFormatter scales was deprecated in Bokeh 3.0. Configure a single string format for each scale C:\Users\paul_\AppData\Local\Programs\Python\Python310\lib\site-packages\bokeh\models\formatters.py:399: UserWarning: DatetimeFormatter scales now only accept a single format. Using the first prodvided: '%m/%Y' warnings.warn(f&quot;DatetimeFormatter scales now only accept a single format. Using the first prodvided: {fmt[0]!r} &quot;) GridPlot(id='p11925', ...) </code></pre> <pre><code>import bokeh import datetime import pandas_ta as ta import pandas as pd from backtesting import Backtest from backtesting import Strategy from backtesting.lib import crossover from backtesting.test import GOOG class RsiOscillator(Strategy): upper_bound = 70 lower_bound = 30 rsi_window = 14 # Do as much initial computation as possible def init(self): self.rsi = self.I(ta.rsi, pd.Series(self.data.Close), self.rsi_window) # Step through bars one by one # Note that multiple buys are a thing here def next(self): if crossover(self.rsi, self.upper_bound): self.position.close() elif crossover(self.lower_bound, self.rsi): self.buy() bt = Backtest(GOOG, RsiOscillator, cash=10_000, commission=.002) stats = bt.run() bt.plot() </code></pre>
[ { "answer_id": 74410309, "author": "oats", "author_id": 1675668, "author_profile": "https://Stackoverflow.com/users/1675668", "pm_score": 2, "selected": false, "text": "python3 -m pip install bokeh==2.4.3\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74334910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20431354/" ]
74,334,952
<p>I need the first part of <code>$or</code> (or equivalent query) to be resolved first and to make sure that the first query is always part of the result.</p> <p>Must use query, not aggregation.</p> <pre><code>[ { &quot;docId&quot;: &quot;x1&quot; }, { &quot;docId&quot;: &quot;x2&quot; }, { &quot;docId&quot;: &quot;x3&quot; }, { &quot;docId&quot;: &quot;x4&quot; }, { &quot;docId&quot;: &quot;x5&quot; }, ... { &quot;docId&quot;: &quot;xn&quot; }, ] </code></pre> <p>Query:</p> <pre><code>{ '$or': [ { docId: 'x434' },{} ], } </code></pre> <p>I need <code>x434</code> to be part of the query result, regardless of all other results.</p> <p>Expected result:</p> <pre><code>[ { docId: 'x434' }, { docId: 'x12' }, { docId: 'x1' }, ... ] </code></pre> <p>Return:</p> <pre><code>[ { docId: 'xn' }, { docId: 'xn' }, { docId: 'xn' }, ... ] </code></pre> <p>Results by <code>x434</code> is not always returned</p> <p>I tried <code>$or</code> and <code>$and</code> queries but nothing worked. I tried <code>regex</code> too</p> <pre><code>{ '$or': [ { docId: 'x434' },{} ], } </code></pre>
[ { "answer_id": 74410309, "author": "oats", "author_id": 1675668, "author_profile": "https://Stackoverflow.com/users/1675668", "pm_score": 2, "selected": false, "text": "python3 -m pip install bokeh==2.4.3\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74334952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2156913/" ]
74,334,960
<p>I have come across different variations when it comes to user authentication and I have seen developers include a userId field AND a username field (both strings) in their database so I wondered if there is an advantage if you have both of these fields.</p> <p>I would rather have only one field (username) to have a better overview and prevent possible mistakes but I'm not sure if there could be problems that come along with that variation.</p> <p>I've already looked on the internet but only found a Quora answer which stated it would make sense to have a userId as an integer since &quot;Integers are easier/faster/less expensive to sort, search, and compare than strings&quot;</p> <ul> <li><a href="https://www.quora.com/Why-do-developers-add-user-id-and-username-fields-to-a-user-table-Isnt-the-username-enough" rel="nofollow noreferrer">https://www.quora.com/Why-do-developers-add-user-id-and-username-fields-to-a-user-table-Isnt-the-username-enough</a></li> </ul>
[ { "answer_id": 74410309, "author": "oats", "author_id": 1675668, "author_profile": "https://Stackoverflow.com/users/1675668", "pm_score": 2, "selected": false, "text": "python3 -m pip install bokeh==2.4.3\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74334960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19717770/" ]
74,334,976
<p>I want to fetch data from an api. Here is the api link and response:</p> <pre><code>https://digital-display.betafore.com/api/v1/digital-display/displays/ </code></pre> <p>Authorization Bearer:</p> <pre><code>eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjY3ODExNjkwLCJpYXQiOjE2Njc3MjUyOTAsImp0aSI6IjFmMjBkNDgyY2E3NzQzMGQ5MzM3ZjU3MTBlYjIzY2NhIiwiaWQiOjV9.QGvXtfHwWEJawAS-zIKo78UaCvMDr2lXx0796QcL_-4 </code></pre> <p>Here is the Response:</p> <pre><code>{ &quot;status&quot;: &quot;success&quot;, &quot;results&quot;: [ { &quot;id&quot;: 12, &quot;products&quot;: [ { &quot;id&quot;: 1, &quot;name&quot;: &quot;Test&quot;, &quot;unit&quot;: null, &quot;price&quot;: &quot;72000.00&quot;, &quot;sale_price&quot;: null, &quot;image&quot;: &quot;/uploads/digital_display/products/Screenshot_from_2022-10-31_13-04-58.png&quot;, &quot;category&quot;: null, &quot;badge&quot;: null } ], &quot;catalogs&quot;: [ { &quot;id&quot;: 12, &quot;name&quot;: null, &quot;unit&quot;: null, &quot;price&quot;: null, &quot;sale_price&quot;: null, &quot;image&quot;: &quot;/uploads/digital_display/catalogs/survivor-series-2021_LSje3Zz.jpg&quot;, &quot;video&quot;: null, &quot;badge&quot;: null } ], &quot;name&quot;: &quot;asdas&quot;, &quot;description&quot;: null, &quot;category&quot;: &quot;sdasdasd&quot;, &quot;template_name&quot;: &quot;dasda&quot;, &quot;banner_text&quot;: null }, { &quot;id&quot;: 13, &quot;products&quot;: [ { &quot;id&quot;: 1, &quot;name&quot;: &quot;Test&quot;, &quot;unit&quot;: null, &quot;price&quot;: &quot;72000.00&quot;, &quot;sale_price&quot;: null, &quot;image&quot;: &quot;/uploads/digital_display/products/Screenshot_from_2022-10-31_13-04-58.png&quot;, &quot;category&quot;: null, &quot;badge&quot;: null } ], &quot;catalogs&quot;: [ { &quot;id&quot;: 13, &quot;name&quot;: null, &quot;unit&quot;: null, &quot;price&quot;: null, &quot;sale_price&quot;: null, &quot;image&quot;: &quot;/uploads/digital_display/catalogs/survivor-series-2021_ndrmDBX.jpg&quot;, &quot;video&quot;: null, &quot;badge&quot;: null } ], &quot;name&quot;: &quot;asdas&quot;, &quot;description&quot;: null, &quot;category&quot;: &quot;sdasdasd&quot;, &quot;template_name&quot;: &quot;dasda&quot;, &quot;banner_text&quot;: null }, { &quot;id&quot;: 14, &quot;products&quot;: [ { &quot;id&quot;: 1, &quot;name&quot;: &quot;Test&quot;, &quot;unit&quot;: null, &quot;price&quot;: &quot;72000.00&quot;, &quot;sale_price&quot;: null, &quot;image&quot;: &quot;/uploads/digital_display/products/Screenshot_from_2022-10-31_13-04-58.png&quot;, &quot;category&quot;: null, &quot;badge&quot;: null } ], &quot;catalogs&quot;: [ { &quot;id&quot;: 14, &quot;name&quot;: null, &quot;unit&quot;: null, &quot;price&quot;: null, &quot;sale_price&quot;: null, &quot;image&quot;: &quot;/uploads/digital_display/catalogs/20220913_nxt_newlogo--52bc0a658df3cb6753ffd8b7da947690.jpg&quot;, &quot;video&quot;: null, &quot;badge&quot;: null } ], &quot;name&quot;: &quot;asdasd&quot;, &quot;description&quot;: null, &quot;category&quot;: &quot;sdasd&quot;, &quot;template_name&quot;: &quot;sdada&quot;, &quot;banner_text&quot;: null }, { &quot;id&quot;: 15, &quot;products&quot;: [ { &quot;id&quot;: 1, &quot;name&quot;: &quot;Test&quot;, &quot;unit&quot;: null, &quot;price&quot;: &quot;72000.00&quot;, &quot;sale_price&quot;: null, &quot;image&quot;: &quot;/uploads/digital_display/products/Screenshot_from_2022-10-31_13-04-58.png&quot;, &quot;category&quot;: null, &quot;badge&quot;: null } ], &quot;catalogs&quot;: [ { &quot;id&quot;: 15, &quot;name&quot;: null, &quot;unit&quot;: null, &quot;price&quot;: null, &quot;sale_price&quot;: null, &quot;image&quot;: &quot;/uploads/digital_display/catalogs/survivor-series-2021.jpg&quot;, &quot;video&quot;: null, &quot;badge&quot;: null } ], &quot;name&quot;: &quot;Sony Bravia&quot;, &quot;description&quot;: null, &quot;category&quot;: &quot;Restaurant&quot;, &quot;template_name&quot;: &quot;Sony Template&quot;, &quot;banner_text&quot;: null }, { &quot;id&quot;: 16, &quot;products&quot;: [ { &quot;id&quot;: 1, &quot;name&quot;: &quot;Test&quot;, &quot;unit&quot;: null, &quot;price&quot;: &quot;72000.00&quot;, &quot;sale_price&quot;: null, &quot;image&quot;: &quot;/uploads/digital_display/products/Screenshot_from_2022-10-31_13-04-58.png&quot;, &quot;category&quot;: null, &quot;badge&quot;: null } ], &quot;catalogs&quot;: [ { &quot;id&quot;: 16, &quot;name&quot;: null, &quot;unit&quot;: null, &quot;price&quot;: null, &quot;sale_price&quot;: null, &quot;image&quot;: &quot;/uploads/digital_display/catalogs/1033561.jpg&quot;, &quot;video&quot;: null, &quot;badge&quot;: null } ], &quot;name&quot;: &quot;asdas&quot;, &quot;description&quot;: null, &quot;category&quot;: &quot;sdasdasd&quot;, &quot;template_name&quot;: &quot;dasda&quot;, &quot;banner_text&quot;: null } ] } </code></pre> <p>Here is my controller where I used http package for fetching data from the api.</p> <pre><code> Future&lt;bool&gt; getDisplays() async { var url = Uri.parse( &quot;https://digital-display.betafore.com/api/v1/digital-display/displays/&quot;); var token = localStorage.getItem('access'); try { http.Response response = await http.get(url, headers: { &quot;Authorization&quot;: &quot;Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjY3NzYwOTY1LCJpYXQiOjE2Njc2NzQ1NjUsImp0aSI6ImE1ZjAyOTJlYTE1MjRhNDM5YzI2YWYwZGQzNjA3YjZlIiwiaWQiOjV9.yjKKzalzRvSrSiSBUhZtZVg3wBy_o7P2Wvy7sbMOOT0&quot; }); var data = json.decode(response.body) as List; List&lt;DisplayModel&gt; temp = []; for (var element in data) { DisplayModel displayModel = DisplayModel.fromJson(element); temp.add(displayModel); } _displays = temp; notifyListeners(); return true; } catch (exception) { return false; } } List&lt;DisplayModel&gt; get displays { return [..._displays]; } </code></pre> <p>Here is model:</p> <pre><code>class DisplayModel { String? status; List&lt;Results&gt;? results; DisplayModel({this.status, this.results}); DisplayModel.fromJson(Map&lt;String, dynamic&gt; json) { status = json['status']; if (json['results'] != null) { results = &lt;Results&gt;[]; json['results'].forEach((v) { results!.add(new Results.fromJson(v)); }); } } Map&lt;String, dynamic&gt; toJson() { final Map&lt;String, dynamic&gt; data = new Map&lt;String, dynamic&gt;(); data['status'] = this.status; if (this.results != null) { data['results'] = this.results!.map((v) =&gt; v.toJson()).toList(); } return data; } } class Results { int? id; List&lt;Products&gt;? products; List&lt;Catalogs&gt;? catalogs; String? name; Null? description; String? category; String? templateName; Null? bannerText; Results( {this.id, this.products, this.catalogs, this.name, this.description, this.category, this.templateName, this.bannerText}); Results.fromJson(Map&lt;String, dynamic&gt; json) { id = json['id']; if (json['products'] != null) { products = &lt;Products&gt;[]; json['products'].forEach((v) { products!.add(new Products.fromJson(v)); }); } if (json['catalogs'] != null) { catalogs = &lt;Catalogs&gt;[]; json['catalogs'].forEach((v) { catalogs!.add(new Catalogs.fromJson(v)); }); } name = json['name']; description = json['description']; category = json['category']; templateName = json['template_name']; bannerText = json['banner_text']; } Map&lt;String, dynamic&gt; toJson() { final Map&lt;String, dynamic&gt; data = new Map&lt;String, dynamic&gt;(); data['id'] = this.id; if (this.products != null) { data['products'] = this.products!.map((v) =&gt; v.toJson()).toList(); } if (this.catalogs != null) { data['catalogs'] = this.catalogs!.map((v) =&gt; v.toJson()).toList(); } data['name'] = this.name; data['description'] = this.description; data['category'] = this.category; data['template_name'] = this.templateName; data['banner_text'] = this.bannerText; return data; } } class Products { int? id; String? name; Null? unit; String? price; Null? salePrice; String? image; Null? category; Null? badge; Products( {this.id, this.name, this.unit, this.price, this.salePrice, this.image, this.category, this.badge}); Products.fromJson(Map&lt;String, dynamic&gt; json) { id = json['id']; name = json['name']; unit = json['unit']; price = json['price']; salePrice = json['sale_price']; image = json['image']; category = json['category']; badge = json['badge']; } Map&lt;String, dynamic&gt; toJson() { final Map&lt;String, dynamic&gt; data = new Map&lt;String, dynamic&gt;(); data['id'] = this.id; data['name'] = this.name; data['unit'] = this.unit; data['price'] = this.price; data['sale_price'] = this.salePrice; data['image'] = this.image; data['category'] = this.category; data['badge'] = this.badge; return data; } } class Catalogs { int? id; Null? name; Null? unit; Null? price; Null? salePrice; String? image; Null? video; Null? badge; Catalogs( {this.id, this.name, this.unit, this.price, this.salePrice, this.image, this.video, this.badge}); Catalogs.fromJson(Map&lt;String, dynamic&gt; json) { id = json['id']; name = json['name']; unit = json['unit']; price = json['price']; salePrice = json['sale_price']; image = json['image']; video = json['video']; badge = json['badge']; } Map&lt;String, dynamic&gt; toJson() { final Map&lt;String, dynamic&gt; data = new Map&lt;String, dynamic&gt;(); data['id'] = this.id; data['name'] = this.name; data['unit'] = this.unit; data['price'] = this.price; data['sale_price'] = this.salePrice; data['image'] = this.image; data['video'] = this.video; data['badge'] = this.badge; return data; } } </code></pre> <p>Here is frontend where I tried to show but gettting errors.</p> <p>here is the error I am getting : &quot;Index out of range: no indices are valid: 0&quot;</p> <p>Here is the frontend code:</p> <pre><code>import 'package:digitaldisplay/controllers/DisplayController.dart'; import 'package:digitaldisplay/views/screens/CreateDisplay.dart'; import 'package:digitaldisplay/views/screens/CreateProduct.dart'; import 'package:digitaldisplay/views/screens/ShowDisplay.dart'; import 'package:digitaldisplay/views/widgets/NavBar.dart'; import 'package:digitaldisplay/views/widgets/Package.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:responsive_toolkit/responsive_toolkit.dart'; import 'package:responsive_grid/responsive_grid.dart'; import '../../models/DisplayModel.dart'; import '../widgets/Display.dart'; class Home extends StatefulWidget { const Home({Key? key}) : super(key: key); static const routeName = &quot;/home&quot;; @override State&lt;Home&gt; createState() =&gt; _HomeState(); } class _HomeState extends State&lt;Home&gt; { bool _init = true; bool _loadingDisplay = false; @override void didChangeDependencies() async { if (_init) { _loadingDisplay = await Provider.of&lt;DisplayController&gt;(context).getDisplays(); setState(() {}); } _init = false; super.didChangeDependencies(); } DisplayController displayController = DisplayController(); @override Widget build(BuildContext context) { final displays = Provider.of&lt;DisplayController&gt;(context).displays; final ButtonStyle buttonStyle2 = ElevatedButton.styleFrom( backgroundColor: const Color(0xFF111111), shape: const StadiumBorder(), minimumSize: const Size(100, 50), ); final ButtonStyle buttonStyle1 = ElevatedButton.styleFrom( backgroundColor: const Color(0xFFc3232a), shape: const StadiumBorder(), minimumSize: const Size(100, 50), ); return Scaffold( backgroundColor: const Color(0xFFf5f5f5), drawer: const NavBar(), appBar: AppBar( leading: const Icon(Icons.menu, color: Colors.black), title: const Text( &quot;Digital Display&quot;, style: TextStyle( fontStyle: FontStyle.italic, color: Color(0xFF111111), fontWeight: FontWeight.bold, ), ), backgroundColor: const Color(0xFFe9e9ff), elevation: 0, ), body: Column( children: [ Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.end, children: [ Padding( padding: const EdgeInsets.all(8.0), child: ElevatedButton( onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (context) =&gt; const CreateDisplay()), ); }, child: Text(&quot;Create Display&quot;), style: buttonStyle2, ), ), ], ), Flexible( child: GridView.count( crossAxisCount: 3, children: List.generate( displays[0].results!.length, (i) =&gt; DisplayCard( displayName: displays[i].results![i].name as String, displayImage: displays[i].results![i].catalogs![i].image as String, id: displays[i].results![i].id as int))), ), // Flexible( // child: FutureBuilder( // future: displayController.getallDisplay(), // builder: (context, snapshot) { // if (snapshot.hasData) { // return GridView.count( // physics: const ScrollPhysics(), // crossAxisCount: 4, // crossAxisSpacing: 5, // children: List.generate( // snapshot.data?[&quot;results&quot;].length, (i) { // return InkWell( // onTap: () { // Navigator.push( // context, // MaterialPageRoute( // builder: (context) =&gt; ShowDisplay( // snapshot.data[&quot;results&quot;]?[i][&quot;id&quot;])), // ); // }, // child: DisplayCard( // id: snapshot.data[&quot;results&quot;]?[i][&quot;id&quot;], // displayName: snapshot.data[&quot;results&quot;]?[i][&quot;name&quot;], // displayImage: snapshot.data[&quot;results&quot;]?[i] // [&quot;catalogs&quot;][0][&quot;image&quot;], // ), // ); // })); // } else if (snapshot.hasError) { // return Center(child: Text(snapshot.error.toString())); // } else { // return const Center(child: CircularProgressIndicator()); // } // }), // ), // Flexible( // child: FutureBuilder( // future: displayController.getallDisplay(), // builder: (context, snapshot) { // if (snapshot.hasData) { // return GridView.count( // crossAxisCount: 4, // children: List.generate(displays.length, (i) { // return DisplayCard( // displayModel: displays, // ); // }), // ); // } else if (snapshot.hasError) { // return Center( // child: Text(snapshot.error.toString()), // ); // } else { // return const Center( // child: Text(&quot;Error&quot;), // ); // } // }), // ), Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( padding: const EdgeInsets.all(8.0), child: ElevatedButton( onPressed: () {}, child: Text(&quot;Dashboard&quot;), style: buttonStyle1, ), ), Padding( padding: const EdgeInsets.all(8.0), child: ElevatedButton( onPressed: () { Navigator.of(context) .pushReplacementNamed(CreateProduct.routeName); }, child: Text(&quot;Create Product&quot;), style: buttonStyle2, ), ), Padding( padding: const EdgeInsets.all(8.0), child: ElevatedButton( onPressed: () {}, child: Text(&quot;Logout&quot;), style: buttonStyle2, ), ), ], ), ], ), ); } } </code></pre> <p>I tried this method but failed to fetch data for that error maybe I did something wrong in the code but I don't have any idea why I am getting an error like this. can you please explain the solution of the error? And How can I fetch data from the api?</p>
[ { "answer_id": 74410309, "author": "oats", "author_id": 1675668, "author_profile": "https://Stackoverflow.com/users/1675668", "pm_score": 2, "selected": false, "text": "python3 -m pip install bokeh==2.4.3\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74334976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14427714/" ]
74,334,979
<p>Im trying to make a thing that can detect whether or not a user wants their password stored for next time they run the program, The reason im using a boolean for this is so in the files that need to use the password they can check to see if storepass is True then get the pass/user from a .env if not they can get the password from the storepasswordquestion file amd use that and it wont get stored when the user closes the program.</p> <p>I have a file called booleans that im using to store booleans, in it is this:</p> <pre><code>storepass = False </code></pre> <p>In a other file called storepasswordquestion i have:</p> <pre><code>import booleans username = 'username' password = 'password' question = input('Would you like your password to be stored for use next time?') # enter y if question == 'y': booleans.storepass = True # store password/username in .env </code></pre> <p>As i understand it import booleans loads the booleans file, Then i think booleans.storepass is like a variable but like a copy of the one in booleans? Because when i go on the booleans file again its still False.</p> <p>Im needing to change storepass to True in the booleans file and then save it.</p>
[ { "answer_id": 74335067, "author": "Kutay Kılıç", "author_id": 19274851, "author_profile": "https://Stackoverflow.com/users/19274851", "pm_score": -1, "selected": false, "text": " booleans.storepass = True\n print(booleans.storepass)#This should return True\n" }, { "answer_id": 74335222, "author": "Driftr95", "author_id": 6146136, "author_profile": "https://Stackoverflow.com/users/6146136", "pm_score": 1, "selected": false, "text": "with open('boolean.py', 'w') as f: \n f.write('storepass = False')\n" }, { "answer_id": 74335545, "author": "Marcus Müller", "author_id": 4433386, "author_profile": "https://Stackoverflow.com/users/4433386", "pm_score": 0, "selected": false, "text": "storepass" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74334979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,334,984
<p>We have a requirement to delete dynamodb items that are 3 days old so I tried default AWS CLI update query but the query doesn't take input value for TTL.</p> <p>As per documentation, I'm following the below query to activate dynamoDB TTL(Time to Live) however when it is activiated it defaults to one hour however I want a query that will take 3 days as the TTL value, can anyone help me with the correct query if it's available, we are creating a script deployment so we won't be doing via UI console.</p> <pre><code>aws dynamodb update-time-to-live \ --table-name MusicCollection \ --time-to-live-specification Enabled=true,AttributeName=ttl </code></pre> <p><strong>As shown in below image, items are not deleted passed the current time, I guess it deletes after an hour.</strong></p> <p><a href="https://i.stack.imgur.com/Y5L0a.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Y5L0a.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/GLegY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GLegY.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74335067, "author": "Kutay Kılıç", "author_id": 19274851, "author_profile": "https://Stackoverflow.com/users/19274851", "pm_score": -1, "selected": false, "text": " booleans.storepass = True\n print(booleans.storepass)#This should return True\n" }, { "answer_id": 74335222, "author": "Driftr95", "author_id": 6146136, "author_profile": "https://Stackoverflow.com/users/6146136", "pm_score": 1, "selected": false, "text": "with open('boolean.py', 'w') as f: \n f.write('storepass = False')\n" }, { "answer_id": 74335545, "author": "Marcus Müller", "author_id": 4433386, "author_profile": "https://Stackoverflow.com/users/4433386", "pm_score": 0, "selected": false, "text": "storepass" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74334984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13255146/" ]
74,334,988
<p>a beginner question over here but why exactly do we do that? like how does that work/what's the logic behind it?</p> <p>example of what I mean (I'm also wondering why we only did that with the Create function)</p> <pre><code>#include&lt;stdio.h&gt; void create(int *T,int n){ int i; printf(&quot;tab: &quot;); for(i=0;i&lt;n;i++) scanf(&quot;%d&quot;,&amp;T[i]); } void print(int T[],int n){ int i; for(i=0;i&lt;n;i++) printf(&quot;[%d]&quot;,T[i]); } int main(){ int n; printf(&quot;size: &quot;); scanf(&quot;%d&quot;,&amp;n); int T[100]; create(T,n); print(T,n); } </code></pre>
[ { "answer_id": 74335093, "author": "Mikdore", "author_id": 8309536, "author_profile": "https://Stackoverflow.com/users/8309536", "pm_score": 0, "selected": false, "text": "int T[]" }, { "answer_id": 74335187, "author": "John Bode", "author_id": 134554, "author_profile": "https://Stackoverflow.com/users/134554", "pm_score": 1, "selected": false, "text": "sizeof" }, { "answer_id": 74335272, "author": "tremon", "author_id": 10918915, "author_profile": "https://Stackoverflow.com/users/10918915", "pm_score": 0, "selected": false, "text": "int* a" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74334988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17676636/" ]
74,335,009
<p>i am stuck in a screen style like below as in the screen shot there are for input(image) elements i want them to be bordered same like in the image with circled tick mark. i've made these four input block but dont know how to style this when the user click on it (i mean when user clicks on it , it gets the same border and tick mark with as it is and input) <a href="https://i.stack.imgur.com/OI23a.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OI23a.png" alt="input type is image" /></a></p> <p>Note: i'm working in Reactjs MUI</p> <p>i have tried this</p> <pre><code>div:focus { border 2px solid #908098 } </code></pre> <p>but i dont know how to make that circled tick.</p>
[ { "answer_id": 74335093, "author": "Mikdore", "author_id": 8309536, "author_profile": "https://Stackoverflow.com/users/8309536", "pm_score": 0, "selected": false, "text": "int T[]" }, { "answer_id": 74335187, "author": "John Bode", "author_id": 134554, "author_profile": "https://Stackoverflow.com/users/134554", "pm_score": 1, "selected": false, "text": "sizeof" }, { "answer_id": 74335272, "author": "tremon", "author_id": 10918915, "author_profile": "https://Stackoverflow.com/users/10918915", "pm_score": 0, "selected": false, "text": "int* a" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11435955/" ]
74,335,026
<p>take the code from rustbook for example</p> <pre><code>fn longest&lt;'a&gt;(x: &amp;'a str, y: &amp;'a str) -&gt; &amp;'a str { if x.len() &gt; y.len() { x } else { y } } </code></pre> <p>we have the above function, now suppose we have main:</p> <pre><code>// can't compile , i understand this part, just post here for reference fn main1(){ let string1 = String::from(&quot;abcd&quot;); let result; { let string2 = String::from(&quot;xyz&quot;); // we will change this to &amp;str in next example result = longest(string1.as_str(), string2.as_str()); ^^^^^^ doesn't compile , string2 doesn't live long enough } println!(&quot;The longest string is {}&quot;, result); } </code></pre> <p>but if we slight change it to the code below, changing the string2 to be a string slice, this code actually compiles , and i dont quite know what's going on, does the &quot;xyz&quot; still count as valid memory?</p> <pre><code>//This compiles. but why? shouldn't ```longest()``` return a smaller lifetime and refuses to compile? fn main2(){ let string1 = String::from(&quot;abcd&quot;); let result; { let string2 = &quot;xyz&quot;; // &lt;------ changed result = longest(string1.as_str(), string2); } println!(&quot;The longest string is {}&quot;, result); } </code></pre>
[ { "answer_id": 74335093, "author": "Mikdore", "author_id": 8309536, "author_profile": "https://Stackoverflow.com/users/8309536", "pm_score": 0, "selected": false, "text": "int T[]" }, { "answer_id": 74335187, "author": "John Bode", "author_id": 134554, "author_profile": "https://Stackoverflow.com/users/134554", "pm_score": 1, "selected": false, "text": "sizeof" }, { "answer_id": 74335272, "author": "tremon", "author_id": 10918915, "author_profile": "https://Stackoverflow.com/users/10918915", "pm_score": 0, "selected": false, "text": "int* a" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8817903/" ]
74,335,047
<p>I am working with a very large dataset, and am looping over chunks of data to add elements to a class. There are many duplicated values in my data, meaning that I am creating a class instance for the same data many times. From some of the testing I've done, it seems that actually creating the instance of the class is the most expensive part of the operation so I want to minimise this as much as possible.</p> <p>My question is: <strong>What is the least expensive (time) way of avoiding creating duplicate class instances? Ideally I would like to create a class instance once only and all duplicates reference the same instance</strong>. I can't remove duplicates from my data at the outset, but I want to make sure I minimise any costly procedures.</p> <p>Here is a toy example that I hope illustrates my problem. The commented out section shows my thinking for how I might be able to shave off time.</p> <p>In this example <code>Person</code> contains 2 methods that call <code>sleep</code> to demonstrate a time cost to creating an instance. In my example, the code will run in 4.22 seconds (<code>(SLEEP_1 * 6) + (SLEEP_2 * 6)</code>). Seeing as I have a person &quot;James&quot; present 3 times, I am looking to find a way to add this person only once, and then reference this for the 2 duplicates.</p> <p>I would then expect the code to run in ~2.8s (<code>(SLEEP_1 * 4) + (SLEEP_2 * 4)</code>)</p> <pre><code>import time from collections import defaultdict SLEEP_1 = 0.2 SLEEP_2 = 0.5 # A class `Person` has a load of methods, # meaning that creating an instance has a non-negligible time-cost over millions of calls. class Person: def __init__(self, info): self._id = info['_id'] self.name = info['name'] self.nationality = info['nationality'] self.age = info['age'] self.can_drink_in_USA = self.some_long_fun() self.can_fly_solo = self.another_costly_fun() def some_long_fun(self): time.sleep(SLEEP_1) if self.age &gt;= 21: return True return False def another_costly_fun(self): time.sleep(SLEEP_2) if self.age &gt;= 18: return True return False # Some data to iterate over # Note that &quot;James&quot; is present 3 times teams = { &quot;team1&quot;: [ {&quot;_id&quot;: &quot;foo&quot;, &quot;name&quot;: &quot;James&quot;, &quot;nationality&quot;: &quot;French&quot;, &quot;age&quot;: 32}, {&quot;_id&quot;: &quot;bar&quot;, &quot;name&quot;: &quot;Frank&quot;, &quot;nationality&quot;: &quot;American&quot;, &quot;age&quot;: 36}, {&quot;_id&quot;: &quot;foo&quot;, &quot;name&quot;: &quot;James&quot;, &quot;nationality&quot;: &quot;French&quot;, &quot;age&quot;: 32} ], &quot;team2&quot;: [ {&quot;_id&quot;: &quot;foo&quot;, &quot;name&quot;: &quot;James&quot;, &quot;nationality&quot;: &quot;French&quot;, &quot;age&quot;: 32}, {&quot;_id&quot;: &quot;baz&quot;, &quot;name&quot;: &quot;Oliver&quot;, &quot;nationality&quot;: &quot;British&quot;, &quot;age&quot;: 26}, {&quot;_id&quot;: &quot;qux&quot;, &quot;name&quot;: &quot;Josh&quot;, &quot;nationality&quot;: &quot;British&quot;, &quot;age&quot;: 42} ] } seen = defaultdict(int) team_directory = defaultdict(list) start_time = time.time() for team in teams: for i, person in enumerate(teams[team]): if person['_id'] in seen: print(f&quot;{person['name']} [_id: {person['_id']}] already exists in Person class&quot;) # p = getattr(Person, '_id') == person['_id'] # team_directory[team].append(p) # continue print(f&quot;Person {i + 1} = {person['name']}&quot;) p = Person(info=person) team_directory[team].append(p) seen[person['_id']] += 1 finish_time = time.time() - start_time expected_finish = round((SLEEP_1 * 6) + (SLEEP_2 * 6), 2) print(f&quot;Built a teams directory in {round(finish_time, 2)}s [expect: {expected_finish}s]&quot;) # Loop over the results to check - I want each team to have 3 people # (so I can't squash duplicates from the outset for t in team_directory: roster = &quot; &quot;.join([p.name for p in team_directory[t]]) print(f&quot;Team {team} contains these people: {roster}&quot;) </code></pre>
[ { "answer_id": 74336529, "author": "OneCricketeer", "author_id": 2308683, "author_profile": "https://Stackoverflow.com/users/2308683", "pm_score": 0, "selected": false, "text": "def age_check(age):\n def f(over):\n return age >= over\n return f\n\nage_check(self.age)(18)\nage_check(self.age)(21)\n" }, { "answer_id": 74339484, "author": "Michael Butscher", "author_id": 987358, "author_profile": "https://Stackoverflow.com/users/987358", "pm_score": 2, "selected": true, "text": "seen" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2105156/" ]
74,335,052
<p>I'm relatively new to C/C++, and I'm learning about nested for loops and arrays. The question I'm asking is referring to the code below</p> <pre><code>int main(){ int N, M; bool secret = false; scanf(&quot;%d %d&quot;, &amp;N, &amp;M); //N is the amount of weapon &quot;The Hero&quot; has, while M is the amount for &quot;The Villain&quot; int X[N]; // To store the value of &quot;Damage&quot; each weapon has int Y[M]; for(int i = 0; i &lt; N; i++){ scanf(&quot;%d&quot;, &amp;X[i]); // Inputting the value to each weapon } for(int i = 0; i &lt; M; i++){ scanf(&quot;%d&quot;, &amp;Y[i]); } for(int i = 0; i &lt; N; i++){ for(int j = 0; j &lt; M; j++){ if(X[i] &gt; Y[j]){ //To check if atleast one weapon of &quot;The Hero&quot; can beat all the weapon of &quot;The Villain&quot; (What i was trying to do anyways) secret = true; } else{ secret = false; } } } if(secret == true){ printf(&quot;The dark secret was true\n&quot;); } else{ printf(&quot;Secret debunked\n&quot;); } return 0; } </code></pre> <p>I am trying to check if at least one weapon in the X array has a greater value than all of the ones is the Y array(not the sum of Y array). The problem I'm running into is that if I put a the last value in the X array as lower than any of the value in the Y array, it will always return false, and print out out the else statement, because the loop will always got to the last iteration and use that as the statement for the condition.</p> <p>I was expecting the outcome to be</p> <pre><code>3 5 // The amount of weapons the Hero and Villain has 4 9 2 // The value of each weapon for the Hero 8 4 6 8 3 // The value of each weapon for the Villain The dark secret was true // The expected output </code></pre> <p>instead, I got</p> <pre><code>Secret Debunked </code></pre> <p>because of the looping to last value in the X array. I tried to stop the if statements using break;, using it in the loop it self, both didn't work as expected. I'm thinking of arranging it first then using specific indexes to compare it. But before trying that I figured to ask here first.</p>
[ { "answer_id": 74336529, "author": "OneCricketeer", "author_id": 2308683, "author_profile": "https://Stackoverflow.com/users/2308683", "pm_score": 0, "selected": false, "text": "def age_check(age):\n def f(over):\n return age >= over\n return f\n\nage_check(self.age)(18)\nage_check(self.age)(21)\n" }, { "answer_id": 74339484, "author": "Michael Butscher", "author_id": 987358, "author_profile": "https://Stackoverflow.com/users/987358", "pm_score": 2, "selected": true, "text": "seen" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20360920/" ]
74,335,053
<p>I have a pandas dataframe:</p> <pre><code>#CHROM POS INFO chr1 111 AC=0;AN=33 chr1 111 AC=0;AN=100 chr1 111 AC=110;AN=51 chr2 737 AC=99;AN=10003 chr2 888 AC=100;AN=1636 </code></pre> <p>I want to create a new column which is based on the numbers in <strong>INFO</strong> column. That is I want the numbers specified as <strong>AC=N</strong>. So the output should look like</p> <pre><code>#CHROM POS INFO number chr1 111 AC=0;AN=33. 0 chr1 111 AC=0;AN=100 0 chr1 111 AC=110;AN=51 110 chr2 737 AC=99;AN=10003. 99 chr2 888 AC=100;AN=1636. 100 </code></pre> <p>Insights will be appreciated.</p>
[ { "answer_id": 74336529, "author": "OneCricketeer", "author_id": 2308683, "author_profile": "https://Stackoverflow.com/users/2308683", "pm_score": 0, "selected": false, "text": "def age_check(age):\n def f(over):\n return age >= over\n return f\n\nage_check(self.age)(18)\nage_check(self.age)(21)\n" }, { "answer_id": 74339484, "author": "Michael Butscher", "author_id": 987358, "author_profile": "https://Stackoverflow.com/users/987358", "pm_score": 2, "selected": true, "text": "seen" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12113684/" ]
74,335,069
<p><a href="https://docs.oracle.com/javase/specs/jls/se17/html/jls-17.html#jls-17.4.5" rel="nofollow noreferrer">JLS states this</a>:</p> <blockquote> <p>A set of synchronization edges, <em>S</em>, is <em>sufficient</em> if it is the minimal set such that the transitive closure of S with the program order determines all of the happens-before edges in the execution. This set is unique.</p> </blockquote> <p>Why is the sufficient set unique?</p> <p>How can we determine which synchronization edges are in the sufficient set and which aren't?</p>
[ { "answer_id": 74337343, "author": "cata", "author_id": 20431343, "author_profile": "https://Stackoverflow.com/users/20431343", "pm_score": 2, "selected": true, "text": "happens-before" }, { "answer_id": 74337715, "author": "pveentjer", "author_id": 2245707, "author_profile": "https://Stackoverflow.com/users/2245707", "pm_score": 2, "selected": false, "text": "I don't care. I asked the question because I'm curious about possible optimizations: \"the minimal set\" means some synchronizes-with edges are not used and thus can be optimized-out." } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20431343/" ]
74,335,071
<p>I have been trying to add one of my dictionaries into another one. I did do that using the code below, but when I update one of the values, all off the values with the same name is also updated. How can I fix it?</p> <p>Here is my code:</p> <pre><code> test_dict = {'count': 0} D = {'emp1': {'name': test_dict, 'job': 'Mgr'}, 'emp2': {'name': test_dict, 'job': 'Dev'}, 'emp3': {'name': test_dict, 'job': 'Dev'}} D['emp1']['name']['count'] += 1 print(D) </code></pre> <p>The output is this</p> <p>{'emp1': {'name': {'count': 1}, 'job': 'Mgr'}, 'emp2': {'name': {'count': 1}, 'job': 'Dev'}, 'emp3': {'name': {'count': 1}, 'job': 'Dev'}}</p> <p>when I should have this. How can I fix it?</p> <p>{'emp1': {'name': {'count': 1}, 'job': 'Mgr'}, 'emp2': {'name': {'count': 0}, 'job': 'Dev'}, 'emp3': {'name': {'count': 0}, 'job': 'Dev'}}</p>
[ { "answer_id": 74335124, "author": "0x0fba", "author_id": 20339407, "author_profile": "https://Stackoverflow.com/users/20339407", "pm_score": 2, "selected": false, "text": "D" }, { "answer_id": 74335142, "author": "Will", "author_id": 12829151, "author_profile": "https://Stackoverflow.com/users/12829151", "pm_score": 2, "selected": false, "text": "copy()" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16254106/" ]
74,335,073
<p>It comes to a surprise to me when I am trying to implement some compound actions with a BlockingQueue based producer/consumer pattern, which makes me think I most likely have missed something obvious.</p> <hr /> <h1>1. In short</h1> <p>I need</p> <ul> <li>my consumer to make sequence actions in form of ‘take obj from the queue + do more consumer operations on the obj’ atomic and</li> <li>My producer to make sequence actions in form of ‘offer obj onto the queue + do more producer operations on the obj’ atomic and</li> <li>The two above atomic sequences synchronized on the same obj, obviously</li> </ul> <p>Without such atomicity, problem may occur, see '<strong>PROBLEM!!</strong>' as an example in the comment in code for the producer in the following section 2.</p> <p>But I can’t simply put a synchronized block around the call to take() and its associated consumer operations as <strong>when the queue is empty</strong>, this consumer will be stuck there <strong>FOREVER</strong> since it will still possess the sync lock while it waits on the producer to fill the queue with an obj, and that sync lock possession of consumer will in turn stop the producer from entering corresponding critical region to do any 'producing'.</p> <h1>2. Specially, simplified example code are as the following:</h1> <h1></h1> <p>Common code known to the producer and consumer classes:</p> <pre><code>Queue&lt;QObj&gt; nbq = new ConcurrentLinkedQueue(); BlockingQueue&lt;QObj&gt; bq = new LinkedBlockingQueue&lt;&gt;(); List&lt;String&gt; idList = new LinkedList&lt;&gt;(); Object lockObj = idList; int Idx = 1; public static class QObj { public String id; public String content; public QObj(String id, String content) { this.id = id; this.content = content; } } </code></pre> <p>Main logic in producer class:</p> <pre><code> public void produceBlocking() { QObj o = new QObj(String.valueOf(Idx), &quot;Content_&quot; + Idx++); // synchronized(lockObj) { // no point to include Queue.offer(...) call in a synchronized block as we // won't be able to use synchronized() in corresponding consumer anyway // for the reason described above bq.offer(o); synchronized (lockObj) { // PROBLEM!! by now, 'o' could have been 'consumed' already // hence we shouldn't do the following operations: // do the associated part of compound action of 'producer' idList.add(o.id); // do some more operation as part of this compound action ... } // } } </code></pre> <p>Main logic in consumer class:</p> <pre><code> public void consumeBlocking() { while (true) { try { // synchronized (lockObj) { // can't simply put synchronized() here to make the following compound action atomic // - when the queue is empty, this consumer will be stuck here forever since it still possesses // the lockObj, which stops the producer from entering the critical region to do any 'producing' QObj o = bq.take(); synchronized (lockObj) { // do the associated part of compound action of 'consumer' idList.remove(o.id); // do some more operation as part of this compound action ... } // } } catch (InterruptedException e) { e.printStackTrace(); } } } </code></pre> <h1>3. Why has this not been a common problem?</h1> <h1></h1> <p>I feel that this must have been a common occurring problem when people are using BlockingQueue, and the fact that I couldn’t really locate anything addressing directly to a similar problem affirms my belief that I might have got something fundamentally wrong.</p> <p>Can someone give some hint about a direct solution or point out where I thought wrong about this problem?</p> <h1>4. Alternative Ideas</h1> <p>I did think of a few ideas as alternatives, but I feel <strong>none of them is addressing this issue directly and all have some drawbacks</strong> (as highlighted '<strong>DRAWBACK!!</strong>' in the comments in the code)</p> <p>4.1 - Do a check using Queue.contains() before continue</p> <pre><code>public void produceBlockingWithCheck() { QObj o = new QObj(String.valueOf(Idx), &quot;Content_&quot; + Idx++); bq.offer(o); synchronized (lockObj) { // First, Check if the obj could have already been consumed // DRAWBACK!!: this could be very costly, e.g. // when 'bq' is a LinkedBlockingQueue, and contains(...) always triggers // a sequential traversal, the Queue itself can be very large if (bq.contains(o)) { // do the associated part of compound action of 'producer' idList.add(o.id); // do some more operation as part of this compound action ... } } } </code></pre> <p>4.2 - Adjust the order of ops on the producer, move the Queue.offer() call to the end</p> <pre><code>public void produceBlockingOrderAdjusted() { QObj o = new QObj(String.valueOf(Idx), &quot;Content_&quot; + Idx++); // do the associated part of compound action of 'producer', only before // calling BlockingQueue.offer(...) // DRAWBACK!!: even this may work for this simple case, such order adjustment // won't not be logically possible for all cases, will it? synchronized (lockObj) { idList.add(o.id); // do some more operation as part of this compound action ... } bq.offer(o); } </code></pre> <p>4.3 - Use non-blocking queues instead.</p> <pre><code> public void produceNonBlocking() { QObj o = new QObj(String.valueOf(Idx), &quot;Content_&quot; + Idx++); synchronized(lockObj) { nbq.offer(o); // do the associated part of compound action of 'producer' idList.add(o.id); // do some more operation as part of this compound action ... } } public void consumeNonBlocking() { while (true) { synchronized (lockObj) { // kind of doing our own blocking. QObj o = nbq.poll(); if (o != null) { // do the associated part of compound action of 'consumer' idList.add(o.id); // do some more operation as part of this compound action ... } // DRAWBACK!!: if the 'producers' don't produce faster than the 'consumers' consuming, // this 'miss' could be happening too often and get costly } } } </code></pre>
[ { "answer_id": 74335333, "author": "cata", "author_id": 20431343, "author_profile": "https://Stackoverflow.com/users/20431343", "pm_score": -1, "selected": false, "text": "wait" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18362708/" ]
74,335,074
<p>I developed a project with the DDD method to manage holidays. I have 2 value objects with the names of HolidayTitle and HolidayDate. Now I want to filter with Contains in the Query Repository but I can't.</p> <p>My code in the repository is as follows:</p> <pre><code>public async Task&lt;ListResponse&lt;IList&lt;GetHolidaysByDatesDto&gt;&gt;&gt; GetHolidays(GetHolidaysQuery param) { var query = _repository.AsQueryable(); if (param.Date.HasValue) query = query.Where(x =&gt; x.Date == param.Date); if (!string.IsNullOrEmpty(param.Title)) query = query.Where(x =&gt; x.Title.Contains(param.Title)); var pagingData = await query.GetPagingData(param); query = query.SetPaging(param); var holidays = await query.ToListAsync(); var mappedResult = _mapper.Map&lt;IList&lt;GetHolidaysByDatesDto&gt;&gt;(holidays); var finalResult = new ListResponse&lt;IList&lt;GetHolidaysByDatesDto&gt;&gt;() { PageCount = pagingData.PageCount, PageNumber = pagingData.PageNumber, RowCount = pagingData.RowCount, Result = mappedResult }; return finalResult; } </code></pre> <p>And the codes of the HolidayTitle are as follows</p> <pre><code>public class HolidayTitle : BaseValueObject&lt;HolidayTitle&gt; { public static readonly int minLength = 5; public static readonly int maxLength = 300; public string Value { get; private set; } private HolidayTitle(string value) { if (value is null) throw new NullOrEmptyArgumentException(HolidayErrors.HolidayTitleIsNull); value = value.Trim(); if (value == string.Empty) throw new NullOrEmptyArgumentException(HolidayErrors.HolidayTitleIsEmpty); if (value.Length &gt; maxLength || value.Length &lt; minLength) throw new RangeLengthArgumentException(HolidayErrors.HolidayTitleLengthIsNotInRangeLength, minLength.ToString(), maxLength.ToString()); Value = value; } public bool Contains(string str) { return Value.Contains(str); } public override bool IsEqual(HolidayTitle otherObject) { return Value == otherObject.Value; } public override int ObjectGetHashCode() { return Value.GetHashCode(); } public static implicit operator string(HolidayTitle value) { return value.Value; } public static HolidayTitle GetInstance(string value) { return new(value); } } </code></pre> <p>I get this error</p> <pre><code>System.InvalidOperationException: 'The LINQ expression 'DbSet&lt;Holiday&gt;() .Where(h =&gt; !(h.IsDeleted)) .Where(h =&gt; h.Title.Contains(__param_Title_0))' could not be translated. Additional information: Translation of method 'Core.Domain.Holidays.ValueObjects.HolidayTitle.Contains' failed. If this method can be mapped to your custom function, see https://go.microsoft.com/fwlink/?linkid=2132413 for more information. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.' </code></pre>
[ { "answer_id": 74335333, "author": "cata", "author_id": 20431343, "author_profile": "https://Stackoverflow.com/users/20431343", "pm_score": -1, "selected": false, "text": "wait" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11882732/" ]
74,335,091
<p>I want to run my python script through the shell, passing variable <code>a</code>.</p> <p>Here is my code:</p> <pre><code>else a=0 osascript -e 'tell application &quot;Terminal&quot; to activate' \ -e 'tell application &quot;System Events&quot; to keystroke &quot;n&quot; using {command down}' \ -e 'tell application &quot;Terminal&quot; to do script &quot;python /Users/kacperXXX/instagram_bot.py \&quot;$a\&quot;&quot; in front window' sleep 5 exit fi </code></pre> <p>My script just prints its arguments. When I run it I got empty list only with file path.</p> <p><strong>Output</strong></p> <pre><code>['/Users/kacperleczynski/Desktop/instagram_bot.py', ''] </code></pre> <p>Thanks for advice.</p>
[ { "answer_id": 74335333, "author": "cata", "author_id": 20431343, "author_profile": "https://Stackoverflow.com/users/20431343", "pm_score": -1, "selected": false, "text": "wait" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17645965/" ]
74,335,096
<p>I'm learning React framework and I'm stuck on a question. I have this array which contains pieces of information about some templates I built.</p> <pre><code>const template = \[ { title: 'firstPortfolio', url: 'first_portfolio', id: 1, img: require('../templates-images/firstPortfolio.png') }, { title: 'leadershipEvent', url: 'leadership_event', id: 2, img: require('../templates-images/leadership-event.png') }, { title: 'digimedia', url: 'digimedia', id: 3, img: require('../templates-images/digimedia.png') }, { title: 'arsha', url: 'arsha', id: 4, img: require('../templates-images/arsha.png') } \]; export default template; </code></pre> <p>I've imported it in App.js (I know that the code makes a little pity and does not reflect the logic on which React is based, I'm new):</p> <pre><code> import './App.css'; import { useEffect, useState } from 'react'; import { Nav } from 'react-bootstrap'; import Container from 'react-bootstrap/Container'; import Navbar from 'react-bootstrap/Navbar'; import HomePage from './pages/Homepage'; import Portfolio from './pages/Portfolio'; import Template from './pages/Template'; import template from './assets/js/templates'; import { Routes, Route, Link } from 'react-router-dom'; function App() { const [menuBtn, setMenuBtn] = useState(true); useEffect(() =&gt; { const menuBtn = document.getElementById('menuBtn'); const lineOne = document.getElementById('lineOne'); const lineTwo = document.getElementById('lineTwo'); const lineThree = document.getElementById('lineThree'); const lineOneAnimation = [ { width: '30px', top: '18px', transform: 'rotate(0deg)' }, { width: '30px', top: '26px', transform: 'rotate(45deg)' } ]; const lineTwoAnimation = [ { width: '20px', top: '26px' }, { width: '0' } ]; const lineThreeAnimation = [ { width: '10px', top: '34px', transform: 'rotate(0deg)' }, { width: '30px', top: '26px', transform: 'rotate(-45deg)' } ]; const menuAnimationTiming = { duration: 200, iterations: 1, fill: 'both' }; menuBtn.addEventListener('click', () =&gt; { if (menuBtn.classList.contains('collapsed')) { setTimeout(function () { lineOne.animate(lineOneAnimation, menuAnimationTiming); }, 200); lineTwo.animate(lineTwoAnimation, menuAnimationTiming); setTimeout(function () { lineThree.animate(lineThreeAnimation, menuAnimationTiming); }, 200); } else { lineOne.animate(lineOneAnimation, menuAnimationTiming).reverse(); lineTwo.animate(lineTwoAnimation, menuAnimationTiming).reverse(); lineThree.animate(lineThreeAnimation, menuAnimationTiming).reverse(); } }); }) const templateRoutePath = function () { for (let i = 0; i &lt; template.length; i++) { return `/portfolio/${template[i].title}`; } } const pathGit = function () { for (let i = 0; i &lt; template.length; i++) { return `https://andrea-mazza.github.io/template/${template[i].url}/`; } } // const templateKey = function () { // for (let i = 0; i &lt; template.length; i++) { // return `${template[i].id}`; // } // } return ( &lt;div className=&quot;App&quot;&gt; &lt;header className='container-fluid'&gt; &lt;Navbar expand=&quot;lg&quot;&gt; &lt;Container fluid&gt; &lt;Navbar.Brand href=&quot;/&quot;&gt;FreeAttitude&lt;/Navbar.Brand&gt; &lt;Navbar.Toggle onClick={setMenuBtn} aria-controls=&quot;basic-navbar-nav&quot; id=&quot;menuBtn&quot;&gt; &lt;span id=&quot;lineOne&quot; className=&quot;line&quot;&gt;&lt;/span&gt; &lt;span id=&quot;lineTwo&quot; className=&quot;line&quot;&gt;&lt;/span&gt; &lt;span id=&quot;lineThree&quot; className=&quot;line&quot;&gt;&lt;/span&gt; &lt;/Navbar.Toggle&gt; &lt;Navbar.Collapse id=&quot;basic-navbbar-nav&quot;&gt; &lt;Nav className=&quot;menu-items&quot;&gt; &lt;Link to=&quot;/&quot; className=&quot;nav-item&quot;&gt;Home&lt;/Link&gt; &lt;Link to=&quot;/portfolio&quot; className=&quot;nav-item&quot;&gt;Portfolio&lt;/Link&gt; &lt;/Nav&gt; &lt;/Navbar.Collapse&gt; &lt;/Container&gt; &lt;/Navbar&gt; &lt;/header&gt; &lt;Routes&gt; &lt;Route path=&quot;/&quot; element={&lt;HomePage /&gt;} /&gt; &lt;Route path=&quot;/portfolio&quot; element={&lt;Portfolio /&gt;} /&gt; &lt;Route path={`/portfolio/:templateTitle`} element={&lt;Template gitPath={pathGit.apply()} /&gt;} /&gt; &lt;/Routes&gt; &lt;/div&gt; ); } export default App; </code></pre> <p>The Route Component in question is the last one, which render the Template component. The Template Component's code is this:</p> <pre><code>import template from &quot;../assets/js/templates&quot;; function Template(props) { const title = function () { for (let i = 0; i &lt; template.length; i++) { return `${template[i].title}` } } return ( &lt;iframe src={props.gitPath} title={title.apply()} /&gt; ); } export default Template; </code></pre> <p><strong>What am I trying to do?</strong> I'd like to show the Template Component whit the right gitPath props, according to the path of the Route Component.</p> <p><strong>What is the problem?</strong> This work but only the first &lt;iframe&gt; is shown, for all the Route that starts with '/portfolio/'. For example: If I type: '/portfolio/firstPortfolio' I can see an iframe element that shows the template I previously built and which is stored on GitHub. However, if I type: '/portfolio/leadershipEvent/' I see again an iframe that shows firstPortfolio project instead of an iframe for the leadershipEvent project.</p> <p>I have attached some pictures for clarity:</p> <ol> <li>If I click on firstPortfolio image <a href="https://i.stack.imgur.com/oEMXk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oEMXk.png" alt="enter image description here" /></a></li> </ol> <p>I actually see the project with the correct URL: <a href="https://i.stack.imgur.com/nmtuo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nmtuo.png" alt="enter image description here" /></a></p> <ol start="2"> <li>But, if i click on the leadershipEvent img: <a href="https://i.stack.imgur.com/ae0kX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ae0kX.png" alt="enter image description here" /></a></li> </ol> <p>URL is correct but the src iframe's attribute points again to the firstPortfolio github's url</p> <p><a href="https://i.stack.imgur.com/2jj97.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2jj97.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74338284, "author": "Andrea", "author_id": 17664715, "author_profile": "https://Stackoverflow.com/users/17664715", "pm_score": 1, "selected": true, "text": "<Routes>\n <Route path=\"/\" element={<HomePage />} />\n <Route path=\"/portfolio\" element={<Portfolio />} />\n {/* The JSX belove is used to dynamycally create Route Component for each template */}\n {\n template.map(element => {\n return (\n <Route path={`/portfolio/${element.title}`} key={element.id} element={<Template gitPath={`https://andrea-mazza.github.io/template/${element.url}/`} />} />\n );\n })\n }\n </Routes>\n" }, { "answer_id": 74342365, "author": "Drew Reese", "author_id": 8690857, "author_profile": "https://Stackoverflow.com/users/8690857", "pm_score": 1, "selected": false, "text": "title" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17664715/" ]
74,335,130
<p>Having the following json</p> <pre><code>[ { &quot;Value&quot;: &quot;100000000&quot;, &quot;Duration&quot;: 1 }, { &quot;Value&quot;: &quot;100000001&quot;, &quot;Duration&quot;: 2 }, { &quot;Value&quot;: &quot;100000002&quot;, &quot;Duration&quot;: 3 }, { &quot;Value&quot;: &quot;100000003&quot;, &quot;Duration&quot;: 5 }, { &quot;Value&quot;: &quot;100000004&quot;, &quot;Duration&quot;: 0 }, { &quot;Value&quot;: &quot;100000005&quot;, &quot;Duration&quot;: 8 }, { &quot;Value&quot;: &quot;100000006&quot;, &quot;Duration&quot;: 10 } ] </code></pre> <p>and the following definition</p> <pre><code>interface Duration { value: string duration: number } </code></pre> <p>I would like to have a method on Duration interface to be available in all objects</p> <pre><code>durationInSeconds():number { return duration*1000 } </code></pre> <p>The usage scenario would be:</p> <pre><code>const all = previousJsonContent const durations:Duration[] = parseAsObjects(all) // JSON.parse(all) const firstInSeconds = durations[0].durationInSeconds() </code></pre> <h1>Typescript approach</h1> <p>What is idiomatic to typescript? What is the least intrusive way? Should I use <code>assign</code>, <code>prototype</code>, <code>mixins</code>? The problem is that deserialized json is just a data container while I want to treat it as full Objects with methods assigned according to the types and ideally also deep, at fields that also should have a type.</p> <h1>Scala approach</h1> <p>In scala I would create a value class wrapper around the data without performance penalty and use some implicit magic like in <a href="https://www.baeldung.com/scala/rich-wrappers" rel="nofollow noreferrer">https://www.baeldung.com/scala/rich-wrappers</a></p>
[ { "answer_id": 74336297, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 1, "selected": false, "text": "const data = [{\"Value\":\"100000000\",\"Duration\":1},{\"Value\":\"100000001\",\"Duration\":2},{\"Value\":\"100000002\",\"Duration\":3},{\"Value\":\"100000003\",\"Duration\":5},{\"Value\":\"100000004\",\"Duration\":0},{\"Value\":\"100000005\",\"Duration\":8},{\"Value\":\"100000006\",\"Duration\":10}];\n\nclass Duration {\n /* private data: { Value: string; Duration: number } */\n\n constructor(data/* : { Value: string; Duration: number */) {\n this.data = data;\n }\n \n durationInSeconds() {\n return this.data.Duration * 1000;\n }\n}\n\nconst parsed = data.map((datum) => new Duration(datum));\n\nconsole.log(parsed[0].durationInSeconds());" }, { "answer_id": 74587052, "author": "shaochuancs", "author_id": 707451, "author_profile": "https://Stackoverflow.com/users/707451", "pm_score": 0, "selected": false, "text": "interface" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/99248/" ]
74,335,162
<p>I have a file with a function and a file that calls the functions. Finally, I run .bat I don't know how I can add an argument when calling the .bat file. So that the argument was added to the function as below.</p> <p>file_with_func.py</p> <pre><code>def some_func(val): print(val) </code></pre> <p>run_bat.py</p> <pre><code>from bin.file_with_func import some_func some_func(val) </code></pre> <p>myBat.bat</p> <pre><code>set basePath=%cd% cd %~dp0 cd .. python manage.py shell &lt; bin/run_bat.py cd %basePath% </code></pre> <p>Now I would like to run .bat like this.</p> <pre><code>\bin&gt;.\myBat.bat &quot;mystring&quot; </code></pre> <p><strong>Or after starting, get options to choose from, e.g.</strong></p> <pre><code>\bin&gt;.\myBat.bat &gt;&gt;&gt; Choose 1 or 2 &gt;&gt;&gt; 1 </code></pre> <p><strong>And then the function returns</strong> <code>&quot;You chose 1&quot;</code></p>
[ { "answer_id": 74336297, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 1, "selected": false, "text": "const data = [{\"Value\":\"100000000\",\"Duration\":1},{\"Value\":\"100000001\",\"Duration\":2},{\"Value\":\"100000002\",\"Duration\":3},{\"Value\":\"100000003\",\"Duration\":5},{\"Value\":\"100000004\",\"Duration\":0},{\"Value\":\"100000005\",\"Duration\":8},{\"Value\":\"100000006\",\"Duration\":10}];\n\nclass Duration {\n /* private data: { Value: string; Duration: number } */\n\n constructor(data/* : { Value: string; Duration: number */) {\n this.data = data;\n }\n \n durationInSeconds() {\n return this.data.Duration * 1000;\n }\n}\n\nconst parsed = data.map((datum) => new Duration(datum));\n\nconsole.log(parsed[0].durationInSeconds());" }, { "answer_id": 74587052, "author": "shaochuancs", "author_id": 707451, "author_profile": "https://Stackoverflow.com/users/707451", "pm_score": 0, "selected": false, "text": "interface" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17356459/" ]
74,335,164
<p>I have mysql DB with important financial data, currently the data is stored as float type and I get incorrect data due to float rounding, I want to store it as DECIMAL.</p> <p>What is the safe way to convert the data in the DB without change existing data? or any another idea to solve that issue?</p> <p><strong>EDIT:</strong> Does converting from FLOAT to VARCHAR and than from VARCHAR to DECIMAL is a safe way?</p> <p>Thanks in advance!</p>
[ { "answer_id": 74336297, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 1, "selected": false, "text": "const data = [{\"Value\":\"100000000\",\"Duration\":1},{\"Value\":\"100000001\",\"Duration\":2},{\"Value\":\"100000002\",\"Duration\":3},{\"Value\":\"100000003\",\"Duration\":5},{\"Value\":\"100000004\",\"Duration\":0},{\"Value\":\"100000005\",\"Duration\":8},{\"Value\":\"100000006\",\"Duration\":10}];\n\nclass Duration {\n /* private data: { Value: string; Duration: number } */\n\n constructor(data/* : { Value: string; Duration: number */) {\n this.data = data;\n }\n \n durationInSeconds() {\n return this.data.Duration * 1000;\n }\n}\n\nconst parsed = data.map((datum) => new Duration(datum));\n\nconsole.log(parsed[0].durationInSeconds());" }, { "answer_id": 74587052, "author": "shaochuancs", "author_id": 707451, "author_profile": "https://Stackoverflow.com/users/707451", "pm_score": 0, "selected": false, "text": "interface" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13029900/" ]
74,335,169
<p>I am trying to generate lists of years from N year to the current year of the user. How can I automatically generate a list of years.</p>
[ { "answer_id": 74335234, "author": "Mike4544", "author_id": 20429017, "author_profile": "https://Stackoverflow.com/users/20429017", "pm_score": 1, "selected": true, "text": "DateTime.now().year" }, { "answer_id": 74335278, "author": "Masum Billah Sanjid", "author_id": 12083662, "author_profile": "https://Stackoverflow.com/users/12083662", "pm_score": 1, "selected": false, "text": " int currentYear = DateTime.now().year;\n int startingYear = 2000;\n List yearList = List.generate((currentYear-startingYear)+1, (index) => startingYear+index);\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18707541/" ]
74,335,175
<p>I wanna move a file after the grep command but as I execute my script, I noticed that there are no results coming back. regardless of that, I want to move the file/s to another directory.</p> <p>this is what I've been doing:</p> <pre class="lang-bash prettyprint-override"><code>for file in *.sup do grep -iq &quot;$file&quot; '' /desktop/list/varlogs.txt || mv &quot;$file&quot; /desktop/first; done </code></pre> <p>but I am getting this error:</p> <pre class="lang-none prettyprint-override"><code>mv: 0653-401 Cannot rename first /desktop/first/first </code></pre> <p>suggestions would be very helpful</p>
[ { "answer_id": 74338736, "author": "TheAnalogyGuy", "author_id": 6317990, "author_profile": "https://Stackoverflow.com/users/6317990", "pm_score": 1, "selected": false, "text": "...\"$file\" '' /desktop..." }, { "answer_id": 74416355, "author": "Dudi Boy", "author_id": 6266192, "author_profile": "https://Stackoverflow.com/users/6266192", "pm_score": 0, "selected": false, "text": "/desktop/list/varlogs.txt" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20431360/" ]
74,335,200
<pre><code>React native android getting error /Users/jeyabaskar/.gradle/caches/transforms-2/files-2.1/03b7bffa42f2fb741f03fe69f60fdec1/jetified-kotlin-stdlib-jdk8-1.6.10.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.1. </code></pre> <p>I'm using macbook m1. while run the android app i'm getting this error.</p>
[ { "answer_id": 74335372, "author": "Layeb Mazen", "author_id": 20421395, "author_profile": "https://Stackoverflow.com/users/20421395", "pm_score": 0, "selected": false, "text": "android/build.gradle" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11812621/" ]
74,335,205
<p>I'm trying to create a click event be able to delete an item on my list, but when I click it I get &quot;TypeError: Cannot read properties of undefined (reading 'name')&quot;.</p> <p>and I'm pretty sure it's something to do bind 'this' somewhere, but I've tried a lot of places and it doesn't work. <a href="https://i.stack.imgur.com/y5jlc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y5jlc.png" alt="enter image description here" /></a></p> <p>here is my code:</p> <pre><code>import React from &quot;react&quot;; import { useRecoilValue } from &quot;recoil&quot;; import { userProfile } from &quot;../recoil&quot;; import ProfileName from &quot;./components/profileName&quot;; const DetailProfil = () =&gt; { const profile = useRecoilValue(userProfile); return ( &lt;div&gt; &lt;ProfileName profilePicture={profile?.profilePicture} fullName={profile?.fullname} roleDetails={profile?.details.name} /&gt; &lt;/div&gt; ); }; export default DetailProfil; </code></pre>
[ { "answer_id": 74335212, "author": "Sachila Ranawaka", "author_id": 6428638, "author_profile": "https://Stackoverflow.com/users/6428638", "pm_score": 2, "selected": true, "text": "roleDetails={profile?.details?.name}\n" }, { "answer_id": 74335260, "author": "Layeb Mazen", "author_id": 20421395, "author_profile": "https://Stackoverflow.com/users/20421395", "pm_score": 0, "selected": false, "text": "roleDetails={profile?.details?.name ?? 'YOUR_DEFAULT_ROLE_HERE'}\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19592889/" ]
74,335,237
<p>I have a csv file with 100 records. I want to write the first 50 records in a new csv file i.e 'newFile.csv' in the first iteration. In the second iteration, I want to write the next 50 records in the 'newFile.csv' file after reading the next 50 records from the original csv file.</p> <p>I am able to perform the first Iteration but unable to perform the second iteration with the expected values as the next 50 rows that has to be written in the csv file. Can someone please help me out in this?? Thank you</p> <p>Here is the code</p> <pre><code>import pandas as pd oldData = pd.read_csv('oldFile.csv') # Has 100 rows for i in range(2): newData = pd.read_csv('oldFile.csv', nrows=50) # Has 50 rows newCsv = newData.to_csv('newFile.csv', index=False) newData = newData.iloc[50:] # Removes those 50 rows </code></pre>
[ { "answer_id": 74335212, "author": "Sachila Ranawaka", "author_id": 6428638, "author_profile": "https://Stackoverflow.com/users/6428638", "pm_score": 2, "selected": true, "text": "roleDetails={profile?.details?.name}\n" }, { "answer_id": 74335260, "author": "Layeb Mazen", "author_id": 20421395, "author_profile": "https://Stackoverflow.com/users/20421395", "pm_score": 0, "selected": false, "text": "roleDetails={profile?.details?.name ?? 'YOUR_DEFAULT_ROLE_HERE'}\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20271284/" ]
74,335,247
<p>I can download the Google Chrome installer easily as follows:</p> <pre><code>Invoke-WebRequest &quot;http://dl.google.com/chrome/install/latest/chrome_installer.exe&quot; -OutFile &quot;$env:Temp\chrome_installer.exe&quot; </code></pre> <p>However, for Opera, I want specifically the latest 64-bit version. On the download page at <code>https://www.opera.com/download</code> there is a handy link to that:</p> <pre><code>https://download.opera.com/download/get/?partner=www&amp;opsys=Windows&amp;arch=x64 </code></pre> <p><a href="https://i.stack.imgur.com/ZjixX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZjixX.png" alt="enter image description here" /></a></p> <p>When I click on the &quot;64 bit&quot; link, it automatically starts the download of the latest executable, but using <code>Invoke-WebRequest</code> on that url does not download the file:</p> <pre><code>Invoke-WebRequest &quot;https://download.opera.com/download/get/?partner=www&amp;opsys=Windows&amp;arch=x64&quot; -OutFile &quot;$env:Temp\opera_installer.exe&quot; </code></pre> <p>How can I manipulate a url like this to:</p> <ol> <li>Download the file as if I clicked on the link on the download page?</li> <li>Get the name of the file that is downloaded (as I see that the full file version is in the file downloaded)?</li> <li>Redirect that download to a destination of my choosing?</li> </ol>
[ { "answer_id": 74335456, "author": "Toni", "author_id": 19895159, "author_profile": "https://Stackoverflow.com/users/19895159", "pm_score": 3, "selected": true, "text": "https://get.opera.com/pub/opera/desktop/\n" }, { "answer_id": 74338812, "author": "mklement0", "author_id": 45375, "author_profile": "https://Stackoverflow.com/users/45375", "pm_score": 1, "selected": false, "text": "Invoke-WebRequest" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/524587/" ]
74,335,259
<p>When I use snakeyaml to convert the yaml file into a class, the List object cannot be converted correctly.</p> <p>The following can work</p> <pre><code>public class UserYaml { private Integer test1; private String test2; private Test3 test3; // private List&lt;Test&gt; test; } </code></pre> <pre><code>test1: 123 test2: &quot;wqre&quot; test3: testt1: 1 testt2: &quot;asd&quot; #test4: # - test: # a: string # b: 3 # - test: # a: integer # b: 4 </code></pre>
[ { "answer_id": 74335456, "author": "Toni", "author_id": 19895159, "author_profile": "https://Stackoverflow.com/users/19895159", "pm_score": 3, "selected": true, "text": "https://get.opera.com/pub/opera/desktop/\n" }, { "answer_id": 74338812, "author": "mklement0", "author_id": 45375, "author_profile": "https://Stackoverflow.com/users/45375", "pm_score": 1, "selected": false, "text": "Invoke-WebRequest" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20375340/" ]
74,335,283
<p>I am trying to get the 0000's to left of the conversion but I have a bit of trouble.</p> <p>For example if I ask for <em>float_number</em>:<code>5</code></p> <p>--&gt; I get <code>101</code></p> <p>--&gt; but Correct Answer is <code>01000000101000000000000000000000</code></p> <pre><code>#include &lt;stdio.h&gt; union intFloat { int i; float f; }; unsigned show_bits(unsigned input) { int checker = input; int i,counter; int size = (sizeof(input)*8)-1; char *buffer = (char*)malloc(size+2); for(i=size,counter=0; i&gt;=0; i--,counter++) { if ( checker == 0) return 0; if ( checker == 1 ) return 1; return (input % 2) + 10 * show_bits(input / 2); } } int main() { union intFloat data; printf(&quot;Enter an int for encoding: &quot;); scanf(&quot;%d&quot;, &amp;data.i); printf(&quot; Number = %d &quot;,show_bits(data.i)); printf(&quot;\n&quot;); printf(&quot;Enter a float for encoding: &quot;); scanf(&quot;%f&quot;, &amp;data.f); //call show bits printf(&quot; Number = %d &quot;,show_bits(data.f)); return 0; } </code></pre> <p>I've tried to source online answer but every code in C is differently structure. I am a novice in C but would like to get more familiar with the language.</p>
[ { "answer_id": 74335940, "author": "Mikdore", "author_id": 8309536, "author_profile": "https://Stackoverflow.com/users/8309536", "pm_score": 2, "selected": true, "text": "show_bits" }, { "answer_id": 74336036, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": -1, "selected": false, "text": "int printfloatasbin(const float x)\n{\n unsigned long long mask = 1ull << (sizeof(x) * CHAR_BIT - 1);\n unsigned long long val;\n\n memcpy(&val, &x, sizeof(x));\n while(mask)\n {\n printf(\"%d\",!!(val & mask));\n mask >>= 1;\n }\n}\n\nint main(void)\n{\n printfloatasbin(5.0f);\n}\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20353469/" ]
74,335,291
<p>I'm getting: &quot;TypeError: 'str' object is not callable&quot; when I execute this code:</p> <pre><code>iframe=driver.find_element(By.XPATH(&quot;//iframe[contains(@src,'https://pianomarvel.com/uploads/editSlicings/85810')]&quot;)); </code></pre> <p>Why?</p> <p>What is the correct syntax?</p> <p>Thanks</p> <p>I tried</p> <pre><code>iframe=driver.find_element(By.XPATH(&quot;//iframe[contains(@src,'https://pianomarvel.com/uploads/editSlicings/85810')]&quot;)); </code></pre> <p>I was expecting it to return an iframe, but instead it returned an error.</p> <p>I'm trying to identify an iframe. I have two iframes they are both the same class. They have differing src, so I wanted to identify them that way</p>
[ { "answer_id": 74335940, "author": "Mikdore", "author_id": 8309536, "author_profile": "https://Stackoverflow.com/users/8309536", "pm_score": 2, "selected": true, "text": "show_bits" }, { "answer_id": 74336036, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": -1, "selected": false, "text": "int printfloatasbin(const float x)\n{\n unsigned long long mask = 1ull << (sizeof(x) * CHAR_BIT - 1);\n unsigned long long val;\n\n memcpy(&val, &x, sizeof(x));\n while(mask)\n {\n printf(\"%d\",!!(val & mask));\n mask >>= 1;\n }\n}\n\nint main(void)\n{\n printfloatasbin(5.0f);\n}\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20431589/" ]
74,335,329
<p>I am trying to implement bottom nav bar just like in youtube app, with the centre add icon being expanded. Here is the image below. <a href="https://i.stack.imgur.com/KHvdZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KHvdZ.jpg" alt="enter image description here" /></a></p> <p>Here <a href="https://stackoverflow.com/questions/70488378/flutter-how-to-make-a-nav-bar-like-in-youtube-app">Flutter: How to make a nav bar like in youtube app?</a> the answer is to use package, but is there any way to implement this without using a package?</p>
[ { "answer_id": 74335940, "author": "Mikdore", "author_id": 8309536, "author_profile": "https://Stackoverflow.com/users/8309536", "pm_score": 2, "selected": true, "text": "show_bits" }, { "answer_id": 74336036, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": -1, "selected": false, "text": "int printfloatasbin(const float x)\n{\n unsigned long long mask = 1ull << (sizeof(x) * CHAR_BIT - 1);\n unsigned long long val;\n\n memcpy(&val, &x, sizeof(x));\n while(mask)\n {\n printf(\"%d\",!!(val & mask));\n mask >>= 1;\n }\n}\n\nint main(void)\n{\n printfloatasbin(5.0f);\n}\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18007568/" ]
74,335,356
<p>I have this values: [0, 0, 0, 0, 1] and I want to write a code that tells me that there is 1 row of 4 zeroes like in the example above, and if there's 2 rows of 4 zeroes like: [0, 0, 0, 0, 1, 0, 0, 0, 0] henceforth it should say that there are 2 rows of 4 zeroes. How can I do that if you guys could help me??</p> <p>I haven't tried anything, I only considered counting the zeroes With i index but it just well counts zeroes like there are 4 zeroes, but I want to count how many rows of zeroes are there.</p>
[ { "answer_id": 74335940, "author": "Mikdore", "author_id": 8309536, "author_profile": "https://Stackoverflow.com/users/8309536", "pm_score": 2, "selected": true, "text": "show_bits" }, { "answer_id": 74336036, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": -1, "selected": false, "text": "int printfloatasbin(const float x)\n{\n unsigned long long mask = 1ull << (sizeof(x) * CHAR_BIT - 1);\n unsigned long long val;\n\n memcpy(&val, &x, sizeof(x));\n while(mask)\n {\n printf(\"%d\",!!(val & mask));\n mask >>= 1;\n }\n}\n\nint main(void)\n{\n printfloatasbin(5.0f);\n}\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20431609/" ]
74,335,381
<p>Here is my initial unuseful code.</p> <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script&gt; function main() { for (let i = 0; i &lt; document.body.childNodes.length; i++) { alert( document.body.childNodes[i].string ); // Text, DIV, Text, UL, ..., SCRIPT } } &lt;/script&gt; &lt;/head&gt; &lt;body onload=&quot;main()&quot;&gt; &lt;p class='[[param-tmpl-1]]'&gt; Some text {{var-templ-2}}. &lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I would like that the browser works with the following code for the body where <code>[[ ... ]]</code> has been cut, and <code>{{ SOMETHING }}</code> is become <code>&lt;span style = &quot;color: red;; font-weight: bold;&quot;&gt;SOMETHING&lt;/span&gt;</code>.</p> <pre class="lang-html prettyprint-override"><code>&lt;body&gt; &lt;p class=''&gt; Some text &lt;span style = &quot;color: red;; font-weight: bold;&quot;&gt;var-templ-2&lt;/span&gt;. &lt;/p&gt; &lt;/body&gt; </code></pre> <p>I have no control on the DOM structure, and the places where <code>[[ ... ]]</code> and <code>{{ ... }}</code> are used.</p>
[ { "answer_id": 74335702, "author": "fasfrtewqt2354r2edrq", "author_id": 18910456, "author_profile": "https://Stackoverflow.com/users/18910456", "pm_score": 0, "selected": false, "text": "<!DOCTYPE html>\n<html>\n \n<head>\n <script> \nfunction main() {\n for (let i = 0; i < document.body.childNodes.length; i++) {\n alert( document.body.childNodes[i].string );\n\n//get the p element by id\nconst simple_p = document.getElementById('simple-p')\n//change class attribute to blank\nsimple_p.setAttribute('class','')\n//create the span\nconst simple_span = document.createElement('span')\n//change the span style\nsimple_span.setAttribute('style','color: red;; font-weight: bold;')\n//text of the span\nsimple_span.innerHTML = 'var-templ-2'\n//part of the p element text\nsimple_p.innerHTML = 'Some text '\n//append the span element to the p element\nsimple_p.appendChild(simple_span)\n//next part of the p element text\nsimple_p.innerHTML += '.'\n\n // Text, DIV, Text, UL, ..., SCRIPT\n } \n}\n </script>\n</head>\n\n \n<body onload=\"main()\">\n\n<p class='[[param-tmpl-1]]'>\n Some text {{var-templ-2}}.\n</p>\n\n</body>\n \n</html>\n" }, { "answer_id": 74335936, "author": "Bqardi", "author_id": 14647816, "author_profile": "https://Stackoverflow.com/users/14647816", "pm_score": 1, "selected": false, "text": "function main() {\n const XMLS = new XMLSerializer();\n let bodyContent = XMLS.serializeToString(document.body);\n bodyContent = bodyContent.replace(/\\[\\[.*?\\]\\]/g, \"\");\n bodyContent = bodyContent.replace(/\\{\\{/g, `<span style=\"color: red; font-weight: bold;\">`);\n bodyContent = bodyContent.replace(/\\}\\}/g, \"</span>\");\n document.body.outerHTML = bodyContent;\n}" }, { "answer_id": 74336061, "author": "Carsten Massmann", "author_id": 2610061, "author_profile": "https://Stackoverflow.com/users/2610061", "pm_score": 3, "selected": true, "text": "document.body.outerHTML" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4589608/" ]
74,335,417
<p>i have a list named events and loop over it via for loop through each iteration i update the values of dict and then append it to the list. so i desire that list items dont be repetitive and be different. <a href="https://i.stack.imgur.com/qoHwr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qoHwr.png" alt="code:" /></a></p> <p><a href="https://i.stack.imgur.com/D54vG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D54vG.png" alt="output:" /></a></p> <p>i tested that if i put the dict definition into the for loop, it will be fixed. but my question is why it doesn't work when dict definition is out of the for loop?</p> <pre class="lang-py prettyprint-override"><code> import requests from bs4 import BeautifulSoup url = 'https://www.python.org/events/python-events/' req = requests.get(url) soup = BeautifulSoup(req.text, 'html.parser') events = soup.find('ul', {'class': 'list-recent-events'}).findAll('li') events_list = [] events_dict = dict() for event in events: events_dict['name'] = event.find('h3').find(&quot;a&quot;).text events_dict['location'] = event.find('span', {'class': 'event-location'}).text events_dict['time'] = event.find('time').text events_list.append(events_dict) for items in events_list: print(items) </code></pre>
[ { "answer_id": 74335461, "author": "HedgeHog", "author_id": 14460824, "author_profile": "https://Stackoverflow.com/users/14460824", "pm_score": 1, "selected": false, "text": "dict" }, { "answer_id": 74350417, "author": "ZeinabBanayazdi", "author_id": 10586169, "author_profile": "https://Stackoverflow.com/users/10586169", "pm_score": 0, "selected": false, "text": "deepcopy" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10586169/" ]
74,335,421
<p>I have a dataframe (with the first column being index column)(below). I would like to add(create) a (last) column which is a copy of the index column (desired result below). However I have the error (below). Is there a workaround? Thanks in advance</p> <pre><code>import pandas as pd df1 = pd.DataFrame({&quot;date&quot;: ['2021-3-22', '2021-3-23', '2021-3-24', '2021-3-25', '2021-3-26'], &quot;x&quot;: ['nan', 1, 'nan', 'nan', 'nan' ]}) df1.set_index('date', inplace=True) df1 date x 2021-3-22 nan 2021-3-23 1 2021-3-24 nan 2021-3-25 nan 2021-3-26 nan df1['date1'] = df1['date'].copy() df1 --------------------------------------------------------------------------- KeyError Traceback (most recent call last) ~\anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance) 3360 try: -&gt; 3361 return self._engine.get_loc(casted_key) 3362 except KeyError as err: ~\anaconda3\lib\site-packages\pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc() ~\anaconda3\lib\site-packages\pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() KeyError: 'date' The above exception was the direct cause of the following exception: KeyError Traceback (most recent call last) C:\Temp/ipykernel_10224/2516020320.py in &lt;module&gt; ----&gt; 1 df1['date1'] = df1['date'].copy() 2 df1 ~\anaconda3\lib\site-packages\pandas\core\frame.py in __getitem__(self, key) 3456 if self.columns.nlevels &gt; 1: 3457 return self._getitem_multilevel(key) -&gt; 3458 indexer = self.columns.get_loc(key) 3459 if is_integer(indexer): 3460 indexer = [indexer] ~\anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance) 3361 return self._engine.get_loc(casted_key) 3362 except KeyError as err: -&gt; 3363 raise KeyError(key) from err 3364 3365 if is_scalar(key) and isna(key) and not self.hasnans: KeyError: 'date' The desired result is: date x date1 0 2021-3-22 nan 2021-3-22 1 2021-3-23 1 2021-3-23 2 2021-3-24 nan 2021-3-24 3 2021-3-25 nan 2021-3-25 4 2021-3-26 nan 2021-3-26 </code></pre> <p>Many thanks in advance!</p>
[ { "answer_id": 74335461, "author": "HedgeHog", "author_id": 14460824, "author_profile": "https://Stackoverflow.com/users/14460824", "pm_score": 1, "selected": false, "text": "dict" }, { "answer_id": 74350417, "author": "ZeinabBanayazdi", "author_id": 10586169, "author_profile": "https://Stackoverflow.com/users/10586169", "pm_score": 0, "selected": false, "text": "deepcopy" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18836406/" ]
74,335,444
<p>I am making a twitter clone application with VueJS 3.</p> <p>I saved Twitter's logo as a .svg file and can use it with the <code>&lt;img /&gt;</code> tag. I can also change its color when I give the <code>&lt;svg&gt;</code> tag the <code>fill=&quot;#fff&quot;</code> attribute. However, I want to use this .svg file in multiple places and in different colors.</p> <p>So I tried to dynamically change the color of the svg by giving the <code>&lt;img /&gt;</code> tag the classes <code>fill-white</code>, <code>bg-white</code> and <code>text-white</code>, but it didn't work.</p> <p><strong>My Currently .svg File - With White Color</strong></p> <pre class="lang-html prettyprint-override"><code>&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot; viewBox=&quot;0 0 24 24&quot; aria-hidden=&quot;true&quot;&gt; &lt;g&gt; &lt;path fill=&quot;#fff&quot; d=&quot;M23.643 4.937c-... 1.7-1.477 2.323-2.41z&quot;&gt;&lt;/path&gt; &lt;/g&gt; &lt;/svg&gt; </code></pre> <p><strong>Img Tag</strong></p> <pre class="lang-html prettyprint-override"><code>&lt;img src=&quot;/twitter-bird.svg&quot; draggable=&quot;false&quot; class=&quot;w-52 lg:w-96 fill-white&quot; alt=&quot;Twitter Bird&quot; /&gt; </code></pre> <p><strong>I Tried This On .svg File</strong></p> <pre class="lang-html prettyprint-override"><code>&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot; viewBox=&quot;0 0 24 24&quot; aria-hidden=&quot;true&quot;&gt; &lt;g&gt; &lt;path fill=&quot;params(fill) #fff&quot; d=&quot;M23.643 4.937c-... 1.7-1.477 2.323-2.41z&quot;&gt;&lt;/path&gt; &lt;/g&gt; &lt;/svg&gt; </code></pre> <p>I understand that I need to make this svg's color editable. But I couldn't find how to do this.</p>
[ { "answer_id": 74335461, "author": "HedgeHog", "author_id": 14460824, "author_profile": "https://Stackoverflow.com/users/14460824", "pm_score": 1, "selected": false, "text": "dict" }, { "answer_id": 74350417, "author": "ZeinabBanayazdi", "author_id": 10586169, "author_profile": "https://Stackoverflow.com/users/10586169", "pm_score": 0, "selected": false, "text": "deepcopy" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335444", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17466049/" ]
74,335,491
<p>How do I adjust the position of the header that has been marked as in the picture slightly inward or in the top center?.<a href="https://i.stack.imgur.com/nQ9Ws.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nQ9Ws.png" alt="enter image description here" /></a></p> <pre><code>.header{ display:flex; position:relative; } .header h1{ position:fixed; width:100%; color:black; background:lightblue; padding:5px; text-align:center; border:3px solid lightblue; border-radius:8px; } </code></pre> <p>this is the script i'm trying to set the position in css.I'm still a beginner so please help to solve this problem, thank you</p>
[ { "answer_id": 74335707, "author": "pier farrugia", "author_id": 19996700, "author_profile": "https://Stackoverflow.com/users/19996700", "pm_score": 1, "selected": false, "text": ".header{\n display:flex;\n position:fixed;\n}\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20431458/" ]
74,335,497
<p>i want to convert date from datepicker to toisostring in angular. my problem is when i add data from to backend a have date day before one day my code is HTML:</p> <pre><code> &lt;mat-form-field appearance=&quot;fill&quot;&gt; &lt;mat-label&gt;Enter a date range&lt;/mat-label&gt; &lt;mat-date-range-input [rangePicker]=&quot;picker&quot; separator=&quot;to&quot; required [min]=&quot;today&quot; [dateFilter]=&quot;dateFilterFn&quot;&gt; &lt;input matStartDate formControlName=&quot;From_Date&quot; placeholder=&quot;From_Date&quot; name=&quot;From_Date&quot;&gt; &lt;input matEndDate formControlName=&quot;To_Date&quot; placeholder=&quot;To_Date&quot; name=&quot;To_Date&quot;&gt; &lt;/mat-date-range-input&gt; &lt;mat-hint&gt;DD/MM/YYYY – DD/MM/YYYY &lt;/mat-hint&gt; &lt;mat-datepicker-toggle matSuffix [for]=&quot;picker&quot;&gt;&lt;/mat-datepicker-toggle&gt; &lt;mat-date-range-picker #picker&gt;&lt;/mat-date-range-picker&gt; &lt;/mat-form-field&gt; </code></pre> <p>File Ts:</p> <pre><code>this.demandeForm = this.formBuilder.group({ From_Date:[], To_Date :[], Created_AT : [this.created_AT,Validators.required], nmbJours : ['',Validators.required], alternate : [''], details:[''], status:['En Cours'], reason:[''], employeeId : ['',Validators.required], typecongesId : ['',Validators.required] }) </code></pre> <p>when i insert data i have this in console From_Date:Mon Nov 07 2022 00:00:00 GMT+0100 (UTC+01:00) {} To_Date:Fri Nov 11 2022 00:00:00 GMT+0100 (UTC+01:00) but in backend i have : From_Date: 06-11-2022<br /> TO_Date : 10-11-2022</p>
[ { "answer_id": 74335707, "author": "pier farrugia", "author_id": 19996700, "author_profile": "https://Stackoverflow.com/users/19996700", "pm_score": 1, "selected": false, "text": ".header{\n display:flex;\n position:fixed;\n}\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19832761/" ]
74,335,504
<p>I have a data frame that has the date column as a char class. I've tried parsing as.Date but the amount of NAs is worrisome. The dates are are in the following formats: &quot;2003-10-19&quot;, and &quot;October 05, 2018&quot;</p> <p><code>date &lt;- c(&quot;October 05, 2018&quot;, &quot;2003-10-19&quot;)</code></p> <p><code>as.Date(date)</code> this is what I tried, but most of my results came back with NAs</p>
[ { "answer_id": 74335659, "author": "AndS.", "author_id": 9778513, "author_profile": "https://Stackoverflow.com/users/9778513", "pm_score": 2, "selected": false, "text": "date <- c(\"October 05, 2018\", \"2003-10-19\", \"10/9/95\", \"6 Oct.2010\")\n\nlubridate::parse_date_time(date, orders = c(\"mdy\", \"ymd\", \"dmy\"))\n#> [1] \"2018-10-05 UTC\" \"2003-10-19 UTC\" \"1995-10-09 UTC\" \"2010-10-06 UTC\"\n" }, { "answer_id": 74336920, "author": "Andre Wildberg", "author_id": 9462095, "author_profile": "https://Stackoverflow.com/users/9462095", "pm_score": 1, "selected": false, "text": "as.Date" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19805656/" ]
74,335,539
<p>the input is like this</p> <pre><code>100 5 0 10 0 5 75 95 12 17 13 14 </code></pre> <p>and the output is <code>65</code> so i want the program to count which numbers from 0-100 are not in the array.</p> <p>this is how i started</p> <pre><code>static void Main(string[] args) { string input1 = Console.ReadLine(); int roadlength = Convert.ToInt32(input1.Split(&quot; &quot;)[0]); int stagecnt = Convert.ToInt32(input1.Split(&quot; &quot;)[1]); int[] startpoint = new int[stagecnt]; int[] endpoint = new int[stagecnt]; int km = 0; for (int i = 0; i &lt; stagecnt; i++) { string input2 = Console.ReadLine(); startpoint[i] = Convert.ToInt32(input2.Split(' ')[0]); endpoint[i] = Convert.ToInt32(input2.Split(' ')[1]); } for (int i = 0; i &lt; stagecnt; i++) { </code></pre>
[ { "answer_id": 74335661, "author": "Dmitry Bychenko", "author_id": 2319407, "author_profile": "https://Stackoverflow.com/users/2319407", "pm_score": 2, "selected": false, "text": "0..100" }, { "answer_id": 74335676, "author": "vivek nuna", "author_id": 6527049, "author_profile": "https://Stackoverflow.com/users/6527049", "pm_score": 1, "selected": false, "text": "int[] items = ;\nint start = 1;\nint end = 100;\n\nint[] arr = Enumerable.Range(start, end - start).ToArray();\nint count = 0;\nfor(int i = 0; i < arr.Length; i++)\n{\n if (!items.Contains(arr[i]))\n {\n count++;\n }\n}\n" }, { "answer_id": 74336022, "author": "Tim Schmelter", "author_id": 284240, "author_profile": "https://Stackoverflow.com/users/284240", "pm_score": 0, "selected": false, "text": "int[] array = {1,2,3,4,5};\nHashSet<int> allBetween1And100 = Enumerable.Range(1, 100).ToHashSet();\nallBetween1And100.ExceptWith(array); // removes all from the set which are not in array\nint countMissing = allBetween1And100.Count; // 95\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20431732/" ]
74,335,540
<p>I have a dataframe as:</p> <pre><code>pl.DataFrame( [{'row_nr': 0, 'middle_name_or_initial': 'R.', 'count': 8}, {'row_nr': 0, 'middle_name_or_initial': 'B.', 'count': 1}, {'row_nr': 1, 'middle_name_or_initial': 'D.', 'count': 1}, {'row_nr': 1, 'middle_name_or_initial': 'J.', 'count': 11}, {'row_nr': 2, 'middle_name_or_initial': 'Micha', 'count': 1}, {'row_nr': 2, 'middle_name_or_initial': 'M.', 'count': 1}, {'row_nr': 2, 'middle_name_or_initial': 'J.', 'count': 1}, {'row_nr': 3, 'middle_name_or_initial': 'E.', 'count': 1}, {'row_nr': 3, 'middle_name_or_initial': 'S.', 'count': 1}, {'row_nr': 4, 'middle_name_or_initial': 'M.', 'count': 1}, {'row_nr': 4, 'middle_name_or_initial': 'P.', 'count': 1}, {'row_nr': 5, 'middle_name_or_initial': 'Christopher', 'count': 15}, {'row_nr': 5, 'middle_name_or_initial': 'Robert', 'count': 1}, {'row_nr': 6, 'middle_name_or_initial': 'Lusi', 'count': 1}, {'row_nr': 6, 'middle_name_or_initial': 'Luis', 'count': 1}]) </code></pre> <p>Here I would like to select the observations on a condition as: on grouping row_nr and middle_name the highest count observation to be given as output per a group.</p> <p>if the counts are equal i.e 1 all of these group rows will be returned.</p> <p>expected output as</p> <p><a href="https://i.stack.imgur.com/E4Mjw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E4Mjw.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74335645, "author": "Will", "author_id": 12829151, "author_profile": "https://Stackoverflow.com/users/12829151", "pm_score": 0, "selected": false, "text": "import polars as pl\ntmp = pl.DataFrame(\n[{'row_nr': 0, 'middle_name_or_initial': 'R.', 'count': 8},\n {'row_nr': 0, 'middle_name_or_initial': 'B.', 'count': 1},\n {'row_nr': 1, 'middle_name_or_initial': 'D.', 'count': 1},\n {'row_nr': 1, 'middle_name_or_initial': 'J.', 'count': 11},\n {'row_nr': 2, 'middle_name_or_initial': 'Micha', 'count': 1},\n {'row_nr': 2, 'middle_name_or_initial': 'M.', 'count': 1},\n {'row_nr': 2, 'middle_name_or_initial': 'J.', 'count': 1},\n {'row_nr': 3, 'middle_name_or_initial': 'E.', 'count': 1},\n {'row_nr': 3, 'middle_name_or_initial': 'S.', 'count': 1},\n {'row_nr': 4, 'middle_name_or_initial': 'M.', 'count': 1},\n {'row_nr': 4, 'middle_name_or_initial': 'P.', 'count': 1},\n {'row_nr': 5, 'middle_name_or_initial': 'Christopher', 'count': 15},\n {'row_nr': 5, 'middle_name_or_initial': 'Robert', 'count': 1},\n {'row_nr': 6, 'middle_name_or_initial': 'Lusi', 'count': 1},\n {'row_nr': 6, 'middle_name_or_initial': 'Luis', 'count': 1}])\n\n df = (\n tmp\n .groupby(['row_nr','middle_name_or_initial'])\n .agg(\n [\n pl.col(\"count\").max(),\n ]\n )\n )\n\ndf\n" }, { "answer_id": 74336952, "author": "TomNorway", "author_id": 1018861, "author_profile": "https://Stackoverflow.com/users/1018861", "pm_score": 2, "selected": true, "text": "count != 1" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9479925/" ]
74,335,542
<p>This started happening after we upgraded our compileSdkVersion and targetSdkVersion to 31.</p> <p>To give some background: Our project is currently on react native 0.63.2 and previous compileSdkVersion was 30. We were successfully building android app till a few days back but suddenly it started to fail with the following error:</p> <pre><code>AAPT: error: resource android:attr/lStar not found </code></pre> <p>After some searching online, we followed some solutions here: <a href="https://stackoverflow.com/questions/69021225/resource-linking-fails-on-lstar/69045181#69045181">Resource linking fails on lStar</a> . We upgraded to compileSdkVersion and targetSdkVersion to 31, did some other related changes and were able to compile successfully. But the app is now crashing immediately on startup when I run it on Android 13 device. The following are the error logs from logcat:</p> <pre><code>2022-11-06 16:54:44.438 15842-15842/com.flyfinapp E/SoLoader: couldn't find DSO to load: libjscexecutor.so caused by: dlopen failed: library &quot;libjsc.so&quot; not found: needed by /data/app/~~xPxviTwL84s3LS8L8OTgAA==/com.flyfinapp-EZ0vekCsB5BzvVwFLbm-GQ==/lib/arm64/libjscexecutor.so in namespace classloader-namespace result: 0 2022-11-06 16:54:44.480 15842-15842/com.flyfinapp E/SoLoader: couldn't find DSO to load: libhermes-executor-debug.so caused by: dlopen failed: cannot locate symbol &quot;_ZTVN6hermes2vm12CrashManagerE&quot; referenced by &quot;/data/app/~~xPxviTwL84s3LS8L8OTgAA==/com.flyfinapp-EZ0vekCsB5BzvVwFLbm-GQ==/lib/arm64/libhermes-executor-debug.so&quot;... result: 0 2022-11-06 16:54:44.482 15842-15842/com.flyfinapp E/SoLoader: couldn't find DSO to load: libhermes-executor-release.so SoSource 0: com.facebook.soloader.ApkSoSource[root = /data/data/com.flyfinapp/lib-main flags = 1] SoSource 1: com.facebook.soloader.DirectorySoSource[root = /data/app/~~xPxviTwL84s3LS8L8OTgAA==/com.flyfinapp-EZ0vekCsB5BzvVwFLbm-GQ==/lib/arm64 flags = 0] SoSource 2: com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2] SoSource 3: com.facebook.soloader.DirectorySoSource[root = /vendor/lib64 flags = 2] Native lib dir: /data/app/~~xPxviTwL84s3LS8L8OTgAA==/com.flyfinapp-EZ0vekCsB5BzvVwFLbm-GQ==/lib/arm64 result: 0 2022-11-06 16:54:44.483 15842-15842/com.flyfinapp E/AndroidRuntime: FATAL EXCEPTION: main Process: com.flyfinapp, PID: 15842 java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes-executor-release.so SoSource 0: com.facebook.soloader.ApkSoSource[root = /data/data/com.flyfinapp/lib-main flags = 1] SoSource 1: com.facebook.soloader.DirectorySoSource[root = /data/app/~~xPxviTwL84s3LS8L8OTgAA==/com.flyfinapp-EZ0vekCsB5BzvVwFLbm-GQ==/lib/arm64 flags = 0] SoSource 2: com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2] SoSource 3: com.facebook.soloader.DirectorySoSource[root = /vendor/lib64 flags = 2] Native lib dir: /data/app/~~xPxviTwL84s3LS8L8OTgAA==/com.flyfinapp-EZ0vekCsB5BzvVwFLbm-GQ==/lib/arm64 result: 0 at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:1127) at com.facebook.soloader.SoLoader.loadLibraryBySoNameImpl(SoLoader.java:943) at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:855) at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:802) at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:772) at com.facebook.hermes.reactexecutor.HermesExecutor.loadLibrary(HermesExecutor.java:30) at com.facebook.hermes.reactexecutor.HermesExecutor.&lt;clinit&gt;(HermesExecutor.java:19) at com.facebook.hermes.reactexecutor.HermesExecutor.loadLibrary(HermesExecutor.java:23) at com.facebook.react.ReactInstanceManagerBuilder.getDefaultJSExecutorFactory(ReactInstanceManagerBuilder.java:369) at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:316) at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:94) at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:41) at com.flyfinapp.MainApplication.onCreate(MainApplication.java:77) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1266) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6785) at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2134) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7898) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) 2022-11-06 16:54:44.483 15842-15842/com.flyfinapp E/WebEngage: App has crashed java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes-executor-release.so SoSource 0: com.facebook.soloader.ApkSoSource[root = /data/data/com.flyfinapp/lib-main flags = 1] SoSource 1: com.facebook.soloader.DirectorySoSource[root = /data/app/~~xPxviTwL84s3LS8L8OTgAA==/com.flyfinapp-EZ0vekCsB5BzvVwFLbm-GQ==/lib/arm64 flags = 0] SoSource 2: com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2] SoSource 3: com.facebook.soloader.DirectorySoSource[root = /vendor/lib64 flags = 2] Native lib dir: /data/app/~~xPxviTwL84s3LS8L8OTgAA==/com.flyfinapp-EZ0vekCsB5BzvVwFLbm-GQ==/lib/arm64 result: 0 2022-11-06 16:54:47.669 15942-15942/com.flyfinapp E/SoLoader: couldn't find DSO to load: libjscexecutor.so caused by: dlopen failed: library &quot;libjsc.so&quot; not found: needed by /data/app/~~xPxviTwL84s3LS8L8OTgAA==/com.flyfinapp-EZ0vekCsB5BzvVwFLbm-GQ==/lib/arm64/libjscexecutor.so in namespace classloader-namespace result: 0 2022-11-06 16:54:47.676 15942-15942/com.flyfinapp E/SoLoader: couldn't find DSO to load: libhermes-executor-debug.so caused by: dlopen failed: cannot locate symbol &quot;_ZTVN6hermes2vm12CrashManagerE&quot; referenced by &quot;/data/app/~~xPxviTwL84s3LS8L8OTgAA==/com.flyfinapp-EZ0vekCsB5BzvVwFLbm-GQ==/lib/arm64/libhermes-executor-debug.so&quot;... result: 0 2022-11-06 16:54:47.678 15942-15942/com.flyfinapp E/SoLoader: couldn't find DSO to load: libhermes-executor-release.so SoSource 0: com.facebook.soloader.ApkSoSource[root = /data/data/com.flyfinapp/lib-main flags = 1] SoSource 1: com.facebook.soloader.DirectorySoSource[root = /data/app/~~xPxviTwL84s3LS8L8OTgAA==/com.flyfinapp-EZ0vekCsB5BzvVwFLbm-GQ==/lib/arm64 flags = 0] SoSource 2: com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2] SoSource 3: com.facebook.soloader.DirectorySoSource[root = /vendor/lib64 flags = 2] Native lib dir: /data/app/~~xPxviTwL84s3LS8L8OTgAA==/com.flyfinapp-EZ0vekCsB5BzvVwFLbm-GQ==/lib/arm64 result: 0 2022-11-06 16:54:47.679 15942-15942/com.flyfinapp E/AndroidRuntime: FATAL EXCEPTION: main Process: com.flyfinapp, PID: 15942 java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes-executor-release.so SoSource 0: com.facebook.soloader.ApkSoSource[root = /data/data/com.flyfinapp/lib-main flags = 1] SoSource 1: com.facebook.soloader.DirectorySoSource[root = /data/app/~~xPxviTwL84s3LS8L8OTgAA==/com.flyfinapp-EZ0vekCsB5BzvVwFLbm-GQ==/lib/arm64 flags = 0] SoSource 2: com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2] SoSource 3: com.facebook.soloader.DirectorySoSource[root = /vendor/lib64 flags = 2] Native lib dir: /data/app/~~xPxviTwL84s3LS8L8OTgAA==/com.flyfinapp-EZ0vekCsB5BzvVwFLbm-GQ==/lib/arm64 result: 0 at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:1127) at com.facebook.soloader.SoLoader.loadLibraryBySoNameImpl(SoLoader.java:943) at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:855) at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:802) at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:772) at com.facebook.hermes.reactexecutor.HermesExecutor.loadLibrary(HermesExecutor.java:30) at com.facebook.hermes.reactexecutor.HermesExecutor.&lt;clinit&gt;(HermesExecutor.java:19) at com.facebook.hermes.reactexecutor.HermesExecutor.loadLibrary(HermesExecutor.java:23) at com.facebook.react.ReactInstanceManagerBuilder.getDefaultJSExecutorFactory(ReactInstanceManagerBuilder.java:369) at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:316) at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:94) at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:41) at com.flyfinapp.MainApplication.onCreate(MainApplication.java:77) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1266) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6785) at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2134) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7898) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) 2022-11-06 16:54:47.679 15942-15942/com.flyfinapp E/WebEngage: App has crashed java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes-executor-release.so SoSource 0: com.facebook.soloader.ApkSoSource[root = /data/data/com.flyfinapp/lib-main flags = 1] SoSource 1: com.facebook.soloader.DirectorySoSource[root = /data/app/~~xPxviTwL84s3LS8L8OTgAA==/com.flyfinapp-EZ0vekCsB5BzvVwFLbm-GQ==/lib/arm64 flags = 0] SoSource 2: com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2] SoSource 3: com.facebook.soloader.DirectorySoSource[root = /vendor/lib64 flags = 2] Native lib dir: /data/app/~~xPxviTwL84s3LS8L8OTgAA==/com.flyfinapp-EZ0vekCsB5BzvVwFLbm-GQ==/lib/arm64 result: 0 </code></pre> <p>We have <code>enableHermes</code> set to true. We also searched solutions for this but everything was applicable for RN 67 and beyond. But we are still on RN 63, so none of those solutions worked. We can try upgrading our RN version but there are some blockers so it is not possible to upgrade right away. For now we would like to solve this specific issue and move on. Any help here would be greatly appreciated.</p>
[ { "answer_id": 74341863, "author": "Ankur", "author_id": 447137, "author_profile": "https://Stackoverflow.com/users/447137", "pm_score": 2, "selected": false, "text": "def REACT_NATIVE_VERSION = \"0.64.2\" //replace this with the latest stable version you were using before\n\nallprojects {\n configurations.all {\n resolutionStrategy {\n force \"com.facebook.react:react-native:\" + REACT_NATIVE_VERSION\n }\n }\n repositories {\n google()\n ...\n }\n}\n" }, { "answer_id": 74361340, "author": "mklb", "author_id": 2502014, "author_profile": "https://Stackoverflow.com/users/2502014", "pm_score": 2, "selected": false, "text": "project.ext.react = [\n enableHermes: false, // clean and rebuild if changing\n]\n" }, { "answer_id": 74369665, "author": "Taras Pysarskyi", "author_id": 19040070, "author_profile": "https://Stackoverflow.com/users/19040070", "pm_score": 0, "selected": false, "text": "hermesFlagsForVariant" }, { "answer_id": 74613358, "author": "IAmCoder", "author_id": 4279006, "author_profile": "https://Stackoverflow.com/users/4279006", "pm_score": 0, "selected": false, "text": "React Native 0.69" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335542", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1430993/" ]
74,335,547
<p>I'd like to split an array into <code>n</code> roughly equal sized chunks, without knowing how large these chunks will be beforehand.</p> <p>Using Numpy, this can be done with <code>array_split</code>:</p> <pre><code>&gt;&gt;&gt; import numpy &gt;&gt;&gt; x = [7, 3, 9, 10, 5, 6, 8, 13] &gt;&gt;&gt; x [7, 3, 9, 10, 5, 6, 8, 13] &gt;&gt;&gt; numpy.array_split(x, 3) [array([7, 3, 9]), array([10, 5, 6]), array([ 8, 13])] </code></pre> <p>What's the Java equivalent of doing this? I'm happy to use a library function if available.</p>
[ { "answer_id": 74341863, "author": "Ankur", "author_id": 447137, "author_profile": "https://Stackoverflow.com/users/447137", "pm_score": 2, "selected": false, "text": "def REACT_NATIVE_VERSION = \"0.64.2\" //replace this with the latest stable version you were using before\n\nallprojects {\n configurations.all {\n resolutionStrategy {\n force \"com.facebook.react:react-native:\" + REACT_NATIVE_VERSION\n }\n }\n repositories {\n google()\n ...\n }\n}\n" }, { "answer_id": 74361340, "author": "mklb", "author_id": 2502014, "author_profile": "https://Stackoverflow.com/users/2502014", "pm_score": 2, "selected": false, "text": "project.ext.react = [\n enableHermes: false, // clean and rebuild if changing\n]\n" }, { "answer_id": 74369665, "author": "Taras Pysarskyi", "author_id": 19040070, "author_profile": "https://Stackoverflow.com/users/19040070", "pm_score": 0, "selected": false, "text": "hermesFlagsForVariant" }, { "answer_id": 74613358, "author": "IAmCoder", "author_id": 4279006, "author_profile": "https://Stackoverflow.com/users/4279006", "pm_score": 0, "selected": false, "text": "React Native 0.69" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1289801/" ]
74,335,592
<pre><code>import 'package:flutter/material.dart'; class DetailsScreen extends StatefulWidget { final int index; const DetailsScreen({Key? key, required this.index}) : super(key: key); @override State&lt;DetailsScreen&gt; createState() =&gt; _DetailsScreenState(); } class _DetailsScreenState extends State&lt;DetailsScreen&gt; { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(), body: Center( child: Hero( tag: widget.index, child: Image.network( &quot;https://raw.githubusercontent.com/markknguyen/pictures/master/pic/${widget.index + 1}.png&quot;, ), const Text(&quot;Rome&quot;), ), ), ); } } </code></pre> <p>I tried adding const thinking it will resolve the issue but I didn't. The code did not run. I Just wanted to add some sort of text box in a page. const Text(&quot;Rome&quot;), is the main concern.</p>
[ { "answer_id": 74341863, "author": "Ankur", "author_id": 447137, "author_profile": "https://Stackoverflow.com/users/447137", "pm_score": 2, "selected": false, "text": "def REACT_NATIVE_VERSION = \"0.64.2\" //replace this with the latest stable version you were using before\n\nallprojects {\n configurations.all {\n resolutionStrategy {\n force \"com.facebook.react:react-native:\" + REACT_NATIVE_VERSION\n }\n }\n repositories {\n google()\n ...\n }\n}\n" }, { "answer_id": 74361340, "author": "mklb", "author_id": 2502014, "author_profile": "https://Stackoverflow.com/users/2502014", "pm_score": 2, "selected": false, "text": "project.ext.react = [\n enableHermes: false, // clean and rebuild if changing\n]\n" }, { "answer_id": 74369665, "author": "Taras Pysarskyi", "author_id": 19040070, "author_profile": "https://Stackoverflow.com/users/19040070", "pm_score": 0, "selected": false, "text": "hermesFlagsForVariant" }, { "answer_id": 74613358, "author": "IAmCoder", "author_id": 4279006, "author_profile": "https://Stackoverflow.com/users/4279006", "pm_score": 0, "selected": false, "text": "React Native 0.69" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20429946/" ]
74,335,608
<p>Write an SQL query to report the patient_id, patient_name all conditions of patients who have Type I Diabetes. Type I Diabetes always starts with DIAB1 prefix.</p> <pre><code>+--------------+---------+ | Column Name | Type | +--------------+---------+ | patient_id | int | | patient_name | varchar | | conditions | varchar | +--------------+---------+ </code></pre> <p>This table contains information of the patients in the hospital.</p> <p><code>patient_id</code> is the primary key for this table. <code>conditions</code> contains 0 or more code separated by spaces.</p> <p>So this was my solution:</p> <pre><code>SELECT * FROM Patients WHERE conditions LIKE 'DIAB1%' OR conditions LIKE '%DIAB1%' ; </code></pre> <p><strong>It worked correctly for all these conditions</strong></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>patient_id</th> <th>patient_name</th> <th>conditions</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Daniel</td> <td>YFEV COUGH</td> </tr> <tr> <td>2</td> <td>Alice</td> <td></td> </tr> <tr> <td>3</td> <td>Bob</td> <td>DIAB100 MYOP</td> </tr> <tr> <td>4</td> <td>George</td> <td>ACNE DIAB100</td> </tr> </tbody> </table> </div> <p><strong>except for this condition</strong></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>patient_id</th> <th>patient_name</th> <th>conditions</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Daniel</td> <td>SADIAB100</td> </tr> </tbody> </table> </div> <p>And in the solution it was shown that there is a space after 1st % which would give you the correct answer:</p> <p><strong>correct query:</strong></p> <pre><code>SELECT * FROM Patients WHERE conditions LIKE 'DIAB1%' OR conditions LIKE '% DIAB1%' ; </code></pre> <p>So, can someone please explain why this query works for that particular condition (SADIAB100) and not the 1st query</p>
[ { "answer_id": 74341863, "author": "Ankur", "author_id": 447137, "author_profile": "https://Stackoverflow.com/users/447137", "pm_score": 2, "selected": false, "text": "def REACT_NATIVE_VERSION = \"0.64.2\" //replace this with the latest stable version you were using before\n\nallprojects {\n configurations.all {\n resolutionStrategy {\n force \"com.facebook.react:react-native:\" + REACT_NATIVE_VERSION\n }\n }\n repositories {\n google()\n ...\n }\n}\n" }, { "answer_id": 74361340, "author": "mklb", "author_id": 2502014, "author_profile": "https://Stackoverflow.com/users/2502014", "pm_score": 2, "selected": false, "text": "project.ext.react = [\n enableHermes: false, // clean and rebuild if changing\n]\n" }, { "answer_id": 74369665, "author": "Taras Pysarskyi", "author_id": 19040070, "author_profile": "https://Stackoverflow.com/users/19040070", "pm_score": 0, "selected": false, "text": "hermesFlagsForVariant" }, { "answer_id": 74613358, "author": "IAmCoder", "author_id": 4279006, "author_profile": "https://Stackoverflow.com/users/4279006", "pm_score": 0, "selected": false, "text": "React Native 0.69" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20081256/" ]
74,335,642
<p>I want to know if there is a way to namespace values, in a similar way that we namespace functions in PHP.</p> <p>You can have:</p> <pre><code>namespace pizza\land; function turn_oven_on(){} </code></pre> <p>And you can access that function with <code>pizza\land\hello()</code></p> <p>I wonder if there is a way to do something similar for values.</p> <p>This is not correct, I am just illustrating what I mean:</p> <pre><code>namespace pizza\land; namespaced $ingredients = array('pepperoni', 'garlic'); </code></pre> <p>Then access it with <code>$pizza\land\ingredients</code>.</p> <p>Other parts in the same runtime can do:</p> <pre><code>namespace pasta\land; namespaced $ingredients = array('tomato', 'mozzarella'); </code></pre> <p>Then access it with <code>$pasta\land\ingredients</code>.</p> <p>Of course that doesn't work, but it serves as an example of what I mean.</p> <p>I know there is the obvious way, which would be to use the Singleton pattern where the constructor sets the value of a public property for the singleton instance (the one and only one instance of the class).</p> <p>I dislike this setup, and in that case I prefer to go the killer route and just do <code>global $pseudonamespaced_pizza_land_ingredients</code>.</p> <p>I wonder, is there anything else I can do to achieve this setup using the latest version of PHP (now 8.1)?</p> <p><strong>Why?</strong></p> <p>To have the same effect you have with <code>global</code> but at the same time avoid collision.</p> <p>Well, let's say I am working with some procedural code and I need a value that can be accessed across multiple functions.</p> <p>So I want to use that value within the realms of that bunch of functions.</p> <p>I do not want to wrap all those functions into one Class and then use a property for that class, because in that case I just prefer the Singleton or the global.</p> <p>Also, if not possible. Why not?</p> <p>I cannot believe that this hasn't been mentioned before as something to consider for integration into PHP. So, there must be a reason for this not being possible, if it isn't. It would be a cool solution for all those codebases that are mostly procedural and use <code>global</code> way too often... ehem... WordPress...</p>
[ { "answer_id": 74341863, "author": "Ankur", "author_id": 447137, "author_profile": "https://Stackoverflow.com/users/447137", "pm_score": 2, "selected": false, "text": "def REACT_NATIVE_VERSION = \"0.64.2\" //replace this with the latest stable version you were using before\n\nallprojects {\n configurations.all {\n resolutionStrategy {\n force \"com.facebook.react:react-native:\" + REACT_NATIVE_VERSION\n }\n }\n repositories {\n google()\n ...\n }\n}\n" }, { "answer_id": 74361340, "author": "mklb", "author_id": 2502014, "author_profile": "https://Stackoverflow.com/users/2502014", "pm_score": 2, "selected": false, "text": "project.ext.react = [\n enableHermes: false, // clean and rebuild if changing\n]\n" }, { "answer_id": 74369665, "author": "Taras Pysarskyi", "author_id": 19040070, "author_profile": "https://Stackoverflow.com/users/19040070", "pm_score": 0, "selected": false, "text": "hermesFlagsForVariant" }, { "answer_id": 74613358, "author": "IAmCoder", "author_id": 4279006, "author_profile": "https://Stackoverflow.com/users/4279006", "pm_score": 0, "selected": false, "text": "React Native 0.69" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10716664/" ]
74,335,653
<p>How can I concatenate two different model query and order by a field that both models has like progress fields.</p> <p><strong>For example</strong></p> <p><em>models.py</em></p> <pre><code>class Gig(models.Model): author= models.ForeignKey(User) title = models.CharFields() progress = models.IntegerField() class Project(models.Model): author= models.ForeignKey(User) title = models.CharFields() progress = models.IntegerField() </code></pre> <p>Can I do my view.py like this, for me to achieve it?</p> <p>İf No, How can I achieve it?</p> <p><em>views.py</em></p> <pre><code>def fetch_all_item(request): gig = Gig.objects.filter(author_id = request.user.id) project = Project.objects.filter(author_id = request.user.id) total_item = (gig + project).order_by(&quot;progress&quot;) return render(request, &quot;all_product.html&quot;, {&quot;item&quot;: total_item}) </code></pre> <p>I am trying to join two query set from <strong>Gig</strong> and <strong>Project</strong> models then send it to frontend in an <strong>ordering</strong> form by a <strong>field</strong> name called <strong>progress</strong>.</p>
[ { "answer_id": 74341863, "author": "Ankur", "author_id": 447137, "author_profile": "https://Stackoverflow.com/users/447137", "pm_score": 2, "selected": false, "text": "def REACT_NATIVE_VERSION = \"0.64.2\" //replace this with the latest stable version you were using before\n\nallprojects {\n configurations.all {\n resolutionStrategy {\n force \"com.facebook.react:react-native:\" + REACT_NATIVE_VERSION\n }\n }\n repositories {\n google()\n ...\n }\n}\n" }, { "answer_id": 74361340, "author": "mklb", "author_id": 2502014, "author_profile": "https://Stackoverflow.com/users/2502014", "pm_score": 2, "selected": false, "text": "project.ext.react = [\n enableHermes: false, // clean and rebuild if changing\n]\n" }, { "answer_id": 74369665, "author": "Taras Pysarskyi", "author_id": 19040070, "author_profile": "https://Stackoverflow.com/users/19040070", "pm_score": 0, "selected": false, "text": "hermesFlagsForVariant" }, { "answer_id": 74613358, "author": "IAmCoder", "author_id": 4279006, "author_profile": "https://Stackoverflow.com/users/4279006", "pm_score": 0, "selected": false, "text": "React Native 0.69" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18986346/" ]
74,335,759
<p>I need to find all regular files in a directory, and would like to use the C++20 ranges (not Eric Niebler's range-v3) library. I came up with the following code:</p> <pre><code>namespace fs = std::filesystem; std::vector&lt;fs::directory_entry&gt; entries{ fs::directory_iterator(&quot;D:\\Path&quot;), fs::directory_iterator() }; std::vector&lt;fs::path&gt; paths; std::ranges::copy(entries | std::views::filter([](const fs::directory_entry&amp; entry) { return entry.is_regular_file(); }) | std::views::transform([](const fs::directory_entry&amp; entry) { return entry.path(); }), std::back_inserter(paths)); </code></pre> <p>This works, but I'm uncomfortable with the additional boilerplate of using lambdas; I'm used to the Java 8 streams library, and I don't see why I can't just use member functions directly. This was my first attempt at refactoring:</p> <pre><code>std::ranges::copy(entries | std::views::filter(fs::directory_entry::is_regular_file) | std::views::transform(fs::directory_entry::path), std::back_inserter(paths)); </code></pre> <p>This resulted in compiler errors:</p> <pre><code>error C3867: 'std::filesystem::directory_entry::is_regular_file': non-standard syntax; use '&amp;' to create a pointer to member error C3889: call to object of class type 'std::ranges::views::_Filter_fn': no matching call operator found ... </code></pre> <p>So I tried this:</p> <pre><code>std::ranges::copy(entries | std::views::filter(&amp;fs::directory_entry::is_regular_file) | std::views::transform(&amp;fs::directory_entry::path), std::back_inserter(paths)); </code></pre> <p>This fixed the first error, but not the second:</p> <pre><code>error C3889: call to object of class type 'std::ranges::views::_Filter_fn': no matching call operator found ... </code></pre> <p>So I found <a href="https://stackoverflow.com/questions/37697832/using-member-variable-as-predicate">Using member variable as predicate</a>, which looked promising, so I tried:</p> <pre><code>std::ranges::copy(entries | std::views::filter(std::mem_fn(&amp;fs::directory_entry::is_regular_file)) | std::views::transform(std::mem_fn(&amp;fs::directory_entry::path)), std::back_inserter(paths)); </code></pre> <p>This resulted in new compiler errors:</p> <pre><code>error C2672: 'std::mem_fn': no matching overloaded function found ... </code></pre> <p>Note, <code>std::bind</code> doesn't appear to work either. Any help would be appreciated, thanks!</p>
[ { "answer_id": 74335815, "author": "user17732522", "author_id": 17732522, "author_profile": "https://Stackoverflow.com/users/17732522", "pm_score": 4, "selected": true, "text": "&fs::directory_entry::is_regular_file" }, { "answer_id": 74335876, "author": "John Zwinck", "author_id": 4323, "author_profile": "https://Stackoverflow.com/users/4323", "pm_score": 0, "selected": false, "text": "is_regular_file" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/291033/" ]
74,335,779
<p>i have seen two different ways of handling post requests on a route:</p> <pre><code>@app.route('/register', methods=['GET', 'POST']) def register(): form = RegistrationForm() if form.validate_on_submit(): # insert logic on data return render_template('register.html', title=&quot;Register&quot;, form=form) </code></pre> <p>and:</p> <pre><code>@app.route('/register', methods=['GET', 'POST']) def register(): if request.method == 'POST': # insert logic </code></pre> <p>I cannot seem to find a clear answer to the following questions, and i cant seem to find a duplicate in SO:</p> <ol> <li>Do they refer to different use cases?</li> <li>Should both be used? Are they redundant?</li> </ol> <p>Thanks in advance!</p>
[ { "answer_id": 74335901, "author": "Nabin Paudel", "author_id": 17363696, "author_profile": "https://Stackoverflow.com/users/17363696", "pm_score": 1, "selected": false, "text": "if request.method == \"POST\":\n # HTTP Method POST. That means the form was submitted by a user\n # and we can find her filled out answers using the request.POST QueryDict\nelse:\n # Normal GET Request (most likely).\n # We should probably display the form, so it can be filled\n # out by the user and submitted. \n" }, { "answer_id": 74336674, "author": "micromoses", "author_id": 2840436, "author_profile": "https://Stackoverflow.com/users/2840436", "pm_score": 3, "selected": true, "text": "/register" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335779", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5449244/" ]
74,335,782
<p>I'm trying to show <code>ResourcePool</code> utilization on a Time Plot chart.</p> <p>Currently I use Time Plot to display by <code>Value</code> the utilization of the selected <code>ResourcePool</code>: <a href="https://i.stack.imgur.com/FnG3A.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FnG3A.png" alt="enter image description here" /></a></p> <p>My problem is that every time the <code>stageIndex</code> changes, the Time Plot resets and starts showing the data from that moment on.</p> <p>Is there a way to directly access the <code>DataSet</code> of the <code>ResourcePool</code> (if there is one) and also get the past information about the utilization?</p> <p>Thanks a lot.</p>
[ { "answer_id": 74335901, "author": "Nabin Paudel", "author_id": 17363696, "author_profile": "https://Stackoverflow.com/users/17363696", "pm_score": 1, "selected": false, "text": "if request.method == \"POST\":\n # HTTP Method POST. That means the form was submitted by a user\n # and we can find her filled out answers using the request.POST QueryDict\nelse:\n # Normal GET Request (most likely).\n # We should probably display the form, so it can be filled\n # out by the user and submitted. \n" }, { "answer_id": 74336674, "author": "micromoses", "author_id": 2840436, "author_profile": "https://Stackoverflow.com/users/2840436", "pm_score": 3, "selected": true, "text": "/register" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18366972/" ]
74,335,789
<p>I have @ManyToMany related entity structures named Student and Course.I would like a student to be able to register for a maximum of 3 courses.At the same time, a course must have a maximum of 10 student. How can i do that? (Also I am using mySql database and hibernate)</p> <p>Here is my Student class;</p> <pre><code>@Entity @NoArgsConstructor @Getter @Setter public class Student extends BaseEntity { private String name; private String surname; @Column(name = &quot;student_number&quot;,unique = true) private String number; //student number @JsonIgnore @ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.EAGER) @JoinTable(name = &quot;students_courses&quot;, joinColumns = @JoinColumn(name = &quot;student_id&quot;), inverseJoinColumns = @JoinColumn(name = &quot;course_id&quot;)) private List&lt;Course&gt; courseList = new ArrayList&lt;&gt;(); } </code></pre> <p>Course Class;</p> <pre><code>@Entity @Getter @Setter public class Course extends BaseEntity{ @Column(name = &quot;course_name&quot;,unique = true) private String courseName; @JsonIgnore @ManyToMany(mappedBy = &quot;courseList&quot;,cascade = CascadeType.ALL ,fetch = FetchType.EAGER) private List&lt;Student&gt; studentList = new ArrayList&lt;&gt;(); } </code></pre> <p>Repositories;</p> <pre><code>@Repository public interface StudentRepository extends JpaRepository&lt;Student,Long&gt; { } </code></pre> <pre><code>@Repository public interface CourseRepository extends JpaRepository&lt;Course,Long&gt; { } </code></pre>
[ { "answer_id": 74335901, "author": "Nabin Paudel", "author_id": 17363696, "author_profile": "https://Stackoverflow.com/users/17363696", "pm_score": 1, "selected": false, "text": "if request.method == \"POST\":\n # HTTP Method POST. That means the form was submitted by a user\n # and we can find her filled out answers using the request.POST QueryDict\nelse:\n # Normal GET Request (most likely).\n # We should probably display the form, so it can be filled\n # out by the user and submitted. \n" }, { "answer_id": 74336674, "author": "micromoses", "author_id": 2840436, "author_profile": "https://Stackoverflow.com/users/2840436", "pm_score": 3, "selected": true, "text": "/register" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335789", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19055500/" ]
74,335,820
<p>I'm sorry if this is a very dumb question but I'm wondering how to pull a single data from flutter's object array list</p> <p>My code</p> <pre><code>class Bank { late String name; late String nameBank; Bank({required this.name, required this.nameBank}); } void main() { var bankMap = listBank.map((d) { return {&quot;name&quot;: d.name}; }).toList(); print(bankMap); } List listBank = [ Bank(name: 'Bank 1', nameBank: 'Bank 1'), Bank(name: 'Bank 2', nameBank: 'Bank 2') ]; </code></pre> <p>I want to pull name: 'Bank 1' only. Thank you!</p> <p>I tried adding [] like normal array but got an error</p>
[ { "answer_id": 74335901, "author": "Nabin Paudel", "author_id": 17363696, "author_profile": "https://Stackoverflow.com/users/17363696", "pm_score": 1, "selected": false, "text": "if request.method == \"POST\":\n # HTTP Method POST. That means the form was submitted by a user\n # and we can find her filled out answers using the request.POST QueryDict\nelse:\n # Normal GET Request (most likely).\n # We should probably display the form, so it can be filled\n # out by the user and submitted. \n" }, { "answer_id": 74336674, "author": "micromoses", "author_id": 2840436, "author_profile": "https://Stackoverflow.com/users/2840436", "pm_score": 3, "selected": true, "text": "/register" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20431969/" ]
74,335,864
<p>When I have a list of immutable objects, <code>lst</code> and want to get rid of duplicates, I can just use <code>set(lst)</code>:</p> <pre><code>lst = [0,4,2,6,3,6,4,9,2,2] # integers are immutable in python print(set(lst)) # {0,2,3,4,6,9} </code></pre> <p>However suppose I have a list of mutable objects, <code>lst</code> and want to get rid of duplicates. <code>set(lst)</code> won't work because mutable objects are not hashable - we'd get a <code>TypeError: unhashable type: '&lt;type&gt;'</code>. What should we do in this case?</p> <p>For example, suppose we have <code>lst</code>, a list of <code>dict</code>s (<code>dict</code>s are mutable and thus not hashable) and some <code>dicts</code> occur multiple times in <code>lst</code>:</p> <pre><code>d0 = {0:'a', 1:'b', 9:'j'} d1 = {'jan':1, 'jul':7, 'dec':12} d2 = {'hello':'hola', 'goodbye':'adios', 'happy':'feliz', 'sad':'triste'} lst = [d0, d1, d1, d0, d2, d1, d0] </code></pre> <p>We want to iterate through <code>lst</code>, but only consider each <code>dict</code> once. If we do <code>set(lst)</code>, we'd get a <code>TypeError: unhashable type: 'dict'</code>. Instead we have to do something like:</p> <pre><code>def dedup(lst): seen_ids = set() for elem in lst: id_ = id(elem) if id_ not in seen_ids: seen_ids.add(id_) yield elem </code></pre> <hr /> <p>Is there a better way to do this???</p>
[ { "answer_id": 74335952, "author": "chrslg", "author_id": 20037042, "author_profile": "https://Stackoverflow.com/users/20037042", "pm_score": 1, "selected": false, "text": "list({id(x):x for x in lst}.values())\n" }, { "answer_id": 74336325, "author": "user3435121", "author_id": 3435121, "author_profile": "https://Stackoverflow.com/users/3435121", "pm_score": -1, "selected": false, "text": "d0 = {0:'a', 1:'b', 9:'j'}\nd1 = {'jan':1, 'jul':7, 'dec':12}\nd2 = {'hello':'hola', 'goodbye':'adios', 'happy':'feliz', 'sad':'triste'}\nlst = [d0, d1, d1, d0, d2, d1, d0]\n\ndef dedup( lst):\n id_seen = []\n elems = []\n for elem in lst:\n if id(elem) not in id_seen:\n id_seen.append( id(elem))\n elems.append( elem)\n return elems\n\nprint( dedup( lst))\n" }, { "answer_id": 74336368, "author": "0x0fba", "author_id": 20339407, "author_profile": "https://Stackoverflow.com/users/20339407", "pm_score": 3, "selected": true, "text": "json" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13881506/" ]
74,335,925
<p>I have a table of grant application numbers and their corresponding disciplines given by cell value 1.</p> <pre><code>import pandas as pd import numpy as np data={'Application number':[0,1,2,3,4,5,6,7,8,9], 'Physics':[0,0,1,0,0,0,0,1,1,0], 'Chemistry':[1,0,0,0,0,0,0,0,0,1], 'Biology':[0,1,0,1,0,0,1,0,0,0], 'Mathematics':[0,0,0,0,1,1,0,0,0,0]} #creation of dataframe df=pd.DataFrame(data) #column counting all disciplines per grant df['All_Discipline_count']=df.loc[:,'Physics' : 'Mathematics'].sum(axis=1) df.head(10) </code></pre> <p>I would like to summarize discipline list and discipline count per grant application. I do that using iloc and multiple nested loops.</p> <pre><code># Creation of resulting dataframe dfA = pd.DataFrame(columns = ['Application number', 'Discipline_list', 'All_Discipline_count']) # Pay attention to how iloc a cell selects. 'Application number' is zeroth column. i=0 #starts from oth row j=1 #starts from 1st column Aanvraag_nummer=0 k=df.columns.get_loc(&quot;All_Discipline_count&quot;) #column number where the All_Discipline_count is l=len(df.index)#number of rows for i in range (0,l): Discipline_count=0 #introducing zero discipline count Discipline_list=&quot; &quot; #introducing empty discipline list for j in range (1,k): #counting columns of disciplines if (df.iloc[i,j]==1) &amp; (Discipline_count&lt;df.iloc[i,k]): #if the given cell has 1 as value Discipline_list=Discipline_list+ df.columns[j] #adds a column name to discipline list Discipline_count+=1 #counts the number of disciplines with 1 as value if Discipline_count==df.iloc[i,k]:#if all disciplines are counted Aanvraag_nummer=df.iloc[i,0] new_row = {'Application number':Aanvraag_nummer, 'Discipline_list':Discipline_list, 'All_Discipline_count':df.iloc[i,k]} dfA = dfA.append(new_row, ignore_index=True) dfA.head(10) </code></pre> <p>The script works for 10 to 100 applications and 20 disciplines as columns. It also works when there are multiple disciplines are given per grant application.</p> <p>However, I notice that I get warning while running the code.</p> <pre><code>/tmp/ipykernel_26718/1290491379.py:19: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead. </code></pre> <p>The code is also slow..Any better method to get the same results?</p>
[ { "answer_id": 74335952, "author": "chrslg", "author_id": 20037042, "author_profile": "https://Stackoverflow.com/users/20037042", "pm_score": 1, "selected": false, "text": "list({id(x):x for x in lst}.values())\n" }, { "answer_id": 74336325, "author": "user3435121", "author_id": 3435121, "author_profile": "https://Stackoverflow.com/users/3435121", "pm_score": -1, "selected": false, "text": "d0 = {0:'a', 1:'b', 9:'j'}\nd1 = {'jan':1, 'jul':7, 'dec':12}\nd2 = {'hello':'hola', 'goodbye':'adios', 'happy':'feliz', 'sad':'triste'}\nlst = [d0, d1, d1, d0, d2, d1, d0]\n\ndef dedup( lst):\n id_seen = []\n elems = []\n for elem in lst:\n if id(elem) not in id_seen:\n id_seen.append( id(elem))\n elems.append( elem)\n return elems\n\nprint( dedup( lst))\n" }, { "answer_id": 74336368, "author": "0x0fba", "author_id": 20339407, "author_profile": "https://Stackoverflow.com/users/20339407", "pm_score": 3, "selected": true, "text": "json" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12985084/" ]
74,335,937
<p>I'm using Solr-9.0.0 with Docker on Windows, and I'm trying to index a simple document.</p> <p>The first thing I did is creating a core using docker terminal</p> <p>Then I've renamed <strong>managed-schema.xml</strong> to <strong>schema.xml</strong> then I've added one single line :</p> <pre class="lang-xml prettyprint-override"><code>&lt;field name=&quot;data_field&quot; type=&quot;text_general&quot; indexed=&quot;true&quot; stored=&quot;true&quot; required=&quot;true&quot; multiValued=&quot;false&quot; /&gt; </code></pre> <p>Then I've updated <strong>solrconfig.xml</strong> by adding this line</p> <pre class="lang-xml prettyprint-override"><code>&lt;schemaFactory class=&quot;ClassicIndexSchemaFactory&quot;/&gt; </code></pre> <p>And I've removed those lines from <strong>solrconfig.xml</strong></p> <pre class="lang-xml prettyprint-override"><code>&lt;updateProcessor class=&quot;solr.UUIDUpdateProcessorFactory&quot; name=&quot;uuid&quot;/&gt; &lt;updateProcessor class=&quot;solr.RemoveBlankFieldUpdateProcessorFactory&quot; name=&quot;remove-blank&quot;/&gt; &lt;updateProcessor class=&quot;solr.FieldNameMutatingUpdateProcessorFactory&quot; name=&quot;field-name-mutating&quot;&gt; &lt;str name=&quot;pattern&quot;&gt;[^\w-\.]&lt;/str&gt; &lt;str name=&quot;replacement&quot;&gt;_&lt;/str&gt; &lt;/updateProcessor&gt; &lt;updateProcessor class=&quot;solr.ParseBooleanFieldUpdateProcessorFactory&quot; name=&quot;parse-boolean&quot;/&gt; &lt;updateProcessor class=&quot;solr.ParseLongFieldUpdateProcessorFactory&quot; name=&quot;parse-long&quot;/&gt; &lt;updateProcessor class=&quot;solr.ParseDoubleFieldUpdateProcessorFactory&quot; name=&quot;parse-double&quot;/&gt; &lt;updateProcessor class=&quot;solr.ParseDateFieldUpdateProcessorFactory&quot; name=&quot;parse-date&quot;&gt; &lt;arr name=&quot;format&quot;&gt; &lt;str&gt;yyyy-MM-dd['T'[HH:mm[:ss[.SSS]][z&lt;/str&gt; &lt;str&gt;yyyy-MM-dd['T'[HH:mm[:ss[,SSS]][z&lt;/str&gt; &lt;str&gt;yyyy-MM-dd HH:mm[:ss[.SSS]][z&lt;/str&gt; &lt;str&gt;yyyy-MM-dd HH:mm[:ss[,SSS]][z&lt;/str&gt; &lt;str&gt;[EEE, ]dd MMM yyyy HH:mm[:ss] z&lt;/str&gt; &lt;str&gt;EEEE, dd-MMM-yy HH:mm:ss z&lt;/str&gt; &lt;str&gt;EEE MMM ppd HH:mm:ss [z ]yyyy&lt;/str&gt; &lt;/arr&gt; &lt;/updateProcessor&gt; &lt;updateProcessor class=&quot;solr.AddSchemaFieldsUpdateProcessorFactory&quot; name=&quot;add-schema-fields&quot;&gt; &lt;lst name=&quot;typeMapping&quot;&gt; &lt;str name=&quot;valueClass&quot;&gt;java.lang.String&lt;/str&gt; &lt;str name=&quot;fieldType&quot;&gt;text_general&lt;/str&gt; &lt;lst name=&quot;copyField&quot;&gt; &lt;str name=&quot;dest&quot;&gt;*_str&lt;/str&gt; &lt;int name=&quot;maxChars&quot;&gt;256&lt;/int&gt; &lt;/lst&gt; &lt;!-- Use as default mapping instead of defaultFieldType --&gt; &lt;bool name=&quot;default&quot;&gt;true&lt;/bool&gt; &lt;/lst&gt; &lt;lst name=&quot;typeMapping&quot;&gt; &lt;str name=&quot;valueClass&quot;&gt;java.lang.Boolean&lt;/str&gt; &lt;str name=&quot;fieldType&quot;&gt;booleans&lt;/str&gt; &lt;/lst&gt; &lt;lst name=&quot;typeMapping&quot;&gt; &lt;str name=&quot;valueClass&quot;&gt;java.util.Date&lt;/str&gt; &lt;str name=&quot;fieldType&quot;&gt;pdates&lt;/str&gt; &lt;/lst&gt; &lt;lst name=&quot;typeMapping&quot;&gt; &lt;str name=&quot;valueClass&quot;&gt;java.lang.Long&lt;/str&gt; &lt;str name=&quot;valueClass&quot;&gt;java.lang.Integer&lt;/str&gt; &lt;str name=&quot;fieldType&quot;&gt;plongs&lt;/str&gt; &lt;/lst&gt; &lt;lst name=&quot;typeMapping&quot;&gt; &lt;str name=&quot;valueClass&quot;&gt;java.lang.Number&lt;/str&gt; &lt;str name=&quot;fieldType&quot;&gt;pdoubles&lt;/str&gt; &lt;/lst&gt; &lt;/updateProcessor&gt; &lt;!-- The update.autoCreateFields property can be turned to false to disable schemaless mode --&gt; &lt;updateRequestProcessorChain name=&quot;add-unknown-fields-to-the-schema&quot; default=&quot;${update.autoCreateFields:true}&quot; processor=&quot;uuid,remove-blank,field-name-mutating,parse-boolean,parse-long,parse-double,parse-date,add-schema-fields&quot;&gt; &lt;processor class=&quot;solr.LogUpdateProcessorFactory&quot;/&gt; &lt;processor class=&quot;solr.DistributedUpdateProcessorFactory&quot;/&gt; &lt;processor class=&quot;solr.RunUpdateProcessorFactory&quot;/&gt; &lt;/updateRequestProcessorChain&gt; </code></pre> <p>Then I reloaded the core from the UI</p> <p>Finally and using documents in the UI, I tried to index a docuement :</p> <pre class="lang-json prettyprint-override"><code>{ &quot;id&quot;:&quot;test_id&quot;, &quot;data_field&quot;:&quot;test value to data field&quot; } </code></pre> <p>then I got the following error : <strong>Exception writing document id test_id to the index; possible analysis error.</strong></p> <p>I've tried with other types, string for example and it worked just fine, but I need it to be text_general</p>
[ { "answer_id": 74335952, "author": "chrslg", "author_id": 20037042, "author_profile": "https://Stackoverflow.com/users/20037042", "pm_score": 1, "selected": false, "text": "list({id(x):x for x in lst}.values())\n" }, { "answer_id": 74336325, "author": "user3435121", "author_id": 3435121, "author_profile": "https://Stackoverflow.com/users/3435121", "pm_score": -1, "selected": false, "text": "d0 = {0:'a', 1:'b', 9:'j'}\nd1 = {'jan':1, 'jul':7, 'dec':12}\nd2 = {'hello':'hola', 'goodbye':'adios', 'happy':'feliz', 'sad':'triste'}\nlst = [d0, d1, d1, d0, d2, d1, d0]\n\ndef dedup( lst):\n id_seen = []\n elems = []\n for elem in lst:\n if id(elem) not in id_seen:\n id_seen.append( id(elem))\n elems.append( elem)\n return elems\n\nprint( dedup( lst))\n" }, { "answer_id": 74336368, "author": "0x0fba", "author_id": 20339407, "author_profile": "https://Stackoverflow.com/users/20339407", "pm_score": 3, "selected": true, "text": "json" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13118602/" ]
74,335,969
<pre><code>int main(int argc, char *argv[]) { int fd_src = open(argv[1], O_RDWR); ssize_t size = lseek(fd_src, 0, SEEK_END); char *buf[size]; char *prefix = strcat(argv[1], &quot;_&quot;); for(int i = 0; i &lt; size-1; i++) { lseek(fd_src, i, SEEK_SET); read(fd_src, buf, 1); char *postfix = &amp;buf[0]; char *filename = strcat(prefix, postfix); int fd_dest = open(filename, O_RDWR | O_CREAT | O_EXCL, 0644); write(fd_dest, buf, 1); close(fd_dest); } close(fd_src); return 0; } </code></pre> <p>The input-file &quot;filename&quot; only contains the string &quot;abc&quot;</p> <p>After I run the program, the output looks like that:</p> <p>filename_a // file contains a filename_ab // file contains b filename_abc // file contains c</p> <p>But I would like it to look like that:</p> <p>filename_a // file contains a filename_b // file contains b filename_c // file contains c</p> <p>I have already tried to declare the postfix like that:</p> <p>char *postfix = &amp;buf[i]</p> <p>But that didn't work either. Any suggestions? :)</p>
[ { "answer_id": 74335952, "author": "chrslg", "author_id": 20037042, "author_profile": "https://Stackoverflow.com/users/20037042", "pm_score": 1, "selected": false, "text": "list({id(x):x for x in lst}.values())\n" }, { "answer_id": 74336325, "author": "user3435121", "author_id": 3435121, "author_profile": "https://Stackoverflow.com/users/3435121", "pm_score": -1, "selected": false, "text": "d0 = {0:'a', 1:'b', 9:'j'}\nd1 = {'jan':1, 'jul':7, 'dec':12}\nd2 = {'hello':'hola', 'goodbye':'adios', 'happy':'feliz', 'sad':'triste'}\nlst = [d0, d1, d1, d0, d2, d1, d0]\n\ndef dedup( lst):\n id_seen = []\n elems = []\n for elem in lst:\n if id(elem) not in id_seen:\n id_seen.append( id(elem))\n elems.append( elem)\n return elems\n\nprint( dedup( lst))\n" }, { "answer_id": 74336368, "author": "0x0fba", "author_id": 20339407, "author_profile": "https://Stackoverflow.com/users/20339407", "pm_score": 3, "selected": true, "text": "json" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17796793/" ]
74,335,986
<p>So far I've got this program which asks me to write a sentence, then it splits it one word at a time separated by spaces. The problem is that if I write a 3 word sentence it just prints the first two words. What I'm trying to do is split the sentence with no word limit. I just talked to my teacher and he said I must use the subString method instead of the splitString one. Any ideas?</p> <p>The code:</p> <pre><code>package NF2; import java.util.Scanner; public class Exercici13 { public static void main(String[] args) { //Declaring variables Scanner ent = new Scanner(System.in); String sentence; //LLegim frase System.out.println(&quot;Enter a non-empty text: &quot;); sentence = ent.nextLine(); if(sentence.length() == 0){ System.out.println(&quot;You haven't written anything, exiting the program...&quot;); System.exit(0); } //Separate by spaces String[] splitString = sentence.split(&quot; &quot;); System.out.println(splitString[0]); System.out.println(splitString[1]); } } </code></pre> <p>For example, if I write a 3 word sentence now it only returns me the first two words. Plus I can only use the subString, so I should re-do it all over again and I'm not sure where to start. Keep in mind I'm a total begginner, so it's not okay to use advanced methods.</p>
[ { "answer_id": 74335952, "author": "chrslg", "author_id": 20037042, "author_profile": "https://Stackoverflow.com/users/20037042", "pm_score": 1, "selected": false, "text": "list({id(x):x for x in lst}.values())\n" }, { "answer_id": 74336325, "author": "user3435121", "author_id": 3435121, "author_profile": "https://Stackoverflow.com/users/3435121", "pm_score": -1, "selected": false, "text": "d0 = {0:'a', 1:'b', 9:'j'}\nd1 = {'jan':1, 'jul':7, 'dec':12}\nd2 = {'hello':'hola', 'goodbye':'adios', 'happy':'feliz', 'sad':'triste'}\nlst = [d0, d1, d1, d0, d2, d1, d0]\n\ndef dedup( lst):\n id_seen = []\n elems = []\n for elem in lst:\n if id(elem) not in id_seen:\n id_seen.append( id(elem))\n elems.append( elem)\n return elems\n\nprint( dedup( lst))\n" }, { "answer_id": 74336368, "author": "0x0fba", "author_id": 20339407, "author_profile": "https://Stackoverflow.com/users/20339407", "pm_score": 3, "selected": true, "text": "json" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20431997/" ]
74,335,990
<p>So in a lot of my coding problems, I end up doing something along the lines of:</p> <pre><code>for i in range(10): for j in range(10): for k in range(10): print(i, j, k) </code></pre> <p>I was just wondering if there was a simpler way to iterate through multiple ranges of numbers? I want to have it so I can give an argument of <code>4</code> in my function and it iterates through 4 different numbers.</p> <p>I know that:</p> <pre><code>for i, j in range(10): print(i, j) </code></pre> <p>will iterate through <code>i</code> and <code>j</code> at the same time.</p> <p>Any help would be greatly appreciated!</p>
[ { "answer_id": 74336029, "author": "joanis", "author_id": 3216427, "author_profile": "https://Stackoverflow.com/users/3216427", "pm_score": 2, "selected": false, "text": "itertools.product" }, { "answer_id": 74336149, "author": "user20432160", "author_id": 20432160, "author_profile": "https://Stackoverflow.com/users/20432160", "pm_score": 0, "selected": false, "text": "def loop_fun(loop_number, *args):\n if loop_number:\n for i in range(10):\n loop_fun(loop_number-1, i, *args)\n if loop_number == 1:\n print(*args, i)\n\n\nloop_fun(4)\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74335990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20422229/" ]
74,336,006
<p>So I've been doing some setTimeout and SetInterval in JS just to gain more knowledge. I'm currently trying to create the most simple Stopwatch you've ever seen but it returns <code>NaN</code> when I'm using it. Any ideas how to make it work? I just gave up after 90mins. Youtube and W3School did not help. I have tried changing code a little bit, but nothing helped.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var timeOutStopwatch; // global var to stop multiple functions at once function stopwatch(screenStopwatch, number) { screenStopwatch.innerHTML = --number; if (number &lt; 0) return; timeOutStopwatch = setTimeout(function() { stopwatch(screenStopwatch, number); }, 1000); }; function stopwatchInterval(screenStopwatch, number) { var timeIntervalRef = setInterval(function() { if (--number &lt; 0) { clearInterval(timeIntervalRef); return; } screenStopwatch.innerHTML = number; }, 1000); return timeIntervalRef; }; window.onload = function() { var btnStartStopwatch = document.getElementById("turnOn_stopwatch"); var btnStopStopwatch = document.getElementById("turnOff_stopwatch"); var screenStopwatch = document.getElementById("stopwatch_screen"); var timeIntervalRef; btnStartStopwatch.onclick = function() { var startValue = document.getElementById("start_Value"); screenStopwatch.innerHTML = startValue.value; timeIntervalRef = stopwatchInterval(screenStopwatch, startValue); }; btnStopStopwatch.onclick = function() { clearTimeout(timeIntervalRef); }; };</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>* { padding: 0; margin: 0; } body { background: linear-gradient( 45deg, #2193b0, #6dd5ed); height: 100vh; } #container { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 800px; height: 100px; text-align: center; } input { border-radius: 8px; } #start_Value { background-color: #252525; color: wheat; width: 200px; height: 20px; } #turnOn_stopwatch, #turnOff_stopwatch { background: linear-gradient( 45deg, #cc2b5e, #753a88); opacity: 0.7; width: 100px; color: wheat; } #stopwatch_screen { position: absolute; top: 55%; left: 50%; font-size: 20px; transform: translateX(-50%); }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="container"&gt; &lt;input type="text" id="start_Value"&gt; &lt;input type="button" value="On" id="turnOn_stopwatch"&gt; &lt;input type="button" value="Off" id="turnOff_stopwatch"&gt; &lt;/div&gt; &lt;div id="stopwatch_screen"&gt;&lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74336123, "author": "Bqardi", "author_id": 14647816, "author_profile": "https://Stackoverflow.com/users/14647816", "pm_score": 2, "selected": true, "text": ".value" }, { "answer_id": 74336251, "author": "Andy", "author_id": 1377002, "author_profile": "https://Stackoverflow.com/users/1377002", "pm_score": 0, "selected": false, "text": "if (--number <= 0)" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15952782/" ]
74,336,023
<p>I have a string of type</p> <pre><code>string = &quot;[A] Assam[B] Meghalaya[C] West Bengal[D] Odisha &quot; Output = ['Assam', 'Meghalaya','West Bengal','Odhisa'] </code></pre> <p>I tried many ways, but I always end up splitting the substring West Bengal into two halves... I am not able to cover the edge case mentioned above.</p> <p>What I tried was pass the string into the below function and then split it.. But not working!!!!</p> <pre><code>def remove_alpha(string): option = ['[A]', '[B]', '[C]', '[D]'] res = &quot;&quot; for i in option: res = string.replace(i, '') string = res return res </code></pre>
[ { "answer_id": 74336101, "author": "ShlomiF", "author_id": 5024514, "author_profile": "https://Stackoverflow.com/users/5024514", "pm_score": 0, "selected": false, "text": "[string[string.find(option[i]):string.find(option[i+1])].split(option[i])[1].strip() for i in range(len(option) - 1)] + [string.split(option[-1])[1].strip()]\n" }, { "answer_id": 74336102, "author": "Matiiss", "author_id": 14531062, "author_profile": "https://Stackoverflow.com/users/14531062", "pm_score": 2, "selected": false, "text": "import re\n\nstring = \"[A] Assam[B] Meghalaya[C] West Bengal[D] Odisha \"\npattern = re.compile(r\"] (.*?)(?:\\[|$)\")\n\noutput = pattern.findall(string.strip())\nprint(output)\n# ['Assam', 'Meghalaya', 'West Bengal', 'Odisha']\n" }, { "answer_id": 74336154, "author": "Steven", "author_id": 6543301, "author_profile": "https://Stackoverflow.com/users/6543301", "pm_score": 1, "selected": false, "text": "re.split" }, { "answer_id": 74336599, "author": "Claudio", "author_id": 7711283, "author_profile": "https://Stackoverflow.com/users/7711283", "pm_score": 0, "selected": false, "text": "re.split()" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14713427/" ]
74,336,067
<p>So im reading the below and i understand why you would do it.. <a href="https://jenkov.com/tutorials/java-exception-handling/exception-wrapping.html" rel="nofollow noreferrer">https://jenkov.com/tutorials/java-exception-handling/exception-wrapping.html</a></p> <p>example :</p> <pre><code> try{ dao.readPerson(); } catch (SQLException sqlException) { throw new MyException(&quot;error text&quot;, sqlException); } </code></pre> <p>So what if i want to isolate all external exceptions inside the dao layer only, and only use my exceptions. so in the above example i dont want to send SQLEXception inside the constructor, would doing the below be enough. Would it contain enough information :</p> <pre><code> throw new MyException(&quot;error text&quot;, sqlException); </code></pre> <p>or maybe my constructor should be the following instead</p> <pre><code>public MyException(String text,Exception ex) </code></pre>
[ { "answer_id": 74336101, "author": "ShlomiF", "author_id": 5024514, "author_profile": "https://Stackoverflow.com/users/5024514", "pm_score": 0, "selected": false, "text": "[string[string.find(option[i]):string.find(option[i+1])].split(option[i])[1].strip() for i in range(len(option) - 1)] + [string.split(option[-1])[1].strip()]\n" }, { "answer_id": 74336102, "author": "Matiiss", "author_id": 14531062, "author_profile": "https://Stackoverflow.com/users/14531062", "pm_score": 2, "selected": false, "text": "import re\n\nstring = \"[A] Assam[B] Meghalaya[C] West Bengal[D] Odisha \"\npattern = re.compile(r\"] (.*?)(?:\\[|$)\")\n\noutput = pattern.findall(string.strip())\nprint(output)\n# ['Assam', 'Meghalaya', 'West Bengal', 'Odisha']\n" }, { "answer_id": 74336154, "author": "Steven", "author_id": 6543301, "author_profile": "https://Stackoverflow.com/users/6543301", "pm_score": 1, "selected": false, "text": "re.split" }, { "answer_id": 74336599, "author": "Claudio", "author_id": 7711283, "author_profile": "https://Stackoverflow.com/users/7711283", "pm_score": 0, "selected": false, "text": "re.split()" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1555190/" ]
74,336,075
<p>First we used Terraform to create our resources along with proper tagging. But later we identified that the Admin team performed some manual modifications to the resource as part of some issues quick fixes and all. At the end the terraform state file of these resources are out of sync.</p> <p>Now we have requirement to update the tags of the already provisioned resources (terraform used) with new additional tags to them. When we tried by adding the terraform manifests with the changes for the tagging, and executed terraform plan, and could see that some resources are showing to replace and we are not advised to perform that .</p> <p>We tried to manually import the changes what performed manually from portal, to the terraform state so that we can apply the tag changes from the terraform itself. But we are facing concerns like cant update the resources in minute level from the portal to the state file?</p> <p>is there any automated way to tag a list of azure resources as per the tags specified for each resources. and we can update the state file so easily ?</p>
[ { "answer_id": 74336101, "author": "ShlomiF", "author_id": 5024514, "author_profile": "https://Stackoverflow.com/users/5024514", "pm_score": 0, "selected": false, "text": "[string[string.find(option[i]):string.find(option[i+1])].split(option[i])[1].strip() for i in range(len(option) - 1)] + [string.split(option[-1])[1].strip()]\n" }, { "answer_id": 74336102, "author": "Matiiss", "author_id": 14531062, "author_profile": "https://Stackoverflow.com/users/14531062", "pm_score": 2, "selected": false, "text": "import re\n\nstring = \"[A] Assam[B] Meghalaya[C] West Bengal[D] Odisha \"\npattern = re.compile(r\"] (.*?)(?:\\[|$)\")\n\noutput = pattern.findall(string.strip())\nprint(output)\n# ['Assam', 'Meghalaya', 'West Bengal', 'Odisha']\n" }, { "answer_id": 74336154, "author": "Steven", "author_id": 6543301, "author_profile": "https://Stackoverflow.com/users/6543301", "pm_score": 1, "selected": false, "text": "re.split" }, { "answer_id": 74336599, "author": "Claudio", "author_id": 7711283, "author_profile": "https://Stackoverflow.com/users/7711283", "pm_score": 0, "selected": false, "text": "re.split()" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16092023/" ]
74,336,086
<p>I have this list of dataframes created as follows :</p> <pre><code>df = data.frame(x = c(1,0,0,0,1,1,1,NA), y = c(2,2,2,2,3,3,2,NA), z = c(1:7,NA), m = c(1,2,3,1,2,3,1,NA) ) df$x = factor(df$x) df$y = factor(df$y) df$m = factor(df$m) l1 = list(df$x,df$y,df$m) l2 = lapply(l1,table) l3 = lapply(l2,as.data.frame) l3 </code></pre> <p>The output is as follows :</p> <pre><code>[[1]] Var1 Freq 1 0 3 2 1 4 [[2]] Var1 Freq 1 2 5 2 3 2 [[3]] Var1 Freq 1 1 3 2 2 2 3 3 2 </code></pre> <p>I wish that the names of the variables from the dataframe are assigned autmatically to the l3 list elements. For example : Var1 from list 1 becomes x. Var1 from list 2 becomes y. Var1 from list 3 becomes m. Thanks</p>
[ { "answer_id": 74336205, "author": "B. Christian Kamgang", "author_id": 10848898, "author_profile": "https://Stackoverflow.com/users/10848898", "pm_score": 0, "selected": false, "text": "Map(\\(x,y) setNames(x, c(y,\"Freq\")), l3, c(\"x\", \"y\", \"z\"))\n\n\n[[1]]\n x Freq\n1 0 3\n2 1 4\n\n[[2]]\n y Freq\n1 2 5\n2 3 2\n\n[[3]]\n z Freq\n1 1 3\n2 2 2\n3 3 2\n" }, { "answer_id": 74336231, "author": "jay.sf", "author_id": 6574038, "author_profile": "https://Stackoverflow.com/users/6574038", "pm_score": 2, "selected": true, "text": "Map" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336086", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19720935/" ]
74,336,109
<p>I am working on combining SVG images into one combined SVG image using ReactJS. Sorry you may think that this is duplicate question. But I have checked all the suggested questions but none of them solved my issue. I have done lot of research in fact spent so many days in figuring out solution for this problem.</p> <p>I have checked NodeJS sharp library as well to solve this issue. I know you must be wondering why I am checking NodeJS because I am looking for solution related to ReactJS. I was checking that because my frontend is in ReactJS but my backend is in NodeJS so I thought If I couldn't achieve this in ReactJS then I should try to do same in NodeJS. But I found that sharp library can take input as SVG but not providing output in SVG.</p> <p>Actually I am using NPM package merge-images to create combined image. In this I am passing multiple SVG's and getting output in PNG format as combined image. I am giving my code for reference.</p> <pre><code>import mergeImages from 'merge-images'; const Avatar = (props) =&gt; { const [src, setSrc] = useState(''); useEffect(() =&gt; { let filteredArray = [ { &quot;name&quot;: &quot;skintone&quot;,&quot;src&quot;: &quot;../images/skintone.svg&quot;}, { &quot;name&quot;: &quot;face&quot;,&quot;src&quot;: &quot;../images/face.svg&quot;}, { &quot;name&quot;: &quot;hair&quot;,&quot;src&quot;: &quot;../images/hair.svg&quot;} ]; mergeImages(filteredArray) .then(src =&gt; { //this src is the base64 encoded data of image in PNG format console.log('base64 string', src); setSrc(src); }) .catch(err =&gt; { console.log('Error', err) }); }); return ( { src ? &lt;div&gt;&lt;image src={src} /&gt;&lt;/div&gt; : &lt;div&gt;&lt;p&gt;Image Loading....&lt;/p&gt;&lt;/div&gt; } ) } </code></pre> <p>Above code giving image in PNG format.But I wanted output image in SVG format. So I tried passing MIME format as a parameter like as follows</p> <pre><code>mergeImages(filteredArray, {format: 'image/svg+xml'}) .then(src =&gt; { //this src is the base64 encoded data of image in PNG format console.log('base64 string', src); setSrc(src); }) .catch(err =&gt; { console.log('Error', err) }); </code></pre> <p>But above code also giving output image in PNG format.</p> <p>Please help me in getting output image in SVG format. If possible suggest me any other library through which I can convert combined image in SVG format.</p> <p>Thanks in advance.</p>
[ { "answer_id": 74336205, "author": "B. Christian Kamgang", "author_id": 10848898, "author_profile": "https://Stackoverflow.com/users/10848898", "pm_score": 0, "selected": false, "text": "Map(\\(x,y) setNames(x, c(y,\"Freq\")), l3, c(\"x\", \"y\", \"z\"))\n\n\n[[1]]\n x Freq\n1 0 3\n2 1 4\n\n[[2]]\n y Freq\n1 2 5\n2 3 2\n\n[[3]]\n z Freq\n1 1 3\n2 2 2\n3 3 2\n" }, { "answer_id": 74336231, "author": "jay.sf", "author_id": 6574038, "author_profile": "https://Stackoverflow.com/users/6574038", "pm_score": 2, "selected": true, "text": "Map" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3747792/" ]
74,336,110
<p>I was looking up some unknown book about C++. and faced with this table which title reads.</p> <p>&quot; ― As the result of inheritance all fields of base class are being inherited by derived class.&quot; <em>And then it shows such table.</em> <a href="https://i.stack.imgur.com/HamrQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HamrQ.png" alt="inherited fields in derived class" /></a></p> <p><strong>My question is: Are private fields and functions from base class accessible (as noted in the confusing table) by derived class during private inheritance?</strong></p> <p>I have read <a href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf#section.11.2" rel="nofollow noreferrer">ISO C++ standard</a>, and there is no any mentions about private fields and private inheritance combined, though I have tried myself to find out, and the code behaves as it supposed to. Example I used.</p> <pre><code> #include &lt;iostream&gt; using namespace std; class BASE { private: int x; }; class DERIVED : private BASE { public: void print_X(void){cout &lt;&lt; x &lt;&lt; &quot;\n&quot;;} }; int main() { return 0; } </code></pre> <p>Then compiler error message says:</p> <pre><code>main.cpp:23:36: error: ‘int BASE::x’ is private within this context 23 | void print_X(void){cout &lt;&lt; x &lt;&lt; &quot;\n&quot;;} </code></pre> <p><em>So now I wonder, whether I do something wrong, or the publisher of that book should correct that pages?!</em></p>
[ { "answer_id": 74336205, "author": "B. Christian Kamgang", "author_id": 10848898, "author_profile": "https://Stackoverflow.com/users/10848898", "pm_score": 0, "selected": false, "text": "Map(\\(x,y) setNames(x, c(y,\"Freq\")), l3, c(\"x\", \"y\", \"z\"))\n\n\n[[1]]\n x Freq\n1 0 3\n2 1 4\n\n[[2]]\n y Freq\n1 2 5\n2 3 2\n\n[[3]]\n z Freq\n1 1 3\n2 2 2\n3 3 2\n" }, { "answer_id": 74336231, "author": "jay.sf", "author_id": 6574038, "author_profile": "https://Stackoverflow.com/users/6574038", "pm_score": 2, "selected": true, "text": "Map" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17489971/" ]
74,336,120
<p>I wish to send a call on Tizen5.5 wearable and the closest way I can reach is to open the dialer:</p> <pre><code>app_control_h request = 0; app_control_create(&amp;request); app_control_set_operation(request, APP_CONTROL_OPERATION_CALL); app_control_set_uri(request, &quot;tel:0123456789&quot;); error_code = app_control_send_launch_request(request, NULL, NULL); dlog_print(DLOG_INFO, LOG_TAG, &quot;app_control_send_launch_request: %d&quot;, error_code); app_control_destroy(request); </code></pre> <p>However this always get me <code>-13</code> which is <em>PERMISSION_DENIED</em>. Am I not allowed to launch from service app?</p> <p>Manifest contains:</p> <pre><code>&lt;privilege&gt;http://tizen.org/privilege/call&lt;/privilege&gt; &lt;privilege&gt;http://tizen.org/privilege/appmanager.launch&lt;/privilege&gt; </code></pre>
[ { "answer_id": 74336205, "author": "B. Christian Kamgang", "author_id": 10848898, "author_profile": "https://Stackoverflow.com/users/10848898", "pm_score": 0, "selected": false, "text": "Map(\\(x,y) setNames(x, c(y,\"Freq\")), l3, c(\"x\", \"y\", \"z\"))\n\n\n[[1]]\n x Freq\n1 0 3\n2 1 4\n\n[[2]]\n y Freq\n1 2 5\n2 3 2\n\n[[3]]\n z Freq\n1 1 3\n2 2 2\n3 3 2\n" }, { "answer_id": 74336231, "author": "jay.sf", "author_id": 6574038, "author_profile": "https://Stackoverflow.com/users/6574038", "pm_score": 2, "selected": true, "text": "Map" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1446710/" ]
74,336,130
<p>I'm trying to extract every skill from job_skills to be attribute and encoding it by zero or one , how i can do that ?</p> <p>note : im trying to create a data frame but its not worth to fill the data frame manually (the code is below) , im search for method to extract a list from the column . i need to apply ML algorithms on this data</p> <pre><code>data = [['a', ['Python', 'UI',' Information Technology (IT)','Software Development','GTK','English',' Software Engineering']], ['b', ['Python', 'Relational Databases',' Celery',' VMWare','Django','Continous Integration',' Test Driven Development',' HTTP']], ['c', ['Flask', 'Python',' Celery',' Software Development',' Computer Science','Information Technology (IT)']], ['c', ['Flask', 'Python',' Celery',' Software Development',' Computer Science','Information Technology (IT)']] ] df1= pd.DataFrame(data, columns=['col1', 'col2']) pd.get_dummies(df1['col2'].explode()).groupby(level=0).sum() </code></pre>
[ { "answer_id": 74336356, "author": "Panda Kim", "author_id": 20430449, "author_profile": "https://Stackoverflow.com/users/20430449", "pm_score": 0, "selected": false, "text": "data = [['a', \"['Python', 'UI']\"],\n ['b', \"['Python', 'Celery']\"],\n ['c', \"['Flask', 'Python']\"],\n ['c', \"['Flask', 'Python']\"]]\ndf1= pd.DataFrame(data, columns=['col1', 'col2'])\ndf1\n" }, { "answer_id": 74336390, "author": "Chris", "author_id": 7694824, "author_profile": "https://Stackoverflow.com/users/7694824", "pm_score": 1, "selected": false, "text": "skills = []\n\nrow = []\n\n\n\nfor index, row in df.iterrows():\n for item in row['jobs_skills']:\n row.append(row)\n skills.append(item)\n\ndf = pd.DataFrame({'row': row, 'skills': skills})\n \n" }, { "answer_id": 74336412, "author": "abokey", "author_id": 16120011, "author_profile": "https://Stackoverflow.com/users/16120011", "pm_score": 0, "selected": false, "text": "pandas" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15935940/" ]
74,336,143
<p>I am analyzin lycris and want to remove such words like &quot;la la la&quot;, &quot;na na na&quot;, etc.</p> <p>I want to do that with a list of words and then with the re.sub function. But this also removes eh &quot;na&quot; from words, which starts with na. How can I just remove the strings, which has &quot;na na na na na na na&quot; and &quot;ah-ah ah-ah-ah ah-ah ah-ah ah-ah&quot;</p> <pre><code>lyrics = &quot;say my name say my name drei zwei eins null baby make it rain baby ruf honigtopf tropft bleibe ganze nacht lang online yeah screenshots kopf na na na na na na na baby ruf honigtopf tropft bleibe ganze nacht lang online yeah screenshots kopf na na na na na na na ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah&quot; stopwords = [' na ', ' ah', '-ah', 'yeah'] lyrics = re.sub(r'|'.join(map(re.escape, stopwords )), '', lyrics) </code></pre>
[ { "answer_id": 74336197, "author": "user14901770", "author_id": 14901770, "author_profile": "https://Stackoverflow.com/users/14901770", "pm_score": 0, "selected": false, "text": "lyrics = \"say my name say my name drei zwei eins null baby make it rain baby ruf honigtopf tropft bleibe ganze nacht lang online yeah screenshots kopf na na na na na na na baby ruf honigtopf tropft bleibe ganze nacht lang online yeah screenshots kopf na na na na na na na ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah\"\n\nstopwords = [' na ', ' ah', '-ah', 'yeah']\nfor i in stopwords:\n lyrics.replace(i, '')\n" }, { "answer_id": 74336208, "author": "The Myth", "author_id": 15042008, "author_profile": "https://Stackoverflow.com/users/15042008", "pm_score": 2, "selected": true, "text": "for" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16137299/" ]
74,336,145
<p>In ReactJS I want to call an onClick function on a button to open another website but it doesn't work. The following excerpt of the code is:</p> <pre><code>import PageButton from &quot;./components/PageButton&quot;; const openInNewTab = (url) =&gt; { window.open(url, &quot;_blank&quot;, &quot;noopener,noreferrer&quot;); }; </code></pre> <pre><code>return ( &lt;div className=&quot;App&quot;&gt; &lt;div className=&quot;appNav&quot;&gt; &lt;div className=&quot;my-2 buttonContainer buttonContainerTop&quot;&gt; &lt;PageButton name={&quot;Home&quot;} isBold={true} /&gt; &lt;PageButton name={&quot;Test&quot;} onClick={() =&gt; openInNewTab(&quot;https://www.bing.com/&quot;)} /&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <pre><code>import React from &quot;react&quot;; const PageButton = (props) =&gt; { return ( &lt;div className=&quot;btn&quot;&gt; &lt;span className={props.isBold ? &quot;pageButtonBold hoverBold&quot; : &quot;hoverBold&quot;}&gt; {props.name} &lt;/span&gt; &lt;/div&gt; ); }; export default PageButton; </code></pre> <p>It should open the Webpage when I click on it but it doesn't.</p>
[ { "answer_id": 74336197, "author": "user14901770", "author_id": 14901770, "author_profile": "https://Stackoverflow.com/users/14901770", "pm_score": 0, "selected": false, "text": "lyrics = \"say my name say my name drei zwei eins null baby make it rain baby ruf honigtopf tropft bleibe ganze nacht lang online yeah screenshots kopf na na na na na na na baby ruf honigtopf tropft bleibe ganze nacht lang online yeah screenshots kopf na na na na na na na ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah\"\n\nstopwords = [' na ', ' ah', '-ah', 'yeah']\nfor i in stopwords:\n lyrics.replace(i, '')\n" }, { "answer_id": 74336208, "author": "The Myth", "author_id": 15042008, "author_profile": "https://Stackoverflow.com/users/15042008", "pm_score": 2, "selected": true, "text": "for" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20432225/" ]
74,336,147
<p>I use <code>Hash::make($req-&gt;pass);</code> to login in Laravel. Now I forgot the password. Can I change the password by editing PHPMyAdmin? Is there any PHPMyadmin function to change the Bcrypt?</p> <p>For eg. To change the password stored in MD5, I can change it by using MD5 function. And it works fine for all WordPress logins.</p> <p>Thanks in Advance</p>
[ { "answer_id": 74336197, "author": "user14901770", "author_id": 14901770, "author_profile": "https://Stackoverflow.com/users/14901770", "pm_score": 0, "selected": false, "text": "lyrics = \"say my name say my name drei zwei eins null baby make it rain baby ruf honigtopf tropft bleibe ganze nacht lang online yeah screenshots kopf na na na na na na na baby ruf honigtopf tropft bleibe ganze nacht lang online yeah screenshots kopf na na na na na na na ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah\"\n\nstopwords = [' na ', ' ah', '-ah', 'yeah']\nfor i in stopwords:\n lyrics.replace(i, '')\n" }, { "answer_id": 74336208, "author": "The Myth", "author_id": 15042008, "author_profile": "https://Stackoverflow.com/users/15042008", "pm_score": 2, "selected": true, "text": "for" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16470274/" ]
74,336,169
<p>here is the code of my issue: <a href="https://codepen.io/isaflame/pen/yLEazmM" rel="nofollow noreferrer">https://codepen.io/isaflame/pen/yLEazmM</a></p> <p>html: `</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot;&gt; &lt;head&gt; &lt;meta charset=&quot;utf-8&quot; /&gt; &lt;title&gt;Reservation&lt;/title&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,initial-scale=1&quot; /&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;modal.css&quot; /&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css&quot;&gt; &lt;link href=&quot;https://fonts.googleapis.com/css?family=DM+Sans&quot; rel=&quot;stylesheet&quot; /&gt; &lt;/head&gt; &lt;body&gt; &lt;div class=&quot;topnav&quot; id=&quot;myTopnav&quot;&gt; &lt;div class=&quot;header-logo&quot;&gt; &lt;img alt=&quot;logo&quot; src=&quot;Logo.png&quot; width=&quot;auto&quot; height=&quot;auto&quot; /&gt; &lt;/div&gt; &lt;div class=&quot;main-navbar&quot;&gt; &lt;a href=&quot;#&quot; class=&quot;active&quot;&gt;&lt;span&gt;Accueil&lt;/span&gt;&lt;/a&gt; &lt;a href=&quot;#&quot;&gt;&lt;span&gt;Détails de l'évènement&lt;/span&gt;&lt;/a&gt; &lt;a href=&quot;#&quot;&gt;&lt;span&gt;À propos&lt;/span&gt;&lt;/a&gt; &lt;a href=&quot;#&quot;&gt;&lt;span&gt;Contact&lt;/span&gt;&lt;/a&gt; &lt;a href=&quot;#&quot;&gt;&lt;span&gt;Évènements passés&lt;/span&gt;&lt;/a&gt; &lt;a href=&quot;javascript:void(0);&quot; class=&quot;icon&quot; onclick=&quot;editNav()&quot;&gt; &lt;i class=&quot;fa fa-bars&quot;&gt;&lt;/i&gt; &lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;main&gt; &lt;div class=&quot;hero-section&quot; &gt; &lt;div class=&quot;hero-content&quot;&gt; &lt;h1 class=&quot;hero-headline&quot;&gt; Marathon national&lt;br&gt; de jeux vidéos &lt;/h1&gt; &lt;p class=&quot;hero-text&quot;&gt; Vous aimez jouer ? Notre prochain évènement gaming est ouvert aux réservations... Places limitées ! &lt;/p&gt; &lt;button class=&quot;btn-signup modal-btn&quot;&gt; je m'inscris &lt;/button&gt; &lt;/div&gt; &lt;div class=&quot;hero-img&quot;&gt; &lt;img src=&quot;./bg_img.jpg&quot; alt=&quot;img&quot; /&gt; &lt;/div&gt; &lt;button class=&quot;btn-signup modal-btn&quot;&gt; je m'inscris &lt;/button&gt; &lt;/div&gt; &lt;div class=&quot;bground&quot;&gt;&lt;!--ouverture et fermeture modale en js--&gt; &lt;div class=&quot;content&quot; &gt; &lt;span class=&quot;close&quot; onclick = closeModal()&gt;&lt;/span&gt; &lt;div class=&quot;modal-body&quot;&gt; &lt;!--ajout id tag &quot;reserve&quot;pour le formulaire--&gt; &lt;form name=&quot;reserve&quot; id=&quot;reserve&quot; action=&quot;index.html&quot; method=&quot;get&quot;&gt; &lt;div class=&quot;formData&quot;&gt; &lt;label&gt;Prénom&lt;/label&gt;&lt;br&gt; &lt;input class=&quot;text-control&quot; type=&quot;text&quot; id=&quot;first&quot; name=&quot;first&quot; minlength=&quot;2&quot; &gt; &lt;/div&gt; &lt;div class=&quot;formData&quot;&gt; &lt;label&gt;Nom&lt;/label&gt;&lt;br&gt; &lt;input class=&quot;text-control&quot; type=&quot;text&quot; id=&quot;last&quot; name=&quot;last&quot; /&gt;&lt;br&gt; &lt;/div&gt; &lt;div class=&quot;formData&quot;&gt; &lt;label&gt;E-mail&lt;/label&gt;&lt;br&gt; &lt;input class=&quot;text-control&quot; type=&quot;email&quot; id=&quot;email&quot; name=&quot;email&quot; /&gt;&lt;br&gt; &lt;/div&gt; &lt;!--le navigateur comprend la date et affiche un calendrier--&gt; &lt;div class=&quot;formData&quot;&gt; &lt;label&gt;Date de naissance&lt;/label&gt;&lt;br&gt; &lt;input class=&quot;text-control&quot; type=&quot;date&quot; id=&quot;birthdate&quot; name=&quot;birthdate&quot; /&gt;&lt;br&gt; &lt;/div&gt; &lt;div class=&quot;formData&quot;&gt; &lt;label&gt;À combien de tournois GameOn avez-vous déjà participé ?&lt;/label&gt;&lt;br&gt; &lt;input type=&quot;number&quot; class=&quot;text-control&quot; id=&quot;quantity&quot; name=&quot;quantity&quot; min=&quot;0&quot; max=&quot;99&quot;&gt; &lt;/div&gt; &lt;p class=&quot;text-label&quot;&gt;A quel tournoi souhaitez-vous participer cette année ?&lt;/p&gt; &lt;div class=&quot;formData&quot;&gt; &lt;input class=&quot;checkbox-input&quot; type=&quot;radio&quot; id=&quot;location1&quot; name=&quot;location&quot; value=&quot;New York&quot; /&gt; &lt;label class=&quot;checkbox-label&quot; for=&quot;location1&quot;&gt; &lt;span class=&quot;checkbox-icon&quot;&gt;&lt;/span&gt; New York&lt;/label &gt; &lt;input class=&quot;checkbox-input&quot; type=&quot;radio&quot; id=&quot;location2&quot; name=&quot;location&quot; value=&quot;San Francisco&quot; /&gt; &lt;label class=&quot;checkbox-label&quot; for=&quot;location2&quot;&gt; &lt;span class=&quot;checkbox-icon&quot;&gt;&lt;/span&gt; San Francisco&lt;/label &gt; &lt;input class=&quot;checkbox-input&quot; type=&quot;radio&quot; id=&quot;location3&quot; name=&quot;location&quot; value=&quot;Seattle&quot; /&gt; &lt;label class=&quot;checkbox-label&quot; for=&quot;location3&quot;&gt; &lt;span class=&quot;checkbox-icon&quot;&gt;&lt;/span&gt; Seattle&lt;/label &gt; &lt;input class=&quot;checkbox-input&quot; type=&quot;radio&quot; id=&quot;location4&quot; name=&quot;location&quot; value=&quot;Chicago&quot; /&gt; &lt;label class=&quot;checkbox-label&quot; for=&quot;location4&quot;&gt; &lt;span class=&quot;checkbox-icon&quot;&gt;&lt;/span&gt; Chicago&lt;/label &gt; &lt;input class=&quot;checkbox-input&quot; type=&quot;radio&quot; id=&quot;location5&quot; name=&quot;location&quot; value=&quot;Boston&quot; /&gt; &lt;label class=&quot;checkbox-label&quot; for=&quot;location5&quot;&gt; &lt;span class=&quot;checkbox-icon&quot;&gt;&lt;/span&gt; Boston&lt;/label &gt; &lt;input class=&quot;checkbox-input&quot; type=&quot;radio&quot; id=&quot;location6&quot; name=&quot;location&quot; value=&quot;Portland&quot; /&gt; &lt;label class=&quot;checkbox-label&quot; for=&quot;location6&quot;&gt; &lt;span class=&quot;checkbox-icon&quot;&gt;&lt;/span&gt; Portland&lt;/label &gt; &lt;br&gt;&lt;small&gt;&lt;/small&gt; &lt;/div&gt; &lt;div class=&quot;formData&quot;&gt; &lt;input class=&quot;checkbox-input&quot; type=&quot;checkbox&quot; id=&quot;checkbox1&quot; checked /&gt; &lt;label class=&quot;checkbox2-label&quot; for=&quot;checkbox1&quot; required&gt; &lt;span class=&quot;checkbox-icon&quot;&gt;&lt;/span&gt; J'ai lu et accepté les conditions d'utilisation. &lt;/label&gt; &lt;br&gt; &lt;small&gt;&lt;/small&gt; &lt;input class=&quot;checkbox-input&quot; type=&quot;checkbox&quot; id=&quot;checkbox2&quot; /&gt; &lt;label class=&quot;checkbox2-label&quot; for=&quot;checkbox2&quot;&gt; &lt;span class=&quot;checkbox-icon&quot;&gt;&lt;/span&gt; Je souhaite être prévenu des prochains évènements. &lt;/label&gt; &lt;br&gt; &lt;/div&gt; &lt;input class=&quot;btn-submit&quot; type=&quot;submit&quot; class=&quot;button&quot; value=&quot;C'est parti&quot; /&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt;&lt;!--fin content --&gt; &lt;/div&gt; &lt;/main&gt; &lt;footer&gt; &lt;p class=&quot;copyrights&quot;&gt; Copyright 2014 - 2022, GameOn Inc. &lt;/p&gt; &lt;/footer&gt; &lt;script src= &quot;modal.js&quot;&gt;&lt;/script&gt; &lt;script src=&quot;https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js&quot;&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><code>css: </code></p> <pre><code>:root { --font-default: &quot;DM Sans&quot;, Arial, Helvetica, sans-serif; --font-slab: var(--font-default); --modal-duration: 0.8s; } * { box-sizing: border-box; margin: 0; padding: 0; } /* Landing Page */ body { margin: 0; display: flex; flex-direction: column; background-image: url(&quot;background.png&quot;); font-family: var(--font-default); font-size: 18px; max-width: 1300px; margin: 0 auto; } p { margin-bottom: 0; padding: 0.5vw; } img { padding-right: 1rem; } .topnav { overflow: hidden; margin: 3.5%; } .header-logo { float: left; } .main-navbar { float: right; } .topnav a { float: left; display: block; color: #000000; text-align: center; padding: 12px 12px; margin: 5px; text-decoration: none; font-size: 20px; font-family: Roboto, sans-serif; } .topnav a:hover { background-color: #ff0000; color: #ffffff; border-radius: 15px; } .topnav a.active { background-color: #ff0000; color: #ffffff; border-radius: 15px; } .topnav .icon { display: none; } @media screen and (max-width: 768px) { .topnav a {display: none;} .topnav a.icon { float: right; display: block; } } @media screen and (max-width: 768px) { .topnav.responsive {position: relative;} .topnav.responsive .icon { position: absolute; right: 0; top: 0; } .topnav.responsive a { float: none; display: block; text-align: left; } } @media screen and (max-width: 540px) { .topnav a {display: none;} .topnav a.icon { float: right; display: block; margin-top: -15px; } } main { font-size: 130%; font-weight: bolder; color: black; padding-top: 0.5vw; padding-left: 2vw; padding-right: 2vw; margin: 1px 20px 15px; border-radius: 2rem; text-align: justify; } .modal-btn { font-size: 145%; background: #fe142f; display: flex; margin: auto; padding: 2em; color: #fff; padding: 0.75rem 2.5rem; border-radius: 1rem; cursor: pointer; } .modal-btn:hover { background: #3876ac; } .footer { margin: 20px; padding: 10px; font-family: var(--font-slab); } /* Modal form */ .button { background: #fe142f; margin-top: 0.5em; padding: 1em; color: #fff; border-radius: 15px; cursor: pointer; font-size: 16px; } .button:hover { background: #3876ac; } .smFont { font-size: 16px; } .bground { display: none; position: fixed; z-index: 1; left: 0; top: 0; height: 100%; width: 100%; overflow: auto; background-color: rgba(26, 39, 156, 0.4); } .content { margin: 5% auto; width: 100%; max-width: 500px; animation-name: modalopen; animation-duration: var(--modal-duration); background: #232323; border-radius: 10px; overflow: hidden; position: relative; color: #fff; padding-top: 10px; } .modal-body { padding: 15px 8%; margin: 15px auto; } label { font-family: var(--font-default); font-size: 17px; font-weight: normal; display: inline-block; margin-bottom: 11px; } input { padding: 8px; border: 0.8px solid #ccc; outline: none; } .text-control { margin: 0; padding: 8px; width: 100%; border-radius: 8px; font-size: 20px; height: 48px; } .formData[data-error]::after { content: attr(data-error); font-size: 0.4em; color: #e54858; display: block; margin-top: 7px; margin-bottom: 7px; text-align: right; line-height: 0.3; opacity: 0; transition: 0.3s; } .formData[data-error-visible=&quot;true&quot;]::after { opacity: 1; } .formData[data-error-visible=&quot;true&quot;] .text-control { border: 2px solid #e54858; } /* input[data-error]::after { content: attr(data-error); font-size: 0.4em; color: red; } */ .checkbox-label, .checkbox2-label { position: relative; margin-left: 36px; font-size: 12px; font-weight: normal; } .checkbox-label .checkbox-icon, .checkbox2-label .checkbox-icon { display: block; width: 20px; height: 20px; border: 2px solid #279e7a; border-radius: 50%; text-indent: 29px; white-space: nowrap; position: absolute; left: -30px; top: -1px; transition: 0.3s; } .checkbox-label .checkbox-icon::after, .checkbox2-label .checkbox-icon::after { content: &quot;&quot;; width: 13px; height: 13px; background-color: #279e7a; border-radius: 50%; text-indent: 29px; white-space: nowrap; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); transition: 0.3s; opacity: 0; } .checkbox-input { display: none; } .checkbox-input:checked + .checkbox-label .checkbox-icon::after, .checkbox-input:checked + .checkbox2-label .checkbox-icon::after { opacity: 1; } .checkbox-input:checked + .checkbox2-label .checkbox-icon { background: #279e7a; } .checkbox2-label .checkbox-icon { border-radius: 4px; border: 0; background: #c4c4c4; } .checkbox2-label .checkbox-icon::after { width: 7px; height: 4px; border-radius: 2px; background: transparent; border: 2px solid transparent; border-bottom-color: #fff; border-left-color: #fff; transform: rotate(-55deg); left: 21%; top: 19%; } .close { position: absolute; right: 15px; top: 15px; width: 32px; height: 32px; opacity: 1; cursor: pointer; transform: scale(0.7); } .close:before, .close:after { position: absolute; left: 15px; content: &quot; &quot;; height: 33px; width: 3px; background-color: #fff; } .close:before { transform: rotate(45deg); } .close:after { transform: rotate(-45deg); } .btn-submit, .btn-signup { background: #fe142f; display: block; margin: 0 auto; border-radius: 7px; font-size: 1rem; padding: 12px 82px; color: #fff; cursor: pointer; border: 0; } /* custom select styles */ .custom-select { position: relative; font-family: Arial; font-size: 1.1rem; font-weight: normal; } .custom-select select { display: none; } .select-selected { background-color: #fff; } /* Style the arrow inside the select element: */ .select-selected:after { position: absolute; content: &quot;&quot;; top: 10px; right: 13px; width: 11px; height: 11px; border: 3px solid transparent; border-bottom-color: #f00; border-left-color: #f00; transform: rotate(-48deg); border-radius: 5px 0 5px 0; } /* Point the arrow upwards when the select box is open (active): */ .select-selected.select-arrow-active:after { transform: rotate(135deg); top: 13px; } .select-items div, .select-selected { color: #000; padding: 11px 16px; border: 1px solid transparent; border-color: transparent transparent rgba(0, 0, 0, 0.1) transparent; cursor: pointer; border-radius: 8px; height: 48px; } /* Style items (options): */ .select-items { position: absolute; background-color: #fff; top: 89%; left: 0; right: 0; z-index: 99; } /* Hide the items when the select box is closed: */ .select-hide { display: none; } .select-items div:hover, .same-as-selected { background-color: rgba(0, 0, 0, 0.1); } /* custom select end */ .text-label { font-weight: normal; font-size: 16px; } .hero-section { min-height: 93vh; border-radius: 10px; display: grid; grid-template-columns: repeat(12, 1fr); overflow: hidden; box-shadow: 0 2px 7px 2px rgba(0, 0, 0, 0.2); margin-bottom: 10px; } .hero-content { padding: 51px 67px; grid-column: span 4; background: #232323; color: #fff; position: relative; text-align: left; min-width: 424px; } .hero-content::after { content: &quot;&quot;; width: 100%; height: 100%; background: #232323; position: absolute; right: -80px; top: 0; } .hero-content &gt; * { position: relative; z-index: 1; } .hero-headline { font-size: 6rem; font-weight: normal; white-space: nowrap; } .hero-text { width: 146%; font-weight: normal; margin-top: 57px; padding: 0; } .btn-signup { outline: none; text-transform: capitalize; font-size: 1.3rem; padding: 15px 23px; margin: 0; margin-top: 59px; } .hero-img { grid-column: span 8; } .hero-img img { width: 100%; height: 100%; display: block; padding: 0; } .copyrights { color: #fe142f; padding: 0; font-size: 1rem; margin: 60px 0 30px; font-weight: bolder; } .hero-section &gt; .btn-signup { display: none; } footer { padding-left: 2vw; padding-right: 2vw; margin: 0 20px; } @media screen and (max-width: 800px) { .hero-section { display: block; box-shadow: unset; } .hero-content { background: #fff; color: #000; padding: 20px; } .hero-content::after { content: unset; } .hero-content .btn-signup { display: none; } .hero-headline { font-size: 4.5rem; white-space: normal; } .hero-text { width: unset; font-size: 1.5rem; } .hero-img img { border-radius: 10px; margin-top: 40px; } .hero-section &gt; .btn-signup { display: block; margin: 32px auto 10px; padding: 12px 35px; } .copyrights { margin-top: 50px; text-align: center; } } @keyframes modalopen { from { opacity: 0; transform: translateY(-150px); } to { opacity: 1; } } </code></pre> <p><code>javascript: </code></p> <pre><code>function editNav() { var x = document.getElementById(&quot;myTopnav&quot;); if (x.className === &quot;topnav&quot;) { x.className += &quot; responsive&quot;; } else { x.className = &quot;topnav&quot;; } } // DOM Elements const modalbg = document.querySelector(&quot;.bground&quot;); const modalBtn = document.querySelectorAll(&quot;.modal-btn&quot;); const formData = document.querySelectorAll(&quot;.formData&quot;); const modalBody = document.querySelector(&quot;.modal-body&quot;); const form = document.getElementById(&quot;reserve&quot;); const firstName = document.getElementById(&quot;first&quot;); const lastName = document.getElementById(&quot;last&quot;); const email = document.getElementById(&quot;email&quot;); const birthdate = document.getElementById(&quot;birthdate&quot;); const quantity = document.getElementById(&quot;quantity&quot;); /* nombre de tournois*/ const city = document.getElementsByName(&quot;location&quot;); // launch modal form function launchModal() { modalbg.style.display = &quot;block&quot;; } // launch modal event modalBtn.forEach((btn) =&gt; btn.addEventListener(&quot;click&quot;, launchModal)); // close modal form and reset datas in the form function closeModal() { modalbg.style.display = &quot;none&quot;; form.reset(); } //close modal event //modalBtn.forEach((btn) =&gt; btn.addEventListener(&quot;click&quot;, closeModal)); /*form.addEventListener( &quot;submit&quot;, validateForm ); /* when submit form =&gt; function validateform start*/ // fonction validation du formulaire. /*si validatefrom n'est pas retournée, alors fonction greetings est lancée*/ function validateForm(event) { event.preventDefault(); event.stopPropagation(); if ( !validateFirstName() &amp;&amp; !validateLastName() &amp;&amp; !validateEmail() &amp;&amp; !validateRadio() &amp;&amp; !validateTournament() &amp;&amp; !validateDate() ) return; /* removeEventListener(&quot;submit&quot;, greetings())*/ } /* formIsValid(); function formIsValid() { if (!validateForm()) { greetings(); } } */ //!!!! reste le rechargement de la modale avec message de remerciement function greetings() { form.innerHTML = /*html*/ `&lt;div class =&quot;content&quot;&gt; Merci pour votre &lt;br&gt;inscription&lt;/div&gt; &lt;button class=&quot;btn-submit&quot; onclick= &quot;closeModal()&quot;&gt; Fermer &lt;/button&gt;`; } /** * fonction validation du prénom et message erreur OK!! * * @return {Boolean} true si valide sinon false */ function validateFirstName() { const regexFirstName = /^[A-Z a-z]{2,25}$/; /*min 2 caracteres*/ const parent = document.getElementById(&quot;first&quot;).parentNode; if (firstName.value == &quot;&quot; || !regexFirstName.test(firstName.value)) { firstName.focus(); parent.setAttribute(&quot;data-error&quot;, &quot;Veuillez entrez un prénom valide&quot;); parent.setAttribute(&quot;data-error-visible&quot;, &quot;true&quot;); return false; } parent.setAttribute(&quot;data-error-visible&quot;, &quot;false&quot;); return true; } //fonction validation du nom et message erreur OK!!! function validateLastName() { const regexLastName = /^[A-Z a-z]{2,25}$/; /*min 2 caracteres*/ const parent = document.getElementById(&quot;last&quot;).parentNode; console.log(parent, &quot;parent1&quot;); if (lastName.value == &quot;&quot; || !regexLastName.test(lastName.value)) { lastName.focus(); parent.setAttribute(&quot;data-error&quot;, &quot;Veuillez entrez un nom valide&quot;); parent.setAttribute(&quot;data-error-visible&quot;, &quot;true&quot;); return false; } parent.setAttribute(&quot;data-error-visible&quot;, &quot;false&quot;); return true; } //fonction validation du courriel et message erreur OK!!! function validateEmail() { const regexEmail = /^[a-zA-Z][a-zA-Z0-9\-\_\.]+@[a-zA-Z0-9]{2,}\.[a-zA-Z0-9]{2,}$/; const parent = document.getElementById(&quot;email&quot;).parentNode; console.log(parent, &quot;parent2&quot;); console.log(email.value); if (email.value == &quot;&quot; || !regexEmail.test(email.value)) { email.focus(); parent.setAttribute(&quot;data-error&quot;, &quot;Veuillez entrez un courriel valide&quot;); parent.setAttribute(&quot;data-error-visible&quot;, &quot;true&quot;); return false; } parent.setAttribute(&quot;data-error-visible&quot;, &quot;false&quot;); return true; } function setDateLimits() { const dateToday = new Date(); // console.log (dateToday); const day = dateToday.getDate(); /* jour du mois en cours */ // console.log (day); const month = dateToday.getMonth() + 1; /* mois de l'année en cours&quot;+1&quot; car renvoie &quot;0&quot; pour janvier*/ // console.log (month); const year = dateToday.getFullYear(); /* année en cours*/ // console.log (year); let date = new Date(`${year - 18}-${month}-${day}`) .toISOString() .split(&quot;T&quot;)[0]; console.log(birthdate, date); birthdate.setAttribute(&quot;max&quot;, date); date = new Date(`${year - 100}-${month}-${day}`).toISOString().split(&quot;T&quot;)[0]; console.log(birthdate, date); birthdate.setAttribute(&quot;min&quot;, date); } function validateDate() { const parent = birthdate.parentNode; let isValid = true; const selectedDate = new Date(birthdate.value); const dateToday = new Date(); const day = dateToday.getDate(); /* jour du mois en cours */ const month = dateToday.getMonth() + 1; /* mois de l'année en cours&quot;+1&quot; car renvoie &quot;0&quot; pour janvier*/ const year = dateToday.getFullYear(); /* année en cours*/ let date = new Date(`${year - 18}-${month}-${day}`); if (selectedDate &gt; date) { isValid = false; } else { date = new Date(`${year - 100}-${month}-${day}`); if (selectedDate &lt; date) { isValid = false; } } if (!isValid) { birthdate.focus(); parent.setAttribute(&quot;data-error&quot;, &quot;Veuillez entrez une date valide&quot;); parent.setAttribute(&quot;data-error-visible&quot;, &quot;true&quot;); return false; } parent.setAttribute(&quot;data-error-visible&quot;, &quot;false&quot;); return true; } console.log(quantity.value); //validation du champ nombre de tournois OK!!! function validateTournament() { const quantityTournament = document.querySelector(&quot;input[name='quantity']&quot;); const parent = document .querySelector(`input[name='quantity']`) .closest(`.formData`); console.log(parent); if (quantityTournament.value == &quot;&quot; || null) { quantity.focus(); parent.setAttribute(&quot;data-error&quot;, &quot;Veuillez entrez un nombre&quot;); parent.setAttribute(&quot;data-error-visible&quot;, &quot;true&quot;); return false; } parent.setAttribute(&quot;data-error-visible&quot;, &quot;false&quot;); return true; } // fonction validation de la ville (bouton radio) OK!! function validateRadio() { const checkradio = document.querySelector(&quot;input[name='location']:checked&quot;); const parent = document .querySelector(`input[name='location']`) .closest(`.formData`); console.log(parent, &quot;parent&quot;); if (checkradio != null) { //Teste si une ville est cochée parent.setAttribute(&quot;data-error-visible&quot;, &quot;false&quot;); return true; } parent.setAttribute(&quot;data-error&quot;, &quot;Veuillez choisir une ville&quot;); parent.setAttribute(&quot;data-error-visible&quot;, &quot;true&quot;); return false; } setDateLimits(); </code></pre> <p>` i want to close the modal if the user click on the cross (succeed), outside of the modal window (i do not find a solution). As well, i have this problem: i have created a function called &quot;grettings&quot; in order that when the form in the modal is filled, the user click on the button, then greetings function is launched and insert a greeting message in the modal... i do not find any solution for that.</p> <p>i have tried to add add a condition (lines 63 to 66 in modal.js file) like &quot;when the form is filled and validate, then, launch the greetings function.. but it daes not work. Anyone can help? thank you in advance;</p>
[ { "answer_id": 74336197, "author": "user14901770", "author_id": 14901770, "author_profile": "https://Stackoverflow.com/users/14901770", "pm_score": 0, "selected": false, "text": "lyrics = \"say my name say my name drei zwei eins null baby make it rain baby ruf honigtopf tropft bleibe ganze nacht lang online yeah screenshots kopf na na na na na na na baby ruf honigtopf tropft bleibe ganze nacht lang online yeah screenshots kopf na na na na na na na ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah\"\n\nstopwords = [' na ', ' ah', '-ah', 'yeah']\nfor i in stopwords:\n lyrics.replace(i, '')\n" }, { "answer_id": 74336208, "author": "The Myth", "author_id": 15042008, "author_profile": "https://Stackoverflow.com/users/15042008", "pm_score": 2, "selected": true, "text": "for" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20407217/" ]
74,336,186
<p>I have a spring boot app in which I have added another library (in pom.xml).</p> <p>This library is also a spring boot library which has created some beans and made the beans available using @Bean. The code snippet in 3rd party library is like this :</p> <pre><code>@Bean public CustomObject customObject() { return new CustomObject(); } </code></pre> <p>Now, I am using this library in my application, but I dont see this bean registered with my application. I checked all the beans registered with application Context and also tried loading from application context. But no luck.</p> <p>What am I missing here? The purpose of this 3rd party library is to check some config and create this bean, so if I have to manually create this bean, it takes away the whole purpose.</p>
[ { "answer_id": 74336197, "author": "user14901770", "author_id": 14901770, "author_profile": "https://Stackoverflow.com/users/14901770", "pm_score": 0, "selected": false, "text": "lyrics = \"say my name say my name drei zwei eins null baby make it rain baby ruf honigtopf tropft bleibe ganze nacht lang online yeah screenshots kopf na na na na na na na baby ruf honigtopf tropft bleibe ganze nacht lang online yeah screenshots kopf na na na na na na na ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah ah-ah ah-ah ah-ah-ah\"\n\nstopwords = [' na ', ' ah', '-ah', 'yeah']\nfor i in stopwords:\n lyrics.replace(i, '')\n" }, { "answer_id": 74336208, "author": "The Myth", "author_id": 15042008, "author_profile": "https://Stackoverflow.com/users/15042008", "pm_score": 2, "selected": true, "text": "for" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3610891/" ]
74,336,187
<p>This piece of code will print <code>[1,2,3,4,5,6,7,8,9,10]</code> on the console it means in every iteration arr.length change and this is reflected in the loop body also.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>let arr = [1, 2, 3]; for (e of arr) { arr.push(arr[arr.length - 1] + 1); if (arr.length &gt;= 10) break; } console.log(arr)</code></pre> </div> </div> </p> <p>But here, The output will be <code>[4,5,6]</code> and that mean the shift() function is not considering the expansion of the array.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>let arr = [1, 2, 3]; for (e of arr) { arr.push(arr[arr.length - 1] + 1); if (arr[arr.length - 1] &gt;= 10) break; arr.shift(); } console.log(arr)</code></pre> </div> </div> </p> <p>My question is why? I expected <code>[8,9,10]</code> output from second code</p>
[ { "answer_id": 74336307, "author": "flyingfox", "author_id": 3176419, "author_profile": "https://Stackoverflow.com/users/3176419", "pm_score": 3, "selected": true, "text": "shift()" }, { "answer_id": 74336355, "author": "damonholden", "author_id": 17670742, "author_profile": "https://Stackoverflow.com/users/17670742", "pm_score": 1, "selected": false, "text": "for ...of" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1035784/" ]
74,336,198
<p>In PHP, I've created a function to create a JSON file:</p> <pre><code>function writeJSONData(PDO $conn): void { $contentJSON = &quot;SELECT * FROM tb_content&quot;; $contentResultsJSON = $conn-&gt;query($contentJSON); $contentJSONExt = array(); while ($JSON = $contentResultsJSON-&gt;fetchAll(PDO::FETCH_ASSOC)) { $contentJSONExt = $JSON; } $infoJSON[] = json_encode(array('movies' =&gt; $contentJSONExt)); $target_dir = $_SERVER['DOCUMENT_ROOT'] . &quot;/CineFlex/private/api/api.json&quot;; file_put_contents($target_dir, $infoJSON); } </code></pre> <p>In my HTML file I've created a button which sends the ID of the selected movie:</p> <pre><code>&lt;!-- Edit Button --&gt; &lt;button onclick=&quot;toggleDialog(editMovie, this.id)&quot; id=&quot;&lt;?php echo($info['content_id']) ?&gt;Edit Movie&lt;/button&gt; </code></pre> <p>My JavaScript file contains the function:</p> <pre><code>// Toggle Dialog function toggleDialog(dialogName, dialogID) { // Toggle Dialog Visibility $(dialogName).fadeToggle(200); $.getJSON(&quot;./private/api/api.json&quot;, function (data) { console.log(data) }) } </code></pre> <p>When I click on the edit button, it prints the entire JSON file in the console. Which is understandable.</p> <p>Current output:</p> <pre><code>{ &quot;movies&quot;: [ { &quot;content_id&quot;: 15, &quot;title&quot;: &quot;Scream (2022)&quot;, &quot;description&quot;: &quot;25 years after a streak of brutal murders shocked the quiet town of Woodsboro, Calif., a new killer dons the Ghostface mask and begins targeting a group of teenagers to resurrect secrets from the town's deadly past.&quot; }, { &quot;content_id&quot;: 16, &quot;title&quot;: &quot;Fear Street: Part Two - 1978&quot;, &quot;description&quot;: &quot;Shadyside, 1978. School's out for summer and the activities at Camp Nightwing are about to begin. But when another Shadysider is possessed with the urge to kill, the fun in the sun becomes a gruesome fight for survival.&quot; }, { &quot;content_id&quot;: 17, &quot;title&quot;: &quot;Archive 81&quot;, &quot;description&quot;: &quot;An archivist hired to restore a collection of tapes finds himself reconstructing the work of a filmmaker and her investigation into a dangerous cult.&quot; } ] } </code></pre> <p>Now my issue is, I want the &quot;dialogID&quot; to be selected from the JSON file where it matches with &quot;content_id&quot;. For example: When I click on a movie with 16 as &quot;dialogID&quot;, I want the console to just print everything from that array.</p> <p>Expected output:</p> <pre><code>{ &quot;movies&quot;: [ { &quot;content_id&quot;: 16, &quot;title&quot;: &quot;Fear Street: Part Two - 1978&quot;, &quot;description&quot;: &quot;Shadyside, 1978. School's out for summer and the activities at Camp Nightwing are about to begin. But when another Shadysider is possessed with the urge to kill, the fun in the sun becomes a gruesome fight for survival.&quot; } ] } </code></pre>
[ { "answer_id": 74336307, "author": "flyingfox", "author_id": 3176419, "author_profile": "https://Stackoverflow.com/users/3176419", "pm_score": 3, "selected": true, "text": "shift()" }, { "answer_id": 74336355, "author": "damonholden", "author_id": 17670742, "author_profile": "https://Stackoverflow.com/users/17670742", "pm_score": 1, "selected": false, "text": "for ...of" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20432185/" ]
74,336,232
<p>I have this dataframe (but let's imagine it very big)</p> <pre><code>df = data.frame(x = c(1,0,0,0,1,1,1,NA), y = c(2,2,2,2,3,3,2,NA), z = c(1:7,NA), m = c(1,2,3,1,2,3,1,NA) ) df$x = factor(df$x) df$y = factor(df$y) df$m = factor(df$m) </code></pre> <p>and I wish to create a list that looks like as follows</p> <pre><code>l1 = list(df$x,df$y,df$z,df$m) </code></pre> <p>with the resulted output as follows :</p> <pre><code>[[1]] [1] 1 0 0 0 1 1 1 &lt;NA&gt; Levels: 0 1 [[2]] [1] 2 2 2 2 3 3 2 &lt;NA&gt; Levels: 2 3 [[3]] [1] 1 2 3 4 5 6 7 NA [[4]] [1] 1 2 3 1 2 3 1 &lt;NA&gt; Levels: 1 2 3 </code></pre> <p>would appreciate the help</p>
[ { "answer_id": 74336254, "author": "jay.sf", "author_id": 6574038, "author_profile": "https://Stackoverflow.com/users/6574038", "pm_score": 3, "selected": true, "text": "as.list" }, { "answer_id": 74337753, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 1, "selected": false, "text": "c" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19720935/" ]
74,336,260
<p>I am working in R where I have a dataframe with one character variable V1 that contains a lot of different strings. I want to find dates in format dd.mm.yy or dd.mm.yyyy in this column using grepl. My dataset includes, among other things</p> <pre><code>V1 00101230311200022 73.11.22 15:19 </code></pre> <p>My date is 73.11.22. Of course it should be 03.11.22 or something like that, so I would like to first extract it and then get an error message because it’s an incorrect date.</p> <p>I tried:</p> <pre><code>grepl(“[0-9]{2}.[0-9]{2}.[0-9]{2}”, x = df[,1]) </code></pre> <p>but I get the positions of both rows. Thanks for any help.</p>
[ { "answer_id": 74336254, "author": "jay.sf", "author_id": 6574038, "author_profile": "https://Stackoverflow.com/users/6574038", "pm_score": 3, "selected": true, "text": "as.list" }, { "answer_id": 74337753, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 1, "selected": false, "text": "c" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332100/" ]
74,336,283
<p>I have a front end (angular) with login form, a back-end for that angular application as my OAuth client (spring dependency) then I have a third application that is the Authorization server and finally the forth is the ressources server.</p> <p>So I want to know is there is any way to jump the redirect to /login from the authorization server?</p> <p>I want to login the user with angular login page, then make a get with my OAuth client (spring) for the authorization code flow and then, since i'm not authenticated, instead of getting redirect, I want to get an error &quot;401&quot; and then send a post request with my OAuth client (spring) to the auth server again to login the user that have sent the data previously in angular login page.</p> <p>Essentially I just wanted to login to my auth server with a custom page that exists in the front end application and let the backend build specially for that front, take over the flow.</p>
[ { "answer_id": 74336254, "author": "jay.sf", "author_id": 6574038, "author_profile": "https://Stackoverflow.com/users/6574038", "pm_score": 3, "selected": true, "text": "as.list" }, { "answer_id": 74337753, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 1, "selected": false, "text": "c" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16571923/" ]
74,336,298
<p>Trying to create md5 hash of a string with powershell that matches linux-generated result... problem is of course that powershell seems to only hash files...</p> <p>most answers point to memorystream/streamwriter but question is how to do without... Posting this because there is an answer but have to search PowerShell 2.0 to find so will post this solution with link and constrained title</p>
[ { "answer_id": 74336338, "author": "Freenex1911", "author_id": 12144193, "author_profile": "https://Stackoverflow.com/users/12144193", "pm_score": 0, "selected": false, "text": "$stringAsStream = [System.IO.MemoryStream]::new()\n$writer = [System.IO.StreamWriter]::new($stringAsStream)\n$writer.write(\"MD5Online\")\n$writer.Flush()\n$stringAsStream.Position = 0\nGet-FileHash -InputStream $stringAsStream -Algorithm MD5\n" }, { "answer_id": 74336383, "author": "cybernado", "author_id": 20432339, "author_profile": "https://Stackoverflow.com/users/20432339", "pm_score": 1, "selected": false, "text": "$md5 = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider\n$utf8 = New-Object -TypeName System.Text.UTF8Encoding\n$String = \"Hello, world!\"\n$Hash = ([System.BitConverter]::ToString($md5.ComputeHash($utf8.GetBytes($String)))).replace(\"-\",\"\").ToLower()\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20432339/" ]
74,336,343
<p>I have k = [3, 2, 0, 1] and A array filled with zeros. I want to fill A with ones such that each row sums up to a value in k</p> <pre><code>k = [3, 2, 0, 1] A = np.zeros((n, n), dtype=int) for i in k: A = np.random.randint(2, size=i) </code></pre> <p>the expected output:</p> <pre><code>([[1., 0., 1., 1.], [0., 1., 1., 0.], [1., 0., 1., 0.], [0., 0., 0., 0.]) </code></pre> <p>I appreciate it</p>
[ { "answer_id": 74336338, "author": "Freenex1911", "author_id": 12144193, "author_profile": "https://Stackoverflow.com/users/12144193", "pm_score": 0, "selected": false, "text": "$stringAsStream = [System.IO.MemoryStream]::new()\n$writer = [System.IO.StreamWriter]::new($stringAsStream)\n$writer.write(\"MD5Online\")\n$writer.Flush()\n$stringAsStream.Position = 0\nGet-FileHash -InputStream $stringAsStream -Algorithm MD5\n" }, { "answer_id": 74336383, "author": "cybernado", "author_id": 20432339, "author_profile": "https://Stackoverflow.com/users/20432339", "pm_score": 1, "selected": false, "text": "$md5 = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider\n$utf8 = New-Object -TypeName System.Text.UTF8Encoding\n$String = \"Hello, world!\"\n$Hash = ([System.BitConverter]::ToString($md5.ComputeHash($utf8.GetBytes($String)))).replace(\"-\",\"\").ToLower()\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11268249/" ]
74,336,360
<p>I am studying this youtube tutorial by ShellWave which learns you how to program in C on a Linux device and for some reason am getting stuck at lesson #024 : <a href="https://www.youtube.com/watch?v=dP3N8g7h8gY&amp;list=PLypxmOPCOkHXbJhUgjRaV2pD9MJkIArhg&amp;index=24" rel="nofollow noreferrer">Youtube</a></p> <p>My code is the following (I used the same as in the video) :</p> <pre><code> #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;sys/types.h&gt; #include &lt;sys/stat.h&gt; #include &lt;fcntl.h&gt; #include &lt;unistd.h&gt; int main(int argc, char *argv[]) { int fd; char buf[14]; //write fd = open(&quot;myfile.txt&quot;, O_WRONLY | O_CREAT, 0600); if(fd == -1) { printf(&quot;Failed to create and open the file. \n&quot;); exit(1); } write(fd, &quot;Hello World!\n&quot;, 13); close(fd); //read fd = open(&quot;myfile.txt&quot;, O_RDONLY); if(fd == -1) { printf(&quot;Failed to open and read the file. \n&quot;); exit(1); } read(fd, buf, 13); buf[13] = '\0'; close(fd); printf(&quot;buf : %s\n&quot;, buf); return 0; } </code></pre> <p>The terminal shows output &quot;Failed to create and open file&quot;. So I think I am using the open() wrong or maybe it has to do with my Ubuntu version?</p> <p>Can somebody see what I am doing wrong?</p> <p>I tried changing the order of the flags and tried to change the mode to 0777 and 0700 with no success.</p> <p>There was a Permission Denied error. For some reason the &quot;myfile.txt&quot; was locked. <em>chmod u=rwx,g=r,o=r myfile.txt</em> command worked for me. Thanks everyone for the quick help.</p>
[ { "answer_id": 74336418, "author": "Liam H.", "author_id": 19206274, "author_profile": "https://Stackoverflow.com/users/19206274", "pm_score": 1, "selected": false, "text": "fd = open(\"myfile\", O_WRONLY | O_CREAT, 0600);\n" }, { "answer_id": 74336428, "author": "Adam", "author_id": 2291248, "author_profile": "https://Stackoverflow.com/users/2291248", "pm_score": -1, "selected": false, "text": "gcc t.c -Wall -Wextra\nt.c: In function ‘main’:\nt.c:11:14: warning: unused parameter ‘argc’ [-Wunused-parameter]\n 11 | int main(int argc, char *argv[])\n | ~~~~^~~~\nt.c:11:26: warning: unused parameter ‘argv’ [-Wunused-parameter]\n 11 | int main(int argc, char *argv[])\n | ~~~~~~^~~~~~\na@zalman:~/Dokumenty/t/t1$ ./a.out\nbuf : Hello World!\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20432331/" ]
74,336,372
<p>I can't redirect user on new page with javascript variants code:</p> <ul> <li><code>window.location.href=url</code></li> <li><code>window.location.replace (url)</code></li> <li><code>window.location.assign (url)</code></li> </ul> <p>The problem of redirect only on android, on other platforms there is no problem with going to another page. How to fix it on android ?</p> <p>View problem: <a href="https://media.discordapp.net/attachments/774759017951920158/1038805166553575467/image.png" rel="nofollow noreferrer">when going to any page</a></p>
[ { "answer_id": 74336418, "author": "Liam H.", "author_id": 19206274, "author_profile": "https://Stackoverflow.com/users/19206274", "pm_score": 1, "selected": false, "text": "fd = open(\"myfile\", O_WRONLY | O_CREAT, 0600);\n" }, { "answer_id": 74336428, "author": "Adam", "author_id": 2291248, "author_profile": "https://Stackoverflow.com/users/2291248", "pm_score": -1, "selected": false, "text": "gcc t.c -Wall -Wextra\nt.c: In function ‘main’:\nt.c:11:14: warning: unused parameter ‘argc’ [-Wunused-parameter]\n 11 | int main(int argc, char *argv[])\n | ~~~~^~~~\nt.c:11:26: warning: unused parameter ‘argv’ [-Wunused-parameter]\n 11 | int main(int argc, char *argv[])\n | ~~~~~~^~~~~~\na@zalman:~/Dokumenty/t/t1$ ./a.out\nbuf : Hello World!\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19295054/" ]
74,336,380
<p>i have been trying to solve this error , after i login i was getting type 'Null' is not a subtype of type 'String' for about 5 seconds and after that the app successfully login, i do not know why this happen, i already add null check to the User but i still get the error . Below is my code, tell me if you need more info, Thanks for helping</p> <pre><code>class _controState extends State&lt;contro&gt; { _controState(); User? user = FirebaseAuth.instance.currentUser; UserModel loggedInUser = UserModel(); var role; var email; var id; @override void initState() { super.initState(); FirebaseFirestore.instance .collection(&quot;users&quot;) //.where('uid', isEqualTo: user!.uid) .doc(user!.uid) .get() .then((value) { this.loggedInUser = UserModel.fromMap(value.data()); }).whenComplete(() { CircularProgressIndicator(); setState(() { email = loggedInUser.email.toString(); role = loggedInUser.role.toString(); id = loggedInUser.uid.toString(); }); }); } routing() { if (role == 'Freelancer') { return JobScreen( id: id, ); } else { return JobScreenClient( id: id, ); } } @override Widget build(BuildContext context) { CircularProgressIndicator(); return routing(); } } </code></pre>
[ { "answer_id": 74336496, "author": "eamirho3ein", "author_id": 10306997, "author_profile": "https://Stackoverflow.com/users/10306997", "pm_score": 1, "selected": false, "text": "routing" }, { "answer_id": 74336548, "author": "Muhammad Qazmouz", "author_id": 19122402, "author_profile": "https://Stackoverflow.com/users/19122402", "pm_score": 0, "selected": false, "text": "void initState() async {\n super.initState();\n await FirebaseFirestore.instance\n .collection(\"users\") //.where('uid', isEqualTo: user!.uid)\n .doc(user!.uid)\n .get()\n .then((value) {\n this.loggedInUser = UserModel.fromMap(value.data());\n }).whenComplete(() {\n CircularProgressIndicator();\n setState(() {\n email = loggedInUser.email.toString();\n role = loggedInUser.role.toString();\n id = loggedInUser.uid.toString();\n });\n });\n }\n" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15003461/" ]
74,336,387
<p>I imagine code similar to this:</p> <pre><code>var someDict: [Int:Bool] = { (0...100).map { someInt -&gt; [Int: String] in (someInt:false) } } </code></pre> <p>but it does not work :(</p> <p>How to properly map array of some value to dictionary?</p>
[ { "answer_id": 74336413, "author": "dillon-mce", "author_id": 11601631, "author_profile": "https://Stackoverflow.com/users/11601631", "pm_score": 0, "selected": false, "text": "reduce" }, { "answer_id": 74336704, "author": "Andrew___Pls_Support_UA", "author_id": 4423545, "author_profile": "https://Stackoverflow.com/users/4423545", "pm_score": -1, "selected": false, "text": "extension Dictionary {\n init<S: Sequence>(_ keys: S, withVal defaultVal: Value) where S.Element == Key {\n self = Dictionary( uniqueKeysWithValues: zip(keys, AnyIterator { defaultVal }) )\n }\n}\n" }, { "answer_id": 74344392, "author": "Jessy", "author_id": 652038, "author_profile": "https://Stackoverflow.com/users/652038", "pm_score": 3, "selected": true, "text": "AnyIterator" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4423545/" ]
74,336,396
<p>I'm asking a user to input a year from the keyboard. For example users input 2008, How can I get the maximum value of the year from list that user input the value of year?</p> <p>This is my code:</p> <pre><code>data_list = [(20070101, 619), (20070102, 615), (20070103, 614), (20080104, 845), (20080105, 840), (20080106, 835), (20090107, 940), (20090108, 970), (20090109, 939), (20090110, 936)] value_year = 0 input_year = input(&quot;Enter year &gt;&gt;&gt;&quot;) for date, value in data_list: result = str(date) if result[0:4] == input_year: if value &gt; value_year: value_year = value print (&quot;Maximum of this year:&quot;, result, value_year) </code></pre> <p>The output should be like this. when user input 2008. how to do that?</p> <pre><code>Maximum of this year: 20080104 845 </code></pre>
[ { "answer_id": 74336413, "author": "dillon-mce", "author_id": 11601631, "author_profile": "https://Stackoverflow.com/users/11601631", "pm_score": 0, "selected": false, "text": "reduce" }, { "answer_id": 74336704, "author": "Andrew___Pls_Support_UA", "author_id": 4423545, "author_profile": "https://Stackoverflow.com/users/4423545", "pm_score": -1, "selected": false, "text": "extension Dictionary {\n init<S: Sequence>(_ keys: S, withVal defaultVal: Value) where S.Element == Key {\n self = Dictionary( uniqueKeysWithValues: zip(keys, AnyIterator { defaultVal }) )\n }\n}\n" }, { "answer_id": 74344392, "author": "Jessy", "author_id": 652038, "author_profile": "https://Stackoverflow.com/users/652038", "pm_score": 3, "selected": true, "text": "AnyIterator" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20362914/" ]
74,336,398
<p>i am trying to open a specific instagram url in my app , i've tried all possible ways that i could find but no matter what i do i get a message that says component name for (url) is null then a message that says component name for <a href="https://flutter.dev" rel="nofollow noreferrer">https://flutter.dev</a> is null , i've added queries , used canluanch method , canlaunchurL , canlaunchurl methods , but i still get the same thing here is the final attempt that i made :</p> <pre><code>import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher_string.dart'; class MilaInformation extends StatelessWidget { const MilaInformation({super.key}); @override Widget build(BuildContext context) { var h = MediaQuery.of(context).size.height; var w = MediaQuery.of(context).size.width; return SafeArea( child: Scaffold( backgroundColor: Colors.white, body: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ ClipRRect( borderRadius: BorderRadius.only( bottomLeft: Radius.circular(w * 0.09), bottomRight: Radius.circular(w * 0.09)), child: Container(width: w, height: h / 1.6, color: Colors.pink), ), SizedBox( height: h * 0.02, ), Padding( padding: const EdgeInsets.all(15.0), child: Text( &quot; ؟ Mila Rose من هي&quot;, style: TextStyle( fontSize: 30, color: Colors.black, ), textDirection: TextDirection.ltr, ), ), Padding( padding: const EdgeInsets.fromLTRB(15, 0, 15, 5), child: Text( &quot; هي أول شركة عربية مختصة بتجارة الورود مقرها الرئيسي في هولندا , تقدم ميلا روز أفضل الخدمات في مجال الزهور على نطاق العالم الواسع&quot;, style: TextStyle(fontSize: 20, color: Colors.grey[500]), textDirection: TextDirection.rtl, ), ), SizedBox( height: 15, ), Padding( padding: const EdgeInsets.all(8.0), child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ GestureDetector( child: Padding( padding: EdgeInsets.all(15.0), child: Container( height: 25, width: 25, child: Image.asset( &quot;assets/images/insta.jfif&quot;, ), ), ), onTap: () async { String url = &quot;https://www.instagram.com//milarosenederland/?igshid=YmMyMTA2M2Y%3D&quot;; final uri = Uri.parse(url); if (await canLaunchUrl(uri)) { await launchUrl(uri, mode: LaunchMode.externalApplication); } }), Text(&quot;+974-6001-1002&quot;), SizedBox( width: 10, ), Text( &quot;للتواصل :&quot;, textDirection: TextDirection.rtl, ), ], ), ) ], ), ), ), ); } } </code></pre> <p>and here is my manifest.xml :</p> <pre><code>&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; package=&quot;com.example.mila_rose&quot;&gt; &lt;application android:label=&quot;mila_rose&quot; android:name=&quot;${applicationName}&quot; android:icon=&quot;@mipmap/ic_launcher&quot;&gt; &lt;activity android:name=&quot;.MainActivity&quot; android:exported=&quot;true&quot; android:launchMode=&quot;singleTop&quot; android:theme=&quot;@style/LaunchTheme&quot; android:configChanges=&quot;orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode&quot; android:hardwareAccelerated=&quot;true&quot; android:windowSoftInputMode=&quot;adjustResize&quot;&gt; &lt;!-- Specifies an Android theme to apply to this Activity as soon as the Android process has started. This theme is visible to the user while the Flutter UI initializes. After that, this theme continues to determine the Window background behind the Flutter UI. --&gt; &lt;meta-data android:name=&quot;io.flutter.embedding.android.NormalTheme&quot; android:resource=&quot;@style/NormalTheme&quot; /&gt; &lt;intent-filter&gt; &lt;action android:name=&quot;android.intent.action.MAIN&quot;/&gt; &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot;/&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;!-- Don't delete the meta-data below. This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --&gt; &lt;meta-data android:name=&quot;flutterEmbedding&quot; android:value=&quot;2&quot; /&gt; &lt;/application&gt; &lt;queries&gt; &lt;intent&gt; &lt;action android:name=&quot;android.intent.action.VIEW&quot; /&gt; &lt;category android:name=&quot;android.intent.category.BROWSABLE&quot; /&gt; &lt;data android:scheme=&quot;https&quot; /&gt; &lt;/intent&gt; &lt;intent&gt; &lt;action android:name=&quot;android.media.browse.MediaBrowserService&quot; /&gt; &lt;/intent&gt; &lt;/queries&gt; &lt;/manifest&gt; </code></pre> <p>any possible solutions ?</p>
[ { "answer_id": 74337054, "author": "Atreides", "author_id": 20097045, "author_profile": "https://Stackoverflow.com/users/20097045", "pm_score": 0, "selected": false, "text": "final Uri toLaunch =\n Uri(scheme: 'https', host: 'www.flutter.dev');\n" }, { "answer_id": 74338330, "author": "ahmed", "author_id": 20033412, "author_profile": "https://Stackoverflow.com/users/20033412", "pm_score": 2, "selected": true, "text": "launchUrlString()" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17826676/" ]
74,336,399
<p>Hmm... I can't understand why my project have error... Please hlep me.</p> <p>[Error Message]</p> <pre><code>Error: The getter 'user' isn't defined for the class '_CreatePageState'. - '_CreatePageState' is from 'package:insta_clone2_start/create_page.dart'('lib/create_page.dart'). Try correcting the name to the name of an existing getter, or defining a getter or field named 'user'. context, MaterialPageRoute(builder:(context) =&gt; HomePage(user)), ^^^^ </code></pre> <p>[Environment] **NON null_safety</p> <pre><code>environment: sdk: &quot;&gt;=2.7.0 &lt;3.0.0&quot; </code></pre> <p>[HomePage Code]</p> <pre><code>class HomePage extends StatelessWidget { final FirebaseUser user; HomePage(this.user); </code></pre> <p>[Create Page1]</p> <pre><code>class CreatePage extends StatefulWidget { final FirebaseUser user; CreatePage(this.user); @override _CreatePageState createState() =&gt; _CreatePageState(); } </code></pre> <p>[Create Page2]</p> <pre><code> Navigator.push( context, MaterialPageRoute(builder:(context) =&gt; HomePage(user)), ); </code></pre>
[ { "answer_id": 74337054, "author": "Atreides", "author_id": 20097045, "author_profile": "https://Stackoverflow.com/users/20097045", "pm_score": 0, "selected": false, "text": "final Uri toLaunch =\n Uri(scheme: 'https', host: 'www.flutter.dev');\n" }, { "answer_id": 74338330, "author": "ahmed", "author_id": 20033412, "author_profile": "https://Stackoverflow.com/users/20033412", "pm_score": 2, "selected": true, "text": "launchUrlString()" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19711930/" ]
74,336,403
<p>I am stuck in a problem. I want to update my cartesian index.</p> <p>I have a matrix (<code>x</code>) 200x6 that is binary. 1 if assigned, 0 otherwise. I want to find the cartesian index of when <code>x</code> is 1 in the first 3 columns and in the last 3 elements.</p> <p>I have the following code:</p> <pre><code>index_right = findall( x -&gt; x == 1, sol.x_assignment[:,1:3]) index_left = findall( x -&gt; x == 1, sol.x_assignment[:,4:6]) index_left </code></pre> <p>However <code>index_right</code> is correct, <code>index_left</code> is wrong as it returns index between 1,2,3 instead of 4,5,6</p> <pre><code>CartesianIndex(2, 1) CartesianIndex(3, 1) CartesianIndex(10, 2) CartesianIndex(11, 1) </code></pre> <p>Expected output:</p> <pre><code>CartesianIndex(2, 4) CartesianIndex(3, 4) CartesianIndex(10, 5) CartesianIndex(11, 4) </code></pre> <p>How can I update <code>index_left</code> to add +3 in the second index for all?</p>
[ { "answer_id": 74337054, "author": "Atreides", "author_id": 20097045, "author_profile": "https://Stackoverflow.com/users/20097045", "pm_score": 0, "selected": false, "text": "final Uri toLaunch =\n Uri(scheme: 'https', host: 'www.flutter.dev');\n" }, { "answer_id": 74338330, "author": "ahmed", "author_id": 20033412, "author_profile": "https://Stackoverflow.com/users/20033412", "pm_score": 2, "selected": true, "text": "launchUrlString()" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10571326/" ]
74,336,430
<p>I am using recursion to find an element in an array</p> <pre><code>def recur_search(arr,n,x): #n is the starting index and x is the target value if (arr[n] == x): return n else: return recur_search(arr,n+1,x) arr = [1,2,3,4,5,6,7,8] print(recur_search(arr,0,5)) </code></pre> <p>This program only works if i have the element present in the array. If the element is not present the program is throwing IndexErrors. Is there a graceful way to tackle the problem</p> <pre><code>type here </code></pre> <p>I was thinking of checking the presence of element using iteration first but that beats the purpose of recursion. Is there a way to use recursion to find the element if it's present and if its not</p>
[ { "answer_id": 74337054, "author": "Atreides", "author_id": 20097045, "author_profile": "https://Stackoverflow.com/users/20097045", "pm_score": 0, "selected": false, "text": "final Uri toLaunch =\n Uri(scheme: 'https', host: 'www.flutter.dev');\n" }, { "answer_id": 74338330, "author": "ahmed", "author_id": 20033412, "author_profile": "https://Stackoverflow.com/users/20033412", "pm_score": 2, "selected": true, "text": "launchUrlString()" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10750387/" ]
74,336,449
<p>How do I change the order of files from alphabetical order to last added?<a href="https://i.stack.imgur.com/pIB0Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pIB0Y.png" alt="enter image description here" /></a></p> <p>I don't know where the settings are , I have a lot of trouble managing those files</p>
[ { "answer_id": 74336475, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 2, "selected": false, "text": " \"explorer.sortOrder\": \"modified\"\n" }, { "answer_id": 74336522, "author": "Anh Le Hoang", "author_id": 16315750, "author_profile": "https://Stackoverflow.com/users/16315750", "pm_score": 1, "selected": false, "text": "explorer.sortOrder" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19946206/" ]
74,336,502
<p>I need to compare if any of the two cases meets the requirement, I need to take decision else need to do something else. I tried many ways and this is one of them but every way giving error.</p> <pre><code>if case .locked = itemStatus || case .hasHistoryLocked = itemStatus { print(&quot;YES&quot;) } else { print(&quot;NO&quot;) } </code></pre>
[ { "answer_id": 74336532, "author": "Thang Phi", "author_id": 10650407, "author_profile": "https://Stackoverflow.com/users/10650407", "pm_score": 0, "selected": false, "text": "Equatable" }, { "answer_id": 74337225, "author": "Rob", "author_id": 1271826, "author_profile": "https://Stackoverflow.com/users/1271826", "pm_score": 2, "selected": false, "text": "switch" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/390423/" ]
74,336,503
<p>I'm trying to print the output, but my code keep getting an error:</p> <blockquote> <p>C++ compile error: ISO C++ forbids comparison between pointer and integer</p> </blockquote> <p>The error is in <code>else if</code>:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;string.h&gt; int main (){ char BT [5][100]; for (int i = 1; i&lt;=2; i++){ printf(&quot;\nInsert book title:&quot;); scanf(&quot;%[^\n]&quot;, &amp;BT[i]); getchar (); } printf(&quot;\nOur Collections :\n&quot;); for (int i = 1; i&lt;= 2 ; i++){ for (int i = 0; i&lt; strlen(BT[i]); i++){ int k; if ( i == 0 &amp;&amp; BT[i][k] != ' ') { printf(&quot;Shelf code : %c\n&quot;, BT[i][k]); } else if ( i &gt; 0 &amp;&amp; BT[i - 1] == ' ') { printf(&quot;Shelf code : %c\n&quot;, BT[i][k]); } } } return 0; } </code></pre>
[ { "answer_id": 74336523, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 0, "selected": false, "text": "BT[i - 1]" }, { "answer_id": 74336585, "author": "Vlad from Moscow", "author_id": 2877241, "author_profile": "https://Stackoverflow.com/users/2877241", "pm_score": 2, "selected": false, "text": "0" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20432505/" ]
74,336,544
<p>I have a very large list of strings which each words in the list are unnormalized, for instance:</p> <pre><code>word_list = [&quot;Alzheimer&quot;, &quot;Alzheimer's&quot;, &quot;Alzheimer.&quot;, &quot;Alzheimer?&quot;,&quot;Cognition.&quot;, &quot;Cognition's&quot;, &quot;Cognitions&quot;, &quot;Cognition&quot;] # and the list goes on </code></pre> <p>As you can see,there are many identical terms in the list but some of them contain unnecessary puntuations (e.g.: dot, single apostrophe), how can I make all the words normalize (e.g.: &quot;Alzheimers.&quot; -&gt; &quot;Alzheimers&quot;, &quot;Cognition's&quot; -&gt; &quot;Cognition&quot;) ?</p> <p>Thank you in advance!</p> <p>I expect a function that to filter out unnecessary single punctuations, I tried the following function but it did not work well:</p> <pre><code>def word_normalizer(word): # Remove unnecessary single puntuations and turn all words into lower case puntuations = [&quot;'&quot;, '&quot;', &quot;;&quot;, &quot;:&quot;, &quot;,&quot;, &quot;.&quot;, &quot;&amp;&quot;, &quot;(&quot;, &quot;)&quot;] new_word =&quot;&quot; for punc in puntuations: if punc in word: new_word = word.strip(punc) return new_word.lower() </code></pre>
[ { "answer_id": 74336636, "author": "Omar", "author_id": 9289463, "author_profile": "https://Stackoverflow.com/users/9289463", "pm_score": 0, "selected": false, "text": "import re\ndef word_normalizer(word): \n word = re.sub('[^A-Za-z0-9]+', '', word)\n return word.lower()\n" }, { "answer_id": 74336783, "author": "Cobra", "author_id": 17580381, "author_profile": "https://Stackoverflow.com/users/17580381", "pm_score": 0, "selected": false, "text": "import string\nimport re\n\npunc = re.compile(f'[{string.punctuation}]')\nword_list = [\"Alzheimer\", \"Alzheimer's\", \"Alzheimer.\", \"Alzheimer?\",\"Cognition.\", \"Cognition's\", \"Cognitions\", \"Cognition\"]\nnew_word_set = {punc.sub('', word).rstrip('s') for word in word_list}\n\nprint(new_word_set)\n" }, { "answer_id": 74336850, "author": "Jason", "author_id": 10639, "author_profile": "https://Stackoverflow.com/users/10639", "pm_score": 0, "selected": false, "text": " from functools import reduce\n\n punctuation = [\"'\", '\"', \";\", \":\", \",\", \".\", \"&\", \"(\", \")\"]\n words = [\"Alzheimer\", \"Alzheimer's\", \"Alzheimer.\", \"Alzheimer?\",\"Cognition.\", \"Cognition's\", \"Cognitions\", \"Cognition\"]\n\n # remove a character from a string\n def strip_punc(word: str, character_to_strip: str) -> str:\n return word.replace(character_to_strip, \"\")\n\n # run the strip_punc function for each item in the punctuation list\n def clean_word(word: str): list(str) -> list(str):\n return reduce(strip_punc, punctuation, word)\n\n # run the clean_word function on each word in the word list\n # use set to remove dupes\n return set(map(clean_word, words))\n" }, { "answer_id": 74337372, "author": "Arifa Chan", "author_id": 19574157, "author_profile": "https://Stackoverflow.com/users/19574157", "pm_score": -1, "selected": false, "text": "str.translate" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19512917/" ]
74,336,557
<p>I'm struggling to define this problem exactly, which is part of the reason I cannot solve it. Basically, I want to assign numbers to nodes that provides a kind of topological sorting, but if there is a cycle in the graph, which I want to allow, it should assign values to the nodes that essentially count up the distance from nearest non-cycle nodes.<a href="https://i.stack.imgur.com/WCJka.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WCJka.png" alt="enter image description here" /></a></p> <p>eg, If there were another non-cyclic dependency, the numbers assigned to the nodes may look more like this.</p> <p><a href="https://i.stack.imgur.com/8yWru.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8yWru.png" alt="enter image description here" /></a></p> <p>Currently, the numbers assigned are just based on total dependencies, which creates less-than-ideal layouts.</p> <p><a href="https://i.stack.imgur.com/CUWl0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CUWl0.png" alt="enter image description here" /></a></p> <p>I have a feeling that I might need to use some algorithm involving Strongly Connected Components, but I'm not sure how to apply it to get the desired result. Any help clarifying this issue would be greatly appreciated!</p>
[ { "answer_id": 74337607, "author": "chrslg", "author_id": 20037042, "author_profile": "https://Stackoverflow.com/users/20037042", "pm_score": 0, "selected": false, "text": "max( shortest_path(node1, node2) for node1 in nodes, node2 in nodes)" } ]
2022/11/06
[ "https://Stackoverflow.com/questions/74336557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20347937/" ]