qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,219,031
<p>I built this SQL:</p> <pre><code>SELECT indexname FROM pg_indexes WHERE schemaname = 'foo' AND tablename = 'foo' </code></pre> <p>It returns me all indexes of a table. However, I would like the index names and the type of the indexes to be displayed, e.g. UNIQUE or PRIMARY.</p>
[ { "answer_id": 74219394, "author": "YJR", "author_id": 19966820, "author_profile": "https://Stackoverflow.com/users/19966820", "pm_score": 0, "selected": false, "text": "indexdef" }, { "answer_id": 74219457, "author": "Jonathan Willcock", "author_id": 7990032, "author...
2022/10/27
[ "https://Stackoverflow.com/questions/74219031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19930015/" ]
74,219,047
<p>Below is the nested list that is framed manually. Similar to this, can we make a nested list for dataframe columns like shown below</p> <pre><code>nested_list = list(`East Coast` = list(&quot;NY&quot;, &quot;NJ&quot;, &quot;CT&quot;), `West Coast` = list(&quot;WA&quot;, &quot;OR&quot;, &quot;CA&quot;), `Midwest` = list(&quot;MN&quot;, &quot;WI&quot;, &quot;IA&quot;)) </code></pre> <p>Example</p> <pre><code>asd &lt;- data.frame(Cat1 = c(&quot;A&quot;, &quot;A&quot;, &quot;B&quot;, &quot;B&quot;), Cat2 = c(&quot;x&quot;,&quot;y&quot;, &quot;x1&quot;, &quot;y1&quot;)) </code></pre> <p>Expected output</p> <pre><code>$`A` $`A`[[1]] [1] &quot;x&quot; $`A`[[2]] [1] &quot;y&quot; $`B` $`B`[[1]] [1] &quot;x1&quot; $`B`[[2]] [1] &quot;y1&quot; </code></pre>
[ { "answer_id": 74219096, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 2, "selected": false, "text": "lapply(split(asd[, -1], asd$Cat1), as.list)\n" }, { "answer_id": 74225617, "author": "akrun", "author...
2022/10/27
[ "https://Stackoverflow.com/questions/74219047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16176890/" ]
74,219,064
<p>I use the code down below to start an application and move it into a Panel on my Form. In this example I use Notepad, only as an example. Later I will use a different application.</p> <p>When another application is moved in front of my Form, I can only move my Form to the foreground by clicking the title bar. If I click on the MDI child area (so the Panel where Notepad is moved into), nothing happens.<br /> Is there a way to enable that?</p> <pre><code>Imports System.Runtime.InteropServices Public Class Form1 Declare Auto Function SetParent Lib &quot;user32.dll&quot; (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer Declare Auto Function SendMessage Lib &quot;user32.dll&quot; (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim proc As Process proc = Process.Start(&quot;notepad.exe&quot;) proc.WaitForInputIdle() SetParent(proc.MainWindowHandle, Me.Panel1.Handle) SendMessage(proc.MainWindowHandle, 274, 61488, 0) End Sub End Class </code></pre>
[ { "answer_id": 74242485, "author": "Jimi", "author_id": 7444103, "author_profile": "https://Stackoverflow.com/users/7444103", "pm_score": 3, "selected": true, "text": "EVENT_SYSTEM_FOREGROUND" }, { "answer_id": 74264774, "author": "Eric van Loon", "author_id": 18608429, ...
2022/10/27
[ "https://Stackoverflow.com/questions/74219064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18608429/" ]
74,219,067
<p><a href="https://i.stack.imgur.com/r6bwY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r6bwY.png" alt="reference image" /></a></p> <p>I am using azure sql as source dataset and delimited file as sink dataset in the copy activity.</p> <p>I tried copy activity but First row as header gives comma separated headers.</p> <p>Is there way to change the header output style ? Please note spacing is unequal (h3...h4)</p>
[ { "answer_id": 74223422, "author": "Aswin", "author_id": 19986107, "author_profile": "https://Stackoverflow.com/users/19986107", "pm_score": 1, "selected": false, "text": "iif(Column_1=='date_col','ECIX',Column_2)" }, { "answer_id": 74231310, "author": "Ashwin Mohan", "au...
2022/10/27
[ "https://Stackoverflow.com/questions/74219067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8910532/" ]
74,219,080
<p>Here is some meta-code:</p> <pre><code>procedure Processing1; begin // Here we do single operations like single INSERT end; procedure Processing2; begin // Here we do single operations like single SELECT end; procedure Processing3; begin // Here we do multiple DB operations end; procedure Processing4; begin // Here we do not touch the database at all end; procedure EntryPoint(ProcessingType: Integer); begin // It could be even a loop StartTransaction; try case ProcessingType of 1: Processing1; 2: Processing2; 3: Processing3; 4: Processing4; end; CommitTransaction; except RollbackTransaction; end; end; </code></pre> <p>Could I wrap every method call in a transaction or should I use a transaction only when needed? What is the overhead of an universal approach?</p>
[ { "answer_id": 74219596, "author": "Ivan Yuzafatau", "author_id": 1889110, "author_profile": "https://Stackoverflow.com/users/1889110", "pm_score": 2, "selected": false, "text": "try-catch" }, { "answer_id": 74219631, "author": "MT0", "author_id": 1509264, "author_pro...
2022/10/27
[ "https://Stackoverflow.com/questions/74219080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/999355/" ]
74,219,103
<p>I have a List which contains some User-Objects. For example:</p> <pre><code>public List&lt;User&gt; Users { get; } = new List&lt;User&gt; ( new User { Username = &quot;Marvin&quot;, IsAdmin = true }, new User { Username = &quot;John&quot;, IsAdmin = false } ); </code></pre> <p>Now lets say I want to edit the user John and I want him to be an admin as well.</p> <pre><code>User john = Users.First(x =&gt; x.Username == &quot;John&quot;); </code></pre> <p>Because I only want the changes to be applied when I hit save, I won't edit the actual object itself. Instead I create a clone one to work with the object until it has been saved by the user.</p> <pre><code>User johnClone = (User)john.Clone(); </code></pre> <p>When I hit save, all changes from the clone object should be applied to the main object. But I do not want to do it for every property by myself. For example:</p> <pre><code>john.IsAdmin = johnClone.IsAdmin; </code></pre> <p>Instead I want to update the entire reference of the object to the new one. So I won't need to update the properties by hand and within every other class which has john assigned to will be updated automatically.</p> <p>I think this needs to be achived with pointers. But does anyone of you know how to do this?</p> <p>I allready tried to update the item within the List itself like this:</p> <pre><code>int index = Users.IndexOf(john); Users[index] = johnClone; </code></pre> <p>But this doesn't update the instances which asked for the user John before it was updated.</p>
[ { "answer_id": 74219596, "author": "Ivan Yuzafatau", "author_id": 1889110, "author_profile": "https://Stackoverflow.com/users/1889110", "pm_score": 2, "selected": false, "text": "try-catch" }, { "answer_id": 74219631, "author": "MT0", "author_id": 1509264, "author_pro...
2022/10/27
[ "https://Stackoverflow.com/questions/74219103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13440841/" ]
74,219,118
<p>It's my first time using typescript and I'm getting a problem with the variable called &quot;state&quot; as it's use to get my list of users form the api but I get this error &quot;'state' is of type 'unknown'&quot; even though it actually works. As I said it's my first time with typescript and I dontu fully understand why it works if it has an error.</p> <pre><code>//React Imports import React, { useEffect } from &quot;react&quot;; //MUI Imports import Navbar from &quot;../../Components/Navbar&quot;; import Grid from &quot;@mui/material/Grid&quot;; import Box from &quot;@mui/material/Box&quot;; import Card from &quot;@mui/material/Card&quot;; import CardContent from &quot;@mui/material/CardContent&quot;; import { CardMedia } from &quot;@mui/material&quot;; import Typography from &quot;@mui/material/Typography&quot;; //Redux Imports import { fetchAllUsers } from &quot;../../redux/slices/users&quot;; import { useDispatch, useSelector } from &quot;react-redux&quot;; function Users() { const { list: users } = useSelector((state) =&gt; state.users);//Error in state.users const dispatch = useDispatch(); useEffect(() =&gt; { dispatch(fetchAllUsers() as any); }, [dispatch]); return ( &lt;div className=&quot;Users&quot;&gt; &lt;Navbar&gt;&lt;/Navbar&gt; &lt;br&gt;&lt;/br&gt; &lt;Box sx={{ flexGrow: 1 }}&gt; &lt;Grid container spacing={2} alignItems=&quot;center&quot; justifyContent=&quot;center&quot;&gt; {users.map((user, index) =&gt; ( &lt;Grid item xs={3.1}&gt; &lt;Card&gt; &lt;CardMedia component=&quot;img&quot; image={user.avatar} alt=&quot;avatar image&quot; &gt;&lt;/CardMedia&gt; &lt;CardContent&gt; &lt;Typography gutterBottom variant=&quot;h5&quot;&gt; {user.first_name} {user.last_name} &lt;/Typography&gt; &lt;Typography gutterBottom variant=&quot;h6&quot;&gt; {user.email} &lt;/Typography&gt; &lt;/CardContent&gt; &lt;/Card&gt; &lt;/Grid&gt; ))} &lt;/Grid&gt; &lt;/Box&gt; &lt;/div&gt; ); } export default Users; </code></pre>
[ { "answer_id": 74219596, "author": "Ivan Yuzafatau", "author_id": 1889110, "author_profile": "https://Stackoverflow.com/users/1889110", "pm_score": 2, "selected": false, "text": "try-catch" }, { "answer_id": 74219631, "author": "MT0", "author_id": 1509264, "author_pro...
2022/10/27
[ "https://Stackoverflow.com/questions/74219118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20346978/" ]
74,219,146
<p>For some technical and organizational reasons, I cannot use our Artifactory as Registry by using <code>docker push</code> or CI/CD pushes.</p> <p>As it seems, JFrog's Artifactory provides a feature to manually deploy artifacts, by directly uploading files. Now, how do I do that with a Docker image I built locally on a machine? I only found explanations about JAR Files.</p>
[ { "answer_id": 74219596, "author": "Ivan Yuzafatau", "author_id": 1889110, "author_profile": "https://Stackoverflow.com/users/1889110", "pm_score": 2, "selected": false, "text": "try-catch" }, { "answer_id": 74219631, "author": "MT0", "author_id": 1509264, "author_pro...
2022/10/27
[ "https://Stackoverflow.com/questions/74219146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1966710/" ]
74,219,161
<p>I have a Pandas pivot table; The goal is to pass this to a Django rest framework in the form of multiple arrays which I can easily filter in React JavaScript.</p> <pre><code>pivot: x y z Magazine date M1 2018-01 173 68 10 2018-02 184 55 11 M2 2018-01 175 68 10 2018-02 189 52 9 </code></pre> <p>I need the output to be:</p> <pre><code>{ &quot;M1&quot;: [ { &quot;date&quot;: &quot;2018-01&quot;, &quot;x&quot;: 173, &quot;y&quot;: 68, &quot;z&quot;: 10}, { &quot;date&quot;: &quot;2018-02&quot;, &quot;x&quot;: 184, &quot;y&quot;: 55, &quot;z&quot;: 11} ], &quot;M2&quot;: [ { &quot;date&quot;: &quot;2018-01&quot;, &quot;x&quot;: 175, &quot;y&quot;: 68, &quot;z&quot;: 10}, { &quot;date&quot;: &quot;2018-02&quot;, &quot;x&quot;: 189, &quot;y&quot;: 52, &quot;z&quot;: 9} ] } </code></pre>
[ { "answer_id": 74219415, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 2, "selected": true, "text": "out = {}\nfor (m, d), row in df.iterrows():\n out.setdefault(m, {}).setdefault(d, {})\n out[m][d] = dic...
2022/10/27
[ "https://Stackoverflow.com/questions/74219161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16910664/" ]
74,219,162
<p>I need to get two different sets of data from the same collection and if any data in any set has convergence with another data in other set combine them into one and if not convert them to a desired format, to make it more clear think there is a collection named <code>collection1</code> and I need to get started tasks with specific condition and completed tasks with specific condition from this collection and I managed to do it like this:</p> <pre><code>db.collection1.aggregate([{ $facet: { &quot;started&quot;:[...], &quot;completed&quot;:[...] } }, ]).toArray() </code></pre> <p>and assume that started is an array of this :</p> <pre><code>interface Starts{ supplier: string; publisher: string; partner: string; buyer: string; started_at: string; starts: number; } </code></pre> <p>And completed is an array of this:</p> <pre><code>interface Completes{ supplier: string; publisher: string; partner: string; buyer: string; finished_at: string; completes: number; revenue: number; } </code></pre> <p>you see some started tasks with certain <code>supplier</code>,<code>partner</code>,<code>buyer</code>,<code>publisher</code> might be actually completed and their completion info exist in completed array so the two need to merge and some might not( and I will not have finished_at,completes,revenue info for them and I would put null for these values) and also some <code>completed tasks</code> might not be related to any <code>started tasks</code>( and I will not have starts,started_at info for them and I would put null for these values)ergo the final result will look like an array of this:</p> <pre><code>interface StartsCompletes{ supplier: string; publisher: string; partner: string; buyer: string; started_at: string; finished_at: string; starts: number; completes: number; revenue: number; } </code></pre> <p>well I can loop through the output of <code>facet</code> with JavaScript for-loops and make it happen but can I some how add another stage to my <code>aggregate</code> pipeline and do it with MongoDB?</p>
[ { "answer_id": 74219415, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 2, "selected": true, "text": "out = {}\nfor (m, d), row in df.iterrows():\n out.setdefault(m, {}).setdefault(d, {})\n out[m][d] = dic...
2022/10/27
[ "https://Stackoverflow.com/questions/74219162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1932617/" ]
74,219,172
<p>this is the second time asking a similar question because i have not found the result i am looking for: I have the following dataframe:</p> <pre><code>gene = c(&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;,&quot;f&quot;,&quot;g&quot;,&quot;h&quot;,&quot;i&quot;,&quot;j&quot;,&quot;k&quot;, &quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;,&quot;f&quot;,&quot;g&quot;,&quot;h&quot;,&quot;i&quot;,&quot;j&quot;,&quot;k&quot;, &quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;,&quot;f&quot;,&quot;g&quot;,&quot;h&quot;,&quot;i&quot;,&quot;j&quot;,&quot;k&quot;) sample1 = c(&quot;a&quot;,&quot;a&quot;,&quot;a&quot;,&quot;a&quot;,&quot;a&quot;,&quot;a&quot;,&quot;a&quot;,&quot;a&quot;,&quot;a&quot;,&quot;a&quot;, &quot;a&quot;,&quot;b&quot;,&quot;b&quot;,&quot;b&quot;,&quot;b&quot;,&quot;b&quot;,&quot;b&quot;,&quot;b&quot;,&quot;b&quot;,&quot;b&quot;,&quot;b&quot;,&quot;b&quot;,&quot;c&quot;,&quot;c&quot;,&quot;c&quot;,&quot;c&quot;,&quot;c&quot;,&quot;c&quot;,&quot;c&quot;,&quot;c&quot;,&quot;c&quot;,&quot;c&quot;,&quot;c&quot;) expression1 = c(&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;, &quot;5&quot;, &quot;6&quot;, &quot;7&quot;, &quot;8&quot;, &quot;9&quot;, &quot;10&quot;, &quot;11&quot;, &quot;14&quot;, &quot;15&quot;, &quot;16&quot;, &quot;17&quot;, &quot;18&quot;, &quot;19&quot;, &quot;20&quot;, &quot;21&quot;, &quot;22&quot;, &quot;23&quot;, &quot;24&quot;,&quot;25&quot;, &quot;26&quot;, &quot;27&quot;, &quot;28&quot;, &quot;29&quot;, &quot;30&quot;, &quot;31&quot;, &quot;32&quot;, &quot;33&quot;, &quot;34&quot;, &quot;36&quot;) data_frame(gene, sample1, expression1) </code></pre> <p>and I have a following dataframe</p> <pre><code>gene = c(&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;,&quot;f&quot;,&quot;g&quot;,&quot;h&quot;,&quot;i&quot;,&quot;j&quot;,&quot;k&quot;) sample2 = c(&quot;g&quot;,&quot;g&quot;,&quot;g&quot;,&quot;g&quot;,&quot;g&quot;,&quot;g&quot;,&quot;g&quot;,&quot;g&quot;,&quot;g&quot;,&quot;g&quot;,&quot;g&quot;) expression2 = c(&quot;14.7&quot;, &quot;15&quot;, &quot;17&quot;, &quot;16&quot;, &quot;18&quot;, &quot;20&quot;, &quot;21&quot;, &quot;22&quot;, &quot;23&quot;, &quot;24&quot;, &quot;25&quot;) gene sample2 expression2 &lt;chr&gt; &lt;chr&gt; &lt;chr&gt; 1 a g 14.7 2 b g 15 3 c g 17 4 d g 16 5 e g 18 6 f g 20 7 g g 21 8 h g 22 9 i g 23 10 j g 24 11 k g 25 </code></pre> <p>and the result i am looking for is that I get a match between sample2 = g &amp;&amp; sample1 = b, because they are most similar in gene expression. how Should I approach this.</p> <p>it will look something like this:</p> <pre><code> gene sample2 expression2 sample1 expression1 &lt;chr&gt; &lt;chr&gt; &lt;chr&gt; &lt;chr&gt; &lt;chr&gt; 1 a g 14.7 b 14 2 b g 15 b 15 3 c g 17 b 16 4 d g 16 b 17 5 e g 18 b 18 6 f g 20 b 19 7 g g 21 b 20 8 h g 22 b 21 9 i g 23 b 22 10 j g 24 b 23 11 k g 25 b 24 </code></pre>
[ { "answer_id": 74219277, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 1, "selected": false, "text": "library(data.table)\nsetDT(df1)[, expression := as.numeric(expression1)]\nsetDT(df2)[, expression := as.numeric(expre...
2022/10/27
[ "https://Stackoverflow.com/questions/74219172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19254600/" ]
74,219,184
<p>I am a bit confused about something. I know that Typescript is a superset of JavaScript since you can put JavaScript into Typescript but not the other way around. Someone told me that there is a similar relation between HTML and XML. I can however not find anything concrete about this on the web. Is this true? And if so, what is the superset?</p>
[ { "answer_id": 74219364, "author": "compuGreen", "author_id": 20291198, "author_profile": "https://Stackoverflow.com/users/20291198", "pm_score": 0, "selected": false, "text": "<parent>\n <child>\n </child>\n</parent>\n" }, { "answer_id": 74219894, "author": "imhotap", "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74219184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19843696/" ]
74,219,211
<p>today i'm tryng to stylize my list of audiobooks but for doing so i have to make every object with an aspectRatio (key= value) in my json file but it gives me an error . <a href="https://i.stack.imgur.com/Qb3TX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qb3TX.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/qTkmx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qTkmx.png" alt="enter image description here" /></a></p> <p>if i can't write like this in my json file how can i do it ? thank you in avance</p>
[ { "answer_id": 74219347, "author": "gnasher729", "author_id": 3255455, "author_profile": "https://Stackoverflow.com/users/3255455", "pm_score": 3, "selected": true, "text": "...\n\"aspectRatio\": { \"width\": 150, \"height\": 200 },\n...\n" }, { "answer_id": 74219350, "author...
2022/10/27
[ "https://Stackoverflow.com/questions/74219211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18713610/" ]
74,219,218
<p>My in-file looks like that.</p> <pre><code>3 5 7 9 2 4 6 5 </code></pre> <p>I want the values from the first line, put into <strong>arrayA</strong>, and values from the second line into <strong>arrayB</strong>. That's what I have for now.</p> <pre><code> while(sc.hasNextLine()) { while (sc.hasNextInt()) { arrA[i] = sc.nextInt(); arrB[i] = Integer.parseInt(sc.nextLine()); i++; } } </code></pre>
[ { "answer_id": 74219399, "author": "刷题养家", "author_id": 17953108, "author_profile": "https://Stackoverflow.com/users/17953108", "pm_score": 1, "selected": false, "text": "String s = sc.readLine();\nInteger[] arrA = Arrays.stream(s.split(\" \")).map(Integer::parseInt).collect(Collectors.t...
2022/10/27
[ "https://Stackoverflow.com/questions/74219218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17701500/" ]
74,219,244
<p>I've written a small playbook to run the <code>sudo /usr/sbin/dmidecode -t1 | grep -i vmware | grep -i product</code> command and write the output in a result file by usign the following code as a .yml:</p> <pre class="lang-yaml prettyprint-override"><code># Check if server is vmware --- - name: Check if server is vmware hosts: all become: yes #ignore_errors: yes gather_facts: False serial: 50 #become_flags: -i tasks: - name: Run uptime command #become: yes shell: &quot;sudo /usr/sbin/dmidecode -t1 | grep -i vmware | grep -i product&quot; register: upcmd - debug: msg: &quot;{{ upcmd.stdout }}&quot; - name: write to file lineinfile: path: /home/myuser/ansible/mine/vmware.out create: yes line: &quot;{{ inventory_hostname }};{{ upcmd.stdout }}&quot; delegate_to: localhost #when: upcmd.stdout != &quot;&quot; </code></pre> <p>When running the playbook against a list of hosts I get different <em>weird</em> results so even if the debug shows the correct output, when I check the <code>/home/myuser/ansible/mine/vmware.out</code> file I see only part of them being present. Even weirder is that if I run the playbook again, I will correctly populate the whole list but only if I run this twice. I have repeated this several times with some minor tweaks but not getting the expected result. Doing -v or -vv shows nothing unusual.</p>
[ { "answer_id": 74219399, "author": "刷题养家", "author_id": 17953108, "author_profile": "https://Stackoverflow.com/users/17953108", "pm_score": 1, "selected": false, "text": "String s = sc.readLine();\nInteger[] arrA = Arrays.stream(s.split(\" \")).map(Integer::parseInt).collect(Collectors.t...
2022/10/27
[ "https://Stackoverflow.com/questions/74219244", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8966945/" ]
74,219,267
<p>I need to create a file that has a list of files(files already exist with data) using a unix command. Basically move the existing files into a newly created text or csv file.</p> <p>Syntax: <code>/$dir/$file_name.csv</code><br /> Ex: <code>/var/data/inbound_data/fusion_po_attachments.txt</code> (or <code>fusion_po_attachments.csv</code>) This path would have n number of files with the same syntax.</p> <p><code>/var/data/inbound_data/fusion_po_attachments.txt</code> --main file &amp; this would have below content</p> <pre><code>/var/data/inbound_data/attachment1.csv . . . /var/data/inbound_data/attachment50.csv </code></pre> <p>how can we achieve this? Please point out if any question like this exist. Thanks.</p>
[ { "answer_id": 74219399, "author": "刷题养家", "author_id": 17953108, "author_profile": "https://Stackoverflow.com/users/17953108", "pm_score": 1, "selected": false, "text": "String s = sc.readLine();\nInteger[] arrA = Arrays.stream(s.split(\" \")).map(Integer::parseInt).collect(Collectors.t...
2022/10/27
[ "https://Stackoverflow.com/questions/74219267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12147618/" ]
74,219,295
<p>I am trying to ask Ansible to check if a server is passive or active based on the value of a specific file in each server, then Ansible will decide which server it runs the next script on.</p> <p>For example with 2 servers:</p> <p><strong>Server1</strong></p> <pre><code>cat /tmp/currentstate PASSIVE </code></pre> <p><strong>Server2</strong></p> <pre><code>cat /tmp/currentstate ACTIVE </code></pre> <p><strong>In Ansible</strong></p> <p>Trigger next set of jobs on server where the output was <code>ACTIVE</code>.</p> <p>Once the jobs complete, trigger next set of jobs on server where output was <code>PASSIVE</code></p> <p>What I have done so far to grab the state, and output the value to Ansible is</p> <pre class="lang-yaml prettyprint-override"><code>- hosts: &quot;{{ hostname1 | mandatory }}&quot; gather_facts: no tasks: - name: Grab state of first server shell: | cat {{ ans_script_path }}currentstate.log register: state_server1 - debug: msg: &quot;{{ state_server1.stdout }}&quot; - hosts: &quot;{{ hostname2 | mandatory }}&quot; gather_facts: no tasks: - name: Grab state of second server shell: | cat {{ ans_script_path }}currentstate.log register: state_server2 - debug: msg: &quot;{{ state_server2.stdout }}&quot; </code></pre> <p>What I have done so far to trigger the script</p> <pre class="lang-yaml prettyprint-override"><code>- hosts: &quot;{{ active_hostname | mandatory }}&quot; tasks: - name: Run the shutdown on active server first shell: sh {{ ans_script_path }}stopstart_terracotta_main.sh shutdown register: run_result - debug: msg: &quot;{{ run_result.stdout }}&quot; - hosts: &quot;{{ passive_hostname | mandatory }}&quot; tasks: - name: Run the shutdown on passive server first shell: sh {{ ans_script_path }}stopstart_terracotta_main.sh shutdown register: run_result - debug: msg: &quot;{{ run_result.stdout }}&quot; </code></pre> <p>but I don't know how to set the value of <code>active_hostname</code> &amp; <code>passive_hostname</code> based on the value from the script above.</p> <p>How can I set the Ansible variable of <code>active_hostname</code> &amp; <code>passive_hostname</code> based on the output of the first section?</p>
[ { "answer_id": 74219399, "author": "刷题养家", "author_id": 17953108, "author_profile": "https://Stackoverflow.com/users/17953108", "pm_score": 1, "selected": false, "text": "String s = sc.readLine();\nInteger[] arrA = Arrays.stream(s.split(\" \")).map(Integer::parseInt).collect(Collectors.t...
2022/10/27
[ "https://Stackoverflow.com/questions/74219295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11588956/" ]
74,219,299
<p>I dont even know how to phrase what I am trying to do so I'm going straight to a simple example. I have a blocked array that looks something like this:</p> <pre><code>a = np.array([ [1,2,0,0], [3,4,0,0], [9,9,0,0], [0,0,5,6], [0,0,7,8], [0,0,8,8] ]) </code></pre> <p>and I want as an output:</p> <pre><code>np.array([ [1/9,2/9,0,0], [3/9,4/9,0,0], [9/9,9/9,0,0], [0,0,5/8,6/8], [0,0,7/8,8/8], [0,0,8/8,8/8] ]) </code></pre> <p>Lets view this as two blocks</p> <p>Block 1</p> <pre><code>np.array([ [1,2,0,0], [3,4,0,0], [9,9,0,0], ]) </code></pre> <p>Block 2</p> <pre><code>np.array([ [0,0,5,6], [0,0,7,8], [0,0,8,8] ]) </code></pre> <p>I want to normalize by the last row of each block. I.e I want to divide each block by the last row (plus epsilon for stability so the zeros are 0/(0+eps) = 0). I need an efficient way to do this.</p> <p>My current inefficient solution is to create a new array of the same shape as <code>a</code> where block one in the new array is the last row of the corresponding block in <code>a</code> and the divide. As follows:</p> <pre><code>norming_indices = np.array([2,2,2,5,5,5]) divisors = a[norming_indices, :] b = a / (divisors + 1e-9) </code></pre> <p>In this example:</p> <pre><code>divisors = np.array([ [9,9,0,0], [9,9,0,0], [9,9,0,0], [0,0,8,8], [0,0,8,8], [0,0,8,8] ]) </code></pre> <p>This like a very inefficient way to do this, does anyone have a better approach?</p>
[ { "answer_id": 74219399, "author": "刷题养家", "author_id": 17953108, "author_profile": "https://Stackoverflow.com/users/17953108", "pm_score": 1, "selected": false, "text": "String s = sc.readLine();\nInteger[] arrA = Arrays.stream(s.split(\" \")).map(Integer::parseInt).collect(Collectors.t...
2022/10/27
[ "https://Stackoverflow.com/questions/74219299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7046421/" ]
74,219,306
<p>I am trying to group column 1 by their values, and remove duplicate values of column 2 within the group.</p> <p>For example,</p> <p>Input</p> <p><a href="https://i.stack.imgur.com/Fuj5o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Fuj5o.png" alt="enter image description here" /></a></p> <p>Output</p> <p><a href="https://i.stack.imgur.com/r1mef.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r1mef.png" alt="enter image description here" /></a></p> <p>I assume I need to use the function <em>group by</em> column 1 and use <em>distinct</em> to column 2, but I am not sure how to implement it.</p>
[ { "answer_id": 74219340, "author": "Sergey", "author_id": 14535517, "author_profile": "https://Stackoverflow.com/users/14535517", "pm_score": 2, "selected": true, "text": "SELECT DISTINCT Column_1,Column_2\nfrom your_table\n" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74219306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10892778/" ]
74,219,324
<p>I would like to compute the element-wise means across multiple blocks of the same dataframe. My <code>input</code> table looks like this, and it consists of 3 (3x3) blocks, with each block having a diagonal of ones:</p> <pre><code>input = data.frame( var1 = c(1,7,4,1,2,9,1,8,3), var2 = c(3,1,9,4,1,8,3,1,8), var3 = c(3,9,1,6,8,1,3,5,1) ) </code></pre> <p>The <code>output</code> table should be a 3x3 including the means of the elements which are located on similar positions in their blocks. E.g. the first row of the <code>output</code> table should be <code>c(1, 3.3, 4)</code>. Any idea how to smartly code this? Thank you.</p>
[ { "answer_id": 74219417, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 2, "selected": true, "text": "do.call(rbind, lapply(split(input, 1:3), colMeans))\n\n var1 var2 var3\n1 1.000000 3.333333 4.000000\n2 5...
2022/10/27
[ "https://Stackoverflow.com/questions/74219324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4035257/" ]
74,219,348
<p>I am trying to webscrape with Python &quot;https://www.futbol24.com/&quot; and I am recognised as bot. I tried everything, including the removal of signatures in the javascript of chromedriver.exe, or changing user-agent and proxy, or playing with the several chrome_options.</p> <p>However, I do reach the website if I simply use Chrome while it always fail whenever I use chromedriver instead. I think there may be something in the headers suggesting to the website when I try to access it by script or not. However, it seems it is impossible (or quite diffucult) to change the headers.</p> <p>I am not expert about networking, so there may be some solution I could not find yet. Can somebody help me with that?</p>
[ { "answer_id": 74219417, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 2, "selected": true, "text": "do.call(rbind, lapply(split(input, 1:3), colMeans))\n\n var1 var2 var3\n1 1.000000 3.333333 4.000000\n2 5...
2022/10/27
[ "https://Stackoverflow.com/questions/74219348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8948867/" ]
74,219,365
<p>How to simplify conditional expression in v-bind?</p> <pre class="lang-html prettyprint-override"><code>:href=&quot;type === 'exampleType'?`${link}/${id}?exampleGetParam=true`:`${link}/${id}`&quot; </code></pre> <p>not to repeat it <code>${link}/${id}</code></p>
[ { "answer_id": 74219400, "author": "Jaromanda X", "author_id": 5053002, "author_profile": "https://Stackoverflow.com/users/5053002", "pm_score": 1, "selected": false, "text": "${}" }, { "answer_id": 74219403, "author": "Boussadjra Brahim", "author_id": 8172857, "autho...
2022/10/27
[ "https://Stackoverflow.com/questions/74219365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19949489/" ]
74,219,370
<p>I have a multipart payload that I want to pass to a flow (an HTTP Listener):</p> <pre><code>--------=_Part_1_5138113571742769845 Content-Type: text/xml Content-ID: &lt;mm7-submit&gt; &lt;soap:Envelope xmlns:soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns=&quot;http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2&quot;&gt; ... &lt;/soap:Envelope&gt; --------=_Part_1_5138113571742769845 Content-Type: multipart/mixed; boundary=&quot;------=_Part_2_3815517668157287202&quot; Content-ID: &lt;attachment&gt; --------=_Part_2_3815517668157287202 Content-Type: text/plain; name=text1.txt Content-ID: &lt;text1.txt&gt; Content-Location: bundled/text1.txt This is the text part I want to access --------=_Part_2_3815517668157287202 Content-Type: image/png Content-Transfer-Encoding: base64 Content-ID: &lt;image.png&gt; Content-Location: bundled/image.jpg aGk= --------=_Part_2_3815517668157287202-- --------=_Part_1_5138113571742769845-- </code></pre> <p>When I send this payload using SoapUI, I can access the text part as <code>payload.parts.part1.content.parts.part0.content</code>.</p> <p>How can I accomplish this with MuleSoft's tools (e.g. DataWeave expressions)? I want to be able to pass this payload from MUnit Set Event, which accepts DataWeave expressions and other formats.</p> <p>I found the <a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-multipart" rel="nofollow noreferrer">multipart page</a> in DataWeave's documentation, but it shows how to convert other formats to multipart, whereas I have the multipart payload already, I just need to pass it to the flow in a way that it can parse.</p> <p>I also tried to simply paste it in a DataWeave expression:</p> <pre><code>%dw 2.0 output multipart/form-data boundary=&quot;------=_Part_1_5138113571742769845&quot; --- --------=_Part_1_5138113571742769845 Content-Type: text/xml ... </code></pre> <p>But when it tried to evaluate <code>payload.parts.part1.content.parts.part0.content</code>, I got the error:</p> <blockquote> <p>Message : &quot;javax.mail.internet.ParseException - Missing start boundary</p> </blockquote> <p>Although I did specify the boundary. Am I missing something?</p> <p>EDIT: I am using munit-runner version 2.3.9. The &quot;Execution&quot; part of the MUnit test case only has a Set Event and a Flow-ref (to the HTTP Listener, where I just try to log <code>payload.parts.part1.content.parts.part0.content</code>).</p> <p>The Set Event has &quot;Start with an empty event&quot; ticked, in the Payload tab under Value it has the DataWeave expression, under Media Type it has &quot;multipart/form-data&quot;,</p> <p>in the Attributes tab it has the headers:</p> <pre><code>&quot;headers&quot;: { &quot;accept-encoding&quot;: &quot;gzip,deflate&quot;, &quot;content-type&quot;: &quot;multipart/related; boundary=\&quot;------=_Part_1_5138113571742769845\&quot;; type=\&quot;text/xml\&quot;; start=\&quot;&lt;mm7-submit&gt;\&quot;&quot;, &quot;host&quot;: &quot;localhost:8081&quot;, &quot;connection&quot;: &quot;Keep-Alive&quot;, &quot;user-agent&quot;: &quot;Apache-HttpClient/4.5.5 (Java/16.0.1)&quot; } </code></pre> <p>EDIT 2: The full error trace is:</p> <pre><code>ERROR 2022-10-31 11:39:08,780 [[MuleRuntime].uber.12: [poc7].api-main.CPU_LITE @3bf5d6df] org.mule.runtime.core.internal.exception.OnErrorPropagateHandler: ******************************************************************************** Message : &quot;javax.mail.internet.ParseException - Missing start boundary javax.mail.internet.ParseException: Missing start boundary at javax.mail.internet.MimeMultipart.parse(MimeMultipart.java:656) at javax.mail.internet.MimeMultipart.getCount(MimeMultipart.java:312) at org.mule.weave.v2.module.multipart.MultiPartReader.doRead(MultiPartReader.scala:119) at org.mule.weave.v2.module.reader.Reader.read(Reader.scala:35) at org.mule.weave.v2.module.reader.Reader.read$(Reader.scala:33) at org.mule.weave.v2.module.multipart.MultiPartReader.read(MultiPartReader.scala:46) at org.mule.weave.v2.el.MuleTypedValue.value(MuleTypedValue.scala:147) at org.mule.weave.v2.model.values.wrappers.DelegateValue.valueType(DelegateValue.scala:17) at org.mule.weave.v2.model.values.wrappers.DelegateValue.valueType$(DelegateValue.scala:16) at org.mule.weave.v2.el.MuleTypedValue.valueType(MuleTypedValue.scala:177) at org.mule.weave.v2.model.types.ObjectType$.accepts(Type.scala:1068) at org.mule.weave.v2.interpreted.node.executors.BinaryOverloadedStaticExecutor.findMatchingFunction(BinaryOverloadedStaticExecutor.scala:151) at org.mule.weave.v2.interpreted.node.executors.BinaryOverloadedStaticExecutor.executeBinary(BinaryOverloadedStaticExecutor.scala:78) at org.mule.weave.v2.interpreted.node.ChainedBinaryOpNode.doExecute(ChainedBinaryOpNode.scala:37) at org.mule.weave.v2.interpreted.node.ValueNode.execute(ValueNode.scala:26) at org.mule.weave.v2.interpreted.node.ValueNode.execute$(ValueNode.scala:21) at org.mule.weave.v2.interpreted.node.ChainedBinaryOpNode.execute(ChainedBinaryOpNode.scala:7) at org.mule.weave.v2.interpreted.node.NullSafeNode.doExecute(NullSafeNode.scala:14) at org.mule.weave.v2.interpreted.node.ValueNode.execute(ValueNode.scala:26) at org.mule.weave.v2.interpreted.node.ValueNode.execute$(ValueNode.scala:21) at org.mule.weave.v2.interpreted.node.NullSafeNode.execute(NullSafeNode.scala:8) at org.mule.weave.v2.interpreted.node.structure.DocumentNode.doExecute(DocumentNode.scala:26) at org.mule.weave.v2.interpreted.node.ValueNode.execute(ValueNode.scala:26) at org.mule.weave.v2.interpreted.node.ValueNode.execute$(ValueNode.scala:21) at org.mule.weave.v2.interpreted.node.structure.DocumentNode.execute(DocumentNode.scala:11) at org.mule.weave.v2.interpreted.InterpretedMappingExecutableWeave.$anonfun$writeWith$3(InterpreterMappingCompilerPhase.scala:264) at org.mule.weave.v2.module.writer.WriterHelper$.writeValue(Writer.scala:161) at org.mule.weave.v2.module.writer.WriterHelper$.writeAndGetResult(Writer.scala:139) at org.mule.weave.v2.interpreted.InterpretedMappingExecutableWeave.writeWith(InterpreterMappingCompilerPhase.scala:264) at org.mule.weave.v2.el.WeaveExpressionLanguageSession.evaluateLogExpression(WeaveExpressionLanguageSession.scala:330) [...] at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2205) at reactor.core.publisher.MonoFlatMapMany$FlatMapManyMain.onSubscribe(MonoFlatMapMany.java:134) at reactor.core.publisher.MonoCurrentContext.subscribe(MonoCurrentContext.java:35) at reactor.core.publisher.MonoFlatMapMany.subscribe(MonoFlatMapMany.java:52) at reactor.core.publisher.MonoNext.subscribe(MonoNext.java:40) at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44) at reactor.core.publisher.MonoMap.subscribe(MonoMap.java:52) at reactor.core.publisher.MonoMap.subscribe(MonoMap.java:52) at reactor.core.publisher.MonoSubscriberContext.subscribe(MonoSubscriberContext.java:47) at reactor.core.publisher.MonoSubscriberContext.subscribe(MonoSubscriberContext.java:47) at reactor.core.publisher.Mono.subscribe(Mono.java:3873) at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:420) at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:204) at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:204) at reactor.core.publisher.FluxPublishOn$PublishOnSubscriber.runAsync(FluxPublishOn.java:447) at reactor.core.publisher.FluxPublishOn$PublishOnSubscriber.run(FluxPublishOn.java:534) at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:84) at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:37) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.mule.service.scheduler.internal.AbstractRunnableFutureDecorator.doRun(AbstractRunnableFutureDecorator.java:151) at org.mule.service.scheduler.internal.RunnableFutureDecorator.run(RunnableFutureDecorator.java:54) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834), while reading `payload` as MultiPart. Trace: at main (Unknown)&quot; evaluating expression: &quot;payload.parts.part1.content.parts.part0.content&quot;. Element : api-main/processors/2 @ poc7:poc7.xml:20 (Copy_of_Text_Logger) Element DSL : &lt;logger level=&quot;INFO&quot; doc:name=&quot;Copy_of_Text_Logger&quot; doc:id=&quot;3672afde-5a7c-4745-bd78-540d726e9354&quot; message=&quot;Received text: #[payload.parts.part1.content.parts.part0.content]&quot;&gt;&lt;/logger&gt; Error type : MULE:EXPRESSION FlowStack : at api-main(api-main/processors/2 @ poc7:poc7.xml:20 (Copy_of_Text_Logger)) (set debug level logging or '-Dmule.verbose.exceptions=true' for everything) ******************************************************************************** </code></pre> <p>And the test XML is:</p> <pre><code>&lt;munit:test name=&quot;poc7-test-suite-api-mainTest&quot; doc:id=&quot;f625b0a6-55a7-431a-962f-cbc68587dca7&quot; description=&quot;Test&quot; expectedErrorType=&quot;ANY&quot;&gt; &lt;munit:execution &gt; &lt;munit:set-event doc:name=&quot;Set Event&quot; doc:id=&quot;2fe9a6bc-b65d-4477-b705-010f247cec6f&quot; &gt; &lt;munit:payload value='%dw 2.0 output multipart/form-data ns soap http://schemas.xmlsoap.org/soap/envelope/ --- { parts: { part0: { headers: { &quot;Content-Type&quot;: &quot;text/xml&quot;, &quot;Content-ID&quot;: &quot;&amp;lt;mm7-submit&amp;gt;&quot; }, content: { soap#Envelope: &quot;\n ...\n&quot; } }, part1: { headers: { &quot;Content-Type&quot;: &quot;multipart/mixed; boundary=\&quot;------=_Part_2_3815517668157287202\&quot;&quot;, &quot;Content-ID&quot;: &quot;&amp;lt;attachment&amp;gt;&quot; }, content: { parts: { part0: { headers: { &quot;Content-Type&quot;: &quot;text/plain; name=text1.txt&quot;, &quot;Content-ID&quot;: &quot;&amp;lt;text1.txt&amp;gt;&quot;, &quot;Content-Location&quot;: &quot;bundled/text1.txt&quot; }, content: &quot;This is the text part I want to access\n&quot; }, part1: { headers: { &quot;Content-Type&quot;: &quot;image/png&quot;, &quot;Content-Transfer-Encoding&quot;: &quot;base64&quot;, &quot;Content-ID&quot;: &quot;&amp;lt;image.png&amp;gt;&quot;, &quot;Content-Location&quot;: &quot;bundled/image.jpg&quot; }, content: &quot;hi&quot; } } } } } }' mediaType=&quot;multipart/form-data&quot; /&gt; &lt;munit:attributes value=&quot;#[{&amp;quot;headers&amp;quot;: { &amp;quot;accept-encoding&amp;quot;: &amp;quot;gzip,deflate&amp;quot;, &amp;quot;content-type&amp;quot;: &amp;quot;multipart/related; boundary=\&amp;quot;------=_Part_1_5138113571742769845\&amp;quot;; type=\&amp;quot;text/xml\&amp;quot;; start=\&amp;quot;&amp;lt;mm7-submit&amp;gt;\&amp;quot;&amp;quot;, &amp;quot;host&amp;quot;: &amp;quot;localhost:8081&amp;quot;, &amp;quot;connection&amp;quot;: &amp;quot;Keep-Alive&amp;quot;, &amp;quot;user-agent&amp;quot;: &amp;quot;Apache-HttpClient/4.5.5 (Java/16.0.1)&amp;quot; } }]&quot; /&gt; &lt;/munit:set-event&gt; &lt;flow-ref doc:name=&quot;Flow-ref to api-main&quot; doc:id=&quot;75a9f728-f461-4233-a5b2-1a01d7b21e80&quot; name=&quot;api-main&quot;/&gt; &lt;/munit:execution&gt; &lt;munit:validation &gt; &lt;munit-tools:assert-equals message=&quot;Wrong HTTP Status code:&quot; expected=&quot;#[746]&quot; actual=&quot;#[message.inboundProperties['http.status']]&quot; doc:name=&quot;Assert Equals&quot;/&gt; &lt;/munit:validation&gt; &lt;/munit:test&gt; </code></pre>
[ { "answer_id": 74219400, "author": "Jaromanda X", "author_id": 5053002, "author_profile": "https://Stackoverflow.com/users/5053002", "pm_score": 1, "selected": false, "text": "${}" }, { "answer_id": 74219403, "author": "Boussadjra Brahim", "author_id": 8172857, "autho...
2022/10/27
[ "https://Stackoverflow.com/questions/74219370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11608080/" ]
74,219,378
<p>My organization needs me to authenticate a two factor authentication to scrape an internal website. Every time when i open a browser it will ask for an authentication . The authentication cookie is stored in <code>c://users//.way//cookie.bat</code> . I want to use this cookie file to scrape an internal website . can some one help me in this?</p> <p>sample program</p> <pre><code>from bs4 import BeautifulSoup import requests header={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'} cookie=c://users//.way//cookie.bat # cookie variable should read the contents in the cookie file and pass it in requests source=requests.get('https://www.internalwebsite.com',headers=header,cookie=cookies) soup=BeautifulSoup(source,'lxml') ### general scraping </code></pre> <p>I tried reading the cookie file but i am unable to do that. kindly help me in reading the cookie file and pass it in requests so that i can access internal website through <code>BeautifulSoup</code></p>
[ { "answer_id": 74219400, "author": "Jaromanda X", "author_id": 5053002, "author_profile": "https://Stackoverflow.com/users/5053002", "pm_score": 1, "selected": false, "text": "${}" }, { "answer_id": 74219403, "author": "Boussadjra Brahim", "author_id": 8172857, "autho...
2022/10/27
[ "https://Stackoverflow.com/questions/74219378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19700272/" ]
74,219,413
<p>I have a data frame roughly like this:</p> <pre><code>dput(df) structure(list(a = 1:9000, b = 1:9000, c = 1:9000, d = 1:9000, e = 1:9000, f = 1:9000, g = 1:9000, h = 1:9000, i = 1:9000), class = &quot;data.frame&quot;, row.names = c(NA, -9000L)) </code></pre> <p><em>Edit: These are the exact values this was just to show rough dimension, and there are far more columns as well, the values don't just run 1:9000</em></p> <p>To sample randomly &amp; add in a column of row averages I have been using the following:</p> <pre><code>sample_1 &lt;- sample(1:9000, 200, replace=F) sampled_df_1 &lt;- df[c(sample_1),] sampled_df_1$Means_1 &lt;- rowMeans(sampled_df_1) </code></pre> <p>I need to do this 100 times over, and then create a data frame of the means. I think I need to use a for loop for this as in:</p> <pre><code>for(i in 1:100){ sample_[i] &lt;- sample(1:9000, 200, replace=F) sampled_df_[i] &lt;- df[c(sample_[i]),] sampled_df_[i]$Means_[i] &lt;- rowMeans(sampled_df_[i])} </code></pre> <p>but the [i] doesn't append the vector number. I have also tried {i} and '+i' Is this possible to do? I think assign(paste()) may be the key here but I am struggling with it And when I am past it is there an easy way to create a data frame of just the means columns without typing out all their names?</p>
[ { "answer_id": 74219799, "author": "Mikko Marttila", "author_id": 4550695, "author_profile": "https://Stackoverflow.com/users/4550695", "pm_score": 2, "selected": false, "text": "sapply()" }, { "answer_id": 74219982, "author": "Roasty247", "author_id": 3723262, "autho...
2022/10/27
[ "https://Stackoverflow.com/questions/74219413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19199954/" ]
74,219,450
<p>I would like to replace specific parts of string containing numbers with a dictionary. Suppose I have a dictionary:</p> <pre><code>d = {7: 'mandat_dépôt', 46: 'battu', 79: 'alphabétisé', 127: 'escrime', 160: 'daara', 162: 'arrivée_foyer', 169: 'fugue', 170: 'né_légitimement'} </code></pre> <p>I have these kinds of string:</p> <pre><code>s_1 = &quot;7 ==&gt; 127 #SUP: 41 #CONF: 0.8723404255319149&quot; s_2 = &quot;46 ==&gt; 162,169 #SUP: 39 #CONF: 0.8478260869565217&quot; s_3 = &quot;46,169 ==&gt; 162 #SUP: 39 #CONF: 0.975&quot; s_4 = &quot;160,169 ==&gt; 79,162 #SUP: 40 #CONF: 0.7692307692307693&quot; s_5 = &quot;160,162,170 ==&gt; 79 #SUP: 39 #CONF: 0.8125&quot; </code></pre> <p>Expected strings:</p> <pre><code>new_s_1 = &quot;mandat_dépôt ==&gt; escrime #SUP: 41 #CONF: 0.8723404255319149&quot; new_s_2 = &quot;battu ==&gt; arrivée_foyer,fugue #SUP: 39 #CONF: 0.8478260869565217&quot; new_s_3 = &quot;battu,fugue ==&gt; arrivée_foyer #SUP: 39 #CONF: 0.975&quot; new_s_4 = &quot;daara,fugue ==&gt; alphabétisé,arrivée_foyer #SUP: 40 #CONF: 0.7692307692307693&quot; new_s_5 = &quot;daara,arrivée_foyer,né_légitimement ==&gt; alphabétisé #SUP: 39 #CONF: 0.8125&quot; </code></pre> <p>Note that i don't want to replace the value of #SUP even if there exists some keys in the the dictionary.</p> <p>Is there an effective way to do it?</p>
[ { "answer_id": 74219720, "author": "Mohamed Mokhtar", "author_id": 8807152, "author_profile": "https://Stackoverflow.com/users/8807152", "pm_score": 0, "selected": false, "text": "d = {7: 'mandat_dépôt', 46: 'battu', 79: 'alphabétisé', 127: 'escrime', 160: 'daara', 162: 'arrivée_foyer', ...
2022/10/27
[ "https://Stackoverflow.com/questions/74219450", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14471688/" ]
74,219,456
<p>I was watching a tutorial on how to make todos, though my main focus was local storage use.</p> <p>But when he made the delete button then I was a bit confused, the code below shows how he did it but I am not getting it.</p> <p>Can anyone explain that I tried using the splice method to remove items from the array but I am not able to remove the items from the page?</p> <p>Can you also suggest what should I do after using splice to return the array on the page?</p> <p>Below is the code,</p> <pre><code>import &quot;./styles.css&quot;; import { useState, useEffect } from 'react' import Todoform from './TodoForm' export default function App() { const [list, setlist] = useState(&quot;&quot;); const [items, setitems] = useState([]) const itemevent = (e) =&gt; { setlist(e.target.value); } const listofitem = () =&gt; { setitems((e) =&gt; { return [...e , list]; }) } const deleteItems = (e) =&gt; { // TODO: items.splice(e-1, 1); // Is there any other way I can do the below thing .i.e // to remove todos from page. // this is from tutorial setitems((e1)=&gt;{ return e1.filter((er , index)=&gt;{ return index!=e-1; }) }) } return ( &lt;&gt; &lt;div className='display_info'&gt; &lt;h1&gt;TODO LIST&lt;/h1&gt; &lt;br /&gt; &lt;input onChange={itemevent} value={list} type=&quot;text&quot; name=&quot;&quot; id=&quot;&quot; /&gt; &lt;br /&gt; &lt;button onClick={listofitem} &gt;Add &lt;/button&gt; &lt;ul&gt; { items.map((e, index) =&gt; { index++; return ( &lt;&gt; &lt;Todoform onSelect={deleteItems} id={index} key={index} index={index} text={e} /&gt; &lt;/&gt; ) }) } &lt;/ul&gt; &lt;/div&gt; &lt;/&gt; ) } </code></pre> <p>And this is the TodoForm in this code above,</p> <pre><code>import React from 'react' export default function Todoform(props) { const { text, index } = props; return ( &lt;&gt; &lt;div key={index} &gt; {index}. {text} &amp;nbsp;&amp;nbsp; &lt;button onClick={() =&gt; { props.onSelect(index) }} className=&quot;delete&quot;&gt;remove&lt;/button&gt; &lt;/div&gt; &lt;/&gt; ) } </code></pre> <p>Here is the codeSandbox link</p> <p><a href="https://codesandbox.io/s/old-wood-cbnq86?file=/src/TodoForm.jsx:0-317" rel="nofollow noreferrer">https://codesandbox.io/s/old-wood-cbnq86?file=/src/TodoForm.jsx:0-317</a></p>
[ { "answer_id": 74219720, "author": "Mohamed Mokhtar", "author_id": 8807152, "author_profile": "https://Stackoverflow.com/users/8807152", "pm_score": 0, "selected": false, "text": "d = {7: 'mandat_dépôt', 46: 'battu', 79: 'alphabétisé', 127: 'escrime', 160: 'daara', 162: 'arrivée_foyer', ...
2022/10/27
[ "https://Stackoverflow.com/questions/74219456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19757319/" ]
74,219,480
<p>I recently upgraded to Python 3.11 and proceeded to get my usual libraries back.</p> <p>I managed to install everything back without much trouble.</p> <p>However I cannot get Pytorch!</p> <p>I installed everything through pip which worked fine until getting to Pytorch.</p> <p>I get this error: &quot;ERROR: Could not find a version that satisfies the requirement torch (from versions: none) ERROR: No matching distribution found for torch&quot;</p> <p>I tried every command suggested on PyTorch.com, but I always end-up with that same exact error message.</p> <p>Has anyone encountered this after switching to Python 3.11?</p> <p>Thank you in advance and have a nice day.</p>
[ { "answer_id": 74219720, "author": "Mohamed Mokhtar", "author_id": 8807152, "author_profile": "https://Stackoverflow.com/users/8807152", "pm_score": 0, "selected": false, "text": "d = {7: 'mandat_dépôt', 46: 'battu', 79: 'alphabétisé', 127: 'escrime', 160: 'daara', 162: 'arrivée_foyer', ...
2022/10/27
[ "https://Stackoverflow.com/questions/74219480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20347179/" ]
74,219,494
<p>I have a Json data as following. The Json has many such objects with same NameId's:</p> <pre><code>[{ &quot;NameId&quot;: &quot;name1&quot;, &quot;exp&quot;: { &quot;exp1&quot;: &quot;test1&quot; } }, { &quot;NameId&quot;: &quot;name1&quot;, &quot;exp&quot;: { &quot;exp2&quot;: &quot;test2&quot; } } </code></pre> <p>]</p> <p>Now, what I am after is to create a new Json Object that has a merged exp and create a file something like below, so that I do not have multiple NameId:</p> <p>[{ &quot;NameId&quot;: &quot;name1&quot;, &quot;exp&quot;: { &quot;exp1&quot;: &quot;test1&quot;, &quot;exp2&quot;: &quot;test2&quot; } } ]</p> <p>Is there a possibility I can achive it using Python?</p>
[ { "answer_id": 74219873, "author": "assume_irrational_is_rational", "author_id": 11622508, "author_profile": "https://Stackoverflow.com/users/11622508", "pm_score": 0, "selected": false, "text": "itertools.groupby" }, { "answer_id": 74220334, "author": "Wyrzutek", "author...
2022/10/27
[ "https://Stackoverflow.com/questions/74219494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2397257/" ]
74,219,528
<p>I am trying to get lower case letters from Kotlin Enum class when i pass the object in @QueryValue, but i am getting only upper case letters.</p> <p>I have an enum in data class for example like below:</p> <pre><code>enum class StudentName{ @JsonProperty(&quot;ram&quot;) RAM, @JsonProperty(&quot;sam&quot;) SAM } </code></pre> <p>and i am using that enum like below:</p> <pre><code>data class StudentParams( @JsonProperty(&quot;studentName&quot;) val studentName: StudentName, @JsonProperty(&quot;age&quot;) val age: Int ) </code></pre> <p>I am passing this data class as request object in param value like below</p> <pre><code>@Post(POST_STUDENT_AGE) fun postStudentAge( studentParams: StudentParams ): String </code></pre> <p>so in my URL, request object will go in params like --some url--/<strong>&amp;studentName=ram&amp;age=20</strong></p> <p>i need lower case letters from StudentName enum class here but getting only Upper case. When i pass the request object with @body annotation i am getting lower case letters in the request.</p> <p>I tried enabling ACCEPT_CASE_INSENSITIVE_ENUMS also but didn't work.</p> <pre><code></code></pre>
[ { "answer_id": 74219873, "author": "assume_irrational_is_rational", "author_id": 11622508, "author_profile": "https://Stackoverflow.com/users/11622508", "pm_score": 0, "selected": false, "text": "itertools.groupby" }, { "answer_id": 74220334, "author": "Wyrzutek", "author...
2022/10/27
[ "https://Stackoverflow.com/questions/74219528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13480480/" ]
74,219,529
<p>I have created a small project using Wt(C++ Web Toolkit). and I now want to host it.</p> <ul> <li>Since there are very sparse resources for this, I read somewhere that LAMP is required for this(since I am using Linux). So after creating an Ubuntu instance at Digital Ocean, I installed my code in it with Apache2, MySql, and PHP. The Apache2 server is working, but it is used for hosting HTML/CSS/JS files. my web page is written entirely in C++.</li> <li>I got directed to this website: <a href="https://www.webtoolkit.eu/wt/doc/reference/html/overview.html#wthttpd" rel="nofollow noreferrer">https://www.webtoolkit.eu/wt/doc/reference/html/overview.html#wthttpd</a> where it mentions &quot;connectors&quot; like <code>libwthttp</code> and <code>libwtfcgi</code>. I tried to install them using <code>apt</code> but I get this error: <code>E: Unable to locate package libwtfcgi-dev</code> (same for libwthttp).</li> <li>The website mentioned above also does not provide clear steps for using these connectors.</li> <li>I have also looked at other related answers : <a href="https://stackoverflow.com/questions/5227842/host-for-wt-c-web-framework-deplowment-issue">Host for Wt C++ web framework, deplowment issue</a> but since I am new to web hosting, I would really appreciate a step-by-step guidance.</li> <li>Even here: <a href="https://redmine.webtoolkit.eu/projects/wt/wiki/Fastcgi_on_apache" rel="nofollow noreferrer">https://redmine.webtoolkit.eu/projects/wt/wiki/Fastcgi_on_apache</a> The language is very unclear ast to where <code>fastcgi.conf</code> is located.</li> </ul>
[ { "answer_id": 74219873, "author": "assume_irrational_is_rational", "author_id": 11622508, "author_profile": "https://Stackoverflow.com/users/11622508", "pm_score": 0, "selected": false, "text": "itertools.groupby" }, { "answer_id": 74220334, "author": "Wyrzutek", "author...
2022/10/27
[ "https://Stackoverflow.com/questions/74219529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8550635/" ]
74,219,541
<p>I have a function that gets a number and has to calculate the multiplication for each number with the rest of the numbers in the sequence.</p> <p>If the input is 10, it should calculate the multiplication between 1x1, 1x2, 1x3, .... 10x1, 10x2, 10x3, .... 10x10. (passing through all the numbers sequentially)</p> <p>So I thought at first sight that I need a double loop to do all possible multiplications but for big numbers it executes following O(n*n) which is too slow.</p> <p>I heard there is a way to use only one loop. Do you know any post related with this subject? The only ones I found doesn't take into count that I need to perform the calculation foreach number by the rest of the numbers of the array.</p> <p>Here the code:</p> <pre><code>for(i=1;i&lt;=n;i++){ for(j=1;j&lt;=n;j++){ // do i*j } } </code></pre>
[ { "answer_id": 74219885, "author": "Qing", "author_id": 6635815, "author_profile": "https://Stackoverflow.com/users/6635815", "pm_score": -1, "selected": false, "text": "map" }, { "answer_id": 74226807, "author": "Karthik Sivasubramaniam", "author_id": 10276412, "auth...
2022/10/27
[ "https://Stackoverflow.com/questions/74219541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/79919/" ]
74,219,546
<p>Talend rookie here. I succed to split a column &quot;category&quot; based on &quot;/&quot; delimiter using tExtractDelimited. However it din't give me correct header name as I have entered in the schema. TFileInputExcel &amp; tFileOutputExcel file.</p> <p>expected result **: <a href="https://i.stack.imgur.com/O6SFa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/O6SFa.png" alt="enter image description here" /></a></p> <p>instead i get this : <a href="https://i.stack.imgur.com/zfFZa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zfFZa.png" alt="enter image description here" /></a></p> <p>or if i checked the option with &quot;include header&quot; in tFileOutputExcel, it gave me this : <a href="https://i.stack.imgur.com/oZ1Rj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oZ1Rj.png" alt="enter image description here" /></a></p> <p>any idea how to get the expected result ?</p>
[ { "answer_id": 74219885, "author": "Qing", "author_id": 6635815, "author_profile": "https://Stackoverflow.com/users/6635815", "pm_score": -1, "selected": false, "text": "map" }, { "answer_id": 74226807, "author": "Karthik Sivasubramaniam", "author_id": 10276412, "auth...
2022/10/27
[ "https://Stackoverflow.com/questions/74219546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18233914/" ]
74,219,561
<p>I have a data that looks like this</p> <pre class="lang-r prettyprint-override"><code>library(tidyverse) df = tibble(gene=c(&quot;geneA&quot;,&quot;geneB&quot;,&quot;geneC&quot;), dat1=c(100,100,50), dat2=c(50,100,20), dat3=c(10,20,30)) df #&gt; # A tibble: 3 × 4 #&gt; gene dat1 dat2 dat3 #&gt; &lt;chr&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; #&gt; 1 geneA 100 50 10 #&gt; 2 geneB 100 100 20 #&gt; 3 geneC 50 20 30 </code></pre> <p><sup>Created on 2022-10-27 with <a href="https://reprex.tidyverse.org" rel="nofollow noreferrer">reprex v2.0.2</a></sup></p> <p>I want to summarise the values of all columns except the first one as a list in a new column while I am keeping the rest of the columns. I want my data to look like this</p> <pre><code>#&gt; # A tibble: 3 × 4 #&gt; gene dat1 dat2 dat3 data #&gt; &lt;chr&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;list&gt; #&gt; 1 geneA 100 50 10 100,50,10 #&gt; 2 geneB 100 100 20 100,100,20 #&gt; 3 geneC 50 20 30 50,20,30 </code></pre>
[ { "answer_id": 74219627, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 3, "selected": true, "text": "rowwise" }, { "answer_id": 74225443, "author": "akrun", "author_id": 3732271, "author_profile": "h...
2022/10/27
[ "https://Stackoverflow.com/questions/74219561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7179299/" ]
74,219,569
<p>Using Pandas, how to check if a valid polygon geometry can be created using coordinates from a string?</p> <p>Input example:</p> <pre class="lang-py prettyprint-override"><code>import pandas as pd coord_series = pd.Series([ '-33, 50, -30, 38, -40, 27, -33.0, 50.5', '-xx, xx, -xx, xx, -xx, xx, -xxxx, xxxx', None, '-10', '-10, 20, -30, 40, -50, 60, -70', '-11, 11, -11, 11, -11, 11, -11.1, 11.1' ]) </code></pre> <p>Only the first string forms a valid polygon.</p> <p>A function is needed which accepts one Series object and outputs one Series object.</p>
[ { "answer_id": 74219627, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 3, "selected": true, "text": "rowwise" }, { "answer_id": 74225443, "author": "akrun", "author_id": 3732271, "author_profile": "h...
2022/10/27
[ "https://Stackoverflow.com/questions/74219569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2753501/" ]
74,219,571
<p>My build pipeline gives an error, when I check the status of jitpack it is nearly always down. Would jitpack being down cause the error and could I remove or replace jitpack with something else?</p> <pre><code>Execution failed for task ‘:@adobe_react-native-acpanalytics:mergeReleaseResources’. &gt; Could not resolve all files for configuration ‘:@adobe_react-native-acpanalytics:releaseRuntimeClasspath’. &gt; Could not resolve com.adobe.marketing.mobile:analytics:1.+. Required by: project :@adobe_react-native-acpanalytics &gt; Failed to list versions for com.adobe.marketing.mobile:analytics. </code></pre> <p>My build.gradle has the following:</p> <pre><code>allprojects { repositories { mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url(&quot;$rootDir/../node_modules/react-native/android&quot;) } maven { // Android JSC is installed from npm url(&quot;$rootDir/../node_modules/jsc-android/dist&quot;) } maven { // react-native-background-fetch url(&quot;${project(':react-native-background-fetch').projectDir}/libs&quot;) } google() jcenter() maven { url 'https://jitpack.io' } } } </code></pre>
[ { "answer_id": 74219627, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 3, "selected": true, "text": "rowwise" }, { "answer_id": 74225443, "author": "akrun", "author_id": 3732271, "author_profile": "h...
2022/10/27
[ "https://Stackoverflow.com/questions/74219571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1901521/" ]
74,219,582
<p>I'm trying to pass a function (addTask) as a prop from parent component (MainComponent.js) to Child Component (Button.js) but it's not working. I've also passed a variable (btnColor) as prop and it's working properly. What am I missing?</p> <p>MainComponent.js:</p> <pre><code>import Button from &quot;./Button&quot;; const MainComponent = () =&gt; { const addTask = () =&gt; { console.log(&quot;Task Added...&quot;); }; return ( &lt;div&gt; &lt;div&gt; Header Component here &lt;/div&gt; &lt;div&gt; Some Data &lt;/div&gt; &lt;Button onClick={addTask} btnColor=&quot;red&quot; /&gt; &lt;div&gt; Footer Component here &lt;/div&gt; &lt;/div&gt; ); }; export default MainComponent; </code></pre> <p>Button.js:</p> <pre><code>const Button = ({ addTask, btnColor }) =&gt; { return ( &lt;button style={{ backgroundColor: btnColor }} onClick={addTask}&gt; Add &lt;/button&gt; ); }; export default Button; </code></pre> <p>I'm expecting the console to log 'Task Added...' but it isn't logging anything.</p>
[ { "answer_id": 74219675, "author": "Oyyou", "author_id": 2156427, "author_profile": "https://Stackoverflow.com/users/2156427", "pm_score": 2, "selected": false, "text": "onClick" }, { "answer_id": 74219693, "author": "khashaa amaze", "author_id": 11423530, "author_pro...
2022/10/27
[ "https://Stackoverflow.com/questions/74219582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14774629/" ]
74,219,587
<p>I have 2 tables, <code>Customers</code> and <code>Countries</code>, like so:</p> <p>Customers:</p> <pre><code> +----+------+-----+---------------+----------------+ | ID | Name | ... | OfficeCountry | BillingCountry | +----+------+-----+---------------+----------------+ | 1 | Bill | ... | 1 | 1 | | 2 | Joe | ... | 2 | 1 | +----+------+-----+---------------+----------------+ </code></pre> <p>Countries:</p> <pre><code> +----+-------------+ | ID | Name | +----+-------------+ | 1 | USA | | 2 | Netherlands | +----+-------------+ </code></pre> <p>(I stripped some columns from the <code>Customers</code> table to only have some relevant columns for this question) The purpose of those two columns are that the country for billing and the physical office location could be different. We also have more address information in this table, but stripped for this example.</p> <p>I <code>JOIN</code> these two tables with a query resulting in something like this:</p> <pre><code>SELECT ID, some, fields, Countries_1.Name AS OfficeCountryName, Countries_2.Name AS BillingCountryName FROM Customers LEFT JOIN Countries AS Countries_1 ON Customers.OfficeCountry = Countries_1.ID LEFT JOIN Countries AS Countries_2 ON Customers.BillingCountry = Countries_2.ID </code></pre> <p>The application we are using is a MS Access front end with a MySQL back-end. This is done with ODBC.</p> <p>The <code>Customers</code> table contains roughly 15,000 records.</p> <p>The problem is that the application has a bad performance. I enabled the query log, and I can see the following queries being executed when I am loading the data (from a DynaSet) into a form:</p> <ul> <li>The Query as written above</li> <li>An extra query, with an <code>OUTER JOIN</code>, written in the old legacy <code>{oj ...}</code> syntax</li> <li><strong>30.000 queries</strong> (2x the COUNT from <code>Customers</code>) to the <code>Countries</code> table. This exact query: <code>SELECT ID FROM Countries WHERE ID = 2</code> (or <code>ID = 1</code>, depending on the Customer).</li> </ul> <p>The last two queries amaze me.</p> <ol> <li>First, <strong>WHERE is the <code>OUTER JOIN</code> query coming from?</strong> I never specified any <code>OUTER JOIN</code> in Access. Also, the old legacy <code>{oj ..}</code> syntax gives me the feeling that something's up. Also, this query is not needed. I do not use it's data in the Access front end, and I don't know where it's coming from.</li> <li>Second, <strong>WHY is Access query'ing the <code>Countries</code> table for every record?</strong> The data isn't needed, and also not helpful. It's only <code>SELECT</code>ing the ID which it already knows (as seen in the <code>WHERE</code> clause)</li> </ol> <p>As you can imagine, 30,000 queries is greatly slowing down the performance.</p> <p>I know that it's not good practice to load 15,000 records into one form (with navigation controls and such), but it's a very old legacy application and a lot of work to re-write.</p> <p><strong>EDIT</strong> I see now that for very simple queries, with just a purpose build very clean form, it generates a few queries:</p> <ol> <li>A query that selects all ID's (so for the Customer, and twice the JOIN'ed table</li> <li>A query that selects all neccesary fields PER RECORD RETURNED from query 1, FOR EVERY TABLE. So a SELECT FROM Customers WHERE Id = record_currently_viewed</li> </ol>
[ { "answer_id": 74303265, "author": "Martins", "author_id": 3713892, "author_profile": "https://Stackoverflow.com/users/3713892", "pm_score": 0, "selected": false, "text": "with memCountry (ID, Name) as (select ID, Name from Countries) \nselect cu.ID, cu.Name, c1.Name, c2.Name from Custom...
2022/10/27
[ "https://Stackoverflow.com/questions/74219587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1451545/" ]
74,219,593
<p>I am using Flutter 2.8, as many package dont yet have support for latest flutter version. I am using stack instead of appBar. and I want to get the look as of below picture.</p> <p>I dont want to use stack in the whole page, i think it will cause performance issues. Also, If i use stack only in lieu of appBar, I can copy paste this code to make that home button on top-left corner, for another app.</p> <p>here is my full code of this page:</p> <pre><code>import 'package:flutter/material.dart'; class HomePage extends StatelessWidget { const HomePage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return SafeArea( child : Scaffold( //todo: 1. copy code from getx4 cool ui app //todo: 1. make it as he made it body: Column( children: [ Expanded( flex: 1, child: Container( color: Color(0xFFc5e5f3), child: Stack( children: [ Positioned( top: 10, left: 5, child: IconButton( onPressed: () {}, icon: Icon(Icons.home), )), ], ), ), ), Expanded( flex: 10, child: Padding( padding: const EdgeInsets.all(15.0), child: Row( children: [ Expanded(child: Text('ShopX', style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold) ,)), Padding( padding: const EdgeInsets.only(right: 8) , child: Icon(Icons.format_list_bulleted ), ), Icon(Icons.grid_view_outlined ), ], ), ), ), ], ), ), ); } } </code></pre> <hr /> <p><a href="https://i.stack.imgur.com/99vDU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/99vDU.png" alt="the one that i have" /></a></p> <p><a href="https://i.stack.imgur.com/UrWoy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UrWoy.png" alt="The one that i want" /></a></p>
[ { "answer_id": 74303265, "author": "Martins", "author_id": 3713892, "author_profile": "https://Stackoverflow.com/users/3713892", "pm_score": 0, "selected": false, "text": "with memCountry (ID, Name) as (select ID, Name from Countries) \nselect cu.ID, cu.Name, c1.Name, c2.Name from Custom...
2022/10/27
[ "https://Stackoverflow.com/questions/74219593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11565523/" ]
74,219,608
<p>I have been doing this problem for 2 days now, and I still can't figure out how to do this properly.</p> <p>In this program, I have to input the number of sticks available (let's say 5). Then, the user will be asked to input the lengths of each stick (space-separated integer). Let's say the lengths of each stick respectively are [4, 4, 3, 3, 4]. Now, I have to determine if there are pairs (2 sticks of same length). In this case, we have 2 (4,4 and 3,3). Since there are 2 pairs, we can create a canvas (a canvas has a total of 2 pairs of sticks as the frame). Now, I don't know exactly how to determine how many &quot;pairs&quot; there are in an array. I would like to ask for your help and guidance. Just note that I am a beginner. I might not understand complex processes. So, if there is a simple (or something that a beginner can understand) way to do it, it would be great. It's just that I don't want to put something in my code that I don't fully comprehend. Thank you!</p> <p>Attached here is the link to the problem itself. <a href="https://codeforces.com/problemset/problem/127/B" rel="nofollow noreferrer">https://codeforces.com/problemset/problem/127/B</a></p> <p>Here is my code (without the process that determines the number of pairs)</p> <pre><code>#include&lt;iostream&gt; #include&lt;cmath&gt; #define MAX 100 int lookForPairs(int numberOfSticks); int main(void){ int numberOfSticks = 0, maxNumOfFrames = 0; std::cin &gt;&gt; numberOfSticks; maxNumOfFrames = lookForPairs(numberOfSticks); std::cout &lt;&lt; maxNumOfFrames &lt;&lt; std::endl; return 0; } int lookForPairs(int numberOfSticks){ int lengths[MAX], pairs = 0, count = 0, canvas = 0; for(int i=0; i&lt;numberOfSticks; i++){ std::cin &gt;&gt; lengths[i]; } pairs = floor(count/2); canvas = floor(pairs/2); return count; } </code></pre> <p>I tried doing it like this, but it was flawed. It wouldn't work when there were 3 or more integers of the same number (for ex. [4, 4, 3, 4, 2] or [5. 5. 5. 5. 6]). On the first array, the count would be 6 when it should only be 3 since there are only three 4s.</p> <pre><code> for(int i=0; i&lt;numberOfSticks; i++){ for (int j=0; j&lt;numberOfSticks; j++){ if (lengths[i] == lengths[j] &amp;&amp; i!=j) count++; } } </code></pre>
[ { "answer_id": 74219685, "author": "JimmyNJ", "author_id": 6016071, "author_profile": "https://Stackoverflow.com/users/6016071", "pm_score": 0, "selected": false, "text": "i" }, { "answer_id": 74219889, "author": "molbdnilo", "author_id": 404970, "author_profile": "ht...
2022/10/27
[ "https://Stackoverflow.com/questions/74219608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19566276/" ]
74,219,621
<p>To reproduce:</p> <ol> <li>Run the MVCE snippet on both Firefox desktop and Chrome desktop.</li> <li>Open FF desktop, then copy &quot;foobar&quot; from source.</li> <li>Open Chrome desktop, and paste into target (after the colon in <code>here:</code>)</li> </ol> <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>window.onload = function() { const info = document.querySelector('.info'), pinfo = document.querySelector('.paste-info'), target = document.querySelector('.target'); setInterval(() =&gt; { const sel = ".source *, .target *" info.innerHTML = ''; for (const elm of [...document.querySelectorAll(sel)]) { info.innerHTML += "TAG: " + elm.tagName + "; TEXT: " + elm.innerText + "; FONTSIZE: " + window.getComputedStyle(elm)['font-size'] + "&lt;br&gt;"; } }, 1000); target.addEventListener('paste', function(e) { pinfo.innerHTML += "PASTE HTML: &lt;pre&gt;" + e.clipboardData.getData('text/html').replaceAll('&lt;', '&amp;lt;').replaceAll('&gt;', '&amp;gt;') + '&lt;/pre&gt;&lt;br&gt;'; }); };</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>div[contenteditable] { border: 1px solid black; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="source" contenteditable=true&gt;Source text: &lt;b&gt;foobar&lt;/b&gt;&lt;/div&gt; &lt;div style="font-size: 14px"&gt; &lt;div contenteditable=true class="target"&gt;Destination, &lt;h1&gt;paste here:&lt;/h1&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="info"&gt;&lt;/div&gt; &lt;div class="paste-info"&gt;&lt;/div&gt;</code></pre> </div> </div> </p> <p>You will notice that:</p> <ol> <li>Clipboard data contains <code>&lt;b&gt;foobar&lt;/b&gt;</code> (see content after <code>PASTE HTML:</code>), but...</li> <li>The actually pasted HTML has <code>style=&quot;font-size: 14px;&quot;</code> set on the <code>b</code> element (The 14px size comes from the parent of the contenteditable).</li> </ol> <p>I expect the pasted HTML to not have any font sizes set on it, because they were not specified in the source clipboard data.</p> <blockquote> <p><strong>Question:</strong> How to force Chrome to not put any font sizes on the pasted HTML, when there is no font-size present on the source HTML?</p> </blockquote> <p>I tried one workaround: to set <code>font-size: unset/revert</code> on the source, but it causes <code>font-size: unset</code> to also be present in the pasted HTML. I prefer to not have any font-size to be present in the pasted HTML.</p> <hr /> <p>The context of this code is a Chrome extension, and I control the text/html data that is pasted into the target. I can attach a paste event listeners on the target contenteditable, but I cannot alter the HTML/styles of contents <em>after</em> it has been pasted.</p>
[ { "answer_id": 74316428, "author": "John", "author_id": 11111119, "author_profile": "https://Stackoverflow.com/users/11111119", "pm_score": 0, "selected": false, "text": "id=\"editor\"" }, { "answer_id": 74337321, "author": "Rene van der Lende", "author_id": 2015909, ...
2022/10/27
[ "https://Stackoverflow.com/questions/74219621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2181238/" ]
74,219,625
<p>I have two dataframes:</p> <pre><code>df = spark.createDataFrame([(&quot;joe&quot;, 34), (&quot;luisa&quot;, 22)], [&quot;name&quot;, &quot;age&quot;]) df2 = spark.createDataFrame([(&quot;joe&quot;, 88), (&quot;luisa&quot;, 99)], [&quot;name&quot;, &quot;age&quot;]) </code></pre> <p>I want to update the age when the names match. So I thought using a when() would work.</p> <pre><code>df.withColumn(&quot;age&quot;, F.when(df.name == df2.name, df2.age)).otherwise(df.age) </code></pre> <p>but this results in this error:</p> <pre><code>AnalysisException: Resolved attribute(s) name#181,age#182L missing from name#177,age#178L in operator !Project [name#177, CASE WHEN (name#177 = name#181) THEN age#182L END AS age#724L]. Attribute(s) with the same name appear in the operation: name,age. Please check if the right attribute(s) are used.; </code></pre> <p>how do resolve this? because when i print the when statement i see this:</p> <pre><code>Column&lt;'CASE WHEN (name = name) THEN age ELSE age END'&gt; </code></pre>
[ { "answer_id": 74316428, "author": "John", "author_id": 11111119, "author_profile": "https://Stackoverflow.com/users/11111119", "pm_score": 0, "selected": false, "text": "id=\"editor\"" }, { "answer_id": 74337321, "author": "Rene van der Lende", "author_id": 2015909, ...
2022/10/27
[ "https://Stackoverflow.com/questions/74219625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15185140/" ]
74,219,636
<p>I'm trying to write a template that configures the whole ecs fargate server and its code pipeline.</p> <p>There is no problem in all other configurations, but the image is empty because it is right after creating the ecr in cloudformation, and the create ecs service refers to the empty image and the process does not end.</p> <p>So I want to push the server image to ecr with code build and then ecs service create to work, but I don't know how.</p> <p>Could it be possible to trigger code build or code pipeline inside cloudformation? If not, is there any way to do docker build &amp; push?</p>
[ { "answer_id": 74316428, "author": "John", "author_id": 11111119, "author_profile": "https://Stackoverflow.com/users/11111119", "pm_score": 0, "selected": false, "text": "id=\"editor\"" }, { "answer_id": 74337321, "author": "Rene van der Lende", "author_id": 2015909, ...
2022/10/27
[ "https://Stackoverflow.com/questions/74219636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9018595/" ]
74,219,641
<p>I was trying to re-render a Quarto document after adding some more code. The code previously rendered fine.</p> <p>However, this time the render failed, with this error:</p> <pre><code>Error in yaml::yaml.load(meta, handlers = list(expr = parse_only)) : Parser error: while parsing a block mapping at line 1, column 1 did not find expected key at line 2, column 27 Calls: .main ... FUN -&gt; parse_block -&gt; partition_chunk -&gt; &lt;Anonymous&gt; Execution halted </code></pre> <p>I thought this was referring to the YAML bit at the top, but I hadn't made any changes to that, and the document previously rendered fine. I simplified the YAML to the simplest case, but the error persisted.</p> <pre><code>--- title: &quot;Test&quot; format: html --- ```{r} #| label: tbl-exibble #| tbl-cap: &quot;Exibble Bla Bla&quot;) gt::gt(exibble) ``` </code></pre> <p>This was caused by a typo - I'm posting this and answering it here because I think the error message is not particularly helpful and it might mislead other people</p>
[ { "answer_id": 74219642, "author": "Andrea M", "author_id": 13968222, "author_profile": "https://Stackoverflow.com/users/13968222", "pm_score": 1, "selected": true, "text": ")" }, { "answer_id": 74220098, "author": "Julian", "author_id": 14137004, "author_profile": "h...
2022/10/27
[ "https://Stackoverflow.com/questions/74219641", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13968222/" ]
74,219,667
<p><a href="https://i.stack.imgur.com/k85pM.png" rel="nofollow noreferrer">This is the information in my db</a></p> <p><a href="https://i.stack.imgur.com/2uv1H.png" rel="nofollow noreferrer">This is my model</a></p> <p><a href="https://i.stack.imgur.com/d3Uv1.png" rel="nofollow noreferrer">Serializers</a></p> <pre><code>@api_view(['GET', 'POST', 'DELETE']) def student_list(request): if request.method == 'GET': student = Student.objects.all() FirstName = request.GET.get('FirstName', None) if FirstName is not None: student = student.filter(FirstName__icontains=FirstName) student_serializer = StudentSerializer(student, many=True) return JsonResponse(student_serializer.data, safe=False) elif request.method == 'POST': student_data = JSONParser().parse(request) student_serializer = StudentSerializer(data=student_data) if student_serializer.is_valid(): student_serializer.save() return JsonResponse(student_serializer.data, status=status.HTTP_201_CREATED) return JsonResponse(student_serializer.errors, status=status.HTTP_400_BAD_REQUEST) </code></pre> <p>Above is my view, I have no problem with Post but when I use Get I only got a &quot;[ ]&quot; . I'm not sure where exactly is the mistake ...</p> <p><a href="https://i.stack.imgur.com/TJ4j9.png" rel="nofollow noreferrer">PostMan Get</a></p> <p>I was following this guide for anyone wondering : <a href="https://www.bezkoder.com/django-postgresql-crud-rest-framework/" rel="nofollow noreferrer">https://www.bezkoder.com/django-postgresql-crud-rest-framework/</a></p> <pre><code> import os import environ env = environ.Env() environ.Env.read_env() # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(file))) SECRET_KEY = env(&quot;SECRET_KEY&quot;) # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'blog', 'blog.apps', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'ManatalAssesment.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'ManatalAssesment.wsgi.application' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': env(&quot;DB_NAME&quot;), 'USER': env(&quot;DB_USER&quot;), 'PASSWORD': env(&quot;DB_PASSWORD&quot;), 'HOST': env(&quot;DB_HOST&quot;), 'PORT': env(&quot;DB_PORT&quot;), } } AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = False STATIC_URL = '/static/' </code></pre> <p>above is my setting.py for the main project</p> <pre><code> from django.contrib import admin from django.urls import path,include urlpatterns = [ path('admin/', admin.site.urls), path('blog/', include('blog.urls')), ] </code></pre> <p>above is my project level urls</p> <p>below is my app urls</p> <pre><code> from django.urls import path from .views import * urlpatterns = [ path('api/students', student_list), # path('api/tutorials/(?P&lt;pk&gt;[0-9]+)$', tutorial_detail), # path('api/tutorials/published$', tutorial_list_published) ] </code></pre>
[ { "answer_id": 74219642, "author": "Andrea M", "author_id": 13968222, "author_profile": "https://Stackoverflow.com/users/13968222", "pm_score": 1, "selected": true, "text": ")" }, { "answer_id": 74220098, "author": "Julian", "author_id": 14137004, "author_profile": "h...
2022/10/27
[ "https://Stackoverflow.com/questions/74219667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18394954/" ]
74,219,738
<pre><code>#include &lt;assert.h&gt; #include &lt;atomic&gt; #include &lt;iostream&gt; #include &lt;thread&gt; std::atomic_bool b(false); std::atomic_bool lock{false}; void producer() { b.store(true, std::memory_order_seq_cst); lock.store(true, std::memory_order_seq_cst); } void consume() { while (!lock.load(std::memory_order_seq_cst)) ; assert(b.load(std::memory_order_seq_cst)); b.store(false, std::memory_order_seq_cst); lock.store(false, std::memory_order_seq_cst); } int main() { std::thread t1([&amp;]() { while (true) consume(); }); std::thread t2([&amp;]() { while (true) producer(); }); t1.join(); t2.join(); } </code></pre> <p>Assert in consume should never fail, memory_order_seq_cst guarentee that atmoic operation run in the order that they are wrote;</p> <p>But assert fail happened :(</p>
[ { "answer_id": 74220390, "author": "for_stack", "author_id": 5384363, "author_profile": "https://Stackoverflow.com/users/5384363", "pm_score": 1, "selected": true, "text": "void producer() {\n b.store(true, std::memory_order_seq_cst); // 1\n lock.store(true, std::memory_order_seq_...
2022/10/27
[ "https://Stackoverflow.com/questions/74219738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20212391/" ]
74,219,758
<p>I have created a custom class</p> <pre><code>Public Class MyFSW Inherits FileSystemWatcher Public Property ParentForm As Form Public Property TabPage As TabPage End Class </code></pre> <p>Now I want to add a custom event to the this class, that fires when the property &quot;EnableRaisingEvents&quot; of the FileSystemWatcher changes?</p> <p>Is there any chance to do this?</p>
[ { "answer_id": 74220390, "author": "for_stack", "author_id": 5384363, "author_profile": "https://Stackoverflow.com/users/5384363", "pm_score": 1, "selected": true, "text": "void producer() {\n b.store(true, std::memory_order_seq_cst); // 1\n lock.store(true, std::memory_order_seq_...
2022/10/27
[ "https://Stackoverflow.com/questions/74219758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7382796/" ]
74,219,762
<p>Controller</p> <pre><code>@RequestMapping(value=&quot;/create&quot;, method=RequestMethod.POST, consumes={&quot;application/json&quot;}) public Alien addDetails(@RequestBody Alien alien){ return repo.save(alien); } </code></pre> <p>Alien.java</p> <pre><code>@Entity public class Alien{ @Id private int id; private String name; private String planet; Getter and setter </code></pre> <p>Now I want to validate the post json data before saving it to the database. If any of the field is empty then the controller should return an error. For example</p> <p><code>{&quot;id&quot;: 1, &quot;name&quot;: &quot;Alien1&quot;, &quot;planet&quot;:&quot;Mars&quot; }</code></p> <p>This is acceptable json data But if there is any field is missing such as</p> <p><code>{&quot;name&quot;: &quot;Alien1&quot;, &quot;planet&quot;:&quot;Mars&quot; }</code></p> <p>Then the controller should return an error and not creating the instance of Alien</p> <p>I tried with @Valid @NotNull still the controller creates an empty instance of Alien and save to the database.</p>
[ { "answer_id": 74219825, "author": "Aid Hadzic", "author_id": 5963060, "author_profile": "https://Stackoverflow.com/users/5963060", "pm_score": 0, "selected": false, "text": "@Validated" }, { "answer_id": 74223387, "author": "Manir Mahamat", "author_id": 11185081, "au...
2022/10/27
[ "https://Stackoverflow.com/questions/74219762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20347300/" ]
74,219,772
<p>I'd like to specify a CSS rule (using SASS/SCSS) for a specific div, located as follows,</p> <pre><code> &lt;div class=&quot;parent-div&quot;&gt; &lt;div class=&quot;first-child has-this-class&quot;&gt; ...... &lt;/div&gt; &lt;div class=&quot;second-child&quot;&gt; ..... &lt;/div&gt; </code></pre> <p>I need to write a specific CSS rule to &quot;second-child&quot;, when the first child has the class &quot;has-this-class&quot;.</p> <p>I tried to use SCSS as this, but it didn't work.</p> <pre><code> .parent-div{ .first-child{ &amp;.has-this-class + .second-child{ //Write the styles here } } } </code></pre>
[ { "answer_id": 74219988, "author": "c.m.", "author_id": 19850943, "author_profile": "https://Stackoverflow.com/users/19850943", "pm_score": 1, "selected": false, "text": " .parent-div{\n .first-child:has(.second-child){\n //Write the styles here\n }\n }\n" }, { ...
2022/10/27
[ "https://Stackoverflow.com/questions/74219772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20347328/" ]
74,219,785
<p>I am working with table data that contains strings with decimal and back-slash like below:</p> <pre><code>info 1/2.2.2 2/1.1.1 3/1.1.11 </code></pre> <p>I need to use a regular expression to replace the data like below:</p> <pre><code>info 1/2.2 2/1.1 3/1.1 </code></pre>
[ { "answer_id": 74219925, "author": "MT0", "author_id": 1509264, "author_profile": "https://Stackoverflow.com/users/1509264", "pm_score": 3, "selected": true, "text": "SELECT info,\n CASE\n WHEN INSTR(info, '.', 1, 2) > 0\n THEN SUBSTR(info, 1, INSTR(info, '.', 1, 2) - 1...
2022/10/27
[ "https://Stackoverflow.com/questions/74219785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20111229/" ]
74,219,788
<p>I pass an array of values as arguments to a function. This function divides somewhere by the values given as arguments. I want to bypass the calculation for zero-value values so that I don't have to divide by zero.</p> <pre><code>import numpy as np def test(t): e = np.where(t==0,0,10/t) return e i = np.arange(0, 5, 1) print('in: ',i) o = test(i) print('out:',o) </code></pre> <p>Output is</p> <pre><code>in: [0 1 2 3 4] out: [ 0. 10. 5. 3.33333333 2.5 ] &lt;ipython-input-50-321938d419be&gt;:4: RuntimeWarning: divide by zero encountered in true_divide e = np.where(t==0,0,10/t) </code></pre> <p>I thought np.where would be the appropriate function for this, but unfortunately I always get a runtime warning 'divide by zero'. So, it does the right thing, but the warning is annoying. I could of course suppress the warning, but I wonder if there is a cleaner solution to the problem?</p>
[ { "answer_id": 74219849, "author": "JimmyNJ", "author_id": 6016071, "author_profile": "https://Stackoverflow.com/users/6016071", "pm_score": 0, "selected": false, "text": "0.0" }, { "answer_id": 74219905, "author": "mozway", "author_id": 16343464, "author_profile": "h...
2022/10/27
[ "https://Stackoverflow.com/questions/74219788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18119746/" ]
74,219,832
<p>I want to create a persistent (global) view in spark sql that gets data from an underlying jdbc database connection. It works fine when I use a temporary (session-scoped) view as shown below but fails when trying to create a regular (persistent and global) view.</p> <p>I don't understand why the latter should not work but couldn't find any docs/hints as all examples are always done with temporary views. Technically, I cannot see why it shouldn't work as the data is properly retrieved from jdbc source in the temporary view and thus it should not matter if I wanted to &quot;store&quot; the query in a persistent view so that whenever calling the view it would retrieve data directly from jdbc source.</p> <p>Config.</p> <pre><code>tbl_in = myjdbctable tbl_out = myview db_user = 'myuser' db_pw = 'mypw' jdbc_url = 'jdbc:sqlserver://myserver.domain:1433;database=mydb' </code></pre> <p>This works.</p> <pre><code>query = f&quot;&quot;&quot; create or replace temporary view {tbl_out} using jdbc options( dbtable '{tbl_in}', user '{db_user}', password '{db_pw}', url '{jdbc_url}' ) &quot;&quot;&quot; spark.sql(query) &gt; DataFrame[] </code></pre> <p>This does not work.</p> <pre><code>query = f&quot;&quot;&quot; create or replace view {tbl_out} using jdbc options( dbtable '{tbl_in}', user '{db_user}', password '{db_pw}', url '{jdbc_url}' ) &quot;&quot;&quot; spark.sql(query) &gt; ParseException: </code></pre> <p>Error.</p> <pre><code>ParseException: mismatched input 'using' expecting {'(', 'UP_TO_DATE', 'AS', 'COMMENT', 'PARTITIONED', 'TBLPROPERTIES'}(line 3, pos 0) == SQL == create or replace view myview using jdbc ^^^ options( dbtable 'myjdbctable', user 'myuser', password '[REDACTED]', url 'jdbc:sqlserver://myserver.domain:1433;database=mydb' ) </code></pre>
[ { "answer_id": 74219849, "author": "JimmyNJ", "author_id": 6016071, "author_profile": "https://Stackoverflow.com/users/6016071", "pm_score": 0, "selected": false, "text": "0.0" }, { "answer_id": 74219905, "author": "mozway", "author_id": 16343464, "author_profile": "h...
2022/10/27
[ "https://Stackoverflow.com/questions/74219832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2519368/" ]
74,219,834
<p>Imagine a scenario in which a producer is producing 100 messages per second, and we're working on a system that consuming messages ASAP matters a lot, even 5 seconds delay might result in a decision not to take care of that message anymore. also, the order of messages does not matter.</p> <p>So I don't want to use a basic queue and a single pod listening on a single partition to consume messages, since in order to consume a message, the consumer needs to make multiple remote API calls and this might take time.</p> <p>In such a scenario, I'm thinking of a single Kafka topic, with 100 partitions. and for each partition, I'm gonna have a separate machine (pod) listening for partitions 0 to 99.</p> <p>Am I thinking right? this is my first project with Kafka. this seems a little weird to me.</p>
[ { "answer_id": 74219849, "author": "JimmyNJ", "author_id": 6016071, "author_profile": "https://Stackoverflow.com/users/6016071", "pm_score": 0, "selected": false, "text": "0.0" }, { "answer_id": 74219905, "author": "mozway", "author_id": 16343464, "author_profile": "h...
2022/10/27
[ "https://Stackoverflow.com/questions/74219834", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1329189/" ]
74,219,842
<p>I have a two column grid.</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>main { max-width: 300px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr; grid-column-gap: 6.4rem; } h3::before { content: ''; display: block; background-color: black; height: 1px; grid-column: 1 / span 2; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;main&gt; &lt;h3&gt;Heading blah&lt;/h3&gt; &lt;p&gt;Velluptiae dolupiet, im ea dolut que expercia sandionsed mo minvelibus modi occati sit autat quis ut fugitias maio. Moluptat.&lt;/p&gt; &lt;h3&gt;Heading blah&lt;/h3&gt; &lt;p&gt;Velluptiae dolupiet, im ea dolut que expercia sandionsed mo minvelibus modi occati sit autat quis ut fugitias maio. Moluptat.&lt;/p&gt; &lt;h3&gt;Heading blah&lt;/h3&gt; &lt;p&gt;Velluptiae dolupiet, im ea dolut que expercia sandionsed mo minvelibus modi occati sit autat quis ut fugitias maio. Moluptat.&lt;/p&gt; &lt;/main&gt;</code></pre> </div> </div> </p> <pre><code>main { display: grid; grid-template-columns: 1fr 1fr; grid-column-gap: 6.4rem; } </code></pre> <p>With headings in the left column and body text in the right column.</p> <p>Is it possible to have a <code>border-top</code> on my <code>H3</code> headings (that display in the left column), that span both columns? Possibly using the before:: pseudo-element? So a horizontal line appears above the headings and goes across both columns. Like trying to insert a <code>&lt;hr&gt;</code> element before every <code>H3</code> that spans both columns.</p> <p>I've got the following:</p> <pre><code>h3::before { content: &quot;&quot;; position: absolute; border-top: 1px solid; width: 100%; grid-column: 1 / -1; } </code></pre> <p>But the border-top stretches outside the width of the containing element (<code>main</code>) and touches the right hand side of the browser window. <code>Position: relative</code> doesn't seem to work.</p> <p>UPDATE</p> <p>I've tried this, but the black line only stretches across one column.</p> <pre><code>h3::before { content: ''; display: block; background-color: black; height: 1px; width: 100%; grid-column: 1 / -1; } </code></pre> <p>UPDATE 2</p> <p>I guess I need the CSS grid to treat the before:: pseudo-element as an actual element, in order for it to span more than one column? Is that possible? According to this 5 year old post pseudo-elements are treated as an element in grid. <a href="https://stackoverflow.com/questions/45599317/pseudo-element-acting-like-a-grid-item-in-css-grid">pseudo-element acting like a grid item in CSS grid</a> But that isn't the case for me.</p>
[ { "answer_id": 74219849, "author": "JimmyNJ", "author_id": 6016071, "author_profile": "https://Stackoverflow.com/users/6016071", "pm_score": 0, "selected": false, "text": "0.0" }, { "answer_id": 74219905, "author": "mozway", "author_id": 16343464, "author_profile": "h...
2022/10/27
[ "https://Stackoverflow.com/questions/74219842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2991837/" ]
74,219,850
<p>I am having problems with <code>frollapply</code> from the <code>data.table</code> package. I have a dataset with a <code>target_var</code> column that consists of lists of equal length containing either numeric entries or NAs. I want to calculate the number of unique entries in these lists in a sliding window of length 2.</p> <p>Surprisingly, the function slides through the sequence <code>NA, 1, NA, 2, NA, 3, NA, 4, NA, 5, NA, 6</code> in steps of two starting with <code>NA, 1</code>. To check this uncomment the lines in the <code>FUN</code> parameter.</p> <pre><code># Packages lapply(c(&quot;data.table&quot;,&quot;dplyr&quot;,&quot;tibble&quot;,&quot;dtplyr&quot;), library, character.only = TRUE) # Test data dummy_data &lt;- tribble( ~date, ~target_var, &quot;2022-10-20&quot;, as.double(list(NA, NA , NA)), &quot;2022-10-21&quot;, as.double(list(NA, 1 , NA)), &quot;2022-10-22&quot;, as.double(list(2, NA, 3)), &quot;2022-10-23&quot;, as.double(list(NA, 4, NA)), &quot;2022-10-24&quot;, as.double(list(5, NA, 6)) ) # Sliding window dummy_data %&gt;% lazy_dt() %&gt;% mutate(new_var = data.table::frollapply( x = target_var, n = 2, align = &quot;right&quot;, FUN = function(x){ # browser() # print(x) x %&gt;% unlist(recursive = FALSE, use.names = FALSE) %&gt;% n_distinct(na.rm = TRUE) } )) %&gt;% as_tibble() # Expected results expected_res &lt;- tribble( ~date, ~target_var, ~new_var, &quot;2022-10-20&quot;, as.double(list(NA, NA , NA)), NA, &quot;2022-10-21&quot;, as.double(list(NA, 1 , NA)), 1, &quot;2022-10-22&quot;, as.double(list(2, NA, 3)), 3, &quot;2022-10-23&quot;, as.double(list(NA, 4, NA)), 3, &quot;2022-10-24&quot;, as.double(list(5, NA, 6)), 3 ) </code></pre> <p>However, I expected the sliding window to slide through the rows of the dataset, starting with <code>NA, 1, NA, 2, NA, 3</code>, i.e. the first two lists unpacked. However, I am not sure if <code>frollapply</code> can combine the two lists within the sliding window or what happens exactly.</p> <p>Another issue is that the new variable is a list and not a single number, which is also unexpected.</p> <p>The inner <code>FUN</code> works as expected when by-passing <code>frollapply</code>.</p> <pre><code>dummy_data$target_var %&gt;% unlist(recursive = FALSE, use.names = FALSE) %&gt;% n_distinct(na.rm = TRUE) </code></pre> <p>I have thought about concatenating the entries rather than creating a list, but the string processing steps turned out to be very inefficient. Does anyone have any idea why <code>frollapply</code> doesn`t work as expected in this context or what I am missing here?</p>
[ { "answer_id": 74224760, "author": "onyambu", "author_id": 8380272, "author_profile": "https://Stackoverflow.com/users/8380272", "pm_score": 0, "selected": false, "text": "dummy_data %>%\n mutate(new_var = map_dbl(row_number()-1,\n ~target_var[.x:(.x+1)]%>%\n ...
2022/10/27
[ "https://Stackoverflow.com/questions/74219850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12984772/" ]
74,219,851
<p>hello there i want to add another one listview on the same screen, how can i do that?</p> <p>hello there i want to add another one listview on the same screen, how can i do that?</p> <p><a href="https://i.stack.imgur.com/8iNMh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8iNMh.png" alt="enter image description here" /></a></p> <p>here is my code:</p> <pre><code>return Scaffold( appBar: AppBar(title: Text('detailsPage'), ), body: ListView( children: [ Card( child: ListTile( title:new Center(child:new Text(utf8.decode(appController.userName.runes.toList()) + &quot; &quot; + utf8.decode(appController.userSurname.runes.toList()))), subtitle:new Center(child:new Text('UserID: '+appController.userid.toString())), ) ), Card( child: ListTile( title:new Center(child:new Text(months[index])), subtitle:new Center(child:new Text(&quot;This month you have done &quot;+appController.Totaleachlength[index].toString()+' charges')), ), ), Card( child: ListTile( title:new Center(child:new Text(appController.Totaleachlist[index].toStringAsFixed(3)+&quot;€&quot;)), subtitle:new Center(child:new Text(&quot;Total amount&quot;)), ) ), ElevatedButton(child: Text('Download Bill pdf'), onPressed: () =&gt; ''), ListTile( title: new Center(child: new Text('Details of your charges'),), ), ], shrinkWrap: true, ), ); </code></pre>
[ { "answer_id": 74220001, "author": "mohammad esmaili", "author_id": 14642553, "author_profile": "https://Stackoverflow.com/users/14642553", "pm_score": 2, "selected": false, "text": "Column:(\n children: [\n ListView1(),\n ListView2(),\n ]\n),\n" }, { "answer_...
2022/10/27
[ "https://Stackoverflow.com/questions/74219851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19778883/" ]
74,219,887
<p>Please excuse me if I don't format this post properly, I'm new to StackOverflow - and a bit new to scripting in Powershell..</p> <p>I'm trying to build an interface between a system that generates access codes, and another that picks it up. The generated CSV looks like this:<a href="https://i.stack.imgur.com/AnrUs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AnrUs.png" alt="sourcefile" /></a></p> <p>The generated file has the date formatted as ddMMyy, but the system that picks it up requires it in the format YYYY-MM-DD HH:MM:SS Fortunately the time should always be the same: 23:59:00</p> <p>I've attempted to break this down into changing the date first, and then I need to append the time into the field on the end.</p> <p>Using <a href="https://stackoverflow.com/questions/39397236/powershell-convert-date-format-in-a-csv">this answer</a> I managed to write the following line, which when pasted into a powershell window outputs the date just as I need it:</p> <p>PS C:\temp&gt; Import-Csv &quot;C:\temp\codes3.csv&quot; | ForEach{[datetime]::ParseExact($_.&quot;When to Cancel User&quot;,&quot;ddMMyy&quot;,$null).ToString(&quot;yyyy-MM-dd&quot;)} 2022-10-25 2022-10-25 2022-10-25 2022-10-25 2022-10-25 2022-10-25 PS C:\temp&gt;</p> <p>which is perfect - but I can't work out how to write that back to my CSV file. When I add</p> <pre><code> | Export-csv 'C:\temp\codes4.csv' -notype </code></pre> <p>to the end of the string, it doesn't actually update the dates. The saved file is exactly the same as the original. Any idea what I'm doing wrong?</p> <p>I also need to append &quot; 23:59:00&quot; to the end of the date, but I'm not sure how. Any advice you might have would be much appreciated!</p>
[ { "answer_id": 74220001, "author": "mohammad esmaili", "author_id": 14642553, "author_profile": "https://Stackoverflow.com/users/14642553", "pm_score": 2, "selected": false, "text": "Column:(\n children: [\n ListView1(),\n ListView2(),\n ]\n),\n" }, { "answer_...
2022/10/27
[ "https://Stackoverflow.com/questions/74219887", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20346992/" ]
74,219,903
<p>I have to create a conversion method that analyzes if the characters in a string are 1 and/or 0, then include that character in a conversion from binary to decimal. Then I have to use a try-catch block to prompt the user for a binary number, and convert the number within the try-catch block and print the converted number to the console. Right now, I can't seem to get the code to return the converted decimal, or the BinaryFormatException.</p> <p>This is what I have so far:</p> <pre class="lang-java prettyprint-override"><code>import java.util.Scanner; public class Tester { public static void main(String[] args) { Scanner input = new Scanner(System.in); String binaryString; int decimalNumber = 0; try { System.out.print(&quot;Please enter the binary number to convert: &quot;); binaryString = input.nextLine(); convertBinary(String.valueOf(decimalNumber)); System.out.println(&quot;Your number converted to decimal is &quot; + binaryString + &quot;.&quot;); } catch (BinaryFormatException e) { System.out.println(e.getMessage()); } } static int convertBinary(String binaryString) throws BinaryFormatException { int decimalNumber = 0; int n = 0; for (int i = 0; i &lt; binaryString.length(); i++) { if (binaryString.matches(&quot;[01]+&quot;)) { throw new BinaryFormatException(&quot;Improper formatting for character: &quot; + i + &quot;.&quot;); } else { int temp = i%10; decimalNumber += temp*Math.pow(2, i); i = i/10; i++; } } } } </code></pre>
[ { "answer_id": 74220143, "author": "刷题养家", "author_id": 17953108, "author_profile": "https://Stackoverflow.com/users/17953108", "pm_score": 1, "selected": false, "text": "static int convertBinary(String binaryString) throws BinaryFormatException {\n int decimalNumber = 0;\n ...
2022/10/27
[ "https://Stackoverflow.com/questions/74219903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20318813/" ]
74,219,906
<p>I have a macro with counter for unique values that met specific conditions. As you can see on the image, I have list of unique values in column F. Macro checks, if value is listed in column AE (can contain duplicated lines) and checks if there is no &quot;OB&quot; in column AH. Then returns how many values it found in cell K2. But I need this counter to also list these values in column AD, but I am struggling to make it happen. I checked many forums and managed to crash Excel twice already. Any ideas how to achieve it?</p> <p><a href="https://i.stack.imgur.com/O4w7D.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/O4w7D.png" alt="Example" /></a></p> <pre><code>Dim myTbl As range, mStr As String, Miss As Long, xCol As Variant Set myTbl = Sheets(&quot;OB&quot;).range(&quot;AE2&quot;) ' xCol = &quot;AH&quot; mStr = &quot;&quot; Set myTbl = range(myTbl, myTbl.End(xlDown).Offset(0, 1)) xCol = Cells(1, xCol).Column - myTbl.Cells(1, 1).Column + 1 For i = 1 To myTbl.Rows.count If myTbl.Cells(i, 1) &lt;&gt; &quot;&quot; Then If myTbl.Cells(i, xCol) &lt;&gt; &quot;OB&quot; And InStr(1, mStr, &quot;##&quot; &amp; myTbl.Cells(i, 1), vbTextCompare) = 0 Then mStr = mStr &amp; &quot;##&quot; &amp; myTbl.Cells(i, 1) Miss = Miss + 1 End If End If Next i If Miss &gt; 0 Then range(&quot;K2&quot;) = Miss &amp; &quot; still active&quot; range(&quot;K2&quot;).Font.ColorIndex = 46 Else range(&quot;K2&quot;) = &quot;None&quot; range(&quot;K2&quot;).Font.ColorIndex = 10 End If </code></pre>
[ { "answer_id": 74220075, "author": "Pᴇʜ", "author_id": 3219613, "author_profile": "https://Stackoverflow.com/users/3219613", "pm_score": 1, "selected": false, "text": "=IF(COUNTIFS(AE:AE,F2,AH:AH,\"<>OB\")>0,F2,\"\")\n" }, { "answer_id": 74220271, "author": "FaneDuru", "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74219906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20181768/" ]
74,219,932
<p>I have a table and I fill one of the columns with a trigger if it is null or empty. I want to delete the trigger and do its job in code.</p> <p>Do I have to first insert and after update or is there a better way? In .NET Framework, ORM is NHibernate</p> <pre><code>CREATE TABLE [dbo].[Table] ( [Id] INT NOT NULL PRIMARY KEY, [Col1] NVARCHAR(50) NOT NULL, [Col2] NVARCHAR(50) NOT NULL, [Code] NVARCHAR(100) NULL ); CREATE TRIGGER Update_Table ON [dbo].[Table] AFTER INSERT AS BEGIN DECLARE @id INT SELECT @id = Id FROM inserted UPDATE [dbo].[Table] SET Code = 'CODE' + Id FROM [dbo].[Table] WHERE Id = @id AND Code IS NULL END </code></pre> <p>I did this</p> <pre><code>Table entity = new Table() { Col1 = &quot;aaa&quot;, Col2 = &quot;bbb&quot; }; entity = _repo.insert(entity); entity.Code = &quot;CODE&quot; + entity.Id; _repo.Update(entity); </code></pre> <p>sometimes i do not need update. Because users send this column value.</p> <pre><code>Table entity = new Table() { Col1 = &quot;aaa&quot;, Col2 = &quot;bbb&quot;, Code = &quot;ccc&quot; }; entity = _repo.insert(entity); </code></pre> <p>I tried insert then update. It is OK. Just seeking a better way.</p>
[ { "answer_id": 74220075, "author": "Pᴇʜ", "author_id": 3219613, "author_profile": "https://Stackoverflow.com/users/3219613", "pm_score": 1, "selected": false, "text": "=IF(COUNTIFS(AE:AE,F2,AH:AH,\"<>OB\")>0,F2,\"\")\n" }, { "answer_id": 74220271, "author": "FaneDuru", "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74219932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2948750/" ]
74,219,970
<p>Help please, I have a WebView screen on which I display the site. This site adapts to the width of the mobile phone and reduces the font. Can I somehow increase the font?</p> <pre><code>body: Container( child: WebView( initialUrl: url, javascriptMode: JavascriptMode.unrestricted, ), ), </code></pre>
[ { "answer_id": 74220075, "author": "Pᴇʜ", "author_id": 3219613, "author_profile": "https://Stackoverflow.com/users/3219613", "pm_score": 1, "selected": false, "text": "=IF(COUNTIFS(AE:AE,F2,AH:AH,\"<>OB\")>0,F2,\"\")\n" }, { "answer_id": 74220271, "author": "FaneDuru", "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74219970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17006711/" ]
74,219,980
<p>I am new to flutter and trying to develop a version updation software. I need to show the version in a radio list. Is there any way to contain the list view in a container? Currently the list view is overflowing through the other widgets. I need to contain the list view between the text and the button. Is there any way to do it.The code the screenshot is given below</p> <p>[![screenshot][1]][1]</p> <pre><code> Widget _createVersionRadioTiles(List&lt;String&gt; versions) { var radioTiles = &lt;Widget&gt;[]; for (var version in versionList) { var tile = Padding( padding: const EdgeInsets.all(8.0), child: RadioListTile&lt;String&gt;( selected: selectedVersion == version, tileColor: colorDarkGray, // selectedTileColor: Colors.white, value: version, groupValue: selectedVersion, onChanged: (String? value) { setState(() { selectedVersion = value!.toString(); }); }, title: Text(version), ), ); radioTiles.add(tile); } return Column( children: [ SizedBox( height: 500, width: 500, child: ListView(children: radioTiles), ) ], ); } ``` [1]: https://i.stack.imgur.com/qQxns.jpg </code></pre>
[ { "answer_id": 74220164, "author": "amir_a14", "author_id": 10281719, "author_profile": "https://Stackoverflow.com/users/10281719", "pm_score": 0, "selected": false, "text": "SizedBox" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74219980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11201918/" ]
74,219,990
<p>I am using matplotlib for the very first time and trying to learn dataframes.</p> <p>Now , In my code I have two lists.I have created a dataframe seperately for those two lists. I intend to create a step plot using those lists.</p> <pre><code>energy_price = [33.28, 30.00, 29.15, 28.49, 34.66, 50.01, #14 sept nord pool day ahead SE1 71.52, 77.94, 81.97, 87.90, 92.76, 94.98, 92.31, 90.03, 90.09, 87.44, 85.37, 79.97, 79.92, 77.83, 76.28, 65.06, 53.07, 34.16] rtn_t0=15 price_energy = [] for price in energy_price: price_energy = price_energy + [int(price)] * int(60 / rtn_t0) #prices for 96 time slots time1 = list() for x in range(1,int(num_t + 1)): time1.append(x) df = pd.DataFrame(price_energy) df = pd.DataFrame(time1) </code></pre> <p>How do I create a step plot with time1 on x-axis &amp; price_energy on y axis?</p> <p>Any help would be appreciated.</p>
[ { "answer_id": 74220164, "author": "amir_a14", "author_id": 10281719, "author_profile": "https://Stackoverflow.com/users/10281719", "pm_score": 0, "selected": false, "text": "SizedBox" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74219990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19551188/" ]
74,219,992
<p>I am new to the Vue 3 ecosystem. I am building a search form using the composition API.</p> <p>I have a child component that contains a search form input. It emits a <code>doEmitSearch</code> event, and has a payload of the <code>searchterm</code>.</p> <p>In the parent component I receive the emitted event <code>@doEmitSearch=”doTriggerSearch”</code></p> <p>In the parent component I have</p> <pre><code>&lt;script lang=”ts” setup&gt; import {doPerformSearch} from &quot;../composables/doPerformSearch&quot; function doTriggerSearch (value){ return doPerformSearch(value) } &lt;script/&gt; </code></pre> <p>Inside the <code>doPerformSearch.ts</code> I have various functions <code>Search1(value)</code>, <code>Search2(value)</code>, <code>Search3(value)</code> etc. that do API calls for multiple API searches, and data cleaning etc, and each one returns search results as JSON, which I want to dispatch/pass/display in either in the parent component or other child-components as props.</p> <ol> <li>What syntax in the composition API can I use to display the returned <code>doPerformSearch(value)</code> in the parent component as <code>{{searchResults}}</code></li> <li>What syntax can I use to pass and display multiple search results to child components ?</li> <li>Is that a good design pattern I'm using, or is there better ways to do it ?</li> </ol> <p>Thank you</p>
[ { "answer_id": 74220164, "author": "amir_a14", "author_id": 10281719, "author_profile": "https://Stackoverflow.com/users/10281719", "pm_score": 0, "selected": false, "text": "SizedBox" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74219992", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19801945/" ]
74,219,998
<p>I need to generate prime twins in python but I can only use basics (if, elif, else, for, print. I cannot use while, def, return or break etc.</p> <p>I wrote this code but it only works under 100, If I want a range up to 1000 it doesn't work and I have no idea how to do it without putting there hundreds ifs'.</p> <p>Could you please help me?</p> <p>I tried this:</p> <pre><code>for i in range (2,100): j=i+2 primetw=True if i%2 == 0 or i%3==0 or i%5==0 or i%7==0: primetw=False if j%2 == 0 or j%3==0 or j%5==0 or j%7==0: primetw=False if i==3 or i==5 or j==5: primetw=True if primetw==True: print(i,j) </code></pre> <p>Which has this output:</p> <pre><code>3 5 5 7 11 13 17 19 29 31 41 43 59 61 71 73 </code></pre>
[ { "answer_id": 74220164, "author": "amir_a14", "author_id": 10281719, "author_profile": "https://Stackoverflow.com/users/10281719", "pm_score": 0, "selected": false, "text": "SizedBox" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74219998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20347481/" ]
74,220,056
<p>i create a form where i upload image into database where i create icon input to select the image i want to convert that icon into that picture which i select after slecting the picture.</p> <pre><code>&lt;label class=&quot;custom-file-upload&quot;&gt; &lt;input asp-for=&quot;imge1&quot; name=&quot;imge1&quot; type=&quot;file&quot; /&gt; &lt;i class=&quot;fa fa-camera&quot;&gt;&lt;/i&gt; </code></pre> <p>CSS</p> <pre><code>input[type=&quot;file&quot;] { display: none; } .custom-file-upload { border: 1px solid #ccc; display: inline-block; padding: 6px 12px; cursor: pointer; height: 80px; width: 100px; display: flex; align-items: center; justify-content: center; font-size: 30px; color: var(--primary-color); } </code></pre>
[ { "answer_id": 74220164, "author": "amir_a14", "author_id": 10281719, "author_profile": "https://Stackoverflow.com/users/10281719", "pm_score": 0, "selected": false, "text": "SizedBox" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74220056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12243242/" ]
74,220,088
<p>So my front-end Lists of Businesses are not in paginated style. But I do not know how to do it. Can anyone please help? The code I posted is in my BusinessListController.php</p> <p>BusinessListController.php</p> <pre><code>`&lt;?php namespace App\Http\Controllers; use App\Models\Business; use App\Models\Category; use App\Models\Location; use Illuminate\Http\Request; class BusinessListController extends Controller { public function index(Request $request) { $businesses = Business::query() -&gt;with('location') -&gt;whereFilters($request-&gt;only( ['search', 'category', 'location'] )) -&gt;get();d return view('pages.business-list', [ 'businesses' =&gt; $businesses, 'locations' =&gt; Location::all(), 'categories' =&gt; Category::all() ]); } }` </code></pre> <p>And then here is the code for my view blade front-end Business-List.blade.php</p> <pre><code>&lt;div class=&quot;row business-list-row mx-auto&quot;&gt; @foreach ($businesses as $business) &lt;div class=&quot;col-md-4&quot;&gt; &lt;div class=&quot;card shadow border-light mb-3&quot;&gt; &lt;img src=&quot;https://cdn1.clickthecity.com/images/articles/content/5d6eba1f4795e0.58378778.jpg&quot; class=&quot;card-img-top&quot; alt=&quot;...&quot;&gt; &lt;div class=&quot;card-body&quot;&gt; &lt;div class=&quot;d-flex justify-content-between&quot;&gt; &lt;div&gt; &lt;h4 class=&quot;card-title h6&quot; style=&quot;font-weight: bold;&quot;&gt; {{Str::limit($business-&gt;name, 20, $end='...')}} &lt;/h4&gt; &lt;div class=&quot;&quot;&gt; &lt;p class=&quot;card-text&quot;&gt; {{ $business-&gt;location?-&gt;name }} &lt;/p&gt; &lt;p class=&quot;card-text&quot; style=&quot;color: #32a852;&quot;&gt; {{ $business-&gt;category?-&gt;name}} &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;align-self-center&quot;&gt; &lt;a href=&quot;{{ route('store', $business-&gt;id) }}&quot; class=&quot;btn btn-info stretched-link&quot;&gt; Visit &lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; @endforeach &lt;/div&gt; </code></pre>
[ { "answer_id": 74220164, "author": "amir_a14", "author_id": 10281719, "author_profile": "https://Stackoverflow.com/users/10281719", "pm_score": 0, "selected": false, "text": "SizedBox" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74220088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20347559/" ]
74,220,097
<p>I have an array consisting of labels but each label has been broken down by individual characters. For example, this is the first 2 elements of the array:</p> <pre><code>array([['1', '.', ' ', 'I', 'd', 'e', 'n', 't', 'i', 'f', 'y', 'i', 'n', 'g', ',', ' ', 'A', 's', 's', 'e', 's', 's', 'i', 'n', 'g', ' ', 'a', 'n', 'd', ' ', 'I', 'm', 'p', 'r', 'o', 'v', 'i', 'n', 'g', ' ', 'C', 'a', 'r', 'e', '', ''], ['9', '.', ' ', 'N', 'o', 'n', '-', 'P', 'h', 'a', 'r', 'm', 'a', 'c', 'o', 'l', 'o', 'g', 'i', 'c', 'a', 'l', ' ', 'I', 'n', 't', 'e', 'r', 'v', 'e', 'n', 't', 'i', 'o', 'n', 's', '', '', '', '', ''], ... </code></pre> <p>I would like it to be formatted as such:</p> <pre><code>array(['1. Identifying, Assessing and Improving Care', '9. Non-Pharmacological Interventions', ... </code></pre> <p>I want to be able to <strong>iterate through a concatenate</strong> the label output so it is as shown above.</p> <p>Any help in achieving this would be much appreciated :) Many thanks!</p>
[ { "answer_id": 74220175, "author": "Talha Tayyab", "author_id": 13086128, "author_profile": "https://Stackoverflow.com/users/13086128", "pm_score": 2, "selected": false, "text": "import numpy as np\nk=np.array([['1', '.', ' ', 'I', 'd', 'e', 'n', 't', 'i', 'f', 'y', 'i', 'n',\n 'g...
2022/10/27
[ "https://Stackoverflow.com/questions/74220097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19357328/" ]
74,220,141
<p>I am trying to send an image to my express backend. I have tried adding the image directly to my post request body.</p> <pre><code>var imgValue = document.getElementById(&quot;image&quot;).value; </code></pre> <p>In my post request</p> <pre><code>body : JSON.stringify({ image:imgValue }) </code></pre> <p>Accessing the image on the backend only gives me the name of the file. Is there any way I can encode the image as a base64 string in the frontend itself?</p>
[ { "answer_id": 74220372, "author": "HendrikThurauEnterprises", "author_id": 15723164, "author_profile": "https://Stackoverflow.com/users/15723164", "pm_score": 3, "selected": true, "text": "var imgEl = document.createElement('img');\nimgEl.onload = function(){\n var canvas = document....
2022/10/27
[ "https://Stackoverflow.com/questions/74220141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13651510/" ]
74,220,153
<p>Say I have a list of lists where each sub-list is a move:</p> <pre><code>movies &lt;- list(list(&quot;Jurassic Park&quot;, &quot;Steven Spielberg&quot;, &quot;Action&quot;), list(&quot;Avatar&quot;, &quot;James Cameron&quot;, &quot;Action&quot;), list(&quot;Schindler's List&quot;, &quot;Steven Spielberg&quot;, &quot;Biography&quot;) ) </code></pre> <p>What is the best/fastest way (preferably without dependencies, but tidyverse would be fine) to subset that list based on the sub-list elements? That is, if director is always the second element in the sub-list, what's the fastest way to get a vector of the names of movies that Spielberg directed?</p> <p>Hoping to do this across very large lists many times.</p> <p>Thanks in advance!!</p>
[ { "answer_id": 74220191, "author": "Aurèle", "author_id": 6197649, "author_profile": "https://Stackoverflow.com/users/6197649", "pm_score": 1, "selected": false, "text": "library(purrr)\n\nmap_chr(movies, pluck, 2)\n#> [1] \"Steven Spielberg\" \"James Cameron\" \"Steven Spielberg\"\n"...
2022/10/27
[ "https://Stackoverflow.com/questions/74220153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10475274/" ]
74,220,181
<p>I'm studying for my first test in C# (beginner). I have a problem with assingments where I'm supposed to create a new array using loops. For example this task where the task is to write a method that recieves a sentence(string) and a letter(char). The method must then identify at which index positions the letter occurs at in the sentence and then place these positions in a array. For example, we have the short sentence &quot;Hello world!&quot; and the letter 'o' then the array should contain 4 (the index position of the first instance) and 7 (the index position of the second instance).</p> <p>I'm not allowed to use built-in methods except for .Length, Console.WriteLine..</p> <p>You can see my code below. It is not working at all. I want it to print out &quot;4, 7, &quot;</p> <pre><code>static void Main(string[] args) { int[] result = IndexesOfChar(&quot;Hello world&quot;, 'o'); for(int i = 0; i&lt;result.Length; i++) { Console.Write(result[i] + &quot;, &quot;); } } static int[] IndexesOfChar(string sentence, char letter) { int count = 0; int[] newArr = new int[count]; for(int i =0; i &lt; sentence.Length; i++) { if(sentence[i] == letter) { newArr[count] = i; count++; } } return newArr; } </code></pre>
[ { "answer_id": 74220495, "author": "AoooR", "author_id": 16233618, "author_profile": "https://Stackoverflow.com/users/16233618", "pm_score": 0, "selected": false, "text": "List" }, { "answer_id": 74221365, "author": "Dmitry Bychenko", "author_id": 2319407, "author_pro...
2022/10/27
[ "https://Stackoverflow.com/questions/74220181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20315140/" ]
74,220,190
<p>I want to create a barchart that shows how often (in percentage) each 'type' of a categorical variable appears in the dataset. I want the bars to be ordered in descending order.</p> <p>Using this reproducible example:</p> <pre><code>data &lt;- chickwts %&gt;% group_by(feed) ggplot(data = data, ) + geom_bar(aes(x = feed, y = stat(count))) </code></pre> <p>Now I would like the bars to be ordered in descending (or ascending) order, i.e., 'soybean' should be shown on the left, followed by 'casein', 'linseed' and 'sunflower', and 'horsebean' should be on the right.</p> <p><a href="https://i.stack.imgur.com/1AbcZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1AbcZ.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74220495, "author": "AoooR", "author_id": 16233618, "author_profile": "https://Stackoverflow.com/users/16233618", "pm_score": 0, "selected": false, "text": "List" }, { "answer_id": 74221365, "author": "Dmitry Bychenko", "author_id": 2319407, "author_pro...
2022/10/27
[ "https://Stackoverflow.com/questions/74220190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20377569/" ]
74,220,230
<p>In PostgreSQL using jsonb column, is there a way to select / convert an attribute with actual datatype the datatype instead of getting it as a string object when using jsonpath? I would like to try to avoid cast as well as -&gt; and -&gt;&gt; type of construct since I have to select many attributes with very deep paths, I am trying to do it using jsonpath and * or ** in the path</p> <p>Is it possible to do it this way or must I use the -&gt; and -&gt;&gt; for each node in the path ? This will make the query look complicated as I have to select about 35+ attributes in the select with quite deep paths.</p> <p>Also, how do we remove quotes from the selected value?</p> <p>This is what I was trying, but doesn't work to remove quotes from Text value and gives an error on numeric</p> <pre><code>Select PolicyNumber AS &quot;POLICYNUMBER&quot;, jsonb_path_query(payload, '$.**.ProdModelID')::text AS &quot;PRODMODELID&quot;, jsonb_path_query(payload, '$.**.CashOnHand')::float AS &quot;CASHONHAND&quot; from policy_json_table </code></pre> <p>the PRODMODELID still shows the quotes around the value and when I add ::float to second column, it gives an error</p> <pre><code>SQL Error [22023]: ERROR: cannot cast jsonb string to type double precision </code></pre> <p>Thank you</p>
[ { "answer_id": 74248204, "author": "Ramin Faracov", "author_id": 17296084, "author_profile": "https://Stackoverflow.com/users/17296084", "pm_score": -1, "selected": false, "text": "jsonb_path_query" }, { "answer_id": 74267394, "author": "Bergi", "author_id": 1048572, ...
2022/10/27
[ "https://Stackoverflow.com/questions/74220230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/913749/" ]
74,220,239
<p>UPDATE: OMG I'm using setTimeOut. But I still need an answer.</p> <p>I made an application that accesses an array and outputs each of its elements after a certain period of time. When the array ends, execution stops.</p> <p>There is a need to pause the execution. How can I do that?</p> <pre><code> const [isPaused, setIsPaused] = useState(false); const togglePause = () =&gt; { setIsPaused(!isPaused) } const soccData = data.player_positions; // cutting only IDs and positions from data const [playerPosition, setPlayerPosition] = useState([]); // creating local state to work with IDs and positions const getPlayerData = (arr) =&gt; { // function goes thru array of players and sets a new playerPosition on every step for (let i = 0; i &lt; arr.length; i++) { setTimeout(() =&gt; { setPlayerPosition(arr[i]) }, data.interval * (i + 1)); } } useEffect(() =&gt; { getPlayerData(soccData) return () =&gt; { clearTimeout() }; }, [soccData]); return ( &lt;div&gt;{playerPosition}&lt;/div&gt; &lt;p&gt;&lt;button onClick={togglePause}&gt;&lt;/button&gt;&lt;/p&gt; ) </code></pre> <p>I tried adding a condition if(!isPaused) to the function getPlayerData (and a dependency to useSeffect), but that didn't work.</p> <p>Here's my code on codesandbox: <a href="https://codesandbox.io/s/youthful-paper-pvrq09" rel="nofollow noreferrer">https://codesandbox.io/s/youthful-paper-pvrq09</a></p> <p>p.s. I found someone's code that allows to start/pause the execution: <a href="https://jsfiddle.net/thesyncoder/12q8r3ex/1/" rel="nofollow noreferrer">https://jsfiddle.net/thesyncoder/12q8r3ex/1/</a>, but there's no ability to stop the execution when array ends.</p>
[ { "answer_id": 74248204, "author": "Ramin Faracov", "author_id": 17296084, "author_profile": "https://Stackoverflow.com/users/17296084", "pm_score": -1, "selected": false, "text": "jsonb_path_query" }, { "answer_id": 74267394, "author": "Bergi", "author_id": 1048572, ...
2022/10/27
[ "https://Stackoverflow.com/questions/74220239", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20073534/" ]
74,220,267
<p>I have a textbox where user inputs values, each one in a new row, now i want to check if those input values are unique, but looks like it does not work if duplicated value is a last value, don't know why. Any tips? Lets say it is:</p> <pre><code>1 2 3 3 </code></pre> <p>It will not work, but</p> <pre><code>1 2 3 3 5 </code></pre> <p>Will work and show an error as duplicate</p> <p>Here is a code i use: First I split textbox into array of strings</p> <pre><code> string[] linesValues = textBoxValues.Text.Split(new Char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); </code></pre> <p>then check for duplicates and show error</p> <pre><code>if (linesValues.Distinct().Count() != linesValues.Count()) { MessageBox.Show(&quot;Question values must be unique!&quot;, &quot;Duplicated values found&quot;, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } </code></pre>
[ { "answer_id": 74248204, "author": "Ramin Faracov", "author_id": 17296084, "author_profile": "https://Stackoverflow.com/users/17296084", "pm_score": -1, "selected": false, "text": "jsonb_path_query" }, { "answer_id": 74267394, "author": "Bergi", "author_id": 1048572, ...
2022/10/27
[ "https://Stackoverflow.com/questions/74220267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4523229/" ]
74,220,286
<p>I would like to know, how I can loop through a list when a <code>KeyError</code> occurs in python. The code is just representatively. In my real problem I want to loop through api keys (when the KeyError occurs use the next api key and do the request again). Imagine I have a list called <code>keys</code> but in my dict only the 3rd to 5th key works. I can easy jump to 2nd key if the first one doesn't work with my <code>try-except-statement</code> but how I can jump to the 3rd key if the 2nd doesn't work either?</p> <p>I guess need something like a while loop, that loops until the <code>KeyError</code> occurs...</p> <pre><code>keys = ['key1','key2','key3','key4','key5'] keys_iter = iter(keys) dict = { &quot;key3&quot;: &quot;3&quot;, &quot;key4&quot;: &quot;4&quot;, &quot;key5&quot;: &quot;5&quot; } try: print(dict[next(keys_iter)]) except KeyError: print(dict[next(keys_iter)]) </code></pre> <p>Thankful for any help.</p> <p>Aaron</p>
[ { "answer_id": 74248204, "author": "Ramin Faracov", "author_id": 17296084, "author_profile": "https://Stackoverflow.com/users/17296084", "pm_score": -1, "selected": false, "text": "jsonb_path_query" }, { "answer_id": 74267394, "author": "Bergi", "author_id": 1048572, ...
2022/10/27
[ "https://Stackoverflow.com/questions/74220286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19931019/" ]
74,220,298
<p>I'm trying to make pagination after sorting in my Laravel project , so I did this method, it sorts my data but when I want to see next paginate table it shows me this error</p> <pre><code>SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'order clause' SELECT * FROM `customers` ORDER BY `` DESC limit 3 OFFSET 3 </code></pre> <p><strong>My method</strong></p> <pre><code> public function Sortfilter(Request $request) { $active = Customer::where('active','=','1')-&gt;count(); $inactive = Customer::where('active','=','0')-&gt;count(); $customer = Customer::query(); $customer = Customer::orderBy($request-&gt;filter,'desc')-&gt;paginate(3); return view('customers.index', compact('customer','inactive','active')); } </code></pre> <p>is there a method to save the $request-&gt;filter data when I click on next button</p> <p><strong>EDIT</strong></p> <p>when i sort my data the URL change like that : <code>http://127.0.0.1:8000/sortCustomer?filter=phone&amp;_token=9xw0q9MKa5ABZc4CwkLaPqf5ko4BhJ4ZaEk0VKYY</code></p> <p>and when i click to the pagination button the URL be like that :</p> <pre><code>http://127.0.0.1:8000/sortCustomer?page=2 </code></pre>
[ { "answer_id": 74220514, "author": "Lucky Person", "author_id": 20147460, "author_profile": "https://Stackoverflow.com/users/20147460", "pm_score": 1, "selected": false, "text": "$request->filter" }, { "answer_id": 74220682, "author": "tobifasc", "author_id": 2633917, ...
2022/10/27
[ "https://Stackoverflow.com/questions/74220298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16129220/" ]
74,220,313
<p>I'm using a MacBook M1 chip with a macOS Ventura 13.0, working on the flutter app.</p> <p>I'm getting this error while I run this command. sudo arch -x86_64 gem install ffi. <a href="https://i.stack.imgur.com/0KPxk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0KPxk.jpg" alt="enter image description here" /></a> Can anyone help me, how to fix this?</p>
[ { "answer_id": 74220514, "author": "Lucky Person", "author_id": 20147460, "author_profile": "https://Stackoverflow.com/users/20147460", "pm_score": 1, "selected": false, "text": "$request->filter" }, { "answer_id": 74220682, "author": "tobifasc", "author_id": 2633917, ...
2022/10/27
[ "https://Stackoverflow.com/questions/74220313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10351599/" ]
74,220,341
<p>I want to make a function to delete some values from an interval given by two keys from a list of key value pairs in <strong>Python</strong>.</p> <p>I've tried a lot of things, I already googled it a lot. This is the list of key value pair:</p> <pre><code>[{&quot;day&quot;: 1, &quot;sum&quot;: 25, &quot;type&quot;: in}, {&quot;day&quot;: 2, &quot;sum&quot;: 55, &quot;type&quot;: in}, {&quot;day&quot;: 3, &quot;sum&quot;: 154, &quot;type&quot;: out}, {&quot;day&quot;: 4, &quot;sum&quot;: 99, &quot;type&quot;: in}] </code></pre> <p>I want to delete the values that have <code>&quot;day&quot;</code> value between <code>1 and 3</code>. Here's my UI code for this function. I just need to make the <strong><code>delete_transaction_interval(all_transactions, dayStart, dayEnd)</code></strong> working.</p> <pre><code>all_transactions = [{&quot;day&quot;: 1, &quot;sum&quot;: 25, &quot;type&quot;: in}, {&quot;day&quot;: 2, &quot;sum&quot;: 55, &quot;type&quot;: in}, {&quot;day&quot;: 3, &quot;sum&quot;: 154, &quot;type&quot;: out}, {&quot;day&quot;: 4, &quot;sum&quot;: 99, &quot;type&quot;: in}] def delete_transaction_interval(all_transactions,dayStart,dayEnd): for i in range(0,len(all_transactions)): if all_transactions[i][&quot;day&quot;]==dayStart: for j in range(i+1, len(all_transactions)): if all_transactions[j][&quot;day&quot;]==dayEnd: del all_transactions[i:j] def ui_delete_transaction_interval(all_transactions): dayStart=int(input(&quot;Start day= &quot;)) dayEnd=int(input(&quot;End day= &quot;)) delete_transaction_interval(all_transactions, dayStart, dayEnd) ui_delete_transaction_interval(all_transactions) print(all_transactions) </code></pre>
[ { "answer_id": 74220559, "author": "amanb", "author_id": 8212173, "author_profile": "https://Stackoverflow.com/users/8212173", "pm_score": 0, "selected": false, "text": "d1 = [{\"day\": 1, \"sum\": 25, \"type\": \"in\"}, {\"day\": 2, \"sum\": 55, \"type\": \"in\"}, {\"day\": 3, \"sum\": ...
2022/10/27
[ "https://Stackoverflow.com/questions/74220341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18164390/" ]
74,220,346
<p>I have a Django project. I use nginx + gunicorn. The views.py file has a combined_data() function that creates and returns an HTML page. As you can see, I am passing the objects in 'rows' and the current date in 'time'.</p> <p><a href="https://i.stack.imgur.com/7HdwD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7HdwD.png" alt="enter image description here" /></a></p> <p>A function that returns objects looks like this</p> <p><a href="https://i.stack.imgur.com/WHHny.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WHHny.png" alt="enter image description here" /></a></p> <p>The problem is that in this function, reporting_date always gets the value it got the first time it was called. For example, I do &quot;sudo systemctl restart gunicorn&quot; and open this page in the browser. reporting_date will be equal to today. If I open the page tomorrow, reporting_date will not change its value.</p> <p>Initially, I assumed that datetime.date.today () does not work correctly, so I added the 'time' parameter to views.py (first screen), but the date is always correct there. Then I thought that the default value of the parameters of the get_combined() function (second screen) is somehow cached, so I added the r_int parameter, which receives a random value, but everything works correctly here. r_int always gets a new value.</p> <p>Now, I have to call &quot;sudo systemctl restart gunicorn&quot; every day to make the page work properly ((</p> <p>Any ideas how to fix this problem? Thanks</p>
[ { "answer_id": 74220451, "author": "KillerRebooted", "author_id": 18554284, "author_profile": "https://Stackoverflow.com/users/18554284", "pm_score": 2, "selected": true, "text": "def get_combined(reported_date=datetime.datetime.today()):\n" }, { "answer_id": 74220701, "autho...
2022/10/27
[ "https://Stackoverflow.com/questions/74220346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9333098/" ]
74,220,370
<p>I have a data frame column name &quot;New&quot; below</p> <pre><code>df = pd.DataFrame({'New' : ['emerald shines bright(happy)(ABCED ID - 1234556)', 'honey in the bread(ABCED ID - 123467890)','http/ABCED/id/234555', 'healing strenght(AxYBD ID -1234556)', 'this is just a text'], 'UI': ['AOT', 'BOT', 'LOV', 'HAP', 'NON']}) </code></pre> <p>Now I want to extract the various IDs for example ABCED', AxYBD, and id in the 'http' into another column.</p> <p>But when I used</p> <pre><code>df['New_col'] = df['New'].str.extract(r'.*\((.*)\).*',expand=True) </code></pre> <p>I can't get it to work well as the whole parenthesis for instance <code>(ABCED ID - 1234556)</code> is returned. More so, the http id <code>234555</code> is not returned.</p> <p>Also, can someone clean the first column to removed the ID in paranthesis and have something like,</p> <pre><code> New UI New_col 0 emerald shines bright(happy) AOT 1234556 1 honey in the bread BOT 123467890 2 http/ABCED/id/234555 LOV 234555 3 healing strenght HAP 1234556 4 this is just a text NON </code></pre>
[ { "answer_id": 74220605, "author": "Evgeniy Yaskov", "author_id": 19232522, "author_profile": "https://Stackoverflow.com/users/19232522", "pm_score": -1, "selected": false, "text": "r'[i,d,I,D]{2}.*?(\\d.*?)\\D'" }, { "answer_id": 74220853, "author": "ScottC", "author_id"...
2022/10/27
[ "https://Stackoverflow.com/questions/74220370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17874691/" ]
74,220,373
<p>I have been working on this SQL Server query:</p> <pre><code>SELECT ISNULL(x.Id, 0) Id, ISNULL(x.Code, 'DEFAULT') Code, ISNULL(x.Name, 'DEFAULT') Name FROM UserApplicationAccess ua JOIN MasterApplication ma ON ua.ApplicationID = ma.Id LEFT JOIN (SELECT a.Id, a.Code, a.Name, m.Id AppId, u.UserCode FROM ApplicationRole a JOIN MasterApplication m ON a.ApplicationId = m.Id JOIN UserRole u ON a.Id = u.RoleId) x ON x.UserCode = ua.Usercode AND x.AppId = ua.ApplicationID </code></pre> <p>How to convert this to linq?</p> <p>Here's what I have already tried:</p> <pre><code>var application = context.MasterApplication .Where(w =&gt; w.IsActive) .AsNoTracking(); var access = context.UserApplicationAccess .Where(w =&gt; w.Usercode == usercode) .AsNoTracking(); var roles = context.ApplicationRole.AsNoTracking(); var userRole = context.UserRole .Where(w =&gt; w.UserCode == usercode) .AsNoTracking(); List&lt;ApplicationRoleDTO2&gt; UserRoles = new List&lt;ApplicationRoleDTO2&gt;(); UserRoles = (from a in access join b in application on a.ApplicationID equals b.Id into UserApplication from ua in UserApplication.Where(from ar in roles join ma in application on ar.ApplicationId equals ma.Id join ur in userRole on ar.Id equals ur.RoleId) ).ToList(); </code></pre> <p>I've done some research but got stuck by how left join with subquery work in linq, of course I can make function/stored procedure and then call it from code, but I want to know how to implement this scenario in linq.</p> <p>Any help, advice or suggestion would be really appreciated</p>
[ { "answer_id": 74220605, "author": "Evgeniy Yaskov", "author_id": 19232522, "author_profile": "https://Stackoverflow.com/users/19232522", "pm_score": -1, "selected": false, "text": "r'[i,d,I,D]{2}.*?(\\d.*?)\\D'" }, { "answer_id": 74220853, "author": "ScottC", "author_id"...
2022/10/27
[ "https://Stackoverflow.com/questions/74220373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9666861/" ]
74,220,427
<p>OS:Ubuntu 20.04LTS Windows10 dual boot</p> <p>Error with nvidia-smi command after apt installation of nvidia driver.</p> <pre><code>$ nvidia-smi Unable to determine the device handle for GPU 0000:0B:00.0: Not Found </code></pre> <pre><code>$ dmesg |grep NVRM [ 3.065144] NVRM: loading NVIDIA UNIX Open Kernel Module for x86_64 520.56.06 Release Build (dvs-builder@U16-T12-10-2) Thu Oct 6 21:33:54 UTC 2022 [ 5.299612] NVRM: Open nvidia.ko is only ready for use on Data Center GPUs. [ 5.299614] NVRM: To force use of Open nvidia.ko on other GPUs, see the [ 5.299615] NVRM: 'OpenRmEnableUnsupportedGpus' kernel module parameter described [ 5.299616] NVRM: in the README. [ 5.692026] NVRM: GPU 0000:0b:00.0: RmInitAdapter failed! (0x63:0x0:1900) [ 5.692585] NVRM: GPU 0000:0b:00.0: rm_init_adapter failed, device minor number 0 [ 19.458670] NVRM: GPU 0000:0b:00.0: RmInitAdapter failed! (0x63:0x0:1900) [ 19.459831] NVRM: GPU 0000:0b:00.0: rm_init_adapter failed, device minor number 0 ... </code></pre> <pre><code>$ dpkg -l | grep nvidia-driver ii nvidia-driver-520-open 520.56.06-0ubuntu0.20.04.1 amd64 NVIDIA driver (open kernel) metapackage </code></pre> <p>I have tried reboot, secure boot and driver reinstallation.</p>
[ { "answer_id": 74402482, "author": "Martino", "author_id": 4080129, "author_profile": "https://Stackoverflow.com/users/4080129", "pm_score": 3, "selected": true, "text": "open" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74220427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19415172/" ]
74,220,447
<p>I have used github API for fetching data like pull requests or commits on a pull request by using the personal access token. But now I'm using Github app and have installed it on the repo for which I want to fetch all prs and commits on a pr.</p> <p>I can see endpoints github apps are allowed to make requests here - <a href="https://docs.github.com/en/rest/overview/endpoints-available-for-github-apps" rel="nofollow noreferrer">https://docs.github.com/en/rest/overview/endpoints-available-for-github-apps</a></p> <p>Is there a way to do this with Github apps without using personal access token?</p>
[ { "answer_id": 74402482, "author": "Martino", "author_id": 4080129, "author_profile": "https://Stackoverflow.com/users/4080129", "pm_score": 3, "selected": true, "text": "open" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74220447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13828167/" ]
74,220,453
<p>I have some data to store in MySQL. The data is guaranteed to be less than 1024 characters but would not be guaranteed to be less than 255 characters.</p> <p>There are two solutions. (1) Use a text column to store the text (2) Use 4 varchar columns to store the text, broken into 4 parts</p> <p>What are the advantages and disadvantages of these two options?</p> <p>I understand that text column would have extra disk-read time. But reading 4 columns, I am not sure would it be faster than the disk read. Also I am not sure about actual storage size comparison on average.</p>
[ { "answer_id": 74240869, "author": "Rick James", "author_id": 1766831, "author_profile": "https://Stackoverflow.com/users/1766831", "pm_score": 1, "selected": false, "text": "TEXT" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74220453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4630773/" ]
74,220,482
<p>I have a flutter app which take an OTP.My issue is i have my button disable by default and want it enable when the user start inputing the otp code.</p> <p>i added a value listiner to the firts otp field to be enable the button when the user starts typing the otp,but the button is <strong>disable</strong> when you finish inputing the code.i want the button to be <strong>enable</strong> when the otp field are filled.</p> <p>`</p> <pre><code>// main.dart import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'KindaCode', theme: ThemeData( primarySwatch: Colors.indigo, ), home: const HomePage(), ); } } class HomePage extends StatefulWidget { const HomePage({Key? key}) : super(key: key); @override State&lt;HomePage&gt; createState() =&gt; _HomePageState(); } class _HomePageState extends State&lt;HomePage&gt; { // 4 text editing controllers that associate with the 4 input fields final TextEditingController _fieldOne = TextEditingController(); final TextEditingController _fieldTwo = TextEditingController(); final TextEditingController _fieldThree = TextEditingController(); final TextEditingController _fieldFour = TextEditingController(); // This is the entered code // It will be displayed in a Text widget String? _otp; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('KindaCode'), ), body: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const Text('Phone Number Verification'), const SizedBox( height: 30, ), // Implement 4 input fields Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ OtpInput(_fieldOne, true), // auto focus OtpInput(_fieldTwo, false), OtpInput(_fieldThree, false), OtpInput(_fieldFour, false) ], ), const SizedBox( height: 30, ), ElevatedButton( onPressed: () { setState(() { _otp = _fieldOne.text + _fieldTwo.text + _fieldThree.text + _fieldFour.text; }); }, child: const Text('Submit')), const SizedBox( height: 30, ), // Display the entered OTP code Text( _otp ?? 'Please enter OTP', style: const TextStyle(fontSize: 30), ) ], ), ); } } // Create an input widget that takes only one digit class OtpInput extends StatelessWidget { final TextEditingController controller; final bool autoFocus; const OtpInput(this.controller, this.autoFocus, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { return SizedBox( height: 60, width: 50, child: TextField( autofocus: autoFocus, textAlign: TextAlign.center, keyboardType: TextInputType.number, controller: controller, maxLength: 1, cursorColor: Theme.of(context).primaryColor, decoration: const InputDecoration( border: OutlineInputBorder(), counterText: '', hintStyle: TextStyle(color: Colors.black, fontSize: 20.0)), onChanged: (value) { if (value.length == 1) { FocusScope.of(context).nextFocus(); } }, ), ); } } </code></pre> <p>`</p>
[ { "answer_id": 74240869, "author": "Rick James", "author_id": 1766831, "author_profile": "https://Stackoverflow.com/users/1766831", "pm_score": 1, "selected": false, "text": "TEXT" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74220482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6143170/" ]
74,220,511
<p>I have this component:</p> <pre><code> interface TestI = { id: string; } const Test = ({children, id}: React.PropsWithChildren&lt;TestI&gt;) =&gt; { return &lt;div id={id}&gt;{children}&lt;/div&gt; } </code></pre> <p>Usage of the component:</p> <pre><code>&lt;Test id={'hi'}&gt;&lt;/Test&gt; </code></pre> <p>I expect to get a warning from TS that i did not use <code>children</code> for <code>Test</code> component. <br> <strong>Question</strong>: How to make children required?</p>
[ { "answer_id": 74240869, "author": "Rick James", "author_id": 1766831, "author_profile": "https://Stackoverflow.com/users/1766831", "pm_score": 1, "selected": false, "text": "TEXT" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74220511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12540500/" ]
74,220,512
<p>I am doing a LogIn page in flutter and I don't know how to put a image to cover the full screen as a background. My problem is that nothing appears.</p> <p><a href="https://i.stack.imgur.com/oOo1w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oOo1w.png" alt="the login screen" /></a></p> <p>And this is my code:</p> <pre><code>class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Astronomy Picture of the Day', theme: ThemeData( primarySwatch: Colors.blue, ********//Here I put the transparent color************** backgroundColor: Color.fromRGBO(24,233, 111, 0.6), ), // home: const MyHomePage(title: 'Flutter Demo Home Page'), home: const LoginPage(), ); } } class LoginPage extends StatelessWidget { const LoginPage({super.key}); @override Widget build(BuildContext context) { return Scaffold( body: Center( ********** //here is where I put the Box Decoration************************** child:Container( decoration: const BoxDecoration( image: DecorationImage( image: AssetImage(&quot;images/image.jpg&quot;), fit: BoxFit.cover, ), ), child: SizedBox( width: 400, child: Form( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: &lt;Widget&gt;[ TextFormField( decoration: const InputDecoration( hintText: 'Username', )), TextFormField( decoration: const InputDecoration( hintText: 'Password', )), Padding( padding: const EdgeInsets.symmetric(vertical: 16.0), child: ElevatedButton( child: const Text(&quot;Login&quot;), onPressed: () {})) ])))),)); } } </code></pre> <pre><code>The most relevant zones are marked with '*'. </code></pre> <p>I try to put the Box Decoration on the top of the Center().</p> <p>I expect to see the image as a background.</p>
[ { "answer_id": 74240869, "author": "Rick James", "author_id": 1766831, "author_profile": "https://Stackoverflow.com/users/1766831", "pm_score": 1, "selected": false, "text": "TEXT" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74220512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20347110/" ]
74,220,517
<p>I have a parent entity with some children entities. When saving a new parent entity and its children entities, Spring is able to call <code>persist</code> and I could see there are only some INSERT statements generated.</p> <p>Problem is when I add some new children entities to an existing parent entity and save it, Spring calls <code>merge</code> instead and what I found was there were some SELECT statements generated for those new children entities before their INSERT statements.</p> <p>How to avoid these extra SELECT statements?</p> <p>e.g.</p> <pre><code>@Entity public class MyParent { ... @OneToMany(fetch = FetchType.LAZY, mappedBy = &quot;myParent&quot;, cascade = CascadeType.ALL) private Set&lt;MyChild&gt; children; } @Entity public class MyChild { ... } </code></pre> <p>and</p> <pre><code>MyParent myParent = buildNewParentAndChildren(); myParentRepository.save(myParent); // deep down calls persist(), generates INSERT only </code></pre> <p>but</p> <pre><code>MyParent myParent = myParentRepository.findById(1); MyChild myChild = buildNewChild(); myParent.getMyChildren().add(myChild); myParentRepository.save(myParent); // deep down calls merge(), generates SELECT and INSERT </code></pre>
[ { "answer_id": 74240869, "author": "Rick James", "author_id": 1766831, "author_profile": "https://Stackoverflow.com/users/1766831", "pm_score": 1, "selected": false, "text": "TEXT" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74220517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1589188/" ]
74,220,534
<p>Imagine that you have 2 mixin classes, that each define abstract methods and implementations. Together they implement every method, but depending on the inheritance order, the empty stubs will overwrite the implementation from the other class. There's at least two ways to overcome this in most situations but I don't really like either.</p> <ol> <li>One could remove the abstract methods and just rely on duck typing, but then there is no clear interface definition and type hinting.</li> <li>One could try to break down the classes into smaller ones to get a straight line of dependency and force a specific inheritance order, but that's not always practical.</li> </ol> <p>Is there a way to, for example, mark a method <em>virtual</em>, which prevents it from actually being added to the class, or at least prevents it from overriding an existing method of the same name?</p> <p>Is there another solution I didn't think of?</p> <p>Simple example:</p> <pre><code>class MixinA: def high_level(self): self.mid_level() def low_level(self): ... def mid_level(self): raise NotImplementedError class MixinB: def mid_level(self): self.low_level() def low_level(self): raise NotImplementedError class ChildA(MixinA, MixinB): pass class ChildB(MixinB, MixinA): pass for cls in (ChildA, ChildB): try: cls().high_level() print(&quot;success&quot;) except NotImplementedError: print(&quot;error&quot;) </code></pre>
[ { "answer_id": 74240869, "author": "Rick James", "author_id": 1766831, "author_profile": "https://Stackoverflow.com/users/1766831", "pm_score": 1, "selected": false, "text": "TEXT" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74220534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4417974/" ]
74,220,554
<p>Still a bit new to R and would appreciate some guidance. I have produced a relatedness matrix but before I melt it to create my edge list, I want to set all the values in each row to 0 EXCEPT for the row maximum. Any tips on how to do this?</p> <p>I have no idea what to try.</p>
[ { "answer_id": 74220648, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 1, "selected": false, "text": "apply" }, { "answer_id": 74222351, "author": "jblood94", "author_id": 9463489, "author_profile": ...
2022/10/27
[ "https://Stackoverflow.com/questions/74220554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20347832/" ]
74,220,579
<p>I have the following code in a tiny web page:</p> <pre><code>&lt;svg width='200' height='200'&gt; &lt;svg x=0 y=0&gt; &lt;circle cx=50 cy=50 r=40 stroke='#808080' stroke-width=3 fill='#FF0000'/&gt; &lt;circle cx=150 cy=50 r=40 stroke='#808080' stroke-width=3 fill='#00FF00'/&gt; &lt;circle cx=50 cy=150 r=40 stroke='#808080' stroke-width=3 fill='#0000FF'/&gt; &lt;circle cx=150 cy=150 r=40 stroke='#808080' stroke-width=3 fill='#FFFF00'/&gt; &lt;/svg&gt; &lt;svg id='CtrBtn' x=0 y=0&gt; &lt;circle cx=100 cy=100 r=20 stroke='#808080' stroke-width=3 fill='#000000'/&gt; &lt;/svg&gt; &lt;/svg&gt; &lt;div id='status'&gt;STATUS&lt;/div&gt; &lt;script type='text/javascript'&gt; window.onload = btnHandler function btnHandler() { let divCtrBtn = document.getElementById('CtrBtn') divCtrBtn.onclick = function() { document.getElementById('status').innerHTML = 'Center-Button-Hit' } } &lt;/script&gt; </code></pre> <p>It works as I expect showing this for start:</p> <p><a href="https://i.stack.imgur.com/9zlwf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9zlwf.png" alt="enter image description here" /></a></p> <p>And then this once I click the black button in the middle:</p> <p><a href="https://i.stack.imgur.com/XHC2i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XHC2i.png" alt="enter image description here" /></a></p> <p>But this is what I want instead when clicking the button:</p> <p>The red disk should change color to become cyan (<em>#00FFFF</em>) and the green should change color to become magenta (<em>#FF00FF</em>).</p> <p>How should I change the code of the <em>function btnHandler()</em> to get this result ?</p>
[ { "answer_id": 74220722, "author": "Harrison", "author_id": 15291770, "author_profile": "https://Stackoverflow.com/users/15291770", "pm_score": 3, "selected": true, "text": "fill" }, { "answer_id": 74221679, "author": "David Thomas", "author_id": 82548, "author_profil...
2022/10/27
[ "https://Stackoverflow.com/questions/74220579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/611201/" ]
74,220,651
<pre><code>const containerEl = document.querySelector (&quot;.container&quot;) for (let index = 0; index &lt; 30; index++) { const colorContainerEl =document.createElement(&quot;div&quot;) colorContainerEl.classList.add(&quot;color-container&quot;); containerEl.appendChild(&quot;colorContainerEl&quot;); } </code></pre> <pre><code>const containerEl = document.querySelector (&quot;.container&quot;) for (let index = 0; index &lt; 30; index++) { const colorContainerEl =document.createElement(&quot;div&quot;) colorContainerEl.classList.add(&quot;color-container&quot;); containerEl.appendChild(&quot;colorContainerEl&quot;); } </code></pre> <p>don't know what is wrong with this .it Shows mew this error messagese</p> <p>Uncaught TypeError: Node.appendChild: Argument 1 is not an object.</p>
[ { "answer_id": 74221511, "author": "Nishanth", "author_id": 5225976, "author_profile": "https://Stackoverflow.com/users/5225976", "pm_score": 1, "selected": true, "text": "colorContainerEl" }, { "answer_id": 74221869, "author": "Fishbite", "author_id": 11815954, "auth...
2022/10/27
[ "https://Stackoverflow.com/questions/74220651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20329127/" ]
74,220,684
<p><em>Guys sorry for my English it's my second language</em>.</p> <p>So There's a string with the following text:</p> <pre><code>**Lorem** ipsum dolor sit, amet consectetur adipisicing elit. </code></pre> <p>How to replace &quot;**&quot; characters with <code>&lt;b&gt;</code> and <code>&lt;/b&gt;</code> tags or <code>&lt;div&gt;</code> and <code>&lt;/div&gt;</code> tags with React native, so i can <strong>output</strong> it like this:</p> <pre><code>&lt;b&gt;Lorem&lt;/b&gt; ipsum dolor sit, amet consectetur adipisicing elit. </code></pre> <p>I tried to start bold text with <code>**</code> and end with <code>/*</code>, and then replace <code>**</code> with <code>&lt;b&gt;</code> and <code>/*</code> with <code>&lt;/b&gt;</code> using replace method:</p> <p><code>str.replace(&quot;/*&quot;, &quot;&lt;/b&gt;&quot;).replace(&quot;**&quot;, &quot;&lt;b&gt;&quot;)</code></p> <p>but i got only string like this:</p> <p><code>&lt;b&gt;Lorem&lt;/b&gt; ipsum dolor sit, amet consectetur adipisicing elit.</code>.</p> <p>It's problematic because I'm using React native, which outputs only like string. It'd work in PHP.</p> <p>Previously thanks!</p>
[ { "answer_id": 74221170, "author": "Dmitriy Zhiganov", "author_id": 13730174, "author_profile": "https://Stackoverflow.com/users/13730174", "pm_score": 1, "selected": false, "text": "<WebView\n originWhitelist={['*']}\n source={{ html: '<b>Lorem</b> ipsum dolor sit, amet consectetur ad...
2022/10/27
[ "https://Stackoverflow.com/questions/74220684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19840456/" ]
74,220,707
<p>I have this code, which basically does a loop inside the DF command to see which disks are more than 90% full.</p> <pre class="lang-bash prettyprint-override"><code>df -H | sed 1d | awk '{ print $5 &quot; &quot; $1 }' | while read -r dfh; do #echo &quot;$output&quot; op=$(echo &quot;$dfh&quot; | awk '{ print $1}' | cut -d'%' -f1 ) partition=$(echo &quot;$dfh&quot; | awk '{ print $2 }' ) if [ $op -ge 90 ]; then echo &quot;&gt;&gt; ### WARNING! Running out of space on \&quot;$partition ($op%)\&quot; on $(hostname) as on $(date)&quot; &gt;&gt; LOGFILE echo -e &quot;&gt;&gt; ### WARNING! Running out of space on \&quot;$partition ($op%)\&quot; on $(hostname) as on $(date)&quot; echo &quot;&gt;&gt; There is not enough left storage in the disk to perform the upgrade, exiting...&quot; &gt;&gt; LOGFILE echo -e &quot;&gt;&gt; There is not enough left storage in the disk to perform the upgrade, exiting...&quot; exit 1 elif [ $op -ge 85 ]; then echo -e &quot;&gt;&gt; ### WARNING! Running out of space on \&quot;$partition ($op%)\&quot; on $(hostname) as on $(date)&quot; &gt;&gt; LOGFILE echo &quot;&gt;&gt; ### WARNING! Running out of space on \&quot;$partition ($op%)\&quot; on $(hostname) as on $(date)&quot; echo &quot;&gt;&gt; There enough left storage in the disk to perform the upgrade, but it is recommended to first increase the size of the disk $partition&quot; &gt;&gt; LOGFILE echo -e &quot;&gt;&gt; There enough left storage in the disk to perform the upgrade, but it is recommended to first increase the size of the disk $partition&quot; fi done if [ &quot;$?&quot; -eq 1 ]; then exit else echo -e &quot;&gt;&gt; There is enough left storage in the disk to continue with the upgrade, OK&quot; fi </code></pre> <p>I want it to exit only if at least one disk is more than 90% full, that's the pourpose of the last if statement</p> <p>The problem here is that the loop exits on the first disk recognised at more than 90%, this is bad because if I have 3 disks at more than 90% it will only report one of them (the first one in the loop) and then exit. Basically I want the script to report all the disks that are at 90% or more (and the ones that are at 85% too but without exiting, as you can read).</p> <p>Is this possible? Thank you in advance</p>
[ { "answer_id": 74221032, "author": "tripleee", "author_id": 874188, "author_profile": "https://Stackoverflow.com/users/874188", "pm_score": 2, "selected": true, "text": "rc=0\ndf -H |\nawk 'NR>1 { n=$5; sub(/%/, \"\", n); print n, $1 }' |\nwhile read -r op partition; \ndo \n if [ $op ...
2022/10/27
[ "https://Stackoverflow.com/questions/74220707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15216388/" ]
74,220,750
<p>I have created a virtual environment to install some Python modules. I am using <code>mini-conda</code> to manage and activate the environments.</p> <p>One issue that I am facing is that the code runs fine when I run it through the terminal with the virtual environment activated.</p> <p>However, the same code does not run when I use the &quot;Run Code&quot; button (Ctrl + Alt + N) in VSCode. It gives me Module Not Found Error.</p> <p>How can I run the code from VSCode in the context of my virtual environment?</p>
[ { "answer_id": 74220939, "author": "laurbtzt", "author_id": 11459709, "author_profile": "https://Stackoverflow.com/users/11459709", "pm_score": 2, "selected": false, "text": "Python: Select Interpreter" }, { "answer_id": 74229870, "author": "JialeDu", "author_id": 1913392...
2022/10/27
[ "https://Stackoverflow.com/questions/74220750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10449848/" ]
74,220,755
<p>I upgraded my software yesterday to MacOS Ventura. Today when I opened my project so I can work on it, I cannot get to build the app because I get this error: The current Flutter SDK version is 0.0.0-unknown.</p> <pre><code>Running &quot;flutter pub get&quot; in elfi_menu... The current Flutter SDK version is 0.0.0-unknown. Because country_icons 2.0.2 requires Flutter SDK version &gt;=0.1.4 and no versions of country_icons match &gt;2.0.2 &lt;3.0.0, country_icons ^2.0.2 is forbidden. So, because elfi_menu depends on country_icons ^2.0.2, version solving failed. pub get failed (1; So, because elfi_menu depends on country_icons ^2.0.2, version solving failed.) Exited (1) </code></pre> <p>I have tried to reinstall flutter, I get the same error, I also tried opening a new project, same error. I also looked it up on the internet but I saw pretty old similar issues, they are fixing it on Windows and it is not the same here on mac from what I've seen.</p> <p>Does anyone have any ideas why this happened and how to fix it?</p> <p>Thank you very much in advance</p> <p>EDIT</p> <p>Above the output I have written in the code, this is a line that appeared:</p> <pre><code>xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun </code></pre> <p>I searched for the solve on the internet and this like solves the problem, written in the terminal:</p> <pre><code>xcode-select --install </code></pre>
[ { "answer_id": 74220889, "author": "Andrei Marin", "author_id": 14362546, "author_profile": "https://Stackoverflow.com/users/14362546", "pm_score": 1, "selected": true, "text": "xcode-select --install\n" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74220755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14362546/" ]
74,220,760
<p>I am creating etch-a-sketch. Currently, i figured out how to create a grid width user input values. But when the values changes the grid size changes. I want to make the width of the grid stays same whenever cell value changes. What should i do for that. I tried adjusting grid template rows and columns. It didn't work</p> <p>Thank you</p> <p>Here's my code</p> <pre><code>.grid{ padding: 10px; display: inline-grid; justify-content: center; border: 1px solid black; gap: 1px; } .button-div{ padding: 10px; display: flex; justify-content: center; } </code></pre> <pre><code>const container = document.getElementById('container'); //div for buttons const buttonDiv = document.createElement('div'); buttonDiv.classList.add('button-div'); container.appendChild(buttonDiv); //A button to reset Everything const resetButton = document.createElement('button'); resetButton.textContent = 'Reset'; buttonDiv.appendChild(resetButton); //grid in a seperate div const grid = document.createElement('div'); grid.classList.add('grid'); container.appendChild(grid); //function to create grid function makeGrid(value){ let gridWidth = 200 / value; grid.style.gridTemplateColumns = `repeat(${value}, ${gridWidth}px)`; grid.style.gridTemplateRows = `repeat(${value}, ${gridWidth}px)`; for(let i = 0; i &lt; value; i++){ for(let j = 0; j &lt; value; j++){ const cell = document.createElement('div'); cell.classList.add('cell'); cell.addEventListener('mouseover', toBlack); grid.appendChild(cell); } } } //to change the cell color to black on mouseover function toBlack(e){ e.target.style.backgroundColor = 'black'; } function resetGrid(){ const value = prompt('Input a number of Squares'); grid.innerHTML = ''; makeGrid(value); } resetButton.addEventListener('click',resetGrid); window.onload = () =&gt; {makeGrid(16)}; </code></pre>
[ { "answer_id": 74220889, "author": "Andrei Marin", "author_id": 14362546, "author_profile": "https://Stackoverflow.com/users/14362546", "pm_score": 1, "selected": true, "text": "xcode-select --install\n" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74220760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20078966/" ]
74,220,788
<p><em>&amp;amp</em> char has somehow got through different imports into the db on many different node attributes and relationship attributes. How do I replace all &amp;amp; strings with regular &amp; char?</p> <p>I don't know all the possible property names that I can filter on.</p>
[ { "answer_id": 74222081, "author": "jose_bacoy", "author_id": 7371893, "author_profile": "https://Stackoverflow.com/users/7371893", "pm_score": 0, "selected": false, "text": "MATCH (p)\n// collect keys (or properties) in node p and look for properties with &amp\nWITH p, [k in keys(p) WHE...
2022/10/27
[ "https://Stackoverflow.com/questions/74220788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5128597/" ]
74,220,810
<p>I'm working with Shopify's Order API and I receive the following responses, which currently sit in a dataframe (very simplified).</p> <pre><code>+----------+-----------+-----------------------------------------------------------------------------+ | order_id | name | item_order | +----------+-----------+-----------------------------------------------------------------------------+ | 123 | Jon Doe | [{'id':789,'price':40.0,'sku':'HAT'},{'id':790,'price':41.0,'sku':'SHIRT'}] | +----------+-----------+-----------------------------------------------------------------------------+ | 122 | Jonah Doe | [{'id':553,'price':20.0,'sku':'CAP'}] | +----------+-----------+-----------------------------------------------------------------------------+ | | | | +----------+-----------+-----------------------------------------------------------------------------+ </code></pre> <p>I'd like to explode item_order, so we get something closer to the below:</p> <pre><code>+----------+-----------+---------------+------------------+----------------+ | order_id | name | item_order.id | item_order.price | item_order.sku | +----------+-----------+---------------+------------------+----------------+ | 123 | Jon Doe | 789 | 40.0 | HAT | +----------+-----------+---------------+------------------+----------------+ | 123 | Jon Doe | 790 | 41.0 | SHIRT | +----------+-----------+---------------+------------------+----------------+ | 122 | Jonah Doe | 553 | 20 | CAP | +----------+-----------+---------------+------------------+----------------+ </code></pre>
[ { "answer_id": 74222081, "author": "jose_bacoy", "author_id": 7371893, "author_profile": "https://Stackoverflow.com/users/7371893", "pm_score": 0, "selected": false, "text": "MATCH (p)\n// collect keys (or properties) in node p and look for properties with &amp\nWITH p, [k in keys(p) WHE...
2022/10/27
[ "https://Stackoverflow.com/questions/74220810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15368200/" ]