qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,186,224
<p>I have a test where I am performing a docker stop operation and checking something and starting the docker container. I am using dockerode library. When I run that I test I keep getting the following error - <strong>Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure &quot;done()&quot; is called; if returning a Promise, ensure it resolves.</strong> I am using async/await. Here's the sample of the code</p> <pre><code>describe('docker container test', () =&gt; { let docker before(() =&gt; { docker = new Docker() }) after( () =&gt; { docker = null }) it('simple docker test', async () =&gt; { try { container = await getDockerContainerByName(docker, containerName) await stopDocker(docker, container) await startDocker(docker, container) await waitForContainerToBeHealthy(docker, container) console.log(&quot;container healthy&quot;) } catch(error) { console.log(&quot;Error occurred &quot;+ JSON.stringify(error)) } }).timeout(120000) }) async waitForContainerToBeHealthy (docker, container) { await invokeUntil(async (retry, complete) =&gt; { return dockerTestHelper.inspectDockerContainer(docker, container).then( (data) =&gt; { if(// check if container is healthy) { complete() } else { retry() } }) }) } </code></pre> <p>I can see on the console that the container is healthy. But, the test doesn't end. It hangs and after some time I see the error posted above. Can someone let me know what am I doing wrong</p>
[ { "answer_id": 74186225, "author": "DJ Cook", "author_id": 16817752, "author_profile": "https://Stackoverflow.com/users/16817752", "pm_score": 0, "selected": false, "text": "Caused by ProxyError('Your proxy appears to only use HTTP and not HTTPS, try changing your proxy URL to be HTTP. S...
2022/10/24
[ "https://Stackoverflow.com/questions/74186224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5201757/" ]
74,186,232
<p>I'm following the example SMUI here: <a href="https://sveltematerialui.com/demo/button/" rel="nofollow noreferrer">https://sveltematerialui.com/demo/button/</a></p> <p>and I've written this component (UserDropdown):</p> <pre><code>&lt;script&gt; import Button, { Group, GroupItem, Icon } from '@smui/button'; import Menu from '@smui/menu'; import List, { Item, Separator, Text } from '@smui/list'; let menu export let user export let onLogout &lt;/script&gt; {#if user &amp;&amp; user.hasOwnProperty('username')} &lt;Group variant=&quot;outlined&quot;&gt; &lt;Button variant=&quot;outlined&quot;&gt; Logged in as: { user.username } &lt;/Button&gt; &lt;div use:GroupItem&gt; &lt;Button on:click={() =&gt; menu.setOpen(true)} variant=&quot;raised&quot; style=&quot;padding: 0; min-width: 36px;&quot;&gt; &lt;Icon class=&quot;material-icons&quot; style=&quot;margin: 0;&quot;&gt;arrow_drop_down&lt;/Icon&gt; &lt;/Button&gt; &lt;Menu bind:this={menu} anchorCorner=&quot;TOP_LEFT&quot;&gt; &lt;List&gt; &lt;Item on:SMUI:action={onLogout}&gt; &lt;Text&gt;Logout&lt;/Text&gt; &lt;/Item&gt; &lt;/List&gt; &lt;/Menu&gt; &lt;/div&gt; &lt;/Group&gt; {:else} &lt;div&gt; &lt;a href=&quot;/login&quot;&gt;LOGIN&lt;/a&gt; &lt;/div&gt; {/if} </code></pre> <p>Even though the code is pretty much verbatim from the SMUI site, it doesn't work. I get this error:</p> <pre><code>Cannot read properties of null (reading 'SmuiElement') TypeError: Cannot read properties of null (reading 'SmuiElement') at CommonIcon.svelte:32:23 at Object.$$render (/node_modules/svelte/internal/index.mjs:1771:22) at Object.default (/src/lib/components/UserDropdown.svelte:43:96) at Object.default (/node_modules/@smui/button/dist/Button.svelte:195:34) at eval (/node_modules/@smui/common/dist/SmuiElement.svelte:62:40) at eval (/node_modules/@smui/common/dist/SmuiElement.svelte:63:7) at SmuiElement.svelte:11:10 at Object.$$render (/node_modules/svelte/internal/index.mjs:1771:22) at Button.svelte:2:17 at Object.$$render (/node_modules/svelte/internal/index.mjs:1771:22) </code></pre> <p>Does anyone have a working example of the SMUI split button that works with 7.0 beta 1?</p> <p>Thanks</p>
[ { "answer_id": 74186225, "author": "DJ Cook", "author_id": 16817752, "author_profile": "https://Stackoverflow.com/users/16817752", "pm_score": 0, "selected": false, "text": "Caused by ProxyError('Your proxy appears to only use HTTP and not HTTPS, try changing your proxy URL to be HTTP. S...
2022/10/24
[ "https://Stackoverflow.com/questions/74186232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20232084/" ]
74,186,241
<p>Let's say I have a dataframe in python with a range of animals, and a range of attributes, with dummy variables for whether the animal has that attribute. I'm interested in creating lists, both vertically and horizontally based on dummy variable value. e.g. I'd like to:</p> <p>a) create a list of animals that have hair<br /> b) create a list of all the attributes that a dog has.</p> <p>Could anyone please assist with how I would do this in Python? Thanks very much!</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Name</th> <th>Hair</th> <th>Eyes</th> </tr> </thead> <tbody> <tr> <td>Dog</td> <td>1</td> <td>1</td> </tr> <tr> <td>Fish</td> <td>0</td> <td>1</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74186225, "author": "DJ Cook", "author_id": 16817752, "author_profile": "https://Stackoverflow.com/users/16817752", "pm_score": 0, "selected": false, "text": "Caused by ProxyError('Your proxy appears to only use HTTP and not HTTPS, try changing your proxy URL to be HTTP. S...
2022/10/24
[ "https://Stackoverflow.com/questions/74186241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20324689/" ]
74,186,245
<p>I just want to save an array in a json file. But I don't know what's going on. In dataUser.json there is only &quot;{}&quot;</p> <pre><code>//test.cs void Start() { Test(); } void Test() { string[,] dataUser = new string[,] { {&quot;NgocPhat&quot;, &quot;03&quot;}, {&quot;PhatNgoc&quot;, &quot;02&quot;} }; string json = JsonUtility.ToJson(dataUser, true); File.WriteAllText(Application.dataPath + &quot;/dataUser.json&quot;, json); } </code></pre> <p>Output</p> <pre><code>//dataJson.json {} //https://i.stack.imgur.com/SRDHJ.png </code></pre>
[ { "answer_id": 74186442, "author": "John B", "author_id": 57698, "author_profile": "https://Stackoverflow.com/users/57698", "pm_score": 0, "selected": false, "text": "public class Dummy\n{\n [Serializable]\n public string[,] Data { get; set; }\n}\n\nstring[,] dataUser = new string[...
2022/10/24
[ "https://Stackoverflow.com/questions/74186245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20324651/" ]
74,186,274
<p>I have the following code that records job candidates' personal details in a class <code>Employee</code>:</p> <pre><code>class Employee: def __init__(self, name, role, id): self.name = name self.role = role self.id = id self.interviewed = False def __str__(self): text = f'Candidate {self.name}; {self.id}. ' if self.interviewed == False: return text + 'Not interviewed yet.' else: return text + 'Interviewed.' def interview(self): self.interviewed = True </code></pre> <p>I also have another class <code>Database</code> that lists all the candidates in a database for a particular employer:</p> <pre><code>class Database: def __init__(self, company, employer): self.company = company self.employer = employer self.candidates = [] def __str__(self): text = f'{The hiring company is {self.company} and the employers name is {self.employer}' return text def add_candidate(self, candidate): self.candidates.append(candidate) </code></pre> <p>Now, if we record personal details of two candidates in the <code>class Employee</code> and add them to the <code>class Database</code> using the method <code>add_candidate</code>, how do I create a new method called <code>list_interviewed_candidates(self)</code> in the <code>class Database</code> that will print all candidates that have <code>self.interviewed</code> set to True?</p> <p>This is what I tried:</p> <pre><code>class Database: def __init__(self, company, employer): self.company = company self.employer = employer self.candidates = [] def __str__(self): text = f'{The hiring company is {self.company} and the employers name is {self.employer}' return text def add_candidate(self, candidate): self.candidates.append(candidate) def list_interviewed_candidates(self): for employee in self.candidates: if employee.interviewed == True: return employee </code></pre> <p>But that doesn't work. I have also tried list comprehension but it seems I just cannot access the boolean value that was set in the first class. Ideally, the output should look something like this:</p> <pre><code>database1 = Database('Google', 'Jack H') print(database1) 'The hiring company is Google and the employers name is Jack H' candidate1 = Employee('Anna S', 'web-designer', 12) database1.add_candidate(candidate1) print(database1.list_interviewed_candidates()) [] candidate1.interview() print(database1.list_interviewed_candidates()) ['Candidate Ana S; 12 - Interviewed'] </code></pre>
[ { "answer_id": 74186442, "author": "John B", "author_id": 57698, "author_profile": "https://Stackoverflow.com/users/57698", "pm_score": 0, "selected": false, "text": "public class Dummy\n{\n [Serializable]\n public string[,] Data { get; set; }\n}\n\nstring[,] dataUser = new string[...
2022/10/24
[ "https://Stackoverflow.com/questions/74186274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19767784/" ]
74,186,291
<p>Trying to create a list of prime numbers in a fixed range. This is producing non-sensical list but the code makes sense to me.</p> <pre><code> for number in range(2,100,2): k = 1 while k*k &lt; number: k += 2 if number % k == 0: break else: print(number) </code></pre>
[ { "answer_id": 74186331, "author": "Dariush Mazlumi", "author_id": 8956917, "author_profile": "https://Stackoverflow.com/users/8956917", "pm_score": 2, "selected": false, "text": "for number in range(2,100):\n prime, divisor = True, 2\n\n while prime and divisor ** 2 <= number:\n ...
2022/10/24
[ "https://Stackoverflow.com/questions/74186291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18181836/" ]
74,186,295
<p>I'm creating a small-ish django application using AllAuth for the authetncation, which I have customised myself to include some additional fields.</p> <p>Part of the sites functionality requires me to refrence the logged in user through a Foreign Key multiple times and I'm approaching this through the custom model I created, called UserProfile; (I tried Django's User model &amp; this also gave me errors)</p> <pre><code>class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile') phone_number = models.CharField(max_length=30, null=False) postcode = models.CharField(max_length=500, null=True, blank=True) town_or_city = models.CharField(max_length=40, null=True, blank=True) street_address1 = models.CharField(max_length=80, null=True, blank=True) street_address2 = models.CharField(max_length=80, null=True, blank=True) county = models.CharField(max_length=80, null=True) </code></pre> <p>I'm referencing the above model in the activity table:</p> <pre><code>class Activity(models.Model): class Meta: verbose_name_plural = 'Activities' activity_id = models.CharField(max_length=32, null=False, editable=False) host = models.ForeignKey(UserProfile, on_delete=models.CASCADE) name = models.CharField(max_length=254, null=False, blank=False) date = models.DateField() start_time =models.TimeField() end_time = models.TimeField() duration = models.DurationField(blank=True, null=True) location = models.CharField(max_length=40, null=False, blank=False) description = models.CharField(max_length=140, null=False, blank=False) available = models.BooleanField(default=True) </code></pre> <p>Everything works smoothly, as I can use this to create one activity per user, however I want to make this a Many to One field, which required me to update from settings.AUTH_USER_MODEL to the Foreign Key.</p> <p>Unfortunately, I'm getting the following error:</p> <blockquote> <p>FOREIGN KEY constraint failed</p> </blockquote> <p>when I try to add a new activity now, and I'm at a loss as to why this is happening.</p> <p>If someone could point me in the right direction on how to create this many to one functionality, it would be great.</p>
[ { "answer_id": 74186331, "author": "Dariush Mazlumi", "author_id": 8956917, "author_profile": "https://Stackoverflow.com/users/8956917", "pm_score": 2, "selected": false, "text": "for number in range(2,100):\n prime, divisor = True, 2\n\n while prime and divisor ** 2 <= number:\n ...
2022/10/24
[ "https://Stackoverflow.com/questions/74186295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13533531/" ]
74,186,305
<p>I have this empty object with a collider attached, and it follows the mouse around. The &quot;is trigger&quot; box isn't checked, and that's it.</p> <p>Now, on my other Object, I also added a collider (2d of course) and set it as &quot;is trigger&quot; = true, but I also tried it with the box unchecked.</p> <p>The following Code should execute when the Trigger &quot;area&quot; is entered:</p> <pre><code>public void OnTriggerEnter2D(Collider2D collider) { print(&quot;found coin&quot;); manager.AddCoin(); Destroy(gameObject); } </code></pre> <p>But it does not. How do I fix this?</p>
[ { "answer_id": 74186331, "author": "Dariush Mazlumi", "author_id": 8956917, "author_profile": "https://Stackoverflow.com/users/8956917", "pm_score": 2, "selected": false, "text": "for number in range(2,100):\n prime, divisor = True, 2\n\n while prime and divisor ** 2 <= number:\n ...
2022/10/24
[ "https://Stackoverflow.com/questions/74186305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20324764/" ]
74,186,337
<p>I have an associative array containing entries that are virtually the same, except the key-value pairs are swapped:</p> <pre><code>[ [ &quot;partnerA&quot; =&gt; &quot;Alice&quot;, &quot;partnerB&quot; =&gt; &quot;Alfred&quot; ], [ &quot;partnerA&quot; =&gt; &quot;Alfred&quot;, &quot;partnerB&quot; =&gt; &quot;Alice&quot; ], [ &quot;partnerA&quot; =&gt; &quot;Alfred&quot;, &quot;partnerB&quot; =&gt; &quot;Brandon&quot; ] ] </code></pre> <p>I stored the array in a Laravel <code>collection</code> and tried using <code>-&gt;unique()</code></p> <pre><code> $partners = collect($array)-&gt;unique(); </code></pre> <p>but the output matches the array feeding in.</p> <p>How can I remove duplicates like this from an array so each pair is unique no matter if the keys are swapped?</p> <p>The desired output is:</p> <pre><code>[ [ &quot;partnerA&quot; =&gt; &quot;Alice&quot;, &quot;partnerB&quot; =&gt; &quot;Alfred&quot; ], [ &quot;partnerA&quot; =&gt; &quot;Alfred&quot;, &quot;partnerB&quot; =&gt; &quot;Brandon&quot; ] ] </code></pre> <p>Update: What I've tried so far that seems to be working...</p> <pre><code>$size = sizeof($partners); for($i = 0; $i &lt;= $size; $i++){ $match = $partners[$i]; $needle = [&quot;partnerA&quot; =&gt; $match[&quot;partnerB&quot;], &quot;partnerB&quot; =&gt; $match[&quot;partnerA&quot;]]; if(in_array($needle, $partners)){ unset($partners[$i]); } } </code></pre>
[ { "answer_id": 74187117, "author": "Khaled Hassan", "author_id": 19713049, "author_profile": "https://Stackoverflow.com/users/19713049", "pm_score": 1, "selected": false, "text": "$results = [\n[\n \"partnerA\" => \"Alfred\",\n \"partnerB\" => \"Alice\"\n],\n[\n \"partnerA\" => ...
2022/10/24
[ "https://Stackoverflow.com/questions/74186337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6523716/" ]
74,186,355
<p>Hello so i made a gallery with images , and i added hover overlay to it, but also added lightbox, so now when i try to click on image i am clicking on overlay. how do i make it clickable trough hover layer that i made ?</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>.gallery-image{ position: relative; width: 300px; box-shadow: rgb(139, 9, 9) 0px 5px 10px; } .image-img{ width: 100%; display: block; } .overlay{ position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.6); color: var(--tect-onblack); display: flex; flex-direction: column; align-items: center; justify-content: center; opacity: 0; transition: all .4s ease; } .image-title i{ font-size: 70px; } .overlay:hover{ opacity: 1; transition: all .4s ease; cursor: pointer; } .overlay &gt;*{ transform: translateY(30px); transition: all .4s ease; } .overlay:hover &gt;*{ transform: translateY(0); }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="gallery"&gt; &lt;div class="gallery-image"&gt; &lt;a href="./images/111.jpg" data-lightbox="shkaf" data-title="gal1"&gt; &lt;img class="image-img" src="./images/111.jpg"&gt;&lt;/a&gt; &lt;div class="overlay"&gt; &lt;div class="image-title"&gt; &lt;i class='bx bx-zoom-in'&gt;&lt;/i&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="price"&gt; &lt;p&gt;120 000р&lt;/p&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74187117, "author": "Khaled Hassan", "author_id": 19713049, "author_profile": "https://Stackoverflow.com/users/19713049", "pm_score": 1, "selected": false, "text": "$results = [\n[\n \"partnerA\" => \"Alfred\",\n \"partnerB\" => \"Alice\"\n],\n[\n \"partnerA\" => ...
2022/10/24
[ "https://Stackoverflow.com/questions/74186355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4458753/" ]
74,186,362
<p>all of you,</p> <p><strong>Here is the image;</strong> <a href="https://i.stack.imgur.com/IXVJl.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IXVJl.jpg" alt="enter image description here" /></a></p> <p><strong>The exact background color is in RGB; (246, 46, 100)</strong></p> <p>I have tried several methods but those are too slow, one of the methods is below;</p> <pre><code>new_image = Image.open(&quot;image-from-rawpixel-id-6649116-original.png&quot;) img_up = np.asarray(new_image) for ind1, i in enumerate(tqdm(img_up)): for ind2, i2 in enumerate(i): if list(i2[:3]) != a: img_up2 = img_up.copy() img_up2.setflags(write=1) img_up2[ind1][ind2][:3] = [0,0,0] cv2.imshow('', img_up2) cv2.waitKey() </code></pre> <p>I want to make the background white and the foreground person black (masked), but unable to find a quick method.</p> <p><strong>Modified</strong></p> <p>I have tied another method to mask the foreground but I think, I am doing some mistakes while converting between RGBs. Below is the code;</p> <pre><code>path = 'image-from-rawpixel-id-2923073-png.png' im = Image.open(path).convert('RGBA') img = cv2.imread(path, cv2.IMREAD_UNCHANGED) #--------------------------- To change the background color that is not present in the foreground --------------------------------------------- lst_ch_a = [] for pixel in tqdm(im.getdata()): lst_ch_a.append(pixel[:3]) break_out = True while break_out: a = random.sample(range(0, 255), 3) if a not in lst_ch_a: new_image = Image.new(&quot;RGBA&quot;, im.size, tuple(a)) print(tuple(a)) break_out = False new_image.paste(im, mask=im) new_image.convert(&quot;RGB&quot;).save(&quot;check6.jpg&quot;) #--------------------------- Numpy ---------------------------------------------------------------- img_up = np.asarray(new_image) img = img_up.copy() img.setflags(write=1) img[:,:,:3][img[:,:,:3] != tuple(a)] = 0 img[img!=0]=255 img = cv2.cvtColor(img, cv2.COLOR_BGRA2RGBA) img = cv2.resize(img,(500,500), cv2.INTER_LINEAR) cv2.imwrite('results1.jpg', img) cv2.imshow('', img) cv2.waitKey(0) </code></pre> <p>Below is the result, but I am getting pixels of Blue, green, red, and some other colors in the image. do you know why I am getting this?</p> <p><a href="https://i.stack.imgur.com/Qs39H.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qs39H.jpg" alt="enter image description here" /></a></p> <p>You can see in the above first image, where I have changed the background. The image was transparent image, but then I changed the background color. There was no green, blue, or red colors but while masking the foreground the red, blue, and green color emerges.</p> <p>Do you know why it is happening?</p>
[ { "answer_id": 74186723, "author": "furas", "author_id": 1832058, "author_profile": "https://Stackoverflow.com/users/1832058", "pm_score": 2, "selected": false, "text": "cv2.imread()" }, { "answer_id": 74188137, "author": "Mark Setchell", "author_id": 2836621, "author...
2022/10/24
[ "https://Stackoverflow.com/questions/74186362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19454065/" ]
74,186,367
<p>This is the question - '''Given a list of strings, create a dictionary, where keys are the strings and the values are the number of times the corresponding string repeats in the list. Do not use any additional libraries.</p> <p>Example:</p> <pre><code>&gt;&gt;&gt; problem1(['Hello', 'Hello', 'Friends', 'Friends', 'Friends', 'Home']) {'Hello': 2, 'Friends': 3, 'Home': 1} </code></pre> <p>This is my code:</p> <pre><code>def problem2(mystrings): mydct = {} for x in mystrings: mydct = [mystrings] for in mydct: return mydct print (problem2(['Hello', 'Hello', 'Friends', 'Friends', 'Friends', 'Home'])) </code></pre> <p>I need help on how to make the keys into strings and the values into the number of times the string shows up, I can't figure out how to do it. Any help is appreciated.</p>
[ { "answer_id": 74186383, "author": "Jamie.Sgro", "author_id": 11550733, "author_profile": "https://Stackoverflow.com/users/11550733", "pm_score": 0, "selected": false, "text": "words = ['Hello', 'Hello', 'Friends', 'Friends', 'Friends', 'Home']\nresult = {}\n\nfor word in words:\n if ...
2022/10/24
[ "https://Stackoverflow.com/questions/74186367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20278026/" ]
74,186,378
<p>I'm trying to connect to a database through R that has authentication type 'SQL Server Authentication' as stated through 'Microsoft SQL Server Management Studio 18'.</p> <p>I know the library DBI has a function called 'dbconnect()' that has an authentication parameter but the documentation does not show what the different type of authentications are. I've tried both 'SQLServer' and 'SQL Server' but it just outputs the same error:<br /> &quot;Invalid value specified for connection string attribute 'Authentication' &quot;</p> <p>Has anyone made a similar connection?</p>
[ { "answer_id": 74186383, "author": "Jamie.Sgro", "author_id": 11550733, "author_profile": "https://Stackoverflow.com/users/11550733", "pm_score": 0, "selected": false, "text": "words = ['Hello', 'Hello', 'Friends', 'Friends', 'Friends', 'Home']\nresult = {}\n\nfor word in words:\n if ...
2022/10/24
[ "https://Stackoverflow.com/questions/74186378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20324870/" ]
74,186,403
<p>How can I extract only the day from a list such as this?</p> <pre><code>date_data = [None, None, None, None, '2014-01-05', '2014-01-06', '2014-01-07', None, None, '2014-01-10'] </code></pre> <p>I've tried a few different lambda functions such as:</p> <pre><code>Date_List = [d for y, m, d in map(lambda x: str(x).split('-'), date_data) if y != None if m != None if d != None] </code></pre> <p>or</p> <pre><code>test = [datetime.strptime(i, '%Y-%m-%d') for i in date_data] test1 = [datetime.strftime(i, '%d') for i in test] </code></pre> <p>But I cannot get the correct output which is:</p> <pre><code>date_data = [None, None, None, None, '05', '06', '07', None, None, '10'] </code></pre> <p>Does someone know how to accomplish this?</p>
[ { "answer_id": 74186455, "author": "Andrew Ryan", "author_id": 7451892, "author_profile": "https://Stackoverflow.com/users/7451892", "pm_score": 3, "selected": true, "text": "Date_List = [x.split('-')[2] if x else None for x in date_data] \n" }, { "answer_id": 74186461, "auth...
2022/10/24
[ "https://Stackoverflow.com/questions/74186403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19787771/" ]
74,186,422
<p>I'm not advanced in Django and would like to know how and if it's possible to do it.</p> <p>I need to override Django's user model, and change the fields &quot;username&quot; to &quot;sr_usuario&quot; and &quot;password&quot; to &quot;sr_password&quot;, but I would like to continue using all Django's default authentication scheme and permissions. I want not only to change the description in the database or a label, I want to change the name of the field in the model, for when for example I needed to make a query, I would use User.objects.filter(sr_usuario=&quot;user_name&quot;) and everything would work usually.</p> <p>It's possible? I couldn't find anything in the documentation or on forums I've searched.</p> <p>Thank you very much in advance!</p>
[ { "answer_id": 74186559, "author": "cerwind", "author_id": 7027316, "author_profile": "https://Stackoverflow.com/users/7027316", "pm_score": 2, "selected": false, "text": "AUTH_USER_MODEL = \"<THE PATH OF THE USER MODEL>\"" }, { "answer_id": 74189783, "author": "Mohsin Maqsoo...
2022/10/24
[ "https://Stackoverflow.com/questions/74186422", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20324898/" ]
74,186,428
<p>I am downloading images from Unsplash API and want to make sure that while the image is loading the user scrolls the data task for that particular cell that is no longer is dismissed. I am creating a <code>URLSessionDataTask</code>, and then calling <code>task.cancel()</code> in <code>prepareToReuse()</code> method.</p> <p>I want to know if this is the correct way to cancel an image request? Also, what are alternate ways of achieving the same thing. Since the whole <code>URLSessionDataTask</code> is an asynchronous operation, I don't really see why I should be wrapping it in a <code>DispatchGroup or DispatchWorkItem</code>. Any tips on how to make smooth asynchronous image loading without caching. (I have implemented NSCache in the code below). Below is the <code>ImageDownloader</code> class:</p> <pre><code>var cache = NSCache&lt;NSURL,UIImage&gt;() class ImageDownloader { var task: URLSessionTask? func imageDownloader(url: String, completion: @escaping (UIImage?) -&gt; ()) { guard let imageURL = URL(string: url) else { return } if let cachedImage = cache.object(forKey: imageURL as NSURL) { completion(cachedImage) return } task = URLSession.shared.dataTask(with: imageURL, completionHandler: { data, response, err in if err != nil { completion(nil) print(err?.localizedDescription) return } guard let data = data, let image = UIImage(data: data) else { completion(nil) return } cache.setObject(image, forKey: imageURL as NSURL) completion(image) }) task?.resume() } func cancelImageRequest() { task?.cancel() } } </code></pre> <p>Here is how I am calling it in custom <code>CollectionViewCell</code>:</p> <pre><code>func configure(image: ImageModel) { imageDownloader = ImageDownloader() guard let urlstring = image.urls.full else { return } imageDownloader?.imageDownloader(url: urlstring, completion: { image in DispatchQueue.main.async { self.cellImage.image = image } }) } override func prepareForReuse() { cellImage.image = nil imageDownloader?.cancelImageRequest() } </code></pre>
[ { "answer_id": 74186559, "author": "cerwind", "author_id": 7027316, "author_profile": "https://Stackoverflow.com/users/7027316", "pm_score": 2, "selected": false, "text": "AUTH_USER_MODEL = \"<THE PATH OF THE USER MODEL>\"" }, { "answer_id": 74189783, "author": "Mohsin Maqsoo...
2022/10/24
[ "https://Stackoverflow.com/questions/74186428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8914352/" ]
74,186,444
<p>I have a table and I want to retrieve all rows for a <code>date</code> column like <code>2022-10-24 21:03:00</code> where the hours for every date are between <code>21:00:00</code> and <code>22:00:00</code>.</p> <p>What would the SQL for this?</p>
[ { "answer_id": 74186559, "author": "cerwind", "author_id": 7027316, "author_profile": "https://Stackoverflow.com/users/7027316", "pm_score": 2, "selected": false, "text": "AUTH_USER_MODEL = \"<THE PATH OF THE USER MODEL>\"" }, { "answer_id": 74189783, "author": "Mohsin Maqsoo...
2022/10/24
[ "https://Stackoverflow.com/questions/74186444", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9087739/" ]
74,186,447
<p>Here i'm using select from material ui, and have a question: how to get an object (handleChange function) when user clicks from dropdown ? in my handleChange i want to have object and not just 'name', and those places where i'm using 'selected' i could just pick it from object like this selected.name (if needed). and another question: i'm getting data to 'selected' from api the thing is that that data shows on select itself but nothing shows in dropdown. any advices how to make this code simpler?</p> <p><a href="https://codesandbox.io/s/material-ui-multiple-select-with-select-all-option-forked-ipukpk?file=/src/App.js" rel="nofollow noreferrer">https://codesandbox.io/s/material-ui-multiple-select-with-select-all-option-forked-ipukpk?file=/src/App.js</a></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>import React, { useState } from "react"; import Checkbox from "@material-ui/core/Checkbox"; import InputLabel from "@material-ui/core/InputLabel"; import ListItemIcon from "@material-ui/core/ListItemIcon"; import ListItemText from "@material-ui/core/ListItemText"; import MenuItem from "@material-ui/core/MenuItem"; import FormControl from "@material-ui/core/FormControl"; import Select from "@material-ui/core/Select"; import DeleteIcon from "@material-ui/icons/Delete"; import CreateIcon from "@material-ui/icons/Create"; import { MenuProps, useStyles } from "./utils"; import AddUser from "./AddUser"; import { Button } from "@material-ui/core"; import EditUser from "./EditUser"; function App() { const rawOptions = [ { id: 1, name: "Oliver Hansen" }, { id: 2, name: "Van Henry" } ]; const classes = useStyles(); const [selected, setSelected] = useState([]); const [options, setOptions] = useState(rawOptions); const [openAddModal, setOpenAddModal] = useState(false); const [openUpdateModal, setOpenUpdateModal] = useState(false); const [edit, setEdit] = useState({ id: null, name: "" }); const handleChange = (event) =&gt; { const value = event.target.value; setSelected(value); console.log("get id and name of selected here", value); }; function addUser(newArray) { const newTodos = [...options, newArray]; setOptions(newTodos); } const openAddUser = () =&gt; { setOpenAddModal(true); }; const openUpdateUser = (event, data) =&gt; { event.preventDefault(); event.stopPropagation(); setOpenUpdateModal(true); setEdit(data); }; // console.log("id", edit); const closeAddModal = () =&gt; { setOpenAddModal(false); }; const closeUpdateModal = () =&gt; { setOpenUpdateModal(false); }; const updateUser = (updateUser) =&gt; { setOptions( options.map((user) =&gt; (user.id === updateUser.id ? updateUser : user)) ); }; return ( &lt;FormControl className={classes.formControl}&gt; &lt;div&gt; &lt;InputLabel id="mutiple-select-label"&gt;Multiple Select&lt;/InputLabel&gt; &lt;Select labelId="mutiple-select-label" multiple variant="outlined" value={selected || []} onChange={handleChange} renderValue={(selected) =&gt; selected} MenuProps={MenuProps} &gt; {options.map((option, index) =&gt; ( &lt;MenuItem key={index} value={option.name}&gt; &lt;ListItemIcon&gt; &lt;Checkbox checked={selected?.includes(option.name)} /&gt; &lt;/ListItemIcon&gt; &lt;ListItemText primary={option.name}&gt;{option}&lt;/ListItemText&gt; &lt;DeleteIcon onClick={(e) =&gt; { e.stopPropagation(); setOptions(options.filter((o) =&gt; o.id !== option.id)); }} /&gt; &lt;ListItemIcon&gt; &lt;CreateIcon onClick={(e) =&gt; openUpdateUser(e, { id: option.id, name: option.name }) } /&gt; &lt;/ListItemIcon&gt; &lt;/MenuItem&gt; ))} &lt;/Select&gt; &lt;Button onClick={openAddUser} style={{ backgroundColor: "#287B7A" }}&gt; Add User &lt;/Button&gt; &lt;/div&gt; &lt;p&gt;{selected}&lt;/p&gt; &lt;AddUser openAddModal={openAddModal} handleClose={closeAddModal} array={options} addUser={addUser} /&gt; &lt;EditUser edit={edit} openUpdateModal={openUpdateModal} handleClose={closeUpdateModal} array={options} updateUser={updateUser} /&gt; &lt;/FormControl&gt; ); } export default App;</code></pre> </div> </div> </p>
[ { "answer_id": 74186559, "author": "cerwind", "author_id": 7027316, "author_profile": "https://Stackoverflow.com/users/7027316", "pm_score": 2, "selected": false, "text": "AUTH_USER_MODEL = \"<THE PATH OF THE USER MODEL>\"" }, { "answer_id": 74189783, "author": "Mohsin Maqsoo...
2022/10/24
[ "https://Stackoverflow.com/questions/74186447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17292277/" ]
74,186,482
<p>I hope you are doing well. I am new with Ruby and I don't really get what is the difference between a setter method and a method with a parameter. For example, let's say I have the following code:</p> <pre class="lang-rb prettyprint-override"><code>module Popy def self.friend @friend end def self.friend=(new_friend) @friend = new_friend end end </code></pre> <p>I understand that with the setter method called friend I set the @friend of Popy. But what is the difference if I put this method?</p> <pre class="lang-rb prettyprint-override"><code>def self.friend!(new_friend) @friend = new_friend end </code></pre> <p>I have tried to search this on internet but can't find an answer. Thank you in advance! Have a great day.</p>
[ { "answer_id": 74186559, "author": "cerwind", "author_id": 7027316, "author_profile": "https://Stackoverflow.com/users/7027316", "pm_score": 2, "selected": false, "text": "AUTH_USER_MODEL = \"<THE PATH OF THE USER MODEL>\"" }, { "answer_id": 74189783, "author": "Mohsin Maqsoo...
2022/10/24
[ "https://Stackoverflow.com/questions/74186482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13911845/" ]
74,186,487
<p>I have a simple view model as:</p> <pre class="lang-cs prettyprint-override"><code>public record CreateViewModel { [Required] [StringLength( 250, ErrorMessage = &quot;The {0} must be at least {2} characters long.&quot;, MinimumLength = 5 )] public string Name { get; set; } = string.Empty; [StringLength( 20, ErrorMessage = &quot;The {0} must be at least {2} characters long.&quot; )] [Display(Name = &quot;Phone Number&quot;)] public string AlternateContactPhoneNumber { get; set; } = string.Empty; } </code></pre> <p>But for some reason when my controller run the state as:</p> <pre><code>if (!ModelState.IsValid) { return View(model); } </code></pre> <p>It is returning that the Phone Number field is required and I do have not a required data annotation on that model property. Any one knows what is going on?</p>
[ { "answer_id": 74186646, "author": "Victor", "author_id": 6630084, "author_profile": "https://Stackoverflow.com/users/6630084", "pm_score": 2, "selected": true, "text": "[ValidateNever]" }, { "answer_id": 74186788, "author": "Mohammad Aghazadeh", "author_id": 10546136, ...
2022/10/24
[ "https://Stackoverflow.com/questions/74186487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16090212/" ]
74,186,524
<p>I trying to show the root partition usage in the Xmobar (with XMonad), but not working!! Without any verbose or error message. I don't know if the problem is the way as the Slackware loading the root partition or its way of the xmobar working. Explaining the context: The disk have three partitions: <code>&quot;swap&quot;, &quot;/&quot; and &quot;/home&quot;</code></p> <pre><code>/dev/sda1 is the / /dev/sda2 is the swap /dev/sda3 is the /home </code></pre> <p>in the Slackware, the system creates a virtual mount point to <code>&quot;/dev/sda1&quot;</code> calling it the <code>&quot;/dev/root&quot;</code> with mount point to <code>&quot;/&quot;</code></p> <p>In the Xmobar (<code>.xmobarrc</code> file), any of the options below not work:</p> <pre><code>- Run DiskU [ ( &quot;/&quot;, &quot;&lt;size&gt;&quot; ) ] [] 20 - Run DiskU [ ( &quot;root&quot;, &quot;&lt;size&gt;&quot; ) ] [] 20 - Run DiskU [ ( &quot;/dev/root&quot;, &quot;&lt;size&gt;&quot; ) ] [] 20 - Run DiskU [ ( &quot;sda1&quot;, &quot;&lt;size&gt;&quot; ) ] [] 20 - Run DiskU [ ( &quot;/dev/sda1&quot;, &quot;&lt;size&gt;&quot; ) ] [] 20 </code></pre> <p>and calling</p> <pre><code>- Run DiskU [ ( &quot;/&quot;, &quot;&lt;size&gt;&quot; ), (&quot;/home&quot;, &quot;&lt;size&gt;&quot;) ] [] 20 </code></pre> <p>where <code>&quot;/home&quot;</code> is the <code>&quot;/dev/sda3&quot;</code> partition, works fine to get the information about <code>&quot;/home&quot;</code></p> <p>Reading Xmobar sources, i see that the list of the available partition is read from <code>&quot;/etc/mtab&quot;</code>. In my case, the <code>&quot;/etc/mtab&quot;</code> have de list of partitions below:</p> <pre><code>/dev/root / ext4 rw,relatime 0 0 ... /dev/sda3 /home ext4 rw,relatime 0 0 </code></pre> <p>but i don't get the DiskU function works...</p> <p>Any idea is welcome to solve this problem...</p> <p>thanks in advance!</p>
[ { "answer_id": 74186646, "author": "Victor", "author_id": 6630084, "author_profile": "https://Stackoverflow.com/users/6630084", "pm_score": 2, "selected": true, "text": "[ValidateNever]" }, { "answer_id": 74186788, "author": "Mohammad Aghazadeh", "author_id": 10546136, ...
2022/10/24
[ "https://Stackoverflow.com/questions/74186524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9062980/" ]
74,186,544
<p>I have a json structure as follows:</p> <pre><code>[ { &quot;apiId&quot;: 18211158, &quot;policyName0&quot;: &quot;cors&quot; }, { &quot;apiId&quot;: 18211158, &quot;policyName1&quot;: &quot;client-id-enforcement&quot; }, { &quot;apiId&quot;: 18211150, &quot;policyName0&quot;: &quot;client-id-enforcement&quot; }, { &quot;apiId&quot;: 18211162, &quot;policyName0&quot;: &quot;client-id-enforcement&quot; }, { &quot;apiId&quot;: 18211162, &quot;policyName1&quot;: &quot;cors&quot; }, { &quot;apiId&quot;: 18211162, &quot;policyName2&quot;: &quot;oauth&quot; } ] </code></pre> <p>I need to transform this into following using dataweave 2.0</p> <pre><code>[ { &quot;apiId&quot;: 18211158 &quot;policyName0&quot;: &quot;cors&quot;, &quot;policyName1&quot;: &quot;client-id-enforcement&quot;, }, { &quot;apiId&quot;: 18211150 &quot;policyName0&quot;: &quot;client-id-enforcement&quot;, }, { &quot;apiId&quot;: 18211162 &quot;policyName0&quot;: &quot;client-id-enforcement&quot;, &quot;policyName1&quot;: &quot;cors&quot;, &quot;policyName2&quot;: &quot;oAuth&quot;, } ] </code></pre> <p>Note that each apiID can have multiple policies and the policyName json attribute is generated and cal have values ranging from 1 to 9.</p> <p>How can I condense the json based on apiID as the key in dataweave?</p>
[ { "answer_id": 74186750, "author": "machaval", "author_id": 1472690, "author_profile": "https://Stackoverflow.com/users/1472690", "pm_score": 3, "selected": false, "text": "%dw 2.0\noutput application/json\n---\npayload \n groupBy ((value, key) -> value.apiId)\n pluck ((value, key,...
2022/10/24
[ "https://Stackoverflow.com/questions/74186544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4771802/" ]
74,186,553
<p>Here I'm trying to pass an id from component1 to my service and I'm using the subject to emit that id inside the service. I'm trying to subscribe to that subject from component2 to get the id. But I'm not able to get the id.</p> <p><strong>component1</strong></p> <pre><code> export class ContestUploadButtonComponent implements OnInit { contestId:any ngOnInit(): void { this.contestId = this.contest this.frontEnd.contestData(this.contestId) } } </code></pre> <p><strong>service</strong></p> <pre><code> @Injectable({ providedIn: 'root' }) export class FrontendService { constructor() { } contest = new Subject&lt;string&gt;() contestData(data:string){ this.contest.next(data) } dialogData():Observable&lt;string&gt;{ return this.contest.asObservable() } } </code></pre> <p><strong>component 2</strong></p> <pre><code> export class ContestUploadDialogComponent implements OnInit { file:File|any filePath!:string; contestId:string=&quot;&quot; constructor(private backEnd : BackendService,private frontEnd:FrontendService) { } ngOnInit(): void { this.frontEnd.dialogData().subscribe((contestId)=&gt;{ console.log(contestId); this.contestId = contestId }) } </code></pre>
[ { "answer_id": 74186750, "author": "machaval", "author_id": 1472690, "author_profile": "https://Stackoverflow.com/users/1472690", "pm_score": 3, "selected": false, "text": "%dw 2.0\noutput application/json\n---\npayload \n groupBy ((value, key) -> value.apiId)\n pluck ((value, key,...
2022/10/24
[ "https://Stackoverflow.com/questions/74186553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19051404/" ]
74,186,633
<p>I'm currently trying to have the input value automatically remove the any leading 0's that might come up for a some numbers. For example, in the snipper below, I have an onchange function that automically converts all numbers into integers and forces any negative values to 0. However when attempting to get rid of the leading 0, the input box doesn't change while the value stored inside the ngModel (number.num) accurately gets rid of the leading 0.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>angular.module('app1', []) // .controller('FormCtrl', function($scope) { $scope.number = {'num': 0}; $scope.numberOnChange = function() { $scope.number.num = parseInt($scope.number.num.toString(), 10) console.log($scope.number.num) if (!$scope.number.num || $scope.number.num &lt; 0) $scope.number.num = 0 } });</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"&gt;&lt;/script&gt; &lt;div ng-app=app1 ng-controller="FormCtrl"&gt; &lt;form&gt; &lt;input type=number ng-model="number.num" ng-change="numberOnChange()"&gt; &lt;/form&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74186750, "author": "machaval", "author_id": 1472690, "author_profile": "https://Stackoverflow.com/users/1472690", "pm_score": 3, "selected": false, "text": "%dw 2.0\noutput application/json\n---\npayload \n groupBy ((value, key) -> value.apiId)\n pluck ((value, key,...
2022/10/24
[ "https://Stackoverflow.com/questions/74186633", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20161657/" ]
74,186,683
<p>I have two data frames that look like this :</p> <pre><code> library(tidyverse) date = c(rep(as.Date(&quot;2022-01-01&quot;),4),rep(as.Date(&quot;2022-02-01&quot;),4),rep(as.Date(&quot;2022-03-01&quot;),3)) A = seq(1,11,1) B = seq(12,22,1) C = seq(23,33,1) symbol = c(rep(&quot;A&quot;,4),rep(&quot;B,C&quot;,4),rep(&quot;D,A&quot;,3)) df1 = tibble(date,A,B,C,symbol);df1 # A tibble: 11 × 5 date A B C symbol &lt;date&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;chr&gt; 1 2022-01-01 1 12 23 A 2 2022-01-01 2 13 24 A 3 2022-01-01 3 14 25 A 4 2022-01-01 4 15 26 A 5 2022-02-01 5 16 27 B,C 6 2022-02-01 6 17 28 B,C 7 2022-02-01 7 18 29 B,C 8 2022-02-01 8 19 30 B,C 9 2022-03-01 9 20 31 D,A 10 2022-03-01 10 21 32 D,A 11 2022-03-01 11 22 33 D,A </code></pre> <p>and the second one :</p> <pre><code> first = c(&quot;A&quot;,&quot;A&quot;,&quot;B&quot;,&quot;B&quot;,&quot;B&quot;) second = c(&quot;D&quot;,&quot;F&quot;,&quot;A&quot;,&quot;C&quot;,&quot;D&quot;) value = c(2,3,4,3,5) df2 = tibble(first,second,value);df2 # A tibble: 5 × 3 first second value &lt;chr&gt; &lt;chr&gt; &lt;dbl&gt; 1 A D 2 2 A F 3 3 B A 4 4 B C 3 5 B D 5 </code></pre> <p>I want from the first data frame to search the values of columns symbol in the first and second columns of data frame 2 (df2).If symbol in df1 has no pair to take the maximum value of columns A,B,C submatrix in df1 which is 26.</p> <p>If there is a match for a pair, for example B,C in df1 and df2 to take the minimum of row corresponding to value of df2 in df1.In my example B,C in column symbol exist in df2 and has the value 3 therefore in the third row of sub matrix corresponding to B,C in df1 is 7,18,29 and the minimum is 7. The for D,A I have to take the minimum in row 2 in the D,A sub matrix in df1 which is 10,21,32 with minimum 10.</p> <p>finally I want ideally the reported data frame to be like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>symbol</th> <th>calc</th> </tr> </thead> <tbody> <tr> <td>A</td> <td>26</td> </tr> <tr> <td>B,C</td> <td>7</td> </tr> <tr> <td>D,A</td> <td>10</td> </tr> </tbody> </table> </div> <p>How can I do this in R (using dplyr) ?</p>
[ { "answer_id": 74186846, "author": "sasfan_1924", "author_id": 20325073, "author_profile": "https://Stackoverflow.com/users/20325073", "pm_score": -1, "selected": false, "text": "df1 %>% \n left_join(\n df2 %>% \n mutate(symbol = paste0(first, “,”, second), \n by = “symbol”...
2022/10/24
[ "https://Stackoverflow.com/questions/74186683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16346449/" ]
74,186,710
<p>Over the last few weeks, any time I get a merge conflict I get a fatal error.</p> <p>Steps to reproduce:</p> <ol> <li>checkout branch name</li> <li>git pull origin master</li> </ol> <p>At this point, my VScode would show the conflict(s) in the file and give me the opportunity of which to pick. This has happened for years..</p> <p>But now, I get this error instead</p> <pre><code> * branch master -&gt; FETCH_HEAD fatal: Not possible to fast-forward, aborting. </code></pre> <p>VScode won't show me the conflict, there appears to be no way to resolve it except for deleting entire branch, creating a new branch from master, then rebuilding all my changes.</p>
[ { "answer_id": 74186959, "author": "torek", "author_id": 1256452, "author_profile": "https://Stackoverflow.com/users/1256452", "pm_score": 1, "selected": false, "text": "fatal: Not possible to fast-forward, aborting.\n" } ]
2022/10/24
[ "https://Stackoverflow.com/questions/74186710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5200574/" ]
74,186,717
<p>I am trying to filter out records where one specific field has special characters with words in them.</p> <p>For example:</p> <pre class="lang-none prettyprint-override"><code>-[ RECORD 1 ]--------------+------------------------------ id | 3151 description | Manual add from SCCM mac_address | d4258be8d064 status | Unknown mac_vendor | Intel Corporate added_by | Policy Manager added_at | 2019-02-19 14:29:21.802413+00 updated_at | 2022-10-19 10:57:15.960282+00 attributes | {&quot;Our Device&quot;: &quot;true&quot;} extras | org_id | 1 permit_id | 1 agentless_managed_endpoint | 0 </code></pre> <p>I tried</p> <pre><code>select * from tips_endpoints where description = 'Manual add from SCCM' AND attributes = '{&quot;Our Device&quot;: &quot;true&quot;}'; </code></pre> <p>but it fails.</p> <p>I need to be able to find records where attributes has value = {&quot;Our Device&quot;: &quot;true&quot;}</p>
[ { "answer_id": 74186744, "author": "Andrey Bessonov", "author_id": 4546382, "author_profile": "https://Stackoverflow.com/users/4546382", "pm_score": 1, "selected": true, "text": "select * \nfrom tips_endpoints \nwhere description = 'Manual add from SCCM' \n AND attributes Like '%{\"Our ...
2022/10/24
[ "https://Stackoverflow.com/questions/74186717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20325023/" ]
74,186,749
<p>This is my current screen. I need to add a loading spinner so that the user doesn't need to wait for 5 seconds until the data is sent to the back and returns the expected response. I added a comment where I call the function &quot;uploadImage&quot; and it's going to send an image to my back and return a status code. With that status code, I display different popups. However, the time between the user pressing the button and the popups appearing is around 5 seconds depending on the internet connection. I would like to display a loading spinning animation until the popups appear with the result. Thanks for the help!</p> <pre><code>import 'dart:convert'; import 'dart:ffi'; import 'dart:io'; import 'package:camera/camera.dart'; import 'package:http/http.dart' as http; import 'package:flutter/material.dart'; import 'package:geolocator/geolocator.dart'; import 'package:intl/intl.dart'; import 'package:stopfire/home.dart'; import 'camera_screen.dart'; class ConfirmationScreen extends StatefulWidget { final XFile? pictureFile; final Position? position; const ConfirmationScreen({this.pictureFile, this.position, Key? key}) : super(key: key); @override State&lt;ConfirmationScreen&gt; createState() =&gt; _ConfirmationScreenState(); } class _ConfirmationScreenState extends State&lt;ConfirmationScreen&gt; { createAlertDialog(BuildContext context){ return showDialog(context: context, builder: (context) { return AlertDialog( title: const Text(&quot;¡Tu alerta fue enviada!&quot;), content: ElevatedButton( style: ElevatedButton.styleFrom( primary: Colors.red, textStyle: const TextStyle(color: Colors.white) ), onPressed: (){ Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) =&gt; const HomePage(), ), ); }, child: const Text(&quot;VOLVER&quot;),), ); }); } createErrorAlertDialog(BuildContext context){ return showDialog(context: context, builder: (context) { return AlertDialog( title: const Text(&quot;Hubo un error y no recibimos la imagen, vuelve a intentarlo&quot;), content: ElevatedButton( style: ElevatedButton.styleFrom( primary: Colors.red, textStyle: const TextStyle(color: Colors.white) ), onPressed: (){ Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) =&gt; const HomePage(), ), ); }, child: const Text(&quot;VOLVER&quot;),), ); }); } Future&lt;int&gt; uploadImage ()async{ var stream = http.ByteStream(widget.pictureFile!.openRead()); stream.cast(); var length = await widget.pictureFile!.length(); //var uri = Uri.parse('http://10.0.2.2:5000/analyze'); //var uri = Uri.parse(&quot;http://172.20.10.4:5000/analyze&quot;); var uri = Uri.parse(&quot;http://10.230.61.125:5000/analyze&quot;); var request = http.MultipartRequest('POST', uri); request.files.add( http.MultipartFile( 'file', File(widget.pictureFile!.path).readAsBytes().asStream(), File(widget.pictureFile!.path).lengthSync(), filename: widget.pictureFile!.path.split(&quot;/&quot;).last ) ); String date = DateFormat(&quot;dd/MM/yy HH:mm:ss&quot;).format(DateTime.now()); request.fields['taken_at'] = date ; request.fields['latitude'] = widget.position!.latitude.toString(); request.fields['longitude'] = widget.position!.longitude.toString(); request.fields['id_camera'] = &quot;App StopFire&quot; ; request.fields['camera_type'] = &quot;Punto móvil&quot; ; request.fields['zone'] = 'Patrullero' ; var response = await http.Response.fromStream(await request.send()).catchError((onError) =&gt; 500); var status = response.statusCode; return status; } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text(&quot;Confirmar&quot;)), body: Column( children: [ Image.file(File(widget.pictureFile!.path)), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ ElevatedButton( style: ElevatedButton.styleFrom( primary: Colors.red, textStyle: const TextStyle(color: Colors.white) ), onPressed: (){ Navigator.pop(context); }, child: const Text(&quot;VOLVER&quot;),), const Padding( padding: EdgeInsets.fromLTRB(30.0,0,0,0)), ElevatedButton( style: ElevatedButton.styleFrom( primary: Colors.green, textStyle: const TextStyle(color: Colors.white) ), // Image.file(File(widget.pictureFile!.path)) onPressed: () async { final status = await uploadImage(); if (status == 200){ createAlertDialog(context); } else { createErrorAlertDialog(context); } }, child: const Text(&quot;ENVIAR&quot;)) ], ), ], ), ); } } </code></pre>
[ { "answer_id": 74186744, "author": "Andrey Bessonov", "author_id": 4546382, "author_profile": "https://Stackoverflow.com/users/4546382", "pm_score": 1, "selected": true, "text": "select * \nfrom tips_endpoints \nwhere description = 'Manual add from SCCM' \n AND attributes Like '%{\"Our ...
2022/10/24
[ "https://Stackoverflow.com/questions/74186749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17312204/" ]
74,186,757
<p>I'm trying to connect to my MongoDB localhost but it just won't connect. What happens is when I go to <code>/admin</code>, it just keeps loading and I get no messages, no nothing in the logs. I have no idea why. This is my router file that uses the connection:</p> <pre class="lang-js prettyprint-override"><code>const express = require('express'); const debug = require('debug')('app:adminRouter'); const mongoose = require('mongoose'); const users = require('../data/users.json'); const adminRouter = express.Router(); adminRouter.route('/').get((req, res) =&gt; { const url = &quot;mongodb://localhost:27017&quot;; // process.env.DBURL const dbName = &quot;workplace_incident_reporter&quot;; (async function mongo(){ let client; try { client = await mongoose.connect(url, { useNewUrlParser: true, useUnifiedTopology: true }); debug('Connected to mongoDB'); const db = client.db(dbName); const response = await db.collection('Users').insertMany(users); res.json = response; } catch (error){ debug(error.stack); } }) }); module.exports = adminRouter; </code></pre> <p>Here is a picture of my MongoDB Compass window. This is only for URL references: <a href="https://i.stack.imgur.com/dBxym.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dBxym.png" alt="MongoDB Compass Window" /></a></p>
[ { "answer_id": 74187206, "author": "POURiA", "author_id": 2749367, "author_profile": "https://Stackoverflow.com/users/2749367", "pm_score": -1, "selected": false, "text": "const db_url = 'mongodb://localhost:27017'\nconst db_main = 'db-main'\n\nconst connectDB = mongoose.connect(\n `${d...
2022/10/24
[ "https://Stackoverflow.com/questions/74186757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15067358/" ]
74,186,791
<p>Let's say I have a table labeled employees and it looks like so</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>date</th> <th>employee id</th> </tr> </thead> <tbody> <tr> <td>4/1/2022</td> <td>9</td> </tr> <tr> <td>4/1/2022</td> <td>8</td> </tr> <tr> <td>3/1/2022</td> <td>9</td> </tr> <tr> <td>3/1/2022</td> <td>8</td> </tr> <tr> <td>3/1/2022</td> <td>7</td> </tr> <tr> <td>2/1/2022</td> <td>9</td> </tr> <tr> <td>2/1/2022</td> <td>8</td> </tr> <tr> <td>2/1/2022</td> <td>7</td> </tr> <tr> <td>1/1/2022</td> <td>9</td> </tr> <tr> <td>1/1/2022</td> <td>8</td> </tr> <tr> <td>1/1/2022</td> <td>7</td> </tr> <tr> <td>1/1/2022</td> <td>6</td> </tr> <tr> <td>1/1/2022</td> <td>5</td> </tr> </tbody> </table> </div> <p>I'd like for my final output to look like below</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>date</th> <th>departures</th> </tr> </thead> <tbody> <tr> <td>4/1/2022</td> <td>NULL</td> </tr> <tr> <td>3/1/2022</td> <td>1</td> </tr> <tr> <td>2/1/2022</td> <td>0</td> </tr> <tr> <td>1/1/2022</td> <td>2</td> </tr> </tbody> </table> </div> <p>Essentially, if the employee is not found on the next upcoming month, it's counting it as a departure for the current month. I already am calculating this with the following query:</p> <pre><code>WITH MONTHLY_COUNT(DTE, EMP_COUNT) AS( SELECT [DATE], COUNT(1) AS [COUNT] FROM employees A GROUP BY [DATE]),raw_data(EMPLOYEE, DATE) AS( SELECT A.EMPLOYEE, [DATE] FROM employees A),RANKING(DTE, EMP_COUNT, RANKING) AS( SELECT A.DTE, A.EMP_COUNT, A.RANKING FROM( SELECT TOP(6) ---pick the most recent x months A.DTE, A.EMP_COUNT, RANK() OVER(ORDER BY A.DTE DESC) AS [RANK] FROM MONTHLY_COUNT AS A )A(DTE, EMP_COUNT, RANKING))SELECT A.DTE, CASE WHEN A.DTE = B.DTE THEN B.SEPARATIONS WHEN A.DTE = C.DTE THEN C.SEPARATIONS WHEN A.DTE = D.DTE THEN D.SEPARATIONS END AS SEPARATIONS FROM( SELECT TOP(6) --pick the most recent x months A.DTE FROM MONTHLY_COUNT A ORDER BY A.DTE DESC )A --COMPARE MONTH RANK 2 AND 1 LEFT JOIN( SELECT A.DTE, SUM(CASE WHEN B.EMPLOYEE IS NULL THEN 1 ELSE 0 END) AS SEPARATIONS FROM( SELECT * FROM RANKING A LEFT JOIN raw_data B ON A.DTE = B.DATE WHERE A.RANKING = '2' ----this is what I want to automate )A LEFT JOIN( SELECT * FROM RANKING A LEFT JOIN raw_data B ON A.DTE = B.DATE WHERE A.RANKING = '1' ----this is what I want to automate )B ON A.Employee = B.Employee GROUP BY A.DTE )B ON B.DTE = A.DTE --COMPARE MONTH RANK 3 AND 2 LEFT JOIN( SELECT A.DTE, SUM(CASE WHEN B.EMPLOYEE IS NULL THEN 1 ELSE 0 END) AS SEPARATIONS FROM( SELECT * FROM RANKING A LEFT JOIN raw_data B ON A.DTE = B.DATE WHERE A.RANKING = '3' )A LEFT JOIN( SELECT * FROM RANKING A LEFT JOIN raw_data B ON A.DTE = B.DATE WHERE A.RANKING = '2' )B ON A.Employee = B.Employee GROUP BY A.DTE )C ON C.DTE = A.DTE --COMPARE MONTH RANK 4 AND 3 LEFT JOIN( SELECT A.DTE, SUM(CASE WHEN B.EMPLOYEE IS NULL THEN 1 ELSE 0 END) AS SEPARATIONS FROM( SELECT * FROM RANKING A LEFT JOIN raw_data B ON A.DTE = B.DATE WHERE A.RANKING = '4' )A LEFT JOIN( SELECT * FROM RANKING A LEFT JOIN raw_data B ON A.DTE = B.DATE WHERE A.RANKING = '3' )B ON A.Employee = B.Employee GROUP BY A.DTE )D ON D.DTE = A.DTE ORDER BY A.DTE DESC </code></pre> <p>The main problem is how can I automate this to where I'm not explicitly comparing months 2 and 1, and then comparing months 3 and 2, and then comparing months 4 and 3, and so on ?</p>
[ { "answer_id": 74187206, "author": "POURiA", "author_id": 2749367, "author_profile": "https://Stackoverflow.com/users/2749367", "pm_score": -1, "selected": false, "text": "const db_url = 'mongodb://localhost:27017'\nconst db_main = 'db-main'\n\nconst connectDB = mongoose.connect(\n `${d...
2022/10/24
[ "https://Stackoverflow.com/questions/74186791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6062534/" ]
74,186,793
<p>So I'm new to programming and I'm trying to learn how to code in uni.</p> <p>We just started learning classes in python and I can't solve this problem.</p> <p>I need to create a method reflect-x so that the variable y is negative. Here is the code I wrote</p> <pre><code>class Point: def __init__(self,x,y): self.x=x self.y=y def reflect_x(self): if self.y &lt; 0: self.y = self.y else: self.y = -abs(self.y) def print(self): a = self.x , self.y print(tuple(a)) </code></pre> <p>And this is what the site uses to check if the code is correct</p> <pre><code> p1 = Point(1, 4) p1.reflect_x().print() p2 = Point(-3, 5) p2.reflect_x().print() p3 = Point(-3, -5) p3.reflect_x().print() </code></pre> <p>I keep getting &quot; AttributeError: 'NoneType' object has no attribute 'print' &quot; , and I don't know what to do.</p>
[ { "answer_id": 74187206, "author": "POURiA", "author_id": 2749367, "author_profile": "https://Stackoverflow.com/users/2749367", "pm_score": -1, "selected": false, "text": "const db_url = 'mongodb://localhost:27017'\nconst db_main = 'db-main'\n\nconst connectDB = mongoose.connect(\n `${d...
2022/10/24
[ "https://Stackoverflow.com/questions/74186793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20193953/" ]
74,186,834
<p>I know how to print to console one line out of time. anyone that can help me learn how to print console word by word</p> <pre><code>private void intro() { try { List&lt;String&gt; allLines = Files.readAllLines(Paths.get(&quot;src/resources/GameStoryIntro.txt&quot;)); for (String line : allLines) { Thread.sleep(2000); System.out.println(&quot;\u001B[31m&quot; + line + &quot;\u001B[0m&quot;); } } catch (IOException | InterruptedException e) { e.printStackTrace(); } subMenu(); } </code></pre>
[ { "answer_id": 74187206, "author": "POURiA", "author_id": 2749367, "author_profile": "https://Stackoverflow.com/users/2749367", "pm_score": -1, "selected": false, "text": "const db_url = 'mongodb://localhost:27017'\nconst db_main = 'db-main'\n\nconst connectDB = mongoose.connect(\n `${d...
2022/10/24
[ "https://Stackoverflow.com/questions/74186834", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12270193/" ]
74,186,878
<p>is Where a way to style native html video attributes in React? I was googling entire day , I found some library for that but when I tried it apparently its not working anymore. any tips?</p>
[ { "answer_id": 74186958, "author": "TinkerTenorSoftwareGuy", "author_id": 5129424, "author_profile": "https://Stackoverflow.com/users/5129424", "pm_score": 0, "selected": false, "text": "const YoutubeEmbed = ({ embedId }) => (\n <div className=\"video-responsive\" style={{ color: 'blue'...
2022/10/24
[ "https://Stackoverflow.com/questions/74186878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20121566/" ]
74,186,893
<p>I need to make around 20K API calls, each one returns a CSV file and then on that file I have to perform some operations, finally, concatenate all the results into a single dataframe.</p> <p>I've completed this task sequentially, but the issue is that each API Call lasts around 1sec and it takes around 6h to complete. So, I would like parallelize the task as I can make up to 100 simulatenous API calls and up to 1000 calls per minute.</p> <p>I've tried several stuff, but I'm struggling... I have accomplished to parallelize the tasks and complete 200 API calls in about 8 seconds, but I can't concat all the results into a single dataframe... Would appreciate any help.</p> <p>Thanks! :)</p> <p>This is what i have:</p> <pre><code>from concurrent.futures import ThreadPoolExecutor </code></pre>
[ { "answer_id": 74186958, "author": "TinkerTenorSoftwareGuy", "author_id": 5129424, "author_profile": "https://Stackoverflow.com/users/5129424", "pm_score": 0, "selected": false, "text": "const YoutubeEmbed = ({ embedId }) => (\n <div className=\"video-responsive\" style={{ color: 'blue'...
2022/10/24
[ "https://Stackoverflow.com/questions/74186893", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13739594/" ]
74,186,915
<p>I have 2 react components X and Y. X holds state which is calculated through different types of logic and through user input. Users can click on a button in X which will unmount X and render Y. Now there also exists a button on Y which when clicked unmounts Y and renders X again, however X no longer has its state because it was lost when the component was unmounted when we first rendered Y. How can I ensure that X &quot;holds&quot; onto its state even when it gets unmounted?</p> <p>I've tried passing X's state as a prop to Y, but I'm not sure if I can pass this prop on Y back to X when Y unmounts?</p>
[ { "answer_id": 74186958, "author": "TinkerTenorSoftwareGuy", "author_id": 5129424, "author_profile": "https://Stackoverflow.com/users/5129424", "pm_score": 0, "selected": false, "text": "const YoutubeEmbed = ({ embedId }) => (\n <div className=\"video-responsive\" style={{ color: 'blue'...
2022/10/24
[ "https://Stackoverflow.com/questions/74186915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18457038/" ]
74,186,948
<p>The problems are:</p> <ol> <li>Upon typing n to stand and winning, it doesnt ask the user again if they want to play a game of blackjack.</li> <li>And upon winning it also does not ask the user if it wants to play, straight up just starts the game once again.</li> </ol> <p>Please help me solve this, I lost all hope while debugging... p.s. #clear and #art are placeholders</p> <pre><code>import random active_game = True # - Active flag def restart_game(): # clear() # print(logo) cards = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10] cards_player = [random.choice(cards), random.choice(cards)] cards_dealer = [random.choice(cards), random.choice(cards)] def total(cards_entity): # count someone's cards return sum(cards_entity) print(f&quot; Your cards: {cards_player}, current score: {total(cards_player)}&quot;) print(f&quot; Dealer's first card: {cards_dealer[0]}&quot;) def final_score(): print(f&quot; Your final hand: {cards_player}, final score: {total(cards_player)}&quot;) print(f&quot; Dealer's final hand: {cards_dealer}, final score: {total(cards_dealer)}&quot;) def winner(): #-checks result of move if total(cards_player) == 21: # player got 21 if total(cards_dealer) == 21: print(&quot;You both scored a blackjack. It's a draw! ‍♂️&quot;) final_score() restart_game() else: print(&quot;You scored a blackjack. You won! &quot;) final_score() restart_game() if total(cards_player) &gt; 21: # player went over 21 if 11 in cards_player: i = cards_player.index(11) cards_player[i] = 1 else: print(&quot;You went over. You lost! &quot;) final_score() restart_game() if total(cards_player) &lt; 21: # player got less than 21 if total(cards_dealer) &gt; 21: print(&quot;The opponent went over. You won! &quot;) final_score() restart_game() if total(cards_dealer) == 21: print(&quot;The opponent got 21! You lost! &quot;) final_score() restart_game() def move(): if input(&quot;Type 'y' to get another card, type 'n' to pass: &quot;) == &quot;y&quot;: cards_player.append(random.choice(cards)) cards_dealer.append(random.choice(cards)) print(f&quot;Your cards: {cards_player}, current score: {total(cards_player)}&quot;) print(f&quot;Dealer's first card: {cards_dealer[0]}&quot;) winner() else: cards_dealer.append(random.choice(cards)) winner() move() while input(&quot;Would you like to play a game of Black Jack? Type 'y' or 'n': &quot;) == &quot;y&quot;: restart_game() print(&quot;I'm out!&quot;) </code></pre>
[ { "answer_id": 74186958, "author": "TinkerTenorSoftwareGuy", "author_id": 5129424, "author_profile": "https://Stackoverflow.com/users/5129424", "pm_score": 0, "selected": false, "text": "const YoutubeEmbed = ({ embedId }) => (\n <div className=\"video-responsive\" style={{ color: 'blue'...
2022/10/24
[ "https://Stackoverflow.com/questions/74186948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20325128/" ]
74,186,971
<p>I'm new here and I really need help with this thing: I have 2 columns called Recruits and Spawners and I want to create a third one with a combination of this two, like this</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">Spawners</th> <th style="text-align: left;">Recruits</th> <th style="text-align: left;">Class</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">85.640176</td> <td style="text-align: left;">0.000000</td> <td style="text-align: left;">Spawners</td> </tr> <tr> <td style="text-align: left;">0.000000</td> <td style="text-align: left;">38.30213</td> <td style="text-align: left;">Recruits</td> </tr> <tr> <td style="text-align: left;">275.391055</td> <td style="text-align: left;">22.031284</td> <td style="text-align: left;">Both</td> </tr> </tbody> </table> </div> <p>The column &quot;Class&quot; is what I need to create, with these condition:</p> <ul> <li>If &quot;Spawners&quot; = n and &quot;Recruits&quot; = 0, then &quot;Class&quot; = Spawners</li> <li>If &quot;Spawners&quot; = 0 and &quot;Recruits&quot; = n, then &quot;Class&quot; = Recruits</li> <li>If &quot;Spawners&quot; = n and &quot;Recruits&quot; = n, then &quot;Class&quot; = Both</li> </ul> <p>Thank you very much</p>
[ { "answer_id": 74187089, "author": "Jilber Urbina", "author_id": 1315767, "author_profile": "https://Stackoverflow.com/users/1315767", "pm_score": 3, "selected": true, "text": "case_when" }, { "answer_id": 74187103, "author": "br00t", "author_id": 4028717, "author_pro...
2022/10/24
[ "https://Stackoverflow.com/questions/74186971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20325165/" ]
74,187,000
<p>I'm attempting to search each of the objects listed below from my dataset to see if they contain a value and if they do have that value to add the entire object into a new array.</p> <p>Example:</p> <p>Search List of Objects for Data &quot;Continuous&quot;, if that data exists (Which it does in Doormerica and Hager) then take the entire object &quot;Doormerica&quot; and &quot;Hager&quot; and put the entire thing into a new array.</p> <pre><code>{ &quot;Doormerica&quot;: { &quot;Floor Stops&quot;: [], &quot;Overhead Stop&quot;: [], &quot;Pull&quot;: [], &quot;Chain Stop&quot;: [], &quot;Continuous&quot;: [ &quot;ALX&quot;, &quot;AL&quot;, &quot;QR&quot; ], &quot;Kick&quot;: [], &quot;Back to Back Pull&quot;: [], &quot;Concealed&quot;: [], &quot;Butt&quot;: [], &quot;Surface Mount&quot;: [], &quot;Mop&quot;: [], &quot;Armor&quot;: [], &quot;Push&quot;: [], &quot;Wall Stops&quot;: [] }, &quot;Schlage&quot;: { &quot;Mortise&quot;: [], &quot;Cylindrical&quot;: [ &quot;ALX&quot;, &quot;AL&quot;, &quot;QR&quot; ], &quot;Deadbolt&quot;: [], &quot;Dummy&quot;: [], &quot;Interconnected&quot;: [], &quot;Cylinders&quot;: [] }, &quot;Pemko&quot;: { &quot;Sweeps&quot;: [ &quot;345AV&quot; ], &quot;Permiter Seal&quot;: [ &quot;303AS&quot; ], &quot;Thresholds&quot;: [ &quot;170A&quot; ], &quot;Rain Drip&quot;: [ &quot;346C&quot; ], &quot;Astragal&quot;: [] }, &quot;LCN&quot;: { &quot;Surface Mount&quot;: [ &quot;4040XP&quot; ], &quot;Concealed&quot;: [] }, &quot;Hager&quot;: { &quot;Butt&quot;: [], &quot;Continuous&quot;: [] } } </code></pre>
[ { "answer_id": 74187089, "author": "Jilber Urbina", "author_id": 1315767, "author_profile": "https://Stackoverflow.com/users/1315767", "pm_score": 3, "selected": true, "text": "case_when" }, { "answer_id": 74187103, "author": "br00t", "author_id": 4028717, "author_pro...
2022/10/24
[ "https://Stackoverflow.com/questions/74187000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17347868/" ]
74,187,014
<p>My dataframe looks like this</p> <pre><code>category value1 value2 A. 20. 30. B. 40. 50. A. 60. 70. B. 80. 90. C. 10. 10. D. 20. 20. </code></pre> <p>I want to create a new column that has the value of either <code>value1</code> or <code>value2</code> based on a condition relative to <code>category</code>. For example, if <code>category</code> is <code>A</code> then store <code>value1</code>, if <code>category</code> is <code>B</code> then store <code>value2</code>,if <code>else</code> then store <code>nan</code>. I expect an output like this:</p> <pre><code>category value1 value2 new_col A. 20. 30. 20. B. 40. 50. 50. A. 60. 70. 60. B. 80. 90. 90. C. 10. 10. nan D. 20. 20. nan </code></pre> <p>How can I do that?</p>
[ { "answer_id": 74187037, "author": "Naveed", "author_id": 3494754, "author_profile": "https://Stackoverflow.com/users/3494754", "pm_score": 1, "selected": false, "text": "# np.select and define list of condition with corresponding values\ndf['value3']=(np.select([df['category'].eq('A.'),...
2022/10/24
[ "https://Stackoverflow.com/questions/74187014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20094033/" ]
74,187,060
<p>So I have a JToken. It might have (or not) a JToken inside. Let's call it &quot;client&quot;.</p> <p>it can be null.</p> <p>Right now,I'm using this code to check for existance and null :</p> <pre><code>var client = MyJToken[&quot;client&quot;]; if (client != null &amp;&amp; client is not JValue) </code></pre> <p>But it just feels wrong. Why can't I use &quot;MyJToken[&quot;client&quot;] ?? &quot;</p> <p>Anyone has an idead how to to that check using null propagation ?</p> <p>Edit Example.</p> <p>So let’s say you have this JSON :</p> <p><a href="https://pastebin.com/nSpP6LEQ" rel="nofollow noreferrer">https://pastebin.com/nSpP6LEQ</a></p> <p>In “invoiceds” array, you’ll see the first is null, but second has value.</p> <p>The JToken is at the level of one invoiceds entry.</p> <p>So the naïve thing to write would be mytoken[“task”]?[“id”]</p> <p>But that will fail, because the first record is null, so mytoken[“task”] is NOT NULL, but has a JValue of null.</p> <p>So my question is : Is there anyway avoid to that check for JValue and null. And write something close to mytoken[“task”]?[“id”].</p>
[ { "answer_id": 74187455, "author": "Enrico Massone", "author_id": 4331637, "author_profile": "https://Stackoverflow.com/users/4331637", "pm_score": 0, "selected": false, "text": "using Newtonsoft.Json.Linq;\n\nnamespace ConsoleApp1\n{\n internal class Program\n {\n static void Main(...
2022/10/24
[ "https://Stackoverflow.com/questions/74187060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1580464/" ]
74,187,080
<p>I want to preface this with the following: I'm super new to programming. So my brain is still trying to figure all of the pieces of the puzzle out. Currently, I'm trying to sharpen my skills by writing some basic console applications. I'm currently writing an application to actually help a friend who hosts tournaments. He simply would like something that will accept input and generate random numbers equal to the inputted value. I have this part functional and working with the code below.</p> <pre><code>using System; using System.Collections.Generic; Console.WriteLine(&quot;Please Enter the number of participants!&quot;); var rand = new Random(); Console.WriteLine(&quot;Please Enter the number of participants!&quot;); int numberofParticipants = Convert.ToInt32(Console.ReadLine()); List&lt;int&gt; listNumbers = new List&lt;int&gt;(); int number; for (int i = 0; i &lt; numberofParticipants; i++) { do { number = rand.Next(1, 20); } while (listNumbers.Contains(number)); listNumbers.Add(number); } listNumbers.ForEach(Console.WriteLine); Console.ReadLine(); </code></pre> <p>The thing is I would like to take this a step farther by implementing a mechanism that caps the max value to the same value of the number of participants.</p> <p>So in other words this section of code is causing me issues:</p> <pre><code> number = rand.Next(1, 20); </code></pre> <p>I have attempted to change 20 for the numberofParticipants variable but I get an error in regards to it not being a signed 32 bit int. So in the end the user should be able to input a number, say 10. This will then output 10 numbers (1-10) with the max value of 10. So in essence a random order of numbers from 1-10.</p> <p>Is there any easy solution for this that I'm not aware of?</p> <p>Thank you in advance for any input and direction for this total newb.</p>
[ { "answer_id": 74188511, "author": "mkmkmk", "author_id": 20154538, "author_profile": "https://Stackoverflow.com/users/20154538", "pm_score": 1, "selected": false, "text": "using System;\nusing System.Collections.Generic;\n\n\nConsole.WriteLine(\"Please Enter the number of participants!\...
2022/10/24
[ "https://Stackoverflow.com/questions/74187080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20325269/" ]
74,187,097
<p>I have been trying to upgrade a library which has a bunch of geometric operations for scalars so they will work with numpy arrays as well. While doing this I noticed some strange behaviour with numpy divide.</p> <p>In original code checks a normalised difference between to variables if neither variable is zero, swapping across to numpy this ended up looking something like:</p> <pre class="lang-py prettyprint-override"><code>import numpy as np a = np.array([0, 1, 2, 3, 4]) b = np.array([1, 2, 3, 0, 4]) o = np.zeros(len(a)) o = np.divide(np.subtract(a, b), b, out=o, where=np.logical_and(a != 0, b != 0)) print(f'First implementation: {o}') </code></pre> <p>where I passed in a output buffer initialised to zero for instances which could not be calculated; this returns:</p> <pre><code>First implementation: [ 0. -0.5 -0.33333333 0. 0. ] </code></pre> <p>I had to slightly modify this for scalars as <code>out</code> required an array, but it seemed fine.</p> <pre class="lang-py prettyprint-override"><code>a = 0 b = 4 o = None if np.isscalar(a) else np.zeros(len(a)) o = np.divide(np.subtract(a, b), b, out=o, where=np.logical_and(b != 0, a != 0)) print(f'Modified out for scalar: {o}') </code></pre> <p>returns</p> <pre><code>Modified out for scalar: 0.0. </code></pre> <p>Then ran this through some test functions and found a lot of them failed. Digging into this, I found that the first time I call the divide with a scalar with <code>where</code> set to <code>False</code> the function returns zero, but if I called it again, the second time it returns something unpredictable.</p> <pre><code>a = 0 b = 4 print(f'First divide: {np.divide(b, a, where=False)}') print(f'Second divide: {np.divide(b, a, where=False)}') </code></pre> <p>returns</p> <pre><code>First divide: 0.0 Second divide: 4.0 </code></pre> <p>Looking at the documentation, it says &quot;locations within it where the condition is False will remain uninitialized&quot;, so I guess numpy as some internal buffer which is initially set to zero then subsequently it ends up carrying over an earlier intermediate value.</p> <p>I am struggling to see how I can use <code>divide</code> with or without a <code>where</code> clause; if I use <code>where</code> I get an unpredictable output and if I don't I can't protect against divide by zero. Am I missing something or do I just need to have a different code path in these cases? I realise I'm half way to a different code path already with the <code>out</code> variable.</p> <p>I would be grateful for any advice.</p>
[ { "answer_id": 74199304, "author": "John M.", "author_id": 18950910, "author_profile": "https://Stackoverflow.com/users/18950910", "pm_score": 0, "selected": false, "text": "np.divide" }, { "answer_id": 74200206, "author": "tdelaney", "author_id": 642070, "author_prof...
2022/10/24
[ "https://Stackoverflow.com/questions/74187097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18950910/" ]
74,187,131
<p>I'm currently using AWS AppSync, however the question applies to general Graphql / Javascript / API.</p> <p>I have the following nested data that I'm passing as an argument:</p> <pre><code>const DUMMY_DATA = [ ['First Name', 'Last Name', 'company', 'email', 'phone', 'Address', 'City', 'State', 'Zip Code'], ['Lambert', 'Beckhouse', 'StackOverflow', 'lbeckhouse0@stackoverflow.com', '512-555-1738', '316 Arapahoe Way', 'Austin', 'TX', '78721'], ['Maryanna', 'Vassman', 'CDBABY', 'mvassman1@cdbaby.com', '479-204-8976', '1126 Troy Way', 'Fort Smith', 'AR', '72916'] ] </code></pre> <p>I'm passing the above, as is, to my api, which looks something like this:</p> <pre><code>try { await doAPIWork({data: DUMMY_DATA}) } catch (err) { console.error(err) } </code></pre> <p>However when it reaches my backend I'm unable to properly iterate through the nested arrays.</p> <p>The nested array comes back as typeof String, and I'm unable to properly convert it back to an array... For instance DUMMY_DATA[0] comes back as ['First Name', 'Last Name', 'company' ....] with <strong>typeof string</strong> .</p> <p>I know I'm either missing a step that I need to take before sending the data, or I'm failing to properly convert the string back to an array.</p> <p>Would really appreciate any help on this!</p> <p>Also: my current schema is</p> <pre><code>type Mutation { doAPIWork(data: [String]): String @function(name: &quot;doAPIWork-dev&quot;) } and Ive also tried type Mutation { doAPIWork(data: [AWSJSON]): String @function(name: &quot;doAPIWork-dev&quot;) } </code></pre>
[ { "answer_id": 74187168, "author": "Michel Floyd", "author_id": 2805154, "author_profile": "https://Stackoverflow.com/users/2805154", "pm_score": 1, "selected": false, "text": "JSON.parse(DUMMY_DATA)" }, { "answer_id": 74187558, "author": "elguapo", "author_id": 8304719, ...
2022/10/24
[ "https://Stackoverflow.com/questions/74187131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8304719/" ]
74,187,140
<p>Why is e.target.value undefined when logged to the console in this very simple component? The value is defined within the element so I don't understand why e.target returns the value as undefined.</p> <pre><code> const NavBar = () =&gt; { const handleClick = (e) =&gt; { console.log(e) } return ( &lt;div id=&quot;navbar&quot;&gt; &lt;nav class=&quot;navbar navbar-expand-lg navbar-light bg-light&quot;&gt; &lt;div class=&quot;container-fluid&quot;&gt; &lt;button class=&quot;navbar-toggler&quot; type=&quot;button&quot; data-bs-toggle=&quot;collapse&quot; data-bs-target=&quot;#navbarNavAltMarkup&quot; aria-controls=&quot;navbarNavAltMarkup&quot; aria-expanded=&quot;false&quot; aria-label=&quot;Toggle navigation&quot;&gt; &lt;span class=&quot;navbar-toggler-icon&quot;&gt;&lt;/span&gt; &lt;/button&gt; &lt;div class=&quot;collapse navbar-collapse&quot; id=&quot;navbarNavAltMarkup&quot;&gt; &lt;div class=&quot;navbar-nav&quot;&gt; &lt;a class=&quot;nav-link active&quot; aria-current=&quot;page&quot; href=&quot;/home&quot; onClick={(e) =&gt; handleClick(e.target.value)}&gt;Home&lt;/a&gt; &lt;a class=&quot;nav-link&quot; aria-current=&quot;page&quot; value={1} onClick={(e) =&gt; handleClick(e.target.value)} &gt; About&lt;/a&gt; &lt;a class=&quot;nav-link&quot; aria-current=&quot;page&quot; value={2} onClick={(e) =&gt; handleClick(e.target.value)} &gt; Contact&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/nav&gt; &lt;/div&gt; ) } export default NavBar </code></pre>
[ { "answer_id": 74187158, "author": "Konrad", "author_id": 5089567, "author_profile": "https://Stackoverflow.com/users/5089567", "pm_score": -1, "selected": false, "text": "getAttribute" }, { "answer_id": 74187210, "author": "Frédéric Perron", "author_id": 9867351, "au...
2022/10/24
[ "https://Stackoverflow.com/questions/74187140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19517284/" ]
74,187,149
<p>I have a dict like this: (More than 1000 records)</p> <pre><code>{&quot;Device1&quot;: [[&quot;Device1&quot;, &quot;TenGigabitEthernet1/0/12&quot;, &quot;SHUT&quot;, &quot;&quot;, &quot;&quot;, &quot;IDF03&quot;], [&quot;Device1&quot;, &quot;TenGigabitEthernet1/0/11&quot;, &quot;SHUT&quot;, &quot;&quot;, &quot;&quot;, &quot;IDF03&quot;, &quot;#f76f6f&quot;]], &quot;Device2&quot;: [[&quot;Device2&quot;, &quot;TenGigabitEthernet1/0/12&quot;, &quot;SHUT&quot;, &quot;&quot;, &quot;&quot;, &quot;IDF03&quot;], [&quot;Device2&quot;, &quot;TenGigabitEthernet1/0/11&quot;, &quot;SHUT&quot;, &quot;&quot;, &quot;&quot;, &quot;IDF03&quot;, &quot;#f76f6f&quot;]]} </code></pre> <p>The problem is, I don't know how to sort the dict based on the portName which would be <code>TenGigabitEthernet1/0/*</code> or <code>GigabitEthernet1/0/*</code></p> <p>I have the following code but it's not doing it right:</p> <pre><code>with open(&quot;data-dic.txt&quot;, 'r') as dic: data = dic.read() dataDic = json.loads(data) dataDic = ast.literal_eval(json.dumps(dataDic)) d2 = OrderedDict({ k : dataDic[1] for k in natsorted(dataDic) }) print(d2) </code></pre> <p>It is sorting the keys which is the Device1, Device2,...</p> <p>How can I sort the dict based on the second value of the nested dict? which would be all the portNames.</p>
[ { "answer_id": 74187158, "author": "Konrad", "author_id": 5089567, "author_profile": "https://Stackoverflow.com/users/5089567", "pm_score": -1, "selected": false, "text": "getAttribute" }, { "answer_id": 74187210, "author": "Frédéric Perron", "author_id": 9867351, "au...
2022/10/24
[ "https://Stackoverflow.com/questions/74187149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15109593/" ]
74,187,195
<p>Can I change my variable name in Python? For example, I have a string <code>x</code>, and I want to change string <code>x</code> variable name to <code>y</code>, how can I do it?</p>
[ { "answer_id": 74187237, "author": "sj95126", "author_id": 13843268, "author_profile": "https://Stackoverflow.com/users/13843268", "pm_score": 2, "selected": false, "text": "y = x\ndel x\n" }, { "answer_id": 74187240, "author": "Rahul K P", "author_id": 4407666, "auth...
2022/10/24
[ "https://Stackoverflow.com/questions/74187195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19604228/" ]
74,187,214
<p>I am updating my theme in my App per useState. This is passed to Topbar-Component per prop. console.log() gets triggered every time it changes. From Topbar theme is passed into a link to AboutMe-Copmponent as state, which works, but when i now change the state of theme it only updates in Topbar. I even tried Useeffect. Only when I refresh the site the change is noticed. I read hours about this but I cant solve it somehow.</p> <p>AppComponent (not all code just the necessary):</p> <pre><code> function App() { const [theme, setTheme] = useState('dark') return ( &lt;Topbar theme={theme}&gt;&lt;/Topbar&gt; &lt;ToggleButton variant='light' onClick={() =&gt; setTheme('light')}&gt;Light&lt;/ToggleButton&gt; &lt;ToggleButton variant='dark' onClick={() =&gt; setTheme('dark')}&gt;Dark&lt;/ToggleButton&gt; </code></pre> <p>TopbarComponent:</p> <pre><code> export default function Topbar({theme}) { console.log('Topbar',theme) React.useEffect(()=&gt;{ console.log('changed') },[theme]) </code></pre> <p>Output when I press the buttons:<br/> Topbar light<br/> changed<br/> Topbar dark<br/> changed</p> <p>AboutMeComponent:</p> <pre><code>export default function AboutMe() { const location = useLocation() console.log(location.state) React.useEffect(() =&gt; { console.log('About-Me',location.state) },[location]) </code></pre> <p>Initial output:<br/> dark<br/> About-Me dark</p> <p>When I now press the other Button I only get the Topbar Output Only when refreshing I get the AboutMe Outputs again.</p> <p>PS The theme is changed anyway from dark to light but i need this state to change fonts etc.</p>
[ { "answer_id": 74187237, "author": "sj95126", "author_id": 13843268, "author_profile": "https://Stackoverflow.com/users/13843268", "pm_score": 2, "selected": false, "text": "y = x\ndel x\n" }, { "answer_id": 74187240, "author": "Rahul K P", "author_id": 4407666, "auth...
2022/10/24
[ "https://Stackoverflow.com/questions/74187214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18532120/" ]
74,187,236
<p>Here is <code>jq</code> getting field <code>a1</code>:</p> <pre><code>$ echo '{&quot;a&quot;: {&quot;a1&quot;: 1}, &quot;b&quot;: {&quot;a1&quot;: 2}}' | jq -r &quot;.[] | .a1&quot; 1 2 </code></pre> <p>I'd like to get the keys <code>a</code> and <code>b</code> as well, and output a flat result, i.e.</p> <pre><code>$ echo '{&quot;a&quot;: {&quot;a1&quot;: 1}, &quot;b&quot;: {&quot;a1&quot;: 2}}' | jq -r &quot;&lt;magic here&gt;&quot; a 1 b 2 </code></pre> <p>Suggestions?</p>
[ { "answer_id": 74187272, "author": "dfrankow", "author_id": 34935, "author_profile": "https://Stackoverflow.com/users/34935", "pm_score": 2, "selected": false, "text": "$ echo '{\"a\": {\"a1\": 1}, \"b\": {\"a1\": 2}}' | \\\n jq -r 'to_entries[] | [.key, .value.a1] | @tsv'\na 1\nb ...
2022/10/24
[ "https://Stackoverflow.com/questions/74187236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34935/" ]
74,187,245
<p>I have a dataframe like so:</p> <pre><code> timestamp open high low close volume trade_count vwap symbol 0 2021-10-28 13:30:00+00:00 8.32 8.37 8.310 8.355 16981 26 8.322444 BVN 1 2021-10-28 13:31:00+00:00 8.35 8.35 8.325 8.335 676 11 8.340991 BVN 2 2021-10-28 13:32:00+00:00 8.32 8.33 8.290 8.310 4458 22 8.306497 BVN 3 2021-10-28 13:33:00+00:00 8.34 8.40 8.330 8.400 13025 59 8.348660 BVN 4 2021-10-28 13:34:00+00:00 8.38 8.40 8.320 8.400 5405 29 8.353166 BVN ... ... ... ... ... ... ... ... ... ... 395837 2022-10-10 20:22:00+00:00 129.32 129.32 129.320 129.320 9630 3 129.319618 WMT 395838 2022-10-10 20:33:00+00:00 129.75 129.75 129.750 129.750 215 4 129.736047 WMT 395839 2022-10-10 20:46:00+00:00 129.13 129.13 129.130 129.130 100 1 129.130000 WMT 395840 2022-10-10 22:16:00+00:00 129.13 129.13 129.130 129.130 100 1 129.130000 WMT 395841 2022-10-10 23:41:00+00:00 129.93 129.93 129.930 129.930 200 1 129.930000 WMT [395842 rows x 9 columns] </code></pre> <p>I make the timestamp column a datetime obj:</p> <pre><code>df['timestamp'] = pd.to_datetime(df['timestamp']) </code></pre> <p>And then group the minute bars by individual days:</p> <pre><code>seperate_days = df.groupby(['symbol', df['timestamp'].dt.date]) </code></pre> <p>But when I loop over the data and print the index:</p> <pre><code>for name, ohlc in seperate_days: ohlc.set_index('timestamp') ohlc.index = pd.to_datetime(ohlc.index) ohlc.index = ohlc.index.tz_localize(tz='America/New_York') print(ohlc.index) </code></pre> <p>All I'm getting is dates from the 1970s:</p> <pre><code>DatetimeIndex(['1970-01-01 00:00:00.000171684-05:00', '1970-01-01 00:00:00.000171685-05:00', '1970-01-01 00:00:00.000171686-05:00', '1970-01-01 00:00:00.000171687-05:00', '1970-01-01 00:00:00.000171688-05:00', '1970-01-01 00:00:00.000171689-05:00', '1970-01-01 00:00:00.000171690-05:00', '1970-01-01 00:00:00.000171691-05:00', '1970-01-01 00:00:00.000171692-05:00', '1970-01-01 00:00:00.000171693-05:00', ... '1970-01-01 00:00:00.000172203-05:00', '1970-01-01 00:00:00.000172204-05:00', '1970-01-01 00:00:00.000172205-05:00', '1970-01-01 00:00:00.000172206-05:00', '1970-01-01 00:00:00.000172207-05:00', '1970-01-01 00:00:00.000172208-05:00', '1970-01-01 00:00:00.000172209-05:00', '1970-01-01 00:00:00.000172210-05:00', '1970-01-01 00:00:00.000172211-05:00', '1970-01-01 00:00:00.000172212-05:00'], dtype='datetime64[ns, America/New_York]', length=529, freq=None) </code></pre> <p>How can I get the dates to work correctly?</p>
[ { "answer_id": 74188868, "author": "a7dc", "author_id": 7317408, "author_profile": "https://Stackoverflow.com/users/7317408", "pm_score": 1, "selected": true, "text": "df = pd.read_sql_query(\"SELECT * from ohlc_minutes\", conn)\n\n\ndf['timestamp'] = pd.to_datetime(df['timestamp']) # re...
2022/10/24
[ "https://Stackoverflow.com/questions/74187245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7317408/" ]
74,187,253
<p>I am practicing writing simple bash scripts. I wrote the following script in TextEdit and saved it as a .sh file.</p> <pre><code>for x in “$@“ do if x = 0; then echo “False” elif x = 1; then echo “True” fi done </code></pre> <p>When I call this script in XQuartz using the following syntax, it runs forever and does not output anything. What am I doing wrong?</p> <pre><code>sh TestBash.sh 0 1 0 1 </code></pre>
[ { "answer_id": 74187292, "author": "Gilles Quenot", "author_id": 465183, "author_profile": "https://Stackoverflow.com/users/465183", "pm_score": 2, "selected": false, "text": "((x == 0))\n" }, { "answer_id": 74187531, "author": "Pedro Freitas Lopes", "author_id": 14404907...
2022/10/24
[ "https://Stackoverflow.com/questions/74187253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20325312/" ]
74,187,262
<p>I'm creating a flutter app that requires a user to complete certain tasks in order to stop an alarm clock. It's a more immersive alarm clock app that could help stimulate the brain in order to aid in the process of waking up.</p> <p>The tasks are simple questions the user has to answer. I'm utilizing TextFeild() to allow the user to input their answer. However, when I go to debug my code is redirected to a file called <strong>box.dart</strong> this is where the error is stated.</p> <p>Here is the <strong>box.dart</strong> file error:</p> <pre><code>throw FlutterError.fromParts(&lt;DiagnosticsNode&gt;[ ErrorSummary('Cannot hit test a render box with no size.'), describeForError('The hitTest() method was called on this RenderBox'), ErrorDescription( 'Although this node is not marked as needing layout, ' 'its size is not set.', ), ErrorHint( 'A RenderBox object must have an ' 'explicit size before it can be hit-tested. Make sure ' 'that the RenderBox in question sets its size during layout.', ), ]); } </code></pre> <p>Here is my full code:</p> <pre><code>import 'package:flutter/material.dart'; import 'package:audioplayers/audioplayers.dart'; //import 'package:audioplayers/audio_cache.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Time Attack', theme: ThemeData( primarySwatch: Colors.red, ), home: const MyHomePage(), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key}); @override State&lt;MyHomePage&gt; createState() =&gt; _MyHomePageState(); } class _MyHomePageState extends State&lt;MyHomePage&gt; { @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( backgroundColor: Colors.black, appBar: AppBar( backgroundColor: Colors.red, title: const Text('Time Attack'), centerTitle: true, ), floatingActionButton: FloatingActionButton( onPressed: () async { final player = AudioCache(); //bool isPLaying = false; await player.load('musicForapp.mp3'); AudioPlayer p = AudioPlayer(); p.audioCache = player; await p.play(AssetSource('musicForapp.mp3')); }, backgroundColor: Colors.red, child: const Icon(Icons.punch_clock), ), body: Padding( padding: const EdgeInsets.all(170), child: Column( children: [ const Text( &quot;Click the Icon in the bottem right to simulate alarm&quot;, style: TextStyle( color: Colors.white, fontSize: 30.0, ), ), ElevatedButton( style: ElevatedButton.styleFrom(backgroundColor: Colors.red), onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (_) =&gt; const TasksPage(), ), ); }, //on pressed child: const Text( &quot;Tasks page&quot;, style: TextStyle(color: Colors.white), ), ) ], ), ), ), ); } //widget build } class TasksPage extends StatefulWidget { const TasksPage({super.key}); @override State&lt;TasksPage&gt; createState() =&gt; _TasksPageState(); } class _TasksPageState extends State&lt;TasksPage&gt; { final _textcontroller = TextEditingController(); @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( backgroundColor: Colors.black, appBar: AppBar( backgroundColor: Colors.red, title: const Text('Tasks'), centerTitle: true, ), floatingActionButton: FloatingActionButton( onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (_) =&gt; const SecondTask(), ), ); }, backgroundColor: Colors.red, child: const Text(&quot;Next&quot;), ), body: Padding( padding: const EdgeInsets.all(8.0), child: Center( child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ const Text( &quot;How many states are there in the Uninted States of America?&quot;, style: TextStyle( backgroundColor: Colors.white, color: Colors.black, fontSize: 30.0, ), ), TextField( controller: _textcontroller, decoration: InputDecoration( hintText: &quot;Type your answer here!&quot;, border: const OutlineInputBorder(), suffixIcon: IconButton( onPressed: () { _textcontroller.clear(); }, icon: const Icon(Icons.clear), ), ), ), ], ), ), ), ), ); } //widget build } class SecondTask extends StatefulWidget { const SecondTask({super.key}); @override State&lt;SecondTask&gt; createState() =&gt; _SecondTask(); } class _SecondTask extends State&lt;SecondTask&gt; { final _textcontroller2 = TextEditingController(); @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( backgroundColor: Colors.black, appBar: AppBar( backgroundColor: Colors.red, title: const Text('Tasks'), centerTitle: true, ), floatingActionButton: FloatingActionButton( onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (_) =&gt; const Thirdtask(), ), ); }, backgroundColor: Colors.red, child: const Text(&quot;Next&quot;), ), body: Padding( padding: const EdgeInsets.all(8.0), child: Center( child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ const Text( &quot;how many oceans are there?&quot;, style: TextStyle( backgroundColor: Colors.white, color: Colors.black, fontSize: 30.0, ), ), TextField( controller: _textcontroller2, decoration: InputDecoration( hintText: &quot;Type your answer here!&quot;, border: const OutlineInputBorder(), suffixIcon: IconButton( onPressed: () { _textcontroller2.clear(); }, icon: const Icon(Icons.clear), ), ), ), ], ), ), ), ), ); } //widget build } class Thirdtask extends StatefulWidget { const Thirdtask({super.key}); @override State&lt;Thirdtask&gt; createState() =&gt; _Thirdtask(); } class _Thirdtask extends State&lt;Thirdtask&gt; { final _textcontroller3 = TextEditingController(); @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( backgroundColor: Colors.black, appBar: AppBar( backgroundColor: Colors.red, title: const Text('Tasks'), centerTitle: true, ), floatingActionButton: FloatingActionButton( onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (_) =&gt; const Finaltask(), ), ); }, backgroundColor: Colors.red, child: const Text(&quot;Next&quot;), ), body: Padding( padding: const EdgeInsets.all(8.0), child: Center( child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ const Text( &quot;What is 8 x 7?&quot;, style: TextStyle( backgroundColor: Colors.white, color: Colors.black, fontSize: 30.0, ), ), TextField( controller: _textcontroller3, decoration: InputDecoration( hintText: &quot;Type your answer here!&quot;, border: const OutlineInputBorder(), suffixIcon: IconButton( onPressed: () { _textcontroller3.clear(); }, icon: const Icon(Icons.clear), ), ), ), ], ), ), ), ), ); } //widget build } class Finaltask extends StatefulWidget { const Finaltask({super.key}); @override State&lt;Finaltask&gt; createState() =&gt; _Finaltask(); } class _Finaltask extends State&lt;Finaltask&gt; { final _textcontroller4 = TextEditingController(); @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( backgroundColor: Colors.black, appBar: AppBar( backgroundColor: Colors.red, title: const Text('Tasks'), centerTitle: true, ), floatingActionButton: FloatingActionButton( onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (_) =&gt; const Congrats(), ), ); }, backgroundColor: Colors.red, child: const Text(&quot;Submit&quot;), ), body: Padding( padding: const EdgeInsets.all(8.0), child: Center( child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ const Text( &quot;Riddle: What goes up but never comes back down?&quot;, style: TextStyle( backgroundColor: Colors.white, color: Colors.black, fontSize: 30.0, ), ), TextField( controller: _textcontroller4, decoration: InputDecoration( hintText: &quot;Type your answer here!&quot;, border: const OutlineInputBorder(), suffixIcon: IconButton( onPressed: () { _textcontroller4.clear(); }, icon: const Icon(Icons.clear), ), ), ), ], ), ), ), ), ); } //widget build } class Congrats extends StatefulWidget { const Congrats({super.key}); @override State&lt;Congrats&gt; createState() =&gt; _Congrats(); } class _Congrats extends State&lt;Congrats&gt; { final _textcontroller4 = TextEditingController(); @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( backgroundColor: Colors.black, appBar: AppBar( backgroundColor: Colors.red, title: const Text('Good Job!'), centerTitle: true, ), floatingActionButton: FloatingActionButton( onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (_) =&gt; const MyHomePage(), ), ); //player.clear('explosion.mp3'); (to stop alarm) }, backgroundColor: Colors.red, child: const Text(&quot;Home&quot;), ), body: Padding( padding: const EdgeInsets.all(8.0), child: Center( child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: const [ Text( &quot;Congratulations you completed your tasks, Click the home button to return home and stop the timer!&quot;, style: TextStyle( backgroundColor: Colors.white, color: Colors.black, fontSize: 30.0, ), ), ], ), ), ), ), ); } //widget build } </code></pre>
[ { "answer_id": 74187292, "author": "Gilles Quenot", "author_id": 465183, "author_profile": "https://Stackoverflow.com/users/465183", "pm_score": 2, "selected": false, "text": "((x == 0))\n" }, { "answer_id": 74187531, "author": "Pedro Freitas Lopes", "author_id": 14404907...
2022/10/24
[ "https://Stackoverflow.com/questions/74187262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15615382/" ]
74,187,295
<p>This is my first post and I'm excited to be here with you all.</p> <p>I'm having an issue centering 2 overlaying png images..</p> <p>This is what I currently have:</p> <p><a href="https://i.stack.imgur.com/EPUET.png" rel="nofollow noreferrer">example</a></p> <p>Now that I have the 2 images located and overlayed how I want them to, how do I center both as if it were one image?</p> <p>this is my html code:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot; dir=&quot;ltr&quot;&gt; &lt;head&gt; &lt;meta charset=&quot;utf-8&quot;&gt; &lt;title&gt;Title Test&lt;/title&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;styles.css&quot;&gt; &lt;/head&gt; &lt;body class=&quot;body&quot;&gt; &lt;div class=&quot;top-container&quot;&gt; &lt;img src=&quot;images/goku1.png&quot; alt=&quot;goku&quot; class=&quot;goku&quot;&gt; &lt;img src=&quot;images/dbzlogo.png&quot; alt=&quot;dbz&quot; class=&quot;dbzlogo&quot;&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I've tried different codes and methods and while some do work, they only center one of the images.</p> <p><a href="https://i.stack.imgur.com/QZV7o.png" rel="nofollow noreferrer">example</a></p> <p>What am I doing wrong? thanks so much!</p>
[ { "answer_id": 74187292, "author": "Gilles Quenot", "author_id": 465183, "author_profile": "https://Stackoverflow.com/users/465183", "pm_score": 2, "selected": false, "text": "((x == 0))\n" }, { "answer_id": 74187531, "author": "Pedro Freitas Lopes", "author_id": 14404907...
2022/10/24
[ "https://Stackoverflow.com/questions/74187295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20325347/" ]
74,187,333
<p>I'm newly learning Python for school, I have wrote this code as training; it works fine except for the last letter &quot;z&quot;.</p> <p>Ther code is this:</p> <pre><code>alpha = &quot;abcdefghijklmnopqrstuvwxyz&quot; letter = int(input('Input number of letter needed from alphabet (between 1 and 26): ')) if 0 &lt; letter &lt; len(alpha): print(alpha[letter - 1]) elif letter &lt;= 0: print ('Number is smaller than number of letters in the alphabet.') elif letter &gt; len(alpha): print (&quot;Number is larger than number of letters in the alphabet&quot;) </code></pre> <p>It works fine, but when I enter &quot;26&quot; which is for &quot;z&quot;, it gives me null instead of an error or &quot;z&quot;. Test it <a href="https://www.online-python.com/" rel="nofollow noreferrer">here</a>.</p>
[ { "answer_id": 74187292, "author": "Gilles Quenot", "author_id": 465183, "author_profile": "https://Stackoverflow.com/users/465183", "pm_score": 2, "selected": false, "text": "((x == 0))\n" }, { "answer_id": 74187531, "author": "Pedro Freitas Lopes", "author_id": 14404907...
2022/10/24
[ "https://Stackoverflow.com/questions/74187333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19302495/" ]
74,187,337
<p>I have class conforming to Encodable which contains 2 date properties. When I'm encoding it to string I'd like these 2 dates to use different date formatting - for example</p> <blockquote> <p>Optional(&quot;{\n &quot;date1&quot; : &quot;2022-10-24T22:03:43Z&quot;,\n &quot;date2&quot; : 688342014.16646099\n}&quot;)</p> </blockquote> <p>but I cant figure out how to do it, heres example code</p> <pre><code> func getString() -&gt; String? { let encoder = JSONEncoder() encoder.outputFormatting = .prettyPrinted encoder.dateEncodingStrategy = .iso8601 guard let data = try? encoder.encode(TwoDates()) else { return nil } guard let dataString = String(data: data, encoding: .utf8) else { return nil } return dataString } class TwoDates: Encodable { public var date1 = Date() public var date2 = Date() public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try? container.encode(date1, forKey: .date1) try? container.encode(date1, forKey: .date2) } enum CodingKeys: String, CodingKey { case date1 = &quot;date1&quot; case date2 = &quot;date2&quot; } } </code></pre> <p>So, how to use different date formatters for 2 different properties? Should I somehow override JSONEncoder.encode()?</p>
[ { "answer_id": 74191488, "author": "Bartosz Jarosz", "author_id": 11774305, "author_profile": "https://Stackoverflow.com/users/11774305", "pm_score": 0, "selected": false, "text": " try? container.encode(date1.iso8601String, forKey: .date1)\n" } ]
2022/10/24
[ "https://Stackoverflow.com/questions/74187337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11774305/" ]
74,187,377
<p>I Have a video here Hosted by <a href="https://kavimo.com/" rel="nofollow noreferrer">https://kavimo.com/</a></p> <pre><code>https://stream.biomaze.ir/i3zqz9fhf69f/iframe </code></pre> <p>It is kind of an m3u8 but I could neither download the m3u8 file nor download the Video does anybody know how we could go around this ?</p>
[ { "answer_id": 74305408, "author": "K J", "author_id": 10802527, "author_profile": "https://Stackoverflow.com/users/10802527", "pm_score": 2, "selected": false, "text": "<svg class=\"icon-hexagon play-big-bg\" style=\"fill:#074EE8\" viewBox=\"0 0 512 512\"><g><path d=\"m219 21c25-14 49-1...
2022/10/24
[ "https://Stackoverflow.com/questions/74187377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16732580/" ]
74,187,391
<p>(struggling) R user here. I've made some lme4 models, and I am trying to find individual fixed effects variances. I am estimating the variance of the fixed effect components by multiplying the design matrix of the fixed effects with the vector of fixed effect estimates, followed by calculating the variance of these fitted values (As per Nakagawa &amp; Schielzeth, 2013).</p> <p>I am getting values, however they are sometimes negtive. Is this incorrect?</p> <p>I also would like to use these values to get the percentage of variance explained, how could this be done? I'm lost when trying to understand all of the maths, and I feel *100 is probably wrong...</p> <p>Here is an example of my code:</p> <pre class="lang-r prettyprint-override"><code>data Ho SP SL DP DL species 1 0.432 -0.62240975 0.9615917 -0.20535833 -0.8038894 Accipiter gentilis 2 0.355 -0.85728592 1.0821313 -0.07917467 -0.8055025 Accipiter gentilis 3 0.370 -0.91221808 0.7616323 -0.17403906 -0.8041293 Accipiter gentilis 4 0.447 -1.15202246 0.9326085 -0.07640844 -0.8031998 Accipiter gentilis 5 0.452 0.12952583 0.7566257 0.35393076 -0.8058789 Ales Alces 6 0.406 -0.06462976 0.6679433 0.86746704 -0.7952550 Ales Alces </code></pre> <pre class="lang-r prettyprint-override"><code>lme &lt;- lmer(data$Ho ~ data$SP + data$DP + data$SL + data$DL + (1|data$spp)) vector &lt;- fixef(lme) vector &lt;- vector[-1] datanew &lt;- data.frame(data$SP, data$DP, data$SL, data$DL) matrix &lt;- datanew * vector variance &lt;- data.frame(var(matrix)[1], var(matrix)[2], var(matrix)[3], var(matrix)[4]) var.matrix..1. var.matrix..2. var.matrix..3. var.matrix..4. 1 0.002225362 1.712515e-05 -0.001885247 -0.001308941 </code></pre> <p>Thank you for your time, lmk if you want me to clarify anything.</p>
[ { "answer_id": 74305408, "author": "K J", "author_id": 10802527, "author_profile": "https://Stackoverflow.com/users/10802527", "pm_score": 2, "selected": false, "text": "<svg class=\"icon-hexagon play-big-bg\" style=\"fill:#074EE8\" viewBox=\"0 0 512 512\"><g><path d=\"m219 21c25-14 49-1...
2022/10/24
[ "https://Stackoverflow.com/questions/74187391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20324962/" ]
74,187,422
<p>I developed some Mockito tests using Jenkins pipeline and will see the report through SonarQube.</p> <p>So far this is what I typed in the Jenkins script:</p> <pre><code>sh ' mvn sonar:sonar -Dsonar.sources=src/main/java -Dsonar.css.node=. -Dsonar.java.binaries=. -Dsonar.host.url=http://192.168.2.2:9000/ -Dsonar.login=admin -Dsonar.password=sonar -Dsonar.jacoco.reportPath=build/reports/jacoco.xml' </code></pre> <p>I've also added this command to the stage before creating the artifact to clean the project (so it ignores at first tests so it doesn't generate the exception for ConnectionNeeded)</p> <pre><code> sh 'mvn package -Dmaven.test.skip=true -P test-coverage' </code></pre> <p><a href="https://i.stack.imgur.com/iS7hR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iS7hR.png" alt="enter image description here" /></a></p> <p>I get an exception and the final stage (I believe this is because I don't have a database on my Centos machine) <a href="https://i.stack.imgur.com/2J8BQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2J8BQ.png" alt="enter image description here" /></a></p> <pre><code>[ERROR] Tests run: 11, Failures: 0, Errors: 11, Skipped: 0 </code></pre> <p>and the Coverage percentage on SonarQube is still 0% and the number of lines is not changing after adding my tests.</p> <p><a href="https://i.stack.imgur.com/A0GDE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/A0GDE.png" alt="enter image description here" /></a></p> <pre><code> &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;parent&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt; &lt;version&gt;2.5.3&lt;/version&gt; &lt;relativePath /&gt; &lt;!-- lookup parent from repository --&gt; &lt;/parent&gt; &lt;groupId&gt;uk.un.ts&lt;/groupId&gt; &lt;artifactId&gt;proj&lt;/artifactId&gt; &lt;version&gt;1.0&lt;/version&gt; &lt;name&gt;achat&lt;/name&gt; &lt;description&gt;Projet pour le module DevOps&lt;/description&gt; &lt;properties&gt; &lt;java.version&gt;1.8&lt;/java.version&gt; &lt;maven-jar-plugin.version&gt;3.1.0&lt;/maven-jar-plugin.version&gt; &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt; &lt;jacoco.version&gt;0.8.6&lt;/jacoco.version&gt; &lt;sonar.java.coveragePlugin&gt;jacoco&lt;/sonar.java.coveragePlugin&gt; &lt;sonar.dynamicAnalysis&gt;reuseReports&lt;/sonar.dynamicAnalysis&gt; &lt;sonar.jacoco.reportPath&gt;${project.basedir}/../target/jacoco.exec&lt;/sonar.jacoco.reportPath&gt; &lt;sonar.language&gt;java&lt;/sonar.language&gt; &lt;/properties&gt; &lt;distributionManagement&gt; &lt;snapshotRepository&gt; &lt;id&gt;nexus-snapshots&lt;/id&gt; &lt;url&gt;http://192.168.2.2:8081/repository/maven-snapshots/&lt;/url&gt; &lt;/snapshotRepository&gt; &lt;repository&gt; &lt;id&gt;nexus-releases&lt;/id&gt; &lt;url&gt;http://192.168.2.2:8081/repository/maven-releases/ &lt;/url&gt; &lt;/repository&gt; &lt;/distributionManagement&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;mysql&lt;/groupId&gt; &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt; &lt;scope&gt;runtime&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.projectlombok&lt;/groupId&gt; &lt;artifactId&gt;lombok&lt;/artifactId&gt; &lt;optional&gt;true&lt;/optional&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;io.springfox&lt;/groupId&gt; &lt;artifactId&gt;springfox-boot-starter&lt;/artifactId&gt; &lt;version&gt;3.0.0&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;io.springfox&lt;/groupId&gt; &lt;artifactId&gt;springfox-swagger-ui&lt;/artifactId&gt; &lt;version&gt;3.0.0&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt; &lt;artifactId&gt;junit-jupiter&lt;/artifactId&gt; &lt;version&gt;5.9.1&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.jacoco&lt;/groupId&gt; &lt;artifactId&gt;jacoco-maven-plugin&lt;/artifactId&gt; &lt;version&gt;0.8.6&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.jacoco&lt;/groupId&gt; &lt;artifactId&gt;jacoco-maven-plugin&lt;/artifactId&gt; &lt;version&gt;${jacoco.version}&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;jacoco-initialize&lt;/id&gt; &lt;goals&gt; &lt;goal&gt;prepare-agent&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;execution&gt; &lt;id&gt;jacoco-site&lt;/id&gt; &lt;phase&gt;package&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;report&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-deploy-plugin&lt;/artifactId&gt; &lt;version&gt;${maven-deploy-plugin.version}&lt;/version&gt; &lt;configuration&gt; &lt;skip&gt;true&lt;/skip&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.sonatype.plugins&lt;/groupId&gt; &lt;artifactId&gt;nexus-staging-maven-plugin&lt;/artifactId&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;default-deploy&lt;/id&gt; &lt;phase&gt;deploy&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;deploy&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;configuration&gt; &lt;serverId&gt;nexus&lt;/serverId&gt; &lt;nexusUrl&gt;http://192.168.2.2:8081/&lt;/nexusUrl&gt; &lt;skipStaging&gt;true&lt;/skipStaging&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt; &lt;version&gt;3.1.0&lt;/version&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;excludes&gt; &lt;exclude&gt; &lt;groupId&gt;org.projectlombok&lt;/groupId&gt; &lt;artifactId&gt;lombok&lt;/artifactId&gt; &lt;/exclude&gt; &lt;/excludes&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/project&gt; </code></pre>
[ { "answer_id": 74305408, "author": "K J", "author_id": 10802527, "author_profile": "https://Stackoverflow.com/users/10802527", "pm_score": 2, "selected": false, "text": "<svg class=\"icon-hexagon play-big-bg\" style=\"fill:#074EE8\" viewBox=\"0 0 512 512\"><g><path d=\"m219 21c25-14 49-1...
2022/10/24
[ "https://Stackoverflow.com/questions/74187422", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15175890/" ]
74,187,430
<p>I am querying Google BigQuery databases using JetBrains' DataGrip. I love the UI in many ways, but one thing I'd like to know is if there is a more friendly way to see structs and arrays. I hate the BigQuery WebUI for many reasons, but the one thing I like is the way they implicitly render structs and arrays.</p> <pre><code>select struct(&quot;s1&quot;,&quot;s2&quot;,&quot;s3&quot;) , array(select &quot;a1&quot; union all select &quot;a2&quot; union all select &quot;a3&quot;) union all select struct(&quot;s4&quot;,&quot;s5&quot;,&quot;s6&quot;) , array(select &quot;a4&quot; union all select &quot;a5&quot; union all select &quot;a6&quot;) </code></pre> <p>To clarify with images, I like the following in BigQuery: <a href="https://i.stack.imgur.com/ZA2Yy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZA2Yy.png" alt="BigQuery implicit rendering" /></a></p> <p>DataGrip is harder to read: <a href="https://i.stack.imgur.com/kfnJu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kfnJu.png" alt="DataGrip symbolized rendering" /></a></p>
[ { "answer_id": 74188131, "author": "Mikhail Berlyant", "author_id": 5221944, "author_profile": "https://Stackoverflow.com/users/5221944", "pm_score": 0, "selected": false, "text": "select format('%T', col1) col1, format('%T', col2) col2 from (\n select struct(\"s1\",\"s2\",\"s3\") col1\...
2022/10/24
[ "https://Stackoverflow.com/questions/74187430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6268854/" ]
74,187,439
<p>With Android View, I'm able to move the focus to a View like so:</p> <pre><code>fun View.requestAccessibilityFocus() { requestFocus() sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED) } </code></pre> <p>How do I achieve this in Jetpack Compose?</p> <p>I tried using FocusRequester but it doesn't seem to do anything:</p> <pre><code>val lifecycleOwner = LocalLifecycleOwner.current val requester = FocusRequester() Box { ... Image( ... contentDescription = &quot;My heading&quot;, modifier = Modifier ... .focusRequester(requester) ) } DisposableEffect(lifecycleOwner) { val observer = LifecycleEventObserver { _, event -&gt; if (event == Lifecycle.Event.ON_RESUME) { requester.requestFocus() } } lifecycleOwner.lifecycle.addObserver(observer) onDispose { lifecycleOwner.lifecycle.removeObserver(observer) } } </code></pre>
[ { "answer_id": 74189967, "author": "Nikhil Dupally", "author_id": 11692985, "author_profile": "https://Stackoverflow.com/users/11692985", "pm_score": 1, "selected": false, "text": "DiposableEffect" }, { "answer_id": 74215240, "author": "Fried Rice", "author_id": 945711, ...
2022/10/24
[ "https://Stackoverflow.com/questions/74187439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/945711/" ]
74,187,441
<p>I have a dictionary that has a list of all of the df column names and maps them to function names.</p> <pre><code>import pandas as pd data= [[&quot;john&quot;,&quot;&quot;,&quot;&quot;,&quot;English&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;]] df= pd.DataFrame(data,columns=['firstName', 'lastName', 'state', 'Communication_Language__c', 'country', 'company', 'email', 'industry', 'System_Type__c', 'AccountType', 'customerSegment', 'Existing_Customer__c', 'GDPR_Email_Permission__c']) filename= 'Template' lang_trans= {&quot;English&quot;:&quot;ENG&quot;, &quot;French&quot;:&quot;FR&quot;} def lang (lang_trans,df): df.replace(lang_trans, inplace=True) df.str.upper() return df parsing_map{ &quot;Communication_Language__c&quot;: lang} </code></pre> <p>I would like to replace the data in the df with the abbreviation for 'english' as 'ENG', I have tried to achieve this with</p> <pre><code>def lang (lang_trans,df): df.replace(lang_trans, inplace=True) df.str.upper() return df </code></pre> <p>but it is not transforming 'english' to 'ENG' in the df</p> <p>How would I call the function lang from the dictionary to change the value in the <code>df[Communication_language_c</code> to be 'ENG'</p> <p>desired output</p> <pre><code>data= [[&quot;john&quot;,&quot;&quot;,&quot;&quot;,&quot;ENG&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;]] df= pd.DataFrame(data,columns=['firstName', 'lastName', 'state', 'Communication_Language__c </code></pre>
[ { "answer_id": 74189967, "author": "Nikhil Dupally", "author_id": 11692985, "author_profile": "https://Stackoverflow.com/users/11692985", "pm_score": 1, "selected": false, "text": "DiposableEffect" }, { "answer_id": 74215240, "author": "Fried Rice", "author_id": 945711, ...
2022/10/24
[ "https://Stackoverflow.com/questions/74187441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,187,463
<p>I have an html element that I'm replacing with a clone of itself to remove event listeners. However, I still want to interact with it after I've replaced it. Unfortunately,</p> <pre class="lang-js prettyprint-override"><code>node.replaceWith(node.cloneNode(true)) </code></pre> <p>makes node link to an element that doesn't exist. Is there any way I can get the element that is now where it was? I know I can circumvent this by giving it an id before and querying for it after, but it feels like there should be a better way.</p>
[ { "answer_id": 74187476, "author": "Konrad", "author_id": 5089567, "author_profile": "https://Stackoverflow.com/users/5089567", "pm_score": 0, "selected": false, "text": "node = node.replaceWith(node.cloneNode(true))\n" }, { "answer_id": 74187579, "author": "pilchard", "a...
2022/10/24
[ "https://Stackoverflow.com/questions/74187463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14735500/" ]
74,187,471
<p>I'm writing an web app with Kotlin and Ktor and I want to parse the json response from Google Books Api and select some specific values from it to store. For serialization I am using Kotlinx serialization. I want to avoid creating a data class</p> <p>The json response from the api is nested and looks like this (Json has been shortened for clarity):</p> <pre><code>{ &quot;kind&quot;: &quot;books#volumes&quot;, &quot;totalItems&quot;: 795, &quot;items&quot;: [{ &quot;kind&quot;: &quot;books#volume&quot;, &quot;id&quot;: &quot;zYw3sYFtz9kC&quot;, &quot;etag&quot;: &quot;ylNs2Stlgis&quot;, &quot;selfLink&quot;: &quot;https://www.googleapis.com/books/v1/volumes/zYw3sYFtz9kC&quot;, &quot;volumeInfo&quot;: { &quot;title&quot;: &quot;The Contemporary Thesaurus of Search Terms and Synonyms&quot;, &quot;subtitle&quot;: &quot;A Guide for Natural Language Computer Searching&quot;, &quot;authors&quot;: [ &quot;Sara D. Knapp&quot; ], &quot;publisher&quot;: &quot;Greenwood Publishing Group&quot;, &quot;publishedDate&quot;: &quot;2000&quot; } }] } </code></pre> <p>So how can I access the <strong>title</strong> property in this json with Kotlin / Kotlinx? I get the json object in <strong>items</strong>, but couldn't go until title.</p> <p>That's my code so far after calling the api.</p> <p><strong>Routing.kt:</strong></p> <pre><code>val response: HttpResponse = client.get(&quot;https://www.googleapis.com/books/v1/volumes?q=isbn:$isbn&quot;) println(response.status) val stringBody: String = response.body() val json: Map&lt;String, JsonElement&gt; = Json.parseToJsonElement(stringBody).jsonObject //println(json) val item = json[&quot;items&quot;] //println(item) </code></pre>
[ { "answer_id": 74191720, "author": "Aleksei Tirman", "author_id": 13963150, "author_profile": "https://Stackoverflow.com/users/13963150", "pm_score": 1, "selected": false, "text": "JsonElement" }, { "answer_id": 74233169, "author": "nicowi", "author_id": 5397752, "aut...
2022/10/24
[ "https://Stackoverflow.com/questions/74187471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5397752/" ]
74,187,478
<p>For the get_letter_from_user function, while using the while loop for validation, it keeps repeating the invalid input; I want to make sure that it is a single letter and lower case, and I want to make sure that it doesn't equal the second parameter of the function. I'm not sure what I'm doing wrong, though. (and how to get gud at coding if u have tips)</p> <pre><code>def get_text_from_user(prompt): return input(prompt).lower() def get_letter_from_user(prompt, not_allowed): not_allowed = '' allowed = input(prompt).lower() while not allowed == not_allowed or allowed.isalpha() or len(allowed) &gt; 1: allowed = str(input('Invalid letter, try again:')) return allowed def main(): text = get_text_from_user(&quot;Enter some text: &quot;) ltr1 = get_letter_from_user(&quot;Enter a letter: &quot;, '') ltr2 = get_letter_from_user(&quot;Enter another letter: &quot;, ltr1) new_text = text.replace(ltr1,ltr2) print(&quot;The new text is&quot;, new_text) if __name__ == &quot;__main__&quot;: main() </code></pre>
[ { "answer_id": 74191720, "author": "Aleksei Tirman", "author_id": 13963150, "author_profile": "https://Stackoverflow.com/users/13963150", "pm_score": 1, "selected": false, "text": "JsonElement" }, { "answer_id": 74233169, "author": "nicowi", "author_id": 5397752, "aut...
2022/10/24
[ "https://Stackoverflow.com/questions/74187478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20017084/" ]
74,187,482
<p>In my example dataframe:</p> <pre><code>df &lt;- data.frame(main=c(2,6,10), V1=c(1,3,5), V2=c(3,5,7), V3=c(5,7,9)) </code></pre> <p>I would like to create column 5 that would check between which column values the value in <em>main</em> falls in and assign the name of the last column that has a value lower than main to it, so in this example the results would be Row 1 = <strong>2</strong> (main) is higher than 1 (V1), but lower than 3(V2), so column 5 would be <strong>&quot;V1&quot;</strong> Row 2 = <strong>6</strong> (main) is higher than 3 (V1) and 5 (V2) but lower than 7(V3), so column 5 would be <strong>&quot;V2&quot;</strong> Row 3 = <strong>10</strong> (main) is higher than 5 (V1), 7 (V2) and 7 (V3), so column 5 would be <strong>&quot;V3&quot;</strong></p> <p>I would also prefer <strong>NOT</strong> to include the column names in the code, as there will be a lot of them in the final dataframe and will be subject to change.</p> <p>Thanks!</p>
[ { "answer_id": 74187570, "author": "Ricardo Semião e Castro", "author_id": 13048728, "author_profile": "https://Stackoverflow.com/users/13048728", "pm_score": 0, "selected": false, "text": "purrr::pmap_chr" }, { "answer_id": 74187949, "author": "TarJae", "author_id": 1332...
2022/10/24
[ "https://Stackoverflow.com/questions/74187482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20325447/" ]
74,187,489
<pre><code>make CFLAGS+=&quot;-g -O0 -fsanitize=address&quot; </code></pre> <p>after running that, I still have this on the backtrace -</p> <pre><code> 0x000000000040146e in main (argc=&lt;optimized out&gt;, argv=&lt;optimized out&gt;) </code></pre> <p>Make file code block</p> <pre><code> # Add -Werror if defined CFLAGS = -g0 -O2 -Wno-system-headers CFLAG_CARES_SYMBOL_HIDING = -fvisibility=hidden CPP = `enter code here`gcc -E CPPFLAGS = CPPFLAG_CARES_STATICLIB = CYGPATH_W = echo DEFS = -DHAVE_CONFIG_H </code></pre>
[ { "answer_id": 74187570, "author": "Ricardo Semião e Castro", "author_id": 13048728, "author_profile": "https://Stackoverflow.com/users/13048728", "pm_score": 0, "selected": false, "text": "purrr::pmap_chr" }, { "answer_id": 74187949, "author": "TarJae", "author_id": 1332...
2022/10/24
[ "https://Stackoverflow.com/questions/74187489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20325548/" ]
74,187,490
<p>I would like to make a rotation using 4x4 matrix in Swift, but it has unexpected behavior: 200 degrees + 45 degrees = 115 degrees, and not 245</p> <pre><code> let degree200 = Angle(degrees: 200).radians let degree45 = Angle(degrees: 45).radians // 200 degrees + 45 degrees let rotationMatrix = float4x4(simd_quatf(angle: Float(degree200+degree45), axis: SIMD3&lt;Float&gt;(0, 1, 0))) // it prints 115 degree, and not 245 print(Angle(radians: Double(simd_quatf(rotationMatrix).angle)).degrees) </code></pre>
[ { "answer_id": 74189185, "author": "robthebloke", "author_id": 8185995, "author_profile": "https://Stackoverflow.com/users/8185995", "pm_score": 2, "selected": true, "text": "print((degree200 + degree45). degrees)\n" } ]
2022/10/24
[ "https://Stackoverflow.com/questions/74187490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10438339/" ]
74,187,493
<p>I am using Spring Boot 2.7.4</p> <p>and</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;com.fasterxml.jackson.module&lt;/groupId&gt; &lt;artifactId&gt;jackson-module-kotlin&lt;/artifactId&gt; &lt;/dependency&gt; </code></pre> <p>I'm facing the following error when trying to send an Object through <code>messagingTemplate.convertAndSend</code> from <code>QueueMessagingTemplate</code></p> <p><strong>com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type <code>java.time.LocalDate</code> not supported by default: add Module &quot;com.fasterxml.jackson.datatype:jackson-datatype-jsr310&quot;</strong></p> <pre><code>@Service class SqsMessageSender( private val messagingTemplate: QueueMessagingTemplate, ) { fun send(operation: DesafioExactaQueueOperation, @Valid dto: BillDTO){ val message = SqsPayload(operation, dto) MessageBuilder .withPayload(message) .build() messagingTemplate.convertAndSend(Queues.DESAFIO_EXACTA, message) } } class SqsPayload( val operation: DesafioExactaQueueOperation, val body: Any //Must to be Any ) class BillDTO( @JsonProperty(&quot;code&quot;) val code: UUID, @JsonProperty(&quot;value&quot;) val value: BigDecimal, @JsonProperty(&quot;expireAt&quot;) @JsonFormat(pattern = &quot;yyyy-MM-dd&quot;, shape = JsonFormat.Shape.STRING) val expireAt: LocalDate ) </code></pre> <p>I have already tryed add</p> <pre><code>import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Primary @Configuration class JacksonModuleConfig { @Bean @Primary fun objectMapper(): ObjectMapper = JsonMapper.builder() .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .addModule(JavaTimeModule()) .build() } </code></pre> <p>and</p> <pre><code>jackson: serialization: WRITE_DATES_AS_TIMESTAMPS: false </code></pre> <p>I did not place <code>@EnableWebMvc</code> over application class</p>
[ { "answer_id": 74189185, "author": "robthebloke", "author_id": 8185995, "author_profile": "https://Stackoverflow.com/users/8185995", "pm_score": 2, "selected": true, "text": "print((degree200 + degree45). degrees)\n" } ]
2022/10/24
[ "https://Stackoverflow.com/questions/74187493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18856205/" ]
74,187,502
<p>If the following setIntVal is called and notifyListeners(); is executed, is the Text redrawn? intVal is changed but strVal is not.</p> <p>Similarly, what happens when StateNotifier is used?</p> <pre><code>class DummyManager with ChangeNotifier { DummyManager(); int intVal = 0; String strVal = &quot;&quot;; void setIntVal(val) { intVal = val; notifyListeners(); } } Consumer&lt;DummyManager&gt;( builder: (context, model, child) { return Text(model.strVal); }, ) </code></pre>
[ { "answer_id": 74189575, "author": "Ruble", "author_id": 17991131, "author_profile": "https://Stackoverflow.com/users/17991131", "pm_score": 1, "selected": false, "text": "state" }, { "answer_id": 74191582, "author": "Rémi Rousselet", "author_id": 8394265, "author_pro...
2022/10/24
[ "https://Stackoverflow.com/questions/74187502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5528270/" ]
74,187,507
<p>I have simple ngFor in which I am showing list</p> <pre><code>&lt;a class=&quot;list-group-item &quot; *ngFor=&quot;let user of chatsLists&quot; (click)=&quot;viewChat(user)&quot;&gt; &lt;div class=&quot;media chat-list-text py-1&quot; [ngClass]=&quot;{'align-items-center': !user.isActiveChat}&quot;&gt; &lt;span class=&quot;avatar avatar-md mr-2&quot;&gt; &lt;img [src]=&quot;user.userid.userImage&quot; alt=&quot;Avatar&quot;&gt; &lt;!-- &lt;span class=&quot;avatar-status-{{user.status}}&quot;&gt;&lt;/span&gt; &lt;i&gt;&lt;/i&gt; --&gt; &lt;/span&gt; &lt;div class=&quot;media-body&quot;&gt; &lt;h6 class=&quot;list-group-item-heading mb-1&quot;&gt;{{user.userid.userName}} &lt;/h6&gt; &lt;/div&gt; &lt;/div&gt; &lt;/a&gt; </code></pre> <p>and function from api I am getting data</p> <pre><code> chatsLists: any; //also tried with chatsLists = []; getChats() { this.api.getAllChats().subscribe((res: any) =&gt; { if (res.success) { this.chatsLists = res.data; this.chatdetails = this.chatsLists[0].messages; this.showChats = true; } else { } }) } </code></pre> <p>Its not updating the ngFor loop and if I click on any input on screen and remove hover from it then its showing the loop state is not updating that's mean</p> <p>Also I try to just place in html</p> <pre><code>&lt;p *ngIf=&quot;showChats&quot;&gt;Show &lt;/p&gt; </code></pre> <p>and in my function I change the bool value but in console I can see its showing true but its not reflecting in html file</p> <p>full code of component.ts</p> <pre><code>this.showChats = true; import { Component, ViewChild, ElementRef, OnInit, ChangeDetectionStrategy, Renderer2, Inject, OnDestroy, ChangeDetectorRef } from '@angular/core'; import { ChatService } from './chat.service'; import { Chat, UsersChat } from './chat.model'; import { DOCUMENT } from '@angular/common'; import { ConfigService } from 'app/shared/services/config.service'; import { Subscription } from 'rxjs'; import { ApiService } from 'app/services/api/api.service'; @Component({ selector: 'app-chat', templateUrl: './chat.component.html', changeDetection: ChangeDetectionStrategy.OnPush, styleUrls: ['./chat.component.scss'], providers: [ChatService] }) export class ChatComponent implements OnInit, OnDestroy { chats: Chat[] = []; activeChat: UsersChat; usersChat: UsersChat[] = []; activeChatUser: string; activeChatUserImg: string; loggedInUserImg: string; newMessage = &quot;&quot;; searchQuery: string = ''; placement = &quot;bottom-right&quot;; isContentOverlay = false; activeIndex = 0; chatdetails = []; showChats: any; public config: any = {}; layoutSub: Subscription; chatsLists: any; messages = new Array(); item: number = 0; constructor(private api: ApiService, private elRef: ElementRef, private renderer: Renderer2, @Inject(DOCUMENT) private document: Document, private configService: ConfigService, private cdr: ChangeDetectorRef, private chatService: ChatService) { this.config = this.configService.templateConf; this.usersChat = chatService.usersChat; this.activeChat = chatService.usersChat.find(_ =&gt; _.isActiveChat); this.chats = this.activeChat.chats; this.activeChatUser = this.activeChat.name; this.activeChatUserImg = this.activeChat.avatar; this.loggedInUserImg = &quot;assets/img/portrait/small/avatar-s-1.png&quot; this.renderer.addClass(this.document.body, &quot;chat-application&quot;); } ngOnInit() { this.getChats(); } ngOnDestroy() { if (this.layoutSub) { this.layoutSub.unsubscribe(); } this.renderer.removeClass(this.document.body, &quot;chat-application&quot;); } getChats() { this.api.getAllChats().subscribe((res: any) =&gt; { if (res.success) { this.chatsLists = res.data; this.chatdetails = this.chatsLists[0].messages; this.showChats = true; } else { } }) } //send button function calls onAddMessage() { if (this.newMessage != &quot;&quot;) { this.activeChat.chats.push({ isReceived: false, time: &quot;&quot;, messages: [this.newMessage], messageType: 'text' }) this.newMessage = &quot;&quot;; } } viewChat(chat: UsersChat) { this.usersChat.forEach(chat =&gt; { if (chat.userId === this.activeChat.userId) { chat.isActiveChat = false; } }) this.activeChat = chat; this.activeChat.isActiveChat = true; this.chats = this.activeChat.chats; this.activeChatUser = this.activeChat.name; this.activeChatUserImg = this.activeChat.avatar; this.isContentOverlay = false; } onSidebarToggle() { this.isContentOverlay = true; } onContentOverlay() { this.isContentOverlay = false; } } </code></pre>
[ { "answer_id": 74189575, "author": "Ruble", "author_id": 17991131, "author_profile": "https://Stackoverflow.com/users/17991131", "pm_score": 1, "selected": false, "text": "state" }, { "answer_id": 74191582, "author": "Rémi Rousselet", "author_id": 8394265, "author_pro...
2022/10/24
[ "https://Stackoverflow.com/questions/74187507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12791644/" ]
74,187,533
<p>Let say I have below <code>ggplot</code> to draw a <code>stacked bar chart</code></p> <pre><code>library(ggplot2) col_define = c('red', 'orange', 'blue', 'lightblue') names(col_define) = c('A', 'B', 'C', 'D') data = rbind(data.frame('grp1' = 'X', 'grp2' = c('A', 'B', 'C', 'D'), 'val' = c(1,2,3,4)), data.frame('grp1' = 'Y', 'grp2' = c('A', 'B', 'C', 'D'), 'val' = c(1,2,3,4)+2)) ggplot(data, aes(x = grp1, fill = grp2, y = val)) + geom_bar(stat = 'identity', position = 'stack') + scale_fill_manual(aesthetics = &quot;fill&quot;, values = col_define, breaks = names(col_define)) </code></pre> <p>It is placing all colour in a single legend. However in my case, I basically have 2 groups of colour i.e. one for <code>A &amp; B</code> and second for <code>C &amp; D</code></p> <p>I was looking into a similar discussion in <a href="https://stackoverflow.com/questions/27803710/ggplot2-divide-legend-into-two-columns-each-with-its-own-title">ggplot2: Divide Legend into Two Columns, Each with Its Own Title</a>, where there is an approach to group colours of legend using package <code>ggnewscale</code> or <code>relayer</code></p> <p>However it looks like, this approach can only be applied in <code>ordinary bar chart</code>, where <code>geom_bar</code> can be called multiple times.</p> <p>On the contrary, <code>geom_bar</code>, in my case, can't be called multiple times, as it is an <em><strong>whole object</strong></em></p> <p>I am looking for some way to use <code>ggnewscale</code> or <code>relayer</code> package in my <code>stack bar chart</code> to group colours in the legend.</p> <p>As @stefan suggested in one of the answers, a possible way to use <code>geom_col</code>.</p> <p>However I found that this approach is fairly restrictive, as I cant apply this method for <code>alluvial</code> plot with the same data as below</p> <pre><code>library(ggalluvial) ggplot(data, aes(x = grp1, stratum = grp2, alluvium = grp2, y = val, fill = grp2)) + geom_flow(aes(fill = grp2), alpha = .3) + geom_stratum(aes(color = grp2), alpha = .9) + scale_fill_manual(values = col_define, breaks = names(col_define)) </code></pre> <p>Is there a more general approach to group colours in legend?</p>
[ { "answer_id": 74187617, "author": "stefan", "author_id": 12993861, "author_profile": "https://Stackoverflow.com/users/12993861", "pm_score": 1, "selected": false, "text": "geom_col" }, { "answer_id": 74190225, "author": "stefan", "author_id": 12993861, "author_profil...
2022/10/24
[ "https://Stackoverflow.com/questions/74187533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1867328/" ]
74,187,542
<p>I'm trying to create a custom vector class for use in doing linear algebra calculations in my programs. The class name for now is Rvec. Here's what I'm attempting:</p> <p>I want to be able to reference elements in my vector by index BUT, also want to be able to access the first three elements (x,y,z) by typing .x after an object name (like if I had and Rvec named V, I could access element 0 by typing V.x and similar for y and z) because that makes it much more easy to follow in some of my programs. I've been thinking about this for a while and also couldn't find any definitive answers online but though of a few ideas that all ended in failure.</p> <p>I also overloaded the [] operator so that you can access elements directly (V[0] instead of V.values[0])</p> <pre><code>class Rvec { public: std::vector&lt;float&gt; values; float operator[] (int index) { return values[index]; } //option 1 //float x, y, z = values[0], values[1], values[2]; /* option 2 float* x = &amp;values[0]; float* y = &amp;values[1]; float* z = &amp;values[2]; // *Rvec.x */ /* option 3 #define x values[0] #define y values[1] #define z values[2] // Rvec.x */ // option 4 /* std::map&lt;char, float&gt; m; Rvec() { m.insert(pair&lt;char, float&gt;('x', 0)); m.insert(pair&lt;char, float&gt;('y', 0)); m.insert(pair&lt;char, float&gt;('z', 0)); } float operator[](int index) {return m.at(index);} float operator[](char key) { return m[key]; }*/ }; </code></pre> <p>The first option would just to be initialize x,y,z as floats, but that clearly wont work because they won't update their values when the actual elements do.</p> <p>The second option would be to define x,y,z as float pointers but then I would need to access them by typing *V.x and so on and that isn't the thing I'm going for.</p> <p>The third option would be to #define x,y,z as macros. But, that comes with its own issues that I don't want to deal with.</p> <p>The final option might be to use a map and initialize the keys to the first three elements as x,y,z. But then to reference them after overloading it would be V['x'] which is even worse than pointers.</p> <p>Is there any way to be able to reference elements like this just typing V.x and the value always being the same as the element it corresponds to?</p>
[ { "answer_id": 74187639, "author": "Thomas Matthews", "author_id": 225074, "author_profile": "https://Stackoverflow.com/users/225074", "pm_score": 1, "selected": false, "text": "class Rvec\n{\n public:\n // getter\n float x() const\n { return values[0];}\n\n // setter\n ...
2022/10/24
[ "https://Stackoverflow.com/questions/74187542", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20325333/" ]
74,187,563
<p>I am using very basic code to convert a string into a long and into a double. The CAN library I am using requires a double as an input. I am attempting to send the device ID as a double to another device on the CAN network.</p> <p>If I use an input string of that is 6 bytes long the long and double values are the same. If I add a 7th byte to the string the values are slightly different.</p> <p>I do not think I am hitting a max value limit. This code is run with ceedling for an automated test. The same behaviour is seen when sending this data across my CAN communications. In main.c the issue is not observed.</p> <p>The test is:</p> <pre><code>void test_can_hal_get_spn_id(void){ struct dbc_id_info ret; memset(&amp;ret, NULL_TERMINATOR, sizeof(struct dbc_id_info)); char expected_str[8] = &quot;smg123&quot;; char out_str[8]; memset(&amp;out_str, 0, 8); uint64_t long_val = 0; double phys = 0.0; memcpy(&amp;long_val, expected_str, 8); phys = long_val; printf(&quot;long %ld \n&quot;, long_val); printf(&quot;phys %f \n&quot;, phys); uint64_t temp = (uint64_t)phys; memcpy(&amp;out_str, &amp;temp, 8); printf(&quot;%s\n&quot;, expected_str); printf(&quot;%s\n&quot;, out_str); } </code></pre> <p>With the input = &quot;smg123&quot;</p> <pre><code>[test_can_hal.c] - &quot;long 56290670243187 &quot; - &quot;phys 56290670243187.000000 &quot; - &quot;smg123&quot; - &quot;smg123&quot; </code></pre> <p>With the input &quot;smg1234&quot;</p> <pre><code>[test_can_hal.c] - &quot;long 14692989459197299 &quot; - &quot;phys 14692989459197300.000000 &quot; - &quot;smg1234&quot; - &quot;tmg1234&quot; </code></pre> <p>Is this error just due to how floats are handled and rounded? Is there a way to test for that? Am I doing something fundamentally wrong?</p> <p>Representing the char array as a double without the intermediate long solved the issue. For clarity I am using <a href="https://github.com/xR3b0rn/dbcppp" rel="nofollow noreferrer">DBCPPP</a>. I am using it in C. I should clarify my CAN library comes from NXP, DBCPPP allows my application to read a <a href="https://www.kvaser.com/developer-blog/an-introduction-j1939-and-dbc-files/" rel="nofollow noreferrer">DBC file</a> and apply the data scales and factors to my raw CAN data. DBCPPP accepts doubles for all data being encoded and returns doubles for all data being decoded.</p>
[ { "answer_id": 74187612, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 0, "selected": false, "text": "NaN" }, { "answer_id": 74188100, "author": "John Bollinger", "author_id": 2402272, "author_profile...
2022/10/24
[ "https://Stackoverflow.com/questions/74187563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16254208/" ]
74,187,571
<p>I want to print</p> <pre><code>+ +++ +++++ +++++++ +++++++++ </code></pre> <p>in the easiest way using 'for'. similarly,</p> <pre><code># # # # # # </code></pre> <p>I want to print this in similar structure with code above</p> <p>what I tried :</p> <pre><code>for(i in 1:5){ cat((&quot;*&quot;*i), &quot;/n&quot;) } </code></pre> <p>but it's wrong because it's non-numeric argument.</p>
[ { "answer_id": 74187641, "author": "Jilber Urbina", "author_id": 1315767, "author_profile": "https://Stackoverflow.com/users/1315767", "pm_score": 3, "selected": true, "text": "cat((\"*\"*i), \"/n\")" }, { "answer_id": 74187659, "author": "scott.pilgrim.vs.r", "author_id"...
2022/10/24
[ "https://Stackoverflow.com/questions/74187571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20277785/" ]
74,187,574
<p>if you have a discord.py bot sometimes the bot goes offline and logs in again. Thats not really a problem but i want my script to automatically call a function when it started im now using on_ready(). like this:</p> <pre class="lang-py prettyprint-override"><code>global restockkk restockkk = False @bot.event async def on_ready(): logchannel = bot.get_channel(ID_CHANNEL) await logchannel.send(f'Logged in as {bot.user}'.format(bot)) await bot.change_presence(activity=discord.Game(name=&quot;Buddy is busy being the GOAT&quot;)) await restock() </code></pre> <p>restock is the name of my function. but when it logs in again it runs the function again, this results in the function running like 40 times after a day which is insane spam. I tried setting a global restockkk that sets to true when the restock() function is run but i think the script just starts over again or something because it ignores the restockkk set to true in the restock() function and still runs if i use:</p> <pre class="lang-py prettyprint-override"><code>global restockkk restockkk = False @bot.event async def on_ready(): logchannel = bot.get_channel(ID_CHANNEL) await logchannel.send(f'Logged in as {bot.user}'.format(bot)) await bot.change_presence(activity=discord.Game(name=&quot;Buddy is busy being the GOAT&quot;)) if not restockkk: await restock() </code></pre> <p>this is my restock function:</p> <pre class="lang-py prettyprint-override"><code>async def restock(): logchannel = bot.get_channel(960147355691253800) await logchannel.send('Restock monitor on') restockkk = True while True: try: if not restockkk: await bot.change_presence(activity=discord.Game(name=&quot;Buddy is busy being the GOAT&quot;)) break #... first piece of code await asyncio.sleep(120) #... second piece of code await asyncio.sleep(120) except Exception: await logchannel.send('exception occurred') await restock() </code></pre> <p>(its an infinite loop). The above sadly didn't work, i run my bot with:</p> <pre><code>bot.run(MY_BOT_TOKEN) </code></pre> <p>I also have a stop command (that's why i use global restockkk)</p> <pre class="lang-py prettyprint-override"><code>@bot.command(pass_context = True) async def stop(message): if message.author.id == myId: restockkk = False await message.channel.send('Restock monitor is off') else: await message.channel.send('You are not allowed to use this command') </code></pre> <p>So my question is: how can i call a function when the bot starts for the <strong>first</strong> time and not when its on_ready?</p>
[ { "answer_id": 74187648, "author": "Grace", "author_id": 10778286, "author_profile": "https://Stackoverflow.com/users/10778286", "pm_score": 3, "selected": true, "text": "bot.setup_hook()" }, { "answer_id": 74189820, "author": "stijndcl", "author_id": 13568999, "autho...
2022/10/24
[ "https://Stackoverflow.com/questions/74187574", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17842242/" ]
74,187,580
<p>I have a dataframe that looks like following:</p> <pre><code> product stars 10717 4 10717 5 10717 5 10717 5 10717 3 10717 2 10717 2 10711 2 10711 1 10711 5 10711 1 10711 1 10711 5 10711 2 </code></pre> <p>I have thousands rows.<br> I want to calculate for each distinct product the number of occurences of each star (from 1 to 5). <br> How can I achieve this? <br></p> <p>What I tried is to get the list of the distinct products with: <code>dp = df.product.unique()</code> <br> Than I looped over it:</p> <pre><code>for key in dd: sf_1[(sf_1['product'] == key)].value_counts() </code></pre> <p>The result looks like:</p> <pre><code>product stars 10717 5 3 4 1 3 1 2 2 dtype: int64 product stars 10711 5 2 2 3 1 2 dtype: int64 </code></pre> <p>What I need is a new dataframe which looks like</p> <pre><code>product stars number_stars 10717 5 3 10717 4 1 10717 3 1 10717 2 2 10717 1 0 10711 5 2 10711 4 0 10711 3 0 10711 2 3 10711 1 2 </code></pre>
[ { "answer_id": 74187634, "author": "PaulS", "author_id": 11564487, "author_profile": "https://Stackoverflow.com/users/11564487", "pm_score": 0, "selected": false, "text": "pandas.DataFrame.value_counts" }, { "answer_id": 74187649, "author": "misterhuge", "author_id": 2021...
2022/10/24
[ "https://Stackoverflow.com/questions/74187580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/920485/" ]
74,187,600
<p>I want to build a model that classifies and predicts words from the users lips. With adverb a total of 142657 images that have been preproccessed using the dataset of videos of individual speakers but I get this error when running the model and doesnt even get past the first epoch heres my code</p> <pre class="lang-py prettyprint-override"><code>import os from silence_tensorflow import silence_tensorflow silence_tensorflow() import tensorflow as tf from tensorflow.keras.layers import Dense, Activation, Dropout, Input, Conv2D, \ MaxPooling2D, Flatten, BatchNormalization from tensorflow.keras.models import Sequential from tensorflow.keras.preprocessing.image import ImageDataGenerator os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' tf.autograph.set_verbosity(0) tf.get_logger().setLevel('ERROR') class AdverbNet(object): def __init__(self): self.Model = Sequential() self.build() def build(self): self.Model.add(Input(name='the_input', shape=(224, 224, 1), batch_size=16, dtype='float32')) self.Model.add(Conv2D(32, (3, 3), activation='sigmoid', name='convo2')) self.Model.add(MaxPooling2D(pool_size=(2, 2))) self.Model.add(Conv2D(32, (3, 3), activation='sigmoid', name='convo3')) self.Model.add(MaxPooling2D(pool_size=(2, 2))) self.Model.add(Conv2D(64, (3, 3), activation='relu', name='convo4')) self.Model.add(MaxPooling2D(pool_size=(2, 2))) self.Model.add(Flatten()) self.Model.add(Dense(512)) self.Model.add(Dropout(0.5)) self.Model.add(BatchNormalization(scale=False)) self.Model.add(Activation('relu')) self.Model.add(Dropout(0.5)) self.Model.add(Dense(4, activation='softmax')) def summary(self): self.Model.summary() if __name__ == &quot;__main__&quot;: common_path = 'C:/Users/Loide/Desktop/Liphy/' C = AdverbNet() C.Model.compile(optimizer=&quot;Adam&quot;, loss='categorical_crossentropy', metrics=['accuracy']) C.Model.summary() with tf.device('/device:GPU:0') batch_size = 16 epochs = 32 train_dir = common_path + 'Images/Adverb/' test_dir = common_path + 'Images/Adverb/' checkpoint_path = common_path + 'SavedModels/Adverb/' train_image_generator = ImageDataGenerator(rescale=1. / 255) # Generator for training data generate training anD test set train_data_gen = train_image_generator.flow_from_directory(batch_size=batch_size, directory=train_dir, shuffle=True, target_size=(224, 224), class_mode='categorical', color_mode='grayscale') test_image_generator = ImageDataGenerator(rescale=1. / 255) # Generator for test data test_data_gen = test_image_generator.flow_from_directory(batch_size=batch_size, directory=test_dir, shuffle=False, target_size=(224, 224), class_mode='categorical', color_mode='grayscale') callback = tf.keras.callbacks.EarlyStopping(monitor='val_accuracy', patience=10, restore_best_weights=True, baseline=0.45) history = C.Model.fit(train_data_gen, steps_per_epoch=8916, # Number of images // Batch size epochs=epochs, verbose=1, validation_data=test_data_gen, validation_steps=187, callbacks=[callback]) C.Model.save(checkpoint_path, save_format='tf') </code></pre> <p>**and I get the following error **</p> <pre class="lang-none prettyprint-override"><code>[Matrix size-incompatible: In[0]: [1,43264], In[1]: [16,512] [[{{node gradient_tape/sequential/dense/MatMul/MatMul_1}}]] [Op:__inference_train_function_1179] </code></pre> <p><img src="https://i.stack.imgur.com/3NW9f.jpg" alt="Error screenshot" /></p>
[ { "answer_id": 74187634, "author": "PaulS", "author_id": 11564487, "author_profile": "https://Stackoverflow.com/users/11564487", "pm_score": 0, "selected": false, "text": "pandas.DataFrame.value_counts" }, { "answer_id": 74187649, "author": "misterhuge", "author_id": 2021...
2022/10/24
[ "https://Stackoverflow.com/questions/74187600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20221843/" ]
74,187,637
<p>I have masked and cropped a raster based on a country boundary as follows:</p> <pre><code>library(geodata) library(terra) tmax &lt;- worldclim_global(&quot;tmax&quot;, 2.5, path=tempdir()) tmax_yr &lt;- tmax[[1]] mys &lt;- gadm(country=&quot;MYS&quot;, level=1, path=tempdir()) mys &lt;- terra::project(mys, crs(tmax_yr)) tmax_crop &lt;- terra::crop(tmax_yr, mys, mask = TRUE) plot(tmax_crop) plot(mys, add = T) </code></pre> <p><a href="https://i.stack.imgur.com/Gbd1l.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gbd1l.png" alt="enter image description here" /></a></p> <p>If I zoom into a small section of the image shown below, I can see the edges of the country boundary has jagged image i.e. raster cells are not smooth. Is there any to smooth them out so that raster cells are not protruding out from the polygon boundary?</p> <p>P.S. I noticed the <code>snap</code> argument in the <code>crop</code> function but there's no description of what it does in the documentation</p> <p><a href="https://i.stack.imgur.com/ViX4I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ViX4I.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74187634, "author": "PaulS", "author_id": 11564487, "author_profile": "https://Stackoverflow.com/users/11564487", "pm_score": 0, "selected": false, "text": "pandas.DataFrame.value_counts" }, { "answer_id": 74187649, "author": "misterhuge", "author_id": 2021...
2022/10/24
[ "https://Stackoverflow.com/questions/74187637", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3227302/" ]
74,187,645
<p>I am trying to make a discord bot with nextcord, but when I try to install it using command prompt, it gives me this error:</p> <pre><code> × Building wheel for yarl (pyproject.toml) did not run successfully. │ exit code: 1 ╰─&gt; [37 lines of output] C:\Users\klama\AppData\Local\Temp\pip-build-env-pknvci1v\overlay\Lib\site-packages\setuptools\config\setupcfg.py:508: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead. warnings.warn(msg, warning_class) ********************** * Accelerated build * ********************** running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-cpython-311 creating build\lib.win-amd64-cpython-311\yarl copying yarl\_quoting.py -&gt; build\lib.win-amd64-cpython-311\yarl copying yarl\_quoting_py.py -&gt; build\lib.win-amd64-cpython-311\yarl copying yarl\_url.py -&gt; build\lib.win-amd64-cpython-311\yarl copying yarl\__init__.py -&gt; build\lib.win-amd64-cpython-311\yarl running egg_info writing yarl.egg-info\PKG-INFO writing dependency_links to yarl.egg-info\dependency_links.txt writing requirements to yarl.egg-info\requires.txt writing top-level names to yarl.egg-info\top_level.txt reading manifest file 'yarl.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no previously-included files matching '*.pyc' found anywhere in distribution warning: no previously-included files matching '*.cache' found anywhere in distribution warning: no previously-included files found matching 'yarl\*.html' warning: no previously-included files found matching 'yarl\*.so' warning: no previously-included files found matching 'yarl\*.pyd' no previously-included directories found matching 'docs\_build' adding license file 'LICENSE' writing manifest file 'yarl.egg-info\SOURCES.txt' copying yarl\__init__.pyi -&gt; build\lib.win-amd64-cpython-311\yarl copying yarl\_quoting_c.pyi -&gt; build\lib.win-amd64-cpython-311\yarl copying yarl\_quoting_c.pyx -&gt; build\lib.win-amd64-cpython-311\yarl copying yarl\py.typed -&gt; build\lib.win-amd64-cpython-311\yarl running build_ext building 'yarl._quoting_c' extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with &quot;Microsoft C++ Build Tools&quot;: https://visualstudio.microsoft.com/visual-cpp-build-tools/ [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for yarl Failed to build frozenlist multidict yarl ERROR: Could not build wheels for frozenlist, multidict, yarl, which is required to install pyproject.toml-based projects </code></pre> <p>I've tried updating my pip, but it says &quot;Requirement already satisfied&quot;. I've been looking for about 2 hours an a half and still can't find it.</p>
[ { "answer_id": 74187634, "author": "PaulS", "author_id": 11564487, "author_profile": "https://Stackoverflow.com/users/11564487", "pm_score": 0, "selected": false, "text": "pandas.DataFrame.value_counts" }, { "answer_id": 74187649, "author": "misterhuge", "author_id": 2021...
2022/10/24
[ "https://Stackoverflow.com/questions/74187645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19892745/" ]
74,187,665
<p>Is it possible to configure the resolution order of user defined operators? Consider the following code:</p> <pre><code>#include &lt;memory&gt; #include &lt;utility&gt; using P = std::unique_ptr&lt;int&gt;; struct S{ P p; operator P() &amp;&amp; { return std::move(p); } operator const P&amp;() const { return p; } }; S s{std::make_unique&lt;int&gt;()}; P p; p = std::move(s); </code></pre> <p>This fails to compile:</p> <pre><code>In file included from /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/memory:76, from &lt;source&gt;:1: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/unique_ptr.h:406:19: note: candidate: 'std::unique_ptr&lt;_Tp, _Dp&gt;&amp; std::unique_ptr&lt;_Tp, _Dp&gt;::operator=(std::unique_ptr&lt;_Tp, _Dp&gt;&amp;&amp;) [with _Tp = int; _Dp = std::default_delete&lt;int&gt;]' 406 | unique_ptr&amp; operator=(unique_ptr&amp;&amp;) = default; | ^~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/unique_ptr.h:515:19: note: candidate: 'std::unique_ptr&lt;_Tp, _Dp&gt;&amp; std::unique_ptr&lt;_Tp, _Dp&gt;::operator=(const std::unique_ptr&lt;_Tp, _Dp&gt;&amp;) [with _Tp = int; _Dp = std::default_delete&lt;int&gt;]' (deleted) 515 | unique_ptr&amp; operator=(const unique_ptr&amp;) = delete; </code></pre> <p>It seems compilation is failing because of an ambiguity between the deleted copy assignment and defaulted move assignment operators.</p> <p>Why is the compiler unable to resolve the operation here? Is there a way to define the operators to make this work?</p>
[ { "answer_id": 74187795, "author": "ShadowRanger", "author_id": 364696, "author_profile": "https://Stackoverflow.com/users/364696", "pm_score": -1, "selected": false, "text": "p = std::move(s)();\n" }, { "answer_id": 74187843, "author": "Nelfeal", "author_id": 3854570, ...
2022/10/24
[ "https://Stackoverflow.com/questions/74187665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14986327/" ]
74,187,711
<p>I have read-only access to a Postgres database. I can not write to the database.</p> <p>Q. Is there a way to construct and run a SQL query where I join a data frame (or other R object) to a table in a read-only Postgres database?</p> <p>This is for accessing data from WRDS, <a href="https://wrds-www.wharton.upenn.edu/" rel="nofollow noreferrer">https://wrds-www.wharton.upenn.edu/</a></p> <p>Here's an attempt at pseudocode</p> <pre><code>#establish a connection to a database con &lt;- dbConnect( Postgres(), host = 'host.org', port = 1234, dbname = 'db_name', sslmode = 'require', user = 'username', password = 'password') #create an R dataframe (or other object) df &lt;- data.frame( customer_id = c('a123', 'a-345', 'b0') ) #write a sql query we will run sql_query &lt;- &quot; SELECT t.customer_id, t.* FROM df t LEFT JOIN table_name df on t.customer_id = df.customer_id &quot; my_query_results &lt;- dbSendQuery(con, sql_query) temp &lt;- dbFetch(res, n = 1) dbClearResult(res) my_query_results </code></pre> <p>Note and edit: The example query I provided is intentionally super simple for example purposes.</p> <p>In my actual queries, there might be 3 or more columns I want to join on, and millions of rows I want to join on.</p>
[ { "answer_id": 74188881, "author": "Gregor Thomas", "author_id": 903061, "author_profile": "https://Stackoverflow.com/users/903061", "pm_score": 0, "selected": false, "text": "in" }, { "answer_id": 74313405, "author": "Ian Gow", "author_id": 745737, "author_profile": ...
2022/10/24
[ "https://Stackoverflow.com/questions/74187711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10816734/" ]
74,187,712
<p>Hi I'm trying to select the minimum and NOT the maximun date in a table. Instead of the maximun date I want to select the date of the fourth event. Any advice?</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>User</th> <th>Event</th> <th>Date</th> </tr> </thead> <tbody> <tr> <td>xyz</td> <td>1</td> <td>2021-06-06</td> </tr> <tr> <td>xyz</td> <td>2</td> <td>2021-06-26</td> </tr> <tr> <td>xyz</td> <td>3</td> <td>2021-07-30</td> </tr> <tr> <td>xyz</td> <td>4</td> <td>2022-01-10</td> </tr> <tr> <td>xyz</td> <td>5</td> <td>2022-02-14</td> </tr> <tr> <td>xyz</td> <td>6</td> <td>2022-02-21</td> </tr> </tbody> </table> </div> <p>I was trying something like this:</p> <pre><code>select user, min(date), max(date) from table where event &lt;= 4 group by user </code></pre> <p>Thanks</p>
[ { "answer_id": 74188881, "author": "Gregor Thomas", "author_id": 903061, "author_profile": "https://Stackoverflow.com/users/903061", "pm_score": 0, "selected": false, "text": "in" }, { "answer_id": 74313405, "author": "Ian Gow", "author_id": 745737, "author_profile": ...
2022/10/24
[ "https://Stackoverflow.com/questions/74187712", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20325690/" ]
74,187,723
<p>I have a dictionary that maps column names to a function name. I have wrote a function that should capitalize the values in the df column with <code>str.title()</code></p> <pre><code>import pandas as pd data= [[&quot;English&quot;,&quot;john&quot;,&quot;smith&quot;,&quot;ohio&quot;,&quot;united states&quot;,&quot;&quot;,&quot;&quot;,&quot;manufacturing&quot;,&quot;National&quot;,&quot;Residental&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;]] df= pd.DataFrame(data,columns=['Communication_Language__c','firstName', 'lastName', 'state', 'country', 'company', 'email', 'industry', 'System_Type__c', 'AccountType', 'customerSegment', 'Existing_Customer__c', 'GDPR_Email_Permission__c']) Communication_Language__c firstName lastName state country company email industry System_Type__c AccountType customerSegment Existing_Customer__c GDPR_Email_Permission__c 0 English john smith ohio united states manufacturing National Residental </code></pre> <pre><code>def capitalize (column,df_temp): if df_temp[column].notna(): df_temp[column]=df[column].str.title() return df_temp def required (): #somethin Pass parsing_map={ &quot;firstName&quot;:[capitalize,required], &quot;lastName&quot;:capitalize, &quot;state&quot;:capitalize, &quot;country&quot;: [capitalize,required], &quot;industry&quot;:capitalize, &quot;System_Type__c&quot;:capitalize, &quot;AccountType&quot;:capitalize, &quot;customerSegment&quot;:capitalize, } </code></pre> <p>i wrote the below to achieve the str title but is there a way to apply it to the df columns without naming them all</p> <pre><code>def capitalize (column,df_temp): if df_temp[column].notna(): df_temp[column]=df[column].str.title() return df_temp </code></pre> <p>What would be the best way to reference the dictionary function mapping to apply <code>str.title()</code> to all of the contents in the columns with a function &quot;capitalize&quot;?</p> <p>desired output</p> <pre><code>data= [[&quot;English&quot;,&quot;John&quot;,&quot;Smith&quot;,&quot;Ohio&quot;,&quot;United States&quot;,&quot;&quot;,&quot;&quot;,&quot;Manufacturing&quot;,&quot;National&quot;,&quot;Residental&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;]] df= pd.DataFrame(data,columns=['Communication_Language__c','firstName', 'lastName', 'state', 'country', 'company', 'email', 'industry', 'System_Type__c', 'AccountType', 'customerSegment', 'Existing_Customer__c', 'GDPR_Email_Permission__c']) Communication_Language__c firstName lastName state country company email industry System_Type__c AccountType customerSegment Existing_Customer__c GDPR_Email_Permission__c 0 English John Smith Ohio United States Manufacturing National Residental </code></pre>
[ { "answer_id": 74187791, "author": "bitflip", "author_id": 20027803, "author_profile": "https://Stackoverflow.com/users/20027803", "pm_score": 0, "selected": false, "text": "cols = ['firstName', 'lastName', 'state', 'country', 'industry', 'System_Type__c', 'AccountType', 'customerSegment...
2022/10/24
[ "https://Stackoverflow.com/questions/74187723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,187,734
<p>Just updated my Mac to the official release of Ventura, and I cannot launch my application via <code>react-native run-ios</code>.</p> <p><strong>Expected behavior:</strong></p> <p>running <code>react-native run-ios</code> will launch an Xcode simulator and a terminal window with Metro running.</p> <p><strong>Current behavior:</strong></p> <p>Xcode simulator opens, main terminal says app was built successfully, but an error is thrown instead of the metro terminal opening:</p> <blockquote> <p>“launchPackager.command” can’t be opened because (null) is not allowed to open documents in Terminal.</p> </blockquote> <p>The simulator just shows a white screen and can't be interacted with.</p> <p><strong>What I've tried:</strong></p> <ul> <li>manually opening <code>node_modules/react-native/scripts/launchPackager.command</code> <ul> <li>opens Metro terminal but is not connected to the app</li> </ul> </li> </ul> <blockquote> <p>warn No apps connected. Sending &quot;reload&quot; to all React Native apps failed. Make sure your app is running in the simulator or on a phone connected via USB. info Reloading app...</p> </blockquote> <ul> <li>giving Terminal full disk access (no change)</li> </ul>
[ { "answer_id": 74244642, "author": "gpmcadam", "author_id": 171758, "author_profile": "https://Stackoverflow.com/users/171758", "pm_score": 3, "selected": false, "text": "open node_modules/react-native/scripts/" } ]
2022/10/24
[ "https://Stackoverflow.com/questions/74187734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16807572/" ]
74,187,735
<p>I'm sorry if this is confusing. Newbie here. I have 2 data frames that contain data from different patients. The first dataframe (df1) contains results for testA, the results are recorded many times per day:</p> <pre><code> Patient TestA Time(A) 0 1 617.0 2019-12-07 13:21:15.224157 1 1 53.0 2019-12-07 14:21:15.224157 2 1 40.0 2019-12-07 15:21:15.224157 3 2 35.0 2019-12-07 13:21:15.224157 3 2 42.0 2019-12-07 16:21:15.224157 </code></pre> <p>and then another dataframe (df2) with the results for TestB:</p> <pre><code> Patient TestB Time(B) 0 1 60.0 2019-12-07 12:21:15.224157 1 1 56.0 2019-12-07 12:31:15.224157 2 1 45.0 2019-12-07 14:21:15.224157 3 1 32.0 2019-12-07 15:21:15.224157 3 2 42.0 2019-12-07 16:21:15.224157 </code></pre> <p>df2 is a lot longer than df1 because the results of TestB get registered more often. I need a dataframe that contains the value of TestA, and the value of TestB nearest in time to TimeA, but TimeB must be lower than TimeA. So, for example. If the result of TestA was taken at 6:05am, and I have 3 different values for TestB taken at: 6:01am, 6:02am, and 6:06am I would want the value from 6:02am because it's the nearest to TimeA(6:05am) that is also lower than TimeA. It would look something like this:</p> <pre><code> Patient TestA Time(A) TestB Time(B) 1 617.0 6:05am 50 6:02 1 &quot; &quot; &quot; &quot; 1 </code></pre> <p>Please help, thank you</p>
[ { "answer_id": 74187945, "author": "Jason Baker", "author_id": 3249641, "author_profile": "https://Stackoverflow.com/users/3249641", "pm_score": 2, "selected": false, "text": "df1[\"Time(A)\"] = pd.to_datetime(df1[\"Time(A)\"])\ndf1 = df1.sort_values([\"Time(A)\"], ascending=[1])\ndf2[\"...
2022/10/24
[ "https://Stackoverflow.com/questions/74187735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20325652/" ]
74,187,752
<p>I have the following:</p> <pre><code>allPlots &lt;- ggtern::grid.arrange(t1, t2, t3, t4, t5, t6, t7, t8, t9, nrow = 3, ncol = 3) </code></pre> <p>I want to create a function and pass the variables t1 to t9 programatically instead of manually typing them.</p> <p>Here is the function:</p> <pre><code>plotsGrid &lt;- function(...) { allPlots &lt;- ggtern::grid.arrange(..., nrow = 3, ncol = 3) return (allPlots) } </code></pre> <p>Is there a way to pass arguments to a function programatically? (maybe by creating a sequence from t1 to t9 that references global variables)? Any help is appreciated.</p>
[ { "answer_id": 74187841, "author": "br00t", "author_id": 4028717, "author_profile": "https://Stackoverflow.com/users/4028717", "pm_score": 1, "selected": false, "text": "\nplotsGrid <- function(pattern, nc = 3) {\n vars <- ls(pattern = pattern, envir = .GlobalEnv)\n nr <- ceiling(lengt...
2022/10/24
[ "https://Stackoverflow.com/questions/74187752", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15637129/" ]
74,187,755
<p>How to correctly remove attribute &quot;disabled&quot; from select in html template? I created button and some select with few options:</p> <pre><code>&lt;select id=&quot;testSelect&quot; disabled&gt; &lt;option&gt;1&lt;/option&gt; &lt;option&gt;2&lt;/option&gt; &lt;option&gt;3&lt;/option&gt; &lt;/select&gt; </code></pre> <p>and next I would like to add script to remover that disabled atribute. I was trying with:</p> <pre><code>$(&quot;input[name=edit]&quot;).on(&quot;click&quot;, function () { document.getElementById('testSelect').disabled = false; }) </code></pre> <p>but it does not work. It works with text inputs and checkboxes but with select I have problem.</p>
[ { "answer_id": 74187841, "author": "br00t", "author_id": 4028717, "author_profile": "https://Stackoverflow.com/users/4028717", "pm_score": 1, "selected": false, "text": "\nplotsGrid <- function(pattern, nc = 3) {\n vars <- ls(pattern = pattern, envir = .GlobalEnv)\n nr <- ceiling(lengt...
2022/10/24
[ "https://Stackoverflow.com/questions/74187755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17896393/" ]
74,187,761
<p>I have numpy array:</p> <pre><code>A = np.array(['abcd','bcde','cdef']) </code></pre> <p>I need hash array of A: with function</p> <pre><code>B[i] = ord(A[i][1]) * 256 + ord(A[i][2]) B = np.array([ord('b') * 256 + ord('c'), ord('c') * 256 + ord('d'), ord('d') * 256 + ord('e')]) </code></pre> <p>How I can do it?</p>
[ { "answer_id": 74187935, "author": "Jérôme Richard", "author_id": 12939557, "author_profile": "https://Stackoverflow.com/users/12939557", "pm_score": 2, "selected": true, "text": "ascii = A.astype('S')\nbuff = ascii.view(np.uint8)\nresult = buff[1::ascii.itemsize]*256 + buff[2::ascii.ite...
2022/10/24
[ "https://Stackoverflow.com/questions/74187761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19414814/" ]
74,187,783
<p>I'm trying to loop through multiple lines and add that into a dictionary, then a dataframe.</p> <p>I've had many attempts but no solution yet.</p> <p>I have a txt file with multiple lines like this for example, and I'm trying to iterate through each line, add it to a dictionary and then append the dictionary to a dataframe.</p> <p>So textfile for example would go from here:</p> <pre class="lang-none prettyprint-override"><code>ABC=123, DEF=&quot;456&quot;, ABC=&quot;789&quot;, DEF=&quot;101112&quot; </code></pre> <p>I would like this be added to a dictionary like this (on the first loop, for the first line):</p> <pre><code>{ABC:123,DEF=456} </code></pre> <p>and then appended to a df like this</p> <pre class="lang-none prettyprint-override"><code> ABC DEF 0 123 456 1 789 101112 </code></pre> <p>So far I have tried this, this only works for one line in the text file, when I add a new line, I get this error:</p> <blockquote> <p>dictionary update sequence element #6 has length 3; 2 is required</p> </blockquote> <pre><code>with open(&quot;file.txt&quot;, &quot;r&quot;) as f: s = f.read().strip() dictionary = dict(subString.split(&quot;=&quot;) for subString in s.split(&quot;,&quot;)) dataframe = dataframe.append(dictionary, ignore_index=True) dataframe </code></pre>
[ { "answer_id": 74187935, "author": "Jérôme Richard", "author_id": 12939557, "author_profile": "https://Stackoverflow.com/users/12939557", "pm_score": 2, "selected": true, "text": "ascii = A.astype('S')\nbuff = ascii.view(np.uint8)\nresult = buff[1::ascii.itemsize]*256 + buff[2::ascii.ite...
2022/10/24
[ "https://Stackoverflow.com/questions/74187783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17343936/" ]
74,187,790
<p>basically i have no idea why this code is not working, ive tried using on_message and that works so long as i dont include and if statement to filter for the messages with the prefix at the start. so i scrapped that, this code worked a few months ago with a different bot i made and ive ended up scrapping all the other stuff i was doing and bringing it down to the bare basics because i cant figure out why the bot doesnt recognise messages starting with the prefix.</p> <pre><code>import discord import os from discord.ext import commands bot = commands.Bot(command_prefix='!') TOKEN = &quot;Token_here&quot; @bot.command(name='tst') async def test(ctx): await ctx.send('testt') @bot.event async def on_ready(): print ('Successful login as {0.user}'.format(bot)) bot.run(TOKEN) </code></pre> <p>ive tried print('Test') debugging aswell see below</p> <pre><code>@bot.command(name='tst') async def test(ctx): print('Test&quot;) </code></pre> <p>then in discord typing the !test command still does nothing and the terminal also remains empty other than the on_ready result of</p> <pre><code>Successful login as botname#0001 </code></pre> <p>i have no idea whats going on honestly</p>
[ { "answer_id": 74187935, "author": "Jérôme Richard", "author_id": 12939557, "author_profile": "https://Stackoverflow.com/users/12939557", "pm_score": 2, "selected": true, "text": "ascii = A.astype('S')\nbuff = ascii.view(np.uint8)\nresult = buff[1::ascii.itemsize]*256 + buff[2::ascii.ite...
2022/10/24
[ "https://Stackoverflow.com/questions/74187790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20325743/" ]
74,187,801
<p>I want to map an object's key name and their values from an API into a list.</p> <p><a href="https://i.stack.imgur.com/R2gua.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R2gua.png" alt="enter image description here" /></a></p> <p>I need the output to be</p> <pre><code>Country: AE Buy: 1) Provider name: Google Play Movies Country: AU Rent: 1) Provider name: ... ... 7) ... Buy: and so on </code></pre> <p>I'm storing the object's name as <code>stream</code></p> <pre><code>const Stream = ({ stream }) =&gt; { console.log(stream) return ( &lt;div&gt; {stream?.results?.map((eachItem) =&gt; ( &lt;li&gt;{eachItem.link}&lt;/li&gt; ))} &lt;/div&gt; ) } export default Stream </code></pre> <p>I tried mapping atleast the link but I'm getting errors.</p> <pre><code>Uncaught TypeError: _stream$results.map is not a function </code></pre>
[ { "answer_id": 74187935, "author": "Jérôme Richard", "author_id": 12939557, "author_profile": "https://Stackoverflow.com/users/12939557", "pm_score": 2, "selected": true, "text": "ascii = A.astype('S')\nbuff = ascii.view(np.uint8)\nresult = buff[1::ascii.itemsize]*256 + buff[2::ascii.ite...
2022/10/24
[ "https://Stackoverflow.com/questions/74187801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15309633/" ]
74,187,817
<p>I tried to insert image in latex. I first uploaded images to sidebar of overleaf. And then I used such code</p> <pre><code>We still first focus on totally random dataset.\\ \begin{figure}[h] \centering \includegraphics[width=0.7\textwidth]{aab.png} \caption{aab\label{thename}} \end{figure} Then we focus on partially random dataset.\\ \begin{figure}[h] \centering \includegraphics[width=0.7\textwidth]{abb.png} \caption{abb\label{thename}} \end{figure} At last we look at true dataset. \begin{figure}[h] \centering \includegraphics[width=0.7\textwidth]{aba.png} \caption{aba\label{thename}} \end{figure} </code></pre> <p>And then But what I got is <a href="https://i.stack.imgur.com/S8yzN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S8yzN.png" alt="enter image description here" /></a></p> <p>There images are all in wrong positions, they all appear after texts, but they are supposed to be inserted between the texts. Where the issue comes from?</p>
[ { "answer_id": 74187935, "author": "Jérôme Richard", "author_id": 12939557, "author_profile": "https://Stackoverflow.com/users/12939557", "pm_score": 2, "selected": true, "text": "ascii = A.astype('S')\nbuff = ascii.view(np.uint8)\nresult = buff[1::ascii.itemsize]*256 + buff[2::ascii.ite...
2022/10/24
[ "https://Stackoverflow.com/questions/74187817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19106825/" ]
74,187,829
<p>I'm relatively new to all of this so hopefully this is a reasonably simple question! I have the following code that was working perfectly previously with pure HTML/CSS. It changes the CSS Class of an element when you click another element:</p> <pre><code>&lt;script&gt; const menu = document.querySelector('.menu') const close = document.querySelector('.close') const nav = document.querySelector('nav') menu.addEventListener('click',() =&gt;{ nav.classList.add('open-nav') }) close.addEventListener('click',() =&gt;{ nav.classList.remove('open-nav') }) &lt;/script&gt; </code></pre> <p>However, I'm working with a friend and we're trying to convert the site to use the Microsoft Blazor framework. We've done that largely successfully and re-structured the site slightly so that the header and footer of the site are loaded from a shared &quot;layout&quot; page, and an @body tag in the middle pulls in that particular pages main content. The stylesheet links and the script above are stored in another, separate layout file.</p> <p>I'm reasonably certain its all linking together properly as the stylesheets are getting applied properly, and the javascript is in the same place as the stylesheet definitions.</p> <p>However, the Javascript no longer works with everything in Blazor. There are no errors in my browser dev tools, but the style of the nav element simply does not change when I click the .menu element any more.</p> <p>Is there anything specific to be done in Blazor to allow running of Javascript? How would I even begin to debug if the Javascript is trying to do anything?</p> <p>Thanks in advance!</p>
[ { "answer_id": 74189797, "author": "AlirezaK", "author_id": 4444757, "author_profile": "https://Stackoverflow.com/users/4444757", "pm_score": 0, "selected": false, "text": "<body>" }, { "answer_id": 74190019, "author": "MrC aka Shaun Curtis", "author_id": 13065781, "a...
2022/10/24
[ "https://Stackoverflow.com/questions/74187829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14766571/" ]
74,187,833
<p>Suppose I have the following table:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>value</th> <th>label</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>art2</td> </tr> <tr> <td>2</td> <td>art1</td> </tr> <tr> <td>3</td> <td>art4</td> </tr> <tr> <td>4</td> <td>art3</td> </tr> </tbody> </table> </div> <p>I would like to have the result:</p> <ul> <li>value field if label found</li> <li>MAX(value)+1 if not found</li> </ul> <pre><code>label = art4 =&gt; 3 label = non existing =&gt; MAX(value)+1 = 5 </code></pre>
[ { "answer_id": 74189797, "author": "AlirezaK", "author_id": 4444757, "author_profile": "https://Stackoverflow.com/users/4444757", "pm_score": 0, "selected": false, "text": "<body>" }, { "answer_id": 74190019, "author": "MrC aka Shaun Curtis", "author_id": 13065781, "a...
2022/10/24
[ "https://Stackoverflow.com/questions/74187833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13463349/" ]
74,187,839
<p>I want to replace a single character on a bunch of file names with another character. However, when I want to replace files with <code>/</code> to another character, it doesn't work. It does work with other characters I want to replace, such as <code>-</code>.</p> <p>The python file is on the directory path, and I 'cd' to the directory path to run the program.</p> <p>I expect that every <code>/</code> on a file name would be replaced with a <code>_</code>. Like this: <code>file/1.txt</code> to <code>file_1.txt</code>.</p> <p>However, the files stay the same. Like this: <code>file/1.txt</code> to <code>file/1.txt</code>.</p> <p>I use this code:</p> <pre class="lang-py prettyprint-override"><code># Replace a character of a name file with another charater from importlib.metadata import files import os counter = 0 path = r&quot;/Users/user/test&quot; char = input('Enter character or string you want to replace:') repl = input('Enter character or string you want this to be replaced with:') files = [] # Loop, doesn't work with &quot;/&quot; for some reason for file_name in os.listdir(path): if char in file_name : old_name = file_name new_name = file_name.replace(char, repl) counter += 1 files.append(new_name) os.rename(old_name, new_name) print(counter) print(files) print(&quot;Done! Check your files&quot;) </code></pre> <p>As an alternative, I deleted the variables <code>char</code> and <code>repl</code> and instead used this in the <code>for</code> loop, but it still doesn't work:</p> <pre class="lang-py prettyprint-override"><code>for file_name in os.listdir(path): if &quot;/&quot; in file_name : old_name = file_name new_name = file_name.replace(&quot;/&quot;, &quot;_&quot;) counter += 1 </code></pre>
[ { "answer_id": 74189797, "author": "AlirezaK", "author_id": 4444757, "author_profile": "https://Stackoverflow.com/users/4444757", "pm_score": 0, "selected": false, "text": "<body>" }, { "answer_id": 74190019, "author": "MrC aka Shaun Curtis", "author_id": 13065781, "a...
2022/10/24
[ "https://Stackoverflow.com/questions/74187839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20325542/" ]
74,187,866
<p>I'm working on a project where I need the values in an array to change depending on if a button is clicked for that specific item. The issue that I'm having is that I need the <code>value</code> of for example <code>'vegetarian'</code> to change to <code>true</code> when <code>onChangeValue</code> is triggered, but I can't figure out how to change the <code>value</code> of an item in my <code>subCategories</code> and get the whole <code>data</code> array to stay in the same format. Currently, I'm getting:</p> <pre><code> [{&quot;category&quot;: &quot;Diet&quot;, &quot;name&quot;: &quot;pescatarian&quot;, &quot;subCategories&quot;: [[Object], [Object], [Object]], &quot;value&quot;: true}, {&quot;category&quot;: &quot;Daily Exercise in Hours&quot;, &quot;subCategories&quot;: [{name:'one', value: false },{name:'two', value: false }, {name:'three', value: false }, {name:'four', value: false }]}] </code></pre> <p>I've tried changing:</p> <pre><code> return { ...items, name: item.name, value: changedValue, } </code></pre> <p>to</p> <pre><code> return { ...items.subCategories, name: item.name, value: changedValue, } </code></pre> <p>, but that just gives me:</p> <pre><code>[{&quot;0&quot;: {&quot;name&quot;: &quot;pescatarian&quot;, &quot;value&quot;: false}, &quot;1&quot;: {&quot;name&quot;: &quot;vegan&quot;, &quot;value&quot;: false}, &quot;2&quot;: {&quot;name&quot;: &quot;vegetarian&quot;, &quot;value&quot;: false}, &quot;name&quot;: &quot;pescatarian&quot;, &quot;value&quot;: true}, {&quot;category&quot;: &quot;Daily Exercise in Hours&quot;, &quot;subCategories&quot;: [{name:'one', value: false },{name:'two', value: false }, {name:'three', value: false }, {name:'four', value: false }]}] </code></pre> <p>I've tried playing around with this a couple of other way, but they gave worse results. Does anyone know how to do this? I would really appreciate any help or advice. Thank you!</p> <p>Data:</p> <pre><code>const [data, setData] = useState([ { category: 'Diet', subCategories: [ {name:'pescatarian', value: false }, {name:'vegan', value: false }, {name:'vegetarian', value: false } ], }, { category: 'Daily Exercise in Hours', subCategories: [{name:'one', value: false },{name:'two', value: false }, {name:'three', value: false }, {name:'four', value: false }], }, ]) </code></pre> <p>onChangeValue()</p> <pre><code> const onChangeValue = (item, changedValue) =&gt; { const newData = data.map(items =&gt; { if (items.subCategories.some(x =&gt; x.name === item.name)) { return { ...items, name: item.name, value: changedValue, } } return items }) setData(newData); } </code></pre> <p>Array that I need:</p> <pre><code>[{&quot;category&quot;: &quot;Diet&quot;, &quot;subCategories&quot;: [{name: &quot;pescatarian&quot;,value: false},{name:&quot;vegan&quot;, value: false },{name:&quot;vegetarian&quot;, value: true }], {&quot;category&quot;: &quot;Daily Exercise in Hours&quot;, &quot;subCategories&quot;: [{name:'one', value: false },{name:'two', value: false }, {name:'three', value: false }, {name:'four', value: false }]}] </code></pre>
[ { "answer_id": 74189797, "author": "AlirezaK", "author_id": 4444757, "author_profile": "https://Stackoverflow.com/users/4444757", "pm_score": 0, "selected": false, "text": "<body>" }, { "answer_id": 74190019, "author": "MrC aka Shaun Curtis", "author_id": 13065781, "a...
2022/10/24
[ "https://Stackoverflow.com/questions/74187866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19222783/" ]
74,187,940
<p>A page contains this route: <code>&lt;a href={{ path('app_gut_food_vector') }}&gt;</code> but triggers a <code>not found by the @ParamConverter annotation</code> error. The log shows this: <code>Matched route &quot;app_gut_show&quot;. </code>. I cannot figure out how this could be. My question: How to get the correct route matched?</p> <p>Pieces of the puzzle:</p> <p>log entry:</p> <pre><code>INFO 23:53:50 request Matched route &quot;app_gut_show&quot;. { &quot;route&quot;: &quot;app_gut_show&quot;, &quot;route_parameters&quot;: { &quot;_route&quot;: &quot;app_gut_show&quot;, &quot;_controller&quot;: &quot;App\\Controller\\GutController::show&quot;, &quot;id&quot;: &quot;vector&quot; }, &quot;request_uri&quot;: &quot;http://diet/gut/vector&quot;, &quot;method&quot;: &quot;GET&quot; } </code></pre> <p>template includes:</p> <pre><code>Click &lt;a href={{ path('app_gut_food_vector') }}&gt; here&lt;/a&gt; </code></pre> <p>Controller includes:</p> <pre><code> #[Route('/vector', name: 'app_gut_food_vector', methods: ['GET', 'POST'])] public function vector(Request $request, GutRepository $gutRepository, VectorService $vectorSvc) { ... } </code></pre> <p><code>debug:router</code> includes:</p> <pre><code> app_gut_index GET ANY ANY /gut/ app_gut_new GET|POST ANY ANY /gut/new app_gut_show GET ANY ANY /gut/{id} app_gut_edit GET|POST ANY ANY /gut/{id}/edit app_gut_delete POST ANY ANY /gut/{id} app_gut_food_vector ANY ANY ANY /gut/vector </code></pre> <p>and the incorrectly matched route:</p> <pre><code> #[Route('/{id}', name: 'app_gut_show', methods: ['GET'])] public function show(Gut $gut): Response { ... } </code></pre> <p>Note: removing the methods from the <code>vector</code> method does NOT prevent the mismatch.</p>
[ { "answer_id": 74190577, "author": "DonCallisto", "author_id": 814253, "author_profile": "https://Stackoverflow.com/users/814253", "pm_score": -1, "selected": false, "text": "/gut/vector" }, { "answer_id": 74192697, "author": "Sergei Buldygin", "author_id": 17983198, ...
2022/10/25
[ "https://Stackoverflow.com/questions/74187940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1318266/" ]
74,187,960
<p>I've been trying to reverse an array using a for loop while not creating a new temporary array however the array only reverses halfway.</p> <pre><code>public void reverse() { int y = 0; int[] values = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; for (int x = values.length - 1; x &gt;= 0; x--) { int placeholder = values[x]; values[y] = placeholder; y++; System.out.print(values[y] + &quot; &quot;); } } </code></pre> <p>Right now the method returns the values of the array. However, the value is</p> <pre><code>&quot;1 2 3 4 5 5 4 3 2 1&quot; </code></pre> <p>The desired output is,</p> <pre><code>&quot;1 2 3 4 5 6 7 8 9 10&quot;. </code></pre>
[ { "answer_id": 74187993, "author": "Unmitigated", "author_id": 9513184, "author_profile": "https://Stackoverflow.com/users/9513184", "pm_score": 1, "selected": false, "text": "for (int i = 0, j = values.length - 1; i < j; i++, j--) {\n int temp = values[i];\n values[i] = values[j];...
2022/10/25
[ "https://Stackoverflow.com/questions/74187960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20325875/" ]
74,187,961
<p>You’ll need to bring all your filtering skills together for this task. We’ve provided you a list of companies in the developers variable. Filter df however you choose so that you only get games that meet the following conditions: Sold in all 3 regions (North America, Europe, and Japan) The Japanese sales were greater than the combined sales from North America and Europe The game developer is one of the companies in the developers list There is no column that explicitly says whether a game was sold in each region, but you can infer that a game was not sold in a region if its sales are 0 for that region. Use the cols variable to select only the 'name', 'developer', 'na_sales', 'eu_sales', and 'jp_sales' columns from the filtered DataFrame, and assign the result to a variable called df_filtered. Print the whole DataFrame.</p> <p>You can use a filter mask or query string for this task. In either case, you need to check if the 'jp_sales' column is greater than the sum of 'na_sales' and 'eu_sales', check if each sales column is greater than 0, and use isin() to check if the 'developer' column contains one of the values in developers. Use [cols] to select only those columns and then print df_filtered.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th></th> <th>developer</th> <th>na_sales</th> <th>eu_sales</th> <th>jp_sales</th> <th>critic_score</th> <th>user_score</th> </tr> </thead> <tbody> <tr> <td>0</td> <td>Nintendo</td> <td>41.36</td> <td>28.96</td> <td>3.77</td> <td>76.0</td> <td>8.0</td> </tr> <tr> <td>1</td> <td>NaN</td> <td>29.08</td> <td>3.58</td> <td>6.81</td> <td>NaN</td> <td>NaN</td> </tr> <tr> <td>2</td> <td>Nintendo</td> <td>15.68</td> <td>12.76</td> <td>3.79</td> <td>82.0</td> <td>8.3</td> </tr> <tr> <td>3</td> <td>Nintendo</td> <td>15.61</td> <td>10.93</td> <td>3.28</td> <td>80.0</td> <td>8.0</td> </tr> <tr> <td>4</td> <td>NaN</td> <td>11.27</td> <td>8.89</td> <td>10.22</td> <td>NaN</td> <td>NaN</td> </tr> </tbody> </table> </div> <p>This is my code. Pretty difficult and having difficulty providing a df_filtered variable with a running code.</p> <pre><code>import pandas as pd df = pd.read_csv('/datasets/vg_sales.csv') df['user_score'] = pd.to_numeric(df['user_score'], errors='coerce') developers = ['SquareSoft', 'Enix Corporation', 'Square Enix'] cols = ['name', 'developer', 'na_sales', 'eu_sales', 'jp_sales'] df_filtered = df([cols ]&gt; 0 | cols['jp_sales'] &gt; sum(cols['eu_sales']+cols['na_sales']) | df['developer'].isin(developers)) print(df_filtered) </code></pre>
[ { "answer_id": 74187993, "author": "Unmitigated", "author_id": 9513184, "author_profile": "https://Stackoverflow.com/users/9513184", "pm_score": 1, "selected": false, "text": "for (int i = 0, j = values.length - 1; i < j; i++, j--) {\n int temp = values[i];\n values[i] = values[j];...
2022/10/25
[ "https://Stackoverflow.com/questions/74187961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20187706/" ]
74,188,002
<p>I am solving rustlings exercises and have issue with <code>errors2</code>, below is my code:</p> <pre><code>pub fn total_cost(item_quantity: &amp;str) -&gt; Result&lt;i32, ParseIntError&gt; { let processing_fee = 1; let cost_per_item = 5; let qty = item_quantity.parse::&lt;i32&gt;(); let quantity_result = match qty { Ok(qty) =&gt; (qty * cost_per_item + processing_fee), Err(err) =&gt; panic!(&quot;invalid digit found in string {:?}&quot;, err), }; Ok(quantity_result) } </code></pre> <p><code>Ok</code> part works but I have no idea how to implement properly <code>Err</code> part. Here is a test for the code:</p> <pre><code>#[test] fn item_quantity_is_an_invalid_number() { assert_eq!( total_cost(&quot;beep boop&quot;).unwrap_err().to_string(), &quot;invalid digit found in string&quot; ); } </code></pre> <p>Currently I have following message:</p> <blockquote> <p>panicked at 'invalid digit found in string ParseIntError { kind: InvalidDigit }'</p> </blockquote>
[ { "answer_id": 74187993, "author": "Unmitigated", "author_id": 9513184, "author_profile": "https://Stackoverflow.com/users/9513184", "pm_score": 1, "selected": false, "text": "for (int i = 0, j = values.length - 1; i < j; i++, j--) {\n int temp = values[i];\n values[i] = values[j];...
2022/10/25
[ "https://Stackoverflow.com/questions/74188002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2856360/" ]
74,188,007
<p>Im trying to find the value of the first <code>&lt;p&gt;</code> tag inside my div when i click a button inside the same div. Note: The <code>$(this)</code> doesn't seem to work.</p> <p>Here's my code:</p> <pre class="lang-jsx prettyprint-override"><code>&lt;div className=&quot;cartcontainer&quot;&gt; &lt;p key={item.id} style={{ display: &quot;inline-block&quot;, marginTop: &quot;auto&quot;, marginBottom: &quot;auto&quot;, float: &quot;left&quot;, }} &gt; NFT ID: {item.id} &lt;/p&gt; &lt;p key={item.id} style={{ display: &quot;inline-block&quot;, marginTop: &quot;auto&quot;, marginBottom: &quot;auto&quot;, float: &quot;left&quot;, }} &gt; Price: {item.price} &lt;/p&gt; &lt;button style={{ float: &quot;right&quot;, width: 40, height: 40, fontSize: 20, borderRadius: 12, display: &quot;block&quot;, }} onClick={() =&gt; removeCartItemHandler(cart.findIndex($(this).closest(&quot;p&quot;)))} &gt; X &lt;/button&gt; &lt;/div&gt; </code></pre>
[ { "answer_id": 74188015, "author": "L8R", "author_id": 14551796, "author_profile": "https://Stackoverflow.com/users/14551796", "pm_score": -1, "selected": false, "text": "$( \".cartcontainer p:first-child\" ).text();\n" }, { "answer_id": 74188050, "author": "Phil", "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74188007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15828620/" ]