qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,309,770
<p>I'm very new to js and programming in general, so I may be missing something very obvious here. I'm trying to create a very basic rock paper scissors program.</p> <p>my html:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const canvas = document.getElementById('canvas'); let playerChoice; let oppChoice; const rps = ['Rock', 'Paper', 'Scissors'] canvas.innerHTML = ` &lt;h1&gt;Rock, Paper, Scissors!&lt;/h1&gt; &lt;p&gt;Make your choice...&lt;/p&gt; &lt;button onclick='playerChoiceIs('Rock')'&gt;Rock&lt;/button&gt; &lt;button onclick='playerChoiceIs('Paper')'&gt;Paper&lt;/button&gt; &lt;button onclick='playerChoiceIs('Scissors')'&gt;Scissors&lt;/button&gt; ` function playerChoiceIs(x) { playerChoice = x; oppChoice = rps[Math.floor(Math.random() * 3)]; console.log('function called'); canvas.innerHTML = ` &lt;h1&gt;You chose ${playerChoice}...&lt;/h1&gt; &lt;h1&gt;Your opponent chose ${oppChoice}!&lt;/h1&gt; ` }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="canvas"&gt;&lt;/div&gt;</code></pre> </div> </div> </p> <p>Whenever I press a button to select rock, paper or scissors, nothing happens, and an error's logged on the console. I've searched online for solutions and run the html and javascript through validators, which found no issues. The reference logged out by the console points me to index.html:11:49, but line 11 in my html file ends at column 34; so I'm totally lost.</p>
[ { "answer_id": 74309961, "author": "yessir", "author_id": 18591002, "author_profile": "https://Stackoverflow.com/users/18591002", "pm_score": 0, "selected": false, "text": "const canvas = document.getElementById('canvas');\nlet playerChoice;\nlet oppChoice;\nconst rps = ['Rock', 'Paper', 'Scissors']\n\n\ncanvas.innerHTML = `\n <h1>Rock, Paper, Scissors!</h1>\n <p>Make your choice...</p>\n <button onclick=\"playerChoiceIs('Rock')\">Rock</button>\n <button onclick=\"playerChoiceIs('Paper')\">Paper</button>\n <button onclick=\"playerChoiceIs('Scissors')\">Scissors</button>\n`\n\nfunction playerChoiceIs(x) {\n playerChoice = x;\n oppChoice = rps[Math.floor(Math.random() * 3)];\n console.log('function called');\n canvas.innerHTML = `\n <h1>You chose ${playerChoice}...</h1>\n <h1>Your opponent chose ${oppChoice}!</h1>\n `\n}" }, { "answer_id": 74309991, "author": "CherryDT", "author_id": 1871033, "author_profile": "https://Stackoverflow.com/users/1871033", "pm_score": 3, "selected": true, "text": "<button onclick='playerChoiceIs('Rock')'>Rock</button>\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74309770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20411947/" ]
74,309,815
<p>I wanted to re-assign/replace my new value, from my current</p> <pre><code>20000123 19850123 19880112 19951201 19850123 20190821 20000512 19850111 19670133 19850123 </code></pre> <p>As you can see there is data with 19670133 (YYYYMMDD), which means that date is not exist since there is no month with 33 days in it.So I wanted to re assign it to the end of the month. I tried to make it to the end of the month, and it works. But when i try to replace the old value with the new ones, it became a problem. What I've tried to do is this :</p> <pre><code>for x in df_tmp_customer['date']: try: df_tmp_customer['date'] = df_tmp_customer.apply(pd.to_datetime(x), axis=1) except Exception: df_tmp_customer['date'] = df_tmp_customer.apply(pd.to_datetime(x[0:6]+&quot;01&quot;)+ pd.offsets.MonthEnd(n=0), axis=1) </code></pre> <p>This part is the one that makes it end of the month :</p> <pre><code>pd.to_datetime(x[0:6]+&quot;01&quot;)+ pd.offsets.MonthEnd(n=0) </code></pre>
[ { "answer_id": 74309961, "author": "yessir", "author_id": 18591002, "author_profile": "https://Stackoverflow.com/users/18591002", "pm_score": 0, "selected": false, "text": "const canvas = document.getElementById('canvas');\nlet playerChoice;\nlet oppChoice;\nconst rps = ['Rock', 'Paper', 'Scissors']\n\n\ncanvas.innerHTML = `\n <h1>Rock, Paper, Scissors!</h1>\n <p>Make your choice...</p>\n <button onclick=\"playerChoiceIs('Rock')\">Rock</button>\n <button onclick=\"playerChoiceIs('Paper')\">Paper</button>\n <button onclick=\"playerChoiceIs('Scissors')\">Scissors</button>\n`\n\nfunction playerChoiceIs(x) {\n playerChoice = x;\n oppChoice = rps[Math.floor(Math.random() * 3)];\n console.log('function called');\n canvas.innerHTML = `\n <h1>You chose ${playerChoice}...</h1>\n <h1>Your opponent chose ${oppChoice}!</h1>\n `\n}" }, { "answer_id": 74309991, "author": "CherryDT", "author_id": 1871033, "author_profile": "https://Stackoverflow.com/users/1871033", "pm_score": 3, "selected": true, "text": "<button onclick='playerChoiceIs('Rock')'>Rock</button>\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74309815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7859524/" ]
74,309,821
<p>Update: used the code on the actual dataset and we found suffixes (jr, sr, I, etc) are an issue. I have been scouring Stack and Google for solutions. Any idea on how to remove suffixes? I am thinking of removing the suffixes before using the regex code.</p> <p>My sample data set looks like this.</p> <p><a href="https://i.stack.imgur.com/TOIvW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TOIvW.png" alt="Screenshot of made up data points" /></a></p> <p><strong>Reproducible Sample Data</strong></p> <pre><code>dput(head(Sample_Dataset)) structure(list(MemberName = c(&quot;David owino&quot;, &quot;Prisca omanya&quot;, &quot;Geraldine nyambura bitange&quot;, &quot;Ruiz aguila de espinoza&quot;, &quot;Hera nyabute oganche&quot;, &quot;Joney boka&quot;), `Date of Birth` = structure(c(-235094400, 252806400, -641606400, 613180800, 697852800, 684115200), tzone = &quot;UTC&quot;, class = c(&quot;POSIXct&quot;, &quot;POSIXt&quot;)), `PCP Name` = c(&quot;Ogero, Lamech, Md :1677742950&quot;, &quot;Njeri, Lamech, Np :1677742951&quot;, &quot;Ogero, Lamech, Md :1677742952&quot;, &quot;Agero, Larisse, Md :1677742953&quot;, &quot;Ogero, Lamech, Md :1677742954&quot;, &quot;Denise, Lamech, Md :1677742955&quot; )), row.names = c(NA, -6L), class = c(&quot;tbl_df&quot;, &quot;tbl&quot;, &quot;data.frame&quot; )) </code></pre> <pre class="lang-r prettyprint-override"><code> #Splitting String &lt;- stringr::str_split(Sample_Dataset$MemberName, &quot;[ ]&quot;, n = 2) Last_Name &lt;- sapply(String, '[', -1) First_Name &lt;- sapply(String, '[', 1) Sample_d2 &lt;-data.frame(First_Name, Last_Name) </code></pre> <p>The first part split it into first names and last names had 2 - 3 names (for individuals with 4 names)</p> <pre class="lang-r prettyprint-override"><code> names.split &lt;- strsplit(unlist(Sample_d2$Last_Name), &quot; &quot;) Middle_Names &lt;- sapply(names.split$Last_Name, function(x) if(length(String$Last_Name) == 2) { Middle_Names &lt;- sapply(String, '[', 1) } else if (length(String$Last_Name) == 3){ Middle_Names&lt;- sapply(String, '[', 1:2) } ) Sample_d2 &lt;- data.frame(First_Name,Middle_Names, Last_Name) </code></pre> <p>I want to extract first name, last name and everything else be middle names.</p>
[ { "answer_id": 74309961, "author": "yessir", "author_id": 18591002, "author_profile": "https://Stackoverflow.com/users/18591002", "pm_score": 0, "selected": false, "text": "const canvas = document.getElementById('canvas');\nlet playerChoice;\nlet oppChoice;\nconst rps = ['Rock', 'Paper', 'Scissors']\n\n\ncanvas.innerHTML = `\n <h1>Rock, Paper, Scissors!</h1>\n <p>Make your choice...</p>\n <button onclick=\"playerChoiceIs('Rock')\">Rock</button>\n <button onclick=\"playerChoiceIs('Paper')\">Paper</button>\n <button onclick=\"playerChoiceIs('Scissors')\">Scissors</button>\n`\n\nfunction playerChoiceIs(x) {\n playerChoice = x;\n oppChoice = rps[Math.floor(Math.random() * 3)];\n console.log('function called');\n canvas.innerHTML = `\n <h1>You chose ${playerChoice}...</h1>\n <h1>Your opponent chose ${oppChoice}!</h1>\n `\n}" }, { "answer_id": 74309991, "author": "CherryDT", "author_id": 1871033, "author_profile": "https://Stackoverflow.com/users/1871033", "pm_score": 3, "selected": true, "text": "<button onclick='playerChoiceIs('Rock')'>Rock</button>\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74309821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20411939/" ]
74,309,841
<p>As the title says, i have 3 containers running in docker, 1 for rails, 1 for a postgres db and 1 for redis. I'm able to enqueue jobs doing <code>Job.perform_async</code> but for some reason my jobs stay on the enqueued indefinitely. I checked and my Redis container is up and running.</p> <p>My Job:</p> <pre><code>class HardJob include Sidekiq::Job def perform(*args) puts 'HardJob' end end </code></pre> <p>The initializer for sidekiq:</p> <pre><code>Sidekiq.configure_server do |config| config.redis = { url: (ENV[&quot;REDIS_URL&quot;] || 'redis://localhost:6379') } end Sidekiq.configure_client do |config| config.redis = { url: (ENV[&quot;REDIS_URL&quot;] || 'redis://localhost:6379') } end </code></pre> <p>My docker-compose:</p> <pre><code>version: '3.0' services: web: build: . entrypoint: &gt; bash -c &quot; rm -f tmp/pids/server.pid &amp;&amp; bundle exec rails s -b 0.0.0.0 -p 3000&quot; ports: - 3000:3000 volumes: - .:/src/myapp depends_on: - db - redis links: - &quot;db:db&quot; environment: REDIS_URL: 'redis://redis:6379' db: image: postgres:11 environment: POSTGRES_PASSWORD: 'postgres' volumes: - db_data:/var/lib/postgresql/data ports: - 5432:5432 redis: image: &quot;redis&quot; volumes: db_data: redis: driver: local </code></pre> <p>And i also set <code>config.active_job.queue_adapter = :sidekiq</code> in my 3 environments. <a href="https://i.stack.imgur.com/B68KZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B68KZ.jpg" alt="enter image description here" /></a></p> <p>Any hint of what could be happening here? Thanks in advance</p> <p><strong>Update</strong></p> <p>Seems that running <code>sidekiq -q default</code> in my rails terminal worked. How can i configure Docker to always run sidekiq?</p>
[ { "answer_id": 74309961, "author": "yessir", "author_id": 18591002, "author_profile": "https://Stackoverflow.com/users/18591002", "pm_score": 0, "selected": false, "text": "const canvas = document.getElementById('canvas');\nlet playerChoice;\nlet oppChoice;\nconst rps = ['Rock', 'Paper', 'Scissors']\n\n\ncanvas.innerHTML = `\n <h1>Rock, Paper, Scissors!</h1>\n <p>Make your choice...</p>\n <button onclick=\"playerChoiceIs('Rock')\">Rock</button>\n <button onclick=\"playerChoiceIs('Paper')\">Paper</button>\n <button onclick=\"playerChoiceIs('Scissors')\">Scissors</button>\n`\n\nfunction playerChoiceIs(x) {\n playerChoice = x;\n oppChoice = rps[Math.floor(Math.random() * 3)];\n console.log('function called');\n canvas.innerHTML = `\n <h1>You chose ${playerChoice}...</h1>\n <h1>Your opponent chose ${oppChoice}!</h1>\n `\n}" }, { "answer_id": 74309991, "author": "CherryDT", "author_id": 1871033, "author_profile": "https://Stackoverflow.com/users/1871033", "pm_score": 3, "selected": true, "text": "<button onclick='playerChoiceIs('Rock')'>Rock</button>\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74309841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10320608/" ]
74,309,847
<p>I know I can do this in a <code>change</code> migration and have it be reversible:</p> <pre><code> add_column :widgets, :color, :string remove_column :widgets, :flavor, :string </code></pre> <p>But strangely, <code>change_table</code>-&gt;<code>remove</code> does not work like this. Instead of params <code>(name, type)</code>, it takes a list of column names. (If you attempt to append a type parameter, it gets interpreted as a column name.)</p> <pre><code> change_table(:widgets) do |t| t.column :color, :string t.remove :flavor, :string # &lt;-- nope! It tries to remove a column named &quot;string&quot; end </code></pre> <p>When you try that, you get this error:</p> <pre><code> remove_columns is only reversible if given a type. </code></pre> <p>Is there another call I am be overlooking? It seems weird that <code>change_table</code> could be missing such a fundamental use case, but I don't see any calls in <a href="https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/Table.html" rel="nofollow noreferrer">the docs</a> that can do it.</p>
[ { "answer_id": 74309848, "author": "Grant Birchmeier", "author_id": 650475, "author_profile": "https://Stackoverflow.com/users/650475", "pm_score": 2, "selected": false, "text": " change_table(:widgets) do |t|\n t.column :color, :string\n t.remove :flavor, type: :string\n #^^^^^\n end\n" }, { "answer_id": 74314840, "author": "max", "author_id": 544825, "author_profile": "https://Stackoverflow.com/users/544825", "pm_score": 1, "selected": false, "text": "ActiveRecord::ConnectionAdapters::Table" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74309847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/650475/" ]
74,309,863
<p>I have a file with this structure (it comes from a json):</p> <pre><code>lista = [{'document': {'amount': 20, 'name': 'Peter', 'city': 'Madrid'}, 'highlights': [], 'text_match': 100}, {'document': {'amount': 15, 'name': 'Angel', 'city': 'Barcelona'}, 'highlights': [], 'text_match': 100}, {'document': {'amount': 10, 'name': 'Louis', 'city': 'London'}, 'highlights': [], 'text_match': 100}] </code></pre> <p>I need to iterate through it for getting a dataframe like this:</p> <pre><code> amount name city 0 20 Peter Madrid 1 15 Angel Barcelona 2 10 Louis London </code></pre> <p>I'm trying to do it with this code:</p> <pre><code>res = [] for p in lista: res.append(p) df = pd.DataFrame(res) </code></pre> <p>But I'm getting a dataframe with 3 columns: document, highlights and text_match like this:</p> <pre><code> document highlights text_match 0 {'amount': 20, 'name': 'Peter', 'city': 'Madrid'} [] 100 1 {'amount': 15, 'name': 'Angel', 'city': 'Barce... [] 100 2 {'amount': 10, 'name': 'Louis', 'city': 'London'} [] 100 </code></pre> <p>. I guess the solution is not very difficult but I'm having problems about manage the iteration in lists/dictionarys</p>
[ { "answer_id": 74309881, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": -1, "selected": false, "text": "df = pd.DataFrame([d[\"document\"] for d in lista])\nprint(df)\n" }, { "answer_id": 74309918, "author": "Coollector", "author_id": 18623283, "author_profile": "https://Stackoverflow.com/users/18623283", "pm_score": 2, "selected": true, "text": "p" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74309863", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15226448/" ]
74,309,879
<p>I have a pandas dataframe like</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>user_id</th> <th>music_id</th> <th>has_rating</th> </tr> </thead> <tbody> <tr> <td>A</td> <td>a</td> <td>1</td> </tr> <tr> <td>B</td> <td>b</td> <td>1</td> </tr> </tbody> </table> </div> <p>and I would like to automatically add new rows for each of user_id &amp; music_id for those users haven't rated, like</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>user_id</th> <th>music_id</th> <th>has_rating</th> </tr> </thead> <tbody> <tr> <td>A</td> <td>a</td> <td>1</td> </tr> <tr> <td>A</td> <td>b</td> <td>0</td> </tr> <tr> <td>B</td> <td>a</td> <td>0</td> </tr> <tr> <td>B</td> <td>b</td> <td>1</td> </tr> </tbody> </table> </div> <p>for each of user_id and music_id combination pairs those are not existing in my Pandas dataframe yet.</p> <p>is there any way to append such rows automatically like this?</p>
[ { "answer_id": 74309940, "author": "rhug123", "author_id": 13802115, "author_profile": "https://Stackoverflow.com/users/13802115", "pm_score": 0, "selected": false, "text": "pd.MultiIndex.from_product()" }, { "answer_id": 74310012, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 2, "selected": true, "text": "pivot_table" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74309879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10761699/" ]
74,309,898
<p>I want to know how to set my activity status for my bot.</p> <p>Like &quot;Watching youtube.com&quot;</p> <p>Or &quot;playing a game.&quot;</p> <p>I've tried following the discord api document but it does not tell me how.</p>
[ { "answer_id": 74309940, "author": "rhug123", "author_id": 13802115, "author_profile": "https://Stackoverflow.com/users/13802115", "pm_score": 0, "selected": false, "text": "pd.MultiIndex.from_product()" }, { "answer_id": 74310012, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 2, "selected": true, "text": "pivot_table" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74309898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20403227/" ]
74,309,903
<p>I have a model <code>class</code> where the variable <code>completed_application</code> should default to <code>False</code> when creating a new user (to show that the user hasn't completed an application yet). However, by default when a new user is created it doesn't show as <code>False</code> in Django admin but '-' instead.</p> <p><strong>models.py:</strong></p> <pre><code>class Company(models.Model): class Meta: verbose_name_plural = 'Company' user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) company_name = models.CharField(max_length=255, blank=True, null=True) class Completed(models.Model): class Meta: verbose_name_plural = 'Completed Application' user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) completed_application = models.BooleanField(default=False) </code></pre> <p><strong>admin.py:</strong></p> <pre><code>class Company(admin.StackedInline): model = Completed can_delete: False verbose_name_plural = 'Completed Application' class UserAdmin(UserAdmin): list_display = ('username', 'first_name', 'last_name', 'email', 'company', 'completed') search_fields = ('username', 'email',) inlines = [Company] list_filter = ('is_active',) fieldsets = ( (None, {'fields': ('username', 'password')}), (('Personal info'), {'fields': ('first_name', 'last_name', 'email')}), (('Permissions'), { 'fields': ('is_active', 'is_staff', 'groups',), }), (('Important dates'), {'fields': ('last_login', 'date_joined')}), ) </code></pre> <p><a href="https://i.stack.imgur.com/WclFF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WclFF.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/ew92j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ew92j.png" alt="enter image description here" /></a></p> <p>The red arrow in the first image above points to the Users admin panel for a newly created user. The second image shows the individual user in Django admin with the custom model added to that user.</p> <p>Other point to note: Checking the box and saving the user it shows <code>True</code> (as to be expected), but then unchecking the box and saving the user it eventually shows <code>False</code> and not '-'.</p> <p>Could someone explain what this '-' means and how to ensure the model always shows False on creation?</p>
[ { "answer_id": 74312800, "author": "Sunderam Dubey", "author_id": 17562044, "author_profile": "https://Stackoverflow.com/users/17562044", "pm_score": 2, "selected": false, "text": "can_delete" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74309903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16673529/" ]
74,309,944
<p>I have a db like this:</p> <pre><code>tibble(Q1 = c(&quot;0&quot;,&quot;A&quot;), Q2 = c(&quot;A&quot;,&quot;A&quot;), Q3 = c(&quot;0&quot;,&quot;A&quot;), C1 = c(&quot;A&quot;,&quot;0&quot;) ) -&gt; DB </code></pre> <p>I aim to add a new column which is a count of how many <code>&quot;0&quot;</code> are detected in the row when the column starts with <code>&quot;Q&quot;</code>.</p> <p>In this case, this column would be like</p> <pre><code>DB %&gt;% mutate(S = c(2,0)) </code></pre>
[ { "answer_id": 74309958, "author": "r2evans - GO NAVY BEAT ARMY", "author_id": 3358272, "author_profile": "https://Stackoverflow.com/users/3358272", "pm_score": 3, "selected": true, "text": "DB %>%\n rowwise() %>%\n mutate(S = sum(c_across(starts_with(\"Q\")) == \"0\")) %>%\n ungroup()\n# # A tibble: 2 x 5\n# Q1 Q2 Q3 C1 S\n# <chr> <chr> <chr> <chr> <int>\n# 1 0 A 0 A 2\n# 2 A A A 0 0\n" }, { "answer_id": 74310094, "author": "B. Christian Kamgang", "author_id": 10848898, "author_profile": "https://Stackoverflow.com/users/10848898", "pm_score": 1, "selected": false, "text": "DB %>%\n mutate(S = rowSums(.[startsWith(names(.), \"Q\")]==\"0\"))\n\n# A tibble: 2 x 5\n Q1 Q2 Q3 C1 S\n <chr> <chr> <chr> <chr> <dbl>\n1 0 A 0 A 2\n2 A A A 0 0\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74309944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17122831/" ]
74,310,008
<p>I am having some questions related to python timer. Hope someone can give some suggestions on that. :)</p> <p>I would like when the timer is expired after 20sec, then it printout a string and exit(2), I look into some example hence, I have written the first example below, the problem for that is after timeout, event I have written sys.exit(2) in the function, it will not exit it with 2, but with exit code 0 instead.</p> <pre><code>import sys import threading def application_timeout(): print(&quot;The application is timeout\n&quot;) sys.exit(2) timer = threading.Timer(20.0, application_timeout) timer.start() </code></pre> <p>Below is my second example, I am managed to make the code exit 2, but the code doesn't look as nice. Just wondering can someone give me a suggestion on that?</p> <p>import sys import threading</p> <pre><code>def application_timeout(): print(&quot;The application is timeout\n&quot;) timer = threading.Timer(20.0, application_timeout) timer.start() while(timer.is_alive() == True): timerstillalive = False if(timerstillalive == False): print(&quot;Timer is expired&quot;) sys.exit(2) </code></pre>
[ { "answer_id": 74310081, "author": "Shiplu Mokaddim", "author_id": 376535, "author_profile": "https://Stackoverflow.com/users/376535", "pm_score": 1, "selected": false, "text": "application_timeout" }, { "answer_id": 74310104, "author": "Coollector", "author_id": 18623283, "author_profile": "https://Stackoverflow.com/users/18623283", "pm_score": 1, "selected": false, "text": "while timer.is_alive():\n pass\n\nprint(\"Timer is expired\")\nsys.exit(2)\n" }, { "answer_id": 74310118, "author": "WeDBA", "author_id": 8514862, "author_profile": "https://Stackoverflow.com/users/8514862", "pm_score": 0, "selected": false, "text": "timer.is_alive()" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6678296/" ]
74,310,011
<p>I have two dates: <code>LastUpdatedOn</code> and <code>CreatedBy</code>. If <code>LastUpdatedOn</code> has a value then I want to use that value. Otherwise I should use <code>CreatedBy</code>. If neither <code>LastUpdatedOn</code> or <code>Createdby</code> have a value then use <code>Date.MinValue</code>.</p> <p>In the code below, <code>CreatedBy</code> is always used even though <code>LastUpdatedOn</code> has a value.</p> <pre><code>var LastUpdated = discrepancy.LastUpdatedOn.HasValue ? discrepancy.CreatedOn.Value.LocalDateTime : DateTime.MinValue; </code></pre> <p>What is wrong with my code?</p>
[ { "answer_id": 74310121, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 1, "selected": false, "text": "var LastUpdated = discrepancy.LastUpdatedOn ?? discrepancy.CreatedOn ?? DateTime.MinValue;\n" }, { "answer_id": 74310122, "author": "Daniel Dutra", "author_id": 747891, "author_profile": "https://Stackoverflow.com/users/747891", "pm_score": 0, "selected": false, "text": "discrepancy.LastUpdatedOn.HasValue" }, { "answer_id": 74310139, "author": "matilda chi", "author_id": 16350603, "author_profile": "https://Stackoverflow.com/users/16350603", "pm_score": 0, "selected": false, "text": "var LastUpdated = discrepancy.LastUpdatedOn.HasValue ? discrepancy.LastUpdatedOn : (discrepancy.CreatedOn.HasValue ? discrepancy.CreatedOn : DateTime.MinValue);\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5748123/" ]
74,310,039
<p>I have the following simple PHP page:</p> <pre class="lang-php prettyprint-override"><code>&lt;?php echo 'done'; </code></pre> <p>When I send a Javascript <code>fetch</code> request to that URL, I can inspect the response in the browser's dev tools and see that it returns the string 'done'.</p> <p>Here is the request:</p> <pre class="lang-js prettyprint-override"><code>const response = await fetch(url, { credentials: 'include' }); </code></pre> <p>On the other hand, if I start a session, the response is blank:</p> <pre class="lang-php prettyprint-override"><code>&lt;?php session_start(); echo 'done'; </code></pre> <p>In both cases, the request headers are exactly the same, the response headers are exactly the same and the HTTP code is 200. It also works correctly if I manually go to that URL in the browser. It only fails specifically with <code>fetch</code> requests.</p> <p>Note, I have <code>display_errors</code> and <code>display_startup_errors</code> set to <code>On</code> and nothing is outputted to the browser and nothing is logged in the log file either.</p>
[ { "answer_id": 74310040, "author": "Mike", "author_id": 811240, "author_profile": "https://Stackoverflow.com/users/811240", "pm_score": 1, "selected": false, "text": "response.text()" }, { "answer_id": 74310174, "author": "Quobi Slim", "author_id": 17088489, "author_profile": "https://Stackoverflow.com/users/17088489", "pm_score": -1, "selected": false, "text": "async " } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/811240/" ]
74,310,043
<p>I have this type:</p> <pre><code>type Item = { title: string } </code></pre> <p>and I want to <code>Pick</code> the <code>title</code> property as use it in another type definition:</p> <pre><code>type NewItem = Pick&lt;Item, 'title'&gt; </code></pre> <p>However, in <code>NewType</code> I want <code>title</code> to be named <code>newTitle</code>. How do I do this?</p>
[ { "answer_id": 74310065, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 2, "selected": true, "text": "Pick" }, { "answer_id": 74310568, "author": "Alex Wayne", "author_id": 62076, "author_profile": "https://Stackoverflow.com/users/62076", "pm_score": 1, "selected": false, "text": "Omit<T, K> & { [newKey in K]: NewTypeHere }\n" }, { "answer_id": 74310792, "author": "jsejcksn", "author_id": 438273, "author_profile": "https://Stackoverflow.com/users/438273", "pm_score": 2, "selected": false, "text": "type PickAndRename<T, PropMap extends Partial<Record<keyof T, string>>> = {\n [\n K in keyof PropMap as K extends keyof T\n ? PropMap[K] extends string\n ? PropMap[K]\n : never\n : never\n ]: K extends keyof T ? T[K] : never;\n};\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3111255/" ]
74,310,069
<p>So we recently migrated our project from .net framework 4.7.2 to .net 6 and we are testing the code for any issues , while testing i found out that the following method for Max is not working in .net 6</p> <pre><code>var maxOfStringMethod = (from method in typeof(Enumerable).GetMethods() where method.Name == &quot;Max&quot; &amp;&amp; method.GetParameters().Length == 2 &amp;&amp; method.GetParameters()[1].ParameterType.GenericTypeArguments[1].IsGenericParameter select method).First().MakeGenericMethod(new Type[] { typeof(SomeViewModel), typeof(string) }); </code></pre> <p>Above code method is for &quot;TResult Max[TSource,TResult](System.Collections.Generic.IEnumerable<code>1[TSource], System.Func</code>2[TSource,TResult])&quot;.<br> It was working fine in .net framework 4.7.2 , but while testing the migrated code in .net 6 it throws &quot;ArrayOutOfBoundsException&quot; So i tried changing the above code to following for getting same result from Enumerable methods in .Net 6</p> <pre><code> var maxOfStringMethod = (from method in typeof(Enumerable).GetMethods() where method.Name == &quot;Max&quot; &amp;&amp; method.GetParameters().Length == 2 &amp;&amp; method.GetParameters()[0].ParameterType.GenericTypeArguments[0].IsGenericParameter select method).ElementAt(1).MakeGenericMethod(new Type[] { typeof(SomeViewModel), typeof(string) }); </code></pre> <p>Now it's throwing &quot;System.ArgumentException: 'The type or method has 1 generic parameter(s), but 2 generic argument(s) were provided. A generic argument must be provided for each generic parameter.' &quot; I dont know what to do to solve this next , any help will be much appreciated</p>
[ { "answer_id": 74310389, "author": "Sarvesh Patil", "author_id": 17718198, "author_profile": "https://Stackoverflow.com/users/17718198", "pm_score": 0, "selected": false, "text": "TResult Max[TSource,TResult](System.Collections.Generic.IEnumerable`1[TSource], System.Func`2[TSource,TResult])\n" }, { "answer_id": 74316084, "author": "thehennyy", "author_id": 4035472, "author_profile": "https://Stackoverflow.com/users/4035472", "pm_score": 2, "selected": true, "text": "var maxOfStringMethod = typeof(Enumerable).GetMethods()\n .Single(x => x.Name == nameof(Enumerable.Max)\n && x.GetGenericArguments().Length == 2\n && x.GetParameters().Length == 2\n && x.GetParameters()[0].ParameterType == typeof(IEnumerable<>).MakeGenericType(x.GetGenericArguments()[0])\n && x.GetParameters()[1].ParameterType == typeof(Func<,>).MakeGenericType(x.GetGenericArguments())\n && x.ReturnType == x.GetGenericArguments()[1]);\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17718198/" ]
74,310,071
<p>I have compileSdkVersion 32 and now I can create <code>LocationRequest</code> only using <code>LocationRequest.Builder</code>. LocationRequest.create() currently unavailable, means I can't even call this deprecated static method. So any suggestions how to create LocationRequest for API lower than 31? Thanks.</p>
[ { "answer_id": 74310103, "author": "CommonsWare", "author_id": 115145, "author_profile": "https://Stackoverflow.com/users/115145", "pm_score": 1, "selected": false, "text": "LocationRequest" }, { "answer_id": 74310193, "author": "Konstantin Konopko", "author_id": 1621111, "author_profile": "https://Stackoverflow.com/users/1621111", "pm_score": 0, "selected": false, "text": "com.google.android.gms.location.LocationRequest" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1621111/" ]
74,310,087
<p>In my main function for my haskell game, I start by loading each sprite. I decided to make a data type called SpriteCollection which holds all the sprites (typed <code>Picture</code>) so I can access them later by their name.</p> <p>loadBMP is a Gloss function typed <code>String -&gt; IO Picture</code>. This code works:</p> <pre><code>main = do -- Load sprites playerBmp &lt;- loadBMP &quot;assets/mario.bmp&quot; goombaBmp &lt;- loadBMP &quot;assets/goomba.bmp&quot; brickBmp &lt;- loadBMP &quot;assets/brick.bmp&quot; let sprites = SpriteCollection { marioSprite = playerBmp, goombaSprite = goombaBmp brickSprite = brickBmp } playIO (... sprites ...) </code></pre> <p>So as you can see, as I load more sprites, it feels like I am writing double the code that I should need. Is there a way to get rid of the intermediate variables? For example:</p> <pre><code>main = do -- Load sprites let sprites = SpriteCollection { marioSprite &lt;- loadBMP &quot;assets/mario.bmp&quot;, goombaSprite &lt;- loadBMP &quot;assets/goomba.bmp&quot;, brickSprite &lt;- loadBMP &quot;assets/brick.bmp&quot; } playIO (... sprites ...) </code></pre> <p>but that does not work.</p>
[ { "answer_id": 74310185, "author": "Noughtmare", "author_id": 15207568, "author_profile": "https://Stackoverflow.com/users/15207568", "pm_score": 2, "selected": false, "text": "RecordWildCards" }, { "answer_id": 74310189, "author": "amalloy", "author_id": 625403, "author_profile": "https://Stackoverflow.com/users/625403", "pm_score": 3, "selected": true, "text": "main = do\n sprites <- SpriteCollection <$> \n loadBMP \"mario\" <*> \n loadBMP \"goomba\" <*> \n loadBMP \"brick\"\n ...\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20046346/" ]
74,310,151
<p>I have data stored in gzip archive folders, every archive contains a big file that includes json in the following format:</p> <pre><code>{key:value, key:value} {key:value, key:value} {key:value, key:value} </code></pre> <p>I need to import the data to MongoDB. What is the best way to do that? I can't extract the gzip on my PC as each file (not archived) is about 1950MB.</p>
[ { "answer_id": 74310185, "author": "Noughtmare", "author_id": 15207568, "author_profile": "https://Stackoverflow.com/users/15207568", "pm_score": 2, "selected": false, "text": "RecordWildCards" }, { "answer_id": 74310189, "author": "amalloy", "author_id": 625403, "author_profile": "https://Stackoverflow.com/users/625403", "pm_score": 3, "selected": true, "text": "main = do\n sprites <- SpriteCollection <$> \n loadBMP \"mario\" <*> \n loadBMP \"goomba\" <*> \n loadBMP \"brick\"\n ...\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7249301/" ]
74,310,176
<pre><code> def addition(): int(input1) int(input2) mysum = input1 + input2 print(mysum) input1: str = input(&quot;Enter integer #1 \n &quot;) input2: str = input(&quot;Enter integer #2 \n &quot;) addition() </code></pre> <p>I tried to convert the inputs to ints so that I could add them together but it just treats them like regularly doing:</p> <p>print(text1(&quot;1&quot;) + text2(&quot;1&quot;)</p> <p>result: 11</p> <p>I also tried to use sum() with a &quot;for numbers in input1 and input2&quot; statement but produced the same result.</p>
[ { "answer_id": 74310185, "author": "Noughtmare", "author_id": 15207568, "author_profile": "https://Stackoverflow.com/users/15207568", "pm_score": 2, "selected": false, "text": "RecordWildCards" }, { "answer_id": 74310189, "author": "amalloy", "author_id": 625403, "author_profile": "https://Stackoverflow.com/users/625403", "pm_score": 3, "selected": true, "text": "main = do\n sprites <- SpriteCollection <$> \n loadBMP \"mario\" <*> \n loadBMP \"goomba\" <*> \n loadBMP \"brick\"\n ...\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10184368/" ]
74,310,187
<p>I need select values from a table and returns the total hours for all categories and their occurrences. The challenge is that there are different totals for each occurrence.</p> <p>My query:</p> <pre><code>SELECT c.Category, c.HrsFirstOccur, c.HrsAddlOccur, COUNT(*) AS Occurrences FROM dbo.Categories sc INNER JOIN dbo.Categories c ON sc.CategoryID = c.CategoryID INNER JOIN dbo.OrderHistory oh ON sc.GONumber = oh.OrderNumber AND sc.Item = oh.ItemNumber WHERE sc.BusinessGroupID = 1 AND oh.OrderNumber = 500 AND oh.ItemNumber = '100' GROUP BY c.Category, c.HrsFirstOccur, c.HrsAddlOccur </code></pre> <p>returns the following results:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Category</th> <th>HrsFirstOccur</th> <th>HrsAddlOccur</th> <th>Occurrences</th> </tr> </thead> <tbody> <tr> <td>Inertia</td> <td>24</td> <td>16</td> <td>2</td> </tr> <tr> <td>Lights</td> <td>1</td> <td>0.5</td> <td>4</td> </tr> <tr> <td>Labor</td> <td>10</td> <td>0</td> <td>1</td> </tr> </tbody> </table> </div> <p>The total is calculated based on the number of occurrences. The first one is totaled then for each additional occurrence, the HrsAddlOccur is used.</p> <p>My final result should be (24 + 16) + (1 + 0.5 + 0.5 + 0.5) + 10 for a grand total of 52.5.</p> <p>How do I loop and process the results to total this up?</p>
[ { "answer_id": 74310234, "author": "GMB", "author_id": 10676716, "author_profile": "https://Stackoverflow.com/users/10676716", "pm_score": 3, "selected": true, "text": "SELECT \n c.Category,\n c.HrsFirstOccur,\n c.HrsAddlOccur,\n COUNT(*) AS Occurrences,\n c.HrsFirstOccur + ( COUNT(*) - 1 ) * HrsAddlOccur As Total\nFROM ... < rest of your query > ..\n" }, { "answer_id": 74310350, "author": "nbk", "author_id": 5193536, "author_profile": "https://Stackoverflow.com/users/5193536", "pm_score": 0, "selected": false, "text": "WITH CTE as(SELECT c.Category,\n c.HrsFirstOccur,\n c.HrsAddlOccur,\n COUNT(*) AS Occurrences\n FROM dbo.Categories sc\n INNER JOIN dbo.Categories c ON sc.CategoryID = c.CategoryID\n INNER JOIN dbo.OrderHistory oh ON sc.GONumber = oh.OrderNumber\n AND sc.Item = oh.ItemNumber\n WHERE sc.BusinessGroupID = 1\n AND oh.OrderNumber = 500\n AND oh.ItemNumber = '100')\n SELECT SUM(HrsFirstOccur + (CAST((Occurrences -1) AS DECIMAL(8,2)) * HrsAddlOccur)) as total FROM CTE\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2812743/" ]
74,310,201
<p>Im doing a practice execise for my Coding class and Cant for the love of me figure out how to Fix it, The strings work within the loop but for some reason I cant read them to an array so I can pull them back to work with them later.</p> <p>Ive been having troubles grabbing my strings that im making in the first loop in main, and it has been killing me cause ive tried multiple different solutions with none working</p> <p>Here is the code ive currently writen</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #define MAX_LEN 10 typedef struct { char name[MAX_LEN]; char food[MAX_LEN]; char sound[MAX_LEN]; } Animal; /*Takes a pointer to an Animal struct and returns nothing*/ void getAnimal(Animal* type); /*Takes a pointer to an Animal and returns nothing*/ void visitAnimal(Animal* type); int main() { int i = 0; int count = 0; Animal type[MAX_LEN] = {}; printf(&quot;How many Animals Are there on the farm?: &quot;); scanf(&quot;%d&quot;, &amp;count); for (i = 0; i &lt; count; ++i) { getAnimal(type); } printf(&quot;Welcome to our farm.\n&quot;); for (i = 0; i &lt; count; ++i) { visitAnimal(type); } return 0; } /**/ void getAnimal(Animal* type) { printf(&quot;Enter the name of the animal: &quot;); scanf(&quot;%s&quot;, type-&gt;name); printf(&quot;What does a %s eat?: &quot;, type-&gt;name); scanf(&quot;%s&quot;, type-&gt;food); printf(&quot;Enter the sound made by a %s: &quot;, type-&gt;name); scanf(&quot;%s&quot;, type-&gt;sound); } /**/ void visitAnimal(Animal* type) { printf(&quot;This is a %s. It eats %s and says %s\n&quot;, type-&gt;name, type-&gt;food, type-&gt;sound); } </code></pre> <pre><code>sh-4.2$ gcc -ansi -Wall PE10.c sh-4.2$ a.out How many Animals Are there on the farm?: 2 Enter the name of the animal: cow What does a cow eat?: wheat Enter the sound made by a cow: moo Enter the name of the animal: Duck What does a Duck eat?: seeds Enter the sound made by a Duck: quack Welcome to our farm. This is a Duck. It eats seeds and says quack This is a Duck. It eats seeds and says quack </code></pre>
[ { "answer_id": 74310234, "author": "GMB", "author_id": 10676716, "author_profile": "https://Stackoverflow.com/users/10676716", "pm_score": 3, "selected": true, "text": "SELECT \n c.Category,\n c.HrsFirstOccur,\n c.HrsAddlOccur,\n COUNT(*) AS Occurrences,\n c.HrsFirstOccur + ( COUNT(*) - 1 ) * HrsAddlOccur As Total\nFROM ... < rest of your query > ..\n" }, { "answer_id": 74310350, "author": "nbk", "author_id": 5193536, "author_profile": "https://Stackoverflow.com/users/5193536", "pm_score": 0, "selected": false, "text": "WITH CTE as(SELECT c.Category,\n c.HrsFirstOccur,\n c.HrsAddlOccur,\n COUNT(*) AS Occurrences\n FROM dbo.Categories sc\n INNER JOIN dbo.Categories c ON sc.CategoryID = c.CategoryID\n INNER JOIN dbo.OrderHistory oh ON sc.GONumber = oh.OrderNumber\n AND sc.Item = oh.ItemNumber\n WHERE sc.BusinessGroupID = 1\n AND oh.OrderNumber = 500\n AND oh.ItemNumber = '100')\n SELECT SUM(HrsFirstOccur + (CAST((Occurrences -1) AS DECIMAL(8,2)) * HrsAddlOccur)) as total FROM CTE\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19945170/" ]
74,310,273
<p>I have defined an environment(global) variable in jenkins via configuration as</p> <pre><code>REPORT = &quot;Test, ${CycleNumber},${JOB_NAME}&quot; </code></pre> <p>I have 1 parameter defined in my pipeline called Cycle which has values new &amp; update. Based on this cycle value CycleNumber should be updated and I tried it via groovy using script block in my pipeline as below</p> <pre><code>if(Cycle == &quot;New&quot;) { CycleNumber = &quot;12345&quot; } else if (Cycle == &quot;Update&quot;) { CycleNumber = &quot;7890&quot; } </code></pre> <p>after this update if I do echo &quot;${env.REPORT}&quot; I get the value as &quot;Test,,TestJob&quot; where in the CycleNumber variable is not updated. Could you please let me know if there is a way to update this CycleNumber field ?</p>
[ { "answer_id": 74310382, "author": "Devin Sag", "author_id": 20388932, "author_profile": "https://Stackoverflow.com/users/20388932", "pm_score": 0, "selected": false, "text": "withEnv(['REPORT=...']) {\n // do something with updated env.REPORT\n}\n" }, { "answer_id": 74310611, "author": "ycr", "author_id": 2627018, "author_profile": "https://Stackoverflow.com/users/2627018", "pm_score": 3, "selected": true, "text": "CycleNumber" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11393899/" ]
74,310,301
<p>I'm trying to prepare an array into a json object to send to an API.</p> <p>I'm struggling to figure out how to manipulate my array into the right shape.</p> <p>My array looks something like this.</p> <pre><code>data: [ [&quot;Lisa&quot;, &quot;Heinz&quot;, &quot;1993-04-15&quot; ], [&quot;Bob&quot;, &quot;Dylan&quot;, &quot;1998-09-12&quot;], [&quot;Cabbage&quot;, &quot;Man&quot;, &quot;1990-01-11&quot;], [&quot;&quot;, &quot;&quot;, &quot;&quot;] ] </code></pre> <p>I'd like it to be a json object looking like this:</p> <pre><code>{person:[{&quot;name&quot;:&quot;Lisa&quot;,&quot;last_name&quot;:&quot;Heinz&quot;,&quot;dob&quot;:&quot;1993-04-15&quot;},{&quot;name&quot;:&quot;Bob&quot;,&quot;last_name&quot;:&quot;Dylan&quot;,&quot;dob&quot;:&quot;1998-09-12&quot;},{&quot;name&quot;:&quot;Cabbage&quot;,&quot;last_name&quot;:&quot;Man&quot;,&quot;dob&quot;:&quot;1990-01-11&quot;},{&quot;name&quot;:&quot;&quot;,&quot;last_name&quot;:&quot;&quot;,&quot;dob&quot;:&quot;&quot;}],&quot;object_id&quot;:259,&quot;test&quot;:&quot;bob&quot;,&quot;attribute&quot;:&quot;bob123&quot;} </code></pre> <p>Currently I do this:</p> <pre><code>let json = {} for (let person of formData) { const identifier = `person${formData.indexOf(person)}`; json[identifier] = { name: person[0], last_name: person[1], dob: person[2] } } json.object_id = &quot;259&quot;; json.wp_test = &quot;bob&quot;; json.attribute = &quot;bob123&quot;; </code></pre> <p>Which outputs something like this:</p> <pre><code>{&quot;person0&quot;:{&quot;name&quot;:&quot;Lisa&quot;,&quot;last_name&quot;:&quot;Heinz&quot;,&quot;dob&quot;:&quot;1993-04-15&quot;},&quot;person1&quot;:{&quot;name&quot;:&quot;Bob&quot;,&quot;last_name&quot;:&quot;Dylan&quot;,&quot;dob&quot;:&quot;1998-09-12&quot;},&quot;person2&quot;:{&quot;name&quot;:&quot;Cabbage&quot;,&quot;last_name&quot;:&quot;Man&quot;,&quot;dob&quot;:&quot;1990-01-11&quot;},&quot;person3&quot;:{&quot;name&quot;:&quot;&quot;,&quot;last_name&quot;:&quot;&quot;,&quot;dob&quot;:&quot;&quot;},&quot;object_id&quot;:259,&quot;wp_test&quot;:&quot;bob&quot;,&quot;attribute&quot;:&quot;bob123&quot;} </code></pre> <p>I've tried a variety of things to get the right shape - what's an easily understandable way to get there?</p>
[ { "answer_id": 74310382, "author": "Devin Sag", "author_id": 20388932, "author_profile": "https://Stackoverflow.com/users/20388932", "pm_score": 0, "selected": false, "text": "withEnv(['REPORT=...']) {\n // do something with updated env.REPORT\n}\n" }, { "answer_id": 74310611, "author": "ycr", "author_id": 2627018, "author_profile": "https://Stackoverflow.com/users/2627018", "pm_score": 3, "selected": true, "text": "CycleNumber" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310301", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8302750/" ]
74,310,308
<p>I have multiple nested arrays, how can I map them ? I could map only one nested with the help of @Apostolos</p> <p>`</p> <pre><code> function RequestDetail({match}) { const [request, setRequests] = useState({ user: {} }); const [fulfillment, setFulfillments] = useState({}); const [text, setText] = useState([]); useEffect(() =&gt; { fetchRequest(); }, []); const fetchRequest = () =&gt; { axios .get( `${baseUrl}/${match.params.id}` ) .then((res) =&gt; { setRequests(res.data); console.log(res.data); }) .catch((err) =&gt; console.log(err)); }; const handleSubmit = async (e) =&gt; { //e.preventDefault(); const newfulfillment = {text} try{ const response = await axios.post(`${baseUrl}/${match.params.id}/fulfillments`, newfulfillment); setAuthHeaders(); const allFullfilments = [...fulfillment, response.data]; setFulfillments(allFullfilments); setText(''); } catch (err) { console.log(`Error: ${err.message}`); } } </code></pre> <p>`</p> <p>The array I need is fulfillments <a href="https://i.stack.imgur.com/EP3QH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EP3QH.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74310382, "author": "Devin Sag", "author_id": 20388932, "author_profile": "https://Stackoverflow.com/users/20388932", "pm_score": 0, "selected": false, "text": "withEnv(['REPORT=...']) {\n // do something with updated env.REPORT\n}\n" }, { "answer_id": 74310611, "author": "ycr", "author_id": 2627018, "author_profile": "https://Stackoverflow.com/users/2627018", "pm_score": 3, "selected": true, "text": "CycleNumber" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16811972/" ]
74,310,316
<p>I'm learning C++ and I want to know if there is a way you can use variables defined in a class's constructor in a member function. I've tried looking online and in my textbook but I can't find a definitive answer. For example:</p> <pre><code>class Item { public: Item(std::string str) { std::string text = str; int pos = -1; } void increment() { // how would I reference pos here? pos++; } }; </code></pre> <p>Thanks in advance!</p>
[ { "answer_id": 74310407, "author": "Ted Lyngmo", "author_id": 7582247, "author_profile": "https://Stackoverflow.com/users/7582247", "pm_score": 3, "selected": true, "text": "class Item {\npublic:\n Item(std::string str) : // colon starts the member initializer list\n text(std::move(str)),\n pos{-1} \n {\n // empty constructor body\n }\n\n void increment() {\n pos++; // now you can access `pos`\n }\n\nprivate:\n // member variables\n std::string text;\n int pos;\n};\n" }, { "answer_id": 74310444, "author": "Giogre", "author_id": 10947572, "author_profile": "https://Stackoverflow.com/users/10947572", "pm_score": 1, "selected": false, "text": "text" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15150535/" ]
74,310,324
<p>My JSON looks something like this, its an array of workers and an array of worksites. The workers start with a worksite id so I need to merge them with the worksites (inside an array).</p> <pre class="lang-json prettyprint-override"><code>[ { &quot;worksite_candidates&quot;: { &quot;worksite_id&quot;: &quot;12345&quot;, &quot;worker&quot;: { &quot;id&quot;: &quot;1232&quot;, &quot;managerId&quot;: &quot;09&quot; }, &quot;openDate&quot;: &quot;2022-10-14&quot;, &quot;finalDate&quot;: &quot;2022-12-16&quot; } }, { &quot;worksite_candidates&quot;: { &quot;worksite_id&quot;: &quot;12345&quot;, &quot;worker&quot;: { &quot;id&quot;: &quot;1233&quot;, &quot;managerId&quot;: &quot;08&quot; }, &quot;openDate&quot;: &quot;&quot;, &quot;finalDate&quot;: &quot;&quot; } }, { &quot;worksite_candidates&quot;: { &quot;worksite_id&quot;: &quot;12347&quot;, &quot;worker&quot;: { &quot;id&quot;: &quot;1234&quot;, &quot;managerId&quot;: &quot;09&quot; }, &quot;openDate&quot;: &quot;2022-11-10&quot;, &quot;finalDate&quot;: &quot;2022-11-12&quot; } }, { &quot;worksite&quot;: { &quot;id&quot;: &quot;12345&quot;, &quot;status&quot;: &quot;2&quot;, &quot;dayid&quot;: &quot;2&quot;, &quot;vacancys&quot;: &quot;1&quot;, &quot;countryid&quot;: &quot;2&quot;, &quot;arenaid&quot;: &quot;8&quot; } }, { &quot;worksite&quot;: { &quot;id&quot;: &quot;12347&quot;, &quot;status&quot;: &quot;2&quot;, &quot;dayid&quot;: &quot;2&quot;, &quot;vacancys&quot;: &quot;1&quot;, &quot;countryid&quot;: &quot;2&quot;, &quot;arenaid&quot;: &quot;8&quot; } } ] </code></pre> <p>and I need to transform it using a JOLT to something like this, workers go inside the worksite as an array</p> <pre class="lang-json prettyprint-override"><code>[ { &quot;worksite&quot;: { &quot;id&quot;: &quot;12345&quot;, &quot;status&quot;: &quot;2&quot;, &quot;dayid&quot;: &quot;2&quot;, &quot;vacancys&quot;: &quot;1&quot;, &quot;countryid&quot;: &quot;2&quot;, &quot;arenaid&quot;: &quot;8&quot;, &quot;Candidates&quot;: [ { &quot;worker&quot;: { &quot;id&quot;: &quot;1232&quot;, &quot;managerId&quot;: &quot;09&quot; }, &quot;openDate&quot;: &quot;2022-10-14&quot;, &quot;finalDate&quot;: &quot;2022-12-16&quot; }, { &quot;worker&quot;: { &quot;id&quot;: &quot;1233&quot;, &quot;managerId&quot;: &quot;08&quot; }, &quot;openDate&quot;: &quot;&quot;, &quot;finalDate&quot;: &quot;&quot; } ] } }, { &quot;worksite&quot;: { &quot;id&quot;: &quot;12347&quot;, &quot;status&quot;: &quot;2&quot;, &quot;dayid&quot;: &quot;2&quot;, &quot;vacancys&quot;: &quot;1&quot;, &quot;countryid&quot;: &quot;2&quot;, &quot;arenaid&quot;: &quot;8&quot;, &quot;Candidates&quot;: [ { &quot;worker&quot;: { &quot;id&quot;: &quot;1234&quot;, &quot;managerId&quot;: &quot;09&quot; }, &quot;openDate&quot;: &quot;2022-11-10&quot;, &quot;finalDate&quot;: &quot;2022-11-12&quot; } ] } } ] </code></pre> <p>Please suggest a JOLT to get the desired output. Can't find a way to do it</p>
[ { "answer_id": 74310407, "author": "Ted Lyngmo", "author_id": 7582247, "author_profile": "https://Stackoverflow.com/users/7582247", "pm_score": 3, "selected": true, "text": "class Item {\npublic:\n Item(std::string str) : // colon starts the member initializer list\n text(std::move(str)),\n pos{-1} \n {\n // empty constructor body\n }\n\n void increment() {\n pos++; // now you can access `pos`\n }\n\nprivate:\n // member variables\n std::string text;\n int pos;\n};\n" }, { "answer_id": 74310444, "author": "Giogre", "author_id": 10947572, "author_profile": "https://Stackoverflow.com/users/10947572", "pm_score": 1, "selected": false, "text": "text" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20409944/" ]
74,310,338
<p>given a dictionary</p> <pre><code>dictionary = {'Animal 1': {'Dog': 'Yes', 'Cat': 'No', 'Color': 'Black'}, 'Animal 2': {'Dog': 'Yes', 'Cat': 'No', 'Color': 'Brown'}, 'Animal 3': {'Dog': 'No', 'Cat': 'Yes', 'Color': 'Grey'}} </code></pre> <p>How do I select the Animals that are dogs? expected output <code>['Animal 1','Animal 2']</code></p> <p>I could use:</p> <pre><code>pd.DataFrame.from_dict(dictionary).T.loc[pd.DataFrame.from_dict(dictionary).T[&quot;Dog&quot;]=='Yes',:].index.to_list() </code></pre> <p>but it looks very ugly</p>
[ { "answer_id": 74310377, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 3, "selected": true, "text": "dictionary = {\n \"Animal 1\": {\"Dog\": \"Yes\", \"Cat\": \"No\", \"Color\": \"Black\"},\n \"Animal 2\": {\"Dog\": \"Yes\", \"Cat\": \"No\", \"Color\": \"Brown\"},\n \"Animal 3\": {\"Dog\": \"No\", \"Cat\": \"Yes\", \"Color\": \"Grey\"},\n}\n\nout = [k for k, d in dictionary.items() if d.get(\"Dog\") == \"Yes\"]\nprint(out)\n" }, { "answer_id": 74310429, "author": "tdelaney", "author_id": 642070, "author_profile": "https://Stackoverflow.com/users/642070", "pm_score": 1, "selected": false, "text": "df = pd.DataFrame.from_dict(dictionary).T\ndogs = df[df[\"Dog\"] == \"Yes\"].index.to_list()\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2038360/" ]
74,310,340
<p>I tried to upgrade with Brew</p> <pre><code>$ brew upgrade stripe/stripe-cli/stripe </code></pre> <p>I got:</p> <pre><code>Error: Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)! To rerun under ARM use: arch -arm64 brew install ... To install under x86_64, install Homebrew into /usr/local. </code></pre> <p>AS suggested, I tried</p> <pre><code>$ arch -arm64 brew install </code></pre> <p>But got:</p> <pre><code>Error: Invalid usage: This command requires at least 1 formula or cask argument. </code></pre> <p>I tried installing Rosetta 2 according to this <a href="https://nhancv.medium.com/macbook-pro-m1-homebrew-install-error-7170e4816894" rel="nofollow noreferrer">tutorial</a></p> <pre><code>$ /usr/sbin/softwareupdate --install-rosetta --agree-to-license </code></pre> <p>But I got:</p> <pre><code>Installing Rosetta 2 on this system is not supported. </code></pre>
[ { "answer_id": 74310377, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 3, "selected": true, "text": "dictionary = {\n \"Animal 1\": {\"Dog\": \"Yes\", \"Cat\": \"No\", \"Color\": \"Black\"},\n \"Animal 2\": {\"Dog\": \"Yes\", \"Cat\": \"No\", \"Color\": \"Brown\"},\n \"Animal 3\": {\"Dog\": \"No\", \"Cat\": \"Yes\", \"Color\": \"Grey\"},\n}\n\nout = [k for k, d in dictionary.items() if d.get(\"Dog\") == \"Yes\"]\nprint(out)\n" }, { "answer_id": 74310429, "author": "tdelaney", "author_id": 642070, "author_profile": "https://Stackoverflow.com/users/642070", "pm_score": 1, "selected": false, "text": "df = pd.DataFrame.from_dict(dictionary).T\ndogs = df[df[\"Dog\"] == \"Yes\"].index.to_list()\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5004011/" ]
74,310,410
<p>I am trying to write scirpt to add events from a spreadsheet to my google calendar. This is the script that I am using.</p> <pre><code>function addEvents() { var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); var lr = ss.getLastRow(); var cal = CalendarApp.getCalendarById(&quot;c_fe882662e583725f15fd4faa8c8fdf5124f3affe543778ecdcf0838d6eb17f26@group.calendar.google.com&quot;) var data = ss.getRange(&quot;A3:D&quot;+lr).getValues(); for(var i = 0;i&lt;data.length;i++){ cal.createEvent(data[i][2],data[i][4],data[i][5],{location: data[i][6], description: data[i][7]}); } } </code></pre> <p>When I run the script I am getting the following error. Error Exception: Invalid argument: startTime addEvents @ Code.gs:10</p> <p>This is the sheet that I am using with my dates.</p> <p><a href="https://docs.google.com/spreadsheets/d/1qG68-NLnq9LscPPzlnzRLCfHFIsN3v7V5zvWiVsG0qU/edit?usp=sharing" rel="nofollow noreferrer">https://docs.google.com/spreadsheets/d/1qG68-NLnq9LscPPzlnzRLCfHFIsN3v7V5zvWiVsG0qU/edit?usp=sharing</a></p> <p>I want the title of the event to be column C, the start time to be Column E, the endtime to be Column F, Location G, and Description H.</p>
[ { "answer_id": 74310377, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 3, "selected": true, "text": "dictionary = {\n \"Animal 1\": {\"Dog\": \"Yes\", \"Cat\": \"No\", \"Color\": \"Black\"},\n \"Animal 2\": {\"Dog\": \"Yes\", \"Cat\": \"No\", \"Color\": \"Brown\"},\n \"Animal 3\": {\"Dog\": \"No\", \"Cat\": \"Yes\", \"Color\": \"Grey\"},\n}\n\nout = [k for k, d in dictionary.items() if d.get(\"Dog\") == \"Yes\"]\nprint(out)\n" }, { "answer_id": 74310429, "author": "tdelaney", "author_id": 642070, "author_profile": "https://Stackoverflow.com/users/642070", "pm_score": 1, "selected": false, "text": "df = pd.DataFrame.from_dict(dictionary).T\ndogs = df[df[\"Dog\"] == \"Yes\"].index.to_list()\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19841228/" ]
74,310,417
<p>I'm trying to do something that in my mind is very simple. I have an array of documents (firebase firestore) and I have a method to fetch From Document with timeStamp A to docuemnt with timeStamp B</p> <p>In the fetch function that tries to see if the ref id has already been fetched, but the <code>messages</code> inside the <code>fetchUpTo</code> function never updates. While the one I log in the effect hook, updates as expected. The top Log is the Inside <code>fetchUpTo</code> and the bottom one is the <code>effect</code> one. The logs are from trying to refetch one of the documents present in the bottom log. <a href="https://i.stack.imgur.com/Lg8uX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lg8uX.png" alt="enter image description here" /></a></p> <pre><code>const fetchUpTo = (ref: any) =&gt; { if (isFetching || isAtEnd) { return }; if (!messagesSnapShot) { return; } if (messagesSnapShot.size &lt; queryLimit) { return; } let index = messages.findIndex(d =&gt; d.id === ref.id) if (index !== -1) { if (messageRefs.current[index] !== null) { scrollToMessage(messageRefs.current[index]) return; } } setIsFetching(true) const lastVisible = messages[0] const cQuery = query(collection(fireStore, &quot;scab-chat&quot;, chatId, &quot;messages&quot;), orderBy('time', 'desc'), startAfter(lastVisible.data.time), endAt(ref.data.time)); getDocs(cQuery).then(newDocs =&gt; { if (newDocs.size &lt; queryLimit) { setIsAtEnd(true) } const newD = newDocs.docs.map(doc =&gt; ({ data: doc.data(), id: doc.id, ref: doc })); setMessages(s =&gt; { const f = newD.filter(doc =&gt; s.findIndex(d =&gt; d.id === doc.id) === -1) return [...s, ...f] }) }) } </code></pre> <p>After doing this, I &quot;wait&quot; for the state to update with an Effect hook</p> <pre><code>useEffect(() =&gt; { if (messages) { setIsFetching(false) } }, [messages]) </code></pre> <p>The problem is I have this small part of the code</p> <pre><code>let index = messages.findIndex(d =&gt; d.id === ref.id) if (index !== -1) { if (messageRefs.current[index] !== null) { scrollToMessage(messageRefs.current[index]) return; } } </code></pre>
[ { "answer_id": 74310377, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 3, "selected": true, "text": "dictionary = {\n \"Animal 1\": {\"Dog\": \"Yes\", \"Cat\": \"No\", \"Color\": \"Black\"},\n \"Animal 2\": {\"Dog\": \"Yes\", \"Cat\": \"No\", \"Color\": \"Brown\"},\n \"Animal 3\": {\"Dog\": \"No\", \"Cat\": \"Yes\", \"Color\": \"Grey\"},\n}\n\nout = [k for k, d in dictionary.items() if d.get(\"Dog\") == \"Yes\"]\nprint(out)\n" }, { "answer_id": 74310429, "author": "tdelaney", "author_id": 642070, "author_profile": "https://Stackoverflow.com/users/642070", "pm_score": 1, "selected": false, "text": "df = pd.DataFrame.from_dict(dictionary).T\ndogs = df[df[\"Dog\"] == \"Yes\"].index.to_list()\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15271412/" ]
74,310,420
<p>This code takes two txt files, reads them puts them in 2d arrays and should check if the numbers in the files are magic squares but it keeps returning NumberFormatException error. I'm new to java so if anyone could help me that would be great. I'm pretty sure the problem come from the txt file being string and the 2d array needing to be in int form. But how and where do I make that conversion on my code?</p> <p>this is what i have:</p> <pre><code>import java.io.File; import java.io.FileNotFoundException; import java.util.Arrays; import java.util.Scanner; public class ms { public static void main(String[] args) throws FileNotFoundException { String filename1 = &quot;magicSquaresData.txt&quot;, filename2 = &quot;magicSquaresData.txt&quot;; int nos[][] = null; nos = getArray(filename1); boolean b = isMagicSquare(nos); printArray(nos); if (b) { System.out.println(&quot;It is a magic Square&quot;); } else { System.out.println(&quot;It is not a magic Square&quot;); } System.out.println(&quot;\n&quot;); nos = getArray(filename2); b = isMagicSquare(nos); printArray(nos); if (b) { System.out.println(&quot;It is a magic Square&quot;); } else { System.out.println(&quot;It is not a magic Square&quot;); } } private static int[][] getArray(String filename) throws FileNotFoundException { String line; int nos[][] = null; int size = 0, rows = 0; Scanner sc = null; try { sc = new Scanner(new File(filename)); while (sc.hasNext()) { if (!sc.nextLine().isEmpty()) size++; } sc.close(); nos = new int[size][size]; sc = new Scanner(new File(filename)); while (sc.hasNext()) { line = sc.nextLine(); if (!line.isEmpty()) { String arr[] = line.split(&quot;\t&quot;); for (int i = 0; i &lt; arr.length; i++) { nos[rows][i] = Integer.valueOf(arr[i]); } rows++; } } sc.close(); } catch (FileNotFoundException e) { System.out.println(e); } return nos; } private static void printArray(int[][] nos){ for(int i = 0; i&lt;nos[0].length;i++) { for (int j = 0; j &lt; nos[0].length; j++){ System.out.printf(&quot;%-3d&quot;,nos[i][j]); } System.out.println(); } } private static boolean isMagicSquare(int[][] square) { boolean bool = true; int order = square.length; int[] sumRow = new int[order]; int[] sumCol = new int[order]; int[] sumDiag = new int[2]; Arrays.fill(sumRow, 0); Arrays.fill(sumCol, 0); Arrays.fill(sumDiag, 0); for (int row = 0; row &lt; order; row++){ for (int col = 0; col &lt; order; col++) { sumRow[row] += square[row][col]; } } for (int col = 0; col &lt; order; col++) { for (int row = 0; row &lt; order; row++) { sumCol[col] += square[row][col]; } } for (int row = 0; row &lt; order; row++) { sumDiag[0] += square[row][row]; } for (int row = 0; row &lt; order; row++) { sumDiag[1] += square[row][order - 1 - row]; } bool = true; int sum = sumRow[0]; for (int i = 1; i &lt; order; i++) { bool = bool &amp;&amp; (sum == sumRow[i]); } for (int i = 0; i &lt; order; i++) { bool = bool &amp;&amp; (sum == sumCol[i]); } for (int i = 0; i &lt; 2; i++) { bool = bool &amp;&amp; (sum == sumDiag[i]); } return bool; } } </code></pre>
[ { "answer_id": 74310473, "author": "paulsm4", "author_id": 421195, "author_profile": "https://Stackoverflow.com/users/421195", "pm_score": 0, "selected": false, "text": "nos[rows][i] = Integer.valueOf(arr[i]);" }, { "answer_id": 74310988, "author": "Francisco Borges", "author_id": 18940862, "author_profile": "https://Stackoverflow.com/users/18940862", "pm_score": -1, "selected": false, "text": "String filename1 = \"magicSquaresData.txt\", filename2 = \"magicSquaresData.txt\";" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20412391/" ]
74,310,474
<p>Im creating a side project for fun in react with create-react-app. I created a hook thats supposed to fetch some information in json and it does the job, the problem is that for some reason its sending a request per item in the json and this is a json with 700+ items, is it a re-render situation? Is it because I'm not using useEffect?</p> <pre><code> export const useFetchQL = (url: URL): Array&lt;Object&gt; =&gt; { const [data, setData] = useState([]); const getData = async () =&gt; { let query = ` query { characters{ id name title imageURL leaderSkill passive categories links } }`; let response = await fetch(url,{ method: &quot;POST&quot;, headers: { &quot;Content-Type&quot;: &quot;application/json&quot;, &quot;Accept&quot;: &quot;application/json&quot; }, body: JSON.stringify({query}), }) let data = await response.json(); setData(data.data.characters) } getData(); return data; } </code></pre> <p>I tried calling it in different parts of the project and nothing, same output. What's happening here and how do I avoid it?</p> <p>I only need/want to fetch this information once so I can start using it. I would like to post IMG but I cant.</p> <pre><code>import './App.css'; import Cards from './components/Cards'; import Team from './components/Team'; import Search from './components/Search'; import { AddToTeamProvider } from './context/addToTeamContext'; import { useState } from 'react'; import { useFetchQL } from './hooks/useFetchQL.ts'; function App() { const [chars, setChars] = useState([]); setChars(useFetchQL('https://dokkanapi.azurewebsites.net/graphql')); console.log(chars); return ( &lt;div className=&quot;App&quot;&gt; &lt;AddToTeamProvider&gt; &lt;Team/&gt; &lt;Search/&gt; &lt;Cards/&gt; &lt;/AddToTeamProvider&gt; &lt;/div&gt; ); } export default App; </code></pre>
[ { "answer_id": 74310651, "author": "Mario Petrovic", "author_id": 3955557, "author_profile": "https://Stackoverflow.com/users/3955557", "pm_score": 2, "selected": false, "text": "export const getQL = async (url: URL): Array<Object> => {\n let query = `\n query {\n characters{\n id \n name \n title \n imageURL \n leaderSkill \n passive \n categories \n links\n }\n }`;\n let response = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n },\n body: JSON.stringify({ query }),\n });\n\n return response.json();\n};\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19552582/" ]
74,310,478
<p>I am completely new to r, and so I apologise in advance for any rookie mistakes.</p> <p>I am working with a df containing a large number of TRUE/FALSE, and I want to colour them accordingly - TRUE = green and FALSE = no colour.</p> <p><a href="https://i.stack.imgur.com/ZXc1e.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZXc1e.jpg" alt="The table as of now" /></a></p> <p>Any advice on how to accomplish this in simple, straight forward manner would be much appreciated!</p> <p><strong>This is as far as I got:</strong></p> <pre><code>Kube_Liten %&gt;% select(-shape.size) %&gt;% gt() %&gt;% tab_header( title = 'Liten Kube', subtitle = 'True/False Comparison' ) %&gt;% opt_align_table_header(align = 'left') </code></pre>
[ { "answer_id": 74310651, "author": "Mario Petrovic", "author_id": 3955557, "author_profile": "https://Stackoverflow.com/users/3955557", "pm_score": 2, "selected": false, "text": "export const getQL = async (url: URL): Array<Object> => {\n let query = `\n query {\n characters{\n id \n name \n title \n imageURL \n leaderSkill \n passive \n categories \n links\n }\n }`;\n let response = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n },\n body: JSON.stringify({ query }),\n });\n\n return response.json();\n};\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20364879/" ]
74,310,507
<p>What is the way to manage this tab bar distribution, I want to add a image next to back button and in the center of the content add a text</p> <p>My code:</p> <pre><code>// Create the label let label = UILabel() label.text = &quot;Haz tu pedido&quot; label.sizeToFit() label.textAlignment = NSTextAlignment.center label.medium(size: 20, fontFamily: .roboto, color: .white) label.frame.origin.y = 0 // Create the image view let image = UIImageView() image.image = UIImage(named: &quot;IconSmall.png&quot;) let imageAspect = image.image!.size.width/image.image!.size.height image.frame = CGRect(x: label.frame.origin.x-label.frame.size.height*imageAspect , y: label.frame.origin.y, width: label.frame.size.height*imageAspect, height: label.frame.size.height) image.contentMode = UIView.ContentMode.scaleAspectFit let stack = UIStackView(arrangedSubviews: [image,label]) stack.axis = .horizontal self.tabBarController?.navigationItem.titleView = stack </code></pre>
[ { "answer_id": 74315622, "author": "keyur kathrotiya", "author_id": 10363229, "author_profile": "https://Stackoverflow.com/users/10363229", "pm_score": 2, "selected": false, "text": " self.tabBarController?.navigationItem.title = \"Haz tu pedido\"\n self.tabBarController?.navigationItem.leftBarButtonItem?.image = UIImage(named: \"IconSmall.png\")\n\n" }, { "answer_id": 74396878, "author": "Guillermo Jiménez", "author_id": 14096169, "author_profile": "https://Stackoverflow.com/users/14096169", "pm_score": 1, "selected": false, "text": "navigation bar" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15324640/" ]
74,310,550
<p>I have a table called traffic shown below. I have to write a query which list all the protocols for which incoming traffic is higher than outgoing. The result should be in this format - protocol, traffic_in, traffic_out and sorted in ascending by protocol.</p> <p>Query I wrote was,</p> <pre><code>select protocol , sum(traffic_in) , sum(traffic_out) from traffic group by protocol order by protocol asc; </code></pre> <p>but it did not work. I know I am missing something but couldn't figure out. Could someone please help with the query?</p> <p><a href="https://i.stack.imgur.com/4rWMj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4rWMj.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74310606, "author": "GMB", "author_id": 10676716, "author_profile": "https://Stackoverflow.com/users/10676716", "pm_score": 3, "selected": true, "text": "sum" }, { "answer_id": 74310617, "author": "nbk", "author_id": 5193536, "author_profile": "https://Stackoverflow.com/users/5193536", "pm_score": 1, "selected": false, "text": "HAVING" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13741118/" ]
74,310,558
<p>I'm learning Python at the moment and I'm resolving easy problems to get the feeling of it.</p> <p>I'm trying to read a text file and print the maze that is inside of it:</p> <pre><code>########## ##---##--# #--------# #---###--# #--------# ##-------# ########## </code></pre> <p>For now I have the following:</p> <pre><code>file = open(&quot;maze.txt&quot;, &quot;r&quot;) maze = file.readlines() print(maze) for i in range(len(maze)): for j in range(len()): print(maze[i][j]) file.close() </code></pre> <p>I want to be able to have acess to every single character inside the file, so my goal for now is to print it one by one. But I have no idea what to write inside the range of the second for loop.</p> <p>I know it's kind of a dumb question, but I'm really stuck. Thank you!</p>
[ { "answer_id": 74310606, "author": "GMB", "author_id": 10676716, "author_profile": "https://Stackoverflow.com/users/10676716", "pm_score": 3, "selected": true, "text": "sum" }, { "answer_id": 74310617, "author": "nbk", "author_id": 5193536, "author_profile": "https://Stackoverflow.com/users/5193536", "pm_score": 1, "selected": false, "text": "HAVING" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12145354/" ]
74,310,591
<p>I have a section of my game where I have to click a button to load the next scene. I'm trying to make it so that when any single button is clicked it can no longer be clicked again, since you will be revisiting the same scene later in the game. (It is a text adventure section, so I'm making the route you took unavailable on the next run) I'm rather new at unity and C# so I'm struggling with what should be something simple.</p> <p>I have fiddled around with DontDestroyOnLoad to store variables of the buttons that have been clicked. I have also tried using a dictionary to store a bool on clicked, and an int for the button ID. I have been looking at tons of documentation and other questions from other users, but I can't for the life of me make this work.</p> <p>This is a Variable Manager script on an empty game object at the start of the game, which should store if a button has been clicked and its id -- I followed a tutorial to make it, so it won't get duplicated or destroyed by accident at any point, and so I can make other objects DontDestroyOnLoad as well, but that is not important.</p> <pre><code>public class VarManager : MonoBehaviour { [HideInInspector] public string objectID; public static Dictionary&lt;int, bool&gt; clickedButtons = new Dictionary&lt;int, bool&gt;(); private void Awake() { objectID = name + transform.position.ToString(); } void Start() { for (int i = 0; i &lt; Object.FindObjectsOfType&lt;VarManager&gt;().Length; i++) { if (Object.FindObjectsOfType&lt;VarManager&gt;()[i] != this) { if (Object.FindObjectsOfType&lt;VarManager&gt;()[i].objectID == objectID) { Destroy(gameObject); } } } DontDestroyOnLoad(gameObject); } void Update() { } } </code></pre> <p>This is the button destroy script that I have on each button. It catches the ID of the button, as well as if it's been clicked or not, and should pass it to the Variable Manager, so it is stored across scenes, so that when you come back to the scene, it already knows to be destroyed.</p> <pre><code>public class ButtonDestroy : MonoBehaviour { [SerializeField] int buttonID; public bool clicked; private void Start() { if (clicked == true) { Destroy(gameObject); Debug.Log(&quot;Button Destroyed&quot;); VarManager.clickedButtons.Add(buttonID, clicked); foreach (KeyValuePair&lt;int, bool&gt; kvp in VarManager.clickedButtons) Debug.Log(&quot;Key = {0} + Value = {1}&quot; + kvp.Key + kvp.Value); } } public void TaskOnClick() { clicked = true; Debug.Log(&quot;You have clicked the button&quot;); } private void Update() { //foreach (VarManager.clickedButtons&lt;int, bool&gt; ); } } </code></pre> <p>The code on this second one is not finished, as I got frustrated and decided to put it down for now.</p> <p>Is my logic flawed? Is there a much simpler solution? Should I start it from scratch again?</p>
[ { "answer_id": 74310606, "author": "GMB", "author_id": 10676716, "author_profile": "https://Stackoverflow.com/users/10676716", "pm_score": 3, "selected": true, "text": "sum" }, { "answer_id": 74310617, "author": "nbk", "author_id": 5193536, "author_profile": "https://Stackoverflow.com/users/5193536", "pm_score": 1, "selected": false, "text": "HAVING" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310591", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20412475/" ]
74,310,621
<p>In python I am appending elements to a list. The element name I am getting from an input file, so the element_name is an unknown. I would like to create a new list by adding a number to the end of the original list (dyn_list1) or even by using one of the elements in the list (element_name). How can this be achieved?</p> <pre><code>dyn_list = [] for i in range(4): dyn_list.append(element_name) </code></pre> <p>I thought it would look something like:</p> <pre><code>dyn_list = [] for i in range(4): dyn_list%i.append(element_name) print(dyn_list) </code></pre> <p>But that obviously doesn't work.</p> <p>To try to be clearer, what I am ultimately trying to do is create a dynamically named list, with a list name that I didn't have to explicitly define in advance.</p> <p><strong>Update:</strong><br /> This is not perfect, but it gets close to accomplishing what I want it to:</p> <pre><code> for i in range(4): dyn_list.append(element_name) globals()[f&quot;dyn_list{i}&quot;] = dyn_list print(&quot;dyn_list %s&quot; %dyn_list) print(&quot;Dyn_list1 %s&quot; %dyn_list1) </code></pre>
[ { "answer_id": 74311211, "author": "emirongrr", "author_id": 20408740, "author_profile": "https://Stackoverflow.com/users/20408740", "pm_score": 0, "selected": false, "text": "list_ = [\"ethereum\", \"is\", \"future\"] #your list\nnew_list = [] #declare your new list\nlist_len = len(list_) #get list len\nwith open('dynamic.txt') as f: #read your file for dynamic string\n\n lines = f.readlines()\n\n\nwhile list_len: # so that the dynamic data does not exceed the length of the list\n\n for i in range(list_len):\n new_element = list_[i] + \".\" + str(lines[i])\n new_list.append(new_element)\n list_len -= 1 #Decrease to finish the while loop\n\nfor p in new_list: print(p)\n" }, { "answer_id": 74311444, "author": "Patrick_N", "author_id": 16176617, "author_profile": "https://Stackoverflow.com/users/16176617", "pm_score": 0, "selected": false, "text": "dyn_list = {}\nfor i in range(4) : \n element_name = ...#some code to get element_name\n dyn_list[i] = element_name\n" }, { "answer_id": 74321676, "author": "emirongrr", "author_id": 20408740, "author_profile": "https://Stackoverflow.com/users/20408740", "pm_score": 3, "selected": true, "text": "my_list = [\"something\"]\n\ng = globals()\nfor i in range(1, 5):\n g['dynamiclist_{0}'.format(i)] = my_list\n\nprint(dynamiclist_1)\nprint(dynamiclist_2)\nprint(dynamiclist_3)\nprint(dynamiclist_4)\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9270227/" ]
74,310,623
<p>I have 2 issues, the first is I'm trying to avoid duplicate values and display SELECT DISTINCT Names in a column as shown in the image, there are 2 rows with the name Rob, I only want to display 1 since both rows have the same name.</p> <p>My other issue is I'm trying to fill the textbox with the column information from the selected name that is clicked on</p> <p>index.cshtml</p> <pre><code>@page @model IndexModel @{ ViewData[&quot;Title&quot;] = &quot;Index&quot;; } &lt;form method=&quot;post&quot;&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt; @Html.TextBox(&quot;TxtDepartment&quot;) &lt;/td&gt; &lt;td&gt; &lt;button type=&quot;button&quot; id=&quot;DepartmentSearch&quot;&gt;Search&lt;/button&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;br /&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;div id=&quot;DepartmentResult&quot;&gt;&lt;/div&gt;&lt;/td&gt;&amp;nbsp; &lt;td&gt;&lt;div id=&quot;EmployeeResult&quot;&gt;&lt;/div&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;form method=&quot;post&quot;&gt; &lt;label&gt;Department Name:&lt;/label&gt; &lt;input type=&quot;text&quot; id=&quot;DeptName&quot; /&gt; &lt;label&gt;Photo File Name:&lt;/label&gt; &lt;input type=&quot;text&quot; id=&quot;NameResult&quot; /&gt; &lt;/form&gt; @section Scripts { &lt;script&gt; $(&quot;#DepartmentSearch&quot;).click(function() { $.ajax( { url: &quot;/Index?handler=DisplayDepartment&quot;, type: &quot;POST&quot;, data: { value: $(&quot;#TxtDepartment&quot;).val() }, headers: { RequestVerificationToken: $('input:hidden[name=&quot;__RequestVerificationToken&quot;]').val() }, success: function(data) { $(&quot;#DepartmentResult&quot;).html(data); } }); }); &lt;/script&gt; } </code></pre> <p>index.cs</p> <pre><code>using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using PracticeApp.Models; using System.Linq; namespace PracticeApp.Pages { public class IndexModel : PageModel { public CompanyContext _context; public IndexModel(CompanyContext context) { _context = context; } public PartialViewResult OnGetDisplayDepartment(int value) { return Partial(&quot;_DisplayDepartmentPartial&quot;, _context.Departments.Where(x =&gt; x.DepartmentId == value).ToList()); } public PartialViewResult OnGetDisplayEmployee(string value) { return Partial(&quot;_DisplayEmployeePartial&quot;, _context.Employees.Where(x =&gt; x.DepartmentName == value).ToList()); } public PartialViewResult OnGetDisplayInfo(string value) { return Partial(&quot;_DisplayEmployeePartial&quot;, _context.Employees.Where(x =&gt; x.EmployeeName == value).ToString()); } } } </code></pre> <p>_DisplayDepartmentPartial.cshtml</p> <pre><code>@model IEnumerable&lt;Models.Department&gt; @if (Model.Count() != 0) { &lt;table style=&quot;border: 1px solid black&quot;&gt; &lt;thead&gt; &lt;tr&gt; &lt;th colspan=&quot;2&quot; style=&quot;border: 1px solid black; text-align: center;&quot;&gt;Department Results&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td align=&quot;center&quot; style=&quot;border: 1px solid black; font-weight: bold;&quot;&gt; @Html.DisplayNameFor(m =&gt; m.DepartmentName) &lt;/td&gt; &lt;/tr&gt; @foreach (Models.Department item in Model) { &lt;tr&gt; &lt;td id=&quot;TxtEmployee&quot; align=&quot;center&quot; style=&quot;border: 1px solid black;&quot;&gt; &lt;a id=&quot;EmployeeSearch&quot; href=&quot;javascript:aa()&quot;&gt;@item.DepartmentName&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; } &lt;/tbody&gt; &lt;/table&gt; } else { &lt;p&gt;No data&lt;/p&gt; } &lt;script&gt; $(&quot;#EmployeeSearch&quot;).click(function() { $.ajax( { url: &quot;Index?handler=DisplayEmployee&quot;, type: &quot;POST&quot;, data: { value: $(&quot;#EmployeeSearch&quot;).text() }, headers: { RequestVerificationToken: $('input:hidden[name=&quot;__RequestVerificationToken&quot;]').val() }, success: function(data) { $(&quot;#EmployeeResult&quot;).html(data); } }); }); &lt;/script&gt; </code></pre> <p>_DisplayEmployeePartial.cshtml</p> <pre><code>@model IEnumerable&lt;Models.Employee&gt; @if (Model.Count() != 0) { &lt;table style=&quot;border: 1px solid black&quot;&gt; &lt;thead&gt; &lt;tr&gt; &lt;th colspan=&quot;2&quot; style=&quot;border: 1px solid black; text-align: center;&quot;&gt;Employee Results&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td align=&quot;center&quot; style=&quot;border: 1px solid black; font-weight: bold;&quot;&gt; @Html.DisplayNameFor(m =&gt; m.EmployeeName) &lt;/td&gt; &lt;/tr&gt; @foreach (Models.Employee item in Model) { &lt;tr&gt; &lt;td align=&quot;center&quot; style=&quot;border: 1px solid black;&quot;&gt; &lt;a id=&quot;PopulateNameData&quot; href=&quot;javascript:aa()&quot;&gt;@item.EmployeeName&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; } &lt;/tbody&gt; &lt;/table&gt; } else { &lt;p&gt;No data&lt;/p&gt; } &lt;script&gt; $(&quot;#PopulateNameData&quot;).click(function() { $.ajax( { url: &quot;Index?handler=DisplayEmployee&quot;, type: &quot;POST&quot;, data: { value: $(&quot;#PopulateNameData&quot;).text() }, headers: { RequestVerificationToken: $('input:hidden[name=&quot;__RequestVerificationToken&quot;]').val() }, success: function(data) { $(&quot;#NameResult&quot;).html(data); } }); }); &lt;/script&gt; </code></pre> <p>Employee Model</p> <pre><code>using System; using System.ComponentModel.DataAnnotations; namespace PracticeApp.Models { public partial class Employee { [Display(Name = &quot;Employee ID&quot;)] public int EmployeeId { get; set; } [Display(Name = &quot;Department ID&quot;)] public int DepartmentId { get; set; } [Display(Name = &quot;Name&quot;)] public string EmployeeName { get; set; } = null!; public string DepartmentName { get; set; } = null!; public DateTime DateofJoining { get; set; } public string PhotoFileName { get; set; } } } </code></pre> <p><a href="https://i.stack.imgur.com/6V9jr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6V9jr.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/pS67E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pS67E.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74310852, "author": "Nycolas Silvestre", "author_id": 11587745, "author_profile": "https://Stackoverflow.com/users/11587745", "pm_score": 0, "selected": false, "text": "_context.Employees\n.Where(x => x.DepartmentName == value)\n.Distinct()\n.ToList());\n" }, { "answer_id": 74314898, "author": "Rena", "author_id": 11398810, "author_profile": "https://Stackoverflow.com/users/11398810", "pm_score": 2, "selected": true, "text": "public PartialViewResult OnGetDisplayEmployee(string value)\n{\n return Partial(\"_DisplayEmployeePartial\", _context.Employees.Where(x => x.DepartmentName == value).GroupBy(x=>x.EmployeeName).Select(x => x.First()).ToList());\n}\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9748930/" ]
74,310,658
<p>I have a column in the format -</p> <pre><code>MAX_DATE PROCESS_DATE 2022-10-14T16:09:09.272+00:00 2022-11-08T15:43:29.027+00:00 </code></pre> <p>WHEN I AM WRITING THE CONDITION</p> <pre><code>SELECT * FROM ANC WHERE MAX_DATE &gt; PROCESS_DATE </code></pre> <p>Even then a lot of rows are coming although they do not fulfill the condition. The date format of both is the same, i am not sure how to change both of them in the same date format, i tried the below but still I am getting all rows so the above condition is not working</p> <pre><code>SELECT * FROM ANC WHERE TO_DATE(to_char(MAX_DATE,'DD-MM-YYY'),'DD-MM-YYY') &gt; TO_DATE(to_char(PROCESS_DATE,'DD-MM-YYY'),'DD-MM-YYY') </code></pre> <p>Also this is giving me the output like</p> <pre><code>MAX_DATE PROCESS_DATE 2022-10-14T00:00:00.000+00:00 2022-11-08T00:00:00.000+00:00 </code></pre> <p>How to compare both the dates ?</p>
[ { "answer_id": 74310698, "author": "mark james", "author_id": 18293547, "author_profile": "https://Stackoverflow.com/users/18293547", "pm_score": 0, "selected": false, "text": "where \nconvert(datetime, MAX_DATE) >= convert(datetime,PROCESS_DATE)\n" }, { "answer_id": 74310929, "author": "MT0", "author_id": 1509264, "author_profile": "https://Stackoverflow.com/users/1509264", "pm_score": 2, "selected": true, "text": "TIMESTAMP WITH TIME ZONE" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1490556/" ]
74,310,659
<p>How do I replace multiple column names with different values? Ideally I want to remove certain characters in column names and replace others.</p> <p>I have to run my jupyter notebook twice in order to get this code to work. Does anyone know the reason for this? Also, how would I go about simplifying this code (I am aware of just nesting .replace(), however that doesn't solve my problem). The snippet posted below may not be enough to go off of; please view the following link to my notebook if needed: <a href="https://datalore.jetbrains.com/notebook/iBhSV0RbfC66p84tZsnC24/w3Z6tCriPC5v5XwqCDQpWf/" rel="nofollow noreferrer">https://datalore.jetbrains.com/notebook/iBhSV0RbfC66p84tZsnC24/w3Z6tCriPC5v5XwqCDQpWf/</a></p> <pre><code>for col in df.columns: df.rename(columns={col: col.replace('Deaths - ', '').replace(' - Sex: Both - Age: All Ages (Number)', '')}, inplace=True) df.rename(columns={col: col.replace(' (deaths)', '')}, inplace=True) df.rename(columns={col: col.replace(' ', '_')}, inplace=True) for col in df.columns: df.rename(columns={col: col.lower()}, inplace=True) </code></pre>
[ { "answer_id": 74310717, "author": "Naveed", "author_id": 3494754, "author_profile": "https://Stackoverflow.com/users/3494754", "pm_score": 0, "selected": false, "text": "# create a list of columns and assign to the DF\ncols = ['col1','col2','col3','col4']\ndf.columns=df.columns = cols\n" }, { "answer_id": 74310720, "author": "user29383", "author_id": 20209216, "author_profile": "https://Stackoverflow.com/users/20209216", "pm_score": 3, "selected": true, "text": "inplace" }, { "answer_id": 74311622, "author": "Adrian Diaz", "author_id": 20412560, "author_profile": "https://Stackoverflow.com/users/20412560", "pm_score": 0, "selected": false, "text": "for col in df.columns:\n df = df.rename(columns={col: col.lower()\n .replace('deaths - ', '')\n .replace(' - sex: both - age: all ages (number)', '')\n .replace(' (deaths)', '')\n .replace(' ', '_')\n .replace('amnesty_international', '')}\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310659", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20412560/" ]
74,310,699
<p>I need to add comma between the two curly braces except last one.</p> <p>Below is the input:</p> <pre><code>{&quot;id&quot;: &quot;1&quot;, &quot;eventName&quot;: &quot;Pause&quot;, &quot;eventTime&quot;: &quot;2022-11-02T21:00:42Z&quot;}{&quot;id&quot;: &quot;2&quot;, &quot;eventName&quot;: &quot;Resume&quot;, &quot;eventTime&quot;: &quot;2022-11-03T14:18:47Z&quot;}{&quot;id&quot;: &quot;7&quot;, &quot;eventName&quot;: &quot;Pause&quot;, &quot;eventTime&quot;: &quot;2022-11-02T18:15:48Z&quot;}{&quot;id&quot;: &quot;3&quot;, &quot;eventName&quot;: &quot;Resume&quot;, &quot;eventTime&quot;: &quot;2022-11-03T08:01:19Z&quot;}{&quot;id&quot;: &quot;4&quot;, &quot;eventName&quot;: &quot;Resume&quot;, &quot;eventTime&quot;: &quot;2022-11-03T06:34:42Z&quot;}{&quot;id&quot;: &quot;6&quot;, &quot;eventName&quot;: &quot;Pause&quot;, &quot;eventTime&quot;: &quot;2022-11-02T23:01:07Z&quot;}{&quot;id&quot;: &quot;5&quot;, &quot;eventName&quot;: &quot;Resume&quot;, &quot;eventTime&quot;: &quot;2022-11-03T03:01:05Z&quot;} </code></pre> <p>I tried sed like <code>sed 's/&quot;\[\[}{\]\]\\+&quot;/&quot;,&quot;/g'</code> but no luck</p> <p>expected output:</p> <pre><code>{&quot;id&quot;: &quot;1&quot;, &quot;eventName&quot;: &quot;Pause&quot;, &quot;eventTime&quot;: &quot;2022-11-02T21:00:42Z&quot;},{&quot;id&quot;: &quot;2&quot;, &quot;eventName&quot;: &quot;Resume&quot;, &quot;eventTime&quot;: &quot;2022-11-03T14:18:47Z&quot;},{&quot;id&quot;: &quot;7&quot;, &quot;eventName&quot;: &quot;Pause&quot;, &quot;eventTime&quot;: &quot;2022-11-02T18:15:48Z&quot;},{&quot;id&quot;: &quot;3&quot;, &quot;eventName&quot;: &quot;Resume&quot;, &quot;eventTime&quot;: &quot;2022-11-03T08:01:19Z&quot;},{&quot;id&quot;: &quot;4&quot;, &quot;eventName&quot;: &quot;Resume&quot;, &quot;eventTime&quot;: &quot;2022-11-03T06:34:42Z&quot;},{&quot;id&quot;: &quot;6&quot;, &quot;eventName&quot;: &quot;Pause&quot;, &quot;eventTime&quot;: &quot;2022-11-02T23:01:07Z&quot;},{&quot;id&quot;: &quot;5&quot;, &quot;eventName&quot;: &quot;Resume&quot;, &quot;eventTime&quot;: &quot;2022-11-03T03:01:05Z&quot;} </code></pre>
[ { "answer_id": 74310736, "author": "drx", "author_id": 20353137, "author_profile": "https://Stackoverflow.com/users/20353137", "pm_score": 0, "selected": false, "text": "string.replace()" }, { "answer_id": 74310788, "author": "Barmar", "author_id": 1491895, "author_profile": "https://Stackoverflow.com/users/1491895", "pm_score": 1, "selected": false, "text": "sed 's/}{/},{/g'\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7567597/" ]
74,310,723
<p>For a layout, I need to have three flex items (rows) in a flex container, and I want them justified as <code>space-between</code>... The first row will contain some cloud tags, the second a price, and the third a Read more link.</p> <p>But there will be cases where for specific items, only the last row (the Read more) will need to exist.</p> <p>So, in those cases, for uniformity, I want the Read more link to be placed at the bottom of the container; but <code>space-between</code> doesn't help much towards that approach...</p> <p>What can I do to have a fallback <code>justify-content</code> property set to <code>end</code> for when there is only one child item?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.container { background-color: #aaa; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; height: 200px; margin-bottom: 20px; } .tags { display: flex; } .tags span { background-color: #f0f; padding: 10px; margin: 0 0 0 10px; } .price { display: flex; background-color: #ff0; padding: 10px; font-size: 150% } .read-more { display: flex; background-color: #0ff; padding: 10px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt; &lt;div class="tags"&gt; &lt;span&gt;tag 1&lt;/span&gt;&lt;span&gt;tag2&lt;/span&gt;&lt;span&gt;tag 3&lt;/span&gt; &lt;/div&gt; &lt;div class="price"&gt; $100 &lt;/div&gt; &lt;div class="read-more"&gt; &lt;a href="#"&gt;Read more &gt;&gt;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="container"&gt; &lt;div class="read-more"&gt; &lt;a href="#"&gt;Read more &gt;&gt;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74310777, "author": "Johannes", "author_id": 5641669, "author_profile": "https://Stackoverflow.com/users/5641669", "pm_score": 1, "selected": false, "text": "flex-direction: column-reverse;" }, { "answer_id": 74310824, "author": "Z2r", "author_id": 10885581, "author_profile": "https://Stackoverflow.com/users/10885581", "pm_score": -1, "selected": false, "text": "position: relative;" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15576971/" ]
74,310,742
<p>I’m trying to get a daily aggregate step count from Google's new Health Connect API:</p> <pre><code>val request = AggregateGroupByPeriodRequest( setOf(StepsRecord.COUNT_TOTAL), TimeRangeFilter.between(Instant.now().minus(10, ChronoUnit.DAYS), Instant.now()), Period.ofDays(1), setOf&lt;DataOrigin&gt;()) val response = client.aggregateGroupByPeriod(request) </code></pre> <p>But any aggregate queries that I execute result in this exception:</p> <pre><code>java.lang.IllegalStateException: Duration must be set with physical times at android.os.Parcel.createExceptionOrNull(Parcel.java:3019) at android.os.Parcel.createException(Parcel.java:2995) at android.os.Parcel.readException(Parcel.java:2978) at android.os.Parcel.readException(Parcel.java:2920) at androidx.health.platform.client.service.IHealthDataService$Stub$Proxy.aggregate(IHealthDataService.java:490) at androidx.health.platform.client.impl.ServiceBackedHealthDataClient.aggregate$lambda$9(ServiceBackedHealthDataClient.kt:162) at androidx.health.platform.client.impl.ServiceBackedHealthDataClient.$r8$lambda$sD3sEial4TRJZ0x1SNHmgqr5dxw(Unknown Source:0) at androidx.health.platform.client.impl.ServiceBackedHealthDataClient$$ExternalSyntheticLambda10.execute(Unknown Source:6) at androidx.health.platform.client.impl.ipc.Client$3.execute(Client.java:297) at androidx.health.platform.client.impl.ipc.internal.ServiceConnection.execute(ServiceConnection.java:286) at androidx.health.platform.client.impl.ipc.internal.ServiceConnection.enqueue(ServiceConnection.java:243) at androidx.health.platform.client.impl.ipc.internal.ConnectionManager.handleMessage(ConnectionManager.java:148) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.os.HandlerThread.run(HandlerThread.java:67) Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@850d063, Dispatchers.Main] </code></pre> <p>Any ideas what’s causing this or how to work around it? I can get non-aggregated data without a problem using <code>client.readRecords()</code>.</p>
[ { "answer_id": 74310777, "author": "Johannes", "author_id": 5641669, "author_profile": "https://Stackoverflow.com/users/5641669", "pm_score": 1, "selected": false, "text": "flex-direction: column-reverse;" }, { "answer_id": 74310824, "author": "Z2r", "author_id": 10885581, "author_profile": "https://Stackoverflow.com/users/10885581", "pm_score": -1, "selected": false, "text": "position: relative;" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/526829/" ]
74,310,760
<p>Here's the code I wrote to put the names and numbers into a file:</p> <pre><code>def main(): num_players = int(input(&quot;How many players are there?&quot;)) golf = open(&quot;golf.txt&quot;, 'w') for i in range(num_players): player_name = str(input(&quot;What is the player's name?&quot;)) player_score = int(input(&quot;What is their golf score?&quot;)) golf.write(player_name + '\n') golf.write(str(player_score) + '\n') golf.close() main() </code></pre> <p>and the output:</p> <pre class="lang-none prettyprint-override"><code>Palmer 120 Nicholas 118 Dalton 150 Woods 122 Player 124 </code></pre> <p>In the following code, I am trying to compare the scores to see whose golf score is the best and the worst. I keep getting an error because <code>str</code> object cannot be interpreted as an integer. How can I fix this?</p> <pre class="lang-py prettyprint-override"><code>def main(): golf = open(&quot;golf.txt&quot;,'r') large = 125 small = 119 name=golf.readline() while name != '': for i in range(name): name = golf.readline() score = int(golf.readline()) if score &gt; large: large = score print(name,&quot;is the worst at golf&quot;) while name != '': for i in range(name): name = golf.readline() score = int(golf.readline()) if score &lt; small: large = score print(name, &quot;is the best at golf&quot;) main() </code></pre>
[ { "answer_id": 74310907, "author": "Kilian", "author_id": 15188988, "author_profile": "https://Stackoverflow.com/users/15188988", "pm_score": 0, "selected": false, "text": "def main():\n file_reader = open(\"golf.txt\",'r')\n raw_data = file_reader.read().split('\\n')\n file_reader.close()\n data = list(zip(raw_data[::2], [int(i) for i in raw_data[1::2]]))\n\n # search for smallest\n si = 0\n sv = data[si][1]\n for i, v in enumerate(data):\n if v[1] < sv:\n sv = v[1]\n si = i\n\n # search for biggest\n mi = si\n mv = data[mi][1]\n for i, v in enumerate(data):\n if v[1] > mv:\n mv = v[1]\n mi = i\n\n print(f'{data[si][0]} is the worst player.')\n print(f'{data[mi][0]} is the best player.')\n" }, { "answer_id": 74311150, "author": "Arifa Chan", "author_id": 19574157, "author_profile": "https://Stackoverflow.com/users/19574157", "pm_score": 0, "selected": false, "text": "Read()" }, { "answer_id": 74311326, "author": "Mark Tolonen", "author_id": 235698, "author_profile": "https://Stackoverflow.com/users/235698", "pm_score": 2, "selected": false, "text": "with open(\"golf.txt\") as golf: # make sure the file gets closed using with\n large = 0 # start small with largest\n small = 300 # start large with smallest\n\n # only one pass to read the file\n # compute small and large at the same time\n while name := golf.readline(): # while name is read... := is a newer feature of Python\n score = int(golf.readline()) # also read score\n if score > large:\n large = score\n worst = name.strip() # make sure to save the worst name\n if score < small:\n small = score\n best = name.strip() # and the best name\n\n # print results when done, not in the loop\n print(worst, \"is the worst at golf\")\n print(best, \"is the best at golf\")\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20153932/" ]
74,310,774
<p>I have this date type:</p> <pre><code>data Storage = HDD String Int Int | SSD String Int deriving (Eq, Show) </code></pre> <p>HDD (Producer) (RPM) (Capacity) | SSD (Producer) (Capacity)</p> <p>My task is to list all the HDDs which are larger than the biggest SSD capacity wise (if there are no SSDs, then list all the HDDs) , in this function:</p> <pre><code>hugeHDDs :: [Storage] -&gt; [Storage] </code></pre> <p>This was my try on creating the functions which give the largest capacity of the SSDs:</p> <pre><code>maxSSD :: [Int] -&gt; Int maxSSD = foldr f 0 where f a (cap (SSD c b)) = max a (cap (SSD c b)) cap :: Storage -&gt; Int cap (SSD _ b) = b </code></pre> <p>But it doesn't work and even if it would, I don't really know how to move on</p>
[ { "answer_id": 74316643, "author": "Marc Talbot", "author_id": 670339, "author_profile": "https://Stackoverflow.com/users/670339", "pm_score": 1, "selected": false, "text": "maxSSD :: [Int] -> Int\nmaxSSD = foldr f 0 \n where f a (cap (SSD c b)) = max a (cap (SSD c b))\n" }, { "answer_id": 74329038, "author": "Tamás Veszelyi", "author_id": 20386169, "author_profile": "https://Stackoverflow.com/users/20386169", "pm_score": 1, "selected": true, "text": "data Storage = HDD String Int Int | SSD String Int deriving (Eq, Show)\n\ncapacity :: Storage -> Int\ncapacity (HDD _ _ a) = a\ncapacity (SSD _ b) = b\n\nisHDD :: Storage -> Bool\nisHDD (HDD _ _ _) = True\nisHDD (SSD _ _) = False\n\nmaxSSD :: [Storage] -> Int\nmaxSSD [] = 0\nmaxSSD [(SSD _ c)] = c\nmaxSSD [(HDD _ _ _)] = 0\nmaxSSD (x:xs) \n |(capacity x >= capacity (head xs)) && ((isHDD x) == False) && ((isHDD (head xs)) == False) = maxSSD (x:(tail xs))\n |otherwise = maxSSD xs\n\nhugeHDDs :: [Storage] -> [Storage]\nhugeHDDs [] = []\nhugeHDDs (x:xs) \n |(isHDD x == True) && ((capacity x) > (maxSSD xs)) = (x:(hugeHDDs xs))\n |otherwise = hugeHDDs xs\n" } ]
2022/11/03
[ "https://Stackoverflow.com/questions/74310774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20386169/" ]
74,310,785
<p>How to flip the image in webGL? <a href="https://i.stack.imgur.com/5i17f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5i17f.png" alt="enter image description here" /></a></p> <p>The original image is: <a href="https://i.stack.imgur.com/ETv20.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ETv20.png" alt="enter image description here" /></a></p> <p>I do not have idea at this moment</p>
[ { "answer_id": 74316643, "author": "Marc Talbot", "author_id": 670339, "author_profile": "https://Stackoverflow.com/users/670339", "pm_score": 1, "selected": false, "text": "maxSSD :: [Int] -> Int\nmaxSSD = foldr f 0 \n where f a (cap (SSD c b)) = max a (cap (SSD c b))\n" }, { "answer_id": 74329038, "author": "Tamás Veszelyi", "author_id": 20386169, "author_profile": "https://Stackoverflow.com/users/20386169", "pm_score": 1, "selected": true, "text": "data Storage = HDD String Int Int | SSD String Int deriving (Eq, Show)\n\ncapacity :: Storage -> Int\ncapacity (HDD _ _ a) = a\ncapacity (SSD _ b) = b\n\nisHDD :: Storage -> Bool\nisHDD (HDD _ _ _) = True\nisHDD (SSD _ _) = False\n\nmaxSSD :: [Storage] -> Int\nmaxSSD [] = 0\nmaxSSD [(SSD _ c)] = c\nmaxSSD [(HDD _ _ _)] = 0\nmaxSSD (x:xs) \n |(capacity x >= capacity (head xs)) && ((isHDD x) == False) && ((isHDD (head xs)) == False) = maxSSD (x:(tail xs))\n |otherwise = maxSSD xs\n\nhugeHDDs :: [Storage] -> [Storage]\nhugeHDDs [] = []\nhugeHDDs (x:xs) \n |(isHDD x == True) && ((capacity x) > (maxSSD xs)) = (x:(hugeHDDs xs))\n |otherwise = hugeHDDs xs\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74310785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14264307/" ]
74,310,790
<p>I have a string with a sentence and an array with some words, I need to sort this array so that the words contained in them are descending based on how often they appear in the string.</p> <p>ex:</p> <pre><code>str = &quot;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua&quot; array = [&quot;a&quot;, &quot;em&quot;, &quot;i&quot;, &quot;el&quot;] X = 3 arrayFrequency = [&quot;i&quot;, &quot;a&quot;, &quot;em&quot;, &quot;el&quot;] // They repeat 11, 7, 2, 1 respectively XarrayFrequency = [&quot;i&quot;, &quot;a&quot;, &quot;em&quot;] // The first X words most repeated </code></pre> <p>I tried this way but my brain stopped and I can't think of a way to continue:</p> <pre><code>str = &quot;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua&quot; array = [&quot;a&quot;, &quot;em&quot;, &quot;i&quot;, &quot;el&quot;] X = 3 for(let word of words) { console.log(s.split(word).length - 1) } // output: 7 2 11 1 </code></pre> <p>I was expecting the output returns [&quot;i&quot;, &quot;a&quot;, &quot;em&quot;, &quot;el&quot;] so then I could easily get the first X words from the array</p> <p>ex: X = 3 XarrayFrequency = [&quot;i&quot;, &quot;a&quot;, &quot;em&quot;]</p>
[ { "answer_id": 74316643, "author": "Marc Talbot", "author_id": 670339, "author_profile": "https://Stackoverflow.com/users/670339", "pm_score": 1, "selected": false, "text": "maxSSD :: [Int] -> Int\nmaxSSD = foldr f 0 \n where f a (cap (SSD c b)) = max a (cap (SSD c b))\n" }, { "answer_id": 74329038, "author": "Tamás Veszelyi", "author_id": 20386169, "author_profile": "https://Stackoverflow.com/users/20386169", "pm_score": 1, "selected": true, "text": "data Storage = HDD String Int Int | SSD String Int deriving (Eq, Show)\n\ncapacity :: Storage -> Int\ncapacity (HDD _ _ a) = a\ncapacity (SSD _ b) = b\n\nisHDD :: Storage -> Bool\nisHDD (HDD _ _ _) = True\nisHDD (SSD _ _) = False\n\nmaxSSD :: [Storage] -> Int\nmaxSSD [] = 0\nmaxSSD [(SSD _ c)] = c\nmaxSSD [(HDD _ _ _)] = 0\nmaxSSD (x:xs) \n |(capacity x >= capacity (head xs)) && ((isHDD x) == False) && ((isHDD (head xs)) == False) = maxSSD (x:(tail xs))\n |otherwise = maxSSD xs\n\nhugeHDDs :: [Storage] -> [Storage]\nhugeHDDs [] = []\nhugeHDDs (x:xs) \n |(isHDD x == True) && ((capacity x) > (maxSSD xs)) = (x:(hugeHDDs xs))\n |otherwise = hugeHDDs xs\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74310790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20410595/" ]
74,310,818
<p>I am using REACT 18.2, and I have a .env file that has REACT_APP_API_URL and REACT_APP_API_SECRET so I can use them during API Calls.</p> <p>After I do <code>npm run build</code> and run the app, the variables are successfully used within the application using <code>process.env.REACT_APP_API_URL</code> in JS API Calls.</p> <p>I tried to take out that <code>process.env.REACT_APP_API_URL</code> code and run in the browser console, but null came up. I also searched the source files and did not find the actual value of that .env variable either.</p> <p>So I guess the question, is it now okay to store secret variables in the project's root .env file without a risk of it being available in the source files accessible by user. If it is still an issue, how would one find that information in the browser inspection?</p> <p>Note: I have the following packages in my package.json, but do not import them or have config files set up.</p> <blockquote> <p>&quot;webpack&quot;: &quot;^5.64.4&quot;, &quot;webpack-dev-server&quot;: &quot;^4.6.0&quot;, &quot;webpack-manifest-plugin&quot;: &quot;^4.0.2&quot;, &quot;workbox-webpack-plugin&quot;: &quot;^6.4.1&quot;, &quot;dotenv&quot;: &quot;^10.0.0&quot;, &quot;dotenv-expand&quot;: &quot;^5.1.0&quot;,</p> </blockquote>
[ { "answer_id": 74310853, "author": "CertainPerformance", "author_id": 9515207, "author_profile": "https://Stackoverflow.com/users/9515207", "pm_score": 1, "selected": true, "text": "process.env.REACT_APP_API_URL" }, { "answer_id": 74311125, "author": "shaunpx2", "author_id": 20412938, "author_profile": "https://Stackoverflow.com/users/20412938", "pm_score": 1, "selected": false, "text": " import CryptoJS from \"crypto-js\";\n\n\nconst REACT_APP_API_URL = \"https://your_end_point.com\";\n\nlet key = \"12345678901234567890123456789012\";\nkey = CryptoJS.enc.Utf8.parse(key);\n\nlet iv = \"1234567890123456\";\niv = CryptoJS.enc.Utf8.parse(iv);\n\nlet encrypted = CryptoJS.AES.encrypt(REACT_APP_API_URL , key, { iv: iv });\nexport const encrypted = encrypted.toString();\n\n\nimport const encrypted\nlet decrypted = CryptoJS.AES.decrypt(encrypted, key, { iv: iv });\ndecrypted = decrypted.toString(CryptoJS.enc.Utf8);\n\n// user you decrypted variable in your code to be called...\n\nconsole.log(\"Criptografia AES256 com Base64\");\nconsole.log('Texto: \"meuteste\"');\nconsole.log(`Criptografado: ${encrypted}`);\nconsole.log(`Descriptografado: ${decrypted}`);\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74310818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2612357/" ]
74,310,822
<p>Basically I need a function that makes x decrement to 0 over a certain time period (40 seconds) This seems pretty simple in theory but I haven't been able to do it for a bit now.</p> <pre class="lang-cpp prettyprint-override"><code>static auto decrement = [](int start_value, int end_value, int time) { //i need this function to decrement start_value until it reaches end_value //this should happen over a set time as well, in this case 40 seconds. }; int cool_variable = decrement(2000, 0, 40); //40 seconds, the time should be expected in seconds </code></pre>
[ { "answer_id": 74310978, "author": "Captain Giraffe", "author_id": 451600, "author_profile": "https://Stackoverflow.com/users/451600", "pm_score": -1, "selected": false, "text": "auto decrement = [&cool](int start_value, int end_value, int time) \n{ // assuming start < end. Adjust if not.\n auto step_delay_millis = time * 1000.0 / -(start_value - end_value);\n cool = start_value;\n while(cool < end_value){\n std::this_thread::sleep_for(std::chrono::milliseconds(step_delay_millis));\n ++cool;\n }\n};\n" }, { "answer_id": 74332685, "author": "Howard Hinnant", "author_id": 576911, "author_profile": "https://Stackoverflow.com/users/576911", "pm_score": 0, "selected": false, "text": "cool_variable" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74310822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15390666/" ]
74,310,833
<pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;time.h&gt; #include &lt;stdbool.h&gt; #define BTT 10 void create_pirolito(int list[BTT]); void create_retardado(int list[BTT]); void compare_lists(int list1[BTT], int list2[BTT]); void prints_both(int list1[BTT], int list2[BTT]); void create_pirolito(int list[BTT]) { for(int i=0; i&lt;BTT; i++) { list[i]=rand()%10; } } void create_retardado(int list[BTT]) { for(int i=0; i&lt;BTT; i++) { list[i]=rand()%20; } } void prints_both(int list1[BTT], int list2[BTT]) { int i=0; int j=0; for(int z=0; z&lt;BTT; z++) { printf(&quot;(%2d %2d)\n&quot;, list1[i], list2[j]); i++; j++; } } void compare_lists(int list1[BTT], int list2[BTT]) { char x='X'; for(int i=0; i&lt;BTT; i++) { for(int j=0; j&lt;BTT; j++) { if(list1[i]==list2[j]) { list1[i]==(int)(x); } } printf(&quot;\n&quot;); } } int main() { int pirolito[BTT]; int retardado[BTT]; create_pirolito(pirolito); create_retardado(retardado); compare_lists(pirolito, retardado); prints_both(pirolito, retardado); return 0; } </code></pre> <p>My intention is to compare two different lists and whenever there are equalities, the number saved in that index is exchanged for the letter 'X', this only in the pirolito list, but when I compile there is no error only a large space and then follow the printing of the two lists but without the character 'X' in the respective equalities. how can I print a list with X on repeated numbers like that: lists: pirolito[3, 6, 8, 9, 7, 3, 6, 1, 0, 4] retardado[3, 17, 12, 18, 11, 16, 6, 10, 0, 15] output: [X, 6, 8, 9, 7, 3, X, 1, X, 4] [3, 17, 12, 18, 11, 16, 6, 10, 0, 15]</p>
[ { "answer_id": 74310978, "author": "Captain Giraffe", "author_id": 451600, "author_profile": "https://Stackoverflow.com/users/451600", "pm_score": -1, "selected": false, "text": "auto decrement = [&cool](int start_value, int end_value, int time) \n{ // assuming start < end. Adjust if not.\n auto step_delay_millis = time * 1000.0 / -(start_value - end_value);\n cool = start_value;\n while(cool < end_value){\n std::this_thread::sleep_for(std::chrono::milliseconds(step_delay_millis));\n ++cool;\n }\n};\n" }, { "answer_id": 74332685, "author": "Howard Hinnant", "author_id": 576911, "author_profile": "https://Stackoverflow.com/users/576911", "pm_score": 0, "selected": false, "text": "cool_variable" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74310833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20381544/" ]
74,310,836
<p>I've been googling for how to search in Splunk to find cases where two fields are not equal to each other.</p> <p>The consensus is to do it like this:</p> <pre><code>index=&quot;*&quot; source=&quot;*.csv&quot; | where Requester!=&quot;Requested For&quot; </code></pre> <p>However, this does not work!</p> <p>This returns results where both Requester and Requested For are equal to &quot;Bob Smith.&quot;</p>
[ { "answer_id": 74319434, "author": "warren", "author_id": 4418, "author_profile": "https://Stackoverflow.com/users/4418", "pm_score": 1, "selected": false, "text": "index=* source=*.csv Requester=* NOT Requester=\"Requested For\"\n" }, { "answer_id": 74327189, "author": "Mads Hansen", "author_id": 14419, "author_profile": "https://Stackoverflow.com/users/14419", "pm_score": 0, "selected": false, "text": "index=\"*\" source=\"*.csv\" | where Requester!='Requested For'\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74310836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5848304/" ]
74,310,846
<p>I'm creating a program that counts letters. I created two dictionaries that both have the same word and, because they are the same exact word, both have the same counter. I want to know how to merge the two dictionaries so that it updates the counters as well, but I consistently receive the result &quot;NONE.&quot;</p> <pre><code>word = 'he' word2 = 'he' d1 = {} d2 = {} for letter in word: if letter in d1: d1[letter]+=1 else: d1[letter] = 1 print(d1) #That Outputs: {'h': 1, 'e': 1} for letter in word2: if letter in d2: d2[letter]+=1 else: d2[letter] = 1 print(d2) #That Outputs {'h': 1, 'e': 1} #That Outputs: None #I want the outputs {'h': 2, 'e': 2} </code></pre>
[ { "answer_id": 74319434, "author": "warren", "author_id": 4418, "author_profile": "https://Stackoverflow.com/users/4418", "pm_score": 1, "selected": false, "text": "index=* source=*.csv Requester=* NOT Requester=\"Requested For\"\n" }, { "answer_id": 74327189, "author": "Mads Hansen", "author_id": 14419, "author_profile": "https://Stackoverflow.com/users/14419", "pm_score": 0, "selected": false, "text": "index=\"*\" source=\"*.csv\" | where Requester!='Requested For'\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74310846", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20017084/" ]
74,310,857
<p>I have a Gradle project (say project A) that depends on another Gradle project (say B). Each project live in their own git repository. Sometimes when I have to make a non-trivial change across both projects, I will make the code changes in B and push to remote where our CI will pick it up and release it as a new version.</p> <p>Then in project A, I will update the version for B with the new version number, then run <code>./gradlew generateLock saveLock</code> and then I will be able to use the new changes made in B to implement the feature in A.</p> <p>I want to avoid having to push B to remote and release a new version before I can start using the new code in A. Ideally, I want to make change to B locally and have A reference the local version of the project. That way I can test both and test the whole feature before I push any code. How can I achieve that using Gradle. I am using Gradle 7.5?</p> <p>I declare my dependency on B in A's <code>build.gradle</code> as <code>implementation 'com.something.project-b'</code>. Note that B might have a bunch of other library dependencies of its own declared in its own build.gradle which should still be transitively pulled when I want to use the local version of B in A.</p> <p>Any pointers?</p> <p>There is a local JAR option in Gradle but that will not pull all the transitive dependencies of B and I do not want to build a combined JAR of B and all its dependencies and use that since then I lose all dependency resolution benefits in case of conflicts.</p> <p>Also note that B is an independent project and cannot simply be moved to Project A as a sub-project</p>
[ { "answer_id": 74319434, "author": "warren", "author_id": 4418, "author_profile": "https://Stackoverflow.com/users/4418", "pm_score": 1, "selected": false, "text": "index=* source=*.csv Requester=* NOT Requester=\"Requested For\"\n" }, { "answer_id": 74327189, "author": "Mads Hansen", "author_id": 14419, "author_profile": "https://Stackoverflow.com/users/14419", "pm_score": 0, "selected": false, "text": "index=\"*\" source=\"*.csv\" | where Requester!='Requested For'\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74310857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20403385/" ]
74,310,923
<p>What is the effect of writing the value of the option when returning the closure?</p> <pre class="lang-rust prettyprint-override"><code> let value = Some(0); let closure = if value.is_some() { |value: i32| false } else { |value: i32| true }; </code></pre> <p>The code above does not produce a compilation error However, the code below has a compilation error What's the reason?</p> <pre class="lang-rust prettyprint-override"><code> let closure = if let Some(option_value) = value { |value: i32| option_value == value } else { |value: i32| true }; </code></pre> <p>They're all different types</p> <pre><code>`if` and `else` have incompatible types no two closures, even if identical, have the same type consider boxing your closure and/or using it as a trait object </code></pre> <h2>Box is a solution. But I don't know the difference yet</h2> <pre><code>let closure = if let Some(option_value) = value { Box::new(move |value: i32| option_value == value) } else { Box::new(|value: i32| true) }; </code></pre>
[ { "answer_id": 74314153, "author": "Oussama Gammoudi", "author_id": 3978243, "author_profile": "https://Stackoverflow.com/users/3978243", "pm_score": 0, "selected": false, "text": "Fn(i32) -> bool\n" }, { "answer_id": 74318271, "author": "Masklinn", "author_id": 8182118, "author_profile": "https://Stackoverflow.com/users/8182118", "pm_score": 1, "selected": false, "text": "fn(args...) -> ret" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74310923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20412752/" ]
74,310,924
<p>I'm tryed but that doesn't work</p> <pre><code>&lt;button type=&quot;button&quot; class=&quot;btn btn-secondary glyphicon glyphicon-chevron-left&quot;&gt;&lt;/button&gt; </code></pre>
[ { "answer_id": 74314153, "author": "Oussama Gammoudi", "author_id": 3978243, "author_profile": "https://Stackoverflow.com/users/3978243", "pm_score": 0, "selected": false, "text": "Fn(i32) -> bool\n" }, { "answer_id": 74318271, "author": "Masklinn", "author_id": 8182118, "author_profile": "https://Stackoverflow.com/users/8182118", "pm_score": 1, "selected": false, "text": "fn(args...) -> ret" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74310924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4665067/" ]
74,310,940
<p>In my Outlook, I have two accounts configured:</p> <ol> <li>my main account / inbox: chip@mail.com</li> <li>a shared mailbox: shared@mail.com</li> </ol> <p>So there are two different mailboxes.</p> <p>I could hide some default folders using VBA in both mailboxes. But now I want to unhide a default folder in the shared mailbox shared@mail.com.</p> <p>This is the suggested code:</p> <pre><code>Option Explicit Public Sub UnHideFolders() Dim oFolder As Outlook.Folder Dim oPA As Outlook.propertyAccessor Dim PropName, Value, FolderType As String PropName = &quot;http://schemas.microsoft.com/mapi/proptag/0x10F4000B&quot; Value = False Set oFolder = Session.GetDefaultFolder(olFolderNotes) Set oPA = oFolder.propertyAccessor oPA.SetProperty PropName, Value Set oFolder = Nothing Set oPA = Nothing End Sub </code></pre> <p>This works fine for the first mailbox account / inbox chip@mail.com, but I can't get it to work for the second account / shared mailbox shared@mail.com.</p> <p>How do I have to change the above code to unhide folders in the second account / shared mailbox?</p> <p>Thanks in advance for your support!</p> <p>A somehow desperate Chipy</p>
[ { "answer_id": 74313616, "author": "JohnM", "author_id": 11318818, "author_profile": "https://Stackoverflow.com/users/11318818", "pm_score": 0, "selected": false, "text": "Set oFolder = Session.Accounts(\"shared@mail.com\").DeliveryStore.GetDefaultFolder(olFolderNotes)\n" }, { "answer_id": 74314721, "author": "Eugene Astafiev", "author_id": 1603351, "author_profile": "https://Stackoverflow.com/users/1603351", "pm_score": 1, "selected": false, "text": "Set oFolder = Session.GetDefaultFolder(olFolderNotes)\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74310940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20412744/" ]
74,310,956
<p>I am trying to append multiple occurrences of a string into a list as so:</p> <p>index('Mississippi', 's') [2,3,5,6]</p> <p>s is found at index 2,3,5 and 6.</p> <p>It's a very simple code, yet I'm not sure why mine isn't working ?</p> <p>Python</p> <pre><code>def index(w,l): wo=[] for i in range(len(w)): if w[i] == l: wor= w.find(l) wo.append(wor) return(wo) </code></pre> <p>It only returns [2,2,2,2] when it should return [2,3,5,6] !</p> <p>Thanks!</p>
[ { "answer_id": 74310966, "author": "Barmar", "author_id": 1491895, "author_profile": "https://Stackoverflow.com/users/1491895", "pm_score": 2, "selected": false, "text": "w.find()" }, { "answer_id": 74311037, "author": "Talha Tayyab", "author_id": 13086128, "author_profile": "https://Stackoverflow.com/users/13086128", "pm_score": 0, "selected": false, "text": "find()" }, { "answer_id": 74311052, "author": "Mehdi", "author_id": 2991872, "author_profile": "https://Stackoverflow.com/users/2991872", "pm_score": 0, "selected": false, "text": "import re\n\nwo = [m.span()[0] for m in re.finditer('s', w)]\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74310956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19861101/" ]
74,310,965
<p>I've recently been using Tkinter and I'm usually running into this problem:</p> <p>Let's say I have to clear a label every time I press a button to show something different to avoid the previous output mixing with the new content of the label. I made a code example to show what I mean:</p> <pre><code>from tkinter import * root = Tk() root.minsize(200, 200) def click(): global label_1 if entry_1.get() == '1': label_1 = Label(root, text=&quot;something&quot;) label_1.grid(row=2, column=0) elif entry_1.get() == '2': label_1.grid_remove() label_2 = Label(root, text=&quot;different&quot;) label_2.grid(row=2, column=0) entry_1 = Entry(root) entry_1.grid(row=0, column=0) button_1 = Button(root, text='click', command=click) button_1.grid(row=1, column=0) root.mainloop() </code></pre> <p>First of all, I know if 2 is passed first, it'll throw an error but that's not the problem.</p> <p>My point is if we remove the global variable then we won't be able to remove the previous output and when 2 is passed the old label content will be still there so it'll look mixed with the new one.</p> <p>I know this can be easily handled with OOP but, is there another way to do this? Because I know using global variables is bad practice but I run into this problem very often and the only way I can think of is global variables and of course OOP but that means refactoring the entire code. Or in this case, is it not that bad to use globals?</p> <p>Thanks in advance, I'm still learning Tkinter but the guy on the course is always using globals to solve this kind of scenario.</p>
[ { "answer_id": 74310966, "author": "Barmar", "author_id": 1491895, "author_profile": "https://Stackoverflow.com/users/1491895", "pm_score": 2, "selected": false, "text": "w.find()" }, { "answer_id": 74311037, "author": "Talha Tayyab", "author_id": 13086128, "author_profile": "https://Stackoverflow.com/users/13086128", "pm_score": 0, "selected": false, "text": "find()" }, { "answer_id": 74311052, "author": "Mehdi", "author_id": 2991872, "author_profile": "https://Stackoverflow.com/users/2991872", "pm_score": 0, "selected": false, "text": "import re\n\nwo = [m.span()[0] for m in re.finditer('s', w)]\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74310965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19934155/" ]
74,310,974
<p>Since the version 2210: October 27 update every action brings up the &quot;Excel ran out of resources while attempting to calculate...&quot; warning.</p> <p>It is happening on all the machines in our office and multiple files (all copies of the same file made over many months/years)</p> <p>The workbook is very complicated with a custom ribbon, pages and pages of code.</p> <p>Any ideas?</p> <p>Many thanks</p> <p>I have tried the adjusting the number of calculation threads, clearing the cache and various other solutions offered by google.</p>
[ { "answer_id": 74310966, "author": "Barmar", "author_id": 1491895, "author_profile": "https://Stackoverflow.com/users/1491895", "pm_score": 2, "selected": false, "text": "w.find()" }, { "answer_id": 74311037, "author": "Talha Tayyab", "author_id": 13086128, "author_profile": "https://Stackoverflow.com/users/13086128", "pm_score": 0, "selected": false, "text": "find()" }, { "answer_id": 74311052, "author": "Mehdi", "author_id": 2991872, "author_profile": "https://Stackoverflow.com/users/2991872", "pm_score": 0, "selected": false, "text": "import re\n\nwo = [m.span()[0] for m in re.finditer('s', w)]\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74310974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20412729/" ]
74,310,982
<p>I am trying to implement a exercise with child process and pipes in rust. The exercise consist in child process 2 send message to child process 1, the message that I recieved in c1 I have to return to c2, I have to do it 10 times every 2 seconds. I have a code that might to do it, but when I want to run it, it's still waiting and I can,t see the messages.</p> <p>This is my code:</p> <pre><code>use nix::sys::wait::wait; use nix::unistd::ForkResult::{Child, Parent}; use nix::unistd::fork; use std::io::prelude::*; use std::time::Duration; fn main() { let (mut reader, mut writer) = os_pipe::pipe().unwrap(); let (mut reader_2, mut writer_2) = os_pipe::pipe().unwrap(); let pid = fork(); match pid.expect(&quot;Error during creating child&quot;) { Parent { child } =&gt; { drop(reader); drop(writer_2); let pid_2 = fork(); match pid_2.expect(&quot;Error creating child 2&quot;) { Parent { child } =&gt; {} Child =&gt; { for _ in 1..10 { writer.write(&quot;C1&quot;.as_bytes()).unwrap(); let mut data = String::new(); reader_2.read_to_string(&amp;mut data).unwrap(); println!(&quot;Data from C1, {}&quot;, data); std::thread::sleep(Duration::from_millis(2000)); } } } } Child =&gt; { drop(writer); drop(reader_2); for _ in 1..10 { let mut data = String::new(); reader.read_to_string(&amp;mut data).unwrap(); println!(&quot;Data from C2, {}&quot;, data); writer_2.write(data.to_string().as_bytes()).unwrap(); } } } wait().unwrap(); } </code></pre> <p>Thanks!!!</p>
[ { "answer_id": 74310966, "author": "Barmar", "author_id": 1491895, "author_profile": "https://Stackoverflow.com/users/1491895", "pm_score": 2, "selected": false, "text": "w.find()" }, { "answer_id": 74311037, "author": "Talha Tayyab", "author_id": 13086128, "author_profile": "https://Stackoverflow.com/users/13086128", "pm_score": 0, "selected": false, "text": "find()" }, { "answer_id": 74311052, "author": "Mehdi", "author_id": 2991872, "author_profile": "https://Stackoverflow.com/users/2991872", "pm_score": 0, "selected": false, "text": "import re\n\nwo = [m.span()[0] for m in re.finditer('s', w)]\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74310982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15250954/" ]
74,311,041
<p>I've got below form:</p> <pre><code>&lt;%= f.hidden_field :document_type, value: item %&gt; &lt;%= f.label :file, 'Upload', class: &quot;btn btn-outline-primary btn-sm custom-btn-sm&quot;, id: &quot;upload_kyc_#{idx}&quot;, name: &quot;upload_button&quot; %&gt; &lt;%= f.file_field :file, class: &quot;inputfile&quot;, accept: &quot;jpeg, .jpg, .png, .pdf&quot;, onchange: 'this.form.requestSubmit()' %&gt; </code></pre> <p><code>custom_styles.scss</code></p> <pre><code>.inputfile { width: 0.1px; height: 0.1px; opacity: 0; overflow: hidden; position: absolute; z-index: -1; } </code></pre> <p>Which produces me in the browser:</p> <p><a href="https://i.stack.imgur.com/RnQQ0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RnQQ0.png" alt="enter image description here" /></a></p> <p>Now I want to test this using Capybara. So what I did was:</p> <pre><code>def pdf_path &quot;#{Rails.root}/spec/fixtures/files/sample.pdf&quot; end it 'show message' do login_as user visit profile_path attach_file('upload_kyc_0', pdf_path, visible: true) end </code></pre> <p>But I gets an error:</p> <pre><code> Capybara::ElementNotFound: Unable to find file field &quot;inputfile&quot; that is not disabled within #&lt;Capybara::Node::Element tag=&quot;div&quot; path=&quot;/HTML/BODY[1]/DIV[1]/DIV[1]/DIV[2]&quot;&gt; </code></pre> <p>How to submit that file then?</p>
[ { "answer_id": 74311850, "author": "Alter Lagos", "author_id": 895789, "author_profile": "https://Stackoverflow.com/users/895789", "pm_score": 0, "selected": false, "text": "attach_file('upload_kyc_0', pdf_path, visible: true)` \n" }, { "answer_id": 74312388, "author": "Thomas Walpole", "author_id": 2709090, "author_profile": "https://Stackoverflow.com/users/2709090", "pm_score": 2, "selected": true, "text": "attach_file" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10443890/" ]
74,311,062
<p>I have the following dataframe in R. Is there a quick way to replace all of the NA values in the dataframe with a blank string in dplyr?</p> <pre><code>data &lt;- structure(list(Bank = c(&quot;Primary Residential Mortgage Loans&quot;, &quot;FNB&quot;, &quot;BWHK&quot;, &quot;NED&quot;, &quot;STD&quot;, &quot;Average&quot;, &quot;Non-Primary Residential Mortgage Loans&quot;, &quot;FNB&quot;, &quot;BWHK&quot;, &quot;NED&quot;, &quot;STD&quot;, &quot;Average&quot;), `Q3 2021` = c(NA, 88.3, 66.5, 87.07, 97.97, 84.96, NA, 11.7, 33.5, 12.93, 2.03, 15.04 ), `Q4 2021` = c(NA, 88.43, 66.71, 87.57, 98, 85.18, NA, 11.57, 33.29, 12.43, 2, 14.82), `Q1 2022` = c(NA, 88.67, 66.6, 89.25, 97.9, 85.61, NA, 11.33, 33.4, 10.75, 2.1, 14.39), `Q2 2022` = c(NA, 88.84, 66.67, 89.18, 97.91, 85.65, NA, 11.16, 33.33, 10.82, 2.09, 14.35), `Q3 2022` = c(NA, 89.09, 66.77, 88.96, 97.98, 85.7, NA, 10.91, 33.23, 11.04, 2.02, 14.3), `Q-o-Q % Point Change` = c(NA, 0.25, 0.1, -0.22, 0.07, 0.05, NA, -0.25, -0.1, 0.22, -0.07, -0.05 ), `Y-o-Y % Point Change` = c(NA, 0.79, 0.27, 1.89, 0.01, 0.74, NA, -0.79, -0.27, -1.89, -0.01, -0.74)), row.names = c(NA, -12L ), class = c(&quot;tbl_df&quot;, &quot;tbl&quot;, &quot;data.frame&quot;)) </code></pre>
[ { "answer_id": 74311277, "author": "zephryl", "author_id": 17303805, "author_profile": "https://Stackoverflow.com/users/17303805", "pm_score": 3, "selected": true, "text": "tidyr::replace_na()" }, { "answer_id": 74312059, "author": "TarJae", "author_id": 13321647, "author_profile": "https://Stackoverflow.com/users/13321647", "pm_score": 2, "selected": false, "text": "base R" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12388534/" ]
74,311,093
<p>I would like users to have the ability to update their email address. I created a profile that has fields, but the email address is in the users table. I created a form that adds a custom form field and it works for update. However, I can't find a way to pre-populate this field on a REQUEST.GET.</p> <pre><code># forms.py class ProfileForm(forms.ModelForm): class Meta: model = Profile fields = ('name', 'timezone') class ProfileUpdateForm(ProfileForm): email = forms.EmailField(max_length=254) class Meta(ProfileForm.Meta): fields = ProfileForm.Meta.fields + ('email',) </code></pre> <pre><code># views.py @login_required @require_http_methods([&quot;GET&quot;,&quot;POST&quot;]) def profile_update_view(request): context = {} # Get the logged in users profile profile_object = Profile.objects.get(user=request.user.id) if request.method == 'GET': profile_form = ProfileUpdateForm(None, instance=profile_object) context[&quot;form&quot;] = profile_form # how can I add User.objects.get(id=request.user.id).email to the custom field if request.method == 'POST': profile_form = ProfileUpdateForm(request.POST or None, instance=profile_object) context[&quot;form&quot;] = profile_form if profile_form.is_valid(): try: # email address exists user = User.objects.get(email=profile_form.cleaned_data.get('email')) messages.error(request, 'Failed profile update. Email address already exists.') except: # email address available # get user object user = User.objects.get(id=request.user.id) user.email = profile_form.cleaned_data.get('email') # update user object user.save() profile_form.save() messages.success(request, 'Successful profile update.') return render(request, &quot;profile.html&quot;, context) </code></pre>
[ { "answer_id": 74311277, "author": "zephryl", "author_id": 17303805, "author_profile": "https://Stackoverflow.com/users/17303805", "pm_score": 3, "selected": true, "text": "tidyr::replace_na()" }, { "answer_id": 74312059, "author": "TarJae", "author_id": 13321647, "author_profile": "https://Stackoverflow.com/users/13321647", "pm_score": 2, "selected": false, "text": "base R" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16178069/" ]
74,311,098
<p>I'm trying to redirect a subdomain user to his profile. For example: If user requested user.example.com he gets redirected to example.com/user</p> <p>I searched a lot, and most answers were old and didn't work.</p> <p>Things I have done:</p> <ol> <li>Created A record with *.example.com.</li> <li>Enabled wildcard redirect to example.com (I actually don't know if this is needed) some Stack Overflow answer provided that.</li> <li>Created subdomain in my hosting like *.example.com (but this caused all my subdomains get redirected to the main landing page, which is example.com) some Stack Overflow answers provided that.</li> <li>In my larave project routes.</li> </ol> <pre><code>Route::domain('{name}'.'example.com')-&gt;group(function () { Route::get('/{name}', 'usersController@profile'); }); </code></pre> <pre><code>Route::group(['domain' =&gt; '{account}.example.com'], function () { Route::get('/{name}', 'usersController@profile'); }); </code></pre> <p>I'm really lost between old Stack Overflow answers and PHP hard code. All I want is simple. If user requested user.example.com he gets redirected to his profile example.com/user then he can navigate normally like no need for subdomain later.</p> <p>I don't know what I'm missing or doing wrong!</p>
[ { "answer_id": 74356284, "author": "Satyandra Shakya", "author_id": 12953436, "author_profile": "https://Stackoverflow.com/users/12953436", "pm_score": 0, "selected": false, "text": "RewriteEngine on \nRewriteCond %{HTTP_HOST} ^(.+)\\.example\\.com$ [NC] \nRewriteRule (.*) example.com/%1/$1 [L,R=301,QSA]\n" }, { "answer_id": 74642588, "author": "Vikas Chadha", "author_id": 20656632, "author_profile": "https://Stackoverflow.com/users/20656632", "pm_score": 1, "selected": false, "text": "RewriteEngine on \nRewriteCond %{HTTP_HOST} ^(.*)\\.example\\.com \nRewriteRule ^(.*)$ /%1/$1 [L,NC,QSA]\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20412817/" ]
74,311,103
<p>Inside a STORED PROCEDURE, I'm trying to change the selection of my for loop, depending on the variable, JOINS AND VARIABLES change and retrieve different data, but I can't put an if inside the for loop.</p> <pre><code>V_NEW_LOGIC BOOLEAN; BEGIN V_NEW_LOGIC = false; FOR rec IN( IF(V_NEW_LOGIC) THEN SELECT T1.var_old AS VAR FROM tables [JOIN T1 TABLE#1] ELSE SELECT T2.var_new as VAR FROM tables [JOIN T2 TABLE#2] END IF; ) LOOP /************/ OTHER ACTIONS /************/ END LOOP; </code></pre> <p>Is there a way to achieve it, for code readability I don't want to opt for temporary tables or materialized views, I had thought of a function that returns a list, but I couldn't find a way to incorporate it inside (FOR IN)</p> <p>Any suggestion?</p>
[ { "answer_id": 74312393, "author": "Connor McDonald", "author_id": 7367293, "author_profile": "https://Stackoverflow.com/users/7367293", "pm_score": 2, "selected": false, "text": "V_NEW_LOGIC BOOLEAN;\nv_bool_as_int int;\nBEGIN\n\nV_NEW_LOGIC = false;\nv_bool_as_int := case when V_NEW_LOGIC then 1 else 0 end;\n FOR rec IN(\n SELECT *\n FROM tables\n WHERE ( v_bool_as_int = 1 and conditions#1] )\n OR (( v_bool_as_int = 0 and conditions#2] )\n ) LOOP\n /************\\\n OTHER ACTIONS\n /************\\\nEND LOOP;\n" }, { "answer_id": 74370605, "author": "d r", "author_id": 19023353, "author_profile": "https://Stackoverflow.com/users/19023353", "pm_score": 1, "selected": true, "text": "Declare\n Cursor c_1 IS\n SELECT T1.var_old AS VAR\n FROM tables\n [JOIN T1 TABLE#1];\n \n Cursor c_2 IS\n SELECT T2.var_new as VAR\n FROM tables\n [JOIN T2 TABLE#2];\n \n rec c_1%ROWTYPE;\n-- rec2 c_2%ROWTYPE -- just if selected cursors' columns are of different number and/or type(s)\nBegin\n If your_condition_expression is True Then\n OPEN c_1;\n Else\n OPEN c_2;\n End If;\n \n Loop\n If your_condition_expression is True Then\n FETCH c_1 Into rec;\n EXIT WHEN c_1%NOTFOUND;\n Else\n FETCH c_2 Into rec;\n -- FETCH c_2 Into rec2; -- or this fetch just for the case that selected columns are of different number and/or type(s)\n EXIT WHEN c_2%NOTFOUND;\n End If;\n \n /************/\n OTHER ACTIONS\n /************/\n End Loop;\n \n /*****************/\n SOME OTHER ACTIONS\n /****************/\nEnd\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19708928/" ]
74,311,104
<p>Is there a way to swap the digits of a 2-digit integer without converting to string and back?</p> <pre><code>number = int(input()) digit_1 = number // 10 digit_2 = number % 10 swapped_number = (digit_2 * 10)+ digit_1 print(swapped_number) </code></pre> <p>so this is what i have so far and it works beside for the fact that 10 will be outputed to just 1 instead of 01 any ideas? This also happens with any tens numbers with a 0 in it like 20 50 ect, it just takes out the 0</p> <p>I tried changing the % and //</p>
[ { "answer_id": 74311111, "author": "Andreas", "author_id": 11971785, "author_profile": "https://Stackoverflow.com/users/11971785", "pm_score": 1, "selected": false, "text": "number = input()\nprint(number[::-1])\n" }, { "answer_id": 74311314, "author": "Pierre D", "author_id": 758174, "author_profile": "https://Stackoverflow.com/users/758174", "pm_score": 1, "selected": false, "text": "10 <= x < 100" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20412889/" ]
74,311,130
<p>I just started learning and using Python today and I am working on a discord bot that allows for custom user queries. In this current iteration, the user can specify how many dice and how many sides are rolled. The bot then displays the results in Discord. I am wanting to save these results in an external log file for future use.</p> <p>Currently, everything works, including writing &quot;Dice results:&quot; in the log, but nothing else gets recorded.</p> <p>This is the bot command that receives the user input and then generates results. It also outputs part of what I want it to, but not the message or rather the results themselves.</p> <pre><code>@bot.command(name='diceroll', help='Simulates rolling dice.') async def roll(ctx, number_of_dice: int, number_of_sides: int, *args, **kwargs): dice = [ str(random.choice(range(1, number_of_sides + 1))) for _ in range(number_of_dice) ] with open('dicerolls.log', 'a') as f: f.write('Dice results:\n') await ctx.send(', '.join(dice)) </code></pre> <p>If I posted this wrong I apologize, but I believe I shared the code in question correctly. Also, please let me know if any other info is needed.</p>
[ { "answer_id": 74311111, "author": "Andreas", "author_id": 11971785, "author_profile": "https://Stackoverflow.com/users/11971785", "pm_score": 1, "selected": false, "text": "number = input()\nprint(number[::-1])\n" }, { "answer_id": 74311314, "author": "Pierre D", "author_id": 758174, "author_profile": "https://Stackoverflow.com/users/758174", "pm_score": 1, "selected": false, "text": "10 <= x < 100" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20412896/" ]
74,311,139
<p>I've been using <code>/sys/class/net/eno1/statistics/rx_bytes</code> and <code>tx_bytes</code> to gather stats on my network interface. The trouble is, that network has a device (a Silicon Dust HDHOMERUN HDTV tuner) which constantly streams UDP packets at a very high rate that I don't want to monitor. I'd like to remove that traffic from the monitor - perhaps by only looking at TCP packets.</p> <p>Is there any way to separate out the TCP and UDP stats?</p> <p><code>netstat -st</code> gives some info but it's somewhat cryptic - just how big is a 'segment'? The MTU? The man page is silent on that.</p> <pre><code>$ netstat -st | grep 'segments received' 25449056 segments received 1683 bad segments received $ netstat -st | grep 'segments sent out' 37860139 segments sent out </code></pre>
[ { "answer_id": 74311111, "author": "Andreas", "author_id": 11971785, "author_profile": "https://Stackoverflow.com/users/11971785", "pm_score": 1, "selected": false, "text": "number = input()\nprint(number[::-1])\n" }, { "answer_id": 74311314, "author": "Pierre D", "author_id": 758174, "author_profile": "https://Stackoverflow.com/users/758174", "pm_score": 1, "selected": false, "text": "10 <= x < 100" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2731575/" ]
74,311,176
<p>I have the following <strong>Interface</strong> &amp; <strong>Class</strong> and I also wrote a unit test as shown down, but I got an exception:</p> <p>Assertion failed for the following call: AsyncConsole.example1.IPlayer.Start(i: 1) Expected to find it once or more but didn't find it among the calls:</p> <p>Is there a way to solve that?</p> <pre><code>public interface IPlayer { public void Play(); public void Start(int i); } public class Player : IPlayer { public void Play() { Start(1); } public void Start(int i) { Console.WriteLine(&quot;Start &quot; + i); } } </code></pre> <hr /> <p>Test class</p> <hr /> <pre><code>using FakeItEasy; using Xunit; namespace TestProject { public class TestPlayer { [Fact] public void Play_WhenCalled_ShouldCallStart() { var player = A.Fake&lt;IPlayer&gt;(); player.Play(); //assert A.CallTo(() =&gt; player.Start(1)).MustHaveHappened(); } } } </code></pre> <pre><code>Message: FakeItEasy.ExpectationException : Assertion failed for the following call: AsyncConsole.example1.IPlayer.Start(i: 1) Expected to find it once or more but didn't find it among the calls: 1: IPlayer.Play() </code></pre>
[ { "answer_id": 74311111, "author": "Andreas", "author_id": 11971785, "author_profile": "https://Stackoverflow.com/users/11971785", "pm_score": 1, "selected": false, "text": "number = input()\nprint(number[::-1])\n" }, { "answer_id": 74311314, "author": "Pierre D", "author_id": 758174, "author_profile": "https://Stackoverflow.com/users/758174", "pm_score": 1, "selected": false, "text": "10 <= x < 100" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5101225/" ]
74,311,198
<p>I want to create a window which height should be equal to the height of the child QLabel, the QLabel can be set to any size text and setWrap is True. Here is my current code:</p> <pre class="lang-py prettyprint-override"><code>class TextWindow(QMainWindow): def __init__(self, parent=None): super().__init__(parent) self.setFixedWidth(230) self.centralwidget = QWidget(self) self.centralwidget.setObjectName(&quot;centralwidget&quot;) self.horizontalLayout = QHBoxLayout(self.centralwidget) self.horizontalLayout.setSizeConstraint(QLayout.SizeConstraint.SetMinimumSize) self.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.horizontalLayout.setSpacing(0) self.horizontalLayout.setObjectName(&quot;horizontalLayout&quot;) self.label = QLabel(self.centralwidget) self.label.setWordWrap(True) self.label.setObjectName(&quot;label&quot;) self.horizontalLayout.addWidget(self.label) self.setCentralWidget(self.centralwidget) self.label.setText(&quot;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur non urna nisl. Integer venenatis aliquet faucibus. Nam tristique massa a vestibulum congue. Vivamus nisi felis, volutpat vitae neque quis, pharetra tristique massa. Duis tincidunt et nulla a hendrerit. Vestibulum in molestie lectus.&quot;) </code></pre> <p>Actual behavior:</p> <p><a href="https://i.stack.imgur.com/Cf988.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cf988.png" alt="When big text" /></a></p> <p><a href="https://i.stack.imgur.com/2rRCd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2rRCd.png" alt="When a little text" /></a></p> <p>The text is cut off if there is a lot of it and if there is not enough of it, then there are huge margins between the edge of the window and the text, I want the window height to wrap the text, that is, the height of the window needs to be equal to the size of the text. How can this be done?</p>
[ { "answer_id": 74311309, "author": "Alexander", "author_id": 17829451, "author_profile": "https://Stackoverflow.com/users/17829451", "pm_score": 1, "selected": false, "text": "QLabel" }, { "answer_id": 74311331, "author": "musicamante", "author_id": 2001654, "author_profile": "https://Stackoverflow.com/users/2001654", "pm_score": 3, "selected": true, "text": "self.label.setFixedWidth(230)\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15709458/" ]
74,311,275
<pre><code>import requests from bs4 import BeautifulSoup import openai #write each line of nuclear.txt to a list with open('nuclear.txt', 'r') as f: lines = f.readlines() #remove the newline character from each line lines = [line.rstrip() for line in lines] #gather the text from each website and add it to a new txt file for line in lines: r = requests.get(line) soup = BeautifulSoup(r.text, 'html.parser') text = soup.get_text() with open('nuclear_text.txt', 'a') as f: f.write(text) </code></pre> <p>I'm trying to import openai, however it keeps throwing the error module not found. I have done pip install openai and it downloads, but it appears to be the wrong version of python. How do I select the correct one for pip to install to? I am using VSCode</p> <p>pip install openai</p>
[ { "answer_id": 74311301, "author": "Nic13Gamer", "author_id": 11839142, "author_profile": "https://Stackoverflow.com/users/11839142", "pm_score": 2, "selected": false, "text": "pip3 install openai" }, { "answer_id": 74311332, "author": "JialeDu", "author_id": 19133920, "author_profile": "https://Stackoverflow.com/users/19133920", "pm_score": -1, "selected": false, "text": "openai" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19416518/" ]
74,311,276
<p>Shown Error: NoSuchMethodError: The getter 'text' was called on null. <br> The getter 'text was called on null. <br> Receiver: null <br> Tried calling: text <br></p> <p>How to create getter that get each controller value from the constructor? so that I can call it in the TextFormField</p> <pre><code>import 'package:flutter/material.dart'; class CustomTextFieldForm extends StatefulWidget { final TextEditingController controller; final String hintText; final String errorMessage; const CustomTextFieldForm({ Key? key, required this.controller, required this.hintText, required this.errorMessage, required Null Function(dynamic text) onChanged, }) : super(key: key); @override _CustomTextFieldFormState createState() =&gt; _CustomTextFieldFormState(); } class _CustomTextFieldFormState extends State&lt;CustomTextFieldForm&gt; { get controller =&gt; null; get errorMessage =&gt; null; get hintText =&gt; null; @override Widget build(BuildContext context) { return TextFormField( controller: controller, validator: (String? value) { if (value!.isEmpty) { return errorMessage; } return null; }, decoration: InputDecoration( hintText: hintText, hintStyle: const TextStyle( fontSize: 18, fontWeight: FontWeight.w200, ), errorStyle: TextStyle(height: 0), suffixIcon: controller.text.length &gt; 0 ? IconButton( onPressed: () { controller.clear(); setState(() {}); }, icon: Icon(Icons.cancel, color: Colors.grey)) : null ), ); } } </code></pre>
[ { "answer_id": 74311301, "author": "Nic13Gamer", "author_id": 11839142, "author_profile": "https://Stackoverflow.com/users/11839142", "pm_score": 2, "selected": false, "text": "pip3 install openai" }, { "answer_id": 74311332, "author": "JialeDu", "author_id": 19133920, "author_profile": "https://Stackoverflow.com/users/19133920", "pm_score": -1, "selected": false, "text": "openai" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8765916/" ]
74,311,313
<p>I need the code to sort the array so the highest number comes first, then the lowest number, then go back and sort the highest number left and then the lowest number left.</p> <p>ex: [ 1, 2, 3, 4 ] = [ 4, 1, 3, 2 ]</p> <p>I tried this way, but the code is limited to only 4 numbers in the array. -if the array is [ 1, 0, 0, 1 ] it always returns 1 0 0 1; -if the array is just one (or no number) it returns Infinity.</p> <pre><code>let m = [ ] const max = Math.max.apply(null, m); const min = Math.min.apply(null, m); const max2 = Math.max.apply(null, m.filter(ma2 =&gt; ma2 &lt; max)); const min2 = Math.min.apply(null, m.filter(mi2 =&gt; mi2 &gt; min)); console.log(max, min, max2, min2) // If m = [ 1, 2, 3, 4 ] the output is [ 4, 1, 3, 2 ] // but things go wrong if m = [ 1, 0, 0, 1] or [ 1, 2, 3, 4, 5] or simply [ 5 ] </code></pre> <p>I was expcting a way to sort the array according to any condition</p>
[ { "answer_id": 74311329, "author": "CertainPerformance", "author_id": 9515207, "author_profile": "https://Stackoverflow.com/users/9515207", "pm_score": 3, "selected": true, "text": "const m = [1, 2, 3, 4];\nm.sort((a, b) => a - b); // if not already sorted\n\nconst sorted = [];\nwhile (m.length) {\n sorted.push(m.pop());\n if (m.length) {\n sorted.push(m.shift());\n }\n}\nconsole.log(sorted);" }, { "answer_id": 74311364, "author": "Andrew Parks", "author_id": 5898421, "author_profile": "https://Stackoverflow.com/users/5898421", "pm_score": 2, "selected": false, "text": "let m = [1, 2, 3, 4];\nconst f=m=>m.sort((a,b)=>b-a).map((_,i)=>m[~~(i%2?m.length-i/2:i/2)]);\nconsole.log(f(m));" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20410595/" ]
74,311,324
<p>I am trying to combine my computer vision code with existing code from DepthAI(this is the code that actually retrieves each frame from the camera) in order to analyze a depth map image to determine obstacles. The issue I am running into is that each frame of video from the DepthAI code seems to be in the form of 'np.uint8'. My computer vision code uses PIL.Image, and I was testing it previously using only .png images. Now that I am integrating the code together, I can't seem to get the DepthAI-retrieved-frames to work with the PIL.Image functions. The code boxed in <code>#</code> tries to reshape the np.uint8 array into a common image resolution (1024x750) but the output image is nonsense. I just want to analyze the colormap image so I can pass this class and graduate :( Does anyone know how to go from np.uint8 to a format compatible with Image?</p> <pre><code>import cv2 import depthai as dai import numpy as np from PIL import Image     q = device.getOutputQueue(name=&quot;disparity&quot;, maxSize=4, blocking=False)     while True:         inDisparity = q.get()  # blocking call, will wait until a new data has arrived         frame = inDisparity.getFrame()         # Normalization for better visualization         frame = (frame * (255 / depth.initialConfig.getMaxDisparity())).astype(np.uint8) #this is where the frame is made into np.uint8         cv2.imshow(&quot;disparity&quot;, frame) # the resulting images from disparity look correct         frame = cv2.applyColorMap(frame, cv2.COLORMAP_JET)         cv2.imshow(&quot;disparity_color&quot;, frame). # the resulting image from the colormap looks correct         #now trying to get the frame to work with PIL.Image  #####################################################         reshapedFrame = np.reshape(frame, (750,1024))#         im = Image.fromarray(reshapedFrame)       #           im.show()             # ######################################################         if cv2.waitKey(1) == ord('q'):             break </code></pre> <p><a href="https://i.stack.imgur.com/iOXPy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iOXPy.png" alt="cv2.show() output of disparity and corresponding color map" /></a></p> <p><a href="https://i.stack.imgur.com/g7Cmv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g7Cmv.png" alt="output from reshaped np.uint, nonsense!" /></a></p>
[ { "answer_id": 74311329, "author": "CertainPerformance", "author_id": 9515207, "author_profile": "https://Stackoverflow.com/users/9515207", "pm_score": 3, "selected": true, "text": "const m = [1, 2, 3, 4];\nm.sort((a, b) => a - b); // if not already sorted\n\nconst sorted = [];\nwhile (m.length) {\n sorted.push(m.pop());\n if (m.length) {\n sorted.push(m.shift());\n }\n}\nconsole.log(sorted);" }, { "answer_id": 74311364, "author": "Andrew Parks", "author_id": 5898421, "author_profile": "https://Stackoverflow.com/users/5898421", "pm_score": 2, "selected": false, "text": "let m = [1, 2, 3, 4];\nconst f=m=>m.sort((a,b)=>b-a).map((_,i)=>m[~~(i%2?m.length-i/2:i/2)]);\nconsole.log(f(m));" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16121638/" ]
74,311,359
<p>So I'm trying to implement a method in a <code>Grid</code> class that returns the tile (which is an instance of the tile class) specified by two coordinates the user inputs. But I have no idea how to go about implementing it.</p> <p>I have an <code>ArrayList</code> that contains all the instances of the tiles like this <code>tiles.add(new Tile(x, y));</code></p> <p>This is the method in question and my attempt at returning the desired tile:</p> <pre><code> public ArrayList&lt;Tile&gt; getTileAtPos(int xCoor, int yCoor) { // if the coordinates are out of bounds // return null; // else return tiles.get(/*???*/); // &lt;---------------------- have no clue } </code></pre>
[ { "answer_id": 74311408, "author": "exoad", "author_id": 14501343, "author_profile": "https://Stackoverflow.com/users/14501343", "pm_score": 2, "selected": true, "text": "get()" }, { "answer_id": 74311431, "author": "Teddy Tsai", "author_id": 16959486, "author_profile": "https://Stackoverflow.com/users/16959486", "pm_score": 0, "selected": false, "text": "public List<Tile> getTileAtPos(int xCoor, int yCoor, List<Tile> tiles) {\n\n return tiles.stream()\n .filter(t -> t.getXCoor() == xCoor && t.getYCoor() == yCoor)\n .collect(Collectors.toList());\n}\n\n@Getter\nclass Tile {\n private int xCoor;\n private int yCoor;\n}\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20413002/" ]
74,311,376
<p>Next13 was released a week ago, and I am trying to migrate a next12 app to a next13. I want to use server-side components as much as possible, but I can't seem to use</p> <pre><code>import { createContext } from 'react'; </code></pre> <p>in any server component.</p> <p>I am getting this error:</p> <pre><code>Server Error Error: You're importing a component that needs createContext. It only works in a Client Component but none of its parents are marked with &quot;use client&quot;, so they're Server Components by default. ,---- 1 | import { createContext } from 'react'; : ^^^^^^^^^^^^^ `---- Maybe one of these should be marked as a client entry with &quot;use client&quot;: </code></pre> <p>Is there an alternative here or do I have to resort to prop drilling to get server-side rendering?</p>
[ { "answer_id": 74311552, "author": "Tomer Almog", "author_id": 2044706, "author_profile": "https://Stackoverflow.com/users/2044706", "pm_score": 3, "selected": true, "text": "createServerContext" }, { "answer_id": 74311631, "author": "Nick Vu", "author_id": 9201587, "author_profile": "https://Stackoverflow.com/users/9201587", "pm_score": 0, "selected": false, "text": "createContext" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2044706/" ]
74,311,420
<p>I want to create animated bottomAppBar in jetpack compose (something like image) but Fab position in jetpack compose is only center or end and i need to move FAB to left at least, my code is : <a href="https://i.stack.imgur.com/lFSZG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lFSZG.png" alt="enter image description here" /></a></p> <pre><code>@Composable fun BottomBarSample() { Scaffold( floatingActionButton = { FloatingActionButton( shape = CircleShape, onClick = {}, ) { Icon(imageVector = Icons.Filled.Add, contentDescription = &quot;icon&quot;) } }, floatingActionButtonPosition = FabPosition.End, isFloatingActionButtonDocked = true, bottomBar = { BottomAppBar(backgroundColor = Color.Cyan, cutoutShape = CircleShape) { } } ){ //body } } </code></pre>
[ { "answer_id": 74311501, "author": "z.y", "author_id": 19023745, "author_profile": "https://Stackoverflow.com/users/19023745", "pm_score": 3, "selected": true, "text": "LTR" }, { "answer_id": 74312669, "author": "Thracian", "author_id": 5457853, "author_profile": "https://Stackoverflow.com/users/5457853", "pm_score": 2, "selected": false, "text": "@Composable\nfun BottomBarSample() {\n CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {\n Scaffold(\n floatingActionButton = {\n FloatingActionButton(\n shape = CircleShape,\n onClick = {},\n ) {\n Icon(imageVector = Icons.Filled.Add, contentDescription = \"icon\")\n }\n },\n floatingActionButtonPosition = FabPosition.End,\n isFloatingActionButtonDocked = true,\n bottomBar = {\n\n CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr) {\n BottomAppBar(backgroundColor = Color.Cyan, cutoutShape = CircleShape) {\n\n }\n }\n\n\n }\n\n ) {\n CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr) {\n //body\n }\n }\n }\n}\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11229077/" ]
74,311,446
<p>Apologies in advance for incorrect terminology. I've borrowed script that saves/loads data, which I can use by referencing an interface that has a save and load method. Say I have script1, with a variable called playerHealth, I can then inherit the interface, call the save and load methods, and in those methods basically write that playerHealth, when saved, replaces the playerHealth variable in the Gamedata script (which houses initial values, or 0 in this case). and when loaded, the playerHealth value in the save file replaces the playerHealth in script1.</p> <p>Problem is, clicking the save button, which has attached to it a function to find all variables within all save/load method instances in the various scripts, script1 (playerHealth), script2 (enemyHealth), etc., and execute the save sequence, which replaces all those variables in the gamedata script to the updated values, gives me an error:</p> <blockquote> <p>NullReferenceException: Object reference not set to an instance of an object</p> </blockquote> <p>Looking at the specifics of the error, it points me to the save method called in script1, where there's only this single line of code</p> <pre><code>public void SaveData ( GameData data ) { data.playerHealth = playerHealth; } </code></pre> <p>playerHealth in this case would be a public int.</p> <p>To me, this code seems to make sense? When I click the save button, it should do everything mentioned above, meaning it will find this section in script1, reference current playerHealth in script1, and make the playerHealth in the save file equal to the current playerHealth. But the error pops up regardless.</p> <h2>What did I do to try and fix the issue</h2> <p>Well, not much, as I'm kind of stuck on what to do. I tried adding a debug.log before the single line of code to see if playerHealth actually has a value attached at that point, and it outputs the correct value. So playerHealth, at the point in code just before replacing the savefile value, does indeed have a current value.</p> <h2>Edit</h2> <p>It is most likely <code>data.playerHealth</code> throwing the error from my subsequent attempts. But then it really doesn't make much sense to me. Here's the gamedata.cs file that the above line of code would reference:</p> <pre class="lang-cs prettyprint-override"><code>[System.Serializable] public class GameData { public int playerHealth; public GameData() { this.playerHealth = 0; } } </code></pre> <p>As you can see, I've set a value. So no reason why it should throw an object reference error, right?</p>
[ { "answer_id": 74311501, "author": "z.y", "author_id": 19023745, "author_profile": "https://Stackoverflow.com/users/19023745", "pm_score": 3, "selected": true, "text": "LTR" }, { "answer_id": 74312669, "author": "Thracian", "author_id": 5457853, "author_profile": "https://Stackoverflow.com/users/5457853", "pm_score": 2, "selected": false, "text": "@Composable\nfun BottomBarSample() {\n CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {\n Scaffold(\n floatingActionButton = {\n FloatingActionButton(\n shape = CircleShape,\n onClick = {},\n ) {\n Icon(imageVector = Icons.Filled.Add, contentDescription = \"icon\")\n }\n },\n floatingActionButtonPosition = FabPosition.End,\n isFloatingActionButtonDocked = true,\n bottomBar = {\n\n CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr) {\n BottomAppBar(backgroundColor = Color.Cyan, cutoutShape = CircleShape) {\n\n }\n }\n\n\n }\n\n ) {\n CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr) {\n //body\n }\n }\n }\n}\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20413103/" ]
74,311,449
<h2>problem description:</h2> <p>While writing a loop with groovy in Jenkins pipeline(below is a smallest case can reproduce the problem):</p> <pre><code>def workList = [1, 2, 3, 4] workList.each{work-&gt; if (work == 2) { break } } sh 'hello world' </code></pre> <p>I got an error like below:</p> <pre><code>09:56:34 java.lang.IllegalStateException: unexpected break statement 09:56:34 at com.cloudbees.groovy.cps.impl.CallEnv.getBreakAddress(CallEnv.java:102) 09:56:34 at com.cloudbees.groovy.cps.impl.ProxyEnv.getBreakAddress(ProxyEnv.java:52) 09:56:34 at com.cloudbees.groovy.cps.impl.ProxyEnv.getBreakAddress(ProxyEnv.java:52) 09:56:34 at com.cloudbees.groovy.cps.impl.ProxyEnv.getBreakAddress(ProxyEnv.java:52) 09:56:34 at com.cloudbees.groovy.cps.impl.BreakBlock.eval(BreakBlock.java:21) 09:56:34 at com.cloudbees.groovy.cps.Next.step(Next.java:83) 09:56:34 at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174) 09:56:34 at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163) 09:56:34 at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129) 09:56:34 at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268) 09:56:34 at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163) 09:56:34 at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18) 09:56:34 at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51) 09:56:34 at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185) 09:56:34 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:403) 09:56:34 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:97) 09:56:34 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:315) 09:56:34 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:279) 09:56:34 at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67) 09:56:34 at java.util.concurrent.FutureTask.run(FutureTask.java:266) 09:56:34 at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139) 09:56:34 at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) 09:56:34 at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68) 09:56:34 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 09:56:34 at java.util.concurrent.FutureTask.run(FutureTask.java:266) 09:56:34 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 09:56:34 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 09:56:34 at java.lang.Thread.run(Thread.java:748) 09:56:34 Finished: FAILURE </code></pre> <h2>Things i tried</h2> <ol> <li><p>I read the related stuff about the loop syntax in groovy, break can break the loop. But why here has errors.</p> </li> <li><p>By search the error pattern <code>java.lang.IllegalStateException: unexpected break statement</code> also has no luck</p> </li> </ol> <h2>last</h2> <p>Thanks in advance!</p>
[ { "answer_id": 74311501, "author": "z.y", "author_id": 19023745, "author_profile": "https://Stackoverflow.com/users/19023745", "pm_score": 3, "selected": true, "text": "LTR" }, { "answer_id": 74312669, "author": "Thracian", "author_id": 5457853, "author_profile": "https://Stackoverflow.com/users/5457853", "pm_score": 2, "selected": false, "text": "@Composable\nfun BottomBarSample() {\n CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {\n Scaffold(\n floatingActionButton = {\n FloatingActionButton(\n shape = CircleShape,\n onClick = {},\n ) {\n Icon(imageVector = Icons.Filled.Add, contentDescription = \"icon\")\n }\n },\n floatingActionButtonPosition = FabPosition.End,\n isFloatingActionButtonDocked = true,\n bottomBar = {\n\n CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr) {\n BottomAppBar(backgroundColor = Color.Cyan, cutoutShape = CircleShape) {\n\n }\n }\n\n\n }\n\n ) {\n CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr) {\n //body\n }\n }\n }\n}\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7663663/" ]
74,311,471
<p>Below is the example.</p> <pre><code>BEGIN set tablenameA = 'tablenamelala'; SELECT * FROM table($tablenameA); END </code></pre> <p>I am expecting it will return me the result from the select statement.</p>
[ { "answer_id": 74311501, "author": "z.y", "author_id": 19023745, "author_profile": "https://Stackoverflow.com/users/19023745", "pm_score": 3, "selected": true, "text": "LTR" }, { "answer_id": 74312669, "author": "Thracian", "author_id": 5457853, "author_profile": "https://Stackoverflow.com/users/5457853", "pm_score": 2, "selected": false, "text": "@Composable\nfun BottomBarSample() {\n CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {\n Scaffold(\n floatingActionButton = {\n FloatingActionButton(\n shape = CircleShape,\n onClick = {},\n ) {\n Icon(imageVector = Icons.Filled.Add, contentDescription = \"icon\")\n }\n },\n floatingActionButtonPosition = FabPosition.End,\n isFloatingActionButtonDocked = true,\n bottomBar = {\n\n CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr) {\n BottomAppBar(backgroundColor = Color.Cyan, cutoutShape = CircleShape) {\n\n }\n }\n\n\n }\n\n ) {\n CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr) {\n //body\n }\n }\n }\n}\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14167512/" ]
74,311,527
<p>I am writing a fairly asynchronous program using the <code>Thread</code> library. I'll have a lot of different threads that need to access <code>string list ref</code>, is this safe without using a <code>Mutex</code>? I learned earlier today that <code>Hashtbl</code> requires a <code>Mutex</code>, but I couldn't find any information on <code>ref</code>.</p>
[ { "answer_id": 74311991, "author": "Chris", "author_id": 15261315, "author_profile": "https://Stackoverflow.com/users/15261315", "pm_score": 2, "selected": false, "text": "Hashtbl" }, { "answer_id": 74314390, "author": "octachron", "author_id": 7369366, "author_profile": "https://Stackoverflow.com/users/7369366", "pm_score": 4, "selected": true, "text": "threads" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12283863/" ]
74,311,536
<p>Tried searching around couldn't really find anything. Was hoping to find a way to revert the datetime format.</p> <p>So I start off with: 4-11-22 and I want to change to Friday, 12 November 2022.</p> <p>Using the intl package</p>
[ { "answer_id": 74311703, "author": "M14", "author_id": 16410436, "author_profile": "https://Stackoverflow.com/users/16410436", "pm_score": 0, "selected": false, "text": " final oldDateDateTime = DateFormat('dd-MM-yy').parse('4-11-22');\n final newDateString = DateFormat('EEEE, d MMMM y', 'en_US').format(oldDateDateTime);\n\n print(oldDateDateTime.toString());\n print(newDateString);\n\n" }, { "answer_id": 74311728, "author": "iqfareez", "author_id": 13617136, "author_profile": "https://Stackoverflow.com/users/13617136", "pm_score": 2, "selected": true, "text": "import 'package:intl/intl.dart';\n" }, { "answer_id": 74311743, "author": "7eg", "author_id": 13311722, "author_profile": "https://Stackoverflow.com/users/13311722", "pm_score": 0, "selected": false, "text": " final DateFormat formatter = DateFormat('EEEE, dd MMMM yyyy');\n final String formatted = formatter.format(DateTime.now());\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11642462/" ]
74,311,595
<p>I'm trying to extract specific sentence in string column and copy&amp;paste it to Nan rows in another column</p> <p>here is the detail:</p> <pre><code></code></pre> <p>`</p> <pre><code> KEY WARNSIGN_DTL EVENT_DTL 55116 77981 Nan 1. Name: Johnson 2. Date: 09 June 2018 3. Place to be found: Wall street 4. Found in his apartment 5. Method: overdose Pentanil 56545 73565 Nan 1. Name: Hay 2. Date: 04 November 2021 3. Place to be found: Plano 75075 4. Found in her car 5. Method: hanging up his neck 56780 77844 3. Place to be found: Coppell 4. Found in his wife's apartment 1. Name: Beard 2. Date: 05 November 2021 3. Place to be found: Coppell 4. Found in his wife's house 5. shooting gun on his head </code></pre> <p>`</p> <pre><code> </code></pre> <p>I want to extract <code>3. Place to be found: xxx 4. Found in xxx xxx</code> string out of EVENT_DTL and put it in WARNSIGN_DTL column in which the rows with Nan(missin value).</p> <p>Here is the desired output:</p> <pre><code>``` ` ``` KEY WARNSIGN_DTL EVENT_DTL 55116 77981 3. Place to be found: Wall street 4. Found in his apartment 1. Name: Johnson 2. Date: 09 June 2018 3. Place to be found: Wall street 4. Found in his apartment 5. Method: overdose Pentanil 56545 73565 3. Place to be found: Plano 75075 4. Found in her car 1. Name: Hay 2. Date: 04 November 2021 3. Place to be found: Plano 75075 4. Found in her car 5. Method: hanging up his neck 56780 77844 3. Place to be found: Coppell 4. Found in his wife's house 1. Name: Beard 2. Date: 05 November 2021 3. Place to be found: Coppell 4. Found in his wife's house 5. shooting gun on his head ``` ` ``` </code></pre>
[ { "answer_id": 74311703, "author": "M14", "author_id": 16410436, "author_profile": "https://Stackoverflow.com/users/16410436", "pm_score": 0, "selected": false, "text": " final oldDateDateTime = DateFormat('dd-MM-yy').parse('4-11-22');\n final newDateString = DateFormat('EEEE, d MMMM y', 'en_US').format(oldDateDateTime);\n\n print(oldDateDateTime.toString());\n print(newDateString);\n\n" }, { "answer_id": 74311728, "author": "iqfareez", "author_id": 13617136, "author_profile": "https://Stackoverflow.com/users/13617136", "pm_score": 2, "selected": true, "text": "import 'package:intl/intl.dart';\n" }, { "answer_id": 74311743, "author": "7eg", "author_id": 13311722, "author_profile": "https://Stackoverflow.com/users/13311722", "pm_score": 0, "selected": false, "text": " final DateFormat formatter = DateFormat('EEEE, dd MMMM yyyy');\n final String formatted = formatter.format(DateTime.now());\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20376341/" ]
74,311,627
<p>I have this object:</p> <pre><code>[ { &quot;latitude&quot;: &quot;113.232160114&quot;, &quot;longitude&quot;: &quot;-1.786978559&quot; }, { &quot;latitude&quot;: &quot;113.211955085&quot;, &quot;longitude&quot;: &quot;-1.790031776&quot; } ] </code></pre> <p>is there any possible way to make it look like this using JavaScript?</p> <pre><code>[ [ 113.232160114, -1.786978559 ], [ 113.211955085, -1.790031776 ] ] </code></pre>
[ { "answer_id": 74311667, "author": "Andrew Parks", "author_id": 5898421, "author_profile": "https://Stackoverflow.com/users/5898421", "pm_score": 1, "selected": false, "text": "const a = [\n { latitude: '113.232160114', longitude: '-1.786978559' },\n { latitude: '113.211955085', longitude: '-1.790031776' }\n];\nconsole.log(a.map(({latitude:i, longitude:j})=>[i,j]));" }, { "answer_id": 74311668, "author": "Amadan", "author_id": 240443, "author_profile": "https://Stackoverflow.com/users/240443", "pm_score": 3, "selected": true, "text": "Array.prototype.map" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2948285/" ]
74,311,664
<p>Hello when I use binascii.a2b_hex, error is occured. There is no error message but the return value is wrong. Here is the data and the resule.</p> <p>Input : FEB10AA86764FFFF Output : b'\xfe\xb1\n\xa8gd\xff\xff'</p> <pre><code>import binascii ta['data'] = ta['data'].apply(binascii.a2b_hex) </code></pre> <p>n\xa8gd &lt;- what it happend? how can i fix it?</p> <p>I am trying to use various hex values with my code. Most of values such as fe, b1 would work well.</p>
[ { "answer_id": 74311737, "author": "Mark Ransom", "author_id": 5987, "author_profile": "https://Stackoverflow.com/users/5987", "pm_score": 2, "selected": false, "text": "FE \\xfe\nB1 \\xb1\n0A \\n\nA8 \\xa8\n67 g\n64 d\nFF \\xff\nFF \\xff\n" }, { "answer_id": 74313147, "author": "ukBaz", "author_id": 7721752, "author_profile": "https://Stackoverflow.com/users/7721752", "pm_score": 1, "selected": false, "text": "$ python3\nPython 3.9.2 (default, Mar 12 2021, 04:06:34) \n[GCC 10.2.1 20210110] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> data = bytes.fromhex('FEB10AA86764FFFF')\n>>> data\nb'\\xfe\\xb1\\n\\xa8gd\\xff\\xff'\n>>> print(data)\nb'\\xfe\\xb1\\n\\xa8gd\\xff\\xff'\n>>> print(list(data))\n[254, 177, 10, 168, 103, 100, 255, 255]\n>>> for idx, x in enumerate(data):\n... ascii_char = data[idx:idx+1].decode('ascii', 'ignore')\n... print(f\"data[{idx}] is denary={x:3d} or hex={x:#04x} or ascii={ascii_char}\")\n... \ndata[0] is denary=254 or hex=0xfe or ascii=\ndata[1] is denary=177 or hex=0xb1 or ascii=\ndata[2] is denary= 10 or hex=0x0a or ascii=\n\ndata[3] is denary=168 or hex=0xa8 or ascii=\ndata[4] is denary=103 or hex=0x67 or ascii=g\ndata[5] is denary=100 or hex=0x64 or ascii=d\ndata[6] is denary=255 or hex=0xff or ascii=\ndata[7] is denary=255 or hex=0xff or ascii=\n>>> data.hex()\n'feb10aa86764ffff'\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14769586/" ]
74,311,670
<p>I'm very new to backend development, and I'm feeling a bit stuck with accomplishing my goal here. I'm trying to pull testimonials and blurbs out of an SQL database and have them populate on the page that I've built. Currently, the code that I've written does nothing but pull an error (8178) and tell me that it expects a parameter that hasn't been supplied. Any guidance would be appreciated. I feel like it's something rather small that I'm missing, but I haven't had any luck in figuring it out.</p> <p>This currently will provide the Response.Write that I've included, and that's working, but I can't seem to figure out what is stopping me from pulling the info off of the database. I've checked that my connection String is correct and active.</p> <pre class="lang-cs prettyprint-override"><code>//This will load blurbs that will initially appear on page. protected void Page_Load(object sender, EventArgs e) { //BlurbID = Session[&quot;Blurb&quot;]; Page.Title = &quot;Testimonials&quot;; try { sqlConnectionStr.Open(); SqlCommand getBlurb = new SqlCommand(@&quot;SELECT b.BlurbID, b.BlurbText FROM TestimonialBlurb b LEFT JOIN Testimonial t ON t.BlurbID = b.BlurbID WHERE t.BlurbID=@BlurbID&quot;, sqlConnectionStr); getBlurb.Parameters.AddWithValue(&quot;@BlurbID&quot;, SqlDbType.Int); getBlurb.Parameters.AddWithValue(&quot;@BlurbText&quot;, SqlDbType.VarChar); DataTable userBlurb = new DataTable(); using (SqlDataAdapter blurbDA = new SqlDataAdapter(getBlurb)) { blurbDA.Fill(userBlurb); DataView blurbDV = new DataView(userBlurb); if (blurbDV.Count &lt; 1) { Response.Write(&quot;There are currently no testimonials available.&quot;); } else { for (int i = 0; i &lt; blurbDV.Count; i++) { blurbPH.Controls.Add(new Literal { Text = blurbDV[i].Row[&quot;BlurbText&quot;].ToString() + &quot;&lt;strong&gt; &quot; + blurbDV[i].Row[&quot;Blurb&quot;].ToString() + &quot;&lt;/strong&gt;&quot; }); } } } } catch (Exception ex) { blurbPH.Controls.Add(new Literal { Text = ex.ToString() }); } finally { sqlConnectionStr.Close(); } </code></pre>
[ { "answer_id": 74311737, "author": "Mark Ransom", "author_id": 5987, "author_profile": "https://Stackoverflow.com/users/5987", "pm_score": 2, "selected": false, "text": "FE \\xfe\nB1 \\xb1\n0A \\n\nA8 \\xa8\n67 g\n64 d\nFF \\xff\nFF \\xff\n" }, { "answer_id": 74313147, "author": "ukBaz", "author_id": 7721752, "author_profile": "https://Stackoverflow.com/users/7721752", "pm_score": 1, "selected": false, "text": "$ python3\nPython 3.9.2 (default, Mar 12 2021, 04:06:34) \n[GCC 10.2.1 20210110] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> data = bytes.fromhex('FEB10AA86764FFFF')\n>>> data\nb'\\xfe\\xb1\\n\\xa8gd\\xff\\xff'\n>>> print(data)\nb'\\xfe\\xb1\\n\\xa8gd\\xff\\xff'\n>>> print(list(data))\n[254, 177, 10, 168, 103, 100, 255, 255]\n>>> for idx, x in enumerate(data):\n... ascii_char = data[idx:idx+1].decode('ascii', 'ignore')\n... print(f\"data[{idx}] is denary={x:3d} or hex={x:#04x} or ascii={ascii_char}\")\n... \ndata[0] is denary=254 or hex=0xfe or ascii=\ndata[1] is denary=177 or hex=0xb1 or ascii=\ndata[2] is denary= 10 or hex=0x0a or ascii=\n\ndata[3] is denary=168 or hex=0xa8 or ascii=\ndata[4] is denary=103 or hex=0x67 or ascii=g\ndata[5] is denary=100 or hex=0x64 or ascii=d\ndata[6] is denary=255 or hex=0xff or ascii=\ndata[7] is denary=255 or hex=0xff or ascii=\n>>> data.hex()\n'feb10aa86764ffff'\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311670", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20412989/" ]
74,311,676
<p>Hope you are doing well. Here is one problem needs your help. I am working with some data on pandas.</p> <p><a href="https://i.stack.imgur.com/nLHbR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nLHbR.png" alt="enter image description here" /></a></p> <p>I want to get 2 points that have the closest distance to the value entered by the user.</p> <p>For example, if I input d=4, I want to get the fastest way to output the result ((C:18 and F:14) or (B:3 and D:7)). The method I implemented is a method used by elementary school students, so I am ashamed to post it.</p> <p>pandas or pyspark will be helpful for me. Thank you very much.</p>
[ { "answer_id": 74311740, "author": "BENY", "author_id": 7964527, "author_profile": "https://Stackoverflow.com/users/7964527", "pm_score": 2, "selected": false, "text": "merge" }, { "answer_id": 74319475, "author": "Jason Baker", "author_id": 3249641, "author_profile": "https://Stackoverflow.com/users/3249641", "pm_score": 2, "selected": true, "text": "import heapq\nfrom itertools import combinations\n\nimport pandas as pd\n\n\nclass ClosestDistances:\n \"\"\"\n :arg data: pd.DataFrame\n :arg user_selection: int\n :arg points: int\n :return list[tuple(dict, dict)]\n \"\"\"\n def __init__(self, **kwargs):\n df = kwargs.get(\"data\")\n self.user_selection = kwargs.get(\"user_selection\")\n self.points = kwargs.get(\"points\")\n self.df_mapping = dict(zip(df[\"letter\"], df[\"number\"]))\n\n def main(self) -> list:\n possible_combinations = self.possible_combinations()\n closest_points = self.nearest_difference(possible_combinations)\n\n return self.map_nearest(closest_points)\n\n def nearest_difference(self, combos: list) -> list:\n return heapq.nsmallest(self.points, combos, lambda x: abs((x[0] - x[1]) - self.user_selection))\n\n def possible_combinations(self) -> list:\n return [sorted(x, reverse=True) for x in combinations(self.df_mapping.values(), self.points)]\n\n def get_keys(self) -> dict:\n return {v: k for k, v in self.df_mapping.items()}\n\n def map_nearest(self, closest_points: list) -> list:\n iterator = iter([{self.get_keys().get(x): x} for i in closest_points for x in i])\n\n return list(zip(iterator, iterator))\n\n\ndata = pd.DataFrame({\n \"letter\": [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\"],\n \"number\": [12, 3, 18, 7, 11, 14, 5]\n})\n\nclosest = ClosestDistances(data=data, user_selection=4, points=2).main()\nprint(closest)\n\n[({'D': 7}, {'B': 3}), ({'C': 18}, {'F': 14})]\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311676", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14837844/" ]
74,311,689
<p>I have an AWS Terraform repo where i have an architecture for an AWS solution.</p> <p>Over time people have gone onto the management console and made changes to the architecture without changing the terraform code causing a drift between the repo and the actual architecture on aws.</p> <p>Is there a way i can change detect the drift and update my <code>main.tf</code> file to match the new architecture? I know you can use <code>terraform apply -refresh</code> to update the state file but does this affect the <code>main.tf</code> file aswell? Does anyone have a solution for a problem like this so that all my files are updated correctly? Thanks!</p>
[ { "answer_id": 74311740, "author": "BENY", "author_id": 7964527, "author_profile": "https://Stackoverflow.com/users/7964527", "pm_score": 2, "selected": false, "text": "merge" }, { "answer_id": 74319475, "author": "Jason Baker", "author_id": 3249641, "author_profile": "https://Stackoverflow.com/users/3249641", "pm_score": 2, "selected": true, "text": "import heapq\nfrom itertools import combinations\n\nimport pandas as pd\n\n\nclass ClosestDistances:\n \"\"\"\n :arg data: pd.DataFrame\n :arg user_selection: int\n :arg points: int\n :return list[tuple(dict, dict)]\n \"\"\"\n def __init__(self, **kwargs):\n df = kwargs.get(\"data\")\n self.user_selection = kwargs.get(\"user_selection\")\n self.points = kwargs.get(\"points\")\n self.df_mapping = dict(zip(df[\"letter\"], df[\"number\"]))\n\n def main(self) -> list:\n possible_combinations = self.possible_combinations()\n closest_points = self.nearest_difference(possible_combinations)\n\n return self.map_nearest(closest_points)\n\n def nearest_difference(self, combos: list) -> list:\n return heapq.nsmallest(self.points, combos, lambda x: abs((x[0] - x[1]) - self.user_selection))\n\n def possible_combinations(self) -> list:\n return [sorted(x, reverse=True) for x in combinations(self.df_mapping.values(), self.points)]\n\n def get_keys(self) -> dict:\n return {v: k for k, v in self.df_mapping.items()}\n\n def map_nearest(self, closest_points: list) -> list:\n iterator = iter([{self.get_keys().get(x): x} for i in closest_points for x in i])\n\n return list(zip(iterator, iterator))\n\n\ndata = pd.DataFrame({\n \"letter\": [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\"],\n \"number\": [12, 3, 18, 7, 11, 14, 5]\n})\n\nclosest = ClosestDistances(data=data, user_selection=4, points=2).main()\nprint(closest)\n\n[({'D': 7}, {'B': 3}), ({'C': 18}, {'F': 14})]\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14065037/" ]
74,311,745
<p>I am fairly new to iOS development. I am trying to update the property &quot;cars&quot; in the &quot;Sire&quot; model using a stepper. Whenever I press on + or - from the stepper controls, it changes the value by a step and then becomes disabled.</p> <p>If I bind the stepper to the variable cars, it works flawlessly.</p> <pre><code>struct AddSireView: View { // @EnvironmentObject var sireVM:SiresViewModel @State var newSire = Sire (id:&quot;&quot;, name: &quot;&quot;, ownerID: 0, info:&quot;&quot;, achievments: &quot;&quot;, cars: 0, cups: 0) @State var cars = 0 @State var cups = 0 @State private var state = FormState.idle var createAction: CreateAction // TODO: Put validation that the added sire is valid and if not show errors to the user var body: some View { Form { VStack (spacing: 18) { TitledTextView(text: $newSire.name, placeHolder: &quot;الاسم&quot;, title: &quot;الاسم&quot;) TiltedTextEditor(text: Binding&lt;String&gt;($newSire.info)!, title: &quot;معلومات البعير&quot;) TiltedTextEditor(text: Binding&lt;String&gt;($newSire.achievments)!, title: &quot;انجازات البعير&quot;) } Stepper(value: $newSire.cars, in: 0...10,step:1) { HStack { Text (&quot;سيارات:&quot;) TextField(&quot;Cars&quot;, value: $newSire.cars, formatter: NumberFormatter.decimal) } } </code></pre> <p><a href="https://i.stack.imgur.com/jweLs.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jweLs.gif" alt="enter image description here" /></a></p> <p>And this is the &quot;Sire&quot; struct</p> <pre><code>struct Sire: Hashable, Identifiable, Decodable { static func == (lhs: Sire, rhs: Sire) -&gt; Bool { lhs.id == rhs.id &amp;&amp; lhs.name == rhs.name &amp;&amp; lhs.ownerID == rhs.ownerID } func hash(into hasher: inout Hasher) { hasher.combine(id) hasher.combine(name) hasher.combine(ownerID) } var id:String var name:String var ownerID:Int var fatherID:String? var info:String? var achievments:String? var cars:Int = 0 var cups:Int = 0 init (id:String, name:String, ownerID:Int, info:String? = nil, achievments:String? = nil, fatherID:String? = nil, cars:Int = 0, cups:Int = 0) { self.id = id self.name = name self.ownerID = ownerID self.cars = cars self.cups = cups self.info = info self.achievments = achievments } } </code></pre> <p>&quot;Sire&quot; was a class and i made it a Struct thinking that that was the problem, but to no avail.</p>
[ { "answer_id": 74312516, "author": "workingdog support Ukraine", "author_id": 11969817, "author_profile": "https://Stackoverflow.com/users/11969817", "pm_score": 2, "selected": false, "text": "ObservableObject" }, { "answer_id": 74317993, "author": "lorem ipsum", "author_id": 12738750, "author_profile": "https://Stackoverflow.com/users/12738750", "pm_score": 2, "selected": true, "text": "Equatable" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13603702/" ]
74,311,772
<p>I have a text file and the contents can be:</p> <pre><code>debug --configuration &quot;Release&quot; \p corebuild </code></pre> <p>Or:</p> <pre><code>-c &quot;Dev&quot; debug </code></pre> <p>And now I have to validate the file to see if it has any pattern that matches <code>--configuration</code> or <code>-c</code> and print the string next to it</p> <ul> <li>Pattern 1 - It should be <code>Release</code></li> <li>Pattern 2 - It should be <code>Dev</code></li> </ul> <p>How to achieve this in single command?</p> <p>I tried below , but not sure how to extract only the release in the text , I only tried to see 1 pattern at a time</p> <pre><code>PS Z:\&gt; $text = Get-Content 'your_file_path' -raw PS Z:\&gt; $Regex = [Regex]::new(&quot;(?&lt;=\-\-configuration)(.*)&quot;) PS Z:\&gt; $Match = $Regex.Match($text) PS Z:\&gt; $Match.Value **Release /p net** </code></pre> <p>Any help would be appreciated</p>
[ { "answer_id": 74311836, "author": "mklement0", "author_id": 45375, "author_profile": "https://Stackoverflow.com/users/45375", "pm_score": 1, "selected": false, "text": "--configuration" }, { "answer_id": 74311844, "author": "Santiago Squarzon", "author_id": 15339544, "author_profile": "https://Stackoverflow.com/users/15339544", "pm_score": 3, "selected": true, "text": "$content = Get-Content 'your_file_path' -Raw\n\n$re = [regex] '(?i)(?<=(?:--configuration|-c)\\s\")[^\"]+'\n$re.Matches($content).Value\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7835017/" ]
74,311,777
<p>C arrays allow for negative indexing, but I can't think of a use for that, seeing that you'll never have an element at a negative index.</p> <p>Sure, you can do this:</p> <pre><code>struct Foo { int arr1[3] = { 1, 2, 3 }; int arr2[3] = { 4, 5, 6 }; }; int main() { Foo foo; std::cout &lt;&lt; foo.arr2[-2] &lt;&lt; std::endl; //output is 2 } </code></pre> <p>But why would you ever want to do something like that? In any case, when is negative indexing of an array necessary, and in what domains would you be doing it in?</p>
[ { "answer_id": 74311805, "author": "Cedric Martens", "author_id": 4048657, "author_profile": "https://Stackoverflow.com/users/4048657", "pm_score": 4, "selected": true, "text": "N" }, { "answer_id": 74313621, "author": "Lundin", "author_id": 584518, "author_profile": "https://Stackoverflow.com/users/584518", "pm_score": 1, "selected": false, "text": "-" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19333949/" ]
74,311,789
<p>I'm using selenium &amp; selenium wire in my project. I'm writing flows to log in google cloud portals..</p> <p>I enter my google cloud mail then, press on continue in Google sign in and then it log in to gcp.</p> <p>I got some errors:</p> <blockquote> <p>Request has invalid authentication credentials. Expected OAuth 2 access token, login cookie or other...</p> </blockquote> <blockquote> <p>net:: ERR_PROXY_CONNECTION_FAILED</p> </blockquote> <p><a href="https://i.stack.imgur.com/GXmM4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GXmM4.jpg" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/JKLMk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JKLMk.jpg" alt="enter image description here" /></a></p> <p>when I do the same flow <strong>manually</strong> without automation, with the same credentials, it works fine and no any network error.</p> <p>my web driver</p> <pre><code>from seleniumwire import webdriver from seleniumwire.webdriver import ChromeOptions def test_gcp_flow(): options = ChromeOptions() options.add_experimental_option(&quot;detach&quot;, True) options.add_argument('--no-sandbox') options.add_argument('--single-process') options.add_argument('--disable-dev-shm-usage') options.add_argument(&quot;--start-maximized&quot;) options.add_argument('--auto-open-devtools-for-tabs') options.add_argument('--log-level=2') options.add_argument('--disable-features=IsolateOrigins,site-per-process') options.add_argument(&quot;--ignore_ssl&quot;) options.add_argument('--ignore-ssl-errors') options.add_argument('--ignore-certificate-errors') options.add_argument(&quot;--disable-extensions&quot;) options.add_argument(&quot;--disable-setuid-sandbox&quot;) options.add_argument(&quot;--dns-prefetch-disable&quot;) options.add_argument('ignore-certificate-errors') options.add_argument('disable-web-security') options.add_argument('--allow-insecure-localhost') driver = webdriver.Chrome(options=options) driver.get('....any-hidden-url') # more flow actions - then it open gcp portal </code></pre> <p>I added openssl.cnf (without this openssl, it shows me TLS ssl issue) to run it locally in my test using Pycharm:</p> <pre><code>openssl_conf = openssl_init [openssl_init] ssl_conf = ssl_sect [ssl_sect] system_default = system_default_sect [system_default_sect] Options = UnsafeLegacyRenegotiation </code></pre> <p>I tried to add some change the chrome options that added to selenium driver but nothing has changed, still same error.</p> <p><strong>I tried to use Firefox webdriver and it works good without any network issue.</strong> Maybe it's any chrome cache issue? because some days ago it worked me with chrome..</p> <p>what I'm expecting is that to sign in to gmail without network/token issues.</p>
[ { "answer_id": 74311805, "author": "Cedric Martens", "author_id": 4048657, "author_profile": "https://Stackoverflow.com/users/4048657", "pm_score": 4, "selected": true, "text": "N" }, { "answer_id": 74313621, "author": "Lundin", "author_id": 584518, "author_profile": "https://Stackoverflow.com/users/584518", "pm_score": 1, "selected": false, "text": "-" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311789", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6455516/" ]
74,311,800
<p>This is my <code>auth-depl.yaml</code> file:</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: auth-depl spec: replicas: 1 selector: matchLabels: app: auth template: metadata: labels: app: auth spec: containers: - name: auth image: tester/auth env: - name: MONGO_URI value: 'mongodb://auth-mongo-srv:27017/auth' - name: JWT_KEY valueFrom: secretKeyRef: name: jwt-secret key: JWT_KEY --- apiVersion: v1 kind: Service metadata: name: auth-srv spec: selector: app: auth ports: - name: auth protocol: TCP port: 3000 targetPort: 3000 </code></pre> <p>And the following is <code>auth-mongo-depl.yaml</code>:</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: auth-mongo-depl spec: replicas: 1 selector: matchLabels: app: auth-mongo template: metadata: labels: app: auth-mongo spec: containers: - name: auth-mongo image: mongo --- apiVersion: v1 kind: Service metadata: name: auth-mongo-srv spec: selector: app: auth-mongo ports: - name: db protocol: TCP port: 27017 targetPort: 27017 </code></pre> <p>When I run <code>skaffold dev</code> it gives me the following error:</p> <pre><code> - deployment/auth-mongo-depl: container auth-mongo is waiting to start: mongo can't be pulled - pod/auth-mongo-depl-64f5f58669-dw4hg: container auth-mongo is waiting to start: mongo can't be pulled - deployment/auth-mongo-depl failed. Error: container auth-mongo is waiting to start: mongo can't be pulled. </code></pre> <p>The <code>mongo</code> service is up and running and I can run <code>mongo</code> command on the terminal. It also starts and runs on it's default <code>mongodb://127.0.0.1:27017</code> address. I use Windows 10 and Docker-Desktop.</p> <p>Let me know if more information needs to be added.</p>
[ { "answer_id": 74311805, "author": "Cedric Martens", "author_id": 4048657, "author_profile": "https://Stackoverflow.com/users/4048657", "pm_score": 4, "selected": true, "text": "N" }, { "answer_id": 74313621, "author": "Lundin", "author_id": 584518, "author_profile": "https://Stackoverflow.com/users/584518", "pm_score": 1, "selected": false, "text": "-" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17100762/" ]
74,311,804
<p>I'm trying to program something that checks to see if two birthdays match, and counts how many birthdays have to be generated before we get a matching date. The actual date isn't important so I used the random.sample function to generate two numbers between 1 and 365. However when I try to compare these numbers in a while loop, I cannot get it to generate those numbers more than once.</p> <pre><code>import random def numberToSharedBirthday(): numberToSharedBirthday = 0 sharedBirthday = False while sharedBirthday == False: birthdays = random.sample(range(1,365), k = 2) numberToSharedBirthday +=1 #adds to the counter until the dates match if birthdays[0] == birthdays[1]: sharedBirthday = True return numberToSharedBirthday </code></pre> <p>When I run the code, the while loop doesn't end because it never satisfies the if statement. What am I doing wrong?</p>
[ { "answer_id": 74311834, "author": "Mark Tolonen", "author_id": 235698, "author_profile": "https://Stackoverflow.com/users/235698", "pm_score": 2, "selected": false, "text": "range(1,365)" }, { "answer_id": 74312063, "author": "Arifa Chan", "author_id": 19574157, "author_profile": "https://Stackoverflow.com/users/19574157", "pm_score": 0, "selected": false, "text": "from random import choices\n\ndef numberToSharedBirthday():\n numberToSharedBirthday = 0\n while birthdays := choices(range(1, 366), k=2):\n numberToSharedBirthday += 1\n if birthdays[0] == birthdays[1]:\n return numberToSharedBirthday\n" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20413486/" ]
74,311,807
<p>I have a parameter called <code>@Unit</code>.</p> <p>I also have a unit column in my table. I Have other requirements so I need to do a case statement in the where clause.</p> <pre><code>CASE WHEN @Unit &gt; 0 THEN unit = @Unit END </code></pre> <p>The statement however is not accepting my <code>=</code>. I'm getting an error on <code>=</code>.</p> <p>Any advice would be helpful.</p>
[ { "answer_id": 74311835, "author": "NorthBigFish", "author_id": 16328089, "author_profile": "https://Stackoverflow.com/users/16328089", "pm_score": 0, "selected": false, "text": "unit = case when ISNULL(@Unit,0) > 0 then @Unit else unit end \n" }, { "answer_id": 74312772, "author": "Thorsten Kettner", "author_id": 2270762, "author_profile": "https://Stackoverflow.com/users/2270762", "pm_score": 1, "selected": false, "text": "CASE" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311807", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20413511/" ]
74,311,823
<p>Why won’t this section stay contained when I change my browser screen size? I used HTML and CSS. It looks fine when I made my screen full size but then if I make my browser smaller it doesn’t show the full content. (it only shows half of the image but shows the full text) <a href="https://i.stack.imgur.com/i9qiK.jpg" rel="nofollow noreferrer">screenshot of how it looks on smaller browser</a>](<a href="https://i.stack.imgur.com/i9qiK.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/i9qiK.jpg</a>)</p> <pre><code>.whoweare{ padding:80px 0px 50px; background-color: #000000; } .whoweare .content { -webkit-display: flex; display: flex; } .whoweare .content .box{ padding:5px; flex:0 0 100%; max-width: 100%; } .whoweare .content .item-img { width: 50%; -webkit-transform: rotateY(180deg); transform: rotateY(180deg); padding: 30px; } .whoweare .content .item-text h2{ font-size: 50px; font-weight: 500; margin:20px; color: #ffffff; padding: 0px 0px 20px; } .whoweare .content .item-text p{ font-size: 20px; line-height:50px; color:#ffffff; margin:20px; padding:0px 0px 20px; font-family: 'Open Sans', sans-serif; } .whoweare .content .class-items .item{ margin-bottom: 30px; display: flex; } .whoweare .content .class-items .item .item-text{ padding: 15px; display: flex; flex-direction: column; justify-content: center; } ` &lt;section class=&quot;whoweare&quot; id=&quot;whoweare&quot;&gt; &lt;dic class=&quot;container&quot;&gt; &lt;div class=&quot;content&quot;&gt; &lt;div class=&quot;box text wow slideInRight&quot;&gt; &lt;div class=&quot;class-items&quot;&gt; &lt;div class=&quot;item wow bounceInUp&quot;&gt; &lt;div class=&quot;item-img&quot;&gt; &lt;img src=&quot;images/ACD68359-D3EB-4302-99C0-E59A663380AB.jpeg&quot; alt=&quot;classes&quot; width=&quot;601&quot; height=&quot;751&quot; /&gt; &lt;/div&gt; &lt;div class=&quot;item-text&quot;&gt; &lt;h2&gt;Who we are&lt;/h2&gt; &lt;p&gt;Our gym provides a unique experience &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/section&gt;```` </code></pre>
[ { "answer_id": 74311916, "author": "Yes_ _Br0", "author_id": 17467664, "author_profile": "https://Stackoverflow.com/users/17467664", "pm_score": 0, "selected": false, "text": " .container\n {\n width:100%:\n height: auto;\n margin: auto;\n }\n//Also can try\n.container\n{\nwidth: auto;\npadding: 0;\n\n}\n" }, { "answer_id": 74311972, "author": "K JOHN", "author_id": 10031834, "author_profile": "https://Stackoverflow.com/users/10031834", "pm_score": 0, "selected": false, "text": "img" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20413531/" ]
74,311,829
<p>I have two sparse matrice where the first has the property of</p> <pre><code>&lt;1x40 sparse matrix of type '&lt;class 'numpy.intc'&gt;' with 10 stored elements in Compressed Sparse Row format&gt; </code></pre> <p>And the second one:</p> <pre><code>&lt;9x15426 sparse matrix of type '&lt;class 'numpy.int64'&gt;' with 25 stored elements in Compressed Sparse Row format&gt; </code></pre> <p>I want to append the 40 dimensions of the first matrix to each of the 9 &lt;1x15426&gt; dimensions of the second matrix so the resulting matrix will have</p> <pre><code>&lt;9x15466 sparse matrix of type '&lt;class 'numpy.int64'&gt;' with 25 stored elements in Compressed Sparse Row format&gt; </code></pre> <p>Is this possible without converting to dense arrays? Thanks!</p>
[ { "answer_id": 74311916, "author": "Yes_ _Br0", "author_id": 17467664, "author_profile": "https://Stackoverflow.com/users/17467664", "pm_score": 0, "selected": false, "text": " .container\n {\n width:100%:\n height: auto;\n margin: auto;\n }\n//Also can try\n.container\n{\nwidth: auto;\npadding: 0;\n\n}\n" }, { "answer_id": 74311972, "author": "K JOHN", "author_id": 10031834, "author_profile": "https://Stackoverflow.com/users/10031834", "pm_score": 0, "selected": false, "text": "img" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3319713/" ]
74,311,843
<p>Please let me know how to get this output, I have searched a lot but all of the queries shows two separate tables one for employees and another department. Here I do not have it so I tried this:</p> <pre><code>SELECT e.department_id, e.Salary FROM Employees1 e INNER JOIN employees1 s ON e.Department_Id = s.Department_Id WHERE (SELECT COUNT(DISTINCT(Salary)) FROM Employees1 WHERE e.Department_Id = s.Department_Id AND s.Salary &gt; E.Salary) &lt; 3 ORDER by E.Department_Id, E.Salary ; </code></pre> <p>But the output is not right.</p>
[ { "answer_id": 74311916, "author": "Yes_ _Br0", "author_id": 17467664, "author_profile": "https://Stackoverflow.com/users/17467664", "pm_score": 0, "selected": false, "text": " .container\n {\n width:100%:\n height: auto;\n margin: auto;\n }\n//Also can try\n.container\n{\nwidth: auto;\npadding: 0;\n\n}\n" }, { "answer_id": 74311972, "author": "K JOHN", "author_id": 10031834, "author_profile": "https://Stackoverflow.com/users/10031834", "pm_score": 0, "selected": false, "text": "img" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14948137/" ]
74,311,860
<p>To double-check, I try a console log both inside and outside the function.</p> <p>The one inside the function is fine, but the one outside the function displays &quot;undefined.&quot;</p> <p>I need to get the value of startDate and use it outside the function.</p> <p>I tried every suggestion here, but none of them worked. <a href="https://bobbyhadz.com/blog/javascript-select-onchange-get-value" rel="nofollow noreferrer">https://bobbyhadz.com/blog/javascript-select-onchange-get-value</a></p> <p>here is the code:</p> <pre><code>var startDate; $('#dayFrom, #timeFrom').change(function() { startDate = $('#dayFrom').val() + ' ' + $('#timeFrom').val(); console.log(&quot;inside start date: &quot; + startDate); }); console.log(&quot;outside start date: &quot; + startDate); </code></pre>
[ { "answer_id": 74311916, "author": "Yes_ _Br0", "author_id": 17467664, "author_profile": "https://Stackoverflow.com/users/17467664", "pm_score": 0, "selected": false, "text": " .container\n {\n width:100%:\n height: auto;\n margin: auto;\n }\n//Also can try\n.container\n{\nwidth: auto;\npadding: 0;\n\n}\n" }, { "answer_id": 74311972, "author": "K JOHN", "author_id": 10031834, "author_profile": "https://Stackoverflow.com/users/10031834", "pm_score": 0, "selected": false, "text": "img" } ]
2022/11/04
[ "https://Stackoverflow.com/questions/74311860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14922985/" ]