qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,129,055
<p>I am trying to place a background image for a personal webpage and I have yet to find any solutions for my issue. All I get is a white background.</p> <p>File path for image: /personal-page/images/ales-nesetril-Im7lZjxeLhg-unsplash.jpg</p> <p>File path for code: /personal-page/style.css</p> <p>Here is my code:</p> <p>CSS</p> <pre><code>#hero{ background-image: url(/images/ales-nesetril-Im7lZjxeLhg-unsplash.jpg); background-size: cover; background-position: top center; position: relative; } </code></pre> <p>HTML</p> <pre><code>&lt;!-- Hero Section --&gt; &lt;section id=&quot;Hero&quot;&gt; &lt;div class=&quot;hero container&quot;&gt; &lt;div&gt; &lt;h1&gt;Hello, My Name is Isaac&lt;/h1&gt; &lt;a href=&quot;#&quot; type=&quot;button&quot; class=&quot;cta&quot;&gt;Portfolio&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/section&gt; &lt;!-- End Hero Section--&gt; </code></pre>
[ { "answer_id": 74129109, "author": "Filipe Mendonça", "author_id": 19298308, "author_profile": "https://Stackoverflow.com/users/19298308", "pm_score": 0, "selected": false, "text": "background-image: url(/images/ales-nesetril-Im7lZjxeLhg-unsplash.jpg);\n" }, { "answer_id": 741291...
2022/10/19
[ "https://Stackoverflow.com/questions/74129055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20284658/" ]
74,129,088
<p>I have some python code that is listening to a socket connection and processes tasks that it receives via that socket. The python code has a multiprocessing pool in it that takes care of these tasks. (A task is assigned to some process in the pool)</p> <p>These tasks involve an API request and I noticed that each time it is doing a task it is repeating the handshake (whereas it should reuse the session).</p> <p>To make sure the processes are not interfering with one another I tried to give each process it's own session. But for some reason I do not get that to work.</p> <p>My attempt</p> <pre><code>import multiprocessing import requests def init_pool(): global s s = requests.Session() print(s) def f(): print(s) pool = multiprocessing.Pool(4, initializer=init_pool ) res= pool.map(f,[1,2,3,4]) </code></pre> <p>When looking at the print in the function <code>f</code> you can notice that the sessions are actually the same. Which surprised my because this code</p> <pre><code>import multiprocessing import random def init_pool(): global r r = random.random() def f(): print(r) pool = multiprocessing.Pool(4, initializer=init_pool ) res= pool.map(f,[1,2,3,4]) </code></pre> <p>does print distinct values.</p> <p>My question is how can I reuse a session in a multiprocessing pool the right way? (preventing repeated handshakes)</p>
[ { "answer_id": 74129242, "author": "jsbueno", "author_id": 108205, "author_profile": "https://Stackoverflow.com/users/108205", "pm_score": 2, "selected": false, "text": "import multiprocessing\nimport requests\nimport random\n\ndef init_pool():\n global s\n s = requests.Session()\n...
2022/10/19
[ "https://Stackoverflow.com/questions/74129088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20149370/" ]
74,129,136
<p>I have recently published my C# app using ClickOnce. When I run my app on my PC which uses windows 10, it runs fine but when I try using my other pc which too has windows 10 installed, it doesn't open. I tried using compatibility troubleshooter which recommended me the setting for win 8 and after applying its recommended settings, my app just works fine on my other pc. Pls tell me why is this issue happening? I know it resolves when we use the troubleshooter, but I would be distributing this app and it will make it difficult for users to manually turn it on. My source code is available here: <a href="https://github.com/Yuvaan17/KrakenZ_Tweaker" rel="nofollow noreferrer">https://github.com/Yuvaan17/KrakenZ_Tweaker</a></p> <p>I had checked the event viewer and here are the debugging details-<br /> Here is the first error message:</p> <pre><code> at System.ThrowHelper.ThrowSecurityException(System.ExceptionResource) at Microsoft.Win32.RegistryKey.OpenSubKey(System.String, Boolean) at KrakenZ_Tweaker.UserControls.UserControl2.Disable_Xbox_Services_Checked(System.Object, System.Windows.RoutedEventArgs) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean) at System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs) at System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs) at System.Windows.Controls.Primitives.ToggleButton.OnChecked(System.Windows.RoutedEventArgs) at System.Windows.Controls.Primitives.ToggleButton.OnIsCheckedChanged(System.Windows.DependencyObject, System.Windows.DependencyPropertyChangedEventArgs) at System.Windows.DependencyObject.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs) at System.Windows.FrameworkElement.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs) at System.Windows.DependencyObject.NotifyPropertyChange(System.Windows.DependencyPropertyChangedEventArgs) at System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex, System.Windows.DependencyProperty, System.Windows.PropertyMetadata, System.Windows.EffectiveValueEntry, System.Windows.EffectiveValueEntry ByRef, Boolean, Boolean, System.Windows.OperationType) at System.Windows.DependencyObject.SetValueCommon(System.Windows.DependencyProperty, System.Object, System.Windows.PropertyMetadata, Boolean, Boolean, System.Windows.OperationType, Boolean) at System.Windows.Controls.Primitives.ToggleButton.set_IsChecked(System.Nullable`1&lt;Boolean&gt;) at KrakenZ_Tweaker.UserControls.UserControl2..ctor() at KrakenZ_Tweaker.MainWindow..ctor() Exception Info: System.Reflection.TargetInvocationException at System.RuntimeTypeHandle.CreateInstance(System.RuntimeType, Boolean, Boolean, Boolean ByRef, System.RuntimeMethodHandleInternal ByRef, Boolean ByRef) at System.RuntimeType.CreateInstanceSlow(Boolean, Boolean, Boolean, System.Threading.StackCrawlMark ByRef) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean, Boolean, Boolean, System.Threading.StackCrawlMark ByRef) at System.Activator.CreateInstance(System.Type, Boolean) at System.RuntimeType.CreateInstanceImpl(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo, System.Object[], System.Threading.StackCrawlMark ByRef) at System.Activator.CreateInstance(System.Type, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo, System.Object[]) at System.Activator.CreateInstance(System.Type, System.Object[]) at System.Xaml.Schema.SafeReflectionInvoker.CreateInstanceCritical(System.Type, System.Object[]) at System.Xaml.Schema.SafeReflectionInvoker.CreateInstance(System.Type, System.Object[]) at System.Xaml.Schema.XamlTypeInvoker.CreateInstance(System.Object[]) at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstanceWithCtor(System.Xaml.XamlType, System.Object[]) at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstance(System.Xaml.XamlType, System.Object[]) at System.Xaml.XamlObjectWriter.Logic_CreateAndAssignToParentStart(MS.Internal.Xaml.Context.ObjectWriterContext) at System.Xaml.XamlObjectWriter.WriteStartMember(System.Xaml.XamlMember) at System.Xaml.XamlWriter.WriteNode(System.Xaml.XamlReader) at System.Windows.Markup.WpfXamlLoader.TransformNodes(System.Xaml.XamlReader, System.Xaml.XamlObjectWriter, Boolean, Boolean, Boolean, System.Xaml.IXamlLineInfo, System.Xaml.IXamlLineInfoConsumer, MS.Internal.Xaml.Context.XamlContextStack`1&lt;System.Windows.Markup.WpfXamlFrame&gt;, System.Windows.Markup.IStyleConnector) at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri) at System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri) at System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean) at System.Windows.Application.LoadBamlStreamWithSyncInfo(System.IO.Stream, System.Windows.Markup.ParserContext) at System.Windows.Application.LoadComponent(System.Uri, Boolean) at System.Windows.Application.DoStartup() at System.Windows.Application.&lt;.ctor&gt;b__1_0(System.Object) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) at System.Windows.Threading.DispatcherOperation.InvokeImpl() at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object) at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.ProcessQueue() at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr) at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef) at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame) at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame) at System.Windows.Application.RunDispatcher(System.Object) at System.Windows.Application.RunInternal(System.Windows.Window) at System.Windows.Application.Run(System.Windows.Window) at KrakenZ_Tweaker.App.Main() </code></pre> <p>Here is the second error message:</p> <pre><code> Faulting application name: KrakenZ Tweaker.exe, version: 1.0.0.0, time stamp: 0xb3f073bc Faulting module name: KERNELBASE.dll, version: 10.0.19041.1288, time stamp: 0x3e55bd0b Exception code: 0xe0434352 Fault offset: 0x0012b5b2 Faulting process id: 0x130 Faulting application start time: 0x01d8e3095e6e54e8 Faulting application path: C:\Users\nevat\AppData\Local\Apps\2.0\YW14JZH9.DZ8\WQ9TP99E.PRA\krak..tion_f4f8753dddbedea6_0001.0000_7a77a162166539c7\KrakenZ Tweaker.exe Faulting module path: C:\Windows\System32\KERNELBASE.dll Report Id: 9912415b-acac-4a3d-bedb-24d07417ebb2 Faulting package full name: Faulting package-relative application ID: </code></pre> <p>Here is the 3rd:</p> <pre><code>Fault bucket 2059872029189490063, type 5 Event Name: CLR20r3 Response: Not available Cab Id: 0 Problem signature: P1: KrakenZ Tweaker.exe P2: 1.0.0.0 P3: de4d2f9f P4: mscorlib P5: 4.8.4515.0 P6: 624cf315 P7: 340 P8: 10 P9: N3CTRYE2KN3C34SGL4ZQYRBFTE4M13NB P10: Attached files: \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERCBE7.tmp.dmp \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERCDFB.tmp.WERInternalMetadata.xml \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERCE3A.tmp.xml These files may be available here: \\?\C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_KrakenZ Tweaker._829d1d36f9ea56e8517d64b3be67bf83e37261_780215cd_c5b1fb2f-51d2-4d41-b1b7-3ff3c56dfd8c Analysis symbol: Rechecking for solution: 0 Report Id: 80bb5e81-84c9-4e03-b56a-a8e65a2a558c Report Status: 268435456 Hashed bucket: c5259aa8925522deac9622b2669a458f Cab Guid: 0 </code></pre>
[ { "answer_id": 74130740, "author": "Joe", "author_id": 5869304, "author_profile": "https://Stackoverflow.com/users/5869304", "pm_score": 2, "selected": false, "text": "RegistryKey.OpenSubKey" }, { "answer_id": 74184237, "author": "Yuvaan Nevatia", "author_id": 20058159, ...
2022/10/19
[ "https://Stackoverflow.com/questions/74129136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20058159/" ]
74,129,153
<p>Im trying to write an sql statement which summarizes the count of rows by values in a specific column.</p> <p>I have several tables, starting with s0_ Every table has a huge amount of rows with multiple, different values in column load_nr.</p> <p>Example: s0_table1:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>load_nr</th> <th>column2</th> <th>column3...</th> </tr> </thead> <tbody> <tr> <td>101</td> <td>someData</td> <td>someData...</td> </tr> <tr> <td>101</td> <td>someData</td> <td>someData...</td> </tr> <tr> <td>102</td> <td>someData</td> <td>someData...</td> </tr> <tr> <td>103</td> <td>someData</td> <td>someData...</td> </tr> <tr> <td>103</td> <td>someData</td> <td>someData...</td> </tr> <tr> <td>103</td> <td>someData</td> <td>someData...</td> </tr> </tbody> </table> </div> <p>S0_table2:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>load_nr</th> <th>column2</th> <th>column3...</th> </tr> </thead> <tbody> <tr> <td>101</td> <td>someData</td> <td>someData...</td> </tr> <tr> <td>102</td> <td>someData</td> <td>someData...</td> </tr> <tr> <td>102</td> <td>someData</td> <td>someData...</td> </tr> <tr> <td>102</td> <td>someData</td> <td>someData...</td> </tr> <tr> <td>102</td> <td>someData</td> <td>someData...</td> </tr> <tr> <td>103</td> <td>someData</td> <td>someData...</td> </tr> </tbody> </table> </div> <p>Desired result:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>load_nr</th> <th>count s0_table1</th> <th>count s0_table2</th> </tr> </thead> <tbody> <tr> <td>101</td> <td>2</td> <td>1</td> </tr> <tr> <td>102</td> <td>1</td> <td>4</td> </tr> <tr> <td>103</td> <td>3</td> <td>1</td> </tr> </tbody> </table> </div> <p>New data with up counting load_nr is added every day. Best case is, that the table names are fetched dynamically (s0_*).</p> <p>Could anyone give me a cloue how to build this statement? I'm a newbe and not so experienced with more complicated statements.</p> <p>Best Regards</p> <p>*edit: Hopefully the tables are displayed correctly xD</p>
[ { "answer_id": 74130740, "author": "Joe", "author_id": 5869304, "author_profile": "https://Stackoverflow.com/users/5869304", "pm_score": 2, "selected": false, "text": "RegistryKey.OpenSubKey" }, { "answer_id": 74184237, "author": "Yuvaan Nevatia", "author_id": 20058159, ...
2022/10/19
[ "https://Stackoverflow.com/questions/74129153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10055515/" ]
74,129,154
<p><img src="https://i.stack.imgur.com/1x4xd.png" alt="enter image description here" /></p> <p>I want to get the else statement only if there is no word from the spam_word list matches the data.</p>
[ { "answer_id": 74129446, "author": "Brian Artschwager", "author_id": 3482194, "author_profile": "https://Stackoverflow.com/users/3482194", "pm_score": 2, "selected": false, "text": "count = 0\nfor word in spam_word:\n if word in data:\n print(word)\n count += 1\n\n# afte...
2022/10/19
[ "https://Stackoverflow.com/questions/74129154", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20284824/" ]
74,129,188
<p>I want to check where the characters in <code>sentence</code> is placed in <code>alphabet_S</code>.</p> <p>I used match function but outcome is <code>NA</code>. Why is this happening?</p> <pre><code>sentence&lt;-c(&quot;soccer is difficult&quot;) sentence&lt;-tolower(sentence) sentence2&lt;-strsplit(sentence, &quot;&quot;) alphabet_S&lt;-c(&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;,&quot;f&quot;,&quot;g&quot;,&quot;h&quot;,&quot;i&quot;,&quot;j&quot;, &quot;k&quot;,&quot;l&quot;,&quot;m&quot;,&quot;n&quot;,&quot;o&quot;,&quot;p&quot;,&quot;q&quot;,&quot;r&quot;,&quot;s&quot;,&quot;t&quot;, &quot;u&quot;,&quot;v&quot;,&quot;w&quot;,&quot;x&quot;,&quot;y&quot;,&quot;z&quot;,&quot;next&quot;) match(sentence2,alphabet_S) </code></pre>
[ { "answer_id": 74129233, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 2, "selected": true, "text": "list" }, { "answer_id": 74129346, "author": "Andre Wildberg", "author_id": 9462095, "author_profile...
2022/10/19
[ "https://Stackoverflow.com/questions/74129188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20275071/" ]
74,129,189
<p>I have a text file that is similar to this:</p> <pre><code>line 1: a b c, line 2: d e f, line 3: g h i </code></pre> <p>I need to write a python code that reads the file and print the first value of each line and multiply the last two to something like this:</p> <pre><code>line 1: a, bc line 2: d, ef line 3: g, hi </code></pre> <p>Please help anyone</p> <p>EDIT: a, d and g are non numeric values, b, c, e, f, h and i are numeric values</p>
[ { "answer_id": 74129350, "author": "BokiX", "author_id": 16843389, "author_profile": "https://Stackoverflow.com/users/16843389", "pm_score": -1, "selected": true, "text": "with open('input.txt', 'r') as file:\n numbers = []\n for line in file.readlines()[1:]:\n for number in lin...
2022/10/19
[ "https://Stackoverflow.com/questions/74129189", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20072086/" ]
74,129,221
<p>Im trying to run a python script using Outlook Vba. When I run the below code. A python icon appears in the taskbar for a second and disappears. When in fact it should open a dialogue box and prompt me to enter folder name. After which it should run the rest of the script as usual.</p> <p>Please help me run this script from outlook as I regularly do by double clicking the .py file.</p> <pre><code>Sub runpythonscript() Dim Path As String Path = &quot;python C:\Doc Management\Exstream_Reconciliation.py&quot; Shell(Path) End Sub </code></pre>
[ { "answer_id": 74129350, "author": "BokiX", "author_id": 16843389, "author_profile": "https://Stackoverflow.com/users/16843389", "pm_score": -1, "selected": true, "text": "with open('input.txt', 'r') as file:\n numbers = []\n for line in file.readlines()[1:]:\n for number in lin...
2022/10/19
[ "https://Stackoverflow.com/questions/74129221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17762058/" ]
74,129,230
<p>I'm totally new and learning Python+MySQL, And I have an issue with passing over 10 to %s</p> <pre><code>@app.route('/usr/&lt;id&gt;', methods=['GET']) def selected_logs(id): response_object = {'status': 'success'} cur = mysql.connection.cursor() cur.execute(''' SELECT usr.id, usr.corp_id, date_format (log.date, '%%m/%%d/%%Y') AS date FROM (usr INNER JOIN corps ON corps.id = usr.corp_id) WHERE usr.corp_id = %s ORDER BY usr.id DESC; ''', (id)) results = cur.fetchall() response_object['usr'] = results return jsonify(response_object) </code></pre> <p>In the URL http://localhost:5000/usr/9 works, but start to 10... won't work, please help me.</p> <pre><code>MySQLdb._exceptions.ProgrammingError: not all arguments converted during bytes formatting </code></pre> <p>THANK YOU SO MUCH</p>
[ { "answer_id": 74129980, "author": "Michael Ruth", "author_id": 4583620, "author_profile": "https://Stackoverflow.com/users/4583620", "pm_score": 3, "selected": true, "text": "Execute()" } ]
2022/10/19
[ "https://Stackoverflow.com/questions/74129230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19155766/" ]
74,129,258
<p>I'm developing a pipeline in Data Fusion that must read a JSON from Google Cloud Storage, transform some fields (erase or rename some of them) and then send the info into a BigQuery table.</p> <p>I'm doing the transformation in Wrangle. My problem is that some columns have no value in the input JSON document, and I cannot include these fields in the output schema. I have tried using the &quot;Keep column&quot; directive unsuccessfully.</p> <p>Also, these empty columns have no type, although it is defined in the json where the schema is defined when importing the input file.</p> <p>How should I treat the empty fields so that they appear in the output schema?</p> <p>Thanks and regards</p>
[ { "answer_id": 74129980, "author": "Michael Ruth", "author_id": 4583620, "author_profile": "https://Stackoverflow.com/users/4583620", "pm_score": 3, "selected": true, "text": "Execute()" } ]
2022/10/19
[ "https://Stackoverflow.com/questions/74129258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20183641/" ]
74,129,261
<p>When trying to debug Python nodes, I can't get Vscode-ROS to attach to a running node.</p> <p>I did what is suggested here: <a href="https://github.com/ms-iot/vscode-ros/blob/master/doc/debug-support.md" rel="nofollow noreferrer">https://github.com/ms-iot/vscode-ros/blob/master/doc/debug-support.md</a></p> <ul> <li>Start roscore in one terminal</li> <li>Start my node in another terminal via <code>rosrun beginner_tutorials talker.py</code> (just the publisher from this tutorial: <a href="http://wiki.ros.org/ROS/Tutorials/ExaminingPublisherSubscriber" rel="nofollow noreferrer">http://wiki.ros.org/ROS/Tutorials/ExaminingPublisherSubscriber</a>)</li> <li>Select a break point in the file I want to debug</li> <li>Create a simple launch configuration in VSCode and run it</li> </ul> <p>Then, nothing more happens. I've also set the <code>-DCMAKE_BUILD_TYPE=Debug</code> flag when building with catkin_make, but I assume that's just for C++?</p>
[ { "answer_id": 74137667, "author": "elanius", "author_id": 1719921, "author_profile": "https://Stackoverflow.com/users/1719921", "pm_score": 0, "selected": false, "text": " {\n \"name\": \"ROS: some_node\",\n \"type\": \"ros\",\n \"request\": \"launch\",\n ...
2022/10/19
[ "https://Stackoverflow.com/questions/74129261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/995784/" ]
74,129,309
<p>The input file type should be beside the 1 column like this 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-html lang-html prettyprint-override"><code>&lt;input type="" placeholder="write a message"&gt; &lt;input type="file" id="myfile" name="myfile"&gt;</code></pre> </div> </div> </p> <p><a href="https://i.stack.imgur.com/PBoto.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PBoto.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74137667, "author": "elanius", "author_id": 1719921, "author_profile": "https://Stackoverflow.com/users/1719921", "pm_score": 0, "selected": false, "text": " {\n \"name\": \"ROS: some_node\",\n \"type\": \"ros\",\n \"request\": \"launch\",\n ...
2022/10/19
[ "https://Stackoverflow.com/questions/74129309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20262711/" ]
74,129,328
<p>I'm trying to display Categories from a port (http://localhost:5000), my database in MangoDB and it showed up successfully in my app Now when I am trying to display the products for each category separately So it does not work. I tried the same way but the message i receive is &quot;No routes match this location&quot;. Can one help me to solve this.</p>
[ { "answer_id": 74137667, "author": "elanius", "author_id": 1719921, "author_profile": "https://Stackoverflow.com/users/1719921", "pm_score": 0, "selected": false, "text": " {\n \"name\": \"ROS: some_node\",\n \"type\": \"ros\",\n \"request\": \"launch\",\n ...
2022/10/19
[ "https://Stackoverflow.com/questions/74129328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19121767/" ]
74,129,355
<p>DATA BELOW</p> <pre><code>library(fixest) analysis&lt;-tibble(off_race = c(&quot;hispanic&quot;, &quot;hispanic&quot;, &quot;white&quot;,&quot;white&quot;, &quot;hispanic&quot;, &quot;white&quot;, &quot;hispanic&quot;, &quot;white&quot;, &quot;white&quot;, &quot;white&quot;,&quot;hispanic&quot;), any_black_uof = c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), any_black_arrest = c(TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), prop_white_scale = c(0.866619646027524, -1.14647499712298, 1.33793539994219, 0.593565300512359, -0.712819809606193, 0.3473585867755, -1.37025501425243, 1.16596624239715, 0.104521426674564, 0.104521426674564, -1.53728347122581), prop_hisp_scale=c(-0.347382203637802, 1.54966785579018, -0.833021026477168, -0.211470492567308, 1.48353691981021, 0.421968013870802, 2.63739845069911, -0.61002505397242, 0.66674880256898,0.66674880256898, 2.93190487813111)) </code></pre> <p>I would like to run a series of regressions that iterate over these vectors</p> <pre><code>officer_race = c(&quot;black&quot;, &quot;white&quot;, &quot;hispanic&quot;) primary_ind&lt;-c(&quot;prop_white_scale&quot;,&quot;prop_hisp_scale&quot;,&quot;prop_black_scale&quot;) outcome&lt;-c(&quot;any_black_uof&quot;,&quot;any_white_uof&quot;,&quot;any_hisp_uof&quot;,&quot;any_black_arrest&quot;,&quot;any_white_arrest&quot;,&quot;any_hisp_arrest&quot;,&quot;any_black_stop&quot;,&quot;any_white_stop&quot;,&quot;any_hisp_stop&quot;) </code></pre> <p>Also of note, I would like to use the fixest package where the regressions would look like this</p> <pre><code>feols(any_black_uof~ prop_white_scale,data=analysis[analysis$off_race ==&quot;black&quot;]) feols(any_black_uof~ prop_white_scale,data=analysis[analysis$off_race ==&quot;white&quot;]) feols(any_black_uof~ prop_white_scale,data=analysis[analysis$off_race==&quot;hispanic&quot;]) feols(any_black_uof~ prop_hisp_scale,data=analysis[analysis$off_race ==&quot;black&quot;]) feols(any_black_uof~ prop_hisp_scale,data=analysis[analysis$off_race ==&quot;white&quot;]) </code></pre> <p>etc. iterating through all possible combinations and creating a list of fixest regression objects.</p> <p>I tried this and it works with the lm() function. Yet, it breaks with feols.</p> <pre><code> result &lt;- lapply(split(analysis, analysis$off_race), function(x) { sapply(primary_ind2, function(y) { sapply(outcome2, function(z) { feols(paste(y, z, sep = &quot;~&quot;), x) }, simplify = FALSE) }, simplify = FALSE) }) </code></pre>
[ { "answer_id": 74129492, "author": "TimTeaFan", "author_id": 9349302, "author_profile": "https://Stackoverflow.com/users/9349302", "pm_score": 1, "selected": false, "text": "lm()" }, { "answer_id": 74129556, "author": "akrun", "author_id": 3732271, "author_profile": "...
2022/10/19
[ "https://Stackoverflow.com/questions/74129355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16365963/" ]
74,129,357
<p>I'm trying to make some code, this part doesn't work. Because it keeps saying my list index is out of range and it looks like items from my list are disappearing. If i take a look at the code I can't find why it's not working. Anyone any idea why this is not working?</p> <pre><code>ts = [[4, 5], [9, 6], [2, 10]] repeats = 3 for i in range(repeats): cts = ts t = ts[i] cts.remove(t) print(ts, t) ### [[6, 9], [2, 10]] [4, 5] ### [[6, 9]] [2, 10] ### ### Exception has occurred: IndexError ### list index out of range ### ### File &quot;MyFile.py&quot;, line 12, in &lt;module&gt; ### t = ts[i] </code></pre>
[ { "answer_id": 74129430, "author": "BokiX", "author_id": 16843389, "author_profile": "https://Stackoverflow.com/users/16843389", "pm_score": -1, "selected": true, "text": "cts = ts" }, { "answer_id": 74130137, "author": "Rahul K P", "author_id": 4407666, "author_profi...
2022/10/19
[ "https://Stackoverflow.com/questions/74129357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19551554/" ]
74,129,371
<p>The title is pretty much self explanatory. Here is my situation:</p> <pre class="lang-cpp prettyprint-override"><code>#include &lt;type_traits&gt; class C1{ enum{ c1 = 3 } } class C2{ enum{ c2 = 10 } } template&lt;class C&gt; class C3{ void do_this(); void do_that(); void foo(){ if constexpr(std::is_enum&lt;C::c1&gt;::value){ do_this(); } if constexpr(std::is_enum&lt;C::c2&gt;::value){ do_that(); } } } </code></pre> <p>If I'd try to compile this I'd get the error</p> <pre><code>error: type/value mismatch at argument 1 in template parameter list for ‘template&lt;class _Tp&gt; struct std::is_enum’ note: expected a type, got ‘typename C::c1’ error: type/value mismatch at argument 1 in template parameter list for ‘template&lt;class _Tp&gt; struct std::is_enum’ note: expected a type, got ‘typename C::c2’ </code></pre> <p>So hence my question: is it possible to use <code>std::is_enum</code> with unnamed <code>enum</code>s?</p>
[ { "answer_id": 74129648, "author": "Jason Liam", "author_id": 12002570, "author_profile": "https://Stackoverflow.com/users/12002570", "pm_score": 3, "selected": true, "text": "decltype" }, { "answer_id": 74129709, "author": "Ayxan Haqverdili", "author_id": 10147399, "...
2022/10/19
[ "https://Stackoverflow.com/questions/74129371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2407119/" ]
74,129,383
<p>I am doing the LeetCode challenge 'Add Two Numbers'</p> <blockquote> <p>You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p> </blockquote> <blockquote> <p>You may assume the two numbers do not contain any leading zero, except the number 0 itself.</p> </blockquote> <p>I was writing a solution, but observed some strange behavior which I am not able to comprehend. (I think the issue is in my for loop).</p> <pre><code>/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int val) { this.val = val; } * ListNode(int val, ListNode next) { this.val = val; this.next = next; } * } */ class Solution { public ListNode addTwoNumbers(ListNode l1, ListNode l2) { l1= reverseList(l1); l2= reverseList(l2); String str1 = returnListAsString(l1); String str2 = returnListAsString(l2); Integer int1 = Integer.valueOf(str1.toString()); Integer int2 = Integer.valueOf(str2.toString()); Integer sum = int1 + int2; System.out.println(&quot;sum..&quot; + sum); char[] ch = String.valueOf(sum).toCharArray(); ListNode result = l1; for (int i=0; i&lt;ch.length; i++) { System.out.println(&quot;test..&quot; + ch[i]); result.val = ch[i]; System.out.println(&quot;test2..&quot;+ result.val); result = result.next; } return result; } public ListNode reverseList(ListNode l1) { ListNode previous = null; ListNode curr = l1; ListNode next = null; while (curr != null) { next = curr.next; curr.next = previous; previous = curr; curr = next; } l1 = previous; return l1; } public String returnListAsString(ListNode l1) { StringBuilder str1 = new StringBuilder(); while (l1 !=null) { str1.append(l1.val); l1 = l1.next; } return str1.toString(); } } </code></pre> <p>Here is my input</p> <blockquote> <p>[2,4,3] [5,6,4]</p> </blockquote> <p>stdout</p> <blockquote> <p>sum..807 test..8 test2..56 test..0 test2..48 test..7 test2..55</p> </blockquote> <p>output</p> <blockquote> <p>[]</p> </blockquote> <p>I think the issue is inside my for loop. My question is, why does test and test2 not equal, and how can I have an output that at least says [8,0,7]?</p>
[ { "answer_id": 74129898, "author": "cyberbrain", "author_id": 2846138, "author_profile": "https://Stackoverflow.com/users/2846138", "pm_score": 1, "selected": false, "text": "'0'" }, { "answer_id": 74130284, "author": "Abra", "author_id": 2164365, "author_profile": "h...
2022/10/19
[ "https://Stackoverflow.com/questions/74129383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7929423/" ]
74,129,392
<p>I put together the following Bash function (in my <code>.bashrc</code>) to open a &quot;random&quot; image from a given folder, one at a time until the user types <kbd>N</kbd>, after which it exits. The script works fine aside from the actual randomness of the images generated - in a quick test of 10 runs, only 4 images are unique.</p> <p>Is this simply unavoidable due to the limited number of images in the directory (20), or is there an alternative to the <code>shuf</code> command that will yield more random results?</p> <p>If it is unavoidable, what's the best way to adapt the function to avoid repeats (i.e. discard images that have already been selected)?</p> <pre><code>function generate_image() { while true; do command cd &quot;D:\Users\Hashim\Pictures\Data&quot; &amp;&amp; image=&quot;$(find . -type f -exec file --mime-type {} \+ | awk -F: '{if ($2 ~/image\//) print $1}' | shuf -n1)&quot; &amp;&amp; echo &quot;Opening $image&quot; &amp;&amp; cygstart &quot;$image&quot; read -p &quot;Open another random image? [Y/n]&quot;$'\n' -n 1 -r echo if [[ $REPLY =~ ^[Nn]$ ]] then exit fi done } </code></pre>
[ { "answer_id": 74129622, "author": "Charles Duffy", "author_id": 14122, "author_profile": "https://Stackoverflow.com/users/14122", "pm_score": 3, "selected": true, "text": "shuf" }, { "answer_id": 74130342, "author": "RARE Kpop Manifesto", "author_id": 14672114, "auth...
2022/10/19
[ "https://Stackoverflow.com/questions/74129392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1191147/" ]
74,129,401
<p>I have a table with a string column like this:</p> <pre><code>------------------------------------------------ | Column | ------------------------------------------------ | #Extract this# and #this too# do not extract | ------------------------------------------------ | Leave this and #get this out# | ------------------------------------------------ </code></pre> <p>I want to extract everything from first # occurrence and the last # occurrence like this:</p> <pre><code>-------------------------------- | Expected Output | -------------------------------- | #Extract this and #this too# | -------------------------------- | #get this out# | -------------------------------- </code></pre> <p>I have tried <code>regexp_substr(column, '#[^.]#', 1, regexp_count(column, '#'))</code> but it is giving me empty string.</p> <p>Does anyone know how to fix this?</p> <p>Thanks in advance!</p>
[ { "answer_id": 74130153, "author": "trillion", "author_id": 12513693, "author_profile": "https://Stackoverflow.com/users/12513693", "pm_score": 2, "selected": false, "text": "select REGEXP_SUBSTR(column, '#.*#') as pattern from [table]\n" }, { "answer_id": 74130552, "author":...
2022/10/19
[ "https://Stackoverflow.com/questions/74129401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8600811/" ]
74,129,468
<p>I need to wrote a code on an older version of the .net Framework, namely 4.5.2. I ran into a problem, the ajax code sends an empty request to the controller.</p> <p>Here is the form and I need to check user Full Name on unique:</p> <pre><code>&lt;div class=&quot;register-card&quot;&gt; &lt;h1&gt;Register the new user&lt;/h1&gt; @using (Html.BeginForm(&quot;CreateUserAsync&quot;, &quot;Home&quot;, FormMethod.Post)) { &lt;div&gt; @Html.Label(&quot;FullName&quot;, &quot;Enter your full name&quot;) &lt;input type=&quot;text&quot; id=&quot;FullName&quot; name=&quot;FullName&quot; pattern=&quot;^(\w\w+)\s(\w+)\s(\w+)$&quot; onblur=&quot;CheckAvailability()&quot; required /&gt; &lt;span id=&quot;message&quot; onclick=&quot;ClearMessage()&quot;&gt;&lt;/span&gt; &lt;/div&gt; &lt;p&gt;&lt;input type=&quot;submit&quot; value=&quot;Send&quot; id=&quot;submit&quot; /&gt;&lt;/p&gt; } &lt;/div&gt; </code></pre> <p>Here is my js function to checking Full Name:</p> <pre><code>function CheckAvailability() { var data = $(&quot;#FullName&quot;).val(); var param = data; $.ajax({ type: &quot;POST&quot;, url: &quot;/Home/CheckFullNameAsync&quot;, contentType: &quot;application/x-www-form-urlencoded; charset=utf-8&quot;, dataType: &quot;String&quot;, data: JSON.stringify(param), success: function (response) { var message = $(&quot;#message&quot;); if (response) { message.css(&quot;color&quot;, &quot;red&quot;); message.html(&quot;Full name is already exist&quot;); $('#submit').attr('disabled', 'disabled'); } else { console.log(JSON.stringify(param)); message.css(&quot;color&quot;, &quot;green&quot;); message.html(&quot;Full name is available&quot;); $('#submit').removeAttr('disabled'); } } }); }; function ClearMessage() { $(&quot;#message&quot;).html(&quot;&quot;); }; </code></pre> <p>Js function pass the FullName to next controller:</p> <pre><code>[HttpPost] public async Task&lt;JsonResult&gt; CheckFullNameAsync([FromBody]string fullName) { var isValid = await _service.IsUserExistAsync(fullName); return Json(isValid); } </code></pre> <p>But the controller receives null. I think the problem is in the Js function, but I can figure out what I'm doing wrong.</p>
[ { "answer_id": 74129530, "author": "David", "author_id": 328193, "author_profile": "https://Stackoverflow.com/users/328193", "pm_score": 2, "selected": true, "text": "dataType: \"String\"" }, { "answer_id": 74129644, "author": "Pradeep Kumar", "author_id": 18704952, "...
2022/10/19
[ "https://Stackoverflow.com/questions/74129468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19147168/" ]
74,129,490
<p>In YouTube's Data API, data are returned in fields, and fields are grouped in parts. In the YouTube documentation, <em><a href="https://developers.google.com/youtube/v3/getting-started" rel="nofollow noreferrer">YouTube Data API Overview</a></em>, the section, <em><a href="https://developers.google.com/youtube/v3/getting-started#part" rel="nofollow noreferrer">How to use the part parameter</a></em>, gives a list of the parts available for videos:</p> <ul> <li>snippet, contentDetails, fileDetails, player, processingDetails, recordingDetails, statistics, status, suggestions, topicDetails</li> </ul> <p>There are two things I have not found in the documentation:</p> <ul> <li>The list of parts available for channels and playlists.</li> <li>The list of fields available in each part for videos, channels, and playlists.</li> </ul> <p>Where can I get that information?</p> <p>Also, some fields are available to the public, while others are only available to the owner of the subject resource. So in the list of fields, I need to know which I can query and which are restricted.</p>
[ { "answer_id": 74129491, "author": "NewSites", "author_id": 5803910, "author_profile": "https://Stackoverflow.com/users/5803910", "pm_score": -1, "selected": false, "text": "https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,fileDetails,player,processingDetails,reco...
2022/10/19
[ "https://Stackoverflow.com/questions/74129490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5803910/" ]
74,129,543
<p>This is a web scraping project in C# and responses are the https responses we get but my project works so slow, so I was thinking to change those <code>foreach</code> calls to <code>parallel.foreach</code>.</p> <pre><code>var index = 0; foreach (var response in responses) { if (index == 0) { ParseHtmlVatan(response); } if (index == 1) { ParseHtmlTrendyol(response); } if (index == 2) { ParseHtmln11(response); } index++; } </code></pre>
[ { "answer_id": 74129491, "author": "NewSites", "author_id": 5803910, "author_profile": "https://Stackoverflow.com/users/5803910", "pm_score": -1, "selected": false, "text": "https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,fileDetails,player,processingDetails,reco...
2022/10/19
[ "https://Stackoverflow.com/questions/74129543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20285090/" ]
74,129,553
<p>I've been trying to generate a OpenMP enabled precompiled header (PCH) with <code>cppyy</code> and have been failing so far. Instead of doing so manually each time <a href="https://stackoverflow.com/questions/73816713/cppyy-openmp-error-nullptr-result-where-temporary-expected">as outlined in this answer</a>, I'm looking for an automated solution.</p> <p>So far, the broad method is to use <code>os.environ</code> to export environmental variables - but this seems to fail somewhat inconsistently, resulting in single-threaded code each time.</p> <p>In particular, there doesn't seem to be any output from <code>cppyy_backend.loader.ensure_precompiled_header</code> all the time. Even if there is output, it has no effect on whether the C++ code runs parallely or not.</p> <p>The relevant part of the code below:</p> <pre><code>import cppyy_backend.loader as l os.environ['EXTRA_CLING_ARGS'] = '-fopenmp -O2 -g' l.set_cling_compile_options(True) current_folder = os.path.split(os.path.abspath(__file__))[0] pch_folder = os.path.join(current_folder, 'cling_pch/') if os.path.exists(pch_folder): pass else: os.mkdir(pch_folder) l.ensure_precompiled_header(pch_folder) # find PCH file: pch_path = glob.glob(pch_folder+'/allDict*') if len(pch_path)&gt;0: os.environ['CLING_STANDARD_PCH'] = pch_path[0] else: raise ValueError('Unable to find a precompiled header...') </code></pre> <p>System specs:</p> <ul> <li>Ubuntu 18.04.2 LTS</li> <li>python 3.9.0</li> <li>cppyy 2.4.0</li> <li>cppyy_backend 6.27.0</li> </ul> <p><em>EDIT: I made sure the custom PCH folder was first empty while checking to see if the custom PCH file was being created.</em></p>
[ { "answer_id": 74132349, "author": "Wim Lavrijsen", "author_id": 9448377, "author_profile": "https://Stackoverflow.com/users/9448377", "pm_score": 2, "selected": true, "text": "CLING_STANDARD_PCH" }, { "answer_id": 74148651, "author": "Thejasvi", "author_id": 4955732, ...
2022/10/19
[ "https://Stackoverflow.com/questions/74129553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4955732/" ]
74,129,563
<p>I have a macOS app that I'm creating in Swift and I have integrated an external HID device that has a number of controls on it. The HID part is done where I am receiving all of the hid commands from the device and I am trying to create a mapping file where I can maintain the HID key mappings in a separate swift file. All I want in that file is the data and what I want to do is this;</p> <ul> <li>raw hid data is received from HID device (In ViewController)</li> <li>Lookup the function name assigned to this hid data (In separate file)</li> <li>Run the function that is mapped to that key. (Function located in the main ViewController)</li> </ul> <p>So far I have the external swift file setup with all of the mapping and that all works fine but my issue is when I try to call the looked up function in the ViewController, it says the function can't be found in the scope.</p> <p>Initially I thought I would use a delegate but the external file isn't a viewcontroller, just a separate swift file so I don't know if I can do that?.</p> <p>I've tried searching but everything I've found is calling a function from another ViewController which I'm not. It's very possible I'm not using the best approach and my goal is to just keep all of the mapping in a separate file as there is a lot and it woudl be easier to maintain.</p> <p>Any suggestions are appreciated.</p>
[ { "answer_id": 74129590, "author": "user20278560", "author_id": 20278560, "author_profile": "https://Stackoverflow.com/users/20278560", "pm_score": 0, "selected": false, "text": "@IBOutlet var uiViewController: UIViewController!\n" }, { "answer_id": 74141965, "author": "mani"...
2022/10/19
[ "https://Stackoverflow.com/questions/74129563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13086219/" ]
74,129,567
<p>I'm building a Microsoft Teams app with the botbuilder in typescript. Everything is working fine except the UI is not matching exactly what I want. Im using an adaptive card to render my responses to the user and typically the adaptive card has a top border (seen below is black) but mine doesnt have it and i'm trying to figure out how i can make it work.</p> <p>I want my card to have the black border on top as shown here for in github's bot: <a href="https://i.stack.imgur.com/S3KiP.png" rel="nofollow noreferrer">See image</a></p> <p>This is what mine currently shows: <a href="https://i.stack.imgur.com/Vj3bI.png" rel="nofollow noreferrer">see image</a></p> <p>below is my code to render the card. What i'm i doing wrong?</p> <pre><code> await context.sendActivity({ attachments: [ CardFactory.adaptiveCard({ &quot;$schema&quot;: &quot;http://adaptivecards.io/schemas/adaptive-card.json&quot;, &quot;version&quot;: &quot;1.0&quot;, &quot;msteams&quot;: { &quot;width&quot;: &quot;Full&quot; }, &quot;body&quot;: [ { &quot;type&quot;: &quot;TextBlock&quot;, &quot;text&quot;: &quot;My card doesnt have the border.&quot;, &quot;wrap&quot;: true } ] }) ] }); </code></pre>
[ { "answer_id": 74129590, "author": "user20278560", "author_id": 20278560, "author_profile": "https://Stackoverflow.com/users/20278560", "pm_score": 0, "selected": false, "text": "@IBOutlet var uiViewController: UIViewController!\n" }, { "answer_id": 74141965, "author": "mani"...
2022/10/19
[ "https://Stackoverflow.com/questions/74129567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20285012/" ]
74,129,579
<p>I cannot figure out what kind of python sytanx is used. I hope someone could tell me.</p> <pre class="lang-py prettyprint-override"><code>from pathlib import Path import matplotlib.pyplot as plt import numpy as np import torch import torchvision.transforms as T from torchvision.io import read_image plt.rcParams[&quot;savefig.bbox&quot;] = 'tight' torch.manual_seed(1) def show(imgs): fix, axs = plt.subplots(ncols=len(imgs), squeeze=False) for i, img in enumerate(imgs): img = T.ToPILImage()(img.to('cpu')) axs[0, i].imshow(np.asarray(img)) axs[0, i].set(xticklabels=[], yticklabels=[], xticks=[], yticks=[]) </code></pre> <p>The part I'm wondering is below.</p> <pre class="lang-py prettyprint-override"><code> img = T.ToPILImage()(img.to('cpu')) </code></pre> <p><code>ToPILImage()</code> class instantiating with an image object, not as its argument but outside the brackets.</p> <p>The code is from this page.<br /> <a href="https://pytorch.org/vision/stable/auto_examples/plot_scripted_tensor_transforms.html#sphx-glr-auto-examples-plot-scripted-tensor-transforms-py" rel="nofollow noreferrer">https://pytorch.org/vision/stable/auto_examples/plot_scripted_tensor_transforms.html#sphx-glr-auto-examples-plot-scripted-tensor-transforms-py</a></p> <p>The source code of <code>ToPILImage()</code> is from the page link below.<br /> <a href="https://pytorch.org/vision/stable/_modules/torchvision/transforms/transforms.html#ToPILImage" rel="nofollow noreferrer">https://pytorch.org/vision/stable/_modules/torchvision/transforms/transforms.html#ToPILImage</a></p> <p>On that page, three special methods (<code>__init__</code>, <code>__call__</code>, <code>__repr__</code>) for the class are defined only.</p> <pre class="lang-py prettyprint-override"><code>class ToPILImage: &quot;&quot;&quot;Convert a tensor or an ndarray to PIL Image. This transform does not support torchscript. Converts a torch.*Tensor of shape C x H x W or a numpy ndarray of shape H x W x C to a PIL Image while preserving the value range. Args: mode (`PIL.Image mode`_): color space and pixel depth of input data (optional). If ``mode`` is ``None`` (default) there are some assumptions made about the input data: - If the input has 4 channels, the ``mode`` is assumed to be ``RGBA``. - If the input has 3 channels, the ``mode`` is assumed to be ``RGB``. - If the input has 2 channels, the ``mode`` is assumed to be ``LA``. - If the input has 1 channel, the ``mode`` is determined by the data type (i.e ``int``, ``float``, ``short``). .. _PIL.Image mode: https://pillow.readthedocs.io/en/latest/handbook/concepts.html#concept-modes &quot;&quot;&quot; def __init__(self, mode=None): _log_api_usage_once(self) self.mode = mode def __call__(self, pic): &quot;&quot;&quot; Args: pic (Tensor or numpy.ndarray): Image to be converted to PIL Image. Returns: PIL Image: Image converted to PIL Image. &quot;&quot;&quot; return F.to_pil_image(pic, self.mode) def __repr__(self) -&gt; str: format_string = self.__class__.__name__ + &quot;(&quot; if self.mode is not None: format_string += f&quot;mode={self.mode}&quot; format_string += &quot;)&quot; return format_string </code></pre> <p>My guess is</p> <ul> <li>the <code>__init__</code> is called in that process.</li> <li>object cast is in the process.</li> </ul> <p>But I don't know how those two are linked in that call ?</p>
[ { "answer_id": 74129590, "author": "user20278560", "author_id": 20278560, "author_profile": "https://Stackoverflow.com/users/20278560", "pm_score": 0, "selected": false, "text": "@IBOutlet var uiViewController: UIViewController!\n" }, { "answer_id": 74141965, "author": "mani"...
2022/10/19
[ "https://Stackoverflow.com/questions/74129579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6753208/" ]
74,129,626
<p>I'm trying to implement a sliver app bar in my flutter app but it just won't respond at all</p> <pre class="lang-dart prettyprint-override"><code> Widget build(BuildContext context) { return const MaterialApp( home: Scaffold( body: CustomScrollView( slivers: [ SliverAppBar( expandedHeight: 200, flexibleSpace: FlexibleSpaceBar( title: Text(&quot;title&quot;), ), ), ], ), )); } } </code></pre>
[ { "answer_id": 74129659, "author": "user20278560", "author_id": 20278560, "author_profile": "https://Stackoverflow.com/users/20278560", "pm_score": 0, "selected": false, "text": "Widget build(BuildContext context) { return const MaterialApp( home: Scaffold( body: CustomScrollView(\n\n ...
2022/10/19
[ "https://Stackoverflow.com/questions/74129626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14803153/" ]
74,129,697
<p>I'm relatively new to React and JavaScript and I'm building a website but I'm having a bit of an issue with passing Data via components from child to parent.</p> <p>So:</p> <p>I have my App.js script which is used as a router with react-router-dom, but I would like to store a boolean value using the useState hook. This boolean value that I would like stored should be passed on from a component called Login. I have the script setup to pass that data however the boolean is only stored as long as the Login COmponent page is active and when it is not rendered the boolean store by the useState hook in the App.js script just goes to 'undefined'. I'm assuming that this is happening because the app.js page constantly re-loads and re-renders, so how could I store that value even when the login page is not being rendered?</p> <p>This is the code setup to pass that data:</p> <p>app.js</p> <pre><code>const [authValue, setAuthValue] = useState(false); const changeValue = (value) =&gt; { setAuthValue(value) } And where the Login is called: &lt;Route path='/signin' element={&lt;Login changeValue={changeValue}value={authValue} /&gt;} /&gt; </code></pre> <p>Login.jsx:</p> <pre><code>const Login = ({changeValue, value}) =&gt; { const [isValid, setIsValid] = useState(true) changeValue(isValid) } </code></pre>
[ { "answer_id": 74129659, "author": "user20278560", "author_id": 20278560, "author_profile": "https://Stackoverflow.com/users/20278560", "pm_score": 0, "selected": false, "text": "Widget build(BuildContext context) { return const MaterialApp( home: Scaffold( body: CustomScrollView(\n\n ...
2022/10/19
[ "https://Stackoverflow.com/questions/74129697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14566133/" ]
74,129,717
<p>How can I read RPG source code into a variable in another RPG program? This is so I can analyze the code to edit it.</p>
[ { "answer_id": 74147220, "author": "Dam", "author_id": 939484, "author_profile": "https://Stackoverflow.com/users/939484", "pm_score": 1, "selected": false, "text": "CREATE ALIAS lib/youralias FOR lib/filesource (sourcemember);\n" } ]
2022/10/19
[ "https://Stackoverflow.com/questions/74129717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20285236/" ]
74,129,718
<p>What happens is: I create a bunch of inputs with jQuery, they can have different IDs. In them, I need to put an alert on a certain value when <code>onChange()</code> happens, how can I do that? A shallow example of this is the code below that I'm trying.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>let exemploIds = ['id1', 'id2', 'id3', 'id4', 'id5', 'id6']; exemploIds.forEach(function(point) { $('#inputs').append(` &lt;input id="${point}" type="number"&gt; `) }); exemploIds.forEach(function(point) { $('#' + point).on('change', function() { if ($(this).val() &gt; 100) { alert('Very high!') } }); });</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"&gt;&lt;/script&gt; &lt;div id="inputs"&gt;&lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74147220, "author": "Dam", "author_id": 939484, "author_profile": "https://Stackoverflow.com/users/939484", "pm_score": 1, "selected": false, "text": "CREATE ALIAS lib/youralias FOR lib/filesource (sourcemember);\n" } ]
2022/10/19
[ "https://Stackoverflow.com/questions/74129718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20061059/" ]
74,129,731
<p>So im trying to make a color guessing game So i created a function that generates a color and returns it, which works fine But since i have 3 buttons with #hex code on them 1 button has to be a correct answer and correct #hex has to be displayed in a color box</p> <p>So im trying to put 3 #hex codes in each button and choose randomly which #hex code is the correct one and display it in HTML</p> <p>i know the code is very bad but i still got a long way to go...</p> <pre><code>function randomColor(){ let randomColor = Math.floor(Math.random()*16777215).toString(16); return randomColor } function arrayOfColors(){ let randColorArr = [] } function generateColors(){ colorBox.style.backgroundColor = `#${correctColor}` btn.forEach(button =&gt; button.innerHTML = `#${randomColor()}`) } generateColors() </code></pre>
[ { "answer_id": 74129950, "author": "GrafiCode", "author_id": 5334486, "author_profile": "https://Stackoverflow.com/users/5334486", "pm_score": 1, "selected": false, "text": "arrayOfColors" }, { "answer_id": 74130016, "author": "Haim Abeles", "author_id": 15298697, "au...
2022/10/19
[ "https://Stackoverflow.com/questions/74129731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15757167/" ]
74,129,734
<p>So I want something like:</p> <p>module0.pl</p> <pre><code>sub fun { print &quot;fun $_[0] from 0\n&quot; } 1 </code></pre> <p>module1.pl</p> <pre><code>sub fun { print &quot;fun $_[0] from 1\n&quot; } 1 </code></pre> <p>main.pl</p> <pre><code>BEGIN{push @INC, &quot;.&quot;}; require &quot;module0.pl&quot;; require &quot;module1.pl&quot;; fun(&quot;test&quot;) </code></pre> <p>Which will print (in any order - I don't care) :</p> <pre><code>fun test from 0 fun test from 1 </code></pre> <p>Is it possible - and what is the most elegant syntax to do it?</p>
[ { "answer_id": 74129967, "author": "zdim", "author_id": 4653379, "author_profile": "https://Stackoverflow.com/users/4653379", "pm_score": 3, "selected": true, "text": "package Pack1;\n\nuse warnings;\nuse strict;\nuse feature 'say';\n\nsub fun { say \"fun $_[0] from \", __PACKAGE__ }\n\n...
2022/10/19
[ "https://Stackoverflow.com/questions/74129734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4031604/" ]
74,129,800
<p>I'm a newbie Python programmer learning how to design web scrapers. The tutorial I'm following used the code I've posted below and I'm trying to follow it. However, the code runs without displaying any info, plus I get two problem messages in VSCode telling me that:</p> <ol> <li>Missing timeout argument for method 'requests.get' can cause your program to hang indefinitely <em>pylint (missing-timeout) [Ln 4, Col 12]</em></li> </ol> <p>2)Missing module docstring <em>pylint(missing-module-docstring)[Ln 1,Col 1]</em></p> <pre><code>import requests from bs4 import BeautifulSoup response = requests.get(&quot;https://stackoverflow.com/questions&quot;) soup = BeautifulSoup(response.text, &quot;html.parser&quot;) questions = soup.select(&quot;.s-post-summary js-post-summary&quot;) for question in questions: print(question.select_one(&quot;.s-link&quot;).getText()) </code></pre>
[ { "answer_id": 74130030, "author": "Rahul K P", "author_id": 4407666, "author_profile": "https://Stackoverflow.com/users/4407666", "pm_score": 0, "selected": false, "text": "data-post-type-id" }, { "answer_id": 74133843, "author": "Driftr95", "author_id": 6146136, "au...
2022/10/19
[ "https://Stackoverflow.com/questions/74129800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11850237/" ]
74,129,810
<p>Below is the array of key/value pairs. I want to match the key from below array and bring its value. But my string is &quot;ss@d.com&quot; and loop through below array and bring its value.</p> <pre><code>[{&quot;nn@g.com&quot;:&quot;custom&quot;}, {&quot;ss@d.com&quot;:&quot;free&quot;}, {&quot;p23@gmail.com&quot;:&quot;free&quot;}] </code></pre> <p>I want access above array and bring value.</p>
[ { "answer_id": 74130030, "author": "Rahul K P", "author_id": 4407666, "author_profile": "https://Stackoverflow.com/users/4407666", "pm_score": 0, "selected": false, "text": "data-post-type-id" }, { "answer_id": 74133843, "author": "Driftr95", "author_id": 6146136, "au...
2022/10/19
[ "https://Stackoverflow.com/questions/74129810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20285186/" ]
74,129,827
<p>I'm trying to make real-time laravel app with beyondcode's laravel-websockets, and pusher-php-server following <a href="https://devdojo.com/bobbyiliev/how-to-use-laravel-websockets" rel="nofollow noreferrer">this</a> manual. But i didnt specify the version of the <code>pusher/pusher-php-server</code> package because it requires an outdated php version.</p> <p>I created &quot;NewTrade&quot; event implements &quot;ShouldBroadcastNow&quot; Then I triggered the event by running the following with tinker:</p> <pre><code>event (new \App\Events\NewTrade('test')) </code></pre> <p>It returns:</p> <pre><code>&gt;&gt;&gt; event (new \App\Events\NewTrade('test')); =&gt; [ null, ] </code></pre> <p>&quot;broadcastOn&quot; method of NewTrade event fired</p> <pre><code> public function broadcastOn() { $test = new \App\Models\Test(); $test-&gt;title = &quot;event&quot;; $test-&gt;save(); return new Channel('trades'); } </code></pre> <p>I see this in the database, new records are being created in the Test table. But in websockets dashboard ( <a href="http://127.0.0.1:8000/laravel-websockets" rel="nofollow noreferrer">http://127.0.0.1:8000/laravel-websockets</a> ) no info about this event.</p> <p>Help pls(( What am I doing wrong?</p>
[ { "answer_id": 74131105, "author": "Dimitrije Drakulic", "author_id": 16803819, "author_profile": "https://Stackoverflow.com/users/16803819", "pm_score": 0, "selected": false, "text": "php artisan websockets:serve\n" }, { "answer_id": 74133256, "author": "nihilsen", "auth...
2022/10/19
[ "https://Stackoverflow.com/questions/74129827", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19930788/" ]
74,129,842
<p>When I needed to allocate memory through a function, most of the time I was using double pointers (when I was experiencing C). However, now I'm learning C++ and I was wondering if there is a way to replace double pointer with a reference (&amp;) or something similar?</p> <p>See a little example bellow!</p> <pre><code>struct Matrix { int** pMatrix; int row, column; }; int allocate_memory(Matrix** ppMatrix) { // allocate memory for ppMatrix } int main() { Matrix* ptr = nullptr; allocate_memory(&amp;ptr); return 0; /* Can we do something like this? Matrix obj_matrix; allocate_memory(obj_matrix); ... */ } </code></pre> <p><strong>Edit:</strong> some people have been saying that I should avoid using direct allocation in my c++ program. The thing is I'm not allowed to use containers yet since we didn't learn them on the lesson so.. I'm basically forced to do stuff with pointers, yeah..</p>
[ { "answer_id": 74130643, "author": "bolov", "author_id": 2805305, "author_profile": "https://Stackoverflow.com/users/2805305", "pm_score": 0, "selected": false, "text": "Matrix" }, { "answer_id": 74130664, "author": "Remy Lebeau", "author_id": 65863, "author_profile":...
2022/10/19
[ "https://Stackoverflow.com/questions/74129842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15249553/" ]
74,129,856
<p>I'm completely new to VBA and I'm trying to learn a little bit about it! I am trying to create a catalog for different equipment, and it was made attributing macros to icons and creating a loop to generate the catalog based in what I'm clicking.</p> <p>The problem is, as you can see, it's attributed to different shapes and groups inside Sheet1, and because of the size of the catalog, I'm trying to create more worksheets in which I can divide the information. Furthermore, when I change the sheets in the code, it still tries to apply to the first worksheet, because of all of the templates and icons put.</p> <p>Is there a possible way in which I can assign the code in every module to a specific sheet? Or do I need to manually alter everything for every worksheet? Below follows a little part of the code to show how It's used around the modules.</p> <p>Thanks in advance!</p> <pre><code>Dim CustRow As Long, ProdCol As Long, ProdRow As Long, LastProdRow As Long, LastResultRow As Long Dim DataType As String Dim ItemShp As Shape Sub Customize_Open() With Sheet1 'limpar grupos menos amostra For Each ItemShp In .Shapes On Error Resume Next If InStr(ItemShp.Name, &quot;Picture&quot;) &lt;&gt; Empty Then ItemShp.Delete If InStr(ItemShp.Name, &quot;ItemGrp&quot;) &lt;&gt; Empty Then ItemShp.Delete On Error GoTo 0 Next ItemShp On Error Resume Next .Shapes(&quot;SampleGrp&quot;).Visible = msoCTrue .Shapes(&quot;SampleGrp&quot;).Ungroup On Error GoTo 0 'colocar em free floating For Each ItemShp In .Shapes If InStr(ItemShp.Name, &quot;Sample&quot;) &gt; 0 Then ItemShp.Placement = xlFreeFloating ItemShp.Visible = msoCTrue End If Next ItemShp .Shapes(&quot;CloseCustBtn&quot;).Visible = msoCTrue .Shapes(&quot;ResetBtn&quot;).Visible = msoCTrue .Shapes(&quot;LabelTemplate&quot;).Visible = msoCTrue .Shapes(&quot;OpenCustBtn&quot;).Visible = msoFalse .Range(&quot;C:F&quot;).EntireColumn.Hidden = False End With End Sub Sub Customize_Close() With Sheet1 On Error Resume Next .Shapes(&quot;SampleGrp&quot;).Placement = xlFreeFloating .Shapes(&quot;SampleGrp&quot;).Visible = msoFalse On Error GoTo 0 .Shapes(&quot;CloseCustBtn&quot;).Visible = msoFalse .Shapes(&quot;LabelTemplate&quot;).Visible = msoFalse .Shapes(&quot;ResetBtn&quot;).Visible = msoFalse .Shapes(&quot;OpenCustBtn&quot;).Visible = msoCTrue .Range(&quot;C:F&quot;).EntireColumn.Hidden = True End With End Sub </code></pre>
[ { "answer_id": 74129982, "author": "pgSystemTester", "author_id": 11732320, "author_profile": "https://Stackoverflow.com/users/11732320", "pm_score": 2, "selected": true, "text": "Sub Customize_Open()\nDim ws As Worksheet\n \n For Each ws In ThisWorkbook.Worksheets\n \n W...
2022/10/19
[ "https://Stackoverflow.com/questions/74129856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20240768/" ]
74,129,858
<p>I am just experimenting with Threads and I noticed something weird.</p> <p>First I created this little class:</p> <pre><code>public class CustomThread implements Runnable{ private String name; public CustomThread(String name){ this.name = name; } @Override public void run() { for(int i = 0; i &lt; 5; i++){ try { Thread.sleep(1000); System.out.println(name + &quot; sleeping since &quot; + (i+1) + &quot; seconds&quot;); } catch (InterruptedException e) { throw new RuntimeException(e); } } System.out.println(&quot;Thread &quot; + name + &quot; ended.&quot;); } } </code></pre> <p>In my main method I ran this:</p> <pre><code>Thread first = new Thread(new CustomThread(&quot;first&quot;)); first.start(); Thread.sleep(5000); System.out.println(first.isAlive()); </code></pre> <p>Expected console output:</p> <pre><code>first sleeping since 1 seconds first sleeping since 2 seconds first sleeping since 3 seconds first sleeping since 4 seconds first sleeping since 5 seconds Thread first ended. false Process finished with exit code 0 </code></pre> <p>Actual console output every 10/10 times I tried this:</p> <pre><code>first sleeping since 1 seconds first sleeping since 2 seconds first sleeping since 3 seconds first sleeping since 4 seconds true first sleeping since 5 seconds Thread first ended. Process finished with exit code 0 </code></pre> <p>I thought, maybe it is because a Thread is taking some time to start up so that is why my customthread is taking longer. so I edited the code to wait until customthread has started like so:</p> <pre><code>Thread first = new Thread(new CustomThread(&quot;first&quot;)); first.start(); while(!first.isAlive()){ Thread.sleep(10); } Thread.sleep(5000); System.out.println(first.isAlive()); </code></pre> <p>But same console output everytime. Why?</p>
[ { "answer_id": 74129982, "author": "pgSystemTester", "author_id": 11732320, "author_profile": "https://Stackoverflow.com/users/11732320", "pm_score": 2, "selected": true, "text": "Sub Customize_Open()\nDim ws As Worksheet\n \n For Each ws In ThisWorkbook.Worksheets\n \n W...
2022/10/19
[ "https://Stackoverflow.com/questions/74129858", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19896194/" ]
74,129,866
<p>In my HTML code, I have something like below:</p> <pre class="lang-html prettyprint-override"><code>&lt;div id=&quot;info&quot;&gt;...&lt;/div&gt; &lt;svg id=&quot;BarChart&quot; class=&quot;chart&quot; width=&quot;500&quot; height=&quot;300&quot; transform=&quot;translate(-110, 0) rotate(-90)&quot;&gt;...&lt;/svg&gt; </code></pre> <p>How can I make this SVG a child of the DIV using JavaScript? I want to have a paragraph in div and then my chart.</p>
[ { "answer_id": 74129985, "author": "Mr-montasir", "author_id": 16093630, "author_profile": "https://Stackoverflow.com/users/16093630", "pm_score": 1, "selected": true, "text": "const BarChart = document.querySelector('#BarChart');\nconst info = document.querySelector('#info');\ninfo.appe...
2022/10/19
[ "https://Stackoverflow.com/questions/74129866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14285143/" ]
74,129,896
<p>My code has the basic aim. Sort a list so that all the odd numbers are to the left and the even numbers are to the right. For example, [1,2,3,4,5] becomes [1,3,5,2,4] However, I kept myself an extra challenge. Make the code as short as possible.</p> <p>I was able to get it down to this.</p> <pre class="lang-py prettyprint-override"><code>l=[int(input(&quot;Number: &quot;)) for i in range(int(input(&quot;N: &quot;)))] [l.append((l.pop(l.count(''))) if l[l.count('')]%2==0 else '') for i in range(len(l))] for i in l: print(f'{i} ' if i!='' else f'{i}',end='') </code></pre> <p><strong>Forgetting readability and efficiency</strong>, is there any way to get this down even further, without using exec()?</p> <p>I thought of adding an else statement to the for loop inside the list comprehension, but apparently, you cannot add for-else statements in list comprehension without Python throwing you a syntax error.</p> <pre class="lang-py prettyprint-override"><code>l=[int(input(&quot;Number: &quot;)) for i in range(int(input(&quot;N: &quot;)))] [l.append((l.pop(l.count(''))) if l[l.count('')]%2==0 else '') for i in range(len(l)) else for i in l: print(f'{i} ' if i!='' else f'{i}',end='')] </code></pre> <p>If anyone else has any other ideas, I would love to hear them</p> <p><strong>EDIT:</strong> All the answers were using sorted() which I felt was a bit of a cheat. But, after a little more thought, I was able to come up with a new logic that only used two lines, one of which was the input.</p> <pre class="lang-py prettyprint-override"><code>l=[int(input(&quot;Number: &quot;)) for i in range(int(input(&quot;N: &quot;)))] [print(f'{l[j]} ' if l[j]%2==i else '',end='') for i in range(1,-1,-1) for j in range(len(l))] </code></pre> <p>If there actually is a way of doing both input, and output in one line, without using sorted() then let me know :)</p> <p><strong>EDIT2:</strong> I came up with a way to adapt my 2 line logic into a one line code!</p> <pre class="lang-py prettyprint-override"><code>[print(f'{j} ' if j%2==i else '',end='') for l in [[int(input(&quot;Number: &quot;)) for i in range(int(input(&quot;N: &quot;)))]] for i in range(1,-1,-1) for j in l] </code></pre>
[ { "answer_id": 74129983, "author": "Rahul K P", "author_id": 4407666, "author_profile": "https://Stackoverflow.com/users/4407666", "pm_score": 0, "selected": false, "text": "In [1]: l = [1,2,3,4,5]\n\nIn [2]: sorted([i for i in l if i%2 == 1]) + sorted([i for i in l if i%2 == 0])\nOut[2]...
2022/10/19
[ "https://Stackoverflow.com/questions/74129896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11884696/" ]
74,129,902
<p>I am building a Rails 7 app using bootstrap (without jquery), in which users can leave a review for various parks. One of the review fields is a 5-star rating.</p> <p>Currently I have the form input as a text_field, but I would like it to be 5 stars that the user can click on to select the rating, then submit together with the review form.</p> <p>I am already displaying the park ratings after they've been submitted, but I am stuck on the input display.</p> <p>I thought maybe I can somehow change the UI for a range_field or collection_radio_buttons, but I can't figure out how to make it work...</p> <p><strong>Park model</strong></p> <pre><code>class Park &lt; ApplicationRecord has_many :visits, dependent: :destroy has_many :visited_users, through: :visits, source: :user has_many :favorites, dependent: :destroy has_many :favorited_users, through: :favorites, source: :user has_many :reviews, as: :reviewable include Translatable translates :name, :website_url validates :name_en, presence: true validates :name_he, presence: true validates :region, presence: true validates :latitude, presence: true validates :longitude, presence: true enum :region, { north: 0, center: 1, south: 2, west_bank: 3 } enum :park_system, { kkl_jnf: 0, inpa: 1 }, default: :inpa def default_image Review&amp;.where(reviewable: self)&amp;.left_joins(:images_attachments)&amp;.where&amp;.not(active_storage_attachments: { id: nil })&amp;.first&amp;.images&amp;.first end def favorited_by?(user) return if user.nil? favorited_users.include?(user) end def visited_by?(user) return if user.nil? visited_users.include?(user) end end </code></pre> <p><strong>Review model</strong></p> <pre><code>class Review &lt; ApplicationRecord has_many_attached :images, dependent: :destroy # validates :title, presence: true validates :body, presence: true validates :rating, presence: true, numericality: { greater_than_or_equal_to: 1, less_than_or_equal_to: 5, only_integer: true } belongs_to :reviewable, polymorphic: true, counter_cache: true belongs_to :user after_commit :update_reviewable_rating, on: [:create, :update, :destroy] def update_reviewable_rating reviewable.update! average_rating: reviewable.reviews.average(:rating) # avg + (rating - avg) / count end end </code></pre> <p><strong>Reviews controller</strong></p> <pre><code># frozen_string_literal: true class ReviewsController &lt; ApplicationController before_action :authenticate_user! before_action :find_park before_action :find_review, only: %i[ edit update destroy ] def new @review = Review.new(reviewable: @park) end def create @review = @park.reviews.new(review_params) @review.reviewable_id = @park.id @review.user_id = current_user.id respond_to do |format| if @review.save format.html { redirect_to params[:previous_request], notice: &quot;Your review for #{@park.name} was successfully added.&quot; } format.json { render :show, status: :created, location: @park } else format.html { render :new, status: :unprocessable_entity } format.json { render json: @review.errors, status: :unprocessable_entity } end end end def edit end def update respond_to do |format| if @review.update(review_params) format.html { redirect_to params[:previous_request], notice: &quot;Your review for #{@park.name} was successfully updated.&quot; } format.json { render :show, status: :ok, location: @park } else format.html { render :edit, status: :unprocessable_entity } format.json { render json: @review.errors, status: :unprocessable_entity } end end end def destroy @review.destroy respond_to do |format| format.html { redirect_to params[:previous_request], notice: &quot;Your review for #{@park.name} was successfully deleted.&quot; } format.json { head :no_content } end end private def review_params params.require(:review).permit(:rating, :body, images: []) end def find_park @park = Park.find(params[:park_id]) end def find_review @review = Review.find(params[:id]) end end </code></pre> <p><strong>Parks show view, reviews partial</strong></p> <pre><code>&lt;% @park.reviews.includes(:user).order(&quot;updated_at desc&quot;).each do |review| %&gt; &lt;div class=&quot;col&quot;&gt; &lt;div class=&quot;card px-0 mt-4 mb-4 border-0&quot;&gt; &lt;div class=&quot;card-body&quot;&gt; &lt;h5 class=&quot;card-title mb-4&quot;&gt; &lt;%= gravatar_for review.user, size: 50 %&gt; &lt;div class=&quot;strong&quot;&gt; &lt;%= link_to review.user.name, review.user, class: &quot;link-dark&quot; %&gt; &lt;/div&gt; &lt;/h5&gt; &lt;h6 class=&quot;card-subtitle mt-2&quot;&gt; &lt;% review_star_classes = [&quot;#DEDEDE&quot;, &quot;#DEDEDE&quot;, &quot;#DEDEDE&quot;, &quot;#DEDEDE&quot;, &quot;#DEDEDE&quot;] review.rating.times do |i| review_star_classes[i] = &quot;#fbbc04&quot; end %&gt; &lt;% review_star_classes.each do |star_class| %&gt; &lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;&lt;%= star_class %&gt;&quot; width=&quot;16&quot; height=&quot;16&quot; class=&quot;w-5 h-5&quot;&gt; &lt;path fill-rule=&quot;evenodd&quot; d=&quot;M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.007 5.404.433c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.433 2.082-5.006z&quot; clip-rule=&quot;evenodd&quot; /&gt; &lt;/svg&gt; &lt;% end %&gt; &lt;/h6&gt; &lt;div class=&quot;card-text mt-4&quot;&gt; &lt;div&gt; &lt;%= review.updated_at.to_fs(:long) %&gt; &lt;/div&gt; &lt;div class=&quot;mt-2&quot;&gt; &lt;%= simple_format(review.body) %&gt; &lt;/div&gt; &lt;% if current_user &amp;&amp; current_user === review.user %&gt; &lt;div&gt; &lt;%= link_to &quot;Edit&quot;, edit_park_review_path(review.reviewable, review) %&gt; &lt;%= button_to &quot;Delete&quot;, park_review_path(review.reviewable, review), class: &quot;btn btn-link p-0 m-0 d-inline align-baseline text-decoration-none&quot;, form: {data: { turbo_confirm: &quot;Are you sure?&quot;} }, method: :delete %&gt; &lt;/div&gt; &lt;% end %&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;% end %&gt; </code></pre> <p><strong>New review form</strong></p> <pre><code>&lt;%= form_with model: @review, url: park_reviews_path, local:true do |f| %&gt; &lt;%= hidden_field_tag :previous_request, request.referer %&gt; &lt;div class=&quot;field form-group&quot;&gt; &lt;%= f.label :rating, &quot;Rate your experience&quot;, style: &quot;display: block&quot; %&gt; &lt;%= f.text_field :rating, class: &quot;form-control&quot;, placeholder: &quot;From 1 to 5 stars&quot;, autofocus: true %&gt; &lt;/div&gt; &lt;div class=&quot;field form-group&quot;&gt; &lt;%= f.text_area :body, class: &quot;form-control&quot;, placeholder: &quot;Tell people about your experience&quot; %&gt; &lt;/div&gt; &lt;div class=&quot;field form-group&quot;&gt; &lt;%= f.file_field :images, multiple: true %&gt; &lt;/div&gt; &lt;div class=&quot;actions&quot;&gt; &lt;%= f.submit &quot;Submit your review&quot;, class: &quot;btn btn-primary&quot; %&gt; &lt;/div&gt; &lt;% end %&gt; </code></pre>
[ { "answer_id": 74129983, "author": "Rahul K P", "author_id": 4407666, "author_profile": "https://Stackoverflow.com/users/4407666", "pm_score": 0, "selected": false, "text": "In [1]: l = [1,2,3,4,5]\n\nIn [2]: sorted([i for i in l if i%2 == 1]) + sorted([i for i in l if i%2 == 0])\nOut[2]...
2022/10/19
[ "https://Stackoverflow.com/questions/74129902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18991927/" ]
74,129,916
<p>Although I copied this problem from the Unity forum, it is also related to C#, so I'm asking if you have any solutions</p> <p>I frequently want to know what's the name of variable and its value:</p> <p>Debug.Log(&quot;variableName: &quot; + variableName); This might output &quot;variableName: true&quot;</p> <p>I would like to only have to write something like this instead, as it is faster and if the name of the variable changes it will still display the correct name so I won't have to change this debug line:</p> <p>DebugExt.Log(variableName); The output would be the same &quot;variableName: true&quot;</p> <p>Suppose I have ten fields and just want to look at them temporarily and think of entering an extra field name for each field .....</p> <p>How can I achieve this?</p> <p>Question source page: <a href="https://forum.unity.com/threads/extending-debug-log-to-display-the-name-of-the-variable-automatically.763271/" rel="nofollow noreferrer">https://forum.unity.com/threads/extending-debug-log-to-display-the-name-of-the-variable-automatically.763271/</a></p> <p>Some related solutions: extending-debug-log: <a href="https://forum.unity.com/threads/extending-debug-log-to-display-the-name-of-the-variable-automatically.763271/" rel="nofollow noreferrer">https://forum.unity.com/threads/extending-debug-log-to-display-the-name-of-the-variable-automatically.763271/</a></p>
[ { "answer_id": 74131080, "author": "John B", "author_id": 57698, "author_profile": "https://Stackoverflow.com/users/57698", "pm_score": 1, "selected": false, "text": "public void LogWithName(string propertyToLog, [CallerArgumentExpression(\"propertyToLog\")] string propertyToLogName = nu...
2022/10/19
[ "https://Stackoverflow.com/questions/74129916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15893325/" ]
74,129,933
<p>I have an angular application that uses a proxy to access the java spring boot backend and other services:</p> <p>proxy.conf.js:</p> <pre><code>const PROXY_CONFIG = [ { context: [ &quot;/my/api/context/**&quot; ], target: &quot;http://localhost:9000/&quot;, headers: { &quot;Content-Type&quot;: &quot;application/json&quot; }, secure: false, logLevel: &quot;debug&quot;, changeOrigin: true, }, ... }] module.exports = PROXY_CONFIG; </code></pre> <p>MyController.java:</p> <pre><code>@RestController @RequestMapping(&quot;/my/api/controller/path&quot;) public class MyController { ... @PostMapping(&quot;/endpoint/{id}&quot;) public ResponseEntity&lt;Boolean&gt; endpoint(@PathVariable Long id) { ... } ... } </code></pre> <p>I'm also using zookeeper for some environment configurations.</p> <p>The issue is that for GET requests, my angular application works fine but for any other verb, I get a <code>403 Forbidden</code> error and a <code>Invalid CORS request</code> message from spring boot. What's weird is that when I copy the request with all the headers and submit via Postman, I get a <code>200</code> response with no problems.</p> <p>There are many questions regarding this problem on the web but all seem to point to a backend issue. In this case the backend seem to be well configured (the Postman request is successful).</p> <p>I'm sure I'm missing something trivial but just can't put my finger on it. Anyone has any idea what could be going wrong here? Any help or suggestion would be appreciated. If you need anything else, just let me know and I'll see if I can share.</p> <p><strong>EDIT #1:</strong></p> <p>my.service.ts:</p> <pre><code>myPost(id: number): Observable&lt;any&gt; { return this.http.post&lt;any&gt;(`${this.endpoint}/${id}`); } </code></pre>
[ { "answer_id": 74131080, "author": "John B", "author_id": 57698, "author_profile": "https://Stackoverflow.com/users/57698", "pm_score": 1, "selected": false, "text": "public void LogWithName(string propertyToLog, [CallerArgumentExpression(\"propertyToLog\")] string propertyToLogName = nu...
2022/10/19
[ "https://Stackoverflow.com/questions/74129933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2366528/" ]
74,129,936
<p>The useState hook is not working for me. In <code>props.data</code> I am getting the array.</p> <p>I am trying to update the array of objects, but rendering is not working:</p> <pre><code>const MenuList = (props)=&gt;{ const [enteredData,setEnteredData] = useState(props.data); const amountChangeHandler = (event)=&gt;{ const findElementId = event.target.attributes.alter.value; const item = props.data.find(item =&gt; item.id === findElementId); item.amount = parseInt(document.getElementById(findElementId).value); console.log(props.data); setEnteredData(props.data); } return( &lt;ul&gt; {enteredData.map((item)=&gt;&lt;li key={item.id} className={classes['cart-item']}&gt; &lt;div&gt; &lt;h2&gt;{item.mealName}&lt;/h2&gt; &lt;div className={classes.summary}&gt;&lt;i&gt;{item.mealDescription}&lt;/i&gt; &lt;span className={classes.price}&gt;${item.price}&lt;/span&gt; &lt;span className={classes.amount}&gt;x {item.amount}&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;div className={classes.actions}&gt; &lt;div&gt;&lt;label htmlFor={item.id}&gt;Amount &lt;/label&gt; &lt;input type='number' id={item.id} defaultValue='1' &gt;&lt;/input&gt; &lt;/div&gt; &lt;button alter={item.id} onClick={amountChangeHandler}&gt;+Add&lt;/button&gt; &lt;/div&gt; &lt;/li&gt;) }&lt;/ul&gt; ) } export default MenuList; </code></pre>
[ { "answer_id": 74131080, "author": "John B", "author_id": 57698, "author_profile": "https://Stackoverflow.com/users/57698", "pm_score": 1, "selected": false, "text": "public void LogWithName(string propertyToLog, [CallerArgumentExpression(\"propertyToLog\")] string propertyToLogName = nu...
2022/10/19
[ "https://Stackoverflow.com/questions/74129936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16135620/" ]
74,129,938
<p>I have added my cypress record key in the cypress config file. But displaying this issue. Can someone help me to resolve this issue? <a href="https://i.stack.imgur.com/w9K0E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w9K0E.png" alt="enter image description here" /></a></p> <p>Tried like this too.</p> <pre class="lang-js prettyprint-override"><code> e2e: { async setupNodeEvents(on, config) { // implement node event listeners here const bundler = createBundler({ plugins: [createEsbuildPlugin(config)], }); on(&quot;file:preprocessor&quot;, bundler); await addCucumberPreprocessorPlugin(on, config); return config; }, specPattern:&quot;cypress/e2e/features/*feature&quot;, baseUrl:&quot;https://d2l5front.net/&quot;, projectId: &quot;7t2&quot;, viewportWidth: 1600, viewportHeight: 1100, env: { CYPRESS_RECORD_KEY: &quot;62ad7c5d-2c01209cf1c7&quot;, } </code></pre> <p>}</p>
[ { "answer_id": 74130026, "author": "agoff", "author_id": 11625850, "author_profile": "https://Stackoverflow.com/users/11625850", "pm_score": 0, "selected": false, "text": "env" }, { "answer_id": 74130718, "author": "TesterDick", "author_id": 18366749, "author_profile"...
2022/10/19
[ "https://Stackoverflow.com/questions/74129938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18173747/" ]
74,129,939
<p>My designer has given me an SVG that looks like this:</p> <p><a href="https://i.stack.imgur.com/5ORuj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5ORuj.png" alt="enter image description here" /></a></p> <p>I will be rendering this as a <em>responsive</em> button on a webpage. As the viewport widens, I want this to horizontally expand in a very particular way. This SVG is 250x44, BTW.</p> <p>My thought is to slice it into pieces and glue them back together, like so:</p> <p><a href="https://i.stack.imgur.com/1kHDm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1kHDm.png" alt="enter image description here" /></a></p> <p>Then, <a href="https://www.sarasoueidan.com/blog/nesting-svgs" rel="nofollow noreferrer">at least in theory</a>, I should be able to give each piece its own <code>preserveAspectRatio</code> that defines how each piece should expand to fill up the room available to it. e.g., have the 3rd piece take up all the available room.</p> <p>Unfortunately, I get stuck at the &quot;slice into pieces&quot; part. No matter what I try, I can't seem to get the <code>viewBox</code> of the pieces have the effect I'm looking for.</p> <p>Here's my SVG file:</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;svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 250 44"&gt; &lt;!-- #default is in &lt;defs&gt;, defined at the bottom of the file. --&gt; &lt;symbol id="bg-1" viewBox="0 0 250 44"&gt; &lt;use href="#default" /&gt; &lt;/symbol&gt; &lt;use href="#bg-1" x="0" width="47" height="44" /&gt; &lt;symbol id="bg-2" viewBox="48 0 250 44"&gt; &lt;use href="#default" /&gt; &lt;/symbol&gt; &lt;use href="#bg-2" x="48" width="36" height="44" /&gt; &lt;symbol id="bg-3" viewBox="84 0 250 44"&gt; &lt;use href="#default" /&gt; &lt;/symbol&gt; &lt;use href="#bg-3" x="84" width="36" height="44" /&gt; &lt;symbol id="bg-4" viewBox="120 0 250 44"&gt; &lt;use href="#default" /&gt; &lt;/symbol&gt; &lt;use href="#bg-4" x="120" width="29" height="44" /&gt; &lt;symbol id="bg-5" viewBox="149 0 250 44"&gt; &lt;use href="#default" /&gt; &lt;/symbol&gt; &lt;use href="#bg-5" x="149" width="9" height="44" /&gt; &lt;symbol id="bg-6" viewBox="158 0 250 44"&gt; &lt;use href="#default" /&gt; &lt;/symbol&gt; &lt;use href="#bg-6" x="158" width="39" height="44" /&gt; &lt;symbol id="bg-7" viewBox="197 0 250 44"&gt; &lt;use href="#default" /&gt; &lt;/symbol&gt; &lt;use href="#bg-7" x="197" width="53" height="44" /&gt; &lt;defs&gt; &lt;!-- This is the file my designer gave to me --&gt; &lt;svg id="default"&gt; &lt;defs&gt; &lt;style&gt; .cls-1, .cls-8 { opacity: 0.6; } .cls-2 { fill: #25180c; } .cls-3 { fill: #fcf9eb; } .cls-4 { opacity: 0.02; } .cls-5 { fill: #956131; } .cls-6 { fill: none; stroke: #724141; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1px; stroke-dasharray: 69.96 2.5 1 2.5 1 2.5; opacity: 0.3; } .cls-7 { opacity: 0.5; fill: url(#linear-gradient); } .cls-8 { fill: url(#linear-gradient-2); } &lt;/style&gt; &lt;linearGradient id="linear-gradient" x1="125.64" y1="27.26" x2="125.64" y2="2" gradientUnits="userSpaceOnUse"&gt; &lt;stop offset="0" stop-color="#956131" stop-opacity="0" /&gt; &lt;stop offset="1" stop-color="#956131" stop-opacity="0.2" /&gt; &lt;/linearGradient&gt; &lt;linearGradient id="linear-gradient-2" x1="111.9" y1="50.47" x2="115.6" y2="8.24" gradientUnits="userSpaceOnUse"&gt; &lt;stop offset="0" stop-color="#956131" stop-opacity="0" /&gt; &lt;stop offset="1" stop-color="#956131" stop-opacity="0.15" /&gt; &lt;/linearGradient&gt; &lt;/defs&gt; &lt;g id="Ingame_Secondary_Button" data-name="Ingame Secondary Button"&gt; &lt;g id="ing2_outershadow" class="cls-1"&gt; &lt;path class="cls-2" d="M234.3,3.16H26.36a2.55,2.55,0,0,0-2.24,1.32,4.75,4.75,0,0,1-.61.94,1.37,1.37,0,0,1-1.28.38,1.88,1.88,0,0,1-.65-.39L19.78,4a3.83,3.83,0,0,0-2.38-.83H1.91A1.89,1.89,0,0,0,0,5V40.29A3.76,3.76,0,0,0,3.81,44H148.72a4,4,0,0,0,1.14-.17l1.61-.47a8,8,0,0,1,3.32-.39,2.73,2.73,0,0,1,1,.4,4.1,4.1,0,0,0,2.12.63h76.39a1.56,1.56,0,0,0,1.07-.43c7.19-7,11.58-13.24,14.48-19.09a1.93,1.93,0,0,0,0-1.78c-5.16-9.34-9.92-15.22-14.46-19.17A1.51,1.51,0,0,0,234.3,3.16Z" /&gt; &lt;/g&gt; &lt;path id="ing2_background" class="cls-3" d="M3.81,41H148.72a2.72,2.72,0,0,0,.84-.13c.6-.19,1.18-.36,1.64-.49a10.87,10.87,0,0,1,2.87-.5A5.42,5.42,0,0,1,155,40a3.55,3.55,0,0,1,1.32.56,3,3,0,0,0,1.58.49h76.39a.58.58,0,0,0,.37-.15,72.13,72.13,0,0,0,14.29-19.36,1.08,1.08,0,0,0,0-.93c-4.65-8.66-9.31-15-14.25-19.44A.46.46,0,0,0,234.3,1H26.36A1.53,1.53,0,0,0,25,1.82,4.57,4.57,0,0,1,24.2,3a2.31,2.31,0,0,1-2.26.63,2.78,2.78,0,0,1-1-.58l-1.8-1.47A2.81,2.81,0,0,0,17.4,1H1.91A.91.91,0,0,0,1,1.91V38.18A2.81,2.81,0,0,0,3.81,41Z" /&gt; &lt;g id="ing2_pattern" class="cls-4"&gt; &lt;path class="cls-5" d="M61.11,5.25H50.84L49,6.33a221.18,221.18,0,0,1-20,10A139.08,139.08,0,0,1,5.24,24.21v6.44A182.55,182.55,0,0,0,31,20.92C41.33,16.15,51.19,10.54,61.11,5.25Z" /&gt; &lt;path class="cls-5" d="M29.81,5.25H28.12a.47.47,0,0,0-.38.19,6.06,6.06,0,0,1-.59.66,6.59,6.59,0,0,1-6.44,1.64,7.15,7.15,0,0,1-2.44-1.35L17,5.36a.49.49,0,0,0-.31-.11H10.15c-1.63.43-3.26.83-4.91,1.18v8.46l1.67-.43A105.92,105.92,0,0,0,29.81,5.25Z" /&gt; &lt;path class="cls-5" d="M75.9,20.29c9.42-5.44,19-10.41,29.31-13.25a78.43,78.43,0,0,1,8.15-1.79H94.79A183.6,183.6,0,0,0,73,15L58.4,22.48c-4.88,2.41-9.75,4.77-14.72,6.86-2.48,1-5,2.05-7.48,3-1.25.48-2.52.9-3.79,1.34s-2.53.87-3.8,1.26c-2,.64-4,1.25-6.08,1.82H47.19C57.08,31.58,66.48,25.75,75.9,20.29Z" /&gt; &lt;path class="cls-5" d="M200,27.22A319.47,319.47,0,0,0,169.61,9.79a92.1,92.1,0,0,0-10.5-4.54h-17.4a78.67,78.67,0,0,1,25.51,9.09,215.09,215.09,0,0,1,28.41,18.88c1.46,1.18,3,2.36,4.44,3.53h16L213.8,35.6C209.13,33,204.52,30.2,200,27.22Z" /&gt; &lt;path class="cls-5" d="M237.5,37.83h0Z" /&gt; &lt;path class="cls-5" d="M213.8,16.09c-2.56-1.86-5-3.79-7.7-5.55l-3.95-2.67c-1.31-.9-2.72-1.68-4.09-2.51l-.18-.11H181.13C190.34,10,201,15.76,209.49,21.94c2.51,1.8,5,3.71,7.49,5.55L224.59,33c1.79,1.23,3.54,2.49,5.33,3.72h2.55a.52.52,0,0,0,.37-.16q1.74-1.8,3.28-3.6-3.75-2.7-7.46-5.49C223.76,23.7,218.85,19.86,213.8,16.09Z" /&gt; &lt;polygon class="cls-5" points="239.58 35.47 239.58 35.47 239.58 35.47 239.58 35.47" /&gt; &lt;path class="cls-5" d="M146.35,16.24a52.33,52.33,0,0,0-12.56-2.95,65.68,65.68,0,0,0-12.78.19,63,63,0,0,0-12.44,2.76,70.65,70.65,0,0,0-11.64,5.12A130.2,130.2,0,0,0,76.47,35.9l-1,.85h9.3A88.7,88.7,0,0,1,99.37,25.64a54,54,0,0,1,22.15-7.57,52.77,52.77,0,0,1,11.72,0,42.13,42.13,0,0,1,11.15,3.13A72.43,72.43,0,0,1,164,34.33c.88.79,1.73,1.61,2.58,2.42h12.75c-3.48-2.82-7-5.6-10.7-8.23C161.74,23.65,154.43,19.17,146.35,16.24Z" /&gt; &lt;path class="cls-5" d="M134.55,27.28a24.77,24.77,0,0,0-4.05-1.15,18.43,18.43,0,0,0-2.11-.27c-.7-.05-1.36-.06-2-.05a29.3,29.3,0,0,0-4.06.36,27.67,27.67,0,0,0-7.68,2.56A38.94,38.94,0,0,0,108,33.09c-1.43,1.17-2.79,2.4-4.1,3.66h7.36a22.78,22.78,0,0,1,11.79-6,16.65,16.65,0,0,1,3.31-.22c.55,0,1.13.05,1.65.11a11.72,11.72,0,0,1,1.55.28,17,17,0,0,1,5.86,2.74,32.48,32.48,0,0,1,3.68,3.1h9.3a54.16,54.16,0,0,0-10.13-7.69A28.5,28.5,0,0,0,134.55,27.28Z" /&gt; &lt;path class="cls-5" d="M220.07,5.25c6.46,4.74,13,9.45,19.85,13.79,1.37.87,2.76,1.73,4.15,2.57l.14-.25a.5.5,0,0,0,0-.49,81.5,81.5,0,0,0-6.94-10.66q-4.09-2.43-8.16-5Z" /&gt; &lt;path class="cls-5" d="M245.68,15h0l0,0Z" /&gt; &lt;path class="cls-5" d="M239.58,35.47c-.67.79-1.36,1.57-2.08,2.36C238.22,37,238.91,36.26,239.58,35.47Z" /&gt; &lt;/g&gt; &lt;path id="ing2_innerborder" class="cls-6" d="M232.63,5.25H28.12a.51.51,0,0,0-.39.19,5.08,5.08,0,0,1-.58.66,6.59,6.59,0,0,1-6.44,1.64,7.25,7.25,0,0,1-2.44-1.35L17,5.36a.49.49,0,0,0-.31-.11h-11a.5.5,0,0,0-.5.5v30.5a.5.5,0,0,0,.5.5H148.42l.15,0,1.51-.45a12.63,12.63,0,0,1,5.57-.52,7.44,7.44,0,0,1,2.52.93.48.48,0,0,0,.24.06h74.06a.52.52,0,0,0,.37-.16,67.69,67.69,0,0,0,11.37-15.23.5.5,0,0,0,0-.49C240.49,14.2,236.8,9.11,233,5.39A.5.5,0,0,0,232.63,5.25Z" /&gt; &lt;path id="ing2_gradient" class="cls-7" d="M246.94,27.26q1.44-2.37,2.6-4.77a1,1,0,0,0,0-.92c-4.65-8.67-9.31-15-14.24-19.45a.48.48,0,0,0-.33-.12H27a1.55,1.55,0,0,0-1.35.82A4.64,4.64,0,0,1,24.84,4a2.31,2.31,0,0,1-2.26.63,2.78,2.78,0,0,1-1-.58L19.78,2.62A2.77,2.77,0,0,0,18,2H2.54a.9.9,0,0,0-.9.91V27.26Z" /&gt; &lt;path id="ing2_innershadow" class="cls-8" d="M149.56,40.87c.6-.19,1.18-.36,1.64-.49a10.87,10.87,0,0,1,2.87-.5A5.42,5.42,0,0,1,155,40a3.55,3.55,0,0,1,1.32.56,3,3,0,0,0,1.58.49h70c-13.72-5.86-30.11-15.3-30.11-15.3l-78-7.51-34.86-.13S61.17,9.64,32.9,1H26.36A1.53,1.53,0,0,0,25,1.82,4.57,4.57,0,0,1,24.2,3a2.31,2.31,0,0,1-2.26.63,2.78,2.78,0,0,1-1-.58l-1.8-1.47A2.81,2.81,0,0,0,17.4,1H1.91A.91.91,0,0,0,1,1.91V38.18A2.81,2.81,0,0,0,3.81,41H148.72A2.72,2.72,0,0,0,149.56,40.87Z" /&gt; &lt;g id="ing2_outerborder"&gt; &lt;path class="cls-5" d="M26.32,1.44h0M234.12,2c4.79,4.33,9.33,10.56,13.88,19.06A70.67,70.67,0,0,1,234.05,40H157.3a5,5,0,0,0-2.18-1,6,6,0,0,0-1.05-.09,11.68,11.68,0,0,0-3.13.54c-.5.14-1.15.33-1.95.58H2V2H18l2.29,1.86a3.94,3.94,0,0,0,1.33.76,2.87,2.87,0,0,0,.87.13,3.49,3.49,0,0,0,2.38-1A6.39,6.39,0,0,0,26,2H234.12m.37-2H25.42a1,1,0,0,0-.9.56,9.75,9.75,0,0,1-1,1.76,1.45,1.45,0,0,1-1,.43,1,1,0,0,1-.29,0,1.91,1.91,0,0,1-.65-.4L19,.22A1,1,0,0,0,18.39,0H1A1,1,0,0,0,0,1V41a1,1,0,0,0,1,1H149.15a1,1,0,0,0,.3,0c.74-.23,1.46-.45,2-.6a9.75,9.75,0,0,1,2.6-.47,4.37,4.37,0,0,1,.72.06,3.63,3.63,0,0,1,1.53.83A1,1,0,0,0,157,42h77.5a1,1,0,0,0,.71-.3c7.28-7.25,11.7-13.71,14.63-19.77a2,2,0,0,0-.05-1.85c-5.2-9.7-10-15.77-14.59-19.83a1,1,0,0,0-.67-.25Z" /&gt; &lt;/g&gt; &lt;/g&gt; &lt;/svg&gt; &lt;/defs&gt; &lt;/svg&gt;</code></pre> </div> </div> </p> <p>When I open this file in Firefox, it's rendered like this:</p> <p><a href="https://i.stack.imgur.com/K7w7p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K7w7p.png" alt="enter image description here" /></a></p> <p><a href="https://www.sarasoueidan.com/demos/interactive-svg-coordinate-system/" rel="nofollow noreferrer">When I play with this tool</a>, I feel like I've got the right idea with the <code>viewBox</code>, but no matter what I try, I can't get it to render the pieces I want, where I want.</p> <p>I've tried using nested <code>svg</code>s, <code>use</code>s, and <code>symbol</code>s (the latter of which is shown in the current iteration of the file), but I never feel like I'm getting closer to the solution. At this point I'm out of ideas and I think there's just something I don't know that's preventing me from pulling this off. But when I compare my example to the looks of that tool, it seems to me that the <code>symbol.viewBox.x</code> value isn't being respected and I don't know why.</p> <p>To summarize my question, how can I modify this SVG file so that it renders the pieces as shown in the 2nd image? It's okay if each piece has a wonky aspect ratio; I plan to fix that in the next step. For now, I just want to get this parent svg to render these pieces side by side.</p>
[ { "answer_id": 74130026, "author": "agoff", "author_id": 11625850, "author_profile": "https://Stackoverflow.com/users/11625850", "pm_score": 0, "selected": false, "text": "env" }, { "answer_id": 74130718, "author": "TesterDick", "author_id": 18366749, "author_profile"...
2022/10/19
[ "https://Stackoverflow.com/questions/74129939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13669212/" ]
74,129,945
<p>I have a dataset where each row represents a continuous spell with start and end months and years. For spells which are over more than one year, I want to pivot them so that there is one row per year.</p> <p>Input:</p> <pre><code>library(data.table) dat &lt;- data.table(id = c(1,1,2), b_sp_y = c(2008, 2009, 2011), b_sp_m = c(3, 8, 6), e_sp_y = c(2008, 2010, 2013), e_sp_m = c(5, 1, 9)) id b_sp_y b_sp_m e_sp_y e_sp_m 1: 1 2008 3 2008 5 2: 1 2009 8 2010 1 3: 2 2011 6 2013 9 </code></pre> <p>Here is my truly horrifyingly ugly code:</p> <pre><code>dat[, y_dif := e_sp_y - b_sp_y] res &lt;- dat[y_dif == 0][, c(&quot;e_sp_y&quot;, &quot;y_dif&quot;) := NULL] setnames(res, &quot;b_sp_y&quot;, &quot;year&quot;) tmp &lt;- dat[y_dif &gt; 0] for(i in 1:nrow(tmp)){ foo &lt;- tmp[i, ] foo2 &lt;- data.table(year = foo$b_sp_y:(foo$b_sp_y + foo$y_dif))[,id := foo$id] foo2[, b_sp_m := c(foo$b_sp_m, rep(1, foo$y_dif))] foo2[, e_sp_m := c(rep(12, foo$y_dif), foo$e_sp_m)] res &lt;- rbind(res, foo2) } </code></pre> <p>Output:</p> <pre><code> id year b_sp_m e_sp_m 1: 1 2008 3 5 2: 1 2009 8 12 3: 1 2010 1 1 4: 2 2011 6 12 5: 2 2012 1 12 6: 2 2013 1 9 </code></pre> <p>This is ugly and slow to a crawl, but I couldn't really come up with anything better. Thanks for your help!</p>
[ { "answer_id": 74129970, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 0, "selected": false, "text": "list" }, { "answer_id": 74130190, "author": "Jon Spring", "author_id": 6851825, "author_profile": ...
2022/10/19
[ "https://Stackoverflow.com/questions/74129945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15776927/" ]
74,129,968
<p>I am creating a programme where you convert numbers to roman numbers.</p> <p>Here is my code:</p> <pre><code>public static void main(String[] args) { System.out.println(convertDigitsToRoman(SplitNumbersIntoDigits(3567))); } public static int[] SplitNumbersIntoDigits(int numberToConvert) { //converting the number into digits int[] digit = new int[4]; digit[0] = numberToConvert / 1000; digit[1] = (numberToConvert % 1000) / 100; digit[2] = (numberToConvert % 100) / 10; digit[3] = numberToConvert % 10; return digit; } public static String convertDigitsToRoman(int[] digit) { String a = &quot;I&quot;, b = &quot;V&quot;, c = &quot;X&quot;; String allDigitInRoman = &quot;&quot;; for (int i = 0; i &lt; digit.length; i++) { String digitInRoman = &quot;&quot;; if (digit[i] &lt; 4) { for (int j = 0; j &lt; digit[i]; j++) { digitInRoman += a; } } else if (digit[i] == 4) { digitInRoman = String.valueOf(a) + b; } else if (digit[i] == 5) { digitInRoman = String.valueOf(b); } else if (digit[i] &gt; 5 &amp;&amp; digit[i] &lt; 9) { String plusA = &quot;&quot;; for (int k = 5; k &lt; digit[i]; k++) { plusA += a; } digitInRoman = b + plusA; } else if (digit[i] == 9) { digitInRoman = String.valueOf(a) + c; } allDigitInRoman += digitInRoman; } return allDigitInRoman; } } </code></pre> <p>Now everytime when digit[i] changes I want the String a, b, c to change. How can I try to write such as:</p> <pre><code>when (digit[0]) change a,b,c to M,C,whateevr when (digit[1]) change a,b,c to L,,whtevr,,whtevr when (digit[2]) change a,b,c to X,whtevr,whtevr when (digit[3]) change a,b,c to I, V, X </code></pre> <p>I know that is not java, it is English but want to know how is achieved in java.</p>
[ { "answer_id": 74130528, "author": "Old Dog Programmer", "author_id": 5103317, "author_profile": "https://Stackoverflow.com/users/5103317", "pm_score": 0, "selected": false, "text": " char [][] roman = { {'I','V'}, {'X','L'},{'C','D'},{'M'}};\n" }, { "answer_id": 74130599, ...
2022/10/19
[ "https://Stackoverflow.com/questions/74129968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13461292/" ]
74,129,976
<p>I am having trouble adding a basemap to my map. My geodataframe is created using X and Y coords of a bunch of points.</p> <pre><code>gdf = geo.GeoDataFrame( df, geometry=gpd.points_from_xy(df['X'], df['Y'])) gdf.set_crs(epsg=3857) </code></pre> <p>Which look like this: <a href="https://i.stack.imgur.com/TnbVa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TnbVa.png" alt="enter image description here" /></a></p> <p>After using contexily to get a basemap, I cannot get the basemap to properly show up. The coords should be showing the bottom of the Mississippi River Basin.</p> <pre><code>ax = gdf.plot(color=&quot;red&quot;, figsize=(9, 9)) cx.add_basemap(ax, zoom=0, crs= gdf.crs) </code></pre> <p><a href="https://i.stack.imgur.com/4llX1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4llX1.png" alt="enter image description here" /></a></p> <p>Let me know if there is anything wrong with my code as to why it is not showing up.</p> <p>Thanks!</p>
[ { "answer_id": 74130528, "author": "Old Dog Programmer", "author_id": 5103317, "author_profile": "https://Stackoverflow.com/users/5103317", "pm_score": 0, "selected": false, "text": " char [][] roman = { {'I','V'}, {'X','L'},{'C','D'},{'M'}};\n" }, { "answer_id": 74130599, ...
2022/10/19
[ "https://Stackoverflow.com/questions/74129976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19499394/" ]
74,129,997
<pre><code>parameter.setContext(splitName[0]); // value = dev parameter.setRegion(splitName[1]); // value = asia parameter.setLob(splitName[2]); // value = all </code></pre> <p>So this is a small piece of java code and i'm assigning some values in it as you can see. Bascially i'm writing a yaml file by reading some text file.</p> <pre><code>context: dev region: asia lob: all </code></pre> <p>This is Yaml file that is converted using snakeYaml Library, so my problem is i want double quotes in values eg:- &quot;dev&quot;.</p> <pre><code>context: &quot;dev&quot; region: &quot;asia&quot; lob: &quot;all&quot; </code></pre> <p>I want the format above but I'm not able to find out how would i be able to achieve that.Please help!!</p> <p>What would i have to do to add double quotes in values area in key-value pair of yaml.</p> <p>Edit:</p> <pre><code>parameter.setContext(&quot;\&quot;&quot;+splitName[0]+&quot;\&quot;&quot;); parameter.setRegion(&quot;\&quot;&quot;+splitName[1]+&quot;\&quot;&quot;); parameter.setLob(&quot;\&quot;&quot;+splitName[2]+&quot;\&quot;&quot;); </code></pre> <p>And if I am doing this for double quotes the output coming is like below:</p> <pre><code>context: '&quot;dev&quot;' region: '&quot;asia&quot;' lob: '&quot;all&quot;' </code></pre>
[ { "answer_id": 74130528, "author": "Old Dog Programmer", "author_id": 5103317, "author_profile": "https://Stackoverflow.com/users/5103317", "pm_score": 0, "selected": false, "text": " char [][] roman = { {'I','V'}, {'X','L'},{'C','D'},{'M'}};\n" }, { "answer_id": 74130599, ...
2022/10/19
[ "https://Stackoverflow.com/questions/74129997", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20285291/" ]
74,130,019
<p>What option or feature must I enable in Visual Studio 2022 to get tooltips to show when hovering the mouse over a method, object, or error (i.e. red squiggly)? See screenshot comparing VS 2019 and 2022. I've searched for variations on VS 2022 and intellisense, intellicode, and it's not clear what changed with VS 2022.</p> <p><a href="https://i.stack.imgur.com/hfzQ6.jpg" rel="nofollow noreferrer">Screenshot of VS 2019 vs. 2022 tooltip compare on mouse-over</a></p>
[ { "answer_id": 74130181, "author": "Wayasel Ahmmed", "author_id": 15525004, "author_profile": "https://Stackoverflow.com/users/15525004", "pm_score": -1, "selected": false, "text": "settings.json" } ]
2022/10/19
[ "https://Stackoverflow.com/questions/74130019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6228419/" ]
74,130,034
<p>I have a regex function that extracts the numbers before text. But I do it now with hard coded text.</p> <p>But is it also possible to extract the numbers regardless of the text.</p> <p>So I have this example string:</p> <pre><code>text = &quot;[' \n\na)\n\n \n\nFactuur\nVerdi Import Schoolfruit\nFactuur nr. : 71201 Koopliedenweg 33\nDeb. nr. : 108636 2991 LN BARENDRECHT\nYour VAT nr. : NL851703884B01 Nederland\nFactuur datum : 10-12-21\nAantal Omschrijving Prijs Bedrag\nOrder number : 77553 Loading date : 09-12-21 Incoterm: : FOT\nYour ref. : SCHOOLFRUIT Delivery date :\nWK50\nD.C. Schoolfruit\n16 Watermeloenen Quetzali 16kg 4 IMPERIAL BR I € 7,70 € 123,20\n360 Watermeloenen Quetzali 16kg 4 IMPERIAL BR I € 7,70 € 2.772,00\n6 Watermeloenen Quetzali 16kg 4 IMPERIAL BR I € 7,/0 € 46,20\n75 Watermeloenen Quetzali 16kg 4 IMPERIAL BR I € 7,70 € 577,50\n9 Watermeloenen Quetzali 16kg 4 IMPERIAL BR I € 7,70 € 69,30\n688 Appels Royal Gala 13kg 60/65 Generica PL I € 5,07 € 3.488,16\n22 Sinaasappels Valencias 15kg 105 Elara ZAI € 6,25 € 137,50\n80 Sinaasappels Valencias 15kg 105 Elara ZAI € 6,25 € 500,00\n160 Sinaasappels Valencias 15kg 105 FVC ZAI € 6,25 € 1.000,00\n320 Sinaasappels Valencias 15kg 105 Generica ZAI € 6,25 € 2.000,00\n160 Sinaasappels Valencias 15kg 105 Noordhoek ZA I € 6,25 € 1.000,00\n61 Sinaasappels Valencias 15kg 105 Noordhoek ZA I € 6,25 € 381,25\nTotaal Colli Totaal Netto Btw Btw Bedrag Totaal Bedrag\n€ 12.095,11 1.088,56\nBetaling binnen 30 dagen\nAchterstand wordt gemeld bij de kredietverzekeringsmaatschappij\nVerDi Import BV ING Bank NV. Rotterdam IBAN number: NL17INGB0006959173 ~~\n\n \n\nKoopliedenweg 38, 2991 LN Barendrecht, The Netherlands SWIFT/BIC: INGBNL2A, VAT number: NL851703884B01 i\nTel, +31 (0}1 80 61 88 11, Fax +31 (0)1 8061 88 25 Chamber of Commerce Rotterdam no. 55424309 VerDi\n\nE-mail: sales@verdiimport.nl, www.verdiimport.nl Dutch law shall apply. The Rotterdam District Court shall have exclusive jurisdiction.\n\nrut ard wegetables\n\x0c']&quot; </code></pre> <p>and I have this as search words :</p> <pre><code>fruit_words = ['Appels', 'Ananas', 'Peen Waspeen', 'Tomaten Cherry', 'Sinaasappels', 'Watermeloenen', 'Rettich'] </code></pre> <p>and this is the regex expression:</p> <pre><code>regex = r&quot;(\d*(?:\.\d+)*)\s*(?:&quot; + '|'.join(re.escape(word) for word in fruit_words) + ')' number_found = re.findall(regex, verdi3) print(number_found) </code></pre> <p>and the output is then like this:</p> <pre><code>['16', '360', '6', '75', '9', '688', '22', '80', '160', '320', '160', '61'] </code></pre> <p>My question: Is it also possible to have the same output but then without the fruit_words?</p> <p>Or mabye without regex?</p> <p>Thank you</p> <p>The problem is. If I have this string. Other factuure. But same structure.</p> <pre><code>text2 = &quot;['A)\n\nFactuur\n\nFactuur nr.\nDeb. nr.\nYour VAT nr.\n\nFactuur datum\n\n72459\n\n108636\nNL851703884B01\n11-01-22\n\nAantal Omschrijving\n\nOrder number\n\nYour ref,\n\nD.C. Schoolfruit\n\n79005 Loading date\nSCHOOLFRUIT Delivery date\nWKO2\n\n782 Peen Breek peen 10xikg B Rabbit NLI\n138 Mandarijnen Clementinas 10kg 3-140 Black MAI\n450 Mandarijnen Clementinas 10kg 3-140 Black MAI\n486 Sinaasappels Navels 15kg 6-90 Gloriosa MAI\n\n60 Sinaasappels Navels 15kg 6-90 Gloriosa MA I\n\nVerDi\nVerDi\nVerDi\n\nTotaal Colli\n\n1.916\n\nVerDi Import BV\n\nKoopliedenweg 38, 2991 LN Barendrecht, The Netherlands\nTel. +31 (0)1 80 61 88 11, Fax +31 (0)1 8061 88 25\nE-mail: sales@verdiimport.nl, www.verdiimport.nl\n\nMidden Zuid Noord\nMandarijn 195 158 235\nWortel 202 164 416\nSinaas 302 244 0\n\nTotaal Netto\n\n€ 12.474,40\n\nVerdi Import Schoolfruit\nKoopliedenweg 38\n2991 LN BARENDRECHT\n\nNederland\nPrijs\n\n10-01-22 Incoterm: : FOT\n€ 4,70\n€ 8,00\n€ 8,00\n€ 7,50\n€ 7,50\n\n588\n\n782\n\n546\n\nBtw Btw Bedrag\n\nBedrag\n\n€ 3.675,40\n€ 1.104,00\n€ 3.600,00\n€ 3.645,00\n€ 450,00\n\nTotaal Bedrag\n\n€ 1.122,70 € 13.597,10\n\n \n\nBetaling binnen 30 dagen\nAchterstand wordt gemeld bij de kredietverzekeringsmaatschappij\n\nING Bank N.V. Rotterdam IBAN number: NL17INGB0006959173\n\nSWIFT/BIC: INGBNL2A, VAT number: NL851703884B01\nChamber of Commerce Rotterdam no, 55424309\nDutch law shall apply. The Rotterdam District Court shall have exclusive jurisdiction.\n\nSas?\nVerDi\n\nfruit and vegetables\n\x0c']&quot; </code></pre> <p>Then the output is this:</p> <pre><code>['72459', '108636', '11-01-22', '79005', '782', '138', '450', '486', '60', '1.916', '2991', '10-01-22', '588', '782', '546'] </code></pre> <p>What of course is wrong. Because I only want the numbers before the fruit sort, so for example:</p> <pre><code>522 Sinaasappels Navelinas 15kg </code></pre> <p>number with . is not included. Like in this string:</p> <pre><code>text3 = '[&quot;a(S (&gt;)\n\n \n\n \n \n\n \n\n \n\n \n\nFactuur\nVerdi Import Schoolfruit\nFactuur nr. + 71257 Koopliedenweg 38\nDeb. nr. : 108636 2991 LN BARENDRECHT\nYour VAT nr. : NL851703884B01 Nederland\nFactuur datum : 13-12-21\nAantal Omschrijving Prijs Bedrag\nOrdernumber : 76929 Loading date : 29-11-21 Incoterm: : FOT\nYour ref, : Delivery date :\nD.C. Schoolfruit\n705 Appels Royal Gala 13kq 60/65 Generica PL I € 4,68 € 3.299,40\nOrder number : 76643 Loading date : 25-11-21 Incoterm: : FRA\nYour ref. : Delivery date\nD.C, Schoolfruit\n1.712 Tomaten Cherry pruim 4kg Los Cherie MA I € 2,25 € 3.852,00\n80 Sinaasappels Midnights 15kg 105 BIG 5 ZAI € 6,50 € 520,00\n240 Sinaasappels Midnights 15kg 105 Noordhoek ZAI € 6,50 € 1.560,00\n8 Sinaasappels Valencias 15kg 105 Limpopo ZAI € 6,50 € 52,00\n160 Sinaasappels Valencias 15kg 105 Noordhoek ZAI € 6,50 € 1.040,00\n320 Sinaasappels Valencias 15kg 105 Noordhoek ZAI € 6,50 € 2.080,00\nSINAAS:\nMIDDEN 267 pcm\nNOORD 325 2%; oe\nZUID 216 PARTUNUMMER\nTOTAAL: 808 | DATUN Bi r|\nCHERRY:\nMIDDEN 564\nNOORD 693\nZUID 455\nTOTAAL: 1712 ee\nBETALING\nTotaal Colli Totaal Bedrag\n\n \n \n \n\n€ 13.519,71\n\n \n \n\nBetaling binnen 30 dagen\nAchterstand wordt gemeld bij de kredietverzekeringsmaatschappij\n\nails,\nVerDi Import BV ING Bank N.V. Rotterdam IBAN number: NL17INGB0006959173 —\nKoopliedenweg 38, 2991 LN Barendrecht, The Netherlands SWIFT/BIC: INGBNL2A, VAT number: NL851703884B01 a\nTel. +31 (0)1 80 61 88 11, Fax +31 (0)1 8061 88 25 Chamber of Commerce Rotterdam no, 55424309 VerDi\n\nE-mail: sales@verdiimport.nl, www.verdiimport.nl Dutch law shall apply. The Rotterdam District Court shall have exclusive jurisdiction,\n\nfret and vegetan&quot;]' </code></pre> <p>I try it with this text:</p> <pre><code>verdi48 = '[&quot;a(S (&gt;)\n\n \n\n \n \n\n \n\n \n\n \n\nFactuur\nVerdi Import Schoolfruit\nFactuur nr. + 71257 Koopliedenweg 38\nDeb. nr. : 108636 2991 LN BARENDRECHT\nYour VAT nr. : NL851703884B01 Nederland\nFactuur datum : 13-12-21\nAantal Omschrijving Prijs Bedrag\nOrdernumber : 76929 Loading date : 29-11-21 Incoterm: : FOT\nYour ref, : Delivery date :\nD.C. Schoolfruit\n705 Appels Royal Gala 13kq 60/65 Generica PL I € 4,68 € 3.299,40\nOrder number : 76643 Loading date : 25-11-21 Incoterm: : FRA\nYour ref. : Delivery date\nD.C, Schoolfruit\n1.712 Tomaten Cherry pruim 4kg Los Cherie MA I € 2,25 € 3.852,00\n80 Sinaasappels Midnights 15kg 105 BIG 5 ZAI € 6,50 € 520,00\n240 Sinaasappels Midnights 15kg 105 Noordhoek ZAI € 6,50 € 1.560,00\n8 Sinaasappels Valencias 15kg 105 Limpopo ZAI € 6,50 € 52,00\n160 Sinaasappels Valencias 15kg 105 Noordhoek ZAI € 6,50 € 1.040,00\n320 Sinaasappels Valencias 15kg 105 Noordhoek ZAI € 6,50 € 2.080,00\nSINAAS:\nMIDDEN 267 pcm\nNOORD 325 2%; oe\nZUID 216 PARTUNUMMER\nTOTAAL: 808 | DATUN Bi r|\nCHERRY:\nMIDDEN 564\nNOORD 693\nZUID 455\nTOTAAL: 1712 ee\nBETALING\nTotaal Colli Totaal Bedrag\n\n \n \n \n\n€ 13.519,71\n\n \n \n\nBetaling binnen 30 dagen\nAchterstand wordt gemeld bij de kredietverzekeringsmaatschappij\n\nails,\nVerDi Import BV ING Bank N.V. Rotterdam IBAN number: NL17INGB0006959173 —\nKoopliedenweg 38, 2991 LN Barendrecht, The Netherlands SWIFT/BIC: INGBNL2A, VAT number: NL851703884B01 a\nTel. +31 (0)1 80 61 88 11, Fax +31 (0)1 8061 88 25 Chamber of Commerce Rotterdam no, 55424309 VerDi\n\nE-mail: sales@verdiimport.nl, www.verdiimport.nl Dutch law shall apply. The Rotterdam District Court shall have exclusive jurisdiction,\n\nfret and vegetan&quot;]' </code></pre> <p>But that doesn't work.</p> <p>I get 100 times no match.</p> <p>This is the string:</p> <pre><code>text4 = '[&quot;a(S (&gt;)\n\n \n\n \n \n\n \n\n \n\n \n\nFactuur\nVerdi Import Schoolfruit\nFactuur nr. + 71257 Koopliedenweg 38\nDeb. nr. : 108636 2991 LN BARENDRECHT\nYour VAT nr. : NL851703884B01 Nederland\nFactuur datum : 13-12-21\nAantal Omschrijving Prijs Bedrag\nOrdernumber : 76929 Loading date : 29-11-21 Incoterm: : FOT\nYour ref, : Delivery date :\nD.C. Schoolfruit\n705 Appels Royal Gala 13kq 60/65 Generica PL I € 4,68 € 3.299,40\nOrder number : 76643 Loading date : 25-11-21 Incoterm: : FRA\nYour ref. : Delivery date\nD.C, Schoolfruit\n1.712 Tomaten Cherry pruim 4kg Los Cherie MA I € 2,25 € 3.852,00\n80 Sinaasappels Midnights 15kg 105 BIG 5 ZAI € 6,50 € 520,00\n240 Sinaasappels Midnights 15kg 105 Noordhoek ZAI € 6,50 € 1.560,00\n8 Sinaasappels Valencias 15kg 105 Limpopo ZAI € 6,50 € 52,00\n160 Sinaasappels Valencias 15kg 105 Noordhoek ZAI € 6,50 € 1.040,00\n320 Sinaasappels Valencias 15kg 105 Noordhoek ZAI € 6,50 € 2.080,00\nSINAAS:\nMIDDEN 267 pcm\nNOORD 325 2%; oe\nZUID 216 PARTUNUMMER\nTOTAAL: 808 | DATUN Bi r|\nCHERRY:\nMIDDEN 564\nNOORD 693\nZUID 455\nTOTAAL: 1712 ee\nBETALING\nTotaal Colli Totaal Bedrag\n\n \n \n \n\n€ 13.519,71\n\n \n \n\nBetaling binnen 30 dagen\nAchterstand wordt gemeld bij de kredietverzekeringsmaatschappij\n\nails,\nVerDi Import BV ING Bank N.V. Rotterdam IBAN number: NL17INGB0006959173 —\nKoopliedenweg 38, 2991 LN Barendrecht, The Netherlands SWIFT/BIC: INGBNL2A, VAT number: NL851703884B01 a\nTel. +31 (0)1 80 61 88 11, Fax +31 (0)1 8061 88 25 Chamber of Commerce Rotterdam no, 55424309 VerDi\n\nE-mail: sales@verdiimport.nl, www.verdiimport.nl Dutch law shall apply. The Rotterdam District Court shall have exclusive jurisdiction,\n\nfret and vegetan&quot;]' </code></pre> <p>Then it prints this:</p> <pre><code>['705', '80', '240', '8', '160', '320'] </code></pre> <p>It is missing the number: 1.712</p> <p>and If I have this string:</p> <pre><code>verdi2 = &quot;['A)\n\nFactuur\n\nFactuur nr.\nDeb. nr.\nYour VAT nr.\n\nFactuur datum\n\n72459\n\n108636\nNL851703884B01\n11-01-22\n\nAantal Omschrijving\n\nOrder number\n\nYour ref,\n\nD.C. Schoolfruit\n\n79005 Loading date\nSCHOOLFRUIT Delivery date\nWKO2\n\n782 Peen Breek peen 10xikg B Rabbit NLI\n138 Mandarijnen Clementinas 10kg 3-140 Black MAI\n450 Mandarijnen Clementinas 10kg 3-140 Black MAI\n486 Sinaasappels Navels 15kg 6-90 Gloriosa MAI\n\n60 Sinaasappels Navels 15kg 6-90 Gloriosa MA I\n\nVerDi\nVerDi\nVerDi\n\nTotaal Colli\n\n1.916\n\nVerDi Import BV\n\nKoopliedenweg 38, 2991 LN Barendrecht, The Netherlands\nTel. +31 (0)1 80 61 88 11, Fax +31 (0)1 8061 88 25\nE-mail: sales@verdiimport.nl, www.verdiimport.nl\n\nMidden Zuid Noord\nMandarijn 195 158 235\nWortel 202 164 416\nSinaas 302 244 0\n\nTotaal Netto\n\n€ 12.474,40\n\nVerdi Import Schoolfruit\nKoopliedenweg 38\n2991 LN BARENDRECHT\n\nNederland\nPrijs\n\n10-01-22 Incoterm: : FOT\n€ 4,70\n€ 8,00\n€ 8,00\n€ 7,50\n€ 7,50\n\n588\n\n782\n\n546\n\nBtw Btw Bedrag\n\nBedrag\n\n€ 3.675,40\n€ 1.104,00\n€ 3.600,00\n€ 3.645,00\n€ 450,00\n\nTotaal Bedrag\n\n€ 1.122,70 € 13.597,10\n\n \n\nBetaling binnen 30 dagen\nAchterstand wordt gemeld bij de kredietverzekeringsmaatschappij\n\nING Bank N.V. Rotterdam IBAN number: NL17INGB0006959173\n\nSWIFT/BIC: INGBNL2A, VAT number: NL851703884B01\nChamber of Commerce Rotterdam no, 55424309\nDutch law shall apply. The Rotterdam District Court shall have exclusive jurisdiction.\n\nSas?\nVerDi\n\nfruit and vegetables\n\x0c']&quot; </code></pre> <p>Then it retuns also the factuur number. What not has to be.</p> <p>Only the numbers with fruit after the nunmber has to be returned. So the line with the €.</p>
[ { "answer_id": 74130133, "author": "Алексей Р", "author_id": 15035314, "author_profile": "https://Stackoverflow.com/users/15035314", "pm_score": 1, "selected": false, "text": "\\n" }, { "answer_id": 74130705, "author": "Dev", "author_id": 13182358, "author_profile": "...
2022/10/19
[ "https://Stackoverflow.com/questions/74130034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7713770/" ]
74,130,038
<p>I have two controllers (FirstController, SecondController) that use the same functions, to avoid rewriting them I thought of creating another controller (ThirdController) and subsequently calling the functions through it.</p> <p>the problem is that if in ThirdController there are relationship query they give me the error that &quot;they don't exist&quot;.</p> <p>example:</p> <blockquote> <p>User Model</p> </blockquote> <pre><code>class User extends Authenticatable implements AuthenticatableUserContract { use HasFactory, Notifiable; public function comments(){ return $this-&gt;hasMany('App\Models\Comment'); } </code></pre> <blockquote> <p>ThirdController</p> </blockquote> <pre><code>class ThirdController extends Controller { public static function example($id){ $comments = Comment::find($id)-&gt;comments(); return $comments; } } </code></pre> <blockquote> <p>FirstController/SecondController</p> </blockquote> <pre><code>public function example2(Request $request){ return ThirdController::example($request-&gt;id); </code></pre> <p>When call the route it give me error: BadMethodCallException: Method Illuminate\Database\Eloquent\Collection::comments does not exist.</p> <p>my questions are:</p> <ol> <li><p>Is there any better method instead of creating a third controller?</p> </li> <li><p>Is there a solution to this?</p> </li> </ol> <p>p.s. I know I could very well build the queries without exploiting the relationship, but where's the beauty of that? :D</p>
[ { "answer_id": 74130133, "author": "Алексей Р", "author_id": 15035314, "author_profile": "https://Stackoverflow.com/users/15035314", "pm_score": 1, "selected": false, "text": "\\n" }, { "answer_id": 74130705, "author": "Dev", "author_id": 13182358, "author_profile": "...
2022/10/19
[ "https://Stackoverflow.com/questions/74130038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18365403/" ]
74,130,047
<p>So I tried using this block of code but what it does is it puts the items from resources index 0 and 1 into both variables on the first iteration. I want a way to where resources will map to alph and range will map to i. Is this possible in python?</p> <pre class="lang-py prettyprint-override"><code>resources = [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;] for alph, i in resources, range(len(resources)): print(alph) if i == 2: print(2) </code></pre> <p>I'm basically looking for something similar to golang's range where you would type</p> <pre class="lang-golang prettyprint-override"><code>resources := [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;] for incrementer, alph := range resources { fmt.Print(alph) if i == 2 { fmt.Print(2) } } </code></pre>
[ { "answer_id": 74130083, "author": "treuss", "author_id": 19838568, "author_profile": "https://Stackoverflow.com/users/19838568", "pm_score": 1, "selected": false, "text": "resources = [\"a\", \"b\", \"c\"]\nfor i, alph in enumerate(resources):\n ...\n" }, { "answer_id": 74130...
2022/10/19
[ "https://Stackoverflow.com/questions/74130047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14307694/" ]
74,130,077
<p>I can't seem to make my watch WidgetKit complication to show while the device is locked. This is done in the weather complication and can be seen if you take off your watch and set it down, but my widget is redacted until unlocked.</p> <p>I tried adding <code>.unredacted</code> to my root widget view but same behaviour. Is this something I can do from the app code or is this only controlled by the user? I don't remember setting this on the weather complication so I thought it set itself as public which is what I would like to do. It is not clear how to achieve this <a href="https://developer.apple.com/documentation/watchOS-Apps/designing-your-app-for-the-always-on-state" rel="nofollow noreferrer">in the docs</a>.</p>
[ { "answer_id": 74240131, "author": "Reinhard Männer", "author_id": 1987726, "author_profile": "https://Stackoverflow.com/users/1987726", "pm_score": 2, "selected": true, "text": "@main\nstruct ShopEasy_Widgets: Widget {\n let kind: String = \"ShopEasy__WidgetKit_Extension\"\n \n ...
2022/10/19
[ "https://Stackoverflow.com/questions/74130077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/235334/" ]
74,130,093
<p>I saw a lot of codes that use <code>Type hints</code></p> <p>and some of them use <strong>python built-in object</strong> as their type annotations and some of them use <strong>typing module</strong> for their type annotations</p> <p>But what is the differences between <code>python objects</code> and <code>typing module</code></p> <p>It's better to say when to use <em>python object</em> as <strong>type hints</strong> and when to use <em>typing module</em> as <strong>type hints</strong></p> <p>for example what is the differences between bellow codes?</p> <pre><code># first code def message_users(users: list[str], msg: str) -&gt; None: for user in users: print(f'User: {user} -&gt; {msg}') # second code from typing import List def message_users(users: List[str], msg: str) -&gt; None: for user in users: print(f'User: {user} -&gt; {msg}') </code></pre> <p>And other types like <em>typing.NamedTuple</em> or <em>collections.namedtuple</em>? Which is better to use?</p>
[ { "answer_id": 74130399, "author": "scotscotmcc", "author_id": 15804190, "author_profile": "https://Stackoverflow.com/users/15804190", "pm_score": 1, "selected": false, "text": "typing.List" } ]
2022/10/19
[ "https://Stackoverflow.com/questions/74130093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14689782/" ]
74,130,118
<p>I want to make div with gradient box shadow. And I have found how to do with :before and blur effect... But I want to make div with transparent background. For example</p> <pre><code>div{ height:200px; width:200px; background-color: rgba(255,255,255,0.3) } div::before{ content:''; z-index: -1; position: absolute; width: 100%; height: 100%; background: linear-gradient(#e66465, #9198e5); filter: blur(10px) } </code></pre> <p>Is it some way to make the before element invisible in place where is the main element?</p>
[ { "answer_id": 74130160, "author": "Abdul Nafay", "author_id": 18909135, "author_profile": "https://Stackoverflow.com/users/18909135", "pm_score": -1, "selected": false, "text": "Position: abosolute; and Contact:\"\"; to position: absolute; content: ''\n" }, { "answer_id": 741303...
2022/10/19
[ "https://Stackoverflow.com/questions/74130118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19733178/" ]
74,130,125
<p>I know there are lot of questions about removing duplicates from pandas dataframe but this is bit different.</p> <p>I am trying to remove duplicates from the dataframe but not getting the actual output as in the below given result dataframe. Actually the data in table is too long. For understanding purpose I have given the dummy data here in the table.</p> <p><strong>Condition:-</strong></p> <p>I need to remove duplicates and get the rows that contain max value from <strong>diast</strong> column.</p> <p>Is there a good way to get result dataframe using given df.</p> <p>Any help would be appreciated. Thanks :)</p> <p><strong>DF:-</strong></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">age</th> <th style="text-align: center;">syst</th> <th style="text-align: center;">diast</th> <th style="text-align: center;">a</th> <th style="text-align: center;">b</th> <th style="text-align: center;">c</th> <th style="text-align: center;">d</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">29</td> <td style="text-align: center;">90</td> <td style="text-align: center;">57</td> <td style="text-align: center;">MO</td> <td style="text-align: center;">MO</td> <td style="text-align: center;">0</td> <td style="text-align: center;">MO</td> </tr> <tr> <td style="text-align: left;">29</td> <td style="text-align: center;">90</td> <td style="text-align: center;">58</td> <td style="text-align: center;">MO</td> <td style="text-align: center;">MO</td> <td style="text-align: center;">0</td> <td style="text-align: center;">MO</td> </tr> <tr> <td style="text-align: left;">29</td> <td style="text-align: center;">90</td> <td style="text-align: center;">59</td> <td style="text-align: center;">MO</td> <td style="text-align: center;">MO</td> <td style="text-align: center;">0</td> <td style="text-align: center;">MO</td> </tr> <tr> <td style="text-align: left;">29</td> <td style="text-align: center;">90</td> <td style="text-align: center;">60</td> <td style="text-align: center;">MO</td> <td style="text-align: center;">MO</td> <td style="text-align: center;">0</td> <td style="text-align: center;">MO</td> </tr> <tr> <td style="text-align: left;">29</td> <td style="text-align: center;">90</td> <td style="text-align: center;">61</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> </tr> <tr> <td style="text-align: left;">29</td> <td style="text-align: center;">90</td> <td style="text-align: center;">62</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> </tr> <tr> <td style="text-align: left;">29</td> <td style="text-align: center;">90</td> <td style="text-align: center;">63</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> </tr> <tr> <td style="text-align: left;">29</td> <td style="text-align: center;">90</td> <td style="text-align: center;">64</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> </tr> <tr> <td style="text-align: left;">29</td> <td style="text-align: center;">90</td> <td style="text-align: center;">65</td> <td style="text-align: center;">MO</td> <td style="text-align: center;">MO</td> <td style="text-align: center;">0</td> <td style="text-align: center;">MO</td> </tr> <tr> <td style="text-align: left;">29</td> <td style="text-align: center;">90</td> <td style="text-align: center;">66</td> <td style="text-align: center;">MO</td> <td style="text-align: center;">MO</td> <td style="text-align: center;">0</td> <td style="text-align: center;">MO</td> </tr> <tr> <td style="text-align: left;">29</td> <td style="text-align: center;">90</td> <td style="text-align: center;">67</td> <td style="text-align: center;">MO</td> <td style="text-align: center;">MO</td> <td style="text-align: center;">0</td> <td style="text-align: center;">MO</td> </tr> <tr> <td style="text-align: left;">29</td> <td style="text-align: center;">90</td> <td style="text-align: center;">68</td> <td style="text-align: center;">MO</td> <td style="text-align: center;">MO</td> <td style="text-align: center;">0</td> <td style="text-align: center;">MO</td> </tr> </tbody> </table> </div> <p><strong>Result:-</strong></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">age</th> <th style="text-align: center;">syst</th> <th style="text-align: center;">diast</th> <th style="text-align: center;">a</th> <th style="text-align: center;">b</th> <th style="text-align: center;">c</th> <th style="text-align: center;">d</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">29</td> <td style="text-align: center;">90</td> <td style="text-align: center;">60</td> <td style="text-align: center;">MO</td> <td style="text-align: center;">MO</td> <td style="text-align: center;">0</td> <td style="text-align: center;">MO</td> </tr> <tr> <td style="text-align: left;">29</td> <td style="text-align: center;">90</td> <td style="text-align: center;">64</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> <td style="text-align: center;">0</td> </tr> <tr> <td style="text-align: left;">29</td> <td style="text-align: center;">90</td> <td style="text-align: center;">68</td> <td style="text-align: center;">MO</td> <td style="text-align: center;">MO</td> <td style="text-align: center;">0</td> <td style="text-align: center;">MO</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74130160, "author": "Abdul Nafay", "author_id": 18909135, "author_profile": "https://Stackoverflow.com/users/18909135", "pm_score": -1, "selected": false, "text": "Position: abosolute; and Contact:\"\"; to position: absolute; content: ''\n" }, { "answer_id": 741303...
2022/10/19
[ "https://Stackoverflow.com/questions/74130125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16255047/" ]
74,130,126
<p>I have Data Grouped in Power Query by Vendor and Month, aggregating total spend. I want to Transpose the Month Column such that the intersection of the Vendor row and the Month Column represent the spend by the given vendor in the given month.</p> <p>How Data Looks:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>New_Vendor</th> <th>MONTH</th> <th>Amount</th> </tr> </thead> <tbody> <tr> <td>VEND1</td> <td>1/31/2022</td> <td>1000</td> </tr> <tr> <td>VEND1</td> <td>2/28/2022</td> <td>900</td> </tr> <tr> <td>VEND2</td> <td>1/31/2022</td> <td>500</td> </tr> <tr> <td>VEND2</td> <td>2/28/2022</td> <td>300</td> </tr> <tr> <td>VEND2</td> <td>3/31/2022</td> <td>1500</td> </tr> <tr> <td>VEND3</td> <td>6/30/2022</td> <td>600</td> </tr> </tbody> </table> </div> <p>How I want it to look:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>New_Vendor</th> <th>1/31/2022</th> <th>2/28/2022</th> <th>3/31/2022</th> <th>6/30/2022</th> </tr> </thead> <tbody> <tr> <td>VEND1</td> <td>1000</td> <td>900</td> <td>0</td> <td>0</td> </tr> <tr> <td>VEND2</td> <td>500</td> <td>300</td> <td>1500</td> <td>0</td> </tr> <tr> <td>VEND3</td> <td>0</td> <td>0</td> <td>0</td> <td>600</td> </tr> </tbody> </table> </div> <p>I have played around with pivoting and unpivoting columns and managed to promote the month column to headers, but the amount column still is its own and all that shows up under the month headers is 1 or a zero:</p> <p><a href="https://i.stack.imgur.com/0nYJE.png" rel="nofollow noreferrer">POWER QUERY PIVOT COLUMN TO ROWS</a></p> <p>Here is my M Code before I try to pivot:</p> <pre><code>let Source = Excel.CurrentWorkbook(){[Name=&quot;TECH_GL&quot;]}[Content], #&quot;Changed Type&quot; = Table.TransformColumnTypes(Source,{{&quot;Account&quot;, type text}, {&quot;Department&quot;, type text}, {&quot;Posted Dt.&quot;, type datetime}, {&quot;Doc Dt.&quot;, type datetime}, {&quot;Doc&quot;, type text}, {&quot;Memo / Description&quot;, type text}, {&quot;Dep_Num&quot;, Int64.Type}, {&quot;Vendor Name&quot;, type text}, {&quot;Vendor&quot;, type text}, {&quot;JNL&quot;, type text}, {&quot;Curr&quot;, type text}, {&quot;Txn Amt&quot;, type number}, {&quot;Debit (USD)&quot;, type number}, {&quot;Credit (USD)&quot;, type number}, {&quot;Total&quot;, type number}, {&quot;MONTH&quot;, type datetime}, {&quot;New_Account&quot;, type text}, {&quot;New_Department&quot;, type text}, {&quot;New_Vendor&quot;, type text}, {&quot;Notes&quot;, type text}}), #&quot;Grouped Rows&quot; = Table.Group(#&quot;Changed Type&quot;, {&quot;New_Vendor&quot;, &quot;MONTH&quot;}, {{&quot;Amount&quot;, each List.Sum([Total]), type nullable number}}), #&quot;Changed Type1&quot; = Table.TransformColumnTypes(#&quot;Grouped Rows&quot;,{{&quot;MONTH&quot;, type date}}), #&quot;Sorted Rows&quot; = Table.Sort(#&quot;Changed Type1&quot;,{{&quot;New_Vendor&quot;, Order.Ascending}, {&quot;MONTH&quot;, Order.Ascending}}) in #&quot;Sorted Rows&quot; </code></pre>
[ { "answer_id": 74130217, "author": "horseyride", "author_id": 9264230, "author_profile": "https://Stackoverflow.com/users/9264230", "pm_score": 2, "selected": true, "text": "let Source = Excel.CurrentWorkbook(){[Name=\"Table1\"]}[Content],\n#\"Changed Type\" = Table.TransformColumnTypes(...
2022/10/19
[ "https://Stackoverflow.com/questions/74130126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19765660/" ]
74,130,128
<p>I need to change the color of &quot;item.email&quot; to the CSS color text-red-600 if the content of &quot;item.email&quot; includes a space.</p> <pre><code> &lt;div className=&quot;relative text-sm w-64 left-400 style={{item.email}.indexOf(' ') = -1 ? text-gray-600 : text-red-600 }&quot;&gt; {item.email} &lt;/div&gt; </code></pre>
[ { "answer_id": 74130463, "author": "heyitsvajid", "author_id": 6626461, "author_profile": "https://Stackoverflow.com/users/6626461", "pm_score": 1, "selected": false, "text": "<div className={`relative text-sm w-64 left-400 \n${item.email.indexOf(' ') === -1 ? 'text-gray-600' : 'text-red...
2022/10/19
[ "https://Stackoverflow.com/questions/74130128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10443384/" ]
74,130,176
<p>I am trying to give Css style to svg path but don't know exactly how to do it, have tried different way but noting seems to work. Any help will be much Apricated. Thanks in Advance!</p> <p>When Inspecting my SVG element look something as below, I can add stroke color on air like below:</p> <p><a href="https://i.stack.imgur.com/ZQHHC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZQHHC.png" alt="enter image description here" /></a></p> <p>and the stroke color changes of the chevron icon:</p> <p><a href="https://i.stack.imgur.com/nbjze.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nbjze.png" alt="enter image description here" /></a></p> <p>But when use in CSS then I don't see any effect:</p> <pre><code>.is-expanded .icon-2 g &gt; path { stroke: darkred; } </code></pre> <p>I also tried to pass in my Icon component like this and its fails:</p> <pre><code>&lt;div :class=&quot;{ 'is-expanded': rowExpanded }&quot; @click=&quot;handleTest()&quot; &gt; &lt;Icon2 icon=&quot;chevronRight&quot; :color=&quot;rowExpanded ? 'darkred' : 'grey'&quot; /&gt; &lt;/div&gt; </code></pre>
[ { "answer_id": 74130463, "author": "heyitsvajid", "author_id": 6626461, "author_profile": "https://Stackoverflow.com/users/6626461", "pm_score": 1, "selected": false, "text": "<div className={`relative text-sm w-64 left-400 \n${item.email.indexOf(' ') === -1 ? 'text-gray-600' : 'text-red...
2022/10/19
[ "https://Stackoverflow.com/questions/74130176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4183650/" ]
74,130,189
<p>I have a table called <code>activity</code> that contains values like the following:</p> <pre><code>userId | timestamp | action ---------------------------------------- 1 | 2022-10-18 10:00:00 | OPEN 2 | 2022-10-18 10:20:00 | OPEN 1 | 2022-10-18 10:05:00 | CLOSE 2 | 2022-10-18 10:22:00 | CLOSE ... </code></pre> <p>I want to be able to get the difference between the open and close time per user for a given day like so:</p> <pre><code>desiredTable ------------------------------------------------------ userId | start_time | time_elapsed_in_minutes ------------------------------------------------------ 1 | 2022-10-18 10:00:00 | 5 2 | 2022-10-18 10:20:00 | 2 </code></pre> <p>A couple of things to note are:</p> <ol> <li>There is no guarantee <code>OPEN</code> and <code>CLOSE</code> rows will be back to back to each other as the table also holds a lot of other action types.</li> <li>Also, there is no guarantee that there will be the same number of <code>OPEN</code> and <code>CLOSE</code> rows due to network conditions that could result in either not being reported. I.e: user 1 can have 3 opens and 1 close, so only 1 pair needs to be calculated.</li> </ol> <p><strong>My approach</strong>:</p> <ul> <li>create table of OPEN and CLOSE counts per user</li> <li><code>userId | # opens | # closes</code></li> <li>determine which number is less (# opens or # closes) and get that # of rows from the activity table</li> <li>opens table with the # of rows determined above <ul> <li><code>userId | timestamp</code></li> </ul> </li> <li>closes table with the # of rows determined above <ul> <li><code>userId | timestamp</code></li> </ul> </li> <li>subtract close timestamp from open timestamp group by userId and truncate to minutes</li> </ul> <p>Any help would be greatly appreciated!</p>
[ { "answer_id": 74131117, "author": "DannySlor", "author_id": 19174570, "author_profile": "https://Stackoverflow.com/users/19174570", "pm_score": 0, "selected": false, "text": "action = 'close'" }, { "answer_id": 74131251, "author": "DannySlor", "author_id": 19174570, ...
2022/10/19
[ "https://Stackoverflow.com/questions/74130189", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19778758/" ]
74,130,192
<p>I mean the reverse application operator. For example in Haskell it would be <code>&amp;</code>:</p> <pre class="lang-hs prettyprint-override"><code>ghci&gt; import Data.Function ((&amp;)) ghci&gt; 2 &amp; (+ 1) 3 </code></pre> <p>In Raku I saw <code>==&gt;</code> feed operator, but that doesn't seem to work with lambdas?</p> <pre><code>&gt; (* + 1)(2) 3 &gt; 2 ==&gt; (* + 1) ===SORRY!=== Error while compiling: Only routine calls or variables that can '.push' may appear on either side of feed operators. ------&gt; 2 ==&gt; ⏏(* + 1) </code></pre>
[ { "answer_id": 74131294, "author": "wamba", "author_id": 5458086, "author_profile": "https://Stackoverflow.com/users/5458086", "pm_score": 5, "selected": true, "text": "==>" }, { "answer_id": 74134872, "author": "jubilatious1", "author_id": 7270649, "author_profile": ...
2022/10/19
[ "https://Stackoverflow.com/questions/74130192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9160022/" ]
74,130,237
<p>Let's say I have a dataframe, df_products, like this one:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">product_id</th> <th style="text-align: center;">version</th> <th style="text-align: center;">month</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">1111</td> <td style="text-align: center;">v1</td> <td style="text-align: center;">jan</td> </tr> <tr> <td style="text-align: left;">1111</td> <td style="text-align: center;">v2</td> <td style="text-align: center;">feb</td> </tr> <tr> <td style="text-align: left;">1111</td> <td style="text-align: center;">v2</td> <td style="text-align: center;">jan</td> </tr> <tr> <td style="text-align: left;">2222</td> <td style="text-align: center;">v1</td> <td style="text-align: center;">mar</td> </tr> <tr> <td style="text-align: left;">3333</td> <td style="text-align: center;">v2</td> <td style="text-align: center;">jan</td> </tr> <tr> <td style="text-align: left;">3333</td> <td style="text-align: center;">v2</td> <td style="text-align: center;">dec</td> </tr> <tr> <td style="text-align: left;">4444</td> <td style="text-align: center;">v1</td> <td style="text-align: center;">jun</td> </tr> <tr> <td style="text-align: left;">4444</td> <td style="text-align: center;">v1</td> <td style="text-align: center;">jan</td> </tr> <tr> <td style="text-align: left;">4444</td> <td style="text-align: center;">v2</td> <td style="text-align: center;">jun</td> </tr> </tbody> </table> </div> <p>How can I filter it to get only the product_ids that have at least one v1 AND one v2 in the version column? I'd like to get something like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">product_id</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">1111</td> </tr> <tr> <td style="text-align: left;">4444</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74131294, "author": "wamba", "author_id": 5458086, "author_profile": "https://Stackoverflow.com/users/5458086", "pm_score": 5, "selected": true, "text": "==>" }, { "answer_id": 74134872, "author": "jubilatious1", "author_id": 7270649, "author_profile": ...
2022/10/19
[ "https://Stackoverflow.com/questions/74130237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11036109/" ]
74,130,243
<p>While creating a node, I am required to input entity reference ID in the <strong>field_tag</strong>. The problem is that I only have entity reference name.</p> <p>How can I get the term id (tid) for a taxonomy term from the term name?</p> <p>I'm very surprised that I can't find an answer anywhere, since this seems to me to be a simple, basic question.</p> <pre><code> $node = Node::create([ 'type' =&gt; 'news', 'title' =&gt; $naslov, 'body' =&gt; $tekst, 'field_tag' =&gt; // Taxonomy reference name is &quot;ostalo&quot;, I need it's ID here ], ); $node-&gt;save(); </code></pre>
[ { "answer_id": 74132222, "author": "2pha", "author_id": 1550696, "author_profile": "https://Stackoverflow.com/users/1550696", "pm_score": 1, "selected": false, "text": "$tids = taxonomy_term_load_multiple_by_name('ostalo');" }, { "answer_id": 74138042, "author": "Balde Binos"...
2022/10/19
[ "https://Stackoverflow.com/questions/74130243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18457389/" ]
74,130,245
<p>I am trying to send the failed values to a <strong>CSV</strong> file but it's only giving me the last failed value in the list.</p> <pre><code>print((&quot;Folder\t&quot;+ &quot;Expected\t&quot;+ &quot;Actual\t&quot;+&quot;Result&quot;).expandtabs(20)) for key in expected: expectedCount = str(expected[key]) actualCount = &quot;0&quot; if key in newDictionary: actualCount = str(newDictionary[key]) elif expectedCount == actualCount: result = &quot;Pass&quot; else: result = &quot;Fail&quot; with open('XML Output.csv', 'w',encoding='utf-8', newline=&quot;&quot;) as csvfile: header = ['Folder', 'Expected', 'Actual','Result'] my_writer = csv.writer(csvfile) my_writer.writerow(header) my_writer.writerow([key, expectedCount, actualCount, result]) csvfile.close() print((key + &quot;\t&quot;+expectedCount+ &quot;\t&quot;+actualCount+ &quot;\t&quot;+result).expandtabs(20)) print(&quot;======================== Data Exported to CSV file ========================&quot;) </code></pre> <p><strong>Output:</strong></p> <p>Folder Expected Actual Result</p> <p>D 2 1 Fail</p> <p><strong>Here is what the output should be:</strong></p> <p>Folder Expected Actual Result</p> <blockquote> <p>A 2 1 Fail</p> </blockquote> <blockquote> <p>B 2 1 Fail</p> </blockquote> <blockquote> <p>C 2 1 Fail</p> </blockquote> <blockquote> <p>D 2 1 Fail</p> </blockquote>
[ { "answer_id": 74130568, "author": "Aechrok", "author_id": 14172999, "author_profile": "https://Stackoverflow.com/users/14172999", "pm_score": 1, "selected": false, "text": "with open" }, { "answer_id": 74130598, "author": "Community", "author_id": -1, "author_profile...
2022/10/19
[ "https://Stackoverflow.com/questions/74130245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8264846/" ]
74,130,249
<p>I'm looking for a way in javascript to transform this json to something else.</p> <pre><code>{ &quot;John Doe&quot;: { &quot;place&quot;: &quot;Amsterdam&quot; }, &quot;Jane Doe&quot;: { &quot;place&quot;: &quot;Paris&quot; } } </code></pre> <p>To something like this:</p> <pre><code>{ { &quot;id&quot;: 0, &quot;name&quot;: &quot;John Doe&quot;, &quot;place&quot;: &quot;Amsterdam&quot; }, { &quot;id&quot;: 1, &quot;name&quot;: &quot;Jane Doe&quot;, &quot;place&quot;: &quot;Paris&quot; }, } </code></pre> <p>How can I achieve this with javascript?</p>
[ { "answer_id": 74130568, "author": "Aechrok", "author_id": 14172999, "author_profile": "https://Stackoverflow.com/users/14172999", "pm_score": 1, "selected": false, "text": "with open" }, { "answer_id": 74130598, "author": "Community", "author_id": -1, "author_profile...
2022/10/19
[ "https://Stackoverflow.com/questions/74130249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14053732/" ]
74,130,250
<p>An iOS/Swift library delivers a <code>Data</code> object containing a null terminated string. When converting it to a <code>String</code> by calling <code>String(data: dataInstance, encoding: .utf8)</code>, the returned <code>String</code> ends with <code>&quot;\0&quot;</code>. Question now is, how do you convert the <code>Data</code> instance to a <code>String</code> without having &quot;\0&quot; appended? I.e. how can you omit the null terminating character at the end?</p> <p>Trying to just <code>.trimmingCharacters(in: .whitespacesAndNewlines)</code> doesn't have any effect, so your advise is very much appreciated. Thank you.</p>
[ { "answer_id": 74130409, "author": "Martin R", "author_id": 1187415, "author_profile": "https://Stackoverflow.com/users/1187415", "pm_score": 3, "selected": true, "text": "let data = Data([65, 66, 0, 67, 0])\nlet end = data.firstIndex(where: { $0 == 0 }) ?? data.endIndex\nif let string =...
2022/10/19
[ "https://Stackoverflow.com/questions/74130250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3921848/" ]
74,130,286
<p>i'm trying to create a delay print function (print a character of a string every second).</p> <p>my code is:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;string.h&gt; #include &lt;windows.h&gt; void delayPrint(char* s); int main(int argc, char * argv[]) { delayPrint(&quot;ciao&quot;); return 0; } void delayPrint(char* s) { for (int i=0; i&lt;strlen(s); i++) { Sleep(1); printf(&quot;%s&quot;, s[i]); } } </code></pre> <p>I can't print a specific character of a string: i can print the entire string in the displayPrint function. Now the function simply does nothing.</p> <p>I can't understand the problem (Windows 11, mingw) Anyone can help?</p>
[ { "answer_id": 74130419, "author": "amanshri93", "author_id": 2173281, "author_profile": "https://Stackoverflow.com/users/2173281", "pm_score": 2, "selected": false, "text": "printf(\"%c\", s[i]);\n" }, { "answer_id": 74130451, "author": "Özgür Güzeldereli", "author_id": ...
2022/10/19
[ "https://Stackoverflow.com/questions/74130286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19853453/" ]
74,130,314
<p>I have the following code:</p> <pre><code>library(quantmod) AAPL_dividend&lt;-getDividends(&quot;AAPL&quot;,from='2017-01-01',to='2022-01-01') getSymbols(&quot;AAPL&quot;,from='2017-01-01',to='2022-01-01') AAPL_Price&lt;-AAPL$AAPL.Close </code></pre> <p>What I would like to do here is that, under the time frame, I would like to locate the stock price from AAPL_Price with respect to the dividend payout date from AAPL_dividend. May I know if there is such a function to do so? Thanks a lot.</p>
[ { "answer_id": 74130330, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 2, "selected": true, "text": "merge" }, { "answer_id": 74131219, "author": "Joshua Ulrich", "author_id": 271616, "author_profile"...
2022/10/19
[ "https://Stackoverflow.com/questions/74130314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16601198/" ]
74,130,326
<p>type of data</p> <blockquote> <p>&lt;class 'collections.OrderedDict'&gt;</p> </blockquote> <pre><code> if(&quot;a&quot; not in data or &quot;b&quot; not in data or &quot;c&quot; not in data or &quot;d&quot; not in data or &quot;e&quot; not in data or &quot;f&quot; not in data or &quot;g&quot; not in data or &quot;h&quot; not in data or &quot;i&quot; not in data): raise serializers.ValidationError(&quot;All Required Parameters not provided&quot;) </code></pre> <p>i am checking for all these parameters whether they are present in my ordered dictionary or not is there any better way to check this?</p>
[ { "answer_id": 74130356, "author": "Rahul K P", "author_id": 4407666, "author_profile": "https://Stackoverflow.com/users/4407666", "pm_score": 1, "selected": false, "text": "if any(i not in data for i in list('abcdefghijkli')):\n raise serializers.ValidationError(\"All Required Parame...
2022/10/19
[ "https://Stackoverflow.com/questions/74130326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19223879/" ]
74,130,338
<p>I have a list of map of fields from ElasticSearch in a JSON structure. I need to extract the keys from the fields into a <code>name.value</code> list to be used as search terms.</p> <p>For example, the response I get from ElasticSearch looks like:</p> <pre class="lang-json prettyprint-override"><code>{ &quot;orange&quot;: { &quot;type&quot;: &quot;keyword&quot; }, &quot;apple&quot;: { &quot;type&quot;: &quot;keyword&quot; }, &quot;banana&quot;: { &quot;type&quot;: &quot;keyword&quot; }, &quot;pineapple&quot;: { &quot;properties&quot;: { &quot;color&quot;: { &quot;type&quot;: &quot;text&quot; }, &quot;size&quot;: { &quot;type&quot;: &quot;text&quot; } } }, &quot;vegetables&quot;: { &quot;properties&quot;: { &quot;potato&quot;: { &quot;properties&quot;: { &quot;quality&quot;: { &quot;type&quot;: &quot;keyword&quot; }, &quot;price&quot;: { &quot;type&quot;: &quot;keyword&quot; }, &quot;location&quot;: { &quot;type&quot;: &quot;keyword&quot; } } } } } } </code></pre> <p>I need to transform this into a list of</p> <pre class="lang-json prettyprint-override"><code>[ &quot;orange&quot;, &quot;apple&quot;, &quot;banana&quot;, &quot;pineapple.color&quot;, &quot;pineapple.size&quot;, &quot;vegetables.potato.quality&quot;, &quot;vegetables.potato.price&quot;, &quot;vegetables.potato.location&quot;, &quot;vegetables.cabbage&quot; ] </code></pre> <p>I'm a bit lost as to where to start so I end up with something that will work no matter how deep the &quot;object&quot; + &quot;properties&quot; key ends up being.</p> <p><strong>edit:</strong></p> <p>I have a couple of methods I'm trying to do this with, but I keep ending up with nested loops instead</p> <pre class="lang-java prettyprint-override"><code>private static String process(final Map.Entry&lt;String, Object&gt; entry) { final String fieldName = entry.getKey(); final Map&lt;String, Object&gt; value = toSourceMap(entry.getValue()); if (value.containsKey(&quot;properties&quot;)) { final Map&lt;String, Object&gt; properties = toSourceMap(value.get(&quot;properties&quot;)); process(entry); // ?? } return fieldName; } </code></pre> <p>And a small helper method I'm using which casts the unknown object to a map</p> <pre class="lang-java prettyprint-override"><code>private static Map&lt;String, Object&gt; toSourceMap(final Object sourceMap) { try { final Map&lt;String, Object&gt; map = (Map) sourceMap; return map; } catch (final Exception e) { return Map.of(); } } </code></pre> <p>And I'm calling this</p> <pre class="lang-java prettyprint-override"><code>final List&lt;String&gt; fieldName = new ArrayList&lt;&gt;(); for (final Map.Entry&lt;String, Object&gt; entry : properties.entrySet()) { fieldName.add(process(entry)); } </code></pre> <p>Trying to get a list of each value from the <code>process</code> method</p> <p><strong>edit 2:</strong> I can get something that works for one level deep, but this won't capture the deeper objects like <code>vegetables.potato.quality</code></p> <pre class="lang-java prettyprint-override"><code> private static List&lt;String&gt; process(final Map.Entry&lt;String, Object&gt; entry) { final String fieldName = entry.getKey(); final Map&lt;String, Object&gt; value = toSourceMap(entry.getValue()); final List&lt;String&gt; fields = new ArrayList&lt;&gt;(); if (value.containsKey(&quot;properties&quot;)) { final Map&lt;String, Object&gt; properties = toSourceMap(value.get(&quot;properties&quot;)); properties.keySet().stream().map(s -&gt; fieldName + &quot;.&quot; + s).forEach(fields::add); } else { fields.add(fieldName); } return fields; } </code></pre> <p>and the caller</p> <pre class="lang-java prettyprint-override"><code> final List&lt;String&gt; fieldName = new ArrayList&lt;&gt;(); for (final Map.Entry&lt;String, Object&gt; entry : properties.entrySet()) { fieldName.addAll(process(entry)); } </code></pre>
[ { "answer_id": 74130356, "author": "Rahul K P", "author_id": 4407666, "author_profile": "https://Stackoverflow.com/users/4407666", "pm_score": 1, "selected": false, "text": "if any(i not in data for i in list('abcdefghijkli')):\n raise serializers.ValidationError(\"All Required Parame...
2022/10/19
[ "https://Stackoverflow.com/questions/74130338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18572479/" ]
74,130,394
<p>I have inherited a SQL Server table design as detailed below. The table is called <code>Info</code>.</p> <p>I need to understand the SQL statement required to return the correct results for the following two examples.</p> <pre><code>Id | ItemId | FieldName | Value 1 | 302 | Colour | Red 2 | 303 | Length | 100 3 | 304 | Length | 25 4 | 305 | Colour | Blue 5 | 306 | Colour | Blue 6 | 306 | Length | 100 7 | 307 | Colour | Blue 8 | 307 | Length | 35 9 | 308 | Colour | Red 10 | 308 | Length | 100 11 | 309 | Colour | Red 12 | 309 | Length | 45 13 | 309 | Shape | Square 14 | 310 | Shape | Round </code></pre> <p>Example 1: I need to find out which Items (ItemId) have a Colour of &quot;Red&quot; AND a Length of &quot;100&quot; from the &quot;Info&quot; table - which should be only, ItemId 308</p> <p>My limited SQL knowledge has taken me down the path of</p> <pre><code>SELECT ItemId FROM Info WHERE (FieldName = 'Colour') AND (Value = 'Red') </code></pre> <p>but this returns Items 302 and 308, the similar query of</p> <pre><code>SELECT ItemId FROM Info WHERE (FieldName = 'Length') AND (Value = '100') </code></pre> <p>returns 303 and 308, when the correct output should just be ItemId 308</p> <p>The scenario I have may also require the expansion of this query to include more than two fields being defined as in the following example:</p> <p>Example 2: I need to find out which Items have a Colour of &quot;Red&quot; AND a Length of &quot;45&quot; AND are &quot;Square&quot; - which should be only ItemId 309</p> <p>Any advice would be gratefully received.</p>
[ { "answer_id": 74130570, "author": "DannySlor", "author_id": 19174570, "author_profile": "https://Stackoverflow.com/users/19174570", "pm_score": 0, "selected": false, "text": "select ItemId\nfrom (\n select ItemId\n ,case when value = 'Red' then 1 end ...
2022/10/19
[ "https://Stackoverflow.com/questions/74130394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20285546/" ]
74,130,415
<p>I have specified the correct CSS file in my HTML file to download the Montserrat font but it is not getting applied at all when I view HTML in my Chrome browser. I have tried moving my styles.css file in different locations but it makes no difference. The Montserrat font is not being applied instead it is a default serif font I think. Any help to get the Montserrat font to render would be greatly appreciated.</p> <p><a href="https://i.stack.imgur.com/0SYdX.jpg" rel="nofollow noreferrer">screenshot of rendered HTML</a></p> <p>Here is my HTML code;</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset=&quot;utf-8&quot;&gt; &lt;title&gt;TinDog&lt;/title&gt; &lt;!-- Google Fonts --&gt; &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.googleapis.com&quot;&gt; &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.gstatic.com&quot; crossorigin&gt; &lt;link href=&quot;https://fonts.googleapis.com/css2?family=Montserrat:wght@100;400;700:900&amp;family=Ubuntu:wght@100;400&amp;display=swap&quot; rel=&quot;stylesheet&quot;&gt; &lt;!-- CSS Stylesheets --&gt; &lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot; integrity=&quot;sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3&quot; crossorigin=&quot;anonymous&quot;&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;css/styles.css&quot;&gt; &lt;!-- Bootstrap Scripts --&gt; &lt;script src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js&quot; integrity=&quot;sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt; &lt;script src=&quot;https://kit.fontawesome.com/693b9c10a5.js&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;section id=&quot;title&quot;&gt; &lt;div class=&quot;container-fluid&quot;&gt; &lt;!-- Nav Bar --&gt; &lt;nav class=&quot;navbar navbar-expand-lg navbar-dark&quot;&gt; &lt;a class=&quot;navbar-brand&quot; href=&quot; &quot;&gt;tindog&lt;/a&gt; &lt;button class=&quot;navbar-toggler&quot; type=&quot;button&quot; data-bs-toggle=&quot;collapse&quot; data-bs-target=&quot;#navbarTogglerDemo01&quot; aria-controls=&quot;navbarTogglerDemo01&quot; aria-expanded=&quot;false&quot; aria-label=&quot;Toggle navigation&quot;&gt; &lt;span class=&quot;navbar-toggler-icon&quot;&gt;&lt;/span&gt; &lt;/button&gt; &lt;div class=&quot;collapse navbar-collapse&quot; id=&quot;navbarTogglerDemo01&quot;&gt; &lt;ul class=&quot;navbar-nav ms-auto&quot;&gt; &lt;li class=&quot;nav-item&quot;&gt; &lt;a class=&quot;nav-link&quot; href=&quot;#footer&quot;&gt;Contact&lt;/a&gt; &lt;/li&gt; &lt;li class=&quot;nav-item&quot;&gt; &lt;a class=&quot;nav-link&quot; href=&quot;#pricing&quot;&gt;Pricing&lt;/a&gt; &lt;/li&gt; &lt;li class=&quot;nav-item&quot;&gt; &lt;a class=&quot;nav-link&quot; href=&quot;#cta&quot;&gt;Download&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/nav&gt; &lt;!-- Title --&gt; &lt;div class=&quot;row&quot;&gt; &lt;div class=&quot;col-lg-6&quot;&gt; &lt;h1 class=&quot;big-heading&quot;&gt;Meet new and interesting dogs nearby.&lt;/h1&gt; &lt;button type=&quot;button&quot; class=&quot;btn btn-dark btn-lg download-button&quot;&gt;&lt;i class=&quot;fa-brands fa-apple&quot;&gt;&lt;/i&gt; Download&lt;/button&gt; &lt;button type=&quot;button&quot; class=&quot;btn btn-outline-light btn-lg download-button&quot;&gt;&lt;i class=&quot;fa-brands fa-google-play&quot;&gt;&lt;/i&gt; Download&lt;/button&gt; &lt;/div&gt; &lt;div class=&quot;col-lg-6&quot;&gt; &lt;img class=&quot;title-image&quot; src=&quot;images/iphone6.png&quot; alt=&quot;iphone-mockup&quot;&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/section&gt; &lt;!-- Features --&gt; &lt;section id=&quot;features&quot;&gt; &lt;div class=&quot;row&quot;&gt; &lt;div class=&quot;feature-box col-lg-4&quot;&gt; &lt;i class=&quot;icon fa-sharp fa-solid fa-circle-check fa-4x&quot;&gt;&lt;/i&gt; &lt;h3 class=&quot;feature-title&quot;&gt;Easy to use.&lt;/h3&gt; &lt;p&gt;So easy to use, even your dog could do it.&lt;/p&gt; &lt;/div&gt; &lt;div class=&quot;feature-box col-lg-4&quot;&gt; &lt;i class=&quot;icon fa-solid fa-bullseye fa-4x&quot;&gt;&lt;/i&gt; &lt;h3 class=&quot;feature-title&quot;&gt;Elite Clientele&lt;/h3&gt; &lt;p&gt;We have all the dogs, the greatest dogs.&lt;/p&gt; &lt;/div&gt; &lt;div class=&quot;feature-box col-lg-4&quot;&gt; &lt;i class=&quot;icon fa-solid fa-heart fa-4x&quot;&gt;&lt;/i&gt; &lt;h3 class=&quot;feature-title&quot;&gt;Guaranteed to work.&lt;/h3&gt; &lt;p&gt;Find the love of your dog's life or your money back.&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/section&gt; &lt;!-- Testimonials --&gt; &lt;section id=&quot;testimonials&quot;&gt; &lt;div id=&quot;testimonial-carousel&quot; class=&quot;carousel slide&quot; data-bs-ride=&quot;false&quot;&gt; &lt;div class=&quot;carousel-inner&quot;&gt; &lt;div class=&quot;carousel-item active&quot;&gt; &lt;h2 class=&quot;testimonial-text&quot;&gt;I no longer have to sniff other dogs for love. I've found the hottest Corgi on TinDog. Woof.&lt;/h2&gt; &lt;img class=&quot;testimonial-image&quot; src=&quot;images/dog-img.jpg&quot; alt=&quot;dog-profile&quot;&gt; &lt;em&gt;Pebbles, New York&lt;/em&gt; &lt;/div&gt; &lt;div class=&quot;carousel-item&quot;&gt; &lt;h2 class=&quot;testimonial-text&quot;&gt;My dog used to be so lonely, but with TinDog's help, they've found the love of their life. I think.&lt;/h2&gt; &lt;img class=&quot;testimonial-image&quot; src=&quot;images/lady-img.jpg&quot; alt=&quot;lady-profile&quot;&gt; &lt;em&gt;Beverly, Illinois&lt;/em&gt; &lt;/div&gt; &lt;/div&gt; &lt;button class=&quot;carousel-control-prev&quot; type=&quot;button&quot; data-bs-target=&quot;#testimonial-carousel&quot; data-bs-slide=&quot;prev&quot;&gt; &lt;span class=&quot;carousel-control-prev-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; &lt;/button&gt; &lt;button class=&quot;carousel-control-next&quot; type=&quot;button&quot; data-bs-target=&quot;#testimonial-carousel&quot; data-bs-slide=&quot;next&quot;&gt; &lt;span class=&quot;carousel-control-next-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; &lt;/button&gt; &lt;/div&gt; &lt;/section&gt; &lt;!-- Press --&gt; &lt;section id=&quot;press&quot;&gt; &lt;img class=&quot;press-logo&quot; src=&quot;images/techcrunch.png&quot; alt=&quot;tc-logo&quot;&gt; &lt;img class=&quot;press-logo&quot; src=&quot;images/tnw.png&quot; alt=&quot;tnw-logo&quot;&gt; &lt;img class=&quot;press-logo&quot; src=&quot;images/bizinsider.png&quot; alt=&quot;biz-insider-logo&quot;&gt; &lt;img class=&quot;press-logo&quot; src=&quot;images/mashable.png&quot; alt=&quot;mashable-logo&quot;&gt; &lt;/section&gt; &lt;!-- Pricing --&gt; &lt;section id=&quot;pricing&quot;&gt; &lt;h2 class=&quot;section-heading&quot;&gt;A Plan for Every Dog's Needs&lt;/h2&gt; &lt;p&gt;Simple and affordable price plans for your and your dog.&lt;/p&gt; &lt;div class=&quot;row row-cols-1 mb-3&quot;&gt; &lt;div class=&quot;pricing-column col-lg-4 col-md-6&quot;&gt; &lt;div class=&quot;card&quot;&gt; &lt;div class=&quot;card-header&quot;&gt; &lt;h3&gt;Chihuahua&lt;/h3&gt; &lt;/div&gt; &lt;div class=&quot;card-body&quot;&gt; &lt;h2 class=&quot;price-text&quot;&gt;Free&lt;/h2&gt; &lt;p&gt;5 Matches Per Day&lt;/p&gt; &lt;p&gt;10 Messages Per Day&lt;/p&gt; &lt;p&gt;Unlimited App Usage&lt;/p&gt; &lt;button type=&quot;button&quot; class=&quot;btn btn-outline-dark btn-lg&quot; style=&quot;width:100%;&quot;&gt;Sign Up&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;pricing-column col-lg-4 col-md-6&quot;&gt; &lt;div class=&quot;card&quot;&gt; &lt;div class=&quot;card-header&quot;&gt; &lt;h3&gt;Labrador&lt;/h3&gt; &lt;/div&gt; &lt;div class=&quot;card-body&quot;&gt; &lt;h2 class=&quot;price-text&quot;&gt;$49 / mo&lt;/h2&gt; &lt;p&gt;Unlimited Matches&lt;/p&gt; &lt;p&gt;Unlimited Messages&lt;/p&gt; &lt;p&gt;Unlimited App Usage&lt;/p&gt; &lt;button type=&quot;button&quot; class=&quot;btn btn-dark btn-lg&quot; style=&quot;width:100%;&quot;&gt;Sign Up&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;pricing-column col-lg-4&quot;&gt; &lt;div class=&quot;card&quot;&gt; &lt;div class=&quot;card-header&quot;&gt; &lt;h3&gt;Mastiff&lt;/h3&gt; &lt;/div&gt; &lt;div class=&quot;card-body&quot;&gt; &lt;h2 class=&quot;price-text&quot;&gt;$99 / mo&lt;/h2&gt; &lt;p&gt;Pirority Listing&lt;/p&gt; &lt;p&gt;Unlimited Matches&lt;/p&gt; &lt;p&gt;Unlimited Messages&lt;/p&gt; &lt;p&gt;Unlimited App Usage&lt;/p&gt; &lt;button type=&quot;button&quot; class=&quot;btn btn-dark btn-lg&quot; style=&quot;width:100%;&quot;&gt;Sign Up&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/section&gt; &lt;!-- Call to Action --&gt; &lt;section id=&quot;cta&quot;&gt; &lt;h3 class=&quot;big-heading&quot;&gt;Find the True Love of Your Dog's Life Today.&lt;/h3&gt; &lt;button type=&quot;button&quot; class=&quot;download-button btn btn-dark btn-lg&quot;&gt;&lt;i class=&quot;fa-brands fa-apple&quot;&gt;&lt;/i&gt; Download&lt;/button&gt; &lt;button type=&quot;button&quot; class=&quot;download-button btn btn-light btn-lg&quot;&gt;&lt;i class=&quot;fa-brands fa-google-play&quot;&gt;&lt;/i&gt; Download&lt;/button&gt; &lt;/section&gt; &lt;!-- Footer --&gt; &lt;footer id=&quot;footer&quot;&gt; &lt;a href=&quot;https://www.twitter.com&quot;&gt;&lt;i class=&quot;fa-brands fa-twitter social-icon fa-xs&quot;&gt;&lt;/i&gt;&lt;/a&gt; &lt;a href=&quot;https://www.facebook.com&quot;&gt;&lt;i class=&quot;fa-brands fa-facebook-f social-icon fa-xs&quot;&gt;&lt;/i&gt;&lt;/a&gt; &lt;a href=&quot;https://www.instagram.com&quot;&gt;&lt;i class=&quot;fa-brands fa-instagram social-icon fa-xs&quot;&gt;&lt;/i&gt;&lt;/a&gt; &lt;a href=&quot;mailto:stephen.j.learmonth@gmail.com&quot;&gt;&lt;i class=&quot;fa-solid fa-envelope social-icon fa-xs&quot;&gt;&lt;/i&gt;&lt;/a&gt; &lt;p class=&quot;footer-title&quot;&gt;© Copyright 2018 TinDog&lt;/p&gt; &lt;a href=&quot;#title&quot;&gt;Top&lt;/a&gt; &lt;/footer&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and here is my CSS code;</p> <pre><code>body { font-family: &quot;Montserrat&quot;; font-weight: 400; text-align: center; } h1, h2, h3, h4, h5, h6 { font-family: 'Montserrat'; font-weight: 900; } p { color: #8F8F8F; } a { color: #8F8F8F; text-decoration: none; } /* Headings */ .big-heading { font-family: &quot;Montserrat&quot;; font-weight: 900; font-size: 3.5rem; line-height: 1.5; } .section-heading { font-size: 3rem; line-height: 1.5; } #title { background-color: #ff4c68; color: white; } .container-fluid { padding: 3% 15% 7%; } /* Navigation Bar */ .navbar { padding: 0 0 4.5rem; } .navbar-brand { font-family: 'Ubuntu'; font-size: 2.5rem; font-weight: bold; } .nav-item { padding: 0 18px; } .nav-link { font-size: 1.2rem; font-family: 'Montserrat'; font-weight: 100; } /* Download Buttons */ .download-button { margin: 5% 3% 5% 0; } .title-image { width: 22%; /* width: 60%; */ transform: rotate(25deg); position: absolute; right: 23%; } /* Features */ #features { padding: 7% 15%; background-color: white; position: relative; } .feature-title { font-size: 1.5rem; } .feature-box { text-align: center; padding: 8%; } .icon { color: #EF8172; margin-bottom: 1rem; } .icon:hover { color: #FF4C68; } /* Testimonials */ #testimonials { text-align: center; background-color: #EF8172; color: #FFFFFF; } .carousel-item { padding: 7% 20%; } .testimonial-image { width: 10%; border-radius: 50%; margin: 20px; } .testimonial-text { font-size: 3rem; line-height: 1.5; } /* Press */ #press { background-color: #EF8172; text-align: center; padding-bottom: 3%; } .press-logo { width: 15%; margin: 20px 20px 50px; } /* Pricing section */ #pricing { padding: 100px; text-align: center; } .price-text { font-size: 3rem; line-height: 1.5; } .pricing-column { padding: 3% 2%; } @media (max-width: 1028px) { #title { text-align: center; } .title-image { position: static; transform: rotate(0); width: 60%; } } /* Call to action */ #cta { background-color: #FF4C68; text-align: center; padding: 7% 20%; color: #fff; } /* Footer */ #footer { background-color: #fff; padding: 7% 15%; text-align: center; } .footer-title { font-family: 'Montserrat' color: gray; font-size: 1.0rem; text-align: center; } .social-icon { color: #000; margin: 20px 10px; } </code></pre>
[ { "answer_id": 74130537, "author": "Abdul Nafay", "author_id": 18909135, "author_profile": "https://Stackoverflow.com/users/18909135", "pm_score": 1, "selected": false, "text": "<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\n <link rel=\"preconnect\" href=\"https://fon...
2022/10/19
[ "https://Stackoverflow.com/questions/74130415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19435833/" ]
74,130,429
<p>Following is a sample array that I have. The goal is to determine whether there are duplicate entries based on a <strong>number of fields</strong> (details below) -</p> <pre><code>values = [ { &quot;name&quot;: &quot;123&quot;, &quot;loginTime&quot;: &quot;01:00:00&quot;, &quot;logoutTime&quot;: &quot;01:00:00&quot;, &quot;description&quot;: &quot;test&quot;, &quot;message&quot;: &quot;test2&quot;, &quot;status&quot;: &quot;test3&quot; }, { &quot;name&quot;: &quot;123&quot;, &quot;loginTime&quot;: &quot;01:00:00&quot;, &quot;logoutTime&quot;: &quot;00:00:00&quot;, &quot;description&quot;: &quot;test&quot;, &quot;message&quot;: &quot;test2&quot;, &quot;status&quot;: &quot;test3&quot; }, { &quot;name&quot;: &quot;222&quot;, &quot;loginTime&quot;: &quot;01:00:00&quot;, &quot;logoutTime&quot;: &quot;00:00:00&quot;, &quot;description&quot;: &quot;test2&quot;, &quot;message&quot;: &quot;test2&quot;, &quot;status&quot;: &quot;test1&quot; } ] </code></pre> <p>I am aware of the similar looking popular question <a href="https://stackoverflow.com/questions/30735465/how-can-i-check-if-the-array-of-objects-have-duplicate-property-values">here</a>, however, the scenario I'm talking about is different. In that question, the user is concerned mainly about the <code>name</code> field only and so the <code>Set</code> based solution works fine. In my case, however, I need to determine the existence of duplicate data if the <code>name, description, message, status</code> fields are the same between any two entries in <code>values</code> (and so not just one field). So from the example list above, the first two entries are duplicates, since all the mentioned fields have the same value between them. At least one of the aforementioned fields will need to have a non-duplicate value here. What would be an ES6 compliant way to detect the duplicate data here?</p> <p>A <code>Set</code> based solution makes sense for when there's just one field that we'll have to look into to determine the duplication. Not sure how one would do it for multiple fields.</p>
[ { "answer_id": 74130687, "author": "Haim Abeles", "author_id": 15298697, "author_profile": "https://Stackoverflow.com/users/15298697", "pm_score": 0, "selected": false, "text": "function test(values) {\n const tempArr = values.map(item => { \n return { \n name: item.name, \n...
2022/10/19
[ "https://Stackoverflow.com/questions/74130429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2860439/" ]
74,130,434
<p>I have a string called &quot;block&quot;, and I want to check in which list it is contained. It works for me as below, but I was wondering if there is a better way (maybe a mapper or dict key\value or something similar). This is what I have:</p> <pre><code>def get_block_container(block: str) -&gt; str: if block in ['sss', 'srs']: return 'prime' if block in ['aaa', 'aba']: return 'general' if block in ['kkk', 'klk']: return 'alpha' if block in ['zyz', 'zzz']: return 'beta' return '' </code></pre> <p>Is there a simpler way to do it? as the list may go longer with time.</p> <p>Thanks!</p>
[ { "answer_id": 74130475, "author": "DeepSpace", "author_id": 1453822, "author_profile": "https://Stackoverflow.com/users/1453822", "pm_score": 3, "selected": true, "text": "O(n*m)" }, { "answer_id": 74130514, "author": "rafathasan", "author_id": 9465840, "author_profi...
2022/10/19
[ "https://Stackoverflow.com/questions/74130434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9434604/" ]
74,130,473
<p>I have an OnEdit function that sort my sheet. And i need to set the range from A2 to the last column, i tried some different codes but this doesn't work. Someone have an idea?</p> <pre><code> function onEdit() { var ss = SpreadsheetApp.getActiveSheet() var nomeAba = ss.getSheetName() var celAtiva = ss.getActiveCell() var pag1 = &quot;Página24&quot; if (nomeAba == pag1 &amp;&amp; celAtiva.getColumn() == 3 &amp;&amp; celAtiva.getRow() &gt; 1) { var columnToSortBy = 2 var tableRange = &quot;A2:F&quot; var range = ss.getRange(tableRange) range.sort({ column: columnToSortBy }) var columnToSortBy = 1 var tableRange = &quot;A2:F&quot; var range = ss.getRange(tableRange) range.sort({ column: columnToSortBy }) } } </code></pre>
[ { "answer_id": 74130475, "author": "DeepSpace", "author_id": 1453822, "author_profile": "https://Stackoverflow.com/users/1453822", "pm_score": 3, "selected": true, "text": "O(n*m)" }, { "answer_id": 74130514, "author": "rafathasan", "author_id": 9465840, "author_profi...
2022/10/19
[ "https://Stackoverflow.com/questions/74130473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19822275/" ]
74,130,502
<p>I'm working on a maze solving algorithm in C but having some output not expected, here's my code:</p> <pre><code>#include &lt;stdio.h&gt; // Maze size #define N 6 //define boolean #ifndef MYBOOLEAN_H #define MYBOOLEAN_H #define false 0 #define true 1 typedef int bool; #endif int endX = 5; int endY = 4; int startX = 0; int startY = 0; //function prototype bool solveMazeUtil(int maze[N][N], int x, int y, int sol[N][N]); int main() { int maze[N][N] = {{1,0,0,0,0,0}, {1,1,1,1,1,0}, {0,1,0,0,0,0}, {0,1,0,0,0,0}, {1,1,1,0,1,1}, {0,0,1,1,1,0}}; mazeGo(maze); return 0; } //print the solution void printSolution(int sol[N][N]) { for (int i = 0; i &lt; N; i++) { for (int j = 0; j &lt; N; j++) printf(&quot; %d &quot;, sol[i][j]); printf(&quot;\n&quot;); } } //checking if in correct path bool isSafe(int maze[N][N], int x, int y) { // if not, return false if (x &gt;= 0 &amp;&amp; x &lt; N &amp;&amp; y &gt;= 0 &amp;&amp; y &lt; N &amp;&amp; maze[x][y] == 1) return true; else return false; } bool mazeGo(int maze[N][N]) { int sol[N][N] = { { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0 }}; if (solveMazeUtil(maze, startX, startY, sol) == false) { printf(&quot;No solution&quot;); return false; } printSolution(sol); return true; } //actual maze solving bool solveMazeUtil(int maze[N][N], int x, int y, int sol[N][N]) { // if (x, y) is goal return true if (x == endX &amp;&amp; y == endY) { sol[x][y] = 1; return true; } // Check if maze[x][y] is valid if (isSafe(maze, x, y) == true) { // mark x, y sol[x][y] = 1; //try move right if (solveMazeUtil(maze, x + 1, y, sol) == true) return true; //try move down if (solveMazeUtil(maze, x, y + 1, sol) == true) return true; //try move left if (solveMazeUtil(maze, x - 1, y, sol) == true) return true; //try move up if (solveMazeUtil(maze, x, y - 1, sol) == true) return true; // If none of the above movements work then unmark x, y else sol[x][y] = 0; return false; } return false; } </code></pre> <p>I am expecting an output like this:</p> <pre><code> 1 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1 0 1 1 0 0 1 1 1 0 </code></pre> <p>But the result is:</p> <pre><code> 1 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 1 0 </code></pre> <p>And if I set the endX and endY (the position of goal) to (4,4), it works:</p> <pre><code> 1 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1 0 1 0 0 0 1 1 1 0 </code></pre> <p>But if I set endX to 0 and endY to 1 the program run but print nothing. May I ask that where have I made the mistake?</p>
[ { "answer_id": 74130475, "author": "DeepSpace", "author_id": 1453822, "author_profile": "https://Stackoverflow.com/users/1453822", "pm_score": 3, "selected": true, "text": "O(n*m)" }, { "answer_id": 74130514, "author": "rafathasan", "author_id": 9465840, "author_profi...
2022/10/19
[ "https://Stackoverflow.com/questions/74130502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20133031/" ]
74,130,513
<p>I am trying to sort a list of class Shape.the shape class has a method surface() which return an int. How would I sort this list from biggest to smallest surface</p> <p>The code is this</p> <pre><code>def sort_list(list_shapes): ''' for shape in list_shapes: shape.surface() = int output = list_shapes sorted by surface size ''' pass # for context: Shape Class class Shape: def __init__(self, width, height): self.width = width self.height = height def surface(self): surface = float(self.width * self.height) return round(surface, 2) </code></pre> <p>I've tried with sort and sorted but cant seem to make it work. I believe possibly I could do something like list(map()) but also couldn't figure it out.</p> <p>Would love to get a better understanding on which way is best for this</p>
[ { "answer_id": 74130475, "author": "DeepSpace", "author_id": 1453822, "author_profile": "https://Stackoverflow.com/users/1453822", "pm_score": 3, "selected": true, "text": "O(n*m)" }, { "answer_id": 74130514, "author": "rafathasan", "author_id": 9465840, "author_profi...
2022/10/19
[ "https://Stackoverflow.com/questions/74130513", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17727207/" ]
74,130,531
<p>In attempt to make type which should be <strong>values</strong> of given object type I started with this:</p> <pre><code>type Book = { name:string, year:number, author:string } // expected result &quot;string&quot; | &quot;number&quot; type ValueOf&lt;T extends {}&gt; = T[k in keyof T] // error due to &quot;in&quot; let x:ValueOf&lt;Book&gt; ; </code></pre> <p>But seems <code>in</code> is redundant here. I could just have used <code>T[keyof T]</code>.</p> <p>While I have seen <code>in</code> operator in similar cases like this:</p> <pre><code>type OptionsFlags&lt;Type&gt; = { [Property in keyof Type]: boolean; }; </code></pre> <p>Why wasn't it needed in my case? What concept did I miss related to <code>in</code> usage? What is rule of thumb when I could use <code>in</code>?</p>
[ { "answer_id": 74130666, "author": "Valentin", "author_id": 1654241, "author_profile": "https://Stackoverflow.com/users/1654241", "pm_score": 1, "selected": true, "text": "in" }, { "answer_id": 74130682, "author": "Matthieu Riegler", "author_id": 884123, "author_profi...
2022/10/19
[ "https://Stackoverflow.com/questions/74130531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,130,535
<pre><code>int a[NUM_ROWS][NUM_COLS], (*p)[NUM_COLS], i=5; //pointer can point to an array of length 'Length Columns' </code></pre> <p>Let's iterate it</p> <pre><code>for(p=&amp;a[0]; p&lt;&amp;a[NUM_ROWS]; p++){ (*p)[i]=0; } </code></pre> <p>My (incomplete) understanding is that p is pointing to the location of array ' a's ' 0th index location, this is stored as a 1-D array of length [NUM_COLS]. How is this making the array column 'i' to reset itself to 0. How is pointer jumping to next column location?</p> <p>I know that a 'p + i' refers to 'address of a + 4*i bytes' so how is 'address of a + x bytes' happening in column wise iteration using pointer to an array,</p>
[ { "answer_id": 74130666, "author": "Valentin", "author_id": 1654241, "author_profile": "https://Stackoverflow.com/users/1654241", "pm_score": 1, "selected": true, "text": "in" }, { "answer_id": 74130682, "author": "Matthieu Riegler", "author_id": 884123, "author_profi...
2022/10/19
[ "https://Stackoverflow.com/questions/74130535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19144786/" ]
74,130,536
<p>I have a long list of keys (main keys) in the nested dictionary. In one of the sub-keys, I want to create a list of its values. This is one of the records from my nested dictionary. They all are structured in a similar manner.</p> <pre><code> {'C4QY10_e': {'protein accession': 'C4QY10_e', 'sequence length': [1879], 'analysis': 'Pfam', 'signature accession': 'PF18314, PF02801, PF18325, PF00109, PF01648', 'signature description': &quot;Fatty acid synthase type I helical domain, Beta-ketoacyl synthase, Fatty acid synthase subunit alpha Acyl carrier domain, 4'-phosphopantetheinyl transferase superfamily&quot;, 'start location': [328, 139, 1761], 'stop location': [528, 300, 1861], 'e-value': [4.7e-73, 1.3e-72, 1.4e-18], 'interpro accession': 'IPR041550, IPR040899, IPR008278', 'interpro description': &quot;Fatty acid synthase type I, Fatty acid synthase subunit alpha, 4'-phosphopantetheinyl transferase domain&quot;, 'nunique': [1] } </code></pre> <p>The sub-key value I want to turn into the list is 'interpro description'. I want it to be divided by ','. So [0] value of the list would be &quot;Fatty acid synthase type I&quot; and [1] &quot;Fatty acid synthase subunit alpha&quot;. It is very important that these values would preserve input order.</p>
[ { "answer_id": 74130600, "author": "JNevill", "author_id": 2221001, "author_profile": "https://Stackoverflow.com/users/2221001", "pm_score": 3, "selected": true, "text": "split()" }, { "answer_id": 74130713, "author": "Ingwersen_erik", "author_id": 17587002, "author_p...
2022/10/19
[ "https://Stackoverflow.com/questions/74130536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19643651/" ]
74,130,548
<p>I have a navigation app where it redirects to Google maps with the Latitude and longitude coordinates. Users have been reporting recently that the endpoint in Google maps is wrong despite it being right in the app, after changing the origin location.</p> <p>After doing some troubleshooting the bug seems to be in Google Maps, but I cannot find any other resources or issues that confirm this bug. I am looking for others to confirm this bug.</p> <p>Replicate the bug in Google maps on an Android device as follows:</p> <ol> <li>Open Google Maps on an Android Device (I am running an S10 running Android Version 12)</li> <li>Search for Lat/Lng coordinates such as <strong>52.66, -114.00</strong>, these coordinates are North of Gull Lake</li> <li>Tap directions, The correct directions will be shown to the coordinates entered from your location.</li> <li>Tap &quot;Your Location&quot; to change the origin location. Enter some nearby town, I used <strong>Edmonton</strong>.</li> <li>New directions will show up with the original location as correct, but the endpoint is now very wrong, In this test it put the endpoint north or Rimby,about 20 km away from the original endpoint.</li> </ol> <p>Please let me know if you can replicate this bug on your Android device.</p> <p>EDIT: <a href="https://www.youtube.com/shorts/QBGb-8tLDck" rel="nofollow noreferrer">Here is a video of the issue</a></p>
[ { "answer_id": 74130600, "author": "JNevill", "author_id": 2221001, "author_profile": "https://Stackoverflow.com/users/2221001", "pm_score": 3, "selected": true, "text": "split()" }, { "answer_id": 74130713, "author": "Ingwersen_erik", "author_id": 17587002, "author_p...
2022/10/19
[ "https://Stackoverflow.com/questions/74130548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6625990/" ]
74,130,549
<p>I am using the following command to convert the first page of a pdf to a png:</p> <p><code>convert -density 200 &quot;somePdf.pdf[0]&quot; -size 500 &quot;newImage.png&quot;</code> But the output image size is not 500 pixels wide (it comes to over a 1000 pixels wide).</p> <p>How do I define a specific output size?</p>
[ { "answer_id": 74130550, "author": "RobKohr", "author_id": 101909, "author_profile": "https://Stackoverflow.com/users/101909", "pm_score": 0, "selected": false, "text": "convert -density 200 \"somePdf.pdf[0]\" -geometry 500 \"newImage.png\"" }, { "answer_id": 74132487, "auth...
2022/10/19
[ "https://Stackoverflow.com/questions/74130549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/101909/" ]
74,130,558
<p>I have a loop which resets a timeout every time it completes an iteration, but if the loop takes too long I want to throw an error that is caught by an exception handler from the calling function. How can I throw the error in the parent instead of inside the timeout scope?</p> <p>Where I'm applying this is attempting to access web pages and if not I have a set of instructions to reset the connection, but hopefully this mwe makes enough sense as a standalone example.</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 wait = ms =&gt; new Promise(r =&gt; setTimeout(r, ms)); const getRand5 = () =&gt; Math.floor(Math.random() * 5 + 1); const wait5 = () =&gt; wait(getRand5() * 1e2); async function something() { for (let i = 0; i &lt; 10; i++) { //I want this thrown error to throw an error for function something, not the timeout scope const timer = setTimeout(() =&gt; { throw new Error("too long!"); }, 3e2); await wait5(); clearTimeout(timer); } } (async () =&gt; { let fails = 0; do { try { console.log("attempt number ", fails); await something(); break; } catch (e) { fails++; } } while (fails &lt; 10); if (fails &gt;= 10) { console.log("failed too many times"); } else { console.log("Looks like we gottem boys"); } })();</code></pre> </div> </div> </p>
[ { "answer_id": 74130729, "author": "gear4", "author_id": 1710359, "author_profile": "https://Stackoverflow.com/users/1710359", "pm_score": 1, "selected": false, "text": "// Timeout helper function\n// Returns a promise which gets resolved after `ms` milliseconds\nasync function timeout(m...
2022/10/19
[ "https://Stackoverflow.com/questions/74130558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7978627/" ]
74,130,561
<p>suppose that I have the following NumPy array:</p> <pre><code>x = np.array([0,1,2,3,4,5]) </code></pre> <p>I'd like to check if the numbers are in ascending order, i.e., if exists a number larger than the number before, it should warn me. I believe that I can do it with the <code>any</code> syntax, but I'm not sure how. For instance, I've been trying:</p> <pre><code>if any(x[i] &lt; x[i-1] for i in range(len(x))): print('Warning!') </code></pre> <p>But it's not working properly. It should activate the warning in arrays like <code>[0,2,1,3,4,5]</code>, and so on. Could someone please help me fix this issue? Thank you in advance!</p>
[ { "answer_id": 74130601, "author": "juanpa.arrivillaga", "author_id": 5014455, "author_profile": "https://Stackoverflow.com/users/5014455", "pm_score": 3, "selected": true, "text": "np.diff" }, { "answer_id": 74130706, "author": "Cobra", "author_id": 17580381, "author...
2022/10/19
[ "https://Stackoverflow.com/questions/74130561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14873225/" ]
74,130,562
<p>I have a quey which has growth rates over a period of time. I am trying to obtain the overall growth between two rows that I specify. Here is the SQL fiddle <a href="http://sqlfiddle.com/#!9/1756ca/2" rel="nofollow noreferrer">http://sqlfiddle.com/#!9/1756ca/2</a></p> <pre><code>select i1.Month, i1.Rate, EXP(SUM(LOG(1+i2.Rate))) InfRate from Inflation i1 inner join Inflation i2 on i1.Month &gt;=i2.Month group by i1.Month, i1.Rate order by Month DESC </code></pre> <p>This seems to work correctly and I am able to get the growth rate for the entire Month range in the fiddle, however I am trying to use a derived table so that I can specify the Month period, like this, however it is not working</p> <pre><code>select i1.Month, i1.Rate, EXP(SUM(LOG(1+i2.Rate))) InfRate from (SELECT * FROM `Inflation` WHERE Month between '2020-01-01' and '2022-01-01') as DT inner join Inflation i2 on i1.Month &gt;=i2.Month group by i1.Month, i1.Rate order by Month DESC </code></pre> <p>I get the error #1054 - Unknown column 'i1.Month' in 'field list'</p> <p>I am trying to use a derived table for the period between '2020-01-01' and '2022-01-01' or any other range that I specify, however it does not seem to be working for me. Any help will be appreciated.</p> <p>The expected result is something like this, considering that only the period between '2020-01-01' and '2022-01-01' was queried</p> <p><a href="http://sqlfiddle.com/#!9/13f818/1" rel="nofollow noreferrer">http://sqlfiddle.com/#!9/13f818/1</a></p> <p>There seems to be some problem with the fiddle, here is an updated one</p> <p><a href="https://dbfiddle.uk/TwQ7VWs2" rel="nofollow noreferrer">https://dbfiddle.uk/TwQ7VWs2</a></p> <p><a href="https://i.stack.imgur.com/RFmqg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RFmqg.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74130601, "author": "juanpa.arrivillaga", "author_id": 5014455, "author_profile": "https://Stackoverflow.com/users/5014455", "pm_score": 3, "selected": true, "text": "np.diff" }, { "answer_id": 74130706, "author": "Cobra", "author_id": 17580381, "author...
2022/10/19
[ "https://Stackoverflow.com/questions/74130562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7110247/" ]
74,130,579
<p>How could you replace the state of a store consisting of multiple slices with some other, new state in react using redux toolkit?</p> <p>You can revert the whole store to its initial state using <a href="https://stackoverflow.com/a/73864197/2938059">extraReducers</a>: could the same mechanism be used to change the store state to something else then the initial state?</p> <p>For example, you would have something like this:</p> <pre class="lang-js prettyprint-override"><code>const aSlice = createSlice({ name: 'a', initialState: {a: 1}, reducers: { someReducer(state, action) {...} } }) const bSlice = createSlice({ name: 'b', initialState: {b: 'foo'}, reducers: {} }) const store = configureStore({ reducer: { aReducer: aSlice.reducer, bReducer: bSlice.reducer, } }); export type RootState = ReturnType&lt;typeof store.getState&gt; </code></pre> <p>In a react component you can update the state with:</p> <pre class="lang-js prettyprint-override"><code>const dispatch = useDispatch(); dispatch(someReducer({...})); </code></pre> <p>How would you replace the state of the whole store with something like this:</p> <pre class="lang-json prettyprint-override"><code>{ &quot;aReducer&quot;: {&quot;a&quot;: 2}, &quot;bReducer&quot;: {&quot;b&quot;: &quot;bar&quot;}, } </code></pre>
[ { "answer_id": 74134966, "author": "dermeck", "author_id": 7891786, "author_profile": "https://Stackoverflow.com/users/7891786", "pm_score": 1, "selected": false, "text": "{\"a\": 2, \"b\": \"bar\"}" }, { "answer_id": 74267889, "author": "Blee", "author_id": 2938059, ...
2022/10/19
[ "https://Stackoverflow.com/questions/74130579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2938059/" ]
74,130,594
<ul> <li>I ask the user to put an input number like a &quot;max&quot; and then count and add all the even numbers together. For example: If the user inputs 6 then that would be 2+4+6 = 12</li> </ul> <pre><code>Sub AddupEvenNumbers() Dim num As Variant Dim evennum As Variant Dim sum As Double Dim str As String Dim count As Integer str = &quot;Enter a upper/maximum number &quot; num = InputBox(str) evennum = num If num Mod 2 Then evennum = num.Value + num count = count + 1 End If MsgBox &quot;The sum of even numbers &quot; &amp; vbNewLine &amp; &quot;from 0 to &quot; &amp; num &amp; vbNewLine &amp; &quot;is &quot; &amp; evennum End Sub </code></pre>
[ { "answer_id": 74134966, "author": "dermeck", "author_id": 7891786, "author_profile": "https://Stackoverflow.com/users/7891786", "pm_score": 1, "selected": false, "text": "{\"a\": 2, \"b\": \"bar\"}" }, { "answer_id": 74267889, "author": "Blee", "author_id": 2938059, ...
2022/10/19
[ "https://Stackoverflow.com/questions/74130594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20178476/" ]
74,130,597
<p>How would you go about changing a variables value using a dictionary?</p> <pre><code>class Solution(object): def __init__(self): self.slot1 = &quot;&quot; self.slot2 = &quot;&quot; self.slot3 = &quot;&quot; self.slot4 = &quot;&quot; self.slot5 = &quot;&quot; self.slotDictionary = {1: self.slot1, 2: self.slot2, 3: self.slot3, 4: self.slot4, 5: self.slot5} def checkAnswer(self): choice = int(input(&quot;What is the answer?&quot;)) self.slotDictionary[choice] = &quot;something&quot; solution = Solution() solution.checkAnswer() </code></pre> <p>However when running this it does not change the value of the self variables. How would i go about this?</p>
[ { "answer_id": 74130782, "author": "alvrm", "author_id": 15956657, "author_profile": "https://Stackoverflow.com/users/15956657", "pm_score": -1, "selected": false, "text": "setattr()" }, { "answer_id": 74130784, "author": "rafathasan", "author_id": 9465840, "author_pr...
2022/10/19
[ "https://Stackoverflow.com/questions/74130597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20055661/" ]
74,130,605
<p>Currently I have an algorithm that runs to compare to different arrays of objects.</p> <pre><code>const allGroups = [{ id: '12345', name: 'groupOne'}, {id: '23421', name: 'groupTwo'}, {id: '28182', name: 'groupThree'}] const clientsGroups = [{ id: 'abcde', clientGroupID: '12345'}, {id: 'dfcdae', clientGroupID: '93282'}, {id: 'jakdab', clientGroupID: '28182'}, {id: 'oiewad', clientGroupID: '93482'}] const updateClientGroups = (allGroups, clientsGroups) =&gt; { let allGroupsCopy = [...allGroups]; for (let i = 0; i &lt; allGroupsCopy.length; i++) { const allGroupsId = allGroupsCopy[i].id; for (let j = 0; j &lt; clientsGroups.length; j++) { if (allGroupsId === clientsGroups[j].clientGroupID) { allGroupsCopy[i] = { ...allGroupsCopy[i], inGroup: true, clientGroupID: clientsGroups[j].id, }; } } } return allGroupsCopy; }; </code></pre> <p>I check two different arrays of objects, if the <em>id</em> of <strong>allGroups</strong> matches the <em>clientGroupID</em> of <strong>clientGroups</strong>, I mutate the 'allGroupsCopy' to have 'inGroup: true' and add in the <em>id</em> of the <strong>clientsGroups</strong>.</p> <p>The problem with this algorithm is it runs in n^2 time. Is there a more efficient way to do this?</p>
[ { "answer_id": 74130782, "author": "alvrm", "author_id": 15956657, "author_profile": "https://Stackoverflow.com/users/15956657", "pm_score": -1, "selected": false, "text": "setattr()" }, { "answer_id": 74130784, "author": "rafathasan", "author_id": 9465840, "author_pr...
2022/10/19
[ "https://Stackoverflow.com/questions/74130605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8304719/" ]
74,130,622
<p>The codegen.ts config below results in duplicating the <code>RegisterDocument</code> entries.</p> <p>codegen.ts:</p> <pre><code>const config: CodegenConfig = { overwrite: true, schema: &quot;http://localhost:4000/graphql&quot;, documents: &quot;src/graphql/**/*.graphql&quot;, generates: { &quot;src/generated/graphql&quot;: { preset: &quot;client&quot;, plugins: [ &quot;typescript-urql&quot; ], config: { documentVariableSuffix: 'test2' } } } }; </code></pre> <p>the output:</p> <pre><code>export const RegisterDocument = {&quot;kind&quot;:&quot;Document&quot;, ...} export const RegisterDocument = gql` mutation Register($username: String!, $password: String!) { register(options: {username: $username, password: $password}) { errors { field message } user { id username createdAt } } } `; export function useRegisterMutation() { return Urql.useMutation&lt;RegisterMutation, RegisterMutationVariables&gt;(RegisterDocument); }; </code></pre> <p>Seemingly either the <code>documentVariableSuffix</code> param didn't affect the output const naming or it was a wrong param. The use of the typescript-operations or/and typescript packages only led to more duplicates.</p> <p>What is the way to have typescript-urql register the mutation differently?</p> <p>UP. The <code>register</code> mutation I need typings for:</p> <pre><code>const registerMutationDocument = graphql(` mutation Register($username: String!, $password: String!) { register(options: { username: $username, password: $password }) { errors { field message } user { id username createdAt } } } `) </code></pre>
[ { "answer_id": 74137167, "author": "Charly Poly", "author_id": 3738219, "author_profile": "https://Stackoverflow.com/users/3738219", "pm_score": 2, "selected": false, "text": "preset: \"client\"" }, { "answer_id": 74199353, "author": "El Anonimo", "author_id": 5524590, ...
2022/10/19
[ "https://Stackoverflow.com/questions/74130622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5524590/" ]
74,130,667
<p>So, I was playing with my JS and I did a &quot;random&quot; phrase generator which replaces the text inside the div on each click of a button. But I want to change the font size of the text based on the length of the replaced text, but it doesn't work the way I intended. I'm new to JS and want to understand why my check function works only once and then get stuck. I'm definitely missing something important, but what?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>let texts = [ "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio eius enim ut minus! Officia repellendus magni labore nulla repellat libero!", "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequatur, velit.", "Lorem ipsum dolor sit amet consectetur." ] const changeText = document.querySelector('.changing_content') const btn = document.querySelector('.btn') function getRandomElement(arr) { let randIndex = Math.floor(Math.random() * arr.length); return arr[randIndex]; } function checkLength(e) { e.map(text =&gt; { if (text.length &gt;= 60) { changeText.style.fontSize = "24px" changeText.style.color = "blue" } else if (text.length &gt;= 144) { changeText.style.fontSize = "34px" changeText.style.color = "lightgreen" } else { changeText.style.fontSize = "14px" changeText.style.color = "black" } }) } btn.addEventListener('click', function() { let randomElement = getRandomElement(texts) changeText.innerHTML = randomElement checkLength(texts); })</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>.changing_content { font-size: 16px; color: red; }</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;title&gt;Document&lt;/title&gt; &lt;link rel="stylesheet" href="style.css"&gt; &lt;script src="prob.js" defer&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h1 class="h1"&gt; hmm...&lt;/h1&gt; &lt;div class="changing_content"&gt;Im changing!&lt;/div&gt; &lt;button class="btn"&gt;Click me!&lt;/button&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74130769, "author": "tao", "author_id": 1891677, "author_profile": "https://Stackoverflow.com/users/1891677", "pm_score": 1, "selected": false, "text": "if (text.length >= 60) {\n // A\n} else if (text.length >= 144) {\n // B\n} else {\n // C\n}\n" }, { "answer_...
2022/10/19
[ "https://Stackoverflow.com/questions/74130667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20198717/" ]
74,130,678
<p>I'm trying to open a dialog if the url include a specific string, but it does not work the way I intend. If I just change the dialog state it render too many time (error) and if I useEffect then it works but I cannot close the modal anymore..</p> <pre><code>export default function Terms() { const [open, setOpen] = useState(false); const [scroll, setScroll] = useState('paper'); const handleClickOpen = () =&gt; { setOpen(true); setScroll(); }; const handleClose = () =&gt; { setOpen(false); }; //if (/terms-conditions/.test(window.location.href)) { // setOpen(true); //} // this gives me Too many render error, same if I call the handleClickOpen() const descriptionElementRef = useRef(null); useEffect(() =&gt; { // this check if &quot;terms-conditions&quot; appear in the url if (/terms-conditions/.test(window.location.href)) { setOpen(true); } if (open) { const { current: descriptionElement } = descriptionElementRef; if (descriptionElement !== null) { descriptionElement.focus(); } } }, [open]); return( &lt;Dialog open={open} onClose={handleClose} scroll={scroll} aria-labelledby=&quot;scroll-dialog-title&quot; aria-describedby=&quot;scroll-dialog-description&quot; &gt; &lt;DialogActions&gt; &lt;Button onClick={handleClose}&gt;{translate('general.close')}&lt;/Button&gt; &lt;/DialogActions&gt; &lt;/Dialog&gt; &lt;Button onClick={handleClickOpen}&gt;Terms&lt;/Button&gt; ) } </code></pre> <p>Thank you.</p>
[ { "answer_id": 74130734, "author": "kind user", "author_id": 6695924, "author_profile": "https://Stackoverflow.com/users/6695924", "pm_score": 3, "selected": true, "text": "useEffect" }, { "answer_id": 74130855, "author": "KcH", "author_id": 11737596, "author_profile"...
2022/10/19
[ "https://Stackoverflow.com/questions/74130678", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13596673/" ]
74,130,717
<p>I have a JS array of objects which looks like:</p> <pre><code>[{ a : {}, b: {}, c: [{}, {}] }] </code></pre> <p>Now I want to flatten this object in such a way, that the array now becomes:</p> <pre><code>[ { a : {}, b: {}, c: {} }, { a : {}, b: {}, c: {} }, ] </code></pre> <p>Note that the array c was flattened, while all the other fields were duplicated across the two objects. What is the best way to do this?</p>
[ { "answer_id": 74130928, "author": "Feathercrown", "author_id": 5527075, "author_profile": "https://Stackoverflow.com/users/5527075", "pm_score": 2, "selected": false, "text": "var data = [{\n a : {test:1},\n b: {test:2},\n c: [{test:3}, {test:4}]\n}];\n\ndata = data.flatMap(obj => {\...
2022/10/19
[ "https://Stackoverflow.com/questions/74130717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8805369/" ]
74,130,733
<p>I have to assign a given datetime value into <code>timestamp</code> column to rows with NaT values if a condition is met in another column. All the values in <code>timestamp</code> are either <code>datetime64[ns]</code> or <code>NaT</code>.</p> <h3>EDIT:</h3> <p>sample data:</p> <pre><code>dates = [pd.to_datetime('2022-10-14 10:13:52', format = &quot;%Y-%m-%d %H:%M:%S&quot;), pd.to_datetime('2022-10-14 17:43:52', format = &quot;%Y-%m-%d %H:%M:%S&quot;), pd.to_datetime('2022-10-14 09:00:10', format = &quot;%Y-%m-%d %H:%M:%S&quot;)] data = {'A': [-0.5, -0.5, 0.7, 1, 0.65, 0.5], 'timestamp': pd.Series(dates, index=[1, 3, 5])} df = pd.DataFrame(data = data, index=[0, 1, 2, 3, 4, 5]) </code></pre> <p>Output:</p> <pre><code> A timestamp 0 -0.50 NaT 1 -0.50 2022-10-14 10:13:52 2 0.70 NaT 3 1.00 2022-10-14 17:43:52 4 0.65 NaT 5 0.50 2022-10-14 09:00:10 </code></pre> <p>I then do the following:</p> <pre><code>threshold = 0.65 null_date = pd.to_datetime('2022-09-01 09:00:00', format = &quot;%Y-%m-%d %H:%M:%S&quot;) df.timestamp = np.where(df.A &gt;= threshold, null_date, df.timestamp) </code></pre> <p>However, this turns all the values in <code>timestamp</code> into object type.</p> <pre><code> A timestamp 0 -0.50 None 1 -0.50 1665742432000000000 2 0.70 2022-09-01 09:00:00 3 1.00 2022-09-01 09:00:00 4 0.65 2022-09-01 09:00:00 5 0.50 1665738010000000000 </code></pre> <p>That is, <code>NaTs</code> in rows where the condition is not met are replaced with <code>None</code>. <code>Datetime</code> in those rows are replaced, too. Only the rows where the condition was met get a <code>datetime</code>.</p> <p>Does anyone have any suggestions how to replace NaT with a given datetime by condition?</p> <h3>EDIT-2:</h3> <p>It <strong>worked out</strong> with lambda function:</p> <pre><code>df.timestamp = df[['A', 'timestamp']].apply(lambda x: null_date if x['A'] &gt;= threshold else x['timestamp'], axis=1) </code></pre> <p>Output:</p> <pre><code> A timestamp 0 -0.50 NaT 1 -0.50 2022-10-14 10:13:52 2 0.70 2022-09-01 09:00:00 3 1.00 2022-09-01 09:00:00 4 0.65 2022-09-01 09:00:00 5 0.50 2022-10-14 09:00:10 </code></pre>
[ { "answer_id": 74130928, "author": "Feathercrown", "author_id": 5527075, "author_profile": "https://Stackoverflow.com/users/5527075", "pm_score": 2, "selected": false, "text": "var data = [{\n a : {test:1},\n b: {test:2},\n c: [{test:3}, {test:4}]\n}];\n\ndata = data.flatMap(obj => {\...
2022/10/19
[ "https://Stackoverflow.com/questions/74130733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19948076/" ]
74,130,748
<p>I am getting error while running <code>bundle install</code>. This is on macOS 12.6 (Intel chip).</p> <pre><code>Installing pg_query 2.1.4 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. ... An error occurred while installing pg_query (2.1.4), and Bundler cannot continue. In Gemfile: pg_query </code></pre>
[ { "answer_id": 74130928, "author": "Feathercrown", "author_id": 5527075, "author_profile": "https://Stackoverflow.com/users/5527075", "pm_score": 2, "selected": false, "text": "var data = [{\n a : {test:1},\n b: {test:2},\n c: [{test:3}, {test:4}]\n}];\n\ndata = data.flatMap(obj => {\...
2022/10/19
[ "https://Stackoverflow.com/questions/74130748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11401032/" ]
74,130,772
<p>I have a column called &quot;dateCreated&quot; and it contains a date and time, and I want to convert it to a number of days.</p> <p>This is my column This is the data as a text: 2021-12-20T15:58:33.948Z</p> <p><a href="https://i.stack.imgur.com/wVmSC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wVmSC.png" alt="enter image description here" /></a></p> <p>I tried this</p> <pre><code>train_data['dateCreated'] = (train_data['dateCreated'] - date.today()).dt.days </code></pre>
[ { "answer_id": 74130928, "author": "Feathercrown", "author_id": 5527075, "author_profile": "https://Stackoverflow.com/users/5527075", "pm_score": 2, "selected": false, "text": "var data = [{\n a : {test:1},\n b: {test:2},\n c: [{test:3}, {test:4}]\n}];\n\ndata = data.flatMap(obj => {\...
2022/10/19
[ "https://Stackoverflow.com/questions/74130772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12932726/" ]
74,130,793
<p>In the past, the domain was hired and used on a physical server (which still exists today) And now I need this domain to stop directing the old physical server and start redirecting to the new one (which will also be physical)</p> <p><strong>Old Server</strong> : Linux Apache</p> <p><strong>New Server</strong> : Windows (IIS?, Apache?, WAMP? is still being decided)</p> <p>Can someone give me a tip? I'm in the dark here</p>
[ { "answer_id": 74130928, "author": "Feathercrown", "author_id": 5527075, "author_profile": "https://Stackoverflow.com/users/5527075", "pm_score": 2, "selected": false, "text": "var data = [{\n a : {test:1},\n b: {test:2},\n c: [{test:3}, {test:4}]\n}];\n\ndata = data.flatMap(obj => {\...
2022/10/19
[ "https://Stackoverflow.com/questions/74130793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17598441/" ]
74,130,799
<p>While compiling there are no errors, compile fine. But when I call the method in the controller got an error. It looks like during the compilation class methods are missing.</p> <p>If you need more information about the project config - please, ask - I will share. For now, I don't have any ideas on how to fix it. The similar code on other projects works fine.</p> <blockquote> <p>TypeError: Cannot read properties of undefined (reading 'onOpenMessage') at WebSocket. (/Users/xxx/redqueen-middleware/src/controllers/websocket.ts:23:16) at WebSocket.onMessage (/Users/xxx/redqueen-middleware/node_modules/ws/lib/event-target.js:132:16) at WebSocket.emit (node:events:513:28) at Receiver.receiverOnMessage (/Users/xxx/redqueen-middleware/node_modules/ws/lib/websocket.js:1068:20) at Receiver.emit (node:events:513:28) at Receiver.dataMessage (/Users/xxx/redqueen-middleware/node_modules/ws/lib/receiver.js:517:14) at Receiver.getData (/Users/xxx/redqueen-middleware/node_modules/ws/lib/receiver.js:435:17) at Receiver.startLoop (/Users/xxx/redqueen-middleware/node_modules/ws/lib/receiver.js:143:22) at Receiver._write (/Users/xxx/redqueen-middleware/node_modules/ws/lib/receiver.js:78:10) at writeOrBuffer (node:internal/streams/writable:391:12) [ERROR] 16:46:06 TypeError: Cannot read properties of undefined (reading 'onOpenMessage')</p> </blockquote> <p>Controller code</p> <pre><code>class WebsocketController { initWebsocket(websocket: WebSocket): void { //some code, works fine before calling method `onOpenMessage` this.onOpenMessage(); } private onOpenMessage(): void { //some code } } export default new WebsocketController(); </code></pre> <p>My <code>tsconfig.json</code></p> <pre><code>{ &quot;compilerOptions&quot;: { &quot;module&quot;: &quot;commonjs&quot;, &quot;declaration&quot;: false, &quot;noImplicitAny&quot;: false, &quot;removeComments&quot;: true, &quot;noLib&quot;: false, &quot;allowSyntheticDefaultImports&quot;: true, &quot;emitDecoratorMetadata&quot;: true, &quot;experimentalDecorators&quot;: true, &quot;target&quot;: &quot;es6&quot;, &quot;esModuleInterop&quot;: true, &quot;lib&quot;: [ &quot;dom&quot;, &quot;es6&quot;, &quot;esnext.asynciterable&quot; ], &quot;typeRoots&quot;: [ &quot;./custom_typings&quot;, &quot;./node_modules/@types&quot; ], &quot;sourceMap&quot;: true, &quot;allowJs&quot;: true, &quot;outDir&quot;: &quot;./build&quot;, &quot;baseUrl&quot;: &quot;./src&quot;, &quot;resolveJsonModule&quot;: true }, &quot;include&quot;: [ &quot;src/**/*&quot;, &quot;config/**/*&quot; ], &quot;exclude&quot;: [ &quot;node_modules&quot;, &quot;**/*.spec.ts&quot;, &quot;**/*.test.ts&quot;, &quot;custom_typings&quot; ] } </code></pre> <p>Here is my server.ts</p> <pre><code>import express from 'express'; import expressWs from 'express-ws'; import winston from 'winston'; import WebsocketController from './controllers/websocket'; export default function initServer() { const app = express(); const port = process.env.PORT; const router = express.Router(); global.websocketsList = []; expressWs(app); router.ws('/ws-request', WebsocketController.initWebsocket); app.use('/', router); app.listen(port, () =&gt; { winston.info(`Middleware server start on port ${port}`); }); } </code></pre> <p>Converting method <code>onOpenMessage</code> from private to public does not give any result.</p>
[ { "answer_id": 74130928, "author": "Feathercrown", "author_id": 5527075, "author_profile": "https://Stackoverflow.com/users/5527075", "pm_score": 2, "selected": false, "text": "var data = [{\n a : {test:1},\n b: {test:2},\n c: [{test:3}, {test:4}]\n}];\n\ndata = data.flatMap(obj => {\...
2022/10/19
[ "https://Stackoverflow.com/questions/74130799", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15215168/" ]