qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,252,049
<p>I am trying to run a Fyne app on a VM. I have attempted it on VirtualBox and Azure. After running the app, I get the following error:</p> <pre><code> Cause:APIUnavailable: WGL: The driver does not appear to support OpenGL At: fyne.io/fyne/v2@v2.2.3/internal/driver/glfw/driver.go:148 </code></pre> <p><a href="https://i.stack.imgur.com/tAKRY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tAKRY.png" alt="enter image description here" /></a></p> <p>I was able to solve this in VM by enabling <strong>3D acceleration</strong>. But I am not able to do the same in Azure.</p> <p><a href="https://i.stack.imgur.com/4PSgp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4PSgp.png" alt="enter image description here" /></a></p> <p>One option is to select the template which supports GPU. There are special VM series like the N-series VMs which support GPU. But just to run a Fyne app, I don't want to pay for a GPU VM.</p> <p>Another option is to use the GPU pass-through feature. But I am not able to find any documentation on how to do this.</p> <p>Is there any other way to solve this?</p>
[ { "answer_id": 74252338, "author": "bobble bubble", "author_id": 5527985, "author_profile": "https://Stackoverflow.com/users/5527985", "pm_score": 2, "selected": true, "text": "-(?=[^\"]*\"\\s*:)\n" }, { "answer_id": 74252628, "author": "Guru Stron", "author_id": 2501279,...
2022/10/30
[ "https://Stackoverflow.com/questions/74252049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13577765/" ]
74,252,061
<p>I have a problem with some Android Phone with an error : java.io.FileNotFoundException: /storage/emulated/0/Download/Joueurs.xlsx: open failed: EACCES (Permission denied) I looked at solutions given by Stackoverflow. I changed my code and manifest but always had the same error. We have a problem with a Galaxy S21. In the parameter of it, it's not possible to change the permission setting to change the multimédia file to all files. It seems difficult to test this problem with the simulator<br /> Have you an idea to solve this error Thank you very much for your help</p> <p>Best regards</p> <p>Georges</p> <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; xmlns:tools=&quot;http://schemas.android.com/tools&quot; package=&quot;com.prod.gfer94&quot; android:minSdkVersion=&quot;8&quot; android:targetSdkVersion=&quot;19&quot;&gt; &lt;uses-permission android:name=&quot;android.permission.GET_ACCOUNTS&quot; /&gt; &lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt; &lt;uses-permission android:name=&quot;android.permission.USE_CREDENTIALS&quot; /&gt; &lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot;/&gt; &lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot;/&gt; &lt;uses-permission android:name=&quot;android.permission.MANAGE_EXTERNAL_STORAGE&quot; tools:ignore=&quot;ScopedStorage&quot;/&gt; &lt;application android:icon=&quot;@drawable/icogaef&quot; android:label=&quot;@string/app_name&quot; android:roundIcon=&quot;@drawable/icogaef&quot; android:theme=&quot;@style/AppTheme&quot; android:requestLegacyExternalStorage=&quot;true&quot;&gt; &lt;activity android:name=&quot;.MainActivity&quot; android:exported=&quot;true&quot; android:label=&quot;G.F.E.R94&quot; android:textColor=&quot;@color/colorBleuDistrict&quot;&gt; ImageButton BoutonLicencies = findViewById(R.id.imageButtonLicencies); BoutonLicencies.setOnClickListener(v -&gt; { if (accesLicencies == 1){ searchFile(&quot;Joueurs.xlsx&quot;); try { FileInputStream fileJoueur = null; if(!fileName.canRead()) fileName.setReadable(true); fileJoueur = new FileInputStream(fileName); XSSFWorkbook myWorkBook = null; myWorkBook = new XSSFWorkbook(fileJoueur); XSSFSheet mySheet = myWorkBook.getSheetAt(0); mySheet = myWorkBook.getSheetAt(0); Iterator&lt;Row&gt; rowIterator = mySheet.iterator(); </code></pre>
[ { "answer_id": 74252338, "author": "bobble bubble", "author_id": 5527985, "author_profile": "https://Stackoverflow.com/users/5527985", "pm_score": 2, "selected": true, "text": "-(?=[^\"]*\"\\s*:)\n" }, { "answer_id": 74252628, "author": "Guru Stron", "author_id": 2501279,...
2022/10/30
[ "https://Stackoverflow.com/questions/74252061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14611913/" ]
74,252,067
<p>I want to train a classifier on ImageNet dataset (1000 classes) and I need each batch to contain 64 images from the same class and consecutive batches from different classes. So far based on <code>@shai</code>'s suggestion and this <a href="https://stackoverflow.com/questions/66065272/customizing-the-batch-with-specific-elements">post</a> I have</p> <pre><code>import torchvision.transforms as transforms import torchvision.datasets as datasets from torch.utils.data import DataLoader from torch.utils.data import Dataset import numpy as np import random import argparse import torch import os class DS(Dataset): def __init__(self, data, num_classes): super(DS, self).__init__() self.data = data self.indices = [[] for _ in range(num_classes)] for i, (data, class_label) in enumerate(data): # create a list of lists, where every sublist containts the indices of # the samples that belong to the class_label self.indices[class_label].append(i) def classes(self): return self.indices def __getitem__(self, index): return self.data[index] class BatchSampler: def __init__(self, classes, batch_size): # classes is a list of lists where each sublist refers to a class and contains # the sample ids that belond to this class self.classes = classes self.n_batches = sum([len(x) for x in classes]) // batch_size self.min_class_size = min([len(x) for x in classes]) self.batch_size = batch_size self.class_range = list(range(len(self.classes))) random.shuffle(self.class_range) assert batch_size &lt; self.min_class_size, 'batch_size should be at least {}'.format(self.min_class_size) def __iter__(self): batches = [] for j in range(self.n_batches): if j &lt; len(self.class_range): batch_class = self.class_range[j] else: batch_class = random.choice(self.class_range) batches.append(np.random.choice(self.classes[batch_class], self.batch_size)) return iter(batches) def main(): # Code about _train_dataset = DS(train_dataset, train_dataset.num_classes) _batch_sampler = BatchSampler(_train_dataset.classes(), batch_size=args.batch_size) _train_loader = DataLoader(dataset=_train_dataset, batch_sampler=_batch_sampler) labels = [] for i, (inputs, _labels) in enumerate(_train_loader): labels.append(torch.unique(_labels).item()) print(&quot;Unique labels: {}&quot;.format(torch.unique(_labels).item())) labels = set(labels) print('Length of traversed unique labels: {}'.format(len(labels))) if __name__ == &quot;__main__&quot;: parser = argparse.ArgumentParser(description='PyTorch ImageNet Training') parser.add_argument('--data', metavar='DIR', nargs='?', default='imagenet', help='path to dataset (default: imagenet)') parser.add_argument('--dummy', action='store_true', help=&quot;use fake data to benchmark&quot;) parser.add_argument('-b', '--batch-size', default=64, type=int, metavar='N', help='mini-batch size (default: 256), this is the total ' 'batch size of all GPUs on the current node when ' 'using Data Parallel or Distributed Data Parallel') parser.add_argument('-j', '--workers', default=4, type=int, metavar='N', help='number of data loading workers (default: 4)') args = parser.parse_args() if args.dummy: print(&quot;=&gt; Dummy data is used!&quot;) num_classes = 100 train_dataset = datasets.FakeData(size=12811, image_size=(3, 224, 224), num_classes=num_classes, transform=transforms.ToTensor()) val_dataset = datasets.FakeData(5000, (3, 224, 224), num_classes, transforms.ToTensor()) else: traindir = os.path.join(args.data, 'train') valdir = os.path.join(args.data, 'val') normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) train_dataset = datasets.ImageFolder( traindir, transforms.Compose([ transforms.RandomResizedCrop(224), transforms.RandomHorizontalFlip(), transforms.ToTensor(), normalize, ])) val_dataset = datasets.ImageFolder( valdir, transforms.Compose([ transforms.Resize(256), transforms.CenterCrop(224), transforms.ToTensor(), normalize, ])) # Samplers are initialized to None and train_sampler will be replaced train_sampler, val_sampler = None, None train_loader = torch.utils.data.DataLoader( train_dataset, batch_size=args.batch_size, shuffle=(train_sampler is None), num_workers=args.workers, pin_memory=True, sampler=train_sampler) val_loader = torch.utils.data.DataLoader( val_dataset, batch_size=args.batch_size, shuffle=False, num_workers=args.workers, pin_memory=True, sampler=val_sampler) main() </code></pre> <p>which prints: <code>Length of traversed unique labels: 100</code>.</p> <p>However, creating <code>self.indices</code> in the for loop takes a lot of time. Is there a more efficient way to construct this sampler?</p> <p>EDIT: yield implementation</p> <pre><code>import torchvision.transforms as transforms import torchvision.datasets as datasets from torch.utils.data import DataLoader from torch.utils.data import Dataset import numpy as np import random import argparse import torch import os from tqdm import tqdm import os.path class DS(Dataset): def __init__(self, data, num_classes): super(DS, self).__init__() self.data = data self.data_len = len(data) indices = [[] for _ in range(num_classes)] for i, (_, class_label) in tqdm(enumerate(data), total=len(data), miniters=1, desc='Building class indices dataset..'): indices[class_label].append(i) self.indices = indices def per_class_sample_indices(self): return self.indices def __getitem__(self, index): return self.data[index] def __len__(self): return self.data_len class BatchSampler: def __init__(self, per_class_sample_indices, batch_size): # classes is a list of lists where each sublist refers to a class and contains # the sample ids that belond to this class self.per_class_sample_indices = per_class_sample_indices self.n_batches = sum([len(x) for x in per_class_sample_indices]) // batch_size self.min_class_size = min([len(x) for x in per_class_sample_indices]) self.batch_size = batch_size self.class_range = list(range(len(self.per_class_sample_indices))) random.shuffle(self.class_range) def __iter__(self): for j in range(self.n_batches): if j &lt; len(self.class_range): batch_class = self.class_range[j] else: batch_class = random.choice(self.class_range) if self.batch_size &lt;= len(self.per_class_sample_indices[batch_class]): batch = np.random.choice(self.per_class_sample_indices[batch_class], self.batch_size) # batches.append(np.random.choice(self.per_class_sample_indices[batch_class], self.batch_size)) else: batch = self.per_class_sample_indices[batch_class] yield batch def n_batches(self): return self.n_batches def main(): file_path = 'a_file_path' file_name = 'per_class_sample_indices.pt' if not os.path.exists(os.path.join(file_path, file_name)): print('File: {} does not exists. Create it.'.format(file_name)) per_class_sample_indices = DS(train_dataset, num_classes).per_class_sample_indices() torch.save(per_class_sample_indices, os.path.join(file_path, file_name)) else: per_class_sample_indices = torch.load(os.path.join(file_path, file_name)) print('File: {} exists. Do not create it.'.format(file_name)) batch_sampler = BatchSampler(per_class_sample_indices, batch_size=args.batch_size) train_loader = torch.utils.data.DataLoader( train_dataset, # batch_size=args.batch_size, # shuffle=(train_sampler is None), num_workers=args.workers, pin_memory=True, # sampler=train_sampler, batch_sampler=batch_sampler ) # We do not use sampler for the validation # val_loader = torch.utils.data.DataLoader( # val_dataset, batch_size=args.batch_size, shuffle=False, # num_workers=args.workers, pin_memory=True, sampler=None) labels = [] for i, (inputs, _labels) in enumerate(train_loader): labels.append(torch.unique(_labels).item()) print(&quot;Unique labels: {}&quot;.format(torch.unique(_labels).item())) labels = set(labels) print('Length of traversed unique labels: {}'.format(len(labels))) if __name__ == &quot;__main__&quot;: parser = argparse.ArgumentParser(description='PyTorch ImageNet Training') parser.add_argument('--data', metavar='DIR', nargs='?', default='imagenet', help='path to dataset (default: imagenet)') parser.add_argument('--dummy', action='store_true', help=&quot;use fake data to benchmark&quot;) parser.add_argument('-b', '--batch-size', default=64, type=int, metavar='N', help='mini-batch size (default: 256), this is the total ' 'batch size of all GPUs on the current node when ' 'using Data Parallel or Distributed Data Parallel') parser.add_argument('-j', '--workers', default=4, type=int, metavar='N', help='number of data loading workers (default: 4)') args = parser.parse_args() if args.dummy: print(&quot;=&gt; Dummy data is used!&quot;) num_classes = 100 train_dataset = datasets.FakeData(size=12811, image_size=(3, 224, 224), num_classes=num_classes, transform=transforms.ToTensor()) val_dataset = datasets.FakeData(5000, (3, 224, 224), num_classes, transforms.ToTensor()) else: traindir = os.path.join(args.data, 'train') valdir = os.path.join(args.data, 'val') normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) train_dataset = datasets.ImageFolder( traindir, transforms.Compose([ transforms.RandomResizedCrop(224), transforms.RandomHorizontalFlip(), transforms.ToTensor(), normalize, ])) val_dataset = datasets.ImageFolder( valdir, transforms.Compose([ transforms.Resize(256), transforms.CenterCrop(224), transforms.ToTensor(), normalize, ])) num_classes = len(train_dataset.classes) main() </code></pre> <p><sup>A similar <a href="https://stackoverflow.com/questions/51555668/how-to-sample-batch-from-only-one-class-at-each-iteration">post</a> but in TensorFlow can be found here</sup></p>
[ { "answer_id": 74254466, "author": "Shai", "author_id": 1714410, "author_profile": "https://Stackoverflow.com/users/1714410", "pm_score": 3, "selected": true, "text": "batch_sampler" }, { "answer_id": 74323596, "author": "Ivan", "author_id": 6331369, "author_profile":...
2022/10/30
[ "https://Stackoverflow.com/questions/74252067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3238679/" ]
74,252,080
<p>I'm trying to find sum of all values divisible by 3 in the num_list = [1, 3, 4, 6, 8, 9, 11, 13, 15, 16, 17, 18] using while loop.</p> <p>I'm trying to get 51. I tried something to get 51 but i don't get it.</p> <pre><code>total = 0 list = [1, 3, 4, 6, 8, 9, 11, 13, 15, 16, 17, 18] while list % 3 == 0: total += list print (total) </code></pre>
[ { "answer_id": 74252097, "author": "Kenny", "author_id": 16185675, "author_profile": "https://Stackoverflow.com/users/16185675", "pm_score": 1, "selected": true, "text": "total = 0\nnums = [1, 3, 4, 6, 8, 9, 11, 13, 15, 16, 17, 18]\nfor num in nums:\n if num % 3 == 0:\n total +...
2022/10/30
[ "https://Stackoverflow.com/questions/74252080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20370688/" ]
74,252,124
<p>I'm creating a library app where users input data into a <code>form</code> and the values they enter are displayed in its own <code>div</code>.</p> <p>I have this <code>array</code></p> <pre><code>let myLibrary = [ { title: &quot;The Once and Future King&quot;, author: &quot;White&quot;, pages: 654, }, { title: &quot;The Hobbit&quot;, author: &quot;Tolkien&quot;, pages: 304, }, ]; </code></pre> <p>which is automatically displaying each <code>object</code> (for testing purposes) on my page thanks to this <code>forEach()</code></p> <pre><code>myLibrary.forEach((book) =&gt; { const bookContent = document.getElementById(&quot;content&quot;); const addBook = document.createElement(&quot;div&quot;); addBook.className = &quot;book&quot;; bookContent.appendChild(addBook); addBook.innerHTML = ` &lt;div class=&quot;title&quot;&gt; &lt;p class=&quot;bookTitle&quot;&gt; &lt;span&gt;${book.title}&lt;/span&gt; &lt;/p&gt; &lt;/div&gt; &lt;div class=&quot;body&quot;&gt; &lt;p&gt; Author: &lt;span&gt;${book.author}&lt;/span&gt; &lt;/p&gt; &lt;p&gt; Pages: &lt;span&gt;${book.pages}&lt;/span&gt; &lt;/p&gt; &lt;/div&gt;`; }); </code></pre> <p>The <code>forEach</code> makes it so every <code>object</code> inside my <code>array</code> is displayed in its own 280x365 pixel <code>div</code> and the book title, author and page count is displayed in it's own <code>p</code> element. I'm also using <code>flex</code> for organization.</p> <p>I also have a <code>form</code> which users can input a new book title, author and page number to add to their growing book collection.</p> <pre><code>const form = document.getElementById(&quot;form&quot;); form.addEventListener(&quot;submit&quot;, updateLibrary); function updateLibrary(event) { event.preventDefault(); const title = document.getElementById(&quot;title&quot;).value; const author = document.getElementById(&quot;author&quot;).value; const pages = document.getElementById(&quot;pages&quot;).value; const book = { title: title, author: author, pages: parseInt(pages), }; myLibrary.push(book); console.log(myLibrary); } </code></pre> <p>When I fill the form out, everything appears to work perfectly. I have <code>console.log</code> in my <code>updateLibrary</code> function and I notice the <code>object</code> is being pushed into the <code>array</code> like I want it to. But every time I hit the <code>submit</code> button, a new <code>div</code> isn't being created for the new book. I'm guessing this has to do with my <code>forEach</code> not triggering the new <code>object</code> but I can't find a way to fix this.</p> <p>How can I better write my code so a new <code>div</code> is also being created with the new <code>object</code> every time I submit the <code>form</code>?</p> <p><em>What I've tried</em></p> <p>I've tried rearranging my code so the <code>forEach</code> is below the <code>array</code>, so the <code>updateLibrary</code> function is above and below the <code>forEach</code>.</p> <p>I've also tried putting the <code>forEach</code> inside the <code>updateLibrary</code> function. That did make it work but it gave me an even worse bug.</p>
[ { "answer_id": 74252097, "author": "Kenny", "author_id": 16185675, "author_profile": "https://Stackoverflow.com/users/16185675", "pm_score": 1, "selected": true, "text": "total = 0\nnums = [1, 3, 4, 6, 8, 9, 11, 13, 15, 16, 17, 18]\nfor num in nums:\n if num % 3 == 0:\n total +...
2022/10/30
[ "https://Stackoverflow.com/questions/74252124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16725896/" ]
74,252,208
<pre><code>import 'package:flutter/material.dart'; import 'dart:math'; import 'dart:io'; main(){ print(&quot;Enter the first number:&quot;); String num1 = stdin.readLineSync()!; print(&quot;Enter the second number:&quot;); String mun2 = stdin.readLineSync()!; print(num1 + mun2); } </code></pre> <p>Whenever i try this code to extract the input i get this error, console doesn't ask for input as well, set aside to printing string with input variable! <a href="https://i.stack.imgur.com/4llvI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4llvI.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74252238, "author": "Tirth Patel", "author_id": 4593315, "author_profile": "https://Stackoverflow.com/users/4593315", "pm_score": 1, "selected": false, "text": "dart:io" } ]
2022/10/30
[ "https://Stackoverflow.com/questions/74252208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20370863/" ]
74,252,221
<blockquote> <p>Write a function which gets numbers from the user (use this command to get the digits from the user: input('Enter the digit\n'). Note that \n is used to go to the next line), and stores them in a list, and ultimately returns it.</p> <p>If the user enters a non-digit character, ignore it, unless they write 'Stop' in which case you should terminate the function and return the outcome in the form of a list.</p> <p>You can use the method var.isdigit() to check if the variable var is a digit or not.</p> </blockquote> <pre><code>def num_print(): output_list = [] while True: var=input('Enter the digit\n') if var.isdigit(): user_list = var.split() output_list += user_list elif var == 'Stop': for i in range(len(output_list)): output_list[i] = float(output_list[i]) return output_list break </code></pre> <p>I expect at last when a person enters Stop, it gives, let's say, <code>[1.0, 2.0, 3.0, 4.0]</code> if inputs were maybe <code>1, 2, 3, 4,h, 5, Stop</code>.</p>
[ { "answer_id": 74252238, "author": "Tirth Patel", "author_id": 4593315, "author_profile": "https://Stackoverflow.com/users/4593315", "pm_score": 1, "selected": false, "text": "dart:io" } ]
2022/10/30
[ "https://Stackoverflow.com/questions/74252221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20350355/" ]
74,252,237
<p>We have a table having around 10 million records and we are trying to update some columns using the id(primary key) in the where clause.</p> <pre><code>UPDATE table_name SET column1=1, column2=0,column3='2022-10-30' WHERE id IN(1,2,3,4,5,6,7,......etc); </code></pre> <p>Scenario 1: when there are 3000 or fewer ids in the IN clause and if I try for EXPLAIN, then the 'possible_keys' and 'key' show the PRIMARY, and the query gets executed very fast.</p> <p>Scenario 2: when there are 3000 or more ids(up to 30K) in the IN clause and if I try for EXPLAIN, then the 'possible_keys' shows NULL and the 'key' shows the PRIMARY and the query runs forever. If I use FORCE INDEX(PRIMARY) then the 'possible_keys' and the 'key' shows the PRIMARY and the query gets executed very fast.</p> <p>Scenario 3: when there are more than 30k ids in the IN clause and even if I use FORCE INDEX(PRIMARY), the 'possible_keys' shows NULL, and the 'key' shows the PRIMARY and the query runs forever.</p> <p>I believe the optimizer is going for a full table scan instead of an index scan. Can we make any change such that the optimizer goes for an index scan instead of a table scan? Please suggest if there are any parameter changes required to overcome this issue.</p> <p>The MySQL version is 5.7</p>
[ { "answer_id": 74252238, "author": "Tirth Patel", "author_id": 4593315, "author_profile": "https://Stackoverflow.com/users/4593315", "pm_score": 1, "selected": false, "text": "dart:io" } ]
2022/10/30
[ "https://Stackoverflow.com/questions/74252237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7761587/" ]
74,252,272
<p>I'm trying to split current line into 3 chunks. Title column contains comma which is delimiter</p> <pre><code>1,&quot;Rink, The (1916)&quot;,Comedy </code></pre> <p>Current code is not working</p> <pre><code>id, title, genres = line.split(',') </code></pre> <p>Expected result</p> <pre><code>id = 1 title = 'Rink, The (1916)' genres = 'Comedy' </code></pre> <p>Any thoughts how to split it properly?</p>
[ { "answer_id": 74252238, "author": "Tirth Patel", "author_id": 4593315, "author_profile": "https://Stackoverflow.com/users/4593315", "pm_score": 1, "selected": false, "text": "dart:io" } ]
2022/10/30
[ "https://Stackoverflow.com/questions/74252272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1743128/" ]
74,252,277
<p>Assuming I have the following module <strong>signature</strong> and <strong>implementation</strong> in the same file named <code>monoids.ml</code>:</p> <pre class="lang-ml prettyprint-override"><code>module type MonoidADT = sig type 'a monoid (* . . . *) end module Monoid : MonoidADT = struct type 'a monoid = Monoid of ('a list) * ('a -&gt; 'a -&gt; 'a) * ('a) (* . . . *) end </code></pre> <p>How am I supposed to use a constructor, of the type defined in the implementation, in an other file (module)? Is it directly accesible or should I create something like a factory function with <code>'a monoid</code> as return type?</p> <p>What I tried to do is simply open the module and call its constructor as I would do inside the module, but of course it doesn't work and gives me <code>Unbound constructor Monoid</code> error:</p> <pre class="lang-ml prettyprint-override"><code>open Monoids.Monoid;; let boolean_monoid = Monoid ([true; false], ( || ), false);; </code></pre>
[ { "answer_id": 74252445, "author": "octachron", "author_id": 7369366, "author_profile": "https://Stackoverflow.com/users/7369366", "pm_score": 1, "selected": false, "text": "module Monoid : MonoidADT = struct\n ...\nend\n" }, { "answer_id": 74252586, "author": "Riccardo Raff...
2022/10/30
[ "https://Stackoverflow.com/questions/74252277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10637300/" ]
74,252,295
<p>It's selenium. and the development environment pycharm What does the yellow line in import os mean? and Hod do I solve This error?? And I want to save images crawled by Google using Selenium to my desktop file. desktop file name 'Image'.<br /> file address is '/Users/jun/Desktop/PyCham/selenium image folder</p> <p>help me . I'm english pool sorry.</p> <p><a href="https://i.stack.imgur.com/jpH8T.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jpH8T.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74252445, "author": "octachron", "author_id": 7369366, "author_profile": "https://Stackoverflow.com/users/7369366", "pm_score": 1, "selected": false, "text": "module Monoid : MonoidADT = struct\n ...\nend\n" }, { "answer_id": 74252586, "author": "Riccardo Raff...
2022/10/30
[ "https://Stackoverflow.com/questions/74252295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20261183/" ]
74,252,320
<p>Why I'm getting a null string through Intent even after passing the value?</p> <p>MainActivity</p> <pre><code> private lateinit var binding: ActivityMainBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding=ActivityMainBinding.inflate(layoutInflater) setContentView(binding.root) binding.btnFirst.setOnClickListener { val name=binding.etName.text.toString() Intent(this,SecondActivity::class.java).also{ it.putExtra(&quot;EXTRA_NAME&quot;,name) startActivity(it) } } } }``` SecondActivity ```class SecondActivity:AppCompatActivity() { private lateinit var binding: ActivitySecondBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding= ActivitySecondBinding.inflate(layoutInflater) setContentView(binding.root) val name=intent.getStringArrayExtra(&quot;EXTRA_NAME&quot;) val toPrint=&quot;$name hahahaha&quot; binding.tvNameIntent.text=toPrint } } </code></pre> <p>toPrint is getting &quot;null hahahaha&quot;</p> <p>Can someone please rectify my error</p>
[ { "answer_id": 74252380, "author": "laalto", "author_id": 101361, "author_profile": "https://Stackoverflow.com/users/101361", "pm_score": 2, "selected": false, "text": "String" } ]
2022/10/30
[ "https://Stackoverflow.com/questions/74252320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19005139/" ]
74,252,349
<p>I am fairly new to programming, so I hope you can help me.</p> <p>I want to check if a input string is a palindrome. The palindrome-checker is case-insensitive.</p> <p>Here is what I got so far:</p> <pre><code># input word word = input(&quot;Enter a word: &quot;) # make it case-INsensitive word = word.lower() # we also need the length of word to iterate over its range length_word = int(len(word)) ### use a for-loop for letter in range(len(word)): if word[-length_word] == word[-1]: print(word, &quot;is a palindrome.&quot;) # if it doesn't match, its not a palindrome, print message else: print(word, &quot;is not a palindrome.&quot;) </code></pre> <p>What bothers me is that it prints the phrase &quot;is a palindrome.&quot; everytime. How can I fix it so it will only print it once if the word is a palindrome?</p> <p>Thank you so much in advance!</p>
[ { "answer_id": 74252421, "author": "ScottC", "author_id": 20174226, "author_profile": "https://Stackoverflow.com/users/20174226", "pm_score": 3, "selected": true, "text": "# input word \nword = input(\"Enter a word: \")\n\n# make it case-INsensitive\nword = word.lower()\n\n# check word a...
2022/10/30
[ "https://Stackoverflow.com/questions/74252349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20370992/" ]
74,252,350
<p>Hi im creating this model class Users and it look like this</p> <pre><code>class User { int? id; String? name; String? username; String? email; Address? address; String? phone; String? website; Company? company; User( {this.id, this.name, this.username, this.email, this.address, this.phone, this.website, this.company}); User.fromJson(Map&lt;String, dynamic&gt; json) { id = json['id']; name = json['name']; username = json['username']; email = json['email']; address = json['address'] != null ? new Address.fromJson(json['address']) : null; phone = json['phone']; website = json['website']; company = json['company'] != null ? new Company.fromJson(json['company']) : null; } Map&lt;String, dynamic&gt; toJson() { final Map&lt;String, dynamic&gt; data = new Map&lt;String, dynamic&gt;(); data['id'] = this.id; data['name'] = this.name; data['username'] = this.username; data['email'] = this.email; if (this.address != null) { data['address'] = this.address!.toJson(); } data['phone'] = this.phone; data['website'] = this.website; if (this.company != null) { data['company'] = this.company!.toJson(); } return data; } } class Address { String? street; String? suite; String? city; String? zipcode; Geo? geo; Address({this.street, this.suite, this.city, this.zipcode, this.geo}); Address.fromJson(Map&lt;String, dynamic&gt; json) { street = json['street']; suite = json['suite']; city = json['city']; zipcode = json['zipcode']; geo = json['geo'] != null ? new Geo.fromJson(json['geo']) : null; } Map&lt;String, dynamic&gt; toJson() { final Map&lt;String, dynamic&gt; data = new Map&lt;String, dynamic&gt;(); data['street'] = this.street; data['suite'] = this.suite; data['city'] = this.city; data['zipcode'] = this.zipcode; if (this.geo != null) { data['geo'] = this.geo!.toJson(); } return data; } } class Geo { String? lat; String? lng; Geo({this.lat, this.lng}); Geo.fromJson(Map&lt;String, dynamic&gt; json) { lat = json['lat']; lng = json['lng']; } Map&lt;String, dynamic&gt; toJson() { final Map&lt;String, dynamic&gt; data = new Map&lt;String, dynamic&gt;(); data['lat'] = this.lat; data['lng'] = this.lng; return data; } } class Company { String? name; String? catchPhrase; String? bs; Company({this.name, this.catchPhrase, this.bs}); Company.fromJson(Map&lt;String, dynamic&gt; json) { name = json['name']; catchPhrase = json['catchPhrase']; bs = json['bs']; } Map&lt;String, dynamic&gt; toJson() { final Map&lt;String, dynamic&gt; data = new Map&lt;String, dynamic&gt;(); data['name'] = this.name; data['catchPhrase'] = this.catchPhrase; data['bs'] = this.bs; return data; } } </code></pre> <p>and this is the json response im getting from API</p> <pre><code>[ { &quot;id&quot;: 1, &quot;name&quot;: &quot;Leanne Graham&quot;, &quot;username&quot;: &quot;Bret&quot;, &quot;email&quot;: &quot;Sincere@april.biz&quot;, &quot;address&quot;: { &quot;street&quot;: &quot;Kulas Light&quot;, &quot;suite&quot;: &quot;Apt. 556&quot;, &quot;city&quot;: &quot;Gwenborough&quot;, &quot;zipcode&quot;: &quot;92998-3874&quot;, &quot;geo&quot;: { &quot;lat&quot;: &quot;-37.3159&quot;, &quot;lng&quot;: &quot;81.1496&quot; } }, &quot;phone&quot;: &quot;1-770-736-8031 x56442&quot;, &quot;website&quot;: &quot;hildegard.org&quot;, &quot;company&quot;: { &quot;name&quot;: &quot;Romaguera-Crona&quot;, &quot;catchPhrase&quot;: &quot;Multi-layered client-server neural-net&quot;, &quot;bs&quot;: &quot;harness real-time e-markets&quot; } }, { &quot;id&quot;: 2, &quot;name&quot;: &quot;Ervin Howell&quot;, &quot;username&quot;: &quot;Antonette&quot;, &quot;email&quot;: &quot;Shanna@melissa.tv&quot;, &quot;address&quot;: { &quot;street&quot;: &quot;Victor Plains&quot;, &quot;suite&quot;: &quot;Suite 879&quot;, &quot;city&quot;: &quot;Wisokyburgh&quot;, &quot;zipcode&quot;: &quot;90566-7771&quot;, &quot;geo&quot;: { &quot;lat&quot;: &quot;-43.9509&quot;, &quot;lng&quot;: &quot;-34.4618&quot; } }, &quot;phone&quot;: &quot;010-692-6593 x09125&quot;, &quot;website&quot;: &quot;anastasia.net&quot;, &quot;company&quot;: { &quot;name&quot;: &quot;Deckow-Crist&quot;, &quot;catchPhrase&quot;: &quot;Proactive didactic contingency&quot;, &quot;bs&quot;: &quot;synergize scalable supply-chains&quot; } }, { &quot;id&quot;: 3, &quot;name&quot;: &quot;Clementine Bauch&quot;, &quot;username&quot;: &quot;Samantha&quot;, &quot;email&quot;: &quot;Nathan@yesenia.net&quot;, &quot;address&quot;: { &quot;street&quot;: &quot;Douglas Extension&quot;, &quot;suite&quot;: &quot;Suite 847&quot;, &quot;city&quot;: &quot;McKenziehaven&quot;, &quot;zipcode&quot;: &quot;59590-4157&quot;, &quot;geo&quot;: { &quot;lat&quot;: &quot;-68.6102&quot;, &quot;lng&quot;: &quot;-47.0653&quot; } }, &quot;phone&quot;: &quot;1-463-123-4447&quot;, &quot;website&quot;: &quot;ramiro.info&quot;, &quot;company&quot;: { &quot;name&quot;: &quot;Romaguera-Jacobson&quot;, &quot;catchPhrase&quot;: &quot;Face to face bifurcated interface&quot;, &quot;bs&quot;: &quot;e-enable strategic applications&quot; } }, { &quot;id&quot;: 4, &quot;name&quot;: &quot;Patricia Lebsack&quot;, &quot;username&quot;: &quot;Karianne&quot;, &quot;email&quot;: &quot;Julianne.OConner@kory.org&quot;, &quot;address&quot;: { &quot;street&quot;: &quot;Hoeger Mall&quot;, &quot;suite&quot;: &quot;Apt. 692&quot;, &quot;city&quot;: &quot;South Elvis&quot;, &quot;zipcode&quot;: &quot;53919-4257&quot;, &quot;geo&quot;: { &quot;lat&quot;: &quot;29.4572&quot;, &quot;lng&quot;: &quot;-164.2990&quot; } }, &quot;phone&quot;: &quot;493-170-9623 x156&quot;, &quot;website&quot;: &quot;kale.biz&quot;, &quot;company&quot;: { &quot;name&quot;: &quot;Robel-Corkery&quot;, &quot;catchPhrase&quot;: &quot;Multi-tiered zero tolerance productivity&quot;, &quot;bs&quot;: &quot;transition cutting-edge web services&quot; } } ] </code></pre> <p>this is the controller im using to pass the json to model class</p> <pre><code>class user_controller extends GetxController { final user_repo repo; user_controller({required this.repo}); List&lt;dynamic&gt; userList = []; Future&lt;void&gt; getUserData() async { Response response = await repo.getUserData(); if (response.statusCode == 200) { userList.add(User.fromJson(response.body)); } else {} } } </code></pre> <p>but I pass the response like this it generates an error</p> <p>List' is not a subtype of type 'Map&lt;String, dynamic&gt;'</p> <p>I change the class like this<code> User.fromJson(List&lt;dynamic&gt; json)</code> like that way I can pass the data like this <code>id =json[0][&quot;id&quot;] </code></p> <p>but it only pass the id of first element of the list</p> <p>How Can I pass all the data? this list has 5 map object I want to display all this data on a listview using this model</p>
[ { "answer_id": 74252370, "author": "eamirho3ein", "author_id": 10306997, "author_profile": "https://Stackoverflow.com/users/10306997", "pm_score": 2, "selected": false, "text": "controller" } ]
2022/10/30
[ "https://Stackoverflow.com/questions/74252350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20370427/" ]
74,252,363
<p>I am looking at this export syntax and don't understand what it means:</p> <pre class="lang-js prettyprint-override"><code>export default { name: 'my-component', data () { return {} } } </code></pre> <p>Is this an object, a list, or what? Why is there an attribute name for <code>name</code> but nothing for the 2nd member? How does this work?</p>
[ { "answer_id": 74252370, "author": "eamirho3ein", "author_id": 10306997, "author_profile": "https://Stackoverflow.com/users/10306997", "pm_score": 2, "selected": false, "text": "controller" } ]
2022/10/30
[ "https://Stackoverflow.com/questions/74252363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1957846/" ]
74,252,367
<p>There was a problem adding user data to cards. More precisely, I didn’t quite understand how to do this, I know that there are fetch requests, but if there is a json file, and I have a regular js file (here it is userData.js <a href="https://playcode.io/919658" rel="nofollow noreferrer">https://playcode.io/919658</a>), how can I connect the data correctly from another file? Thanks a lot in advance.</p> <p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false"> <div class="snippet-code snippet-currently-hidden"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const userData = [ { "id": 1, "name": "John", "description": "fafewqrewrqwer2322revzd", "profilePicture": "https://images.unsplash.com/1535713875002-d1d0cf377fde?ixlib=rb-1.2.1&amp;ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&amp;auto=format&amp;fit=crop&amp;w=580&amp;q=80" }, { "id": 2, "name": "Josh", "description": "qweqwsxasdqwew", "profilePicture": "https://images.unsplash.com/photo-1570295999919-56ceb5ecca61?ixlib=rb-1.2.1&amp;ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&amp;auto=format&amp;fit=crop&amp;w=580&amp;q=80" }, { "id": 3, "name": "Jane", "description": "yjtykyumjhjhjkgjhhjkhkj", "profilePicture": "https://media.istockphoto.com/photos/elegant-beauty-picture-id516208984?k=20&amp;m=516208984&amp;s=612x612&amp;w=0&amp;h=KooFBmqHtO2lz5CFV5Oe87u_12wgKCxHvTHxlYuErCU=" }, { "id": 4, "name": "Iness", "description": "k4jh23k4jh23kjhk2jhk", "profilePicture": "https://images.unsplash.com/photo-1573496359142-b8d87734a5a2?ixlib=rb-1.2.1&amp;ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&amp;auto=format&amp;fit=crop&amp;w=388&amp;q=80" } ] const root = document.querySelector('#root') function section() { const section = document.createElement('section') section.classList.add('section'); return section; } // function article() { // const article = document.createElement('article') // article.classList.add('article'); // return article; // } // function img(imgSrc) { // const img = document.createElement('img') // img.setAttribute('src', imgSrc); // img.classList.add('img'); // return img; // } // function h1() { // const h1 = document.createElement('h1') // h1.textContent = 'Name'; // h1.classList.add('h1'); // return h1; // } // function p() { // const p = document.createElement('p') // h1.textContent = 'Description'; // p.classList.add('p'); // return p; // } function button() { const button = document.createElement('button') button.classList.add('button') return button; } const userCards = userData.map(section); root.append(...userCards);</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>* { margin: 0; padding: 0; box-sizing: border-box; } html { font-size: 62.5%; --font-size-sm: 2rem; --font-size-md: 2.4rem; } body { min-height: 100vh; background-color: blanchedalmond; } #root { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 50px; padding: 10%; } section { position: relative; padding: 1.2rem; width: 100%; height: 350px; border: 2px solid black; background-color: white; border-radius: 15px; } .section-name { font-size: var(--font-size-md, 24px); } .section-desc { font-size: var(--font-size-sm, 18px); padding: 2rem 0; } article { text-align: center; margin-top: 20%; } img { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; } button { background-color: hsl(229deg 100% 73%); border: none; width: 120px; height: 40px; border-radius: 10px; font-size: 15px; font-family: Arial, Helvetica, sans-serif; color: white; cursor: pointer; box-shadow: 0 0 5px 0 black; margin-top: 20px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt; &lt;link rel="stylesheet" href="style.css"&gt; &lt;!-- &lt;script src='./UsersData.js' defer&gt;&lt;/script&gt; --&gt; &lt;script src='./script.js' defer&gt;&lt;/script&gt; &lt;title&gt;Usercards&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="root"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74252438, "author": "Franco Agustín Torres", "author_id": 20318366, "author_profile": "https://Stackoverflow.com/users/20318366", "pm_score": 0, "selected": false, "text": "id=\"root\"" }, { "answer_id": 74252555, "author": "Mina", "author_id": 11887902, ...
2022/10/30
[ "https://Stackoverflow.com/questions/74252367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19665304/" ]
74,252,418
<p>I use this regex to mark whole sentences ending in period, question mark or exclamation mark - it works so far.</p> <pre><code>[A-Z][^.!?]*[.?!] </code></pre> <p>But there are two problems:</p> <ol> <li>if there is a number followed by a period in the sentence.</li> <li>if there is an abbreviation with a period in the sentence.</li> </ol> <p>Then the sentence is extracted incorrectly. Example:</p> <blockquote> <ol> <li>Sentence Example: &quot;Er kam am 1. November.&quot;</li> </ol> </blockquote> <blockquote> <ol start="2"> <li>Sentence Example: &quot;Dr. Schiwago.&quot;</li> </ol> </blockquote> <p>The first sentence then becomes two sentences because a period follows the number. The second sentence then also becomes two sentences because the abbreviation ends in a period.</p> <p>How can I adjust the regex so that both problems do not occur?</p> <p>So in the first sentence, whenever a period follows a number, this should not be seen as the end of the sentence, but the regex continues to the next period.</p> <p>In the second sentence, for example, a minimum size of 4 characters would ensure that the abbreviation is not seen as a complete sentence.</p> <p><a href="https://regex101.com/r/2mZayI/1" rel="nofollow noreferrer">DEMO</a></p>
[ { "answer_id": 74252438, "author": "Franco Agustín Torres", "author_id": 20318366, "author_profile": "https://Stackoverflow.com/users/20318366", "pm_score": 0, "selected": false, "text": "id=\"root\"" }, { "answer_id": 74252555, "author": "Mina", "author_id": 11887902, ...
2022/10/30
[ "https://Stackoverflow.com/questions/74252418", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3392296/" ]
74,252,454
<p>I'm trying to :</p> <ol> <li>Upload an Excel to the controller from a Blazor page</li> <li>Process the rows in the controller and perform some stuff with them (and return empty response if successful)</li> <li>If there were validation errors while parsing the Excel, return them to the page</li> </ol> <p>I don't know how many rows there will be beforehand, so I'm returning that number too from the controller. I don't have a model either, so I'll just fake it in Blazor to display the validation errors. The ValidationMessages won't show. Here's a test code, without need of a server invocation:</p> <pre class="lang-cs prettyprint-override"><code>@using System.Collections &lt;button @onclick=&quot;GenerateErrors&quot;&gt; Generate &lt;/button&gt; &lt;EditForm EditContext=&quot;@editContext&quot;&gt; @if (Errors != null) { for (int i = 0; i &lt; Errors.Rows; i++) { &lt;ValidationMessage For=&quot;()=&gt;cmd.Users[i].Name&quot; /&gt; } } &lt;/EditForm&gt; @code { private record FakeValidationError(string Identifier, string ErrorMessage); // This is what I would get from the controller private record FakeValidationErrors(List&lt;FakeValidationError&gt; Errors, int? Rows); private class FakeList&lt;T&gt; : IList&lt;T&gt; where T : new() { public T this[int index] { get =&gt; _factory == null ? new T() : _factory(); set =&gt; _ = value; } private Func&lt;T&gt; _factory; public int Count =&gt; throw new NotImplementedException(); public FakeList(Func&lt;T&gt; factory = null) { _factory = factory; } public bool IsReadOnly =&gt; false; public void Add(T item) =&gt; throw new NotImplementedException(); public void Clear() =&gt; throw new NotImplementedException(); public bool Contains(T item) =&gt; throw new NotImplementedException(); public void CopyTo(T[] array, int arrayIndex) =&gt; throw new NotImplementedException(); public IEnumerator&lt;T&gt; GetEnumerator() { yield return _factory == null ? new T() : _factory(); } public int IndexOf(T item) =&gt; throw new NotImplementedException(); public void Insert(int index, T item) =&gt; throw new NotImplementedException(); public bool Remove(T item) =&gt; throw new NotImplementedException(); public void RemoveAt(int index) =&gt; throw new NotImplementedException(); IEnumerator IEnumerable.GetEnumerator() { yield return _factory == null ? new T() : _factory(); } } private class FakeUser { public string Name { get; set; } } private class FakeUsers { public IList&lt;FakeUser&gt; Users { get; set; } = new FakeList&lt;FakeUser&gt;(); } // This is the model, which I have to fake, because it only lives in the controller when it parses the Excel // It's not returned by it because it won't validate, so it's meaningless. FakeUsers cmd = new(); protected override async Task OnInitializedAsync() { editContext = new(cmd); messageStore = new(editContext); base.OnInitialized(); } FakeValidationErrors Errors = null; protected EditContext editContext; protected ValidationMessageStore messageStore; private void GenerateErrors() { List&lt;FakeValidationError&gt; l = new(); l.Add(new(&quot;Users[5].Name&quot;, &quot;Bad name at #5&quot;)); Errors = new(l, 8); messageStore?.Clear(); foreach (var x in Errors.Errors) { FieldIdentifier f = new FieldIdentifier(cmd, x.Identifier); messageStore.Add(f, x.ErrorMessage); } editContext.NotifyValidationStateChanged(); } } </code></pre> <p>I know there are a lot of pragmatic ways to achieve this. But I want to know, specifically, why this won't work. This piece of code</p> <pre class="lang-cs prettyprint-override"><code> messageStore?.Clear(); foreach (var x in Errors.Errors) { FieldIdentifier f = new FieldIdentifier(cmd, x.Identifier); messageStore.Add(f, x.ErrorMessage); } editContext.NotifyValidationStateChanged(); </code></pre> <p>works all the time in other EditForms.</p> <p>UPDATE: There was a typo in the code. It's been deleted(Errors=new())</p> <p>ValidationSummary works</p> <p>I've tried with a variable so the lambda won't capture i. It makes no difference</p> <pre class="lang-cs prettyprint-override"><code>for (int i = 0; i &lt; Errors.Rows; i++) { var j=i; &lt;ValidationMessage For=&quot;()=&gt;cmd.Users[j].Name&quot; /&gt; } </code></pre>
[ { "answer_id": 74255224, "author": "MrC aka Shaun Curtis", "author_id": 13065781, "author_profile": "https://Stackoverflow.com/users/13065781", "pm_score": 2, "selected": false, "text": "ValidatationMessage" }, { "answer_id": 74275899, "author": "faibistes", "author_id": ...
2022/10/30
[ "https://Stackoverflow.com/questions/74252454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1801534/" ]
74,252,479
<p>The use of the askopenfilename is quite easy but its counterpart is a bit more complicated. I can get the box to open and enter the name but the file created is empty</p> <pre class="lang-py prettyprint-override"><code>import tkinter as tk from tkinter.filedialog import askopenfilename, asksaveasfilename import PyPDF4 # import des fichiers root = tk.Tk() root.withdraw() file1 = askopenfilename() file2 = askopenfilename() # import des fichiers pdf pdfFile1 = PyPDF4.PdfFileReader(file1, 'rb') pdfFile2 = PyPDF4.PdfFileReader(file2, 'rb') #création de l'objet pdf newPdf = PyPDF4.PdfFileWriter() # fonction d'extraction des pages du pdf def extract_page(pdfFile): for numPage in range(pdfFile.numPages): page = pdfFile.getPage(numPage) newPdf.addPage(page) # application de la fct sur nos objets-pdf extract_page(pdfFile1) extract_page(pdfFile2) # création du nouveau Pdf et écriture file = asksaveasfilename(defaultextension=&quot;.pdf&quot;) pdfCombined = open(file, &quot;wb&quot;) newPdf.write(pdfCombined) file.close() </code></pre> <p>My previous script is <code>pdfCombined = open('path', 'wb')</code> but i want the program to ask for a file name</p>
[ { "answer_id": 74252984, "author": "Сергей Кох", "author_id": 18400908, "author_profile": "https://Stackoverflow.com/users/18400908", "pm_score": 1, "selected": false, "text": "file = asksaveasfilename(defaultextension=\".pdf\")\n# pdfCombined = open(file, \"wb\")\n# newPdf.write(pdfComb...
2022/10/30
[ "https://Stackoverflow.com/questions/74252479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19995498/" ]
74,252,503
<p>I want to change an image when the user hovers over a certain text. I found this question on stackoverflow (<a href="https://stackoverflow.com/questions/28398273/change-image-on-hover-javascript">Change Image On Hover Javascript</a>), but here the image is changed when the user hovers the image not the text. So I tried to adapt the code of the answer, so that the image is cahnged on texthover (I just put the &quot;onmouseover&quot; and &quot;onmouseout&quot; into the h1 instead of the img).</p> <p>This is the code of the answer which changes the image when the user hovers the image:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;img onmouseover="this.src='images/Logo white transparent.png'" onmouseout="this.src='images/Logo black transparent.png'" height="100px" src="images/Logo black transparent.png" /&gt;</code></pre> </div> </div> </p> <p>And this is the code I tried in order to change the image when the text is hovered:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;img height="100px" src="images/Logo black transparent.png" /&gt; &lt;h1 onmouseover="this.src='images/Logo white transparent.png'" onmouseout="this.src='images/Logo black transparent.png'" &gt; Hello &lt;/h1&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74252984, "author": "Сергей Кох", "author_id": 18400908, "author_profile": "https://Stackoverflow.com/users/18400908", "pm_score": 1, "selected": false, "text": "file = asksaveasfilename(defaultextension=\".pdf\")\n# pdfCombined = open(file, \"wb\")\n# newPdf.write(pdfComb...
2022/10/30
[ "https://Stackoverflow.com/questions/74252503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332178/" ]
74,252,504
<p>I'm Trying to make code where an employees are filtered by their skills, with if the employee has one or no skills, they don't come up. I got the first half done, getting them filtered by their skills, but whenever I try to add a COUNT, it doesn't work unless it's running entirely on its own!</p> <pre><code>Select k.employeeID, COUNT (*) FROM EmployeeSkills_t k GROUP BY k.employeeID HAVING COUNT(*)&gt;1 </code></pre> <p>Does not want to intergrate with</p> <pre><code>select e.Employeename, s.skillDescription from EmployeeSkills_t k INNER JOIN Employee_t e ON k.EmployeeID = e.EmployeeID INNER JOIN Skill_t s ON k.skillID=s.skillID ORDER BY e.Employeename, skillDescription </code></pre>
[ { "answer_id": 74252984, "author": "Сергей Кох", "author_id": 18400908, "author_profile": "https://Stackoverflow.com/users/18400908", "pm_score": 1, "selected": false, "text": "file = asksaveasfilename(defaultextension=\".pdf\")\n# pdfCombined = open(file, \"wb\")\n# newPdf.write(pdfComb...
2022/10/30
[ "https://Stackoverflow.com/questions/74252504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20371110/" ]
74,252,509
<p>I'm receiving an array of objects in form of a json file, and using ajax to display certain key-value pairs in a table. My next step is to sort the rendered table, but I'm unsure of how to proceed.</p> <pre><code>&lt;div id=&quot;data-table&quot;&gt; &lt;table id=&quot;html-data-table&quot;&gt; &lt;tr&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Age&lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; </code></pre> <p>Javascript code which creates the table:</p> <pre><code>newData.map(row =&gt; { let newRow = document.createElement(&quot;tr&quot;); // new row is created Object.values(row).map((value) =&gt; { //console.log(value); let cell = document.createElement(&quot;td&quot;); // new data for the row is added cell.innerText = value; newRow.appendChild(cell); }) mytable.appendChild(newRow); }); </code></pre> <p>I want to sort this both columns individually. What method can I use?</p>
[ { "answer_id": 74252984, "author": "Сергей Кох", "author_id": 18400908, "author_profile": "https://Stackoverflow.com/users/18400908", "pm_score": 1, "selected": false, "text": "file = asksaveasfilename(defaultextension=\".pdf\")\n# pdfCombined = open(file, \"wb\")\n# newPdf.write(pdfComb...
2022/10/30
[ "https://Stackoverflow.com/questions/74252509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17204104/" ]
74,252,514
<p>I use three different GitHub accounts.</p> <p>I have correctly set my ssh keys (created, added to keyring, added to github).</p> <p>Doing <code>ssh-add -l</code> returns:</p> <pre><code>3072 SHA256:/Vq3tN5FxtE64LALAe25GQr+MpIPbGg mail@first.com (RSA) 3072 SHA256:9NheazRnzMzicLALA6z70kQeO6tQcNZcePJw0RRk mail@second.com (RSA) 3072 SHA256:r7uaTSfE9ZXn7LALAGHIn4syyaKPPyXsKdK8Sjk mail@third.com (RSA) </code></pre> <p>In my <strong>~/.ssh/.config</strong> file I have:</p> <pre><code># GITHUB FIRST Host github.com-first-user HostName github.com User git IdentityFile ~/.ssh/first-user # GITHUB SECOND Host github.com-second-user HostName github.com User git IdentityFile ~/.ssh/second-user # GITHUB THIRD Host github.com-third-user HostName github.com User git IdentityFile ~/.ssh/third-user </code></pre> <p>In my global git config I did not add any user/email config.</p> <p>Each repository contains the correct user and email.</p> <p>When I try to push, it says that <code>first-user</code> doesn't have permission.</p> <pre><code>ERROR: Permission to user/repo.git denied to first-user. fatal: Could not read from remote repository. </code></pre> <p>I believe to have read somewhere that git uses the ssh key it sees, so maybe it is seeing the first key and taking that.</p> <p>Doing <code>git config --list --show-origin --show-scope</code> in the repo folder, I get:</p> <pre><code>global file:/home/user/.gitconfig core.autocrlf=input local file:.git/config user.name=Second local file:.git/config user.email=mail@second.com </code></pre> <p>Nowhere is there any setup for the first user.</p> <p>Doing <code>git remote -v</code> returns:</p> <pre><code>origin git@github.com-second-user:user/repo.git (fetch) origin git@github.com-second-user:user/repo.git (push) </code></pre> <p><strong>Relevant note:</strong></p> <p>Doing <code>ssh -T github.com-second-user</code> returns <em>Hi <strong>first-user</strong>!, You've successfully authenticated...</em></p> <p><strong>Note</strong>: this error happens both using the git cli, and also using git via the phpStorm UI.</p> <p>How can I force it to use the second key for the second user?</p> <p>Thanks!</p>
[ { "answer_id": 74252685, "author": "torek", "author_id": 1256452, "author_profile": "https://Stackoverflow.com/users/1256452", "pm_score": 3, "selected": true, "text": "IdentitiesOnly yes\n" }, { "answer_id": 74271113, "author": "Mạnh Đỗ", "author_id": 16142058, "auth...
2022/10/30
[ "https://Stackoverflow.com/questions/74252514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10716664/" ]
74,252,521
<p>I'm using Springboot and JPA to create two tables sharing the same primary key.</p> <p>For the first table I write:</p> <pre><code>public class UserAccount implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @OneToOne(mappedBy =&quot;user&quot;, cascade = {CascadeType.REMOVE, CascadeType.MERGE, CascadeType.REFRESH}, fetch=FetchType.LAZY) @PrimaryKeyJoinColumn private UserLogin login; } </code></pre> <p>For the second table I write:</p> <pre><code>public class UserLogin implements Serializable { @Id private Long user_id; @OneToOne(cascade = {CascadeType.MERGE, CascadeType.REFRESH}, fetch=FetchType.LAZY) @MapsId(&quot;user_id&quot;) @JoinColumn(name = &quot;user_id&quot;, referencedColumnName = &quot;id&quot;) @Setter(AccessLevel.NONE) private UserAccount user; public void setUser(UserAccount user) { this.user = user; this.user_id = user.getId(); } } </code></pre> <p>Other stuff are omitted for conciseness. The code works because I manually set the id of UserLogin by writing the statement</p> <pre><code>this.user_id = user.getId(); </code></pre> <p>otherwise I get the error:</p> <blockquote> <p>Hibernate error: ids for this class must be manually assigned before calling save():</p> </blockquote> <p>I guess that the ids can be manually managed but I cannot get the right configuration.</p> <p>UPDATE: I found the solution thanks (see the accepted answer). Now I just would get rid of the findById() when setting the user login.</p> <pre><code>//these methods are defined within a dedicated @Service @Transactional public void createLoginInfo(UserAccount user) { UserLogin userlogin=new UserLogin(); this.addLoginToUser(userlogin,user); loginService.save(userlogin); } @Transactional public void addLoginToUser(UserLogin login, UserAccount account) { //whit this commented line works //UserAccount acc= this.findById(account.getId()); login.setUser(account); account.setLogin(login); } //In a transactional test method I first create the user then I call userService.save(theuser); userService.createLoginInfo(theuser); </code></pre>
[ { "answer_id": 74253954, "author": "grigouille", "author_id": 14946729, "author_profile": "https://Stackoverflow.com/users/14946729", "pm_score": 1, "selected": true, "text": "public class UserLogin implements Serializable\n {\n @Id\n private Long user_id;\n\n @OneToOne(fetch=Fe...
2022/10/30
[ "https://Stackoverflow.com/questions/74252521", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2260835/" ]
74,252,524
<p>I have created an ASP.NET Core Web API app that connects to a SQL Server database. I have a table in which I need to use SQL Server always encryption.</p> <p>I'm creating a column master key with the following T-SQL:</p> <pre><code> CREATE COLUMN MASTER KEY [MyCMK] WITH ( KEY_STORE_PROVIDER_NAME = N'MSSQL_CERTIFICATE_STORE', KEY_PATH = N'CurrentUser/my/2DB1E2F1BE5E2A640FB1626895DB174D1A3176DD' ); </code></pre> <p>and then a column encryption key using this column master key as follows:</p> <pre><code> CREATE COLUMN ENCRYPTION KEY [MyCEK] WITH VALUES ( COLUMN_MASTER_KEY = [MyCMK], ALGORITHM = 'RSA_OAEP', ENCRYPTED_VALUE = 0x016E000001630075007200720065006E00740075007300650072002F006D0079002F0032006400620031006500320066003100620065003500650032006100360034003000660062003100360032003600380039003500640062003100370034006400310061003300310037003600640064002E9E339743391E3829BF1A7B9DF9BAF6858F7D46928D9285A01C6833A049F0DE3A01192B274CD793AD49572F372F79D825B999A4ED2DE824D694A5FA0AC42D62CCA8CCC20D4182F31B52C919E343BF945E518C836F2444304A18307A03C33C1BFA6FB7938F4FC004B11FD4EBD8FC773292689936EAAC6A0B0CD16B5BA937F0169FBC75B3380E23A196DF905292CEDA6F4DEC327F29EBF8B65CD7B073B4BEB07D2B3CC3E6E24951B27B7E0B1ACE272DEA133C41932C72381262B74A7FABF4E84129A3F4D36639D662ECBD4C0D25CA360248559B4479B7076F9C8BD352CBCB4D6460201DBB5CC734139F5032AE241F8491779BBE10554568554AC9530EB76AE2AD560E8D4CB18FA6DDAA7763E873DCA23D582176E84D78BF2E59D2ED2D926932D05231F52D7E9E01AADC08A039DDC082F0F2B67115922E01772741CE19DE63C7AA4B6B2E3A120717FD04A6A31FB72713CA603E5ADF701497D5EAE1E3920DDF24EB9DD367CBAB8CEDFEDBEAEDC7CD8C2123066AC5BCE552AB3E3C211D38DEDDCB3300EFC652FB03443EE91429CFEE802484FD84E7FA1194CD2A753D0CCA29FAC8286F79390C3E24B5F0ACA479FD5F3BBB78F82A4C4F32FF33C878B1895A0C6CB57F05CBE69FC2D1A26236102F19F2256FE7352A5CB3B6700F373B6DBC7E022EC5DBFE405BCAA96B5B0A070FB704E251F804B9F5AC2EFE4E75C8D02B3DCEA21B90C4 ); </code></pre> <p>Then I create my table using TSQL which has 2 encrypted columns:</p> <pre><code>CREATE TABLE [Appraisal].[Answer] ( [Id] [uniqueidentifier] NOT NULL, [AppraisalId] [uniqueidentifier] NOT NULL, [QuestionId] [uniqueidentifier] NOT NULL, [AppraiserId] [uniqueidentifier] NOT NULL, [AppraisedId] [uniqueidentifier] NOT NULL, [InteractionGroupId] [uniqueidentifier] NOT NULL, [Point] [int] ENCRYPTED WITH ( COLUMN_ENCRYPTION_KEY = MyCEK, ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256'), [Comment] [nvarchar](1024) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (COLUMN_ENCRYPTION_KEY = MyCEK, ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256'), [CreateDateTime] [datetime] NOT NULL ) </code></pre> <p>Then in order to install my certificate on any machine which will host my app I export SQL Server Always Encrypted certificate using windows certification manager to my application root folder and try to install it using this code:</p> <pre><code>X509Certificate2 cert = new X509Certificate2(&quot;MyExportedCertificate.pfx&quot;, &quot;MyPassword&quot;, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet); X509Store store = new X509Store(StoreName.My); </code></pre> <p>I run the app and everything works fine. the X509Certificate2 class installs my certificate and my app can encrypt/decrypt the data.</p> <p>then I create a docker file using Visual Studio&gt; Add Item&gt; Docker Support and add this line of code to copy my &quot;*.pfx&quot; file to my app's root folder:</p> <pre><code>FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine3.16-amd64 AS base WORKDIR /app EXPOSE 80 EXPOSE 443 COPY [&quot;Api/MyExportedCertificate.pfx&quot;, &quot;&quot;] </code></pre> <ul> <li>rest of the docker file contents are omitted for clarity.</li> </ul> <p>then I edit my docker-compose file to add my sql server image:</p> <pre><code>services: api: image: ali-api container_name: web_api_application ports: - &quot;5000:80&quot; environment: - ASPNETCORE_ENVIRONMENT=Production sqldb: image: mcr.microsoft.com/mssql/server:2019-latest environment: - SA_PASSWORD=Qwerty*2607548 - ACCEPT_EULA=Y ports: - &quot;1440:1433&quot; container_name: sqldb </code></pre> <p>and finally I build my app:</p> <pre><code>docker build -t ali-api -f Api/Dockerfile . docker-compose up </code></pre> <p>my app starts working and I can access my swagger page.</p> <p><a href="https://i.stack.imgur.com/RwLPx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RwLPx.png" alt="enter image description here" /></a></p> <p>I can see that CMK and CEK are both generated too.</p> <p><a href="https://i.stack.imgur.com/fN3Wk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fN3Wk.png" alt="enter image description here" /></a></p> <p>And also my always encryption is done as well:</p> <p><a href="https://i.stack.imgur.com/wFyIk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wFyIk.png" alt="enter image description here" /></a></p> <p>But it seems that my license is not installed, because when I want to insert a data to my encrypted table columns I get the error:</p> <blockquote> <p>An error occurred while saving the entity changes. See the inner exception for details. Failed to decrypt a column encryption key using key store provider: 'MSSQL_CERTIFICATE_STORE'. The last 10 bytes of the encrypted column encryption key are: '51-29-CD-17-1C-E2-6E-13-A4-45'. Operation is not supported on this platform.</p> </blockquote> <p>what am I doing wrong?</p> <p>how can I import this certificate in linux?(docker)</p> <p>how can I install this certificate in linux?(docker)</p> <p>.pfx file is located in my app's root folder. how can I install this .pfx file in linux?</p> <p><a href="https://i.stack.imgur.com/duds9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/duds9.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74253954, "author": "grigouille", "author_id": 14946729, "author_profile": "https://Stackoverflow.com/users/14946729", "pm_score": 1, "selected": true, "text": "public class UserLogin implements Serializable\n {\n @Id\n private Long user_id;\n\n @OneToOne(fetch=Fe...
2022/10/30
[ "https://Stackoverflow.com/questions/74252524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2451499/" ]
74,252,528
<p>i am beginner at php. I want to calculate exact total number of days between two dates using php, mysql and want to show it in html form. I tried datediff but it doesn't works as it gives , diffrence not total number of days.</p> <p>Date fm - 10-10-22; Date to - 20-10-22; Total Days - 11</p>
[ { "answer_id": 74253954, "author": "grigouille", "author_id": 14946729, "author_profile": "https://Stackoverflow.com/users/14946729", "pm_score": 1, "selected": true, "text": "public class UserLogin implements Serializable\n {\n @Id\n private Long user_id;\n\n @OneToOne(fetch=Fe...
2022/10/30
[ "https://Stackoverflow.com/questions/74252528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20371139/" ]
74,252,549
<p>When i run the application it doesnt fetch the data</p> <pre><code>import 'package:fakeapi/homepage.dart'; import 'package:flutter/material.dart'; import 'dart:convert'; import 'package:fakeapi/album.dart'; import 'package:flutter/material.dart'; import 'package:flutter/src/widgets/container.dart'; import 'package:flutter/src/widgets/framework.dart'; import 'package:http/http.dart' as http; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.lightGreen, ), home: const HomePage(), ); } } class HomePage extends StatefulWidget { const HomePage({super.key}); @override State&lt;HomePage&gt; createState() =&gt; _HomePageState(); } class _HomePageState extends State&lt;HomePage&gt; { @override Widget build(BuildContext context) { return Scaffold( body: FutureBuilder( builder: ((context, snapshot) { if (snapshot.hasError) { throw Exception(&quot;ERROR&quot;); } else if (snapshot.hasData) { ListView.builder( itemBuilder: ((context, index) { return Text(snapshot.data!.title); }), itemCount: 1, ); } return Center( child: CircularProgressIndicator(), ); }), future: getAlbums(), ), ); } } Future&lt;Album&gt; getAlbums() async { final response = await http .get(Uri.parse(&quot;https://jsonplaceholder.typicode.com/albums/10&quot;)); if (response.statusCode == 200) { return Album.fromJson(jsonDecode(response.body)); } else { throw Exception(&quot;hey&quot;); } } // To parse this JSON data, do // // final album = albumFromJson(jsonString); List&lt;Album&gt; albumFromJson(String str) =&gt; List&lt;Album&gt;.from(json.decode(str).map((x) =&gt; Album.fromJson(x))); String albumToJson(List&lt;Album&gt; data) =&gt; json.encode(List&lt;dynamic&gt;.from(data.map((x) =&gt; x.toJson()))); This is how i coded my class </code></pre> <pre><code>class Album { Album({ required this.userId, required this.id, required this.title, }); int userId; int id; String title; factory Album.fromJson(Map&lt;String, dynamic&gt; json) =&gt; Album( userId: json[&quot;userId&quot;], id: json[&quot;id&quot;], title: json[&quot;title&quot;], ); Map&lt;String, dynamic&gt; toJson() =&gt; { &quot;userId&quot;: userId, &quot;id&quot;: id, &quot;title&quot;: title, }; } </code></pre> <pre><code> </code></pre> <p>I tried to fetch data and display it</p> <pre><code>import 'package:fakeapi/homepage.dart'; import 'package:flutter/material.dart'; import 'dart:convert'; import 'package:fakeapi/album.dart'; import 'package:flutter/material.dart'; import 'package:flutter/src/widgets/container.dart'; import 'package:flutter/src/widgets/framework.dart'; import 'package:http/http.dart' as http; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.lightGreen, ), home: const HomePage(), ); } } class HomePage extends StatefulWidget { const HomePage({super.key}); @override State&lt;HomePage&gt; createState() =&gt; _HomePageState(); } class _HomePageState extends State&lt;HomePage&gt; { @override Widget build(BuildContext context) { return Scaffold( body: FutureBuilder( builder: ((context, snapshot) { if (snapshot.hasError) { throw Exception(&quot;ERROR&quot;); } else if (snapshot.hasData) { ListView.builder( itemBuilder: ((context, index) { return Text(snapshot.data!.title); }), itemCount: 1, ); } return Center( child: CircularProgressIndicator(), ); }), future: getAlbums(), ), ); } } Future&lt;Album&gt; getAlbums() async { final response = await http .get(Uri.parse(&quot;https://jsonplaceholder.typicode.com/albums/10&quot;)); if (response.statusCode == 200) { return Album.fromJson(jsonDecode(response.body)); } else { throw Exception(&quot;hey&quot;); } } // To parse this JSON data, do // // final album = albumFromJson(jsonString); List&lt;Album&gt; albumFromJson(String str) =&gt; List&lt;Album&gt;.from(json.decode(str).map((x) =&gt; Album.fromJson(x))); String albumToJson(List&lt;Album&gt; data) =&gt; json.encode(List&lt;dynamic&gt;.from(data.map((x) =&gt; x.toJson()))); class Album { Album({ required this.userId, required this.id, required this.title, }); int userId; int id; String title; factory Album.fromJson(Map&lt;String, dynamic&gt; json) =&gt; Album( userId: json[&quot;userId&quot;], id: json[&quot;id&quot;], title: json[&quot;title&quot;], ); Map&lt;String, dynamic&gt; toJson() =&gt; { &quot;userId&quot;: userId, &quot;id&quot;: id, &quot;title&quot;: title, }; } </code></pre>
[ { "answer_id": 74252572, "author": "Robert Sandberg", "author_id": 13263384, "author_profile": "https://Stackoverflow.com/users/13263384", "pm_score": 0, "selected": false, "text": "return ListView.builder(\n itemBuilder: ((context, index) {\n return Text(snap...
2022/10/30
[ "https://Stackoverflow.com/questions/74252549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20371130/" ]
74,252,563
<p>Say I have the following Dataframe.</p> <pre><code>df = pd.DataFrame([[&quot;a&quot;, &quot;b&quot;, &quot;c&quot;], [&quot;d&quot;, &quot;e&quot;, &quot;f&quot;],[&quot;g&quot;, &quot;h&quot;, &quot;i&quot;]]) </code></pre> <p>How do I get the column index of &quot;c&quot; in row 0?</p> <p>I know there are ways to get the column index if there are column labels, but I can't find ways to return the column index just based on the cell value, if searching a particular row.</p> <hr />
[ { "answer_id": 74252572, "author": "Robert Sandberg", "author_id": 13263384, "author_profile": "https://Stackoverflow.com/users/13263384", "pm_score": 0, "selected": false, "text": "return ListView.builder(\n itemBuilder: ((context, index) {\n return Text(snap...
2022/10/30
[ "https://Stackoverflow.com/questions/74252563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19669877/" ]
74,252,598
<p>I'm trying to make a page with a horizontal scrolled image gallery using flex grid.</p> <p>The gallery should be centered on the page with bars on the sides. To accomplish this, I have created a css grid with areas <code>'mainleft maincenter mainright'</code>. It shuld look something like this: <a href="https://i.stack.imgur.com/Xt0K3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xt0K3.png" alt="Horizontal image gallery" /></a></p> <p>The problem is the page is not responsive. So, if I do not set <code>max-width</code> of the gallery the site looks like this: <a href="https://i.stack.imgur.com/Gws3Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gws3Y.png" alt="Horizontal image gallery" /></a></p> <p>The gallery overflows the entire page. Setting <code>max-width</code> to 100% do not work. Setting <code>max-widt</code> to something like 700px works but then the page is not responsive anymore.</p> <p>Code for the page:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot;&gt; &lt;head&gt; &lt;title&gt;HScroll gallery test&lt;/title&gt; &lt;style&gt; main { background-color:aqua; display: grid; grid-template-columns: 100px auto 100px; grid-template-rows: auto; grid-template-areas: 'mainleft maincenter mainright'; } .left { grid-area: mainleft; background-color:coral; } .right { grid-area: mainright; background-color:coral; } .gallery { grid-area: maincenter; position: relative; max-width: 100%; /* Not working */ padding: 0 10; } .gallery_scroller { /* snap mandatory on horizontal axis */ scroll-snap-type: x mandatory; overflow-x: scroll; overflow-y: hidden; display: flex; align-items: center; height: 300px; /* Enable Safari touch scrolling physics which is needed for scroll snap */ -webkit-overflow-scrolling: touch; } .gallery_scroller img { /* snap align center */ scroll-snap-align: center; scroll-snap-stop: always; margin:22px; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;main class=&quot;main&quot;&gt; &lt;div class=&quot;left&quot;&gt; &lt;/div&gt; &lt;div class=&quot;gallery&quot;&gt; &lt;div class=&quot;gallery_scroller&quot;&gt; &lt;img src=&quot;https://placeimg.com/300/300/animals/grayscale&quot;/&gt; &lt;img src=&quot;https://placeimg.com/360/480/animals/grayscale&quot;/&gt; &lt;img src=&quot;https://placeimg.com/640/480/animals/grayscale&quot;/&gt; &lt;img src=&quot;https://placeimg.com/360/360/animals/grayscale&quot;/&gt; &lt;img src=&quot;https://placeimg.com/2560/960/animals/grayscale&quot;/&gt; &lt;img src=&quot;https://placeimg.com/360/360/animals/grayscale&quot;/&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;right&quot;&gt; &lt;/div&gt; &lt;/main&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code> main { background-color:aqua; display: grid; grid-template-columns: 100px auto 100px; grid-template-rows: auto; grid-template-areas: 'mainleft maincenter mainright'; } .left { grid-area: mainleft; background-color:coral; } .right { grid-area: mainright; background-color:coral; } .gallery { grid-area: maincenter; position: relative; width: 100%; /* Not working */ padding: 0 10; } .gallery_scroller { /* snap mandatory on horizontal axis */ scroll-snap-type: x mandatory; overflow-x: scroll; overflow-y: hidden; display: flex; align-items: center; height: 300px; /* Enable Safari touch scrolling physics which is needed for scroll snap */ -webkit-overflow-scrolling: touch; } .gallery_scroller img { /* snap align center */ scroll-snap-align: center; scroll-snap-stop: always; margin:22px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;main class="main"&gt; &lt;div class="left"&gt; &lt;/div&gt; &lt;div class="gallery"&gt; &lt;div class="gallery_scroller"&gt; &lt;img src="https://placeimg.com/300/300/animals/grayscale"/&gt; &lt;img src="https://placeimg.com/360/480/animals/grayscale"/&gt; &lt;img src="https://placeimg.com/640/480/animals/grayscale"/&gt; &lt;img src="https://placeimg.com/360/360/animals/grayscale"/&gt; &lt;img src="https://placeimg.com/2560/960/animals/grayscale"/&gt; &lt;img src="https://placeimg.com/360/360/animals/grayscale"/&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="right"&gt; &lt;/div&gt; &lt;/main&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74252572, "author": "Robert Sandberg", "author_id": 13263384, "author_profile": "https://Stackoverflow.com/users/13263384", "pm_score": 0, "selected": false, "text": "return ListView.builder(\n itemBuilder: ((context, index) {\n return Text(snap...
2022/10/30
[ "https://Stackoverflow.com/questions/74252598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3294855/" ]
74,252,607
<p>I am trying to do a <a href="https://stackoverflow.com/a/5668050/10515002">rebase on the remote branch</a>, but I get the following error:</p> <pre class="lang-bash prettyprint-override"><code>$ git rebase -i origin/master~2 master # fatal: invalid upstream 'origin/master~2' </code></pre> <p>I have tried to do a <code>git fetch</code> and <code>git pull</code> but it doesn't fix the problem.</p> <p>In the <code>git log</code> I can see the following:</p> <pre class="lang-bash prettyprint-override"><code>$ git log # commit 611e384e89da3cec1e45bf59d7564580912e5073 (HEAD -&gt; master, origin/master) # Author: Shahrad Elahi &lt;shahradq@gmail.com&gt; # Date: Sun Oct 30 14:38:57 2022 +0330 # # Initial Commit # # commit 8ae591b238960b862eb67bbb37377b5ca1611c47 # Author: Shahrad Elahi &lt;shahradq@gmail.com&gt; # Date: Sun Oct 30 14:34:50 2022 +0330 # # Initial Commit </code></pre>
[ { "answer_id": 74252684, "author": "knittl", "author_id": 112968, "author_profile": "https://Stackoverflow.com/users/112968", "pm_score": 3, "selected": true, "text": "git rebase -i --root" }, { "answer_id": 74252696, "author": "eftshift0", "author_id": 2437508, "auth...
2022/10/30
[ "https://Stackoverflow.com/questions/74252607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10515002/" ]
74,252,647
<p>i am trying to displaying the new value every time the user click the button but it keeps displaying the old data. I need to hot restart to see the new data after i update it. I do not know what i did wrong because i am still learning. This is my full code. I hope someone can help me because i am stuck here 3 hours +</p> <pre><code>TextEditingController _reloadEditingController = new TextEditingController(); int balance = 0; late int s = int.parse(_reloadEditingController.text); final _formKey = GlobalKey&lt;FormState&gt;(); String? name; String email = ''; String phoneNumber = ''; String imageUrl = ''; String joinedAt = ''; String location = ''; void reload() async { FirebaseFirestore.instance .collection(&quot;users&quot;) .doc(widget.userID) .update({&quot;balance&quot;: balance + s}); } void getUserData() async { try { _isLoading = true; final DocumentSnapshot userDoc = await FirebaseFirestore.instance .collection('users') .doc(widget.userID) .get(); if (userDoc == null) { return; } else { setState(() { name = userDoc.get('name'); email = userDoc.get('email'); phoneNumber = userDoc.get('phoneNumber'); imageUrl = userDoc.get('userImage'); location = userDoc.get('location'); balance = userDoc.get('balance'); }); final FirebaseAuth _auth = FirebaseAuth.instance; User? user = _auth.currentUser; final _uid = user!.uid; setState(() { _isSameUser = _uid == widget.userID; }); } } catch (error) { } finally { _isLoading = false; } } void initState() { super.initState(); getUserData(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.teal[300], appBar: AppBar( title: const Text('Wallet'), flexibleSpace: Container( color: Colors.teal[300], ), leading: IconButton( onPressed: () { final FirebaseAuth _auth = FirebaseAuth.instance; final User? user = _auth.currentUser; final String uid = user!.uid; Navigator.pushReplacement( context, MaterialPageRoute( builder: (_) =&gt; ProfileScreen( userID: uid, ))); }, icon: Icon(Icons.arrow_back, size: 40, color: Colors.white)), ), body: ListView( children: [ Column( children: [ Container( width: 300, padding: EdgeInsets.all(20), decoration: BoxDecoration( borderRadius: BorderRadius.circular(16), color: Color(0xFF006e6e)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Text( name!, style: TextStyle(color: Colors.white, fontSize: 18), ), ], ), ], ), ), Container( padding: EdgeInsets.all(10), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 25), child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Row( children: [ Text( &quot;Balance&quot;, ), ], ), Row( children: [ Text( 'RM', ), Container( child: FutureBuilder&lt;DocumentSnapshot&gt;( future: FirebaseFirestore.instance .collection('users') .doc(widget.userID) .get(), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return Center( child: CircularProgressIndicator(), ); } return Text(balance.toString()); }, ), ), ], ), Row( children: [ Text(&quot;Reload your E-Wallet&quot;, ) ], ), Row( children: [ Form( key: _formKey, child: Expanded( child: TextFormField( controller: _reloadEditingController, keyboardType: TextInputType.phone, ), ), ) ], ) ], ), ), ), Container( width: 320, child: MaterialButton( onPressed: () { reload(); }, child: Padding( padding: EdgeInsets.symmetric(vertical: 14), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( &quot;Reload E-Wallet&quot;, ) ], ), ), ), ), ], ) ], )); </code></pre>
[ { "answer_id": 74252777, "author": "eamirho3ein", "author_id": 10306997, "author_profile": "https://Stackoverflow.com/users/10306997", "pm_score": 1, "selected": false, "text": "getUserData" } ]
2022/10/30
[ "https://Stackoverflow.com/questions/74252647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15003461/" ]
74,252,649
<p>I'm really new to the world of python, and especially dictionaries, so it is very likely that the answer to my question is quite simple, but I really can't figure it out...</p> <p>My problem is, that I can't seem to figure out how to access one specific list element at a certain position when I have a dictionary that has a list as it's values.</p> <p>More specifically I have the following list:</p> <pre><code>my_books = {'Eragon': [2007,'Paolin'], 'Harry Potter': [1992,'Rowling'], 'Obscura': [2017, 'Canon'], 'Many Wonders': [1964,'Meyers'], 'Never': [2001, 'McKey']} </code></pre> <p>What I now want to achieve is that it returns me the value at list position 1 and the title of the book (the key) in a very simple, alphabetically sorted table.</p> <p>Output required:</p> <pre><code>Canon Obscura McKey Never Meyers Many Wonders Paolin Eragon Rowling Harry Potter </code></pre> <p>What I can't seem to figure out is how to only print the list element at position 1, instead of the whole list.</p> <p>My code:</p> <pre><code>for book in my_books: print(my_books[book], ' ', book) </code></pre> <p>My output:</p> <pre><code>[2007,'Paolin'] Eragon [1992,'Rowling'] Harry Potter [2017, 'Canon'] Obscura [1964,'Meyers'] Many Wonders [2001, 'McKey'] Never </code></pre> <p>Anyways, if any one of you could help me out here I would greatly appreciate it!</p>
[ { "answer_id": 74252700, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 2, "selected": false, "text": "my_books = {\n \"Eragon\": [2007, \"Paolin\"],\n \"Harry Potter\": [1992, \"Rowling\"],\n \"Obscura...
2022/10/30
[ "https://Stackoverflow.com/questions/74252649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20364472/" ]
74,252,668
<p>currently I'm trying the following setup:</p> <p>I have:</p> <ul> <li>one cluster</li> <li>one Ingress Controller</li> <li>one url (myapp.onazure.com)</li> <li>two namespaces for two applications default and default-test</li> <li>two deployments, ingress objects, services for the namespaces</li> </ul> <p>I can easily reach my app from the default namespace with path based routing '/' as a prefix rule Now i have tried to configure the second namespace and following rule: /testing to hit another service</p> <p>Unfortunately i get an HTTP404 when i try to hit the following URL myapp.onazure.com/testing/openapi.json</p> <p>What did I miss?</p> <p><strong>Working Ingress 1</strong></p> <pre><code>kind: Ingress apiVersion: networking.k8s.io/v1 metadata: name: liveapi-ingress-object namespace: default annotations: kubernetes.io/ingress.class: public-nginx spec: tls: - hosts: - myapp-region1.onazure.com - myapp-region2.onazure.com secretName: ingress-tls-csi rules: - host: - myapp-region1.onazure.com http: paths: - path: / pathType: Prefix backend: service: name: liveapi-svc port: number: 8080 - host: myapp-region2.onazure.com http: paths: - path: / pathType: Prefix backend: service: name: liveapi-svc port: number: 8080 </code></pre> <p><strong>Not working Ingress 2</strong></p> <pre><code>kind: Ingress apiVersion: networking.k8s.io/v1 metadata: name: liveapi-ingress-object-testing namespace: default-testing annotations: kubernetes.io/ingress.class: public-nginx #nginx.ingress.kubernetes.io/rewrite-target: /testing spec: tls: - hosts: - myapp-region1.onazure.com - myapp-region2.onazure.com secretName: ingress-tls-csi-testing rules: - host: myapp-region1.onazure.com http: paths: - path: /testing #pathType: Prefix backend: service: name: liveapi-svc-testing port: number: 8080 - host: myapp-region2.onazure.com http: paths: - path: /testing #pathType: Prefix backend: service: name: liveapi-svc-testing port: number: 8080 </code></pre> <p>Maybe I am missing a rewrite target to simply '/' in the testing namespace ingress?</p>
[ { "answer_id": 74252947, "author": "Reda E.", "author_id": 15307414, "author_profile": "https://Stackoverflow.com/users/15307414", "pm_score": 0, "selected": false, "text": "$SERVICE.$NAMESPACE.svc.cluster.local\n" }, { "answer_id": 74286139, "author": "Artur123", "author...
2022/10/30
[ "https://Stackoverflow.com/questions/74252668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20331557/" ]
74,252,691
<p>I am trying to implement an interface of the shape of</p> <pre><code>type someUnion = &quot;foo&quot; | &quot;bar&quot;; interface RecursiveInterface { a: number; b: Array&lt;number&gt;; [key in someUnion]?: RecursiveInterface; } </code></pre> <p>to describe objects like</p> <pre><code>const someObject: RecursiveInterface = { a: 2, b: [1,5], foo: { a: 0, b: [2,6], bar: { a: 8, b: 7 } } } </code></pre> <p>However this leads to the error <code>A mapped type may not declare properties or methods.</code></p> <p>Suggesting that the following is viable</p> <pre><code>type mappedType = { [key in someUnion]?: RecursiveInterface; } </code></pre> <p>which throws no errors, but as the initial error suggests, does not allow additional properties.</p> <p>Extending the initial interface with the mappedType appears to work though, as in</p> <pre><code>interface RecursiveInterface extends mappedType { a: number; b: Array&lt;number&gt; } </code></pre> <p>Now my question is, <strong>is this the correct way to define the desired interface or is there a more concise option, that does not require extending the interface with an additional mapped type?</strong></p>
[ { "answer_id": 74252947, "author": "Reda E.", "author_id": 15307414, "author_profile": "https://Stackoverflow.com/users/15307414", "pm_score": 0, "selected": false, "text": "$SERVICE.$NAMESPACE.svc.cluster.local\n" }, { "answer_id": 74286139, "author": "Artur123", "author...
2022/10/30
[ "https://Stackoverflow.com/questions/74252691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14804461/" ]
74,252,695
<p>Inside of the react fragment I have to add conditional statement. On basis of the conditional statement, return what expected</p> <pre><code>return ( &lt;React.Fragment&gt; &lt;Toolbar pageTitle={i18next.t('TITLE')} iconButtons={this.state.icons} {this.props.abc &amp;&amp; this.props.abc.operation ?( moreButton={moreButton} ):null} /&gt; </code></pre> <p>if this.props.abc.operation is present then only show morebutton if not show only iconbuttons this is my condition and above is the code i tried. any help would be really appreciated.</p>
[ { "answer_id": 74252947, "author": "Reda E.", "author_id": 15307414, "author_profile": "https://Stackoverflow.com/users/15307414", "pm_score": 0, "selected": false, "text": "$SERVICE.$NAMESPACE.svc.cluster.local\n" }, { "answer_id": 74286139, "author": "Artur123", "author...
2022/10/30
[ "https://Stackoverflow.com/questions/74252695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20260032/" ]
74,252,734
<p>I'm trying to make an automation program to scrape part of a website. But this website is made out of javascript, and the part of the website I want to scrape is in a shadow dom.</p> <p>So I figured out that I should use selenium to go to that website and use this code to access elements in shadow dom</p> <pre><code>def expand_shadow_element(element): shadow_root = driver.execute_script('return arguments[0].shadowRoot', element) return shadow_root </code></pre> <p>and use</p> <pre><code>driver.page_source </code></pre> <p>to get the HTML of that website. But this code doesn't show me elements that are inside the shadow dom.</p> <p>I've tried combining those two and tried</p> <pre><code>root1 = driver.find_element(By. CSS_SELECTOR, &quot;path1&quot;) shadow_root = expand_shadow_element(root1) html = shadow_root.page_source </code></pre> <p>but I got</p> <pre><code>AttributeError: 'ShadowRoot' object has no attribute 'page_source' </code></pre> <p>for a response. So I think that I need to use BeautifulSoup to scrape data from that page, but I can't figure out how to combine BeautifulSoup and Selenium to scrape data from a shadow dom.</p> <hr/> <p>P.S. If the part I want to scrape is</p> <pre><code>&lt;h3&gt;apple&lt;/h3&gt; &lt;p&gt;1$&lt;/p&gt; &lt;p&gt;red&lt;/p&gt; </code></pre> <p>I want to scrape that code exactly, not</p> <pre><code>apple 1$ red </code></pre>
[ { "answer_id": 74252947, "author": "Reda E.", "author_id": 15307414, "author_profile": "https://Stackoverflow.com/users/15307414", "pm_score": 0, "selected": false, "text": "$SERVICE.$NAMESPACE.svc.cluster.local\n" }, { "answer_id": 74286139, "author": "Artur123", "author...
2022/10/30
[ "https://Stackoverflow.com/questions/74252734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16247845/" ]
74,252,737
<p>I have a database of a the employees of a company that looks like this:</p> <pre><code>{ _id: 7698, name: 'Blake', job: 'manager', manager: 7839, hired: ISODate(&quot;1981-05-01T00:00:00.000Z&quot;), salary: 2850, department: {name: 'Sales', location: 'Chicago'}, missions: [ {company: 'Mac Donald', location: 'Chicago'}, {company: 'IBM', location: 'Chicago'} ] } </code></pre> <p>I have an exercise in which I need to write the MongoDb command that returns all them employees who did all their missions in Chicago. I struggle with the all because I cannot find a way to check that all the locations of the missions array are equal to 'Chicago'.</p> <p>I was thinking about doing it in two time: first find the total number of missions the employee has and then compare it to the number of mission he has in Chicago (that how I would do in SQL I guess). But I cannot found the number of mission the employee did in Chicago. Here is what I tried:</p> <pre><code>db.employees.aggregate([ { $match: { &quot;missions&quot;: { $exists: true } } }, { $project: { name: 1, nbMissionsChicago: { $sum: { $cond: [ { $eq: [{ $getField: { field: { $literal: &quot;$location&quot; }, input: &quot;$missions&quot; } }, &quot;Chicago&quot;] }, 1, 0 ] } } } } ]) </code></pre> <p>Here is the result :</p> <pre><code>{ _id: 7698, name: 'Blake', nbMissionsChicago: 0 } { _id: 7782, name: 'Clark', nbMissionsChicago: 0 } { _id: 8000, name: 'Smith', nbMissionsChicago: 0 } { _id: 7902, name: 'Ford', nbMissionsChicago: 0 } { _id: 7499, name: 'Allen', nbMissionsChicago: 0 } { _id: 7654, name: 'Martin', nbMissionsChicago: 0 } { _id: 7900, name: 'James', nbMissionsChicago: 0 } { _id: 7369, name: 'Smith', nbMissionsChicago: 0 } </code></pre> <p>First of all, is there a better method to check that all the locations of the missions array respect the condition? And why does this commands returns only 0 ?</p> <p>Thanks!</p>
[ { "answer_id": 74252947, "author": "Reda E.", "author_id": 15307414, "author_profile": "https://Stackoverflow.com/users/15307414", "pm_score": 0, "selected": false, "text": "$SERVICE.$NAMESPACE.svc.cluster.local\n" }, { "answer_id": 74286139, "author": "Artur123", "author...
2022/10/30
[ "https://Stackoverflow.com/questions/74252737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19858170/" ]
74,252,741
<p>A question dawned on me lately: Why bother having the <strong>scope resolution operator</strong> (<code>::</code>) when the usage of the <strong>dot operator</strong> (<code>.</code>) doesn't clash with the former?</p> <p>Like,</p> <pre><code>namespace my_module { const int insane_constant = 69; int some_threshold = 100; } </code></pre> <p>In order to access <code>some_threshold</code>, one would write <code>my_module::some_threshold</code>. But the thing is the left hand side of <code>::</code> must be a namespace or a class, as far as I know, while that of the <code>.</code> can never be a namespace or a class. Moreover, the order of <code>::</code> is higher than <code>.</code>, which is really pointless in my opinion. Why make 2 distinct operators, both of which cannot be overloaded, with use cases can be covered with just one? I'm having a hard time finding any satisfying answer, so any clue on this matter is much appriciated.</p>
[ { "answer_id": 74252861, "author": "Thomas Weller", "author_id": 480982, "author_profile": "https://Stackoverflow.com/users/480982", "pm_score": 1, "selected": false, "text": "#include <iostream>\nnamespace my_module\n{\n const int insane_constant = 69;\n}\nclass C{\n public:\n ...
2022/10/30
[ "https://Stackoverflow.com/questions/74252741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13372362/" ]
74,252,760
<p>I have installed a npm package, however i am using the vue framework. The npm package is written in JS, but Vue's syntax is different that JS, even though it is a JS framework. How can i use the package in my vue project?</p> <p>I have mainly installed the npm package and unsure how to translate what is written in it. i am new to coding and only recently learnt JS and now trying Vue</p>
[ { "answer_id": 74252846, "author": "kissu", "author_id": 8816585, "author_profile": "https://Stackoverflow.com/users/8816585", "pm_score": 0, "selected": false, "text": "swiper/vue" }, { "answer_id": 74253395, "author": "Ninowis", "author_id": 3245139, "author_profile...
2022/10/30
[ "https://Stackoverflow.com/questions/74252760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20371345/" ]
74,252,801
<p>This is my code</p> <pre><code>houses = ['C', 'D', 'H', 'S'] ranks = ['A','2','3','4','5','6','7','8','9','10','J','Q','K'] deck = [] for house in houses: for rank in ranks: deck.append(f&quot;{rank}-{house}&quot;) for i in range(13): print(deck[i], end=&quot;,&quot;)` </code></pre> <p>The output is supposed to be:</p> <pre class="lang-none prettyprint-override"><code>A-C,2-C,3-C,4-C,5-C,6-C,7-C,8-C,9-C,10-C,J-C,Q-C,K-C </code></pre> <p>but I got</p> <pre class="lang-none prettyprint-override"><code>A-C,2-C,3-C,4-C,5-C,6-C,7-C,8-C,9-C,10-C,J-C,Q-C,K-C, </code></pre> <p>How do I remove the last comma?</p>
[ { "answer_id": 74252846, "author": "kissu", "author_id": 8816585, "author_profile": "https://Stackoverflow.com/users/8816585", "pm_score": 0, "selected": false, "text": "swiper/vue" }, { "answer_id": 74253395, "author": "Ninowis", "author_id": 3245139, "author_profile...
2022/10/30
[ "https://Stackoverflow.com/questions/74252801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20370477/" ]
74,252,803
<p>I am building a wordpress plugin in which I have implement a widget which shows analytics chart from the wordpress data table named dummy using rest api but I am failing to do so. I am using reactjs for building plugin and axios for fetching data from database and recharts for showing analytics chart.</p> <pre class="lang-js prettyprint-override"><code>import React from 'react'; import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts'; import axios from 'axios'; const API_URL = &quot;http://localhost/wordpress2/wp-json/wp/v2?query=dummy&quot; const Dashboard = () =&gt; { axios.get(API_URL) .then(Response =&gt; {console.log(Response.data); }).catch(err =&gt; console.log(err)); return ( &lt;div className='dashboard' &gt; &lt;div className=&quot;card&quot; &gt; &lt;h3&gt;Analytics&lt;/h3&gt; &lt;ResponsiveContainer&gt; &lt;LineChart data={Response}&gt; &lt;XAxis dataKey=&quot;post&quot; /&gt; &lt;YAxis /&gt; &lt;Legend/&gt; &lt;Tooltip /&gt; &lt;CartesianGrid stroke=&quot;#eee&quot; /&gt; &lt;Line type=&quot;monotone&quot; dataKey=&quot;likes&quot; stroke=&quot;#8884d8&quot; /&gt; &lt;Line type=&quot;monotone&quot; dataKey=&quot;dislikes&quot; stroke=&quot;#82ca9d&quot; /&gt; &lt;/LineChart&gt; &lt;/ResponsiveContainer&gt; &lt;/div&gt; &lt;/div&gt; ); } export default Dashboard; </code></pre> <p>In my wordpress dashboard plugin is working well and chart is also showing but without data it will show when apiurl problem is solved.</p>
[ { "answer_id": 74253012, "author": "Varun Kaklia", "author_id": 18574568, "author_profile": "https://Stackoverflow.com/users/18574568", "pm_score": 0, "selected": false, "text": "const[data,setData] = useState()\nuseEffect(()=>{\n const apiData = axios.get(API_URL)\n .then(Resp...
2022/10/30
[ "https://Stackoverflow.com/questions/74252803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19811360/" ]
74,252,816
<p>I need to Filter/Show data on the visible cells only on my dataset.<br> The using of AutoFilter is very fast, But it has a downside that it show any hidden rows on the respective criteria. .<br> Although I am using arrays and Application optimization on the below code , but it gets very slow if the range starts to be bigger. <br> With just 100 rows, it finished on 1.12 sec and with 1000 rows it finished on 117.47 sec ! <br> In advance, I am grateful for all your support.<br></p> <pre><code>Option Explicit Option Compare Text Sub Filter_on_Visible_Cells_Only() Dim t: t = Timer Dim ws1 As Worksheet, ws2 As Worksheet Dim rng1 As Range, rng2 As Range Dim arr1() As Variant, arr2() As Variant Dim i As Long, HdRng As Range Dim j As Long, k As Long SpeedOn Set ws1 = ThisWorkbook.ActiveSheet Set ws2 = ThisWorkbook.Sheets(&quot;Platforms&quot;) Set rng1 = ws1.Range(&quot;D3:D&quot; &amp; ws1.Cells(Rows.Count, &quot;D&quot;).End(xlUp).Row) 'ActiveSheet Set rng2 = ws2.Range(&quot;B3:B&quot; &amp; ws2.Cells(Rows.Count, &quot;A&quot;).End(xlUp).Row) 'Platforms arr1 = rng1.Value2 arr2 = rng2.Value2 For i = 1 To UBound(arr1) If ws1.Rows(i + 2).Hidden = False Then '(i + 2) because Data starts at Row_3 For j = LBound(arr1) To UBound(arr1) For k = LBound(arr2) To UBound(arr2) If arr1(j, 1) &lt;&gt; arr2(k, 1) Then addToRange HdRng, ws1.Range(&quot;A&quot; &amp; i + 2) 'Make a union range of the rows NOT matching criteria... End If Next k Next j End If Next i If Not HdRng Is Nothing Then HdRng.EntireRow.Hidden = True 'Hide not matching criteria rows. Speedoff Debug.Print &quot;Filter_on_Visible_Cells, in &quot; &amp; Round(Timer - t, 2) &amp; &quot; sec&quot; End Sub Private Sub addToRange(rngU As Range, rng As Range) If rngU Is Nothing Then Set rngU = rng Else Set rngU = Union(rngU, rng) End If End Sub Sub SpeedOn() With Application .Calculation = xlCalculationManual .ScreenUpdating = False .EnableEvents = False .DisplayAlerts = False End With End Sub Sub Speedoff() With Application .Calculation = xlCalculationAutomatic .ScreenUpdating = True .EnableEvents = True .DisplayAlerts = True End With End Sub </code></pre>
[ { "answer_id": 74253012, "author": "Varun Kaklia", "author_id": 18574568, "author_profile": "https://Stackoverflow.com/users/18574568", "pm_score": 0, "selected": false, "text": "const[data,setData] = useState()\nuseEffect(()=>{\n const apiData = axios.get(API_URL)\n .then(Resp...
2022/10/30
[ "https://Stackoverflow.com/questions/74252816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17797849/" ]
74,252,828
<p>I'm trying to add an image to a navbar, and I have countless issues regardless of the approach I take. The image &quot;exits&quot; the container when it is too big, the image isn't aligned in the center - vertically or horizontally, the image changes how the navbar looks depending on the size...</p> <p>I just want an image that fits either at the end or just somewhere in my navbar, and moves with the other elements if I resize the page. (i.e. stays to the right of the other tags).</p> <p>I have this code as part of the freecodecamp challenge of making a product landing page, and I'm trying to make a navbar, with the logo within the navbar. I wanted it at the right but I've since given up I just want it in it.</p> <p>I've tried the W3School tutorials, tried using Flexbox (example in the code here) and a bunch of different things. The problem is that the image isn't &quot;in the container.&quot; I can always modify its size and it will either exit the navbar, modify the navbar size... countless issues.</p> <p>Here is the html &amp; CSS:</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>html { box-sizing: border-box; } nav { display: flex; flex-direction: row; justify-content: space-evenly; align-items: center; background-color: rgba(0, 0, 0, 0.8); height: 30px; width: 100%; } li { display: inline; } ul { list-style-type: none; padding: 0; margin: 0; } a { text-decoration: none; color: white; } img { display: inline; width: 20px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;header id="header"&gt; &lt;img id="header-img"&gt; &lt;nav id="nav-bar"&gt; &lt;ul&gt; &lt;li&gt;&lt;a class="nav-link" href="#Running"&gt;Push Farther. Run Wilder.&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a class="nav-link" href="#Hiking"&gt;Above. Beyond. And Back Again.&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a class="nav-link" href="#Diving"&gt;Groundbreaking, even in the sea.&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;img src="https://cdn.freebiesupply.com/logos/large/2x/apple1-logo-png-transparent.png"&gt;&lt;/img&gt; &lt;/nav&gt; &lt;/header&gt;</code></pre> </div> </div> </p> <p>These are the issues that happen:</p> <p>In this image I used height for the img, and a height occurs ON TOP of the navbar, plus the logo exits the navbar instead of being capped or something.</p> <p><a href="https://i.stack.imgur.com/l75D1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l75D1.png" alt="enter image description here" /></a></p> <p>With no size attribute, the logo becomes huge and all navbar related images disappear. <a href="https://i.stack.imgur.com/ZrPcn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZrPcn.png" alt="enter image description here" /></a></p> <p>And then without flexbox, getting the image to be in the navbar, properly sized, and aligned never happened.</p> <p>Just not sure how to fix this, what I'm misunderstanding of CSS.. I've spent so long on this thing.</p> <p>Thanks a lot for any help!</p> <p>Edit:</p> <p>For the fixes I've been shown, this error occurs: <a href="https://i.stack.imgur.com/3j2m4.png" rel="nofollow noreferrer">enter image description here</a></p> <p>As you can see, there is white space above the navbar. I gave the logo a red border so the whitespace is more visible and maybe it helps someone understand the problem.</p>
[ { "answer_id": 74253012, "author": "Varun Kaklia", "author_id": 18574568, "author_profile": "https://Stackoverflow.com/users/18574568", "pm_score": 0, "selected": false, "text": "const[data,setData] = useState()\nuseEffect(()=>{\n const apiData = axios.get(API_URL)\n .then(Resp...
2022/10/30
[ "https://Stackoverflow.com/questions/74252828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20371374/" ]
74,252,865
<p>EDIT: found the answer thanks to James Brown, there was a problem in the way I formatted the command:</p> <pre><code>awk -F&quot;,&quot; '{ if ($2*$3 &gt; 0.5) print }' </code></pre> <p>is working.</p> <p>I've got a file like this:</p> <pre><code>1000,0.5,1 2000,0.5,3 4000,1,3 5000,0.2,1 </code></pre> <p>I need to multiply $2 and $3 for each line and check if the result is superior to 0.5. I read that the -gt operator cannot handle floating-point numbers and that awk could do it.</p> <p>Here's the best I could come up with:</p> <pre><code>cat awk.txt | awk -F&quot;,&quot; '{ if (&quot;$2&quot;*&quot;$3&quot; &gt; &quot;0,5&quot;) print &quot;$line&quot;}' </code></pre> <p>Of course, it doesn't work, but it doesn't return any error...</p> <p>Expected result:</p> <pre><code>5000,0.2,1 </code></pre> <p>Can you point me in the right direction?</p> <p>Thank you very much</p>
[ { "answer_id": 74252916, "author": "James Brown", "author_id": 4162356, "author_profile": "https://Stackoverflow.com/users/4162356", "pm_score": 3, "selected": true, "text": "$ awk -F\",\" '{if($2*$3 > 0.5) print}' file\n" }, { "answer_id": 74253168, "author": "Daweo", "a...
2022/10/30
[ "https://Stackoverflow.com/questions/74252865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1444848/" ]
74,252,868
<p>Assume I have a function that is defined for two float values, and this function is rather complex that is not easy to be modified. Now I have two same 2D arrays, say $X_{n \times m}, Y_{n \times m}$, I need to carry out the function on each element on the 2D array $x_{ij}, y_{ij}$. How can I speed this work with respect to the two for loops?</p> <p>The following is the general code, in which the function has been simplified to be a summation:</p> <pre><code>def func(x, y): return x + y X = np.random.rand(100, 100) Y = np.random.rand(100, 100) Z = np.zeros((100, 100)) for i in range(100): for j in range(100): z = func(X[i, j], Y[i, j]) Z[i, j] = z </code></pre>
[ { "answer_id": 74252916, "author": "James Brown", "author_id": 4162356, "author_profile": "https://Stackoverflow.com/users/4162356", "pm_score": 3, "selected": true, "text": "$ awk -F\",\" '{if($2*$3 > 0.5) print}' file\n" }, { "answer_id": 74253168, "author": "Daweo", "a...
2022/10/30
[ "https://Stackoverflow.com/questions/74252868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8378256/" ]
74,252,978
<p>I have a BiqQuery table (Table A) that has around 1,000 records containing an ID and 15 datapoints that range between 0 - 100. Imagine its like a top-trumps card but with 15 attributes. Here's an example:</p> <pre><code>Record_ID = 0001 Size = 56 Height = 34 Width = 23 Weight = 78 Color = 42 Volume = 8 Density = 77 Smell = 23 Touch = 67 Hearing = 52 Power = 87 Sensitivity = 3 Strength = 78 Endurance = 45 Reliability = 87 </code></pre> <p>And I have a separate table (Table B) that has exactly the same schema with around 5,000 different records</p> <p>I need to take each Record_ID from Table A and then somehow rank the records in Table B that most closely match across all attributes. If I were just trying to rank records based on a single attribute such as Size then this would be really easy but I don't know where to start when I'm trying to find the closest matches and rankings across all attributes.</p> <p>Is there any kind of model or approach that might help me achieve this? I have been reading up on clustering and K-means nearest neighbor but these don't seem to help.</p>
[ { "answer_id": 74252916, "author": "James Brown", "author_id": 4162356, "author_profile": "https://Stackoverflow.com/users/4162356", "pm_score": 3, "selected": true, "text": "$ awk -F\",\" '{if($2*$3 > 0.5) print}' file\n" }, { "answer_id": 74253168, "author": "Daweo", "a...
2022/10/30
[ "https://Stackoverflow.com/questions/74252978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13547768/" ]
74,252,996
<p>I am struggling to find a solution to my problem. the error that appears is</p> <pre><code>The argument type 'String' can't be assigned to the parameter type 'Iterable&lt;Map&lt;dynamic, dynamic&gt;&gt;' </code></pre> <p>my code</p> <pre><code>loadPreviousEvents() async { var url = 'http://xxxxxxxxxx/getEvents.php'; var res = await http.get(Uri.parse(url)); var response = res.body; var newMap = groupBy(response, (Map oj) =&gt; oj['date']); } </code></pre>
[ { "answer_id": 74252916, "author": "James Brown", "author_id": 4162356, "author_profile": "https://Stackoverflow.com/users/4162356", "pm_score": 3, "selected": true, "text": "$ awk -F\",\" '{if($2*$3 > 0.5) print}' file\n" }, { "answer_id": 74253168, "author": "Daweo", "a...
2022/10/30
[ "https://Stackoverflow.com/questions/74252996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19674940/" ]
74,253,018
<h1>The problem</h1> <p>e.g.</p> <p>list1 = [&quot;a&quot;, &quot;c&quot;, &quot;b&quot;, &quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;a&quot;, &quot;c&quot;, &quot;b&quot;]</p> <p>list2 = [&quot;a&quot;, &quot;c&quot;, &quot;a&quot;, &quot;b&quot;]</p> <h2>Possibilities:</h2> <h3>1.</h3> <p>list1 = [<strong>&quot;a&quot;</strong>, <strong>&quot;c&quot;</strong>, &quot;b&quot;, <strong>&quot;a&quot;</strong>, <strong>&quot;b&quot;</strong>, &quot;c&quot;, &quot;a&quot;, &quot;c&quot;, &quot;b&quot;]</p> <p>list2 = [&quot;a&quot;, &quot;c&quot;, &quot;a&quot;, &quot;b&quot;]</p> <p>those are indexes: [1, 2, 4, 5</p> <h3>2.</h3> <p>list1 = [<strong>&quot;a&quot;</strong>, <strong>&quot;c&quot;</strong>, &quot;b&quot;, <strong>&quot;a&quot;</strong>, &quot;b&quot;, &quot;c&quot;, &quot;a&quot;, &quot;c&quot;, <strong>&quot;b&quot;</strong>]</p> <p>list2 = [&quot;a&quot;, &quot;c&quot;, &quot;a&quot;, &quot;b&quot;]</p> <p>those are indexes: [1, 2, 4, 9]</p> <h3>3.</h3> <p>list1 = [<strong>&quot;a&quot;</strong>, <strong>&quot;c&quot;</strong>, &quot;b&quot;, &quot;a&quot;, &quot;b&quot;, &quot;c&quot;, <strong>&quot;a&quot;</strong>, &quot;c&quot;, <strong>&quot;b&quot;</strong>]</p> <p>list2 = [&quot;a&quot;, &quot;c&quot;, &quot;a&quot;, &quot;b&quot;]</p> <p>those are indexes: [1, 2, 7, 9]</p> <h3>4.</h3> <p>list1 = [<strong>&quot;a&quot;</strong>, &quot;c&quot;, &quot;b&quot;, &quot;a&quot;, &quot;b&quot;, <strong>&quot;c&quot;</strong>, <strong>&quot;a&quot;</strong>, &quot;c&quot;, <strong>&quot;b&quot;</strong>]</p> <p>list2 = [&quot;a&quot;, &quot;c&quot;, &quot;a&quot;, &quot;b&quot;]</p> <p>those are indexes: [1, 6, 7, 9]</p> <h3>5.</h3> <p>list1 = [&quot;a&quot;, &quot;c&quot;, &quot;b&quot;, <strong>&quot;a&quot;</strong>, &quot;b&quot;, <strong>&quot;c&quot;</strong>, <strong>&quot;a&quot;</strong>, &quot;c&quot;, <strong>&quot;b&quot;</strong>]</p> <p>list2 = [&quot;a&quot;, &quot;c&quot;, &quot;a&quot;, &quot;b&quot;]</p> <p>those are indexes: [4, 6, 7, 9]</p> <h1>Output</h1> <p>The output should be an array of indexes never used</p> <p>for that above example it would be [2, 8] (because it never appears in the indexes)</p> <p>I tried a whole amount of solutions and all I could do is determine whether list2 is a subsequence of list1 or not</p>
[ { "answer_id": 74252916, "author": "James Brown", "author_id": 4162356, "author_profile": "https://Stackoverflow.com/users/4162356", "pm_score": 3, "selected": true, "text": "$ awk -F\",\" '{if($2*$3 > 0.5) print}' file\n" }, { "answer_id": 74253168, "author": "Daweo", "a...
2022/10/30
[ "https://Stackoverflow.com/questions/74253018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20371562/" ]
74,253,021
<p>I want to disbale button for specific work for next 24 hours when that user click that button. also i want user can't edit any thing after 24 hours <a href="https://i.stack.imgur.com/8q4oX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8q4oX.png" alt="enter image description here" /></a>24 hours.</p> <pre><code> &lt;?php $i = 0; ?&gt; @foreach ($works as $work) @php $start =Carbon\Carbon::parse($work-&gt;start_from)-&gt;format('d-m-Y h:i A'); $end =Carbon\Carbon::parse($work-&gt;end_to)-&gt;format('d-m-Y h:i A'); $t1 = strtotime($start); $t2 = strtotime($end); $total = gmdate('h:i',$t2 - $t1); $oneHourDiff = now()-&gt;addDays(-1); @endphp &lt;tr&gt; &lt;?php $i++; ?&gt; &lt;td&gt;{{ $i }}&lt;/td&gt; &lt;td&gt;{{$start}}&lt;/td&gt; &lt;td&gt;{{$end}}&lt;/td&gt; &lt;td&gt;{{$total}}&lt;/td&gt; &lt;td&gt;{{$work-&gt;project-&gt;Name}}&lt;/td&gt; &lt;td&gt;{{ $work-&gt;description }}&lt;/td&gt; @if(isset($work-&gt;user-&gt;name)) &lt;td&gt;{{$work-&gt;user-&gt;name}}&lt;/td&gt; @else &lt;td&gt;--&lt;/td&gt; @endif &lt;td&gt; @can('edit_work') &lt;button type=&quot;button&quot; class=&quot;btn btn-info btn-sm &quot; data-toggle=&quot;modal&quot; data-target=&quot;#edit{{ $work-&gt;id }}&quot; title=&quot;{{ trans('Works_trans.Edit') }}&quot;&gt;&lt;i class=&quot;fa fa-edit&quot;&gt;&lt;/i&gt; &lt;/button&gt; @endcan @can('delete_work') &lt;button type=&quot;button&quot; class=&quot;btn btn-danger btn-sm &quot; data-toggle=&quot;modal&quot; data-target=&quot;#delete{{ $work-&gt;id }}&quot; title=&quot;{{ trans('Works_trans.Delete') }}&quot;&gt;&lt;i class=&quot;fa fa-trash&quot;&gt;&lt;/i&gt;&lt;/button&gt; @endcan &lt;/td&gt; &lt;/tr&gt; @endforeach </code></pre> <p>I want to disbale button for specific work for next after 24 hour when that user click that button. also i want user can't edit any thing after 24 hour</p>
[ { "answer_id": 74252916, "author": "James Brown", "author_id": 4162356, "author_profile": "https://Stackoverflow.com/users/4162356", "pm_score": 3, "selected": true, "text": "$ awk -F\",\" '{if($2*$3 > 0.5) print}' file\n" }, { "answer_id": 74253168, "author": "Daweo", "a...
2022/10/30
[ "https://Stackoverflow.com/questions/74253021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11222598/" ]
74,253,046
<p>I have dataframe in following way:</p> <pre><code>vals = [[100,200], [100,200],[100,200]] df = pd.DataFrame({'y':vals}) df['x'] = [1,2,3] df </code></pre> <p>how can I append y values to the lists in x column, so my final values are in the following shape?</p> <p><a href="https://i.stack.imgur.com/NNuWA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NNuWA.png" alt="enter image description here" /></a></p> <p>thanks</p>
[ { "answer_id": 74252916, "author": "James Brown", "author_id": 4162356, "author_profile": "https://Stackoverflow.com/users/4162356", "pm_score": 3, "selected": true, "text": "$ awk -F\",\" '{if($2*$3 > 0.5) print}' file\n" }, { "answer_id": 74253168, "author": "Daweo", "a...
2022/10/30
[ "https://Stackoverflow.com/questions/74253046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15943988/" ]
74,253,059
<p>so I am trying to find the number of samples that are labelled with the phrase 'PaperB' in a very larger data frame in R, I have used the following:</p> <p><code>df[grep(&quot;PaperB&quot;, names(df))]</code></p> <p>but this has given me all the columns labelled with Tissue B and their values, rather than the total amount of PaperB samples, how could i change this to just get the total amount?</p> <p>thanks for any help</p>
[ { "answer_id": 74252916, "author": "James Brown", "author_id": 4162356, "author_profile": "https://Stackoverflow.com/users/4162356", "pm_score": 3, "selected": true, "text": "$ awk -F\",\" '{if($2*$3 > 0.5) print}' file\n" }, { "answer_id": 74253168, "author": "Daweo", "a...
2022/10/30
[ "https://Stackoverflow.com/questions/74253059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20285663/" ]
74,253,077
<p>I'm writing a program which will create 4 lists with words in them. A user is prompted to answer how many words they'd like to print from list A, how many from list B, how many from list C, D etc. and the program randomly chooses those words and prints them out.</p> <p>I've got the shell out ready, the lists are made up, and the user input prompts are done, I can't figure out how to connect these two together. I can print out random values from a list using random.choice() but the amount that I specify. Not the number of words the user specifies.</p> <p>The code is something like this:</p> <pre><code>def lists(): animal = [&quot;cat&quot;, &quot;dog&quot;, &quot;horse&quot;, &quot;cow&quot;, &quot;rabbit&quot;] furnishings = [&quot;couch&quot;, &quot;table&quot;, &quot;chair&quot;, &quot;lamp&quot;, &quot;bed&quot;] vehicle = [&quot;mazda&quot;, &quot;toyota&quot;, &quot;ford&quot;, &quot;cadillac&quot;, &quot;honda&quot;] shade = [&quot;red&quot;, &quot;blue&quot;, &quot;black&quot;, &quot;green&quot;, &quot;purple&quot;] def inputFunction(): animals = input(&quot;how many animals would you like to print? &quot;) furniture = input(&quot;how many furniture pieces would you like to print? &quot;) cars = input(&quot;how many cars would like to use? &quot;) colors = input(&quot;how many colors? &quot;) def main(): </code></pre> <p>***please note this is not the entire code but an oversimplified version of it to illustrate what I mean ***</p> <p>The output I want is something along the lines of:</p> <p>how many animals would you like to print? 2 how many furniture pieces would you like to print? 3 how many cars would like to use? 1 how many colors? 5</p> <p>cat horse table lamp bed toyota red blue black green purple.</p>
[ { "answer_id": 74253344, "author": "Francisco Orbe", "author_id": 9575385, "author_profile": "https://Stackoverflow.com/users/9575385", "pm_score": 0, "selected": false, "text": "hmf=[] #this is the list that in each spaces the number of selection random words\n\nfor j in (0,4):\n x=int...
2022/10/30
[ "https://Stackoverflow.com/questions/74253077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20371612/" ]
74,253,083
<p>Following the first answer to <a href="https://stackoverflow.com/questions/25153153/initializing-array-of-variable-size-inside-a-class">this question</a>, I ran into an issue with overriding variables. This is the code I wrote to find the root of the problem:</p> <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt; using namespace std; class foo { private: int *bar; int l; public: foo(int bar); ~foo(); void print_bar() { cout &lt;&lt; &quot;bar = {&quot;; for (int i = 0; i &lt; l; i++) {cout &lt;&lt; + bar[i] &lt;&lt; &quot;, &quot;;} cout &lt;&lt; &quot;}&quot; &lt;&lt; endl; } }; foo::foo(int l) { this-&gt;l = l; cout &lt;&lt; &quot;Creating with length &quot; &lt;&lt; l &lt;&lt; endl; bar = new int[l]; cout &lt;&lt; &quot;{&quot;; for (int i = 0; i &lt; l; i++) {cout &lt;&lt; + bar[i] &lt;&lt; &quot;, &quot;;} cout &lt;&lt; &quot;}&quot; &lt;&lt; endl; for(size_t i = 0; i &lt; l; ++i) {bar[i] = 0;} cout &lt;&lt; &quot;Created with bar = {&quot;; for (int i = 0; i &lt; l; i++) {cout &lt;&lt; + bar[i] &lt;&lt; &quot;, &quot;;} cout &lt;&lt; &quot;}&quot; &lt;&lt; endl; } foo::~foo() { cout &lt;&lt; &quot;Deleted with bar = {&quot;; for (int i = 0; i &lt; l; i++) {cout &lt;&lt; + bar[i] &lt;&lt; &quot;, &quot;;} cout &lt;&lt; &quot;}&quot; &lt;&lt; endl; delete[] bar; } int main() { foo a = foo(1); a = foo(2); a.print_bar(); return 0; } </code></pre> <p>This outputs:</p> <pre><code>Creating with length 1 {0, } Created with bar = {0, } Creating with length 2 {0, 0, } Created with bar = {0, 0, } Deleted with bar = {0, 0, } bar = {1431655787, 5, } Deleted with bar = {1431655787, 5, } </code></pre> <p>Instead of what I expected:</p> <pre><code>Creating with length 1 {0, } Created with bar = {0, } Creating with length 2 {0, 0, } Created with bar = {0, 0, } Deleted with bar = {0, } bar = {0, 0, } Deleted with bar = {0, 0, } </code></pre> <p>How can I avoid this, or is there a better way to have a class with a variable length array as a parameter?</p> <p><em>(Please keep in mind when answering that I'm very new to c++.)</em></p>
[ { "answer_id": 74253260, "author": "Lance", "author_id": 10199326, "author_profile": "https://Stackoverflow.com/users/10199326", "pm_score": 1, "selected": false, "text": "a=foo(2)" }, { "answer_id": 74253335, "author": "vitrack", "author_id": 9780724, "author_profile...
2022/10/30
[ "https://Stackoverflow.com/questions/74253083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9780724/" ]
74,253,115
<p>In <em>Algorithms</em> by Bob Sedgewick (<a href="https://www.coursera.org/learn/algorithms-part1/lecture/ZjoSM/heapsort" rel="nofollow noreferrer">https://www.coursera.org/learn/algorithms-part1/lecture/ZjoSM/heapsort</a>) he constructs a heap using bottom up method, starting at index N/2. Why there? What is the meaning of this index for the heap sorted array?</p>
[ { "answer_id": 74282420, "author": "Pentragon", "author_id": 19010882, "author_profile": "https://Stackoverflow.com/users/19010882", "pm_score": 0, "selected": false, "text": "0" } ]
2022/10/30
[ "https://Stackoverflow.com/questions/74253115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11958281/" ]
74,253,160
<p>I have a type that looks like this:</p> <pre class="lang-js prettyprint-override"><code>type Config = { endpoints: [ {name: &quot;abc&quot;, created: false}, {name: &quot;xyz&quot;, created: true}, ] } </code></pre> <p>I have a function that transforms this type into the following:</p> <pre class="lang-js prettyprint-override"><code>type Instance = { abc: {name: &quot;abc&quot;, created: false}, xyz: {name: &quot;xyz&quot;, created: false}, } </code></pre> <p>I wrote the following transformation type</p> <pre class="lang-js prettyprint-override"><code>type IntersectOf&lt;U extends any&gt; = (U extends unknown ? (k: U) =&gt; void : never) extends ((k: infer I) =&gt; void) ? I : never; type Transform&lt;T extends Config, K extends (keyof T)[] = (keyof T)[]&gt; = IntersectOf&lt;{ [key in keyof K]: K[key] extends keyof T['endpoints'] // here it says &quot;name&quot; can't be used as index of `T[&quot;endpoints&quot;][K[key]]` ? Record&lt;T['endpoints'][K[key]]['name'], T['endpoints'][K[key]]&gt; : never; }[number]&gt;; type Instance = Transform&lt;Config&gt;; </code></pre> <p>I also tried adding a number type guard, and the error goes away but <code>Instance</code> becomes <code>unknown</code>. Here is the <code>Transform</code> type with number typeguard:</p> <pre class="lang-js prettyprint-override"><code>type Trasnform&lt;T extends Config, K extends (keyof T)[] = (keyof T)[]&gt; = IntersectOf&lt;{ [key in keyof K]: K[key] extends keyof T['endpoints'] ? K[key] extends number ? Record&lt;T['endpoints'][K[key]]['name'], T['endpoints'][K[key]]&gt; : never : never; }[number]&gt;; </code></pre>
[ { "answer_id": 74253712, "author": "tokland", "author_id": 188031, "author_profile": "https://Stackoverflow.com/users/188031", "pm_score": 1, "selected": false, "text": "export type IndicesOf<T> = Exclude<keyof T, keyof any[]>;\n\ntype Instance = { \n [Idx in IndicesOf<Config[\"endpoint...
2022/10/30
[ "https://Stackoverflow.com/questions/74253160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6016274/" ]
74,253,197
<p>I'm new to python and web scraping. I have trouble printing the &quot;advice to management&quot; part in the review from Glassdoor. Everything else is printing expect for &quot;advice to management&quot;.</p> <p>If you check below in the review we have 'advice to management' but in the output it's not getting scrapped with the rest of the datapoints.</p> <p>Can anyone help me please?!! This is so important to me. It's the data I'm going to be using for my thesis.</p> <p>I have tried this code:</p> <pre><code> import requests from bs4 import BeautifulSoup import pandas as pd def extract(pg): headers = {'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.80 Safari/537.36'} url = f'https://www.glassdoor.com/Reviews/Google-Engineering-Reviews-EI_IE9079.0,6_DEPT1007_IP{pg}.htm?sort.sortType=RD&amp;sort.ascending=false&amp;filter.iso3Language=eng' r = requests.get(url, headers) soup = BeautifulSoup(r.content, 'html.parser')# this a soup function that retuen the whole html return soup def transform(soup): #to get reviews divs = soup.find_all('div', class_='gdReview') for item in divs: try: Title = item.find('h2', class_= 'mb-xxsm mt-0 css-93svrw el6ke055').text except: Title = None try: Rating = item.find('span', class_= 'ratingNumber mr-xsm').text.replace('&lt;span class=&quot;ratingNumber mr-xsm&quot;&gt;', '').strip() except: Rating = None try: Employee_Situation= item.find('span', class_= 'pt-xsm pt-md-0 css-1qxtz39 eg4psks0').text.replace('&lt;span class=&quot;pt-xsm pt-md-0 css-1qxtz39 eg4psks0&quot;&gt;', '').strip() except: Employee_Situation = None try: Pros = item.find('span', {'data-test':'pros'}).text.replace('&lt;span data-test=&quot;pros&quot;&gt;', '').strip() except: Pros = None try: Cons = item.find('span', {'data-test':'cons'}).text.replace('&lt;span data-test=&quot;cons&quot;&gt;', '') except: Cons: None try: Advice_To_Management = item.find('span', {'data-test':'advice-management'}).text except: Advice_To_Management = None try: Auhtor_Info = item.find('span', class_= 'common__EiReviewDetailsStyle__newUiJobLine').text.replace('&lt;span class=&quot;common__EiReviewDetailsStyle__newUiJobLine&quot;&gt;&lt;span&gt;&lt;span class=&quot;middle common__EiReviewDetailsStyle__newGrey&quot;&gt;', '').strip() except: Auhtor_Info = None Reviews = { 'Title' : Title, 'Rating': Rating, 'Employee_Situation' : Employee_Situation, 'Pros' : Pros, 'Cons' : Cons, 'Advice_To_Management' : Advice_To_Management, 'Auhtor_Info' : Auhtor_Info, } ReviewsList.append(Reviews) # to add reviews elements to our list 'ReviewList' return ReviewsList = [] #loop into pages for i in range(1,3,1): soup = extract( f'https://www.glassdoor.com/Reviews/Google-Engineering-Reviews-EI_IE9079.0,6_DEPT1007_IP{i}.htm?sort.sortType=RD&amp;sort.ascending=false&amp;filter.iso3Language=eng') print(f' page {i}') transform(soup) print(len(ReviewsList)) if not soup.find(&quot;data-test&quot;, class_ = &quot;nextButton css-1hq9k8 e13qs2071&quot;): pass else: break df = pd.DataFrame(ReviewsList) df2 = df.drop_duplicates(subset=[&quot;Title&quot;, &quot;Rating&quot;, &quot;Employee_Situation&quot;, &quot;Pros&quot;, &quot;Cons&quot;, &quot;Auhtor_Info&quot;], keep='first') df2.to_csv('Google Reviews.csv') print(len(df2)) </code></pre>
[ { "answer_id": 74253712, "author": "tokland", "author_id": 188031, "author_profile": "https://Stackoverflow.com/users/188031", "pm_score": 1, "selected": false, "text": "export type IndicesOf<T> = Exclude<keyof T, keyof any[]>;\n\ntype Instance = { \n [Idx in IndicesOf<Config[\"endpoint...
2022/10/30
[ "https://Stackoverflow.com/questions/74253197", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19810494/" ]
74,253,200
<p>I have a class</p> <pre class="lang-dart prettyprint-override"><code>class Foo { final List&lt;int&gt; a; final List&lt;int&gt; b; Foo(this.a, this.b); @override bool operator ==(Object other) =&gt; identical(this, other) || other is Foo &amp;&amp; listEquals(a, other.a) &amp;&amp; listEquals(b, other.b); @override int get hashCode =&gt; Object.hash(a, b); } </code></pre> <p>I want to check if two instances of <code>Foo</code> are equal with hashCodes.</p> <pre class="lang-dart prettyprint-override"><code>final list1 = Foo([0], [0]); final list2 = Foo([0], [0]); print(list1 == list2); // Prints true, all good print(list1.hashCode == list2.hashCode); // Prints false. </code></pre> <p>How to properly override hashCode so that the above print statement also prints <code>true</code> without using a third party package?</p>
[ { "answer_id": 74253712, "author": "tokland", "author_id": 188031, "author_profile": "https://Stackoverflow.com/users/188031", "pm_score": 1, "selected": false, "text": "export type IndicesOf<T> = Exclude<keyof T, keyof any[]>;\n\ntype Instance = { \n [Idx in IndicesOf<Config[\"endpoint...
2022/10/30
[ "https://Stackoverflow.com/questions/74253200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12483095/" ]
74,253,213
<p>I'm just learning and don't know much yet. I wrote incorrect code</p> <pre><code>Sub sierotkiTXT_select() Do Selection.EndKey Unit:=wdLine Selection.MoveLeft Unit:=wdCharacter, Count:=3, Extend:=wdExtend If Selection.Text Like &quot;* [aAwWzZiIoOuUVQ] *&quot; Or Selection.Text Like &quot;*[A-Z]. *&quot; Or Selection.Text Like &quot;* [a-z]. *&quot; Or Selection.Text Like &quot;*z. *&quot; Or Selection.Text Like &quot;*:] *&quot; Then Result = MsgBox(&quot;OK?&quot;, vbYesNoCancel + vbQuestion) If Result = vbYes Then Selection.MoveRight Unit:=wdCharacter, Count:=1 Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.Delete Selection.InsertAfter Text:=ChrW(160) End If If Result = vbCancel Then Exit Sub End If End If Selection.MoveRight Unit:=wdCharacter, Count:=3 Loop Until Selection.Text = ActiveDocument.Range.Characters.Last End Sub </code></pre> <p>and don't know how to stop such a macro at the end of the document (break the loop) without using a</p> <pre><code>Loop Until Selection.Text = ActiveDocument.Range.Characters.Last </code></pre> <p>It wouldn't be a problem, but the macro sometimes stops at the end-of-paragraph characters, interpreting them as the end of the document. [EDIT] Ok-ActiveDocument.Range.Characters.Last Still returns empty - that's why it stops. I should not use this.</p> <p>Examples (main text): <a href="https://i.stack.imgur.com/7i1Dy.jpg" rel="nofollow noreferrer">before</a></p> <p>After run macro: <a href="https://i.stack.imgur.com/7C4Bw.jpg" rel="nofollow noreferrer">after</a></p> <p>Examples (Endnotes): <a href="https://i.stack.imgur.com/p4fEU.jpg" rel="nofollow noreferrer">before</a> <a href="https://i.stack.imgur.com/rwdXs.jpg" rel="nofollow noreferrer">after</a></p>
[ { "answer_id": 74253712, "author": "tokland", "author_id": 188031, "author_profile": "https://Stackoverflow.com/users/188031", "pm_score": 1, "selected": false, "text": "export type IndicesOf<T> = Exclude<keyof T, keyof any[]>;\n\ntype Instance = { \n [Idx in IndicesOf<Config[\"endpoint...
2022/10/30
[ "https://Stackoverflow.com/questions/74253213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20342355/" ]
74,253,268
<p>Current it works, but not as expected</p> <pre class="lang-js prettyprint-override"><code>import {Routes, Route, Navigate} from 'react-router-dom'; import appInfo from './app-info'; import routes from './app-routes'; import {SideNavOuterToolbar as SideNavBarLayout} from './layouts'; import {Footer} from './components'; export default function Content() { return ( &lt;SideNavBarLayout title={appInfo.title}&gt; &lt;Routes&gt; {routes.map(({path, element}) =&gt; ( &lt;Route key={path} path={path} element={element} /&gt; ))} &lt;Route path='*' element={&lt;Navigate to='/login'/&gt;} /&gt; &lt;/Routes&gt; &lt;Footer&gt; © Bản quyền: FAMABOOK® 2018 - {new Date().getFullYear()} . {/*&lt;br /&gt;*/} {/*All trademarks or registered trademarks are property of their*/} {/*respective owners.*/} &lt;/Footer&gt; &lt;/SideNavBarLayout&gt; ); } </code></pre> <p>it always show features inside even when not log in</p> <p><a href="https://i.stack.imgur.com/A9H07.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/A9H07.png" alt="enter image description here" /></a></p> <p>I want hide menu if token in local storage did not exist, something like this</p> <pre class="lang-js prettyprint-override"><code>import {Routes, Route, Navigate} from 'react-router-dom'; import appInfo from './app-info'; import routes from './app-routes'; import {SideNavOuterToolbar as SideNavBarLayout} from './layouts'; import {Footer} from './components'; export default function Content() { return ( &lt;SideNavBarLayout title={appInfo.title}&gt; &lt;Routes&gt; if (localStorage.getItem('token')) { &lt;&gt; {routes.map(({path, element}) =&gt; ( &lt;Route key={path} path={path} element={element} /&gt; ))}&lt;/&gt; }else{ } &lt;Route path='*' element={&lt;Navigate to='/login'/&gt;} /&gt; &lt;/Routes&gt; &lt;Footer&gt; 2018 - {new Date().getFullYear()} . {/*&lt;br /&gt;*/} {/*All trademarks or registered trademarks are property of their*/} {/*respective owners.*/} &lt;/Footer&gt; &lt;/SideNavBarLayout&gt; ); } </code></pre> <p>How to archive that?</p>
[ { "answer_id": 74253291, "author": "DecPK", "author_id": 9153448, "author_profile": "https://Stackoverflow.com/users/9153448", "pm_score": 1, "selected": false, "text": "&&" }, { "answer_id": 74253311, "author": "Varun Kaklia", "author_id": 18574568, "author_profile":...
2022/10/30
[ "https://Stackoverflow.com/questions/74253268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3728901/" ]
74,253,307
<p>I was restricted to using only one way of inserting a new node after a given node and implementing the linked list. I was getting a garbage value in my output. I'm not clear on how I can resolve this issue. Any help is appreciated thanks in advance.</p> <blockquote> </blockquote> <pre><code> #include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; struct Node{ int data; struct Node *next; }; void insertAfter(struct Node *prevNode,int newData){ if(prevNode == NULL){ printf(&quot;the given previous node cannot be NULL&quot;); return; } struct Node* newNode = (struct Node*)malloc(sizeof(struct Node)); newNode-&gt;data = newData; newNode-&gt;next = prevNode-&gt;next; prevNode-&gt;next = newNode; } void printList(struct Node *head){ while(head!=NULL){ printf(&quot; %d &quot;, head-&gt;data); head = head-&gt;next; } } int main() { struct Node* head = NULL; struct Node* second = NULL; struct Node* third = NULL; head = (struct Node*)malloc(sizeof(struct Node)); second = (struct Node*)malloc(sizeof(struct Node)); third = (struct Node*)malloc(sizeof(struct Node)); head-&gt;data = 9; head-&gt;next = second; insertAfter(head-&gt;next, 8); third-&gt;data = 10; third-&gt;next = NULL; printf(&quot;\n Created Linked list is: &quot;); printList(head); return 0; } </code></pre> <p>Generated output:: 9 0 8 Expected output: 9 8 10</p>
[ { "answer_id": 74253351, "author": "hyde", "author_id": 1717300, "author_profile": "https://Stackoverflow.com/users/1717300", "pm_score": 0, "selected": false, "text": "head->next = second;\n" }, { "answer_id": 74253357, "author": "Vlad from Moscow", "author_id": 2877241,...
2022/10/30
[ "https://Stackoverflow.com/questions/74253307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16918445/" ]
74,253,352
<p>I am making a site and this is some part of them. let's say I am in &quot;home&quot; page. and I will go to &quot;service&quot; page.</p> <p>I want to get path of &quot;service&quot; page. (I want to get like &quot;/service&quot;, after &quot;router push&quot;.</p> <p>but my code show &quot;/&quot; (before &quot;router push&quot;'s path)</p> <p>How to get present path after &quot;router push&quot;, not previous path?</p> <p>thanks.</p> <code> <pre><code>import Link from 'next/link' import { useRouter } from &quot;next/router&quot; const SideBar = (props) =&gt; { const router = useRouter() const handleClick = (e, path) =&gt; { e.preventDefault() props.toggleMenu() router.push(path) console.log( router.pathname ) // this shows path &quot;before router push&quot; } return ( &lt;div className=&quot;sidebar&quot;&gt; &lt;Link href=&quot;/&quot;&gt; &lt;a onClick={(e)=&gt; handleClick(e, &quot;/&quot;)} &gt;HOME&lt;/a&gt; &lt;/Link&gt; &lt;Link href=&quot;/service&quot;&gt; &lt;a onClick={(e)=&gt; handleClick(e, &quot;/service&quot;)} &gt;SERVICE&lt;/a&gt; &lt;/Link&gt; &lt;/div&gt; ) } export default SideBar </code></pre> </code>
[ { "answer_id": 74253786, "author": "Jorn Blaedel Garbosa", "author_id": 5955450, "author_profile": "https://Stackoverflow.com/users/5955450", "pm_score": 1, "selected": false, "text": "const router = useRouter();\n\nconsole.log(router.pathname); // returns /service\nconsole.log(router.as...
2022/10/30
[ "https://Stackoverflow.com/questions/74253352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9557575/" ]
74,253,373
<pre class="lang-rust prettyprint-override"><code>fn main() { let c: i32 = 5; let rrc = &amp;&amp;c; println!(&quot;{}&quot;, rrc); // 5 println!(&quot;{}&quot;, *rrc); // 5 println!(&quot;{}&quot;, **rrc); // 5 } </code></pre> <p>In C/C++ language, rrc likes a two level pointer. In this example, rrc doesn't mean this in rust. What do <code>&amp;</code> and <code>*</code> mean in Rust?</p>
[ { "answer_id": 74253451, "author": "LeoDog896", "author_id": 7589775, "author_profile": "https://Stackoverflow.com/users/7589775", "pm_score": 2, "selected": false, "text": "fn main() {\n let c: i32 = 5;\n let rrc = &c;\n let rrc = &rrc; // this is &&c\n}\n" }, { "answer_id": ...
2022/10/30
[ "https://Stackoverflow.com/questions/74253373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7650970/" ]
74,253,390
<p>I am trying to create a new column which is formed by taking the value from column A as the upper bound of the sample which I would like to take. I tried the following but no avail. Any suggestions? Suppose the value A is 15.25, then I would like to generate a value which is between 1 and 15.25 which are spaced by 1/4.</p> <pre class="lang-r prettyprint-override"><code>my_data = data.frame(A = sample(seq(1, 20, 1/4), 10)) my_data %&gt;% mutate(B = sample(seq(1, A, 1/4), 1)) </code></pre>
[ { "answer_id": 74253455, "author": "Anoushiravan R", "author_id": 14314520, "author_profile": "https://Stackoverflow.com/users/14314520", "pm_score": 3, "selected": true, "text": "rowwise" }, { "answer_id": 74254607, "author": "Jaap", "author_id": 2204410, "author_pro...
2022/10/30
[ "https://Stackoverflow.com/questions/74253390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2890129/" ]
74,253,400
<p>I am trying to use binding class to inject dependecies into my flutters application but for some reason its not working as i expected</p> <p>binding class</p> <pre><code>class LibraryHomeBinding extends Bindings { @override void dependencies() { Get.put(LibraryHomeController(), tag: 'home'); } } </code></pre> <p>controller class</p> <pre><code>class LibraryHomeController extends GetxController { @override void onInit() { print('initilizing'); super.onInit(); } @override void onReady() { print('Controller ready'); super.onReady(); } @override void onClose() { print('Controller closing'); super.onClose(); } } </code></pre> <p>home</p> <pre><code>class LibraryHome extends StatelessWidget { LibraryHome({super.key, required this.title}); final String title; final libraryHomeBinding = Get.find(tag: 'home'); ... } </code></pre> <p>main</p> <pre><code> void main() { WidgetsFlutterBinding.ensureInitialized(); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return GetMaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter Demo', theme: lightTheme, getPages: [ GetPage( name: '/home', page: () =&gt; LibraryHome(title: 'Library'), binding: LibraryHomeBinding(), ) ], initialRoute: '/home', ); } } </code></pre> <p>i am getting this error</p> <p>&quot;&quot;dynamic&quot; not found. You need to call &quot;Get.put(dynamic())&quot; or &quot;Get.lazyPut(()=&gt;dynamic())&quot;&quot;</p>
[ { "answer_id": 74253459, "author": "Gwhyyy", "author_id": 18670641, "author_profile": "https://Stackoverflow.com/users/18670641", "pm_score": 0, "selected": false, "text": "Get.find()" }, { "answer_id": 74253479, "author": "Arbiter Chil", "author_id": 10782024, "autho...
2022/10/30
[ "https://Stackoverflow.com/questions/74253400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19264520/" ]
74,253,411
<p>I have a data frame with 70k rows and two columns. Col1 contains bill of materials name and customer, Col2 contains a part number (which is a part of the BOM).</p> <pre><code> Col1 Col2 0 TUR, Cust1 1001 1 GAR, Cust2 1001 2 FOR, Cust3 1001 3 ERB, Cust1 1002 4 PNR, Cust1 1002 5 DUL, Cust2 1003 6 COC, Cust3 1003 7 ETM, Cust1 1004 8 ROW, Cust3 1005 9 HON, Cust3 1005 </code></pre> <p>When searching for Cust1, I want to see in column3 if the part number is purchased exclusively for that customer. Something like this:</p> <pre><code> Col1 Col2 Col3 0 TUR, Cust1 1001 false 1 GAR, Cust2 1001 false 2 FOR, Cust3 1001 false 3 ERB, Cust1 1002 true 4 PNR, Cust1 1002 true 5 DUL, Cust2 1003 false 6 COC, Cust3 1003 false 7 ETM, Cust1 1004 true 8 ROW, Cust3 1005 false 9 HON, Cust3 1005 false </code></pre> <p>I already tried to extract duplicates with df.duplicated and to evaluate the customer name with str.contains, but without satisfying result. Is there a smart solution that I don't know? I am new to python and getting nowhere with this problem.</p>
[ { "answer_id": 74253459, "author": "Gwhyyy", "author_id": 18670641, "author_profile": "https://Stackoverflow.com/users/18670641", "pm_score": 0, "selected": false, "text": "Get.find()" }, { "answer_id": 74253479, "author": "Arbiter Chil", "author_id": 10782024, "autho...
2022/10/30
[ "https://Stackoverflow.com/questions/74253411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20371428/" ]
74,253,418
<p>I want to create new columns in df1 based on two columns in df2. df1 has multiple columns (&quot;x&quot;, &quot;y&quot; , &quot;z&quot;), with possible values 0,1, or NA. df2 has two columns: &quot;a&quot; and &quot;b&quot;. The values of column &quot;b&quot; include the column names of df1 (although some values in df2$a may be present as columns in df1).</p> <pre><code>x &lt;- c(1, 1, NA, NA, 0) y &lt;- c(0, 1, 1, NA, NA) z &lt;- c(1, 1, 0, 1, 1) df1 &lt;- data.frame(x, y, z) a &lt;- c( &quot;Green&quot;, &quot;Green&quot;, &quot;Green&quot;, &quot;Red&quot;, &quot;Red&quot;, &quot;Blue&quot;, &quot;Blue&quot;, &quot;Yellow&quot;) b &lt;- c( &quot;w&quot;, &quot;x&quot;, &quot;y&quot;, &quot;x&quot;, &quot;z&quot;, &quot;w&quot; , &quot;y&quot;, &quot;z&quot; ) df2 &lt;- data.frame(a, b) </code></pre> <p>The new columns to be created in df1 should be named as the values of column df2$a. The value of each new column (i.e df1$Green) should be &quot;1&quot; when</p> <ul> <li>the values of df2$a and df2$b are matched (example: df2$a = &quot;Green&quot; matches df2$b = &quot;w&quot;, &quot;x&quot; and &quot;y&quot;), and</li> <li>the corresponding column in df1 (df1$x and df$y) equals &quot;1&quot;.</li> </ul> <p>The new_df1 should be:</p> <pre><code>new_df1 x y z Green Red Blue Yellow 1 1 0 1 1 1 0 1 2 1 1 1 1 1 1 1 3 NA 1 0 1 0 1 0 4 NA NA 1 0 1 0 1 5 0 NA 1 0 1 0 1 </code></pre>
[ { "answer_id": 74253746, "author": "Ric Villalba", "author_id": 6912817, "author_profile": "https://Stackoverflow.com/users/6912817", "pm_score": 2, "selected": false, "text": "\nx <- c(1, 1, NA, NA, 0)\ny <- c(0, 1, 1, NA, NA)\nz <- c(1, 1, 0, 1, 1)\n\ndf1 <- data.frame(x, y, z)\n\na <-...
2022/10/30
[ "https://Stackoverflow.com/questions/74253418", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7436552/" ]
74,253,452
<p>Here my code to create trigger</p> <pre><code>CREATE TRIGGER TRIGGERNAME ON [TABLENAME] AFTER INSERT, UPDATE, DELETE AS BEGIN --[SQL STATEMENTS] END </code></pre> <p>In the SQL statement, how can I check things like:</p> <pre><code>if (a row is updated) { -- do something } else if (a row is deleted) { -- do something else } </code></pre>
[ { "answer_id": 74253715, "author": "Ana", "author_id": 11323179, "author_profile": "https://Stackoverflow.com/users/11323179", "pm_score": 0, "selected": false, "text": "CREATE TRIGGER [TRIGGERNAME] ON [TABLENAME]\nAFTER INSERT, UPDATE, DELETE\nAS\nBEGIN\n DECLARE @DELETED INT, @UPDAT...
2022/10/30
[ "https://Stackoverflow.com/questions/74253452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11323179/" ]
74,253,468
<p>Mapstruct always generate mappers that use a default empty constructor and setters to construct an object.</p> <p>I need mapstruct to construct objects using parameterized constructor instead.</p> <p>I have this mapper configured using maptruct:</p> <pre><code>@Mapper(componentModel = &quot;spring&quot;) public interface FlightMapper { FlightBooking flightBookingPostRequestDtoToFlightBooking(FlightBookingPostRequestDto flightBookingDto); } </code></pre> <p>The implementation that mapstruct generates uses the default constructor without parameters:</p> <pre><code>public FlightBooking flightBookingPostRequestDtoToFlightBooking(FlightBookingPostRequestDto flightBookingDto) { if ( flightBookingDto == null ) { return null; } FlightBooking flightBooking = new FlightBooking(); flightBooking.setFlight_booking_id( flightBookingDto.getBooking_id() ); return flightBooking; } </code></pre> <p>But I need this implementation with a parameterized constructor instead:</p> <pre><code>public FlightBooking flightBookingPostRequestDtoToFlightBooking(FlightBookingPostRequestDto flightBookingDto) { if ( flightBookingDto == null ) { return null; } FlightBooking flightBooking = new FlightBooking(flightBookingDto.getBooking_id()); return flightBooking; } </code></pre> <p>How can I configure mapstruct to achieve this? I haven't found any responses in the official documentation. Thanks in advance</p>
[ { "answer_id": 74253891, "author": "birca123", "author_id": 10231374, "author_profile": "https://Stackoverflow.com/users/10231374", "pm_score": 1, "selected": false, "text": "@Default" } ]
2022/10/30
[ "https://Stackoverflow.com/questions/74253468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20371858/" ]
74,253,536
<p>Given the list of integers stored in the variable numbers, declare the variable result1 and initialize the values ​​of the initial list containing only the even positive numbers, respecting the initial order.</p> <pre><code>numbers = [-85,34,-7,-6,57,-6,-65,-49,-51,79,90,-75,33,36,9,30,-61,-66,95 .15,-56.45,-21,-81,-83,-31.82,-92,21.95,-70.88,-25,100,-17,-52,-74,-24.85 ,-40,-35,82,-74,-89,73,-44,53,88,35,-77,-90, 54,-41,-23,58,-95,47,-65, -92,91,64,-69,-21,-58, -63,-51,95,45,95,50,4,-15,-98,27,-84,32,57,-50, -54,-14,-46,98,76,0,-85,-1,15,67,-5,92,-39,-68, -73,-85,0,-39,-72, -9,52,27,52,-41,69,52,-42, -78,-37.59,-77,-30,77,56,-13,-80,-14,-30.94 ,34, 81,-46,-77,50,-23,-20,-59,-4,59,94,34,50,46,87, -78,88,-47,66,92,- 42,0,-28,-31,-18,-32,34,66,-12, 81,17,-11,37,20,-82,9,41,28,-81,26,47, 70.98, -82,-15.46,-13.89,-33,19,94,-88,52,14,27,-4, 6,-60.44,-98.83,-13 ,-80,-58,-10,-33,-70.87, -50.51,-3,-36,-60.61,-40,41.91,-25.38,-60.67 ,-85.36,-83.43] </code></pre> <p>What I tried to do:</p> <pre><code>def filterList(p, xs): return [x for x in xs if p(x)] def ePar(numbers): return numbers%2==0 def ePositive(numbers): return numbers&gt;0 def result1(): return filterList(eEven, ePositive) print (result1[:7]) ## because i want the last seven even positive integers </code></pre> <p>I expected that with my function result1, it would filter just the even and positive integers, but instead, the error was the following:</p> <pre><code>***Run error*** Traceback (most recent call last): File &quot;__tester__.python3&quot;, line 35, in &lt;module&gt; print(resultado1[:7]) TypeError: 'function' object is not subscriptable </code></pre>
[ { "answer_id": 74253606, "author": "The Myth", "author_id": 15042008, "author_profile": "https://Stackoverflow.com/users/15042008", "pm_score": -1, "selected": true, "text": "resultado1" }, { "answer_id": 74253762, "author": "Samwise", "author_id": 3799759, "author_pr...
2022/10/30
[ "https://Stackoverflow.com/questions/74253536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20371954/" ]
74,253,541
<pre class="lang-js prettyprint-override"><code>const data = new SlashCommandBuilder() // &lt;/&gt; command .setName('info') .setDescription('информация об админе') .addStringOption(option =&gt; option.setName('steam64') .setDescription('numbers') .setRequired(true)); //code client.on('interactionCreate', async interaction =&gt; { if (interaction.commandName === 'убитьбота') { interaction.reply(&quot;Успешно!&quot;); client.destroy(); } else if (interaction.commandName === 'info'){ // Problem console.log(&quot;here&quot;); id = interaction.options.string; // over here // console.log(id) // undefined console.log(admins[id]) // undefined const embed = new MessageEmbed() .setColor('#77dd77') .setTitle('Информация') .setDescription(`Имя: ${admins[id].NAME} \n **Описание:** ${admins[id].DIS} \n **Звание:** ${admins[id].ADMINLVL} \n **Наказание** - ***Выговоров:*** ${admins[id].PUNS.VARN} | ***Предов:*** ${admins[id].PUNS.PRED}`); // error await interaction.reply({ content: 'Вот!', ephemeral: true, embeds: [embed]}); console.log(interaction.option); interaction.reply(`debug - {admins} в conlose)`); } }); </code></pre> <p>How can I get the variable that was passed through <code>option</code>?<br /> I've already gone through most of the methods, but I haven't found a method to get a variable.</p> <p>I use Discord.js v13.12.0.</p> <p><code>JSON</code>:</p> <pre><code>{ &quot;76561198887558606&quot;: { &quot;NAME&quot;: &quot;Пельмень&quot;, &quot;DIS&quot;: &quot;Вы хотите знать что-то обо мне? Хи-Хи [NO DATA] ooops!&quot;, &quot;ADMINLVL&quot;: &quot;GOD XD&quot;, &quot;PUNS&quot;: { &quot;VARN&quot;: 0, &quot;PRED&quot;: 0 } }, &quot;76561199037779891&quot;:{ &quot;NAME&quot;: &quot;Senko Number ₲ne&quot;, &quot;DIS&quot;: &quot;[NO DATA] ooops!&quot;, &quot;ADMINLVL&quot;: &quot;Технарь&quot;, &quot;PUNS&quot;: { &quot;VARN&quot;: 0, &quot;PRED&quot;: 0 } } } </code></pre>
[ { "answer_id": 74253731, "author": "TheProgrammerEthan", "author_id": 14627571, "author_profile": "https://Stackoverflow.com/users/14627571", "pm_score": 0, "selected": false, "text": "const option = interaction.options.getString(\"steam64\")" }, { "answer_id": 74253821, "aut...
2022/10/30
[ "https://Stackoverflow.com/questions/74253541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17172641/" ]
74,253,554
<p>Store.js:</p> <pre><code>import {useReducer} from &quot;react&quot;; import {ACTION_TYPES} from &quot;./storeActionTypes&quot;; export const INITIAL_STATE = { counter: 0, }; export const storeReducer = (state, action) =&gt; { switch (action.type) { case ACTION_TYPES.INCREASE_COUNTER_BY_1: return { ...state, counter: state.counter + 1, }; default: return state; } }; const Store = () =&gt; { const [state, dispatch] = useReducer(storeReducer, INITIAL_STATE); return [state, dispatch]; }; export default Store; </code></pre> <p>AnyComponent.js</p> <pre><code>import React from &quot;react&quot;; import Store from &quot;../store/Store&quot;; const AnyComponent = () =&gt; { const [store, dispatch] = Store(); const handleInceaseByOne = (e) =&gt; { e.preventDefault(); dispatch({type: &quot;INCREASE_COUNTER_BY_1&quot;}); }; return ( &lt;div&gt; &lt;button onClick={(e) =&gt; handleInceaseByOne(e)}&gt;Submit&lt;/button&gt; &lt;span&gt;counter from AnyComponent.js:{store.counter}&lt;/span&gt; &lt;/div&gt; ); }; export default AnyComponent; </code></pre> <p>OtherComponent.js</p> <pre><code>import React from &quot;react&quot;; import Store from &quot;../store/Store&quot;; const OtherComponent.js = () =&gt; { const [store, dispatch] = Store(); return ( &lt;div&gt; &lt;span&gt;counter from OtherComponent.js:{store.counter}&lt;/span&gt; &lt;/div&gt; ); }; export default OtherComponent.js; </code></pre> <p>So basically like in Redux, create a one Store where you store everything. In AnyComponent.js we have button who increase counter by 1 so we can see that value of store.counter in AnyComponent.js and OtherComponent.js.<br/> Please anyone tell me if anything is wrong with this code?<br/> Will try to upload this to GitHub later.<br/></p> <p>I looked in web and did not found anything what is similar to this so please let me know what you think.</p>
[ { "answer_id": 74253982, "author": "fgkolf", "author_id": 13168083, "author_profile": "https://Stackoverflow.com/users/13168083", "pm_score": 3, "selected": true, "text": "counter" } ]
2022/10/30
[ "https://Stackoverflow.com/questions/74253554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20371859/" ]
74,253,559
<p>I am converting python 2.7 to python 3.9 with pandas 1.1.5 currently. The below code working in python 2.7 but caused an error when it is in 3.9 (or due to upgrading pandas as well)</p> <pre><code>agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' headers = {'User-Agent': agent} query = requests.get('https://query1.finance.yahoo.com/v7/finance/quote?symbols=AALI.JK') data = query.json() data = pd.DataFrame(data['quoteResponse']['result']) data['regularMarketTime']= pd.to_datetime(data['regularMarketTime'],unit='s').dt.strftime(&quot;%Y-%m-%d&quot;) data = data[['regularMarketTime','symbol','regularMarketOpen','regularMarketDayHigh','regularMarketDayLow','regularMarketPrice','regularMarketVolume']] data_append.append(data) </code></pre> <p>The error as below <code>TypeError: int() argument must be a string, a bytes-like object or a number, not '_NoValueType'</code> in line <code>data = pd.DataFrame(data['quoteResponse']['result'])</code>. Why the error occurred and how to fix.</p>
[ { "answer_id": 74253982, "author": "fgkolf", "author_id": 13168083, "author_profile": "https://Stackoverflow.com/users/13168083", "pm_score": 3, "selected": true, "text": "counter" } ]
2022/10/30
[ "https://Stackoverflow.com/questions/74253559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5730859/" ]
74,253,563
<p>Considering the following code :</p> <pre><code>switch(checkState) { case 0: pixel.addEventListener('mouseover', addColor); console.log(&quot;test&quot;); break; case 1: pixel.removeEventListener('mouseover', addColor); console.log(&quot;test2&quot;); break; } </code></pre> <p>The function containing this switch statement is called on other event, and should either add listeners if checkState === 0, or remove them if checkState === 1. But listeners aren't removed on checkState === 1, despite &quot;test2&quot; showing in the console.</p> <p>I made sure that :</p> <ul> <li>addColor is a declared function (so both addEvent and removeEvent reference the same function) ;</li> <li>both handlers refer the same DOM elements ;</li> <li>Not using the .bind method.</li> </ul> <p>I also dug into <a href="https://stackoverflow.com/questions/10444077/javascript-removeeventlistener-not-working">this topic</a> but unfortunately didn't find the solution.</p> <p>Here is a <a href="https://replit.com/@hirono9730/ValidBoringRadius#script.js" rel="nofollow noreferrer">replit</a>.</p> <p>Thank you for your time.</p>
[ { "answer_id": 74253982, "author": "fgkolf", "author_id": 13168083, "author_profile": "https://Stackoverflow.com/users/13168083", "pm_score": 3, "selected": true, "text": "counter" } ]
2022/10/30
[ "https://Stackoverflow.com/questions/74253563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14549345/" ]
74,253,569
<p>I've below macro to login web page and exract data from <code>table</code>. But sometimes login is not successful and message appears on webpage - <em>Please try to login again.</em> So I tried adding <code>If</code> loop to check whether <code>web element</code> has been loaded and if not try again login. But to due to presence of <code>If</code> loop, getting below error:</p> <p><a href="https://i.stack.imgur.com/5uIEl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5uIEl.png" alt="enter image description here" /></a></p> <pre><code>Option Explicit Private ch As Selenium.ChromeDriver Sub TestSelenium() Dim Lastrow As Variant Dim ws As Worksheet Dim sheetsname As String Dim tr, td, th As WebElement Dim c, r, l As Integer Lastrow = 1 Set ch = New Selenium.ChromeDriver ' ch.AddArgument &quot;--headless&quot; ''Hide browser ch.Start ch.Get &quot;https://address&quot; ch.Timeouts.ImplicitWait = 20000 ' 5 seconds With ch With .FindElementById(&quot;logInForm&quot;) .FindElementById(&quot;j_username&quot;).SendKeys &quot;name&quot; .FindElementById(&quot;j_password&quot;).SendKeys &quot;password@1012&quot; .FindElementById(&quot;submitButton&quot;, timeout:=1000000).Click 'ch.Timeouts.Server = 120000 ' 2 mins 'ch.Timeouts.ImplicitWait = 50000 ' 5 seconds End With 'Stop '&lt;== Delete me after inspection For l = 1 To 5 If ch.IsElementPresent(FindElementByXPath(&quot;/html/body/div[1]/div/div[2]/div/div[4]/div/table/tbody/tr/td/div/table/tbody/tr[1]/td/div/div/div/div/div/div/div[1]/div[3]/div/div[4]/div/div/div/div/div[8]/div/div/div/div[1]/div/table&quot;)) Then '' Print header For Each tr In ch.FindElementByXPath(&quot;/html/body/div[1]/div/div[2]/div/div[4]/div/table/tbody/tr/td/div/table/tbody/tr[1]/td/div/div/div/div/div/div/div[1]/div[3]/div/div[4]/div/div/div/div/div[8]/div/div/div/div[1]/div/table&quot;).FindElementByTag(&quot;thead&quot;).FindElementsByTag(&quot;tr&quot;) c = 1 For Each th In tr.FindElementsByTag(&quot;th&quot;) Sheets(&quot;Sheet1&quot;).Cells(Lastrow + r, c).Value = th.Text c = c + 1 Next th r = r + 1 Next tr '' Print table data For Each tr In ch.FindElementByXPath(&quot;/html/body/div[1]/div/div[2]/div/div[4]/div/table/tbody/tr/td/div/table/tbody/tr[1]/td/div/div/div/div/div/div/div[1]/div[3]/div/div[4]/div/div/div/div/div[8]/div/div/div/div[1]/div/table&quot;).FindElementByTag(&quot;tbody&quot;).FindElementsByTag(&quot;tr&quot;) c = 1 For Each td In tr.FindElementsByTag(&quot;td&quot;) Sheets(&quot;Sheet1&quot;).Cells(Lastrow + r, c).Value = td.Text c = c + 1 Next td r = r + 1 Next tr Else ' if table NOT found With .FindElementById(&quot;logInForm&quot;) .FindElementById(&quot;j_username&quot;).SendKeys &quot;name&quot; .FindElementById(&quot;j_password&quot;).SendKeys &quot;password@1012&quot; .FindElementById(&quot;submitButton&quot;, timeout:=1000000).Click ch.Timeouts.Server = 120000 ' 2 mins ch.Timeouts.ImplicitWait = 50000 ' 5 seconds End With For Each tr In ch.FindElementByXPath(&quot;/html/body/div[1]/div/div[2]/div/div[4]/div/table/tbody/tr/td/div/table/tbody/tr[1]/td/div/div/div/div/div/div/div[1]/div[3]/div/div[4]/div/div/div/div/div[8]/div/div/div/div[1]/div/table&quot;).FindElementByTag(&quot;thead&quot;).FindElementsByTag(&quot;tr&quot;) c = 1 For Each th In tr.FindElementsByTag(&quot;th&quot;) Sheets(&quot;Sheet1&quot;).Cells(Lastrow + r, c).Value = th.Text c = c + 1 Next th r = r + 1 Next tr ' Print table data For Each tr In ch.FindElementByXPath(&quot;/html/body/div[1]/div/div[2]/div/div[4]/div/table/tbody/tr/td/div/table/tbody/tr[1]/td/div/div/div/div/div/div/div[1]/div[3]/div/div[4]/div/div/div/div/div[8]/div/div/div/div[1]/div/table&quot;).FindElementByTag(&quot;tbody&quot;).FindElementsByTag(&quot;tr&quot;) c = 1 For Each td In tr.FindElementsByTag(&quot;td&quot;) Sheets(&quot;Sheet1&quot;).Cells(Lastrow + r, c).Value = td.Text c = c + 1 Next td r = r + 1 Next tr End If Next l .Quit End With End Sub </code></pre> <p>Any help would be appreciated.</p>
[ { "answer_id": 74254129, "author": "NickSlash", "author_id": 212869, "author_profile": "https://Stackoverflow.com/users/212869", "pm_score": 1, "selected": false, "text": "Option Explicit\nPrivate Driver As Selenium.ChromeDriver\n\nSub Main()\n\nSet Driver = New Selenium.ChromeDriver\n\n...
2022/10/30
[ "https://Stackoverflow.com/questions/74253569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9076059/" ]
74,253,584
<p>I recently downloaded unity, and I found that the localScale method was a better option for flip a character(especially for the box collider). But when I go close to a wall and turn, my character get stuck in wall. Do <a href="https://i.stack.imgur.com/zHuz1.png" rel="nofollow noreferrer">Code that I use</a>](<a href="https://i.stack.imgur.com/zHuz1.png" rel="nofollow noreferrer">https://i.stack.imgur.com/zHuz1.png</a>) have solutions ?<a href="https://i.stack.imgur.com/C7vfj.png" rel="nofollow noreferrer">Game preview</a>](<a href="https://i.stack.imgur.com/C7vfj.png" rel="nofollow noreferrer">https://i.stack.imgur.com/C7vfj.png</a>)</p> <p>I tried to make my wall bouce my character and nothing changed, sometimes he got stuck.</p>
[ { "answer_id": 74254129, "author": "NickSlash", "author_id": 212869, "author_profile": "https://Stackoverflow.com/users/212869", "pm_score": 1, "selected": false, "text": "Option Explicit\nPrivate Driver As Selenium.ChromeDriver\n\nSub Main()\n\nSet Driver = New Selenium.ChromeDriver\n\n...
2022/10/30
[ "https://Stackoverflow.com/questions/74253584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20372009/" ]
74,253,597
<p>Let's say I have progress tag which imitate progress bar for video. In this case video last 100 seconds and we are currently at 80 seconds.</p> <p>I would like to place a div square in 50 seconds of the video (on our progress bar):</p> <p>So my expected result will be:</p> <p><a href="https://i.stack.imgur.com/rsZYy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rsZYy.png" alt="enter image description here" /></a></p> <p>I have no idea how I can set such a div to just 50 seconds, because in future I would like to have more than one div to be place on this progress bar for many different second</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;progress value="80" max="100" /&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74254129, "author": "NickSlash", "author_id": 212869, "author_profile": "https://Stackoverflow.com/users/212869", "pm_score": 1, "selected": false, "text": "Option Explicit\nPrivate Driver As Selenium.ChromeDriver\n\nSub Main()\n\nSet Driver = New Selenium.ChromeDriver\n\n...
2022/10/30
[ "https://Stackoverflow.com/questions/74253597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19324810/" ]
74,253,641
<pre><code>SELECT HIRE_DATE, FIRST_NAME, LAST_NAME, CONCAT(FIRST_NAME, ' ', LAST_NAME) AS &quot;First and Last name&quot; FROM HR.EMPLOYEES </code></pre> <p>I'm trying to get one column by concatenating two other, but i get an error</p> <blockquote> <p>ORA-00909: invalid number of arguments</p> </blockquote>
[ { "answer_id": 74253670, "author": "Kazi Mohammad Ali Nur", "author_id": 8651601, "author_profile": "https://Stackoverflow.com/users/8651601", "pm_score": 1, "selected": false, "text": "concat()" }, { "answer_id": 74254232, "author": "Ramesh Kumar", "author_id": 20372484,...
2022/10/30
[ "https://Stackoverflow.com/questions/74253641", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18502120/" ]
74,253,662
<p>I want to create a button on my HTML page that reveals some images (and text) when a button is pressed. I want both to be revealed with one click and then hidden when the button is clicked again. I tried making a button that can be seen in my code that reveals an image but can't seem to figure out to have it reveal text as well.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const showImage = () =&gt; { document.getElementById("first").style.display = 'block'; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;button onClick="showImage()"&gt;Button&lt;/button&gt; &lt;div id="first" style="height:400px; width:400px; display:none;"&gt; &lt;img src="https://placekitten.com/400/400" /&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74253728, "author": "Ankit", "author_id": 19757319, "author_profile": "https://Stackoverflow.com/users/19757319", "pm_score": 0, "selected": false, "text": "let index=0 ; \nconst showImage = () => {\n index++;\n if(index%2!=0){ \n document.getElementById(\"first\").styl...
2022/10/30
[ "https://Stackoverflow.com/questions/74253662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20355729/" ]
74,253,724
<p>I'm trying to get the average of the cost value and the cost per liter.</p> <pre><code>r = [] with open('petrolPrice.txt') as f1: r = f1.read() s = r.split() del s[0] s.pop(0) print(sum(s) / len(s)) # AVERAGE COST with open('petrolPrice.txt') as f1: r = f1.read() s = r.split() s.pop(0) # COST PER LITER </code></pre> <p>Here is the text file below. The liters and cost are divided using tab space</p> <pre><code>Liters Cost 20.0 56.40 9.6 29.95 5.0 15.60 15.0 54.30 18.4 65.32 18.7 75.36 17.7 80.00 </code></pre> <p>print average and the cost per liter in the text file.</p>
[ { "answer_id": 74253728, "author": "Ankit", "author_id": 19757319, "author_profile": "https://Stackoverflow.com/users/19757319", "pm_score": 0, "selected": false, "text": "let index=0 ; \nconst showImage = () => {\n index++;\n if(index%2!=0){ \n document.getElementById(\"first\").styl...
2022/10/30
[ "https://Stackoverflow.com/questions/74253724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20372089/" ]
74,253,737
<p>I have millions of &lt; 20 char strings, and I want to compress each of them <em>individually</em>.</p> <p>Using <code>zlib</code> or <code>lz4</code> on each string individually doesn't work: the output is bigger than the input:</p> <pre><code>inputs = [b&quot;hello world&quot;, b&quot;foo bar&quot;, b&quot;HELLO foo bar world&quot;, b&quot;bar foo 1234&quot;, b&quot;12345 barfoo&quot;] import zlib for s in inputs: c = zlib.compress(s) print(c, len(c), len(s)) # the output is larger than the input </code></pre> <p>Is there a way in Python (maybe with zlib or lz4?) to use a <strong>dictionary-based compression</strong>, with a custom dictionary size (for example 64 KB or 1 MB) <strong>that would allow compression of very short strings <em>individually</em></strong>?</p> <pre><code>inputs = [b&quot;hello world&quot;, b&quot;foo bar&quot;, b&quot;HELLO foo bar world&quot;, b&quot;bar foo 1234&quot;, b&quot;12345 barfoo&quot;] D = DictionaryCompressor(dictionary_size=1_000_000) for s in inputs: D.update(s) # now the dictionary is ready for s in inputs: print(D.compress(s)) </code></pre> <p>Note: &quot;Smaz&quot; looks promising, but it is very much hard-coded and not adaptive: <a href="https://github.com/antirez/smaz/blob/master/smaz.c" rel="nofollow noreferrer">https://github.com/antirez/smaz/blob/master/smaz.c</a></p>
[ { "answer_id": 74254273, "author": "Mark Adler", "author_id": 1180620, "author_profile": "https://Stackoverflow.com/users/1180620", "pm_score": 2, "selected": false, "text": "zdict" }, { "answer_id": 74254326, "author": "Basj", "author_id": 1422096, "author_profile": ...
2022/10/30
[ "https://Stackoverflow.com/questions/74253737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1422096/" ]
74,253,743
<p>I am trying to split my cats and dogs dataset into train, validation and test sets with a 0.8, 0.1, 0.1 split, I've made this function to do it.</p> <pre><code>def split_data(main_dir, training_dir, validation_dir, test_dir): &quot;&quot;&quot; Splits the data into train and test sets Args: main_dir (string): path containing the images training_dir (string): path to be used for training validation_dir (string): path to be used for validation test_dir (string): path to be used for testing split_size (float): size of the dataset to be used for training &quot;&quot;&quot; files = [] for file in os.listdir(main_dir): if os.path.getsize(os.path.join(main_dir, file)): # check if the file's size isn't 0 files.append(file) # appends file name to a list shuffled_files = random.sample(files, len(files)) # shuffles the data split = int(0.8 * len(shuffled_files)) #the training split casted into int for numeric rounding test_split = int(0.9 * len(shuffled_files))#the test split train = shuffled_files[:split] #training split validation = shuffled_files[split:test_split] # validation split test = shuffled_files[test_split:] for element in train: copyfile(os.path.join(main_dir, element), os.path.join(training_dir, element)) for element in validation: copyfile(os.path.join(main_dir, element), os.path.join(validation_dir, element)) for element in test: copyfile(os.path.join(main_dir, element), os.path.join(validation_dir, element)) </code></pre> <p>Heres the function call:</p> <pre><code>split_data(CAT_DIR, '/tmp/cats-v-dogs/training/cats','/tmp/cats-v-dogs/validation/cats', '/tmp/cats-v-dogs/testing/cats') split_data(DOG_DIR, '/tmp/cats-v-dogs/training/dogs', '/tmp/cats-v-dogs/validation/dogs', '/tmp/cats-v-dogs/testing/dogs') </code></pre> <p>And here I list the directory lengths</p> <pre><code>print(len(os.listdir('/tmp/cats-v-dogs/training/cats'))) print(len(os.listdir('/tmp/cats-v-dogs/training/dogs'))) print(len(os.listdir('/tmp/cats-v-dogs/validation/cats'))) print(len(os.listdir('/tmp/cats-v-dogs/validation/dogs'))) print(len(os.listdir('/tmp/cats-v-dogs/testing/cats'))) print(len(os.listdir('/tmp/cats-v-dogs/testing/dogs'))) </code></pre> <p>Which gives the output</p> <p>10000</p> <p>10000</p> <p>2500</p> <p>2500</p> <p>0</p> <p>0</p> <p>The function is splitting the data 0.8, 0.2 into the train and validation sets but I need it 0.8, 0.1, 0.1, for train val and test sets but I don't know where I'm going wrong.</p>
[ { "answer_id": 74254273, "author": "Mark Adler", "author_id": 1180620, "author_profile": "https://Stackoverflow.com/users/1180620", "pm_score": 2, "selected": false, "text": "zdict" }, { "answer_id": 74254326, "author": "Basj", "author_id": 1422096, "author_profile": ...
2022/10/30
[ "https://Stackoverflow.com/questions/74253743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20301773/" ]
74,253,748
<p>Am working on active directory and i need to get a value of a checkbox in userAccountControl <a href="https://i.stack.imgur.com/c5jSv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c5jSv.png" alt="enter image description here" /></a></p> <p>and want to know if the check box is checked or not.. I tried to get the value of it by using the code</p> <pre><code> VARIANT var; VariantInit(&amp;var); hr = pUsr-&gt;Get(CComBSTR(&quot;userAccountControl&quot;), &amp;var); if (SUCCEEDED(hr)) { std::cout &lt;&lt; V_I4(&amp;var) &lt;&lt; std::endl; } </code></pre> <p>and I got the output 512. The problem is even if the checkbox is checked or unchecked it has the same value 512. it changes for other checkboxes but shows the same value for this option i need a way to find if the checkbox is true or not</p>
[ { "answer_id": 74254273, "author": "Mark Adler", "author_id": 1180620, "author_profile": "https://Stackoverflow.com/users/1180620", "pm_score": 2, "selected": false, "text": "zdict" }, { "answer_id": 74254326, "author": "Basj", "author_id": 1422096, "author_profile": ...
2022/10/30
[ "https://Stackoverflow.com/questions/74253748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19652021/" ]
74,253,749
<pre><code>import java.util.Scanner; // Needed to make Scanner available public static int age() { int age; Scanner scanner = new Scanner(System.in); System.out.println(&quot;How old are you? &quot;); age = Integer.parseInt(scanner.nextLine()); return age; } age(); public static void yesornodisability() { String disabled; Scanner scanner = new Scanner(System.in); System.out.println(&quot;Are you registered disabled(Yes / No)? &quot;); disabled = scanner.nextLine(); return; } yesornodisability(); public static int total() { int total; total = 10; return total; } total(); public static void swimmingprice() { if (age()&lt;=18);{ total() = total()/2}; else if (age()&gt;=65);{ total()=total()-3}; else if (yesornodisability().equals(&quot;Yes&quot;);{ total() = total()-4}; System.out.println(&quot;The swimming price for you is &quot;+total()+&quot; pounds.&quot;); } </code></pre> <p>I am asking two sets of questions the first question is asking there age, second question is asking if they are registered disabled. Then using both results I put them in a if statement. As if they are younger than 18 they get 50% discount, if they are registered disable they get 4 pounds discount. My inputs are working, but when I put them in the if statement they are class it expected and else without if error.</p>
[ { "answer_id": 74254273, "author": "Mark Adler", "author_id": 1180620, "author_profile": "https://Stackoverflow.com/users/1180620", "pm_score": 2, "selected": false, "text": "zdict" }, { "answer_id": 74254326, "author": "Basj", "author_id": 1422096, "author_profile": ...
2022/10/30
[ "https://Stackoverflow.com/questions/74253749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20372133/" ]
74,253,787
<p>I am developing a search engine for a website; now it's working fine and responding to input search keywords with no issues in its interaction with the (Django-based) local web server. The problem (well there are actually two, but I'm presenting only one here) is with the datalist. When I select an option from the list, although it goes into the search input field, nothing happens until I click the submit button.</p> <p>I have written an event listener for each option, but I'm clearly missing something (important). Here's my minimal working code:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code> const searchForm = document.getElementById('search-form'); const enter = document.getElementById('enter'); let options = document.querySelectorAll(".option"); options.forEach((item, index) =&gt; { item.addEventListener("click", () =&gt; { return searchForm.action; }) })</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form id="search-form" action ="{% url 'search' %}" method='POST'&gt; {% csrf_token %} &lt;input id="enter" type="search" list="options" name="query" /&gt; &lt;datalist id="options"&gt; &lt;option class="option" value="Happy"&gt; &lt;option class="option" value="Puzzled"&gt; &lt;/datalist&gt; &lt;button id="go" type="submit"&gt;&lt;strong&gt;&amp;#x1F50E;&amp;#xFE0E;&lt;/strong&gt;&lt;/button&gt; &lt;button id="reset" type="reset"&gt;&lt;strong&gt;X&lt;/strong&gt;&lt;/button&gt; &lt;/form&gt;</code></pre> </div> </div> </p> <p>Maybe the event should be something else; I've tried &quot;keydown&quot; and clicking twice but nothing has worked.</p>
[ { "answer_id": 74254273, "author": "Mark Adler", "author_id": 1180620, "author_profile": "https://Stackoverflow.com/users/1180620", "pm_score": 2, "selected": false, "text": "zdict" }, { "answer_id": 74254326, "author": "Basj", "author_id": 1422096, "author_profile": ...
2022/10/30
[ "https://Stackoverflow.com/questions/74253787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11777339/" ]
74,253,793
<p>I'm building a dialog which allow user to use multi Regions by checking the checkBox next to the region name.</p> <p>what I wanna know is how to add the Checkbox checked values to a list of int to be sent later to the API</p> <p>And how to make multi select which not affect the value of the others check boxes , What I mean is if I checked the box the whole list stays unchecked</p> <p>please I've been trying for a long time and got nothing</p> <p><a href="https://i.stack.imgur.com/F3ULe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F3ULe.png" alt="enter image description here" /></a></p> <pre><code> showDialog( context: context, builder: (context) { return AlertDialog( content: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Text('يرجي اختيار المناطق', textAlign: TextAlign.center, style: mediumStyle( fontSize: 21, color: AppColors.blackColor)), SizedBox( height: 20.h, ), SizedBox( width: 500, height: 250, child: ListView.builder( itemCount: state.selectedCity!.regions.length, itemBuilder: (context, index) { bool isChecked = false; return CheckboxListTile( title: Text( state.selectedCity!.regions[index].name, style: mediumStyle(fontSize: 20.sp, color: AppColors.blackColor), ), value: isChecked, onChanged: (value) { setState(() =&gt; isChecked = value!); List regions = []; }, ); }, ), ) ], ), ); </code></pre>
[ { "answer_id": 74254273, "author": "Mark Adler", "author_id": 1180620, "author_profile": "https://Stackoverflow.com/users/1180620", "pm_score": 2, "selected": false, "text": "zdict" }, { "answer_id": 74254326, "author": "Basj", "author_id": 1422096, "author_profile": ...
2022/10/30
[ "https://Stackoverflow.com/questions/74253793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17733339/" ]
74,253,828
<p>I currently using pandas to summarize my data. I have a data listed like this (the real data have ten of thousands of entries).</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>A</th> <th>B</th> <th>Intensity</th> <th>Area</th> </tr> </thead> <tbody> <tr> <td>3</td> <td>4</td> <td>20.2</td> <td>55</td> </tr> <tr> <td>3</td> <td>4</td> <td>20.7</td> <td>23</td> </tr> <tr> <td>3</td> <td>4</td> <td>30.2</td> <td>17</td> </tr> <tr> <td>3</td> <td>4</td> <td>51.8</td> <td>80</td> </tr> <tr> <td>5</td> <td>6</td> <td>79.6</td> <td>46</td> </tr> <tr> <td>5</td> <td>6</td> <td>11.9</td> <td>77</td> </tr> <tr> <td>5</td> <td>7</td> <td>56.7</td> <td>19</td> </tr> <tr> <td>5</td> <td>7</td> <td>23.4</td> <td>23</td> </tr> </tbody> </table> </div> <p>I would like to group the columns (A &amp; B) together and list down the all the intensity and area values without aggregating the values (eg calculate mean, median, mode etc)</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th></th> <th>A,B</th> <th></th> <th></th> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>Intensity</td> <td>3,4</td> <td>20.2</td> <td>20.7</td> <td>30.2</td> <td>51.8</td> </tr> <tr> <td></td> <td>5,6</td> <td>79.6</td> <td>11.9</td> <td>NaN</td> <td>NaN</td> </tr> <tr> <td></td> <td>5,7</td> <td>56.7</td> <td>23.4</td> <td>NaN</td> <td>NaN</td> </tr> <tr> <td>Area</td> <td>3,4</td> <td>55</td> <td>23</td> <td>17</td> <td>80</td> </tr> <tr> <td></td> <td>5,6</td> <td>46</td> <td>77</td> <td>NaN</td> <td>NaN</td> </tr> <tr> <td></td> <td>5,7</td> <td>19</td> <td>23</td> <td>NaN</td> <td>NaN</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74254273, "author": "Mark Adler", "author_id": 1180620, "author_profile": "https://Stackoverflow.com/users/1180620", "pm_score": 2, "selected": false, "text": "zdict" }, { "answer_id": 74254326, "author": "Basj", "author_id": 1422096, "author_profile": ...
2022/10/30
[ "https://Stackoverflow.com/questions/74253828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20372036/" ]
74,253,832
<p>The code was working well till when I tried Extract <em><strong>CupertinoNavigationBar</strong></em> to a widget.</p> <p><em>May Anyone please give some information why this issue happening?</em></p> <p><strong>It gives me this error:</strong></p> <blockquote> <p>Error: The argument type 'HomePageAppBar' can't be assigned to the parameter type 'ObstructingPreferredSizeWidget?'. package:flutter_todo_app/main.dart:27</p> <ul> <li>'HomePageAppBar' is from 'package:flutter_todo_app/main.dart' ('lib/main.dart'). package:flutter_todo_app/main.dart:1</li> <li>'ObstructingPreferredSizeWidget' is from 'package:flutter/src/cupertino/page_scaffold.dart' ('../../development/flutter/packages/flutter/lib/src/cupertino/page_scaffold.dart'). package:flutter/…/cupertino/page_scaffold.dart:1 navigationBar: HomePageAppBar(), ^</li> </ul> </blockquote> <pre><code>import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'widgets/body.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return CupertinoApp( debugShowCheckedModeBanner: false, home: const HomePage(), ); } } class HomePage extends StatelessWidget { const HomePage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return CupertinoPageScaffold( navigationBar: HomePageAppBar(), child: HomePageBody(), ); } } class HomePageAppBar extends StatelessWidget { const HomePageAppBar({ Key? key, }) : super(key: key); @override Widget build(BuildContext context) { return CupertinoNavigationBar( middle: const Text('app bar'), ); } } </code></pre>
[ { "answer_id": 74254273, "author": "Mark Adler", "author_id": 1180620, "author_profile": "https://Stackoverflow.com/users/1180620", "pm_score": 2, "selected": false, "text": "zdict" }, { "answer_id": 74254326, "author": "Basj", "author_id": 1422096, "author_profile": ...
2022/10/30
[ "https://Stackoverflow.com/questions/74253832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16491896/" ]
74,253,833
<p>I'm trying to filter some information from one table, but I need the criteria to look for some info inside an array. I'll give an example to try to explain what I need:</p> <p><a href="https://i.stack.imgur.com/f5WXN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f5WXN.png" alt="enter image description here" /></a></p> <p>I need to get everyone from <strong>Array1</strong> <code>E2:E4</code> that is listed on <strong>TABLE1</strong> <code>A2:C4</code> and has <strong>Monday</strong> and <strong>Yes</strong> on their respective columns.</p> <p>Hope that makes sense and that somebody will be able to help me on this one.</p> <p>Thanks a lot!</p> <p>Tried using filter formula but I can't make it work with the array as a filter.</p>
[ { "answer_id": 74254170, "author": "Carlos J.", "author_id": 16372276, "author_profile": "https://Stackoverflow.com/users/16372276", "pm_score": 0, "selected": false, "text": "*" }, { "answer_id": 74254294, "author": "Mayukh Bhattacharya", "author_id": 8162520, "autho...
2022/10/30
[ "https://Stackoverflow.com/questions/74253833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8167526/" ]
74,253,868
<p>I'm trying to set up 3NF tables and insert data, but keep getting 'UNIQUE constraint failed' error. Maybe I've done the 1NF-3NF conversion incorrectly, or incorrectly identified foreign/primary keys.</p> <p>Insert method:</p> <pre><code>INSERT INTO Employee VALUES ('16', 'Smith'), ('33', 'Smith'),('30', 'Jenny'), ('16', 'Smith') </code></pre> <p>What I hope <code>Employee</code> table to look like (16-SMITH is supposed to duplicate):</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>EMP_ID</th> <th>EMP_FNAME</th> </tr> </thead> <tbody> <tr> <td>16</td> <td>SMITH</td> </tr> <tr> <td>33</td> <td>SMITH</td> </tr> <tr> <td>30</td> <td>JENNY</td> </tr> <tr> <td>16</td> <td>SMITH</td> </tr> </tbody> </table> </div> <p>My tables:</p> <pre><code>CREATE TABLE &quot;Employee&quot; ( &quot;EMP_ID&quot; INTEGER, &quot;EMP_FNAME&quot; TEXT, PRIMARY KEY(&quot;EMP_ID&quot;) ); CREATE TABLE &quot;Project&quot; ( &quot;PROJ_ID&quot; INTEGER, &quot;JOB_TYPE&quot; INTEGER, &quot;EMP_ID&quot; INTEGER, PRIMARY KEY(&quot;PROJ_ID&quot;,&quot;EMP_ID&quot;) ); CREATE TABLE &quot;HOURLY PAY&quot; ( &quot;JOB_TYPE&quot; INTEGER, &quot;HOUR_RATE&quot; INTEGER, PRIMARY KEY(&quot;JOB_TYPE&quot;), FOREIGN KEY(&quot;JOB_TYPE&quot;) REFERENCES &quot;Project&quot;(&quot;JOB_TYPE&quot;) ); </code></pre> <p>Table I was provided with that I had to convert from 1NF-&gt;3NF:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>PROJ_ID</th> <th>PROJ_NAME</th> <th>EMP_ID</th> <th>EMP_FNAME</th> <th>JOB_TYPE</th> <th>HOUR_RATE</th> </tr> </thead> <tbody> <tr> <td>1135</td> <td>Zulu</td> <td>16</td> <td>Smith</td> <td>H25</td> <td>20</td> </tr> <tr> <td>1135</td> <td>Zulu</td> <td>33</td> <td>Smith</td> <td>H27</td> <td>20</td> </tr> <tr> <td>1188</td> <td>Voyager</td> <td>30</td> <td>Jenny</td> <td>H26</td> <td>30</td> </tr> <tr> <td>1188</td> <td>Voyager</td> <td>16</td> <td>Smith</td> <td>H25</td> <td>20</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74254070, "author": "Olivier Jacot-Descombes", "author_id": 880990, "author_profile": "https://Stackoverflow.com/users/880990", "pm_score": 2, "selected": true, "text": "EMP_ID" } ]
2022/10/30
[ "https://Stackoverflow.com/questions/74253868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17416337/" ]
74,253,871
<p>I am supposed to solve this problem in as low time complexity as possible, but let me be more specific.</p> <p>You are given a sorted array of integers that contains duplicates.</p> <p>Unique quadruple is a set of four indexes. Elements from the array under those indexes have to sum to a given value X. For example:</p> <ol> <li><p>Given an array [10, 20, 30, 40] and X = 100, there is only one quadruple: (0, 1, 2, 3).</p> </li> <li><p>Given an array [0, 0, 0, 0, 0] and X = 0, there are 5 quadruples: (0, 1, 2, 3), (0, 1, 2, 4), (0, 1, 3, 4), (0, 2, 3, 4), (1, 2, 3, 4).</p> </li> </ol> <p>On the Internet there are plenty of N^3 solutions, but those are for unique quadruples in terms on values, not indexes. In those solutions, example number 1 would still give only one quadruple: (10, 20, 30, 40), but example number 2 gives only one quadruple (0, 0, 0, 0), not five of them.</p> <p>I couldn't find a O(N^3) solution that would solve my problem instead of the other one. I can easily write a program that solves it in O(N^3logN) time. I also heard that the lower complexity bound for this problem is allegedly not known. Is there a O(N^3) solution known though?</p> <p>Solutions known to me:</p> <ol> <li><p>Obvious naive approach O(N^4):</p> <pre class="lang-cpp prettyprint-override"><code>int solution(int arr[], int arrSize, int X){ int counter = 0; for(int i=0; i&lt;arrSize-3; ++i) for(int j=i+1; j&lt;arrSize-2; ++j) for(int k=j+1; k&lt;arrSize-1; ++k) for(int l=k+1; l&lt;arrSize; ++l) if(arr[i] + arr[j] + arr[k] + arr[l] == X) ++counter; return counter; } </code></pre> </li> <li><p>Approach using triplets and binary search O(N^3logN):</p> <pre class="lang-cpp prettyprint-override"><code>int solution(int arr[], int arrSize, int X){ int counter = 0; for(int i=0; i&lt;arrSize-3; ++i) for(int j=i+1; j&lt;arrSize-2; ++j) for(int k=j+1; k&lt;arrSize-1; ++k){ int subX = X - arr[i] - arr[j] - arr[k]; int first = binFirst(subX, arr, k+1, arrSize); // Binary search that returns the position of the first // occurrence of subX in arr in range [k+1, arrSize) // or -1 if not found int last = binLast(subX, arr, k+1, arrSize); // Binary search that returns the position of the last // occurrence of subX in arr in range [k+1, arrSize) // or -1 if not found if(first != -1) counter += last - first + 1; return counter; </code></pre> </li> </ol> <p>Naturally, the above algorithm could be improved by counting all duplicates of arr[i], arr[j], arr[k], but as far as I can tell, it does not lower the actual O(N^3logN) complexity.</p>
[ { "answer_id": 74255008, "author": "Navpreet Devpuri", "author_id": 8099521, "author_profile": "https://Stackoverflow.com/users/8099521", "pm_score": 3, "selected": false, "text": "pairs" }, { "answer_id": 74256562, "author": "גלעד ברקן", "author_id": 2034787, "author...
2022/10/30
[ "https://Stackoverflow.com/questions/74253871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10515330/" ]
74,253,875
<p>Im trying to make an Star Pattern Generator in Flutter. I pass Data from type int in a callback function from the child widget: Textfield Widget to the parent Widget CustomBarWidget and after to the Toplevel parent Widget RootPage.</p> <p>At the Textfield I got an Error at the Line:</p> <pre><code>onChanged: widget.onChange, </code></pre> <p>The Error says: The argument type 'dynamic Function(int)' can't be assigned to the parameter type void Function(String)?</p> <p>Here is the Full Code:</p> <p>RootPage:</p> <pre><code>class RootPage extends StatefulWidget { const RootPage({super.key}); @override State&lt;RootPage&gt; createState() =&gt; _RootPageState(); } class _RootPageState extends State&lt;RootPage&gt; { int data = 5; void getData(int newNumb) { setState(() { data = newNumb; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: CustomBarWidget(sendData: getData), body: StarTriangleWidget(data: data), ); } } </code></pre> <p>CustomBarWidget:</p> <pre><code>class CustomBarWidget extends StatefulWidget implements PreferredSizeWidget { const CustomBarWidget({super.key, this.sendData}); final sendData; @override Size get preferredSize =&gt; const Size.fromHeight(70.0); @override State&lt;CustomBarWidget&gt; createState() =&gt; _CustomBarWidgetState(); } class _CustomBarWidgetState extends State&lt;CustomBarWidget&gt; { int data = 0; @override Widget build(BuildContext context) { return AppBar( backgroundColor: Colors.transparent, elevation: 0, title: Row( children: &lt;Widget&gt;[ TextfielWidget(onChange: (val) { widget.sendData(val); }), ElevatedButton( onPressed: () { debugPrint(&quot;click&quot;); }, style: ElevatedButton.styleFrom( padding: const EdgeInsets.symmetric(horizontal: 40.0, vertical: 15.0), shape: const StadiumBorder(), ), child: const Text( &quot;Enter&quot;, style: TextStyle(color: Colors.white, fontSize: 18), ), ), ], ), ); } } </code></pre> <p>textfieldWidget:</p> <pre><code>class TextfielWidget extends StatefulWidget { final Function(int) onChange; const TextfielWidget({super.key, required this.onChange}); @override State&lt;TextfielWidget&gt; createState() =&gt; _TextfielWidgetState(); } class _TextfielWidgetState extends State&lt;TextfielWidget&gt; { @override Widget build(BuildContext context) { return Flexible( child: TextField( onChanged: widget.onChange, keyboardType: TextInputType.number, decoration: const InputDecoration( border: OutlineInputBorder(), labelText: 'Enter Number', ) ) ); } } </code></pre> <p>Where can I change the type of &quot;void Function(String)?&quot;? I can't find the Problem, is the Problem the Textfield itself?</p> <p>Thank you for help</p>
[ { "answer_id": 74255008, "author": "Navpreet Devpuri", "author_id": 8099521, "author_profile": "https://Stackoverflow.com/users/8099521", "pm_score": 3, "selected": false, "text": "pairs" }, { "answer_id": 74256562, "author": "גלעד ברקן", "author_id": 2034787, "author...
2022/10/30
[ "https://Stackoverflow.com/questions/74253875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20372186/" ]
74,253,882
<p>A normal split:</p> <pre><code>s = &quot;/works/proj/kod/resources/excel/words/tam.xls&quot; p = s.split(&quot;/kod&quot;) print(p) </code></pre> <p>Result</p> <pre><code>['/works/proj', '/resources/excel/words/tam.xls'] </code></pre> <p>What I want to obtain is, a split in front of the passed particle/word.:</p> <p>Example:</p> <pre><code> ['/works/proj', '/kod/resources/excel/words/tam.xls'] </code></pre>
[ { "answer_id": 74253968, "author": "Thunderwrathy", "author_id": 10277059, "author_profile": "https://Stackoverflow.com/users/10277059", "pm_score": 3, "selected": true, "text": "s = \"/works/proj/kod/resources/excel/words/tam.xls\"\np = s.split(\"/kod\")\np[1] = \"/kod\" + p[1]\nprint(p...
2022/10/30
[ "https://Stackoverflow.com/questions/74253882", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3541631/" ]
74,253,893
<p>I am finding indexes of <code>1's</code> in a bit string successfully. However, these indexes start from <code>0</code>.</p> <p><strong>Sample Data:</strong></p> <pre><code>initial_pop 000000000000000000000000000001011000000 000000001000000000000001000000000010000 000000000000000000000000000000010011000 000000000000001001000000000000010000000 000000000000000000010000001000000010000 1000000000100000000010000000000000000000 1000000010000000000001000000000000000000 1001000000000000000010000000000000000000 000000000000100000000000100000000000010 000000000110000000000000000000001000000 </code></pre> <p>Now, If we look at the <code>6th, 7th, and 8th</code> data rows, values are placed at index 0 by default.</p> <p><strong>My sample code:</strong></p> <pre><code>#Getting 1's index in a bit string def intial_population(df_initial_pop): for ind in df_initial_pop['initial_pop'].index: msu_locations = indices(df_initial_pop['initial_pop'] [ind]) initial_chromosomes_list.append(msu_locations) #Calling function intial_population(df_initial_pop) </code></pre> <p><strong>Output: (<code>print (initial_chromosomes_list</code>))</strong></p> <pre><code>[{32, 29, 31}, {8, 34, 23}, {34, 35, 31}, {17, 14, 31}, {26, 19, 34}, {0, 10, 20}, {0, 8, 21}, {0, 3, 20}, {24, 12, 37}, {32, 9, 10}] </code></pre> <p>As you can see in the above ouput, the index values are starting from <code>0</code>.</p> <p><strong>Is it possible that I start my indexes from <code>1</code>?</strong></p>
[ { "answer_id": 74253968, "author": "Thunderwrathy", "author_id": 10277059, "author_profile": "https://Stackoverflow.com/users/10277059", "pm_score": 3, "selected": true, "text": "s = \"/works/proj/kod/resources/excel/words/tam.xls\"\np = s.split(\"/kod\")\np[1] = \"/kod\" + p[1]\nprint(p...
2022/10/30
[ "https://Stackoverflow.com/questions/74253893", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13373167/" ]
74,253,903
<p>I am working with R and I have a series x at quarterly frequency and for which I want to extract the mean over the four quarters in 2012 and store that value in all rows of a newly created column. I have this kind of dataset</p> <pre><code>date durabl services 2011-10-01 56.7 37.1 2012-01-01 68.1 90.6 2012-04-01 34.1 29.1 2012-07-01 22.56 34.12 2012-10-01 44.89 66.8 </code></pre> <p>And I want to get to this</p> <pre><code>date durabl services base_durabl base_services 2011-10-01 56.7 37.1 42.4125 55.155 2012-01-01 68.1 90.6 42.4125 55.155 2012-04-01 34.1 29.1 42.4125 55.155 2012-07-01 22.56 34.12 42.4125 55.155 2012-10-01 44.89 66.8 42.4125 55.155 </code></pre> <p>I tried using dplyr</p> <pre><code>df %&gt;% group_by(year(date)) %&gt;% filter(year(date)==2012) %&gt;% mutate(base_durabl= mean(durabl),base_services=mean(services)) </code></pre> <p>or with summarise but of course I just get a smaller tibble.</p>
[ { "answer_id": 74253968, "author": "Thunderwrathy", "author_id": 10277059, "author_profile": "https://Stackoverflow.com/users/10277059", "pm_score": 3, "selected": true, "text": "s = \"/works/proj/kod/resources/excel/words/tam.xls\"\np = s.split(\"/kod\")\np[1] = \"/kod\" + p[1]\nprint(p...
2022/10/30
[ "https://Stackoverflow.com/questions/74253903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332100/" ]
74,253,945
<p>as title says I want to make a loop foreach item where the post_user_id and user_id match, but just dont know quite how</p> <pre><code>@foreach($posts as $post where $post-&gt;user_id == auth()-&gt;user()-&gt;id) @endforeach </code></pre> <p>There many posts with different post_user_id's but i want for a specific account to see all his own posts.</p>
[ { "answer_id": 74254111, "author": "Innovin", "author_id": 14357856, "author_profile": "https://Stackoverflow.com/users/14357856", "pm_score": 2, "selected": true, "text": "// I'm assuming the name of your model is POST\n$posts = Post::where('user_id',auth()->user()->id)->get();\n\n// th...
2022/10/30
[ "https://Stackoverflow.com/questions/74253945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332808/" ]
74,253,946
<p>I will start this by saying I have read all of the posts I have found on here regarding this issue and have troubleshot all of the solutions suggested, and none have worked. I have also tried all of the suggestions from the AWS and MySQL websites themselves to no avail. I believe the issue is a Security issue, but I'm not sure where the issue is. All of these were set to Public. So far I have done the following: MySQL side: -Installed Visual Studio 2019 toggled so that it can use the MySQL for Visual Studio in case I need it (Currently, my plan is to use Eclipse as my IDE, but this is my first time interfacing with MySQL in Java and I'm not sure if I will be able to use the Connector directly with Eclipse or if I will need this) -I installed 8.0.31, but rolled it back believing it may have been an issue with 8.0.31 being newer than 8.0.30 and seeing there is no documentation saying this version is compatible with RDS in Amazon's documentation -Installed 8.0.30 as both Developer and Custom (installed MySQL Server, MySQL Workbench, MySQL for Visual Studio, MySQL Shell, Connector/J)</p> <p>From RDS I have done the following: -Created 3 different Databases, 2 using the &quot;Standard&quot; mode, 1 using the &quot;Easy&quot; mode. The 2 using the &quot;Standard&quot; mode were toggled with one using an EC2 and one not using an EC2. -For all 3 Databases, I went in and Edited the Inbound Rules to add a rule of &quot;All traffic&quot; and &quot;Anywhere-IPv4&quot;. I'm aware this is actually a security risk, but this is for a school project and I'm literally trying to connect to the Database. Currently, I'm the only person who needs to connect to the Database and when I can actually do it, I will limit it to my IP Address.</p> <p>I have tried connecting from the Workbench itself and also from the Command Prompt, but I cannot find any more suggestions for what can be the issue. I have also changed the name of the Masteruser (to &quot;root&quot; and &quot;root user&quot;) and simplified the Masterpassword. This is for a school project so no confidential information is in it. I have literally spent an entire day trying to solve this issue and have no idea what else it could be unless it is the admin as I am not the Admin. I have seen a suggestion to make sure the Subnet for the Internet Gateway is active, but I haven't seen information on how to actually verify this, so if this is likely the issue, information on how to check this would be very useful.</p>
[ { "answer_id": 74254111, "author": "Innovin", "author_id": 14357856, "author_profile": "https://Stackoverflow.com/users/14357856", "pm_score": 2, "selected": true, "text": "// I'm assuming the name of your model is POST\n$posts = Post::where('user_id',auth()->user()->id)->get();\n\n// th...
2022/10/30
[ "https://Stackoverflow.com/questions/74253946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20372125/" ]
74,253,949
<p>How to finish the forever when another component has finished in uvm? There is 2 components first component_a just send transaction from uvm_tlm_analysis_fifo. and other component_b keep polling the received transaction. I want if component_a has finished then component_b also finished.</p> <p>But currently component_b never stop because it is along with forever statement.</p> <p>How do I finish the another component's process? component_b never stop.</p> <pre><code>class basic_test extends uvm_test; .. task run_phase(uvm_phase phase); phase.raise_objection(this); // raise an objection #500; phase.drop_objection(this); // drop an objection endtask: run_phase endclass class component_a extends uvm_component; transaction trans; ... uvm_analysis_port#(transaction) analysis_port; ... virtual task run_phase(uvm_phase phase); for(int a=0; a&lt;10; a++) begin trans = transaction::type_id::create(&quot;trans&quot;); if (!trans.randomize()) `uvm_fatal(&quot;RNDERR&quot;, &quot;Randomization of trans failed&quot;); analysis_port.write(trans); `uvm_info(get_type_name(), &quot;Trans Sending....&quot;,UVM_LOW) end endtask endclass class component_b extends uvm_component; ... virtual task run_phase(uvm_phase phase); ... forever begin `uvm_info(get_type_name(), $sformatf(&quot; FIFO used: %0d&quot;, analy_fifo.used()), UVM_LOW) if(analy_fifo.is_empty()) begin `uvm_info(get_type_name(), &quot;FIFO is Empty!!!!!&quot;,UVM_LOW) end else begin analy_fifo.get(trans); `uvm_info(get_type_name(),$sformatf(&quot; Printing receive trans, \n &quot;,trans.sprint()),UVM_LOW) end end endtask endclass </code></pre> <p>I expected that component_b working as background but I only get the printg as below</p> <pre><code>UVM_INFO component_b.sv(55) @ 0: uvm_test_top.env.comp_b [component_b] FIFO is Empty!!!!! UVM_INFO component_b.sv(52) @ 0: uvm_test_top.env.comp_b [component_b] FIFO used: 0 UVM_INFO component_b.sv(55) @ 0: uvm_test_top.env.comp_b [component_b] FIFO is Empty!!!!! UVM_INFO component_b.sv(52) @ 0: uvm_test_top.env.comp_b [component_b] FIFO used: 0 ... </code></pre> <p>There is no time consume by test and component_a has no chance to work.</p>
[ { "answer_id": 74254799, "author": "dave_59", "author_id": 2755607, "author_profile": "https://Stackoverflow.com/users/2755607", "pm_score": 2, "selected": true, "text": "raise/drop_objection()" }, { "answer_id": 74567703, "author": "Parth Pandya", "author_id": 20595321, ...
2022/10/30
[ "https://Stackoverflow.com/questions/74253949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20066803/" ]
74,253,980
<p>I have an array of pointers, <code>componentArray</code>, but I'm struggling to figure out the syntax to both render them in <code>ParentComponent</code></p> <pre class="lang-js prettyprint-override"><code> function Component1() { return( &lt;h1&gt;Hello from Component 1&lt;/h1&gt; ); } function Component2() { return( &lt;h1&gt;Hello from Component 2&lt;/h1&gt; ); } export const componentObject = [{ name: &quot;Component1&quot;, pointer: Component1 }, { name: &quot;Component2&quot;, pointer: Component2 }]; function ParentComponent(props) { return ( &lt;div&gt; {Object.entries(componentObject).map((ChildComponent) =&gt; ( &lt;span&gt;{ChildComponent[1]() DOESNOTWORKPROP=&quot;Test&quot;}&lt;/span&gt; ))} &lt;/div&gt; ); }; </code></pre> <p>The above will work if you remove <code>DOESNOTWKRPROP=&quot;TEST&quot;</code>, but will not work when trying to add props to the children.</p>
[ { "answer_id": 74254799, "author": "dave_59", "author_id": 2755607, "author_profile": "https://Stackoverflow.com/users/2755607", "pm_score": 2, "selected": true, "text": "raise/drop_objection()" }, { "answer_id": 74567703, "author": "Parth Pandya", "author_id": 20595321, ...
2022/10/30
[ "https://Stackoverflow.com/questions/74253980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4427375/" ]
74,254,027
<p>am trying to compere 2 arrays formed from numbers this is the code</p> <pre><code>#include&lt;stdio.h&gt; #include&lt;string.h&gt; #include&lt;stdlib.h&gt; int main() { int n,i,j,k; int a[n]; int b[n]; int ta=sizeof(a); printf(&quot;Enter la taille du tableux: &quot;); scanf(&quot;%d&quot;, &amp;n); // taking input a printf(&quot;Enter %d nombres: &quot;,n); for(i = 0; i &lt; n; ++i) { scanf(&quot;%d&quot;, &amp;a[i]); } // taking input b printf(&quot;Enter %d nombres: &quot;,n); for(j = 0; j &lt; n; ++j) { scanf(&quot;%d&quot;, &amp;b[j]); } //a to b for(k=0;k&lt;ta;k++) { if(a[k] != b[k]) { printf(&quot;Is ne sont pas identiques.\n&quot;); exit(0); } else if(k == n-1) { printf(&quot;Ils sont identiques.\n&quot;); } } } </code></pre> <p>but am not getting the comparation after inserting the arrays, what am i doing wrong.</p> <p>but am not getting the comparation after inserting the arrays, what am i doing wrong.</p>
[ { "answer_id": 74254799, "author": "dave_59", "author_id": 2755607, "author_profile": "https://Stackoverflow.com/users/2755607", "pm_score": 2, "selected": true, "text": "raise/drop_objection()" }, { "answer_id": 74567703, "author": "Parth Pandya", "author_id": 20595321, ...
2022/10/30
[ "https://Stackoverflow.com/questions/74254027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17992777/" ]
74,254,066
<p>I have a table where I have students name, their ID and a bit to signify whether or not they passed a certain subject. Ultimately, I would like to group by all the subjects in 1 report / query where individuals have passed. I couldnt figure out how to script this so I just did a <code>select *</code> and elected to try in crystal reports.</p> <p>This is my Data.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">ID</th> <th style="text-align: center;">Name</th> <th style="text-align: center;">passMath</th> <th style="text-align: center;">passScience</th> <th style="text-align: center;">passFrench</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">1</td> <td style="text-align: center;">Peter</td> <td style="text-align: center;">1</td> <td style="text-align: center;">0</td> <td style="text-align: center;">1</td> </tr> <tr> <td style="text-align: left;">2</td> <td style="text-align: center;">John</td> <td style="text-align: center;">1</td> <td style="text-align: center;">1</td> <td style="text-align: center;">1</td> </tr> <tr> <td style="text-align: left;">3</td> <td style="text-align: center;">Kacy</td> <td style="text-align: center;">0</td> <td style="text-align: center;">1</td> <td style="text-align: center;">1</td> </tr> </tbody> </table> </div> <p>And this is the expected results, or what I am ultimately trying to show in a report. Basically, in my crystal report, I'll have a secion<br /> <strong>Math</strong></p> <p>Peter</p> <p><strong>Science</strong></p> <p>John</p> <p>Kacy</p> <p><strong>French</strong></p> <p>Peter</p> <p>John</p> <p>Kacy</p> <p><strong>What have I tried</strong></p> <p>Now, I haven't figured out how to do this in a query, so what I did is, following the answer from this link I tried to <a href="https://stackoverflow.com/questions/64811666/add-a-conditional-row-in-crystal-report">conditionally render a section</a>.</p> <p>My issue is, this sort of works but the results it's returning is.</p> <p><strong>passMath</strong></p> <p>Peter</p> <p>passScience</p> <p>John</p> <p><strong>passMath</strong></p> <p>John</p> <p>Basically, instead of grouping everyone who passed math together, it's giving them their separate row. So John and Peter both create a section titled &quot;passMath&quot; where I want them to be grouped together. What I did in crystal report was to create a section&gt;section expert and add <code>{usp_student.passMath}= false</code> to the formula area where I expect it to suppress all records that didnt pass Math. So far it works 50% And I would like it to group them all.</p> <p>Appreciate if I could get help with this query or a way to fix the crystal report.</p>
[ { "answer_id": 74254799, "author": "dave_59", "author_id": 2755607, "author_profile": "https://Stackoverflow.com/users/2755607", "pm_score": 2, "selected": true, "text": "raise/drop_objection()" }, { "answer_id": 74567703, "author": "Parth Pandya", "author_id": 20595321, ...
2022/10/30
[ "https://Stackoverflow.com/questions/74254066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7686595/" ]