qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,234,508
<p>Having read through eBay's guide for including digital signatures to certain of their REST API calls, I am having trouble with generating the signature header. Rather than including all of the documentation here (there is a lot!), I'll provide links to the appropriate pages and some of the documentation. The following page it the starting point provided by eBay: <a href="https://developer.ebay.com/develop/guides/digital-signatures-for-apis" rel="nofollow noreferrer">https://developer.ebay.com/develop/guides/digital-signatures-for-apis</a> The next page is where I am lead to from the previous page describing how to create the signature: <a href="https://www.ietf.org/archive/id/draft-ietf-httpbis-message-signatures-13.html#name-eddsa-using-curve-edwards25" rel="nofollow noreferrer">https://www.ietf.org/archive/id/draft-ietf-httpbis-message-signatures-13.html#name-eddsa-using-curve-edwards25</a> Which leads me onto the following : <a href="https://www.rfc-editor.org/rfc/rfc8032#section-5.1.6" rel="nofollow noreferrer">https://www.rfc-editor.org/rfc/rfc8032#section-5.1.6</a></p> <pre><code>5.1.6. Sign The inputs to the signing procedure is the private key, a 32-octet string, and a message M of arbitrary size. For Ed25519ctx and Ed25519ph, there is additionally a context C of at most 255 octets and a flag F, 0 for Ed25519ctx and 1 for Ed25519ph. 1. Hash the private key, 32 octets, using SHA-512. Let h denote the resulting digest. Construct the secret scalar s from the first half of the digest, and the corresponding public key A, as described in the previous section. Let prefix denote the second half of the hash digest, h[32],...,h[63]. 2. Compute SHA-512(dom2(F, C) || prefix || PH(M)), where M is the message to be signed. Interpret the 64-octet digest as a little- endian integer r. 3. Compute the point [r]B. For efficiency, do this by first reducing r modulo L, the group order of B. Let the string R be the encoding of this point. 4. Compute SHA512(dom2(F, C) || R || A || PH(M)), and interpret the 64-octet digest as a little-endian integer k. 5. Compute S = (r + k * s) mod L. For efficiency, again reduce k modulo L first. 6. Form the signature of the concatenation of R (32 octets) and the little-endian encoding of S (32 octets; the three most significant bits of the final octet are always zero). </code></pre> <p>I have some Python code from the appendix from this same web page (<a href="https://www.rfc-editor.org/rfc/rfc8032#section-6" rel="nofollow noreferrer">https://www.rfc-editor.org/rfc/rfc8032#section-6</a>):</p> <pre><code>## First, some preliminaries that will be needed. import hashlib def sha512(s): return hashlib.sha512(s).digest() # Base field Z_p p = 2**255 - 19 def modp_inv(x): return pow(x, p-2, p) # Curve constant d = -121665 * modp_inv(121666) % p # Group order q = 2**252 + 27742317777372353535851937790883648493 def sha512_modq(s): return int.from_bytes(sha512(s), &quot;little&quot;) % q ## Then follows functions to perform point operations. # Points are represented as tuples (X, Y, Z, T) of extended # coordinates, with x = X/Z, y = Y/Z, x*y = T/Z def point_add(P, Q): A, B = (P[1]-P[0]) * (Q[1]-Q[0]) % p, (P[1]+P[0]) * (Q[1]+Q[0]) % p; C, D = 2 * P[3] * Q[3] * d % p, 2 * P[2] * Q[2] % p; E, F, G, H = B-A, D-C, D+C, B+A; return (E*F, G*H, F*G, E*H); # Computes Q = s * Q def point_mul(s, P): Q = (0, 1, 1, 0) # Neutral element while s &gt; 0: if s &amp; 1: Q = point_add(Q, P) P = point_add(P, P) s &gt;&gt;= 1 return Q def point_equal(P, Q): # x1 / z1 == x2 / z2 &lt;==&gt; x1 * z2 == x2 * z1 if (P[0] * Q[2] - Q[0] * P[2]) % p != 0: return False if (P[1] * Q[2] - Q[1] * P[2]) % p != 0: return False return True ## Now follows functions for point compression. # Square root of -1 modp_sqrt_m1 = pow(2, (p-1) // 4, p) # Compute corresponding x-coordinate, with low bit corresponding to # sign, or return None on failure def recover_x(y, sign): if y &gt;= p: return None x2 = (y*y-1) * modp_inv(d*y*y+1) if x2 == 0: if sign: return None else: return 0 # Compute square root of x2 x = pow(x2, (p+3) // 8, p) if (x*x - x2) % p != 0: x = x * modp_sqrt_m1 % p if (x*x - x2) % p != 0: return None if (x &amp; 1) != sign: x = p - x return x # Base point g_y = 4 * modp_inv(5) % p g_x = recover_x(g_y, 0) G = (g_x, g_y, 1, g_x * g_y % p) def point_compress(P): zinv = modp_inv(P[2]) x = P[0] * zinv % p y = P[1] * zinv % p return int.to_bytes(y | ((x &amp; 1) &lt;&lt; 255), 32, &quot;little&quot;) def point_decompress(s): if len(s) != 32: raise Exception(&quot;Invalid input length for decompression&quot;) y = int.from_bytes(s, &quot;little&quot;) sign = y &gt;&gt; 255 y &amp;= (1 &lt;&lt; 255) - 1 x = recover_x(y, sign) if x is None: return None else: return (x, y, 1, x*y % p) ## These are functions for manipulating the private key. def secret_expand(secret): if len(secret) != 32: raise Exception(&quot;Bad size of private key&quot;) h = sha512(secret) a = int.from_bytes(h[:32], &quot;little&quot;) a &amp;= (1 &lt;&lt; 254) - 8 a |= (1 &lt;&lt; 254) return (a, h[32:]) def secret_to_public(secret): (a, dummy) = secret_expand(secret) return point_compress(point_mul(a, G)) ## The signature function works as below. def sign(secret, msg): a, prefix = secret_expand(secret) A = point_compress(point_mul(a, G)) r = sha512_modq(prefix + msg) R = point_mul(r, G) Rs = point_compress(R) h = sha512_modq(Rs + A + msg) s = (r + h * a) % q return Rs + int.to_bytes(s, 32, &quot;little&quot;) ## And finally the verification function. def verify(public, msg, signature): if len(public) != 32: raise Exception(&quot;Bad public key length&quot;) if len(signature) != 64: Exception(&quot;Bad signature length&quot;) A = point_decompress(public) if not A: return False Rs = signature[:32] R = point_decompress(Rs) if not R: return False s = int.from_bytes(signature[32:], &quot;little&quot;) if s &gt;= q: return False h = sha512_modq(Rs + public + msg) sB = point_mul(s, G) hA = point_mul(h, A) return point_equal(sB, point_add(R, hA)) </code></pre> <p>Now, the problem that I am having is that this code insists on the &quot;secret&quot; consisting of a 32 byte array:</p> <p><code>if len(secret) != 32: raise Exception(&quot;Bad size of private key&quot;)</code></p> <p>However, the secret is described as being the private key provided by eBay's Key Management API (<a href="https://developer.ebay.com/api-docs/developer/key-management/overview.html" rel="nofollow noreferrer">https://developer.ebay.com/api-docs/developer/key-management/overview.html</a>), which is not a 32 byte array, but a 64 character ASCII string (see <a href="https://developer.ebay.com/api-docs/developer/key-management/resources/signing_key/methods/createSigningKey#h2-samples" rel="nofollow noreferrer">https://developer.ebay.com/api-docs/developer/key-management/resources/signing_key/methods/createSigningKey#h2-samples</a>): <code>&quot;privateKey&quot;: &quot;MC4CAQAwBQYDK2VwBCIEI******************************************n&quot;</code></p> <p>When I try to generate a signature with the eBay private key using this Python code, it gives me an error saying it is a &quot;Bad size of private key&quot;. If I convert the private key from eBay to a bytearray, it is 64 bytes long. How can I use the Python code to generate the signature header using the private key supplied by eBay?</p> <p>To further complicate things, I am actually using Excel VBA (Visual Basic) to make the API call after using Python to generate the signature (simply because Python is better at this kind of thing!). eBay's PAID FOR technical support has confirmed that the following headers are correct and that there is no &quot;message&quot; as described in <a href="https://www.rfc-editor.org/rfc/rfc8032#section-5.1.6" rel="nofollow noreferrer">https://www.rfc-editor.org/rfc/rfc8032#section-5.1.6</a>, but they have not yet been of any further help other than suggesting that there may be a &quot;bug&quot;.</p> <pre><code>http.setRequestHeader &quot;signature-input&quot;, &quot;sig1=(&quot;&quot;x-ebay-signature-key&quot;&quot; &quot;&quot;@method&quot;&quot; &quot;&quot;@path&quot;&quot; &quot;&quot;@authority&quot;&quot;);created=1667386210&quot; http.setRequestHeader &quot;x-ebay-signature-key&quot;, &quot;&lt;jwe returned by eBay&gt;&quot; http.setRequestHeader &quot;x-ebay-enforce-signature&quot;, &quot;true&quot; </code></pre> <p>The remaining header would be as follows once I can generate a valid signature:</p> <pre><code>http.setRequestHeader &quot;signature&quot; &quot;sig1=:&lt;signature&gt;:&quot; </code></pre> <p>Everything I have tried results in the same response:</p> <pre><code>{ &quot;errors&quot;: [ { &quot;errorId&quot;: 215122, &quot;domain&quot;: &quot;ACCESS&quot;, &quot;category&quot;: &quot;REQUEST&quot;, &quot;message&quot;: &quot;Signature validation failed&quot;, &quot;longMessage&quot;: &quot;Signature validation failed to fulfill the request.&quot; } ] } </code></pre> <p>Here are some example keys like the ones generated by eBay. <a href="https://www.ietf.org/archive/id/draft-ietf-httpbis-message-signatures-11.html#appendix-B.1.4" rel="nofollow noreferrer">https://www.ietf.org/archive/id/draft-ietf-httpbis-message-signatures-11.html#appendix-B.1.4</a></p> <p>&quot;The following key is an elliptical curve key over the Edwards curve ed25519, referred to in this document as test-key-ed25519. This key is PCKS#8 encoded in PEM format, with no encryption.&quot;</p> <pre><code>-----BEGIN PUBLIC KEY----- MCowBQYDK2VwAyEAJrQLj5P/89iXES9+vFgrIy29clF9CC/oPPsw3c5D0bs= -----END PUBLIC KEY----- -----BEGIN PRIVATE KEY----- MC4CAQAwBQYDK2VwBCIEIJ+DYvh6SEqVTm50DFtMDoQikTmiCqirVv9mWG9qfSnF -----END PRIVATE KEY----- </code></pre> <p>This is the format of private key that I believe that I need to convert to a 32-byte array to work with the above Python code. I believe that there is a typo on the linked to web page and it should be &quot;PKCS&quot;, not &quot;PCKS&quot;.</p> <p>UPDATE: If I run the following command:</p> <pre><code>openssl ec -in test.pem -text </code></pre> <p>Where test.pem is a text file containing:</p> <pre><code>-----BEGIN PRIVATE KEY----- MC4CAQAwBQYDK2VwBCIEIJ+DYvh6SEqVTm50DFtMDoQikTmiCqirVv9mWG9qfSnF -----END PRIVATE KEY----- </code></pre> <p>It displays private and public keys as 32 byte hex dumps, but even when using these values I get the same response as above with the 215122 error. When I verify using the Python &quot;verify&quot; method in the code above with these 32 byte hex dump keys, validation is successful.</p>
[ { "answer_id": 74235271, "author": "Douwe de Haan", "author_id": 1336174, "author_profile": "https://Stackoverflow.com/users/1336174", "pm_score": 0, "selected": false, "text": "MethodNotAllowedException" }, { "answer_id": 74235917, "author": "Zaryabro1", "author_id": 104...
2022/10/28
[ "https://Stackoverflow.com/questions/74234508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20357453/" ]
74,234,528
<p>I want to get the multiplication of array elements using recursion.</p> <p><strong>arr</strong> is array, and <strong>n</strong> is length of the array.</p> <p>if arr=[1, 2, 3], n=3, answer is 6.</p> <p>I tried this, but error occurred.</p> <pre><code>def multiply(arr, n): if n == 0: return arr else: return arr[n] * \ multyply(arr[n - 1]) </code></pre> <p>please help me.</p>
[ { "answer_id": 74234553, "author": "assume_irrational_is_rational", "author_id": 11622508, "author_profile": "https://Stackoverflow.com/users/11622508", "pm_score": 1, "selected": false, "text": "def mul(arr):\n if not arr:\n return 1\n return arr[0] * mul(arr[1:])\n" }, ...
2022/10/28
[ "https://Stackoverflow.com/questions/74234528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20281037/" ]
74,234,532
<p>I have a simple script:</p> <pre><code>$ErrorPreference = 'Stop' $user = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name if ($null -eq $user) { throw 'User and password are required' } else { $password = (Get-Credential -credential $user).Password if ($null -eq $password) { throw 'Password is required' } else { $plainpassword = [System.Net.NetworkCredential]::new(&quot;&quot;, $password).Password $service = Get-WMIObject -class Win32_Service -filter &quot;name='myservice'&quot; if ($null -ne $service) { [void]$service.change($null, $null, $null, $null, $null, $false, $user, $plainpassword) } else { throw 'Service was not installed properly' } } } </code></pre> <p>and when I press &quot;Cancel&quot; in the dialog of credentials input, then the user and password must be <code>$null</code>. So, I test them on <code>$null</code>. But I get an error:</p> <pre><code>Get-Credential : Cannot bind argument to parameter 'Credential' because it is null. At C:....ps1:6 char:45 + $password = (Get-Credential -credential $user).Password + ~~~~~ + CategoryInfo : InvalidData: (:) [Get-Credential], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetCredenti alCommand Password is required At C:....ps1:8 char:9 + throw 'Password is required' + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (Password is required:String) [], RuntimeException + FullyQualifiedErrorId : Password is required </code></pre> <p>and I see <code>throw 'Password is required'</code> but at the same time I see:</p> <pre><code>Get-Credential : Cannot bind argument to parameter 'Credential' because it is null. </code></pre> <p>and I expect that if <code>$user</code> is <code>$null</code> then it should not happen and I would exit before this line even. Why this happen and how to handle this?</p> <p>PS. It seems <code>$ErrorPreference = 'Stop'</code> is redundant, just to be sure...</p>
[ { "answer_id": 74234553, "author": "assume_irrational_is_rational", "author_id": 11622508, "author_profile": "https://Stackoverflow.com/users/11622508", "pm_score": 1, "selected": false, "text": "def mul(arr):\n if not arr:\n return 1\n return arr[0] * mul(arr[1:])\n" }, ...
2022/10/28
[ "https://Stackoverflow.com/questions/74234532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1980863/" ]
74,234,577
<p>My script has many lines starting with slo. How can I replace all the strings that are starting with slo to fwd using bash commands? Any help would be appreciated. Here is a snippet of my script</p> <pre><code>template_version: 2018-03-02 resources: instance01: type: ../../../templates/nf.yaml properties: vm_name: 'slol2lvdl1' vm_flavour: 'dns_19te' image_name: 'pdns_dnsd_slo_211214121207' vm_az: 'az-1' vm_disk_root_size: '50' vm_disk_data_size: '50' network_mgmt_refs: 'int:dns_ox_slo_507:c3dns_slo_live_nc_vnns_pcg' </code></pre> <p>My requirement is to replace all slo to fwd in the above code. I have 5 files like this in the same directory.</p>
[ { "answer_id": 74234683, "author": "erik258", "author_id": 1726083, "author_profile": "https://Stackoverflow.com/users/1726083", "pm_score": 2, "selected": false, "text": "sed" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74234577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13334309/" ]
74,234,587
<p>My JSON data looks like this:</p> <pre class="lang-py prettyprint-override"><code>data = { &quot;areas&quot;: [ { &quot;id&quot;: &quot;1348828088398400836&quot;, &quot;name&quot;: &quot;Building A&quot;, &quot;children&quot;: [ { &quot;id&quot;: &quot;1348828088398403213&quot;, &quot;name&quot;: &quot;Floor 1&quot;, &quot;children&quot;: [ {&quot;id&quot;: &quot;1348828088398403214&quot;, &quot;name&quot;: &quot;Room 1&quot;, &quot;children&quot;: []}, {&quot;id&quot;: &quot;1348828088398403215&quot;, &quot;name&quot;: &quot;Room 2&quot;, &quot;children&quot;: []}, {&quot;id&quot;: &quot;1348828088398403216&quot;, &quot;name&quot;: &quot;Room 3&quot;, &quot;children&quot;: []}, { &quot;id&quot;: &quot;1348828088398403217&quot;, &quot;name&quot;: &quot;Room 4&quot;, &quot;children&quot;: [ { &quot;id&quot;: &quot;1348828088398407094&quot;, &quot;name&quot;: &quot;Washroom&quot;, &quot;children&quot;: [], } ], }, ], } ], } ] } </code></pre> <p>Right now I am reading JSON data like this:</p> <pre class="lang-py prettyprint-override"><code>for i in data[&quot;areas&quot;]: areaName = i[&quot;name&quot;] for j in i[&quot;children&quot;]: print(&quot;Name:&quot;, j[&quot;name&quot;]) for k in j[&quot;children&quot;]: print(&quot;Name:&quot;, k[&quot;name&quot;]) for l in k[&quot;children&quot;]: print(&quot;Name:&quot;, l[&quot;name&quot;]) </code></pre> <p>The problem with this approach is that it will miss any <code>children</code> under <code>washroom</code> is there any way to make this dynamic, instead of doing multiple <code>for</code>-loops to get each child?</p>
[ { "answer_id": 74234716, "author": "Daniil Fajnberg", "author_id": 19770795, "author_profile": "https://Stackoverflow.com/users/19770795", "pm_score": 2, "selected": true, "text": "from typing import Any\n\n\ndata = ...\n\n\ndef print_children(dictionary: dict[str, Any]) -> None:\n pr...
2022/10/28
[ "https://Stackoverflow.com/questions/74234587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1932021/" ]
74,234,644
<p>I have the element: MVa.8.199038.R I only want to extract the number 199038, using R. However, I want this to be more general. So, I need a code that will read this element from right to left (starting from the dot) and end to the next dot. This element is part of a data frame.</p> <p>I tried this: <code>substr((df$marker), nchar(df$marker) - 2, \.)</code>, but this does not give output.</p>
[ { "answer_id": 74234716, "author": "Daniil Fajnberg", "author_id": 19770795, "author_profile": "https://Stackoverflow.com/users/19770795", "pm_score": 2, "selected": true, "text": "from typing import Any\n\n\ndata = ...\n\n\ndef print_children(dictionary: dict[str, Any]) -> None:\n pr...
2022/10/28
[ "https://Stackoverflow.com/questions/74234644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20357745/" ]
74,234,673
<p>After using the <code>Illuminate\Auth\Authenticatable</code> trait on a model, I can now do <code>Auth::id()</code> in places in my app (when the current auth-ed thing is that particular model).</p> <p>Is there a way to get the class / type of the auth-ed model?</p> <p>Perhaps something like <code>Auth::model()</code> which might return the model's class name (such as App\Models\User or App\Models\MyCustomAuthCapabaleModel)?</p>
[ { "answer_id": 74235045, "author": "Delano van londen", "author_id": 19923550, "author_profile": "https://Stackoverflow.com/users/19923550", "pm_score": 0, "selected": false, "text": "Auth::user();" }, { "answer_id": 74235073, "author": "Techno", "author_id": 2595985, ...
2022/10/28
[ "https://Stackoverflow.com/questions/74234673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5202562/" ]
74,234,706
<p>Hiya I am trying to print out a dictionary so it ends up looking like this</p> <pre><code>-------- view contacts -------- 1 Stish 123 2 Rita 321 </code></pre> <p>I have got so far as to print it like this</p> <pre><code>-------- view contacts -------- Stish 123 Rita 321 </code></pre> <p>But I am unsure as to how I could get it to print with index numbers as well. This is the code I have currently.</p> <pre><code>def viewcontacts(contacts): print(&quot;-------- view contacts --------&quot;) for key, value in contacts.items(): print (&quot; &quot;,key,&quot; &quot;,value) </code></pre> <p>many thanks for the help and please bear with me as I'm pretty inexperienced.</p> <p>Tried to integrate a for loop with then x+1 for each value but I kept running into concatenation errors as its a string and not an integer that the dictionary values are being stored as.</p>
[ { "answer_id": 74234779, "author": "Tom Karzes", "author_id": 5460719, "author_profile": "https://Stackoverflow.com/users/5460719", "pm_score": 2, "selected": true, "text": "def viewcontacts(contacts):\n print(\"-------- view contacts --------\")\n for ix, (key, value) in enumerate...
2022/10/28
[ "https://Stackoverflow.com/questions/74234706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20357735/" ]
74,234,734
<p>I have a radzen datagrid on a Blazor Server side app, that seems to be loading twice, this is, when first opening the page all data flashes for half a second (I took a screenshot, the data is show, not a blank grid) and then it switched to loading a it takes about 2 seconds and then shows the content of the grid.</p> <p>I have been using as per radzen examples the &quot;IsLoading&quot; property to fill up data, I'll put an abridged version of the datagrid and of my code to show what I have.</p> <p>Razor section:</p> <pre><code>@page &quot;/projectlist&quot; @page &quot;/&quot; @inject ISqlData _db @inject AuthenticationStateProvider AuthenticationStateProvider @inject NavigationManager navigationManager @if (IsDetail == true) { &lt;ProjectDetail OnDetailShown=&quot;UpdateDetailView&quot; CalendarPeriod=&quot;CalendarPeriod&quot; Project=&quot;Project&quot;&gt;&lt;/ProjectDetail&gt; } else { &lt;h3&gt;&lt;p class=&quot;text-center &quot;&gt;Project List&lt;/p&gt;&lt;/h3&gt; &lt;RadzenPanel Style=&quot;width: calc(100vw - 80px)&quot;&gt; &lt;RadzenDataGrid style=&quot;height: calc(100vh - 175px)&quot; AllowPaging=&quot;true&quot; AllowColumnResize=&quot;true&quot; PageSize=&quot;20&quot; IsLoading=&quot;IsLoading&quot; AllowSorting=&quot;true&quot; ShowPagingSummary=&quot;true&quot; AllowColumnReorder=&quot;true&quot; AllowMultiColumnSorting=&quot;true&quot; AllowFiltering=&quot;true&quot; FilterMode=&quot;FilterMode.Simple&quot; FilterCaseSensitivity=&quot;FilterCaseSensitivity.CaseInsensitive&quot; Data=&quot;@Projects&quot; TItem=&quot;Project&quot; &gt; &lt;Columns&gt; &lt;RadzenDataGridColumn TItem=&quot;Project&quot; Property=&quot;ProjectNumber&quot; Title=&quot;Project Number&quot; Sortable=&quot;false&quot; FilterOperator=&quot;FilterOperator.Contains&quot; Width=&quot;130px&quot; Pickable=&quot;false&quot; Frozen=&quot;true&quot; &gt; &lt;Template Context=&quot;data&quot;&gt;&lt;RadzenButton Click=@(args =&gt; OnClick(data.ProjectId, data.ProjectStatus)) Shade=&quot;Shade.Dark&quot; Text=&quot;@data.ProjectNumber&quot; Size=&quot;ButtonSize.Small&quot; ButtonStyle=&quot;ButtonStyle.Success&quot; /&gt;&lt;/Template&gt; &lt;/RadzenDataGridColumn&gt; &lt;RadzenDataGridColumn TItem=&quot;Project&quot; Property=&quot;Name&quot; Title=&quot;Project Name&quot; MinWidth=&quot;300px&quot; /&gt; &lt;RadzenDataGridColumn TItem=&quot;Project&quot; Property=&quot;ContractType&quot; Title=&quot;Contract Type&quot; MinWidth=&quot;300px&quot; /&gt; &lt;RadzenDataGridColumn TItem=&quot;Project&quot; Property=&quot;PtdUnbilled&quot; Title=&quot;Beginning WIP Balance&quot; FormatString=&quot;{0:0,0.00}&quot; TextAlign=&quot;TextAlign.Right&quot; MinWidth=&quot;210px&quot; Width=&quot;210px&quot; /&gt; &lt;/Columns&gt; &lt;/RadzenDataGrid&gt; &lt;/RadzenPanel&gt; } </code></pre> <p>and Code section:</p> <pre><code> public IEnumerable&lt;Project&gt; Projects; private Employee Employee { get; set; } = null!; private string PersonnelNo { get; set; } = null!; public string EmployeeAdName { get; set; } public CalendarPeriod CalendarPeriod { get; set; } = null!; public IEnumerable&lt;ProjectWip&gt; ProjectWipCalculations { get; set; } public bool IsDetail { get; set; } public Project Project { get; set; } public bool IsLoading { get; set; } protected override async Task OnParametersSetAsync() { } protected override async Task OnInitializedAsync() { IsLoading = true; EmployeeAdName = (await AuthenticationStateProvider.GetAuthenticationStateAsync()).User.Identity!.Name!; CalendarPeriod = await _db.GetCalendarPeriodAsync(); Employee = await _db.GetEmployeeDataAsync(EmployeeAdName); PersonnelNo = Employee.PersonnelNumber; Projects = await _db.GetProjectsAsync(PersonnelNo); var enumerable = Projects.ToList(); var projectList = enumerable.Select(x =&gt; x.ProjectId).ToArray(); ProjectWipCalculations = await _db.GetCurrentMonthWIPData(projectList, CalendarPeriod.PeriodFrom); foreach (var project in enumerable) { var projectWip = ProjectWipCalculations.FirstOrDefault(p =&gt; p.ProjectId == project.ProjectId); if (projectWip != null) { project.CurrMonthInvoiceTotal = projectWip.CurrMonthInvoiceTotal; } } IsLoading = false; } private void OnClick(int projectId, string projectStatus) { IsDetail = true; Project = Projects.First(x =&gt; x.ProjectId == projectId); Project.ProjectStatus = projectStatus; } private void UpdateDetailView() { IsDetail = false; } </code></pre> <p>If I remove the &quot;IsLoading&quot; property the only difference is that the grid flashess for half a second all filled and then it blanks for about 2 seconds and the is shown, the &quot;IsLoading&quot; just renders an animation in the middle for a bit.</p> <p>I don't entirely understand what is happening, if maybe the grid is being filled and then the call is done again to fill it? (I have all code in <code>OnInitializedAsync</code></p> <p>I've added a small gif showing what I mean below <a href="https://i.stack.imgur.com/Q1T50.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Q1T50.gif" alt="enter image description here" /></a></p>
[ { "answer_id": 74234779, "author": "Tom Karzes", "author_id": 5460719, "author_profile": "https://Stackoverflow.com/users/5460719", "pm_score": 2, "selected": true, "text": "def viewcontacts(contacts):\n print(\"-------- view contacts --------\")\n for ix, (key, value) in enumerate...
2022/10/28
[ "https://Stackoverflow.com/questions/74234734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2572899/" ]
74,234,739
<p>I am trying to replace words starting with string in text data stored in multiple rows of a dataframe. The df has 6 columns : date, user, tweet, language, coordinates, place. The replacement takes place in tweet column that has for example row 1 :</p> <p>« Nous ne sommes pas très favorables au télétravail mais nous avons de super locaux tout neufs » Il manque un babyfoot et les courtiers auront rejoint les rangs de la Start-up Nation https://link.</p> <p>In row 2 : « Une étude de la Spire Healthcare a révélé, que le #télétravail pouvait avoir un impact sur le #cyclemenstruel, et ce, notamment à cause de la fatigue, du #stress et du manque d’activité physique induits par le travail à distance »</p> <p>Via @marieclaire_fr https://link.</p> <p>In row 3 : @IrisDessine @fredchristian__ Mais c'est super pratique car j'ai horreur de passer la serpillière le mien aspire et lave et franchement c'est devenu mon meilleur ami il bosse tranquillou quand je suis en télétravail </p> <p>Etc.</p> <p>I would like to replace words starting with '@' by '@user' and replace the links (word starting with 'http') by 'http'. All the columns of the df are considered as object. I have tried multiple things :</p> <pre><code>for individual_word in df[&quot;Tweet&quot;]: #print(individual_word) if individual_word.startswith('@') and len(individual_word) &gt; 1: individual_word = '@user' </code></pre> <p>With this code nothing is happening, no error, no replacement. Another code :</p> <pre><code>for individual_word in df[&quot;Tweet&quot;].split(' '): #print(individual_word) if individual_word.split(' ').startswith('@') and len(individual_word) &gt; 1: individual_word = '@user' </code></pre> <p>With this code I have the error : 'Series' object has no attribute 'split'. Another code :</p> <pre><code>for individual_word in df[&quot;Tweet&quot;].str.split(' '): #print(individual_word) if individual_word.str.split(' ').startswith('@') and len(individual_word) &gt; 1: individual_word = '@user' #print(individual_word) </code></pre> <p>With this code I have the error : 'list' object has no attribute 'str'. I have tried to do the same when the column Tweet is converted as string but nothing changes. Depending on the code tried, I think each row is considered as a list so I have to look for word in list of list starting with '@' and 'http' and replace them. Or, each row is considered as a word and not a sentence. So if the first word starts with '@' it will be changed, but if the word starts with '@' later in the sentence it won't be changed.</p> <p>I have also tried with list of list. I can have my data in a list called my_list and 3 columns Type, Size, Value. Row 1 of my_list in column Value :</p> <p>['être', 'favorable', 'télétravail', 'super', 'local', 'neuf', 'manque', 'babyfoot', 'courtier', 'rejoindre', 'rang', 'start', 'nation', 'https://link']</p> <p>Row 2 of my_list in column Value :</p> <p>['étude', 'spire', 'healthcare', 'révéler', 'télétravail', 'impact', 'cyclemenstruel', 'cause', 'fatigue', 'stress', 'manque', 'activité', 'physique', 'induire', 'travail', 'distance', '@marieclaire_fr', 'https://link']</p> <p>Row 3 of my_list in column Value :</p> <p>['vive', 'télétravail', 'commeunlundi', 'https://link']</p> <p>I have tried the code :</p> <pre><code>for each_list in my_list: #print(each_list) for each_word in each_list: #print(each_word) if each_word.startswith('@') and len(each_word) &gt; 1: #print(each_word) each_word = '@user' </code></pre> <p>I don't have any errors but the word isn't changed in each list of my_list.</p> <p>Thank you for your help !</p>
[ { "answer_id": 74235510, "author": "Yolao_21", "author_id": 15283859, "author_profile": "https://Stackoverflow.com/users/15283859", "pm_score": 2, "selected": true, "text": "df['tweets'] = df['tweets'].str.replace('@\\S+', '@user')\n>>>df['tweets']\n tweets\n0 « Une étude de la Spir...
2022/10/28
[ "https://Stackoverflow.com/questions/74234739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15769407/" ]
74,234,751
<p>I want to skip Build stage if AMI already exists using declarative syntax.</p> <pre><code>stage('Build') { environment { AMI = sh(returnStdout: true, script: 'aws ec2 describe-images').trim() } when { expression { AMI = null } } steps { sh 'packer build base.json -machine-readable' } } </code></pre> <p>But when I'm running this pipeline I get <code>groovy.lang.MissingPropertyException: No such property: AMI for class: groovy.lang.Binding</code></p> <p>At the same time scripted pipeline works perfectly fine</p> <pre><code>stage('Build') { steps { script { env.AMI = sh(returnStdout: true, script: 'aws ec2 describe-images').trim() if (env.AMI == '') { sh 'packer build base.json -machine-readable' } } } } } </code></pre> <p>I'd really love to switch to the declarative pipelines just stuck with this condition. Any help is really appreciated. Thanks</p> <p>I tried a lot things without any luck</p> <pre><code>when { expression { return AMI.isEmpty() } } </code></pre> <pre><code>when { not { expression { AMI == '' } } </code></pre> <pre><code>when { not { expression { env.AMI } } } </code></pre> <p>Nothing works. I suspect it is somehow related to env variable association through sh</p>
[ { "answer_id": 74235052, "author": "ycr", "author_id": 2627018, "author_profile": "https://Stackoverflow.com/users/2627018", "pm_score": 1, "selected": false, "text": "pipeline {\n agent any\n\n stages {\n stage('Build') {\n when {\n expression { ...
2022/10/28
[ "https://Stackoverflow.com/questions/74234751", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1057324/" ]
74,234,754
<p>I have a string with comma now i want to get first value how can i get it?</p> <p>My Code:-</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var data = "0.46609362959861755, 0.25069287419319153, 0.5107838958501816, 0.26014574989676476"; console.log(data.replaceAll(',','').splice(0,2));</code></pre> </div> </div> </p> <p>Thanks for your efforts!</p>
[ { "answer_id": 74234788, "author": "BeSter Development", "author_id": 20356148, "author_profile": "https://Stackoverflow.com/users/20356148", "pm_score": 3, "selected": true, "text": "data.split(',')[0]\n" }, { "answer_id": 74234930, "author": "Jonas", "author_id": 157971...
2022/10/28
[ "https://Stackoverflow.com/questions/74234754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7333403/" ]
74,234,763
<p>I would like to create a shaded area in color blue between the two dotted lines (-0.5 and 0.5), tried with geom_polygon() but didn't work. How can this be done in the best possible way?</p> <pre><code>model &lt;- lm(Sepal.Width ~ Petal.Length, data = iris) ggplot(data.frame(x = seq(model$residuals), y = model$residuals)) + geom_point(aes(x, y)) + geom_hline(yintercept = 0, linetype = &quot;dashed&quot;) + geom_hline(yintercept = 0.5, linetype = &quot;dotted&quot;) + geom_hline(yintercept = -0.5, linetype = &quot;dotted&quot;) + labs(x = &quot;Index&quot;, y = &quot;Residuals&quot;, title = paste(&quot;Residuals of&quot;, format(model$call))) </code></pre> <p><a href="https://i.stack.imgur.com/vTu5X.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vTu5X.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74234822, "author": "Allan Cameron", "author_id": 12500315, "author_profile": "https://Stackoverflow.com/users/12500315", "pm_score": 2, "selected": false, "text": "geom_ribbon" }, { "answer_id": 74234839, "author": "Maël", "author_id": 13460602, "autho...
2022/10/28
[ "https://Stackoverflow.com/questions/74234763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18135188/" ]
74,234,786
<p>I want to replace space with comma for this particular pattern only not all spaces: &quot;21311 asd&quot;</p> <p>Input:</p> <pre class="lang-py prettyprint-override"><code>[&quot;dog,cat ax 21311 asd&quot;,&quot;131 MAN&quot;] </code></pre> <p>Desired output:</p> <pre class="lang-py prettyprint-override"><code>[&quot;dog,cat ax 21311,asd&quot;,&quot;131,MAN&quot;] </code></pre> <p>Code:</p> <pre class="lang-py prettyprint-override"><code>input = [&quot;dog,cat ax 21311 asd&quot;,&quot;131 MAN&quot;] new_list = [] for i in input: word = re.findall(r&quot;\d*\s[a-zA-Z]*&quot; , i) new_word = re.sub(word , r&quot;\d*\s[a-zA-Z]*&quot; , i) new_list = new_list + new_word print(new_list) </code></pre> <p>I know this is wrong syntax, but I don't know how to do it using Regex or any other method.</p> <p>I'm using Python 3 and Jupyter notebook.</p>
[ { "answer_id": 74234850, "author": "AlexanderKondrat", "author_id": 16174212, "author_profile": "https://Stackoverflow.com/users/16174212", "pm_score": 2, "selected": false, "text": "input = [\"dog,cat,21311 asd\", \"131 MAN\"]\nprint([data.replace(' ', ',') for data in input])\n" }, ...
2022/10/28
[ "https://Stackoverflow.com/questions/74234786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20357722/" ]
74,234,815
<p>I have a libY.tableX that have for each record some SQL strings like the ones below and other fields to write the result of their execution.</p> <pre><code>select count(*) from libZ.tableK select sum(fieldV) from libZ.tableK select min(dsitact) from libZ.tableK </code></pre> <p>This my steps:</p> <ol> <li>the user is prompted to select a lib and table and the value is passed to the vars &amp;sel_livraria and &amp;sel_tabela;</li> <li>My 1st block is a proc sql to get all the sql string from that record.</li> <li>My 2nd block is trying to concrenate all that strings to use further on to update my table with the results. The macro %isBlank is the one recommended by Chang CHung and John King in their sas papper;</li> <li>My 3th block is to execute that concrenated sql string and update the table with results.</li> </ol> <pre><code>%macro exec_strings; proc sql noprint ; select livraria, tabela, sql_tot_linhas, sql_sum_num, sql_min_data, sql_max_data into :livraria, :tabela, :sql_tot_linhas, :sql_sum_num, :sql_min_data, :sql_max_data from libY.tableX where livraria='&amp;sel_livraria' and tabela='&amp;sel_tabela'; quit; %LET mystring1 =%str(tot_linhas=(&amp;sql_tot_linhas)); %LET separador =%str(,); %if %isBlank(&amp;sql_sum_num) %then %LET mystring2=&amp;mystring1; %else %LET mystring2= %sysfunc(catx(&amp;separador,&amp;mystring1,%str(sum_num=(&amp;sql_tot_linhas)))); %if %isBlank(&amp;sql_min_data) %then %LET mystring3=&amp;mystring2 ; %else %LET mystring3= %sysfunc(catx(&amp;separador,&amp;mystring2,%str(min_data=(&amp;sql_min_data)))); %if %isBlank(&amp;sql_max_data) %then %LET mystring0=&amp;mystring3; %else %LET mystring0= %sysfunc(catx(&amp;separador,&amp;mystring3,%str(max_data=(&amp;sql_min_data)))); %PUT &amp;mystring0; proc sql noprint; update libY.tableX set &amp;mystring0 where livraria='&amp;sel_livraria' and tabela='&amp;sel_tabela'; quit; %mend; </code></pre> <p>My problem with the code above is that iam getting this error in my final concrenated string, &amp;mystring0.</p> <pre><code>tot_linhas=(&amp;sql_tot_linhas),sum_num=(&amp;sql_tot_linhas),min_data=(&amp;sql_min_data),max_data=(&amp;sql_min_data) _ _ _ _ ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant, a missing value, BTRIM, INPUT, PUT, SUBSTRING, USER. </code></pre> <p>Any help appreciated</p>
[ { "answer_id": 74235599, "author": "Tom", "author_id": 4965549, "author_profile": "https://Stackoverflow.com/users/4965549", "pm_score": 1, "selected": true, "text": "where livraria=\"&sel_livraria\"\n" }, { "answer_id": 74275959, "author": "JPOLIVA", "author_id": 2029437...
2022/10/28
[ "https://Stackoverflow.com/questions/74234815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20294371/" ]
74,234,838
<p>I have two classes and I have to do a foreach to insert the data of both shipping and billing address.</p> <pre><code> //Class 1 public class shippingInformation { public string name {get; set;} public string address {get; set;} public string telephone {get; set;} } //Class 2 public class billingInformation { public string name {get; set;} public string address {get; set;} public string telephone {get; set;} } </code></pre> <p>I have tried to put both the classes in the foreach statement, but it did not work.</p> <pre><code>foreach(var data in billingInformation &amp;&amp; shippingInformation) { //Insert into the DB } </code></pre>
[ { "answer_id": 74235599, "author": "Tom", "author_id": 4965549, "author_profile": "https://Stackoverflow.com/users/4965549", "pm_score": 1, "selected": true, "text": "where livraria=\"&sel_livraria\"\n" }, { "answer_id": 74275959, "author": "JPOLIVA", "author_id": 2029437...
2022/10/28
[ "https://Stackoverflow.com/questions/74234838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17329929/" ]
74,234,849
<p>I am trying to profile a CUDA Application. I had a basic doubt about performance analysis and workload characterization of HPC programs. Let us say I want to analyse the wall clock time(the end-to-end time of execution of a program). How many times should one run the same experiment to account for the variation in the wall clock time measurement? Thanks.</p>
[ { "answer_id": 74235599, "author": "Tom", "author_id": 4965549, "author_profile": "https://Stackoverflow.com/users/4965549", "pm_score": 1, "selected": true, "text": "where livraria=\"&sel_livraria\"\n" }, { "answer_id": 74275959, "author": "JPOLIVA", "author_id": 2029437...
2022/10/28
[ "https://Stackoverflow.com/questions/74234849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5545551/" ]
74,234,862
<pre><code>[FirebaseAnalytics][I-ACS023001] Deep Link does not contain valid required params. URL params: { &quot;_cpb&quot; = 1; &quot;_cpt&quot; = cpit; &quot;_fpb&quot; = &quot;CIAHEJ4DGgVlbi1JTg==&quot;; &quot;_iumchkactval&quot; = 1; &quot;_iumenbl&quot; = 1; &quot;_osl&quot; = &quot;https://helpwise.page.link/TJBU&quot;; &quot;_plt&quot; = 3322; &quot;_uit&quot; = 1679; apn = &quot;com.saaslabs.helpwise&quot;; cid = 3913316441535437959; ibi = &quot;com.saaslabs.helpwise&quot;; isi = 1503985272; link = &quot;https://app.helpwise.io&quot;; } VERBOSE: application/scene didBecomeActive DEBUG: Application Foregrounded started DEBUG: cancelFocusCall of { &quot;NOT_ATTRIBUTED&quot; = &quot;&lt;OSUnattributedFocusTimeProcessor: 0x28181f8e0&gt;&quot;; } </code></pre> <p>I am getting this error how to solve it</p> <p>I tried the normal integration method from the firebase website but not able to solve this issue</p>
[ { "answer_id": 74235599, "author": "Tom", "author_id": 4965549, "author_profile": "https://Stackoverflow.com/users/4965549", "pm_score": 1, "selected": true, "text": "where livraria=\"&sel_livraria\"\n" }, { "answer_id": 74275959, "author": "JPOLIVA", "author_id": 2029437...
2022/10/28
[ "https://Stackoverflow.com/questions/74234862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11814358/" ]
74,234,871
<p>context:<a href="https://stackoverflow.com/a/50655730/15603477">https://stackoverflow.com/a/50655730/15603477</a></p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include&lt;string.h&gt; #include&lt;ctype.h&gt; #include&lt;limits.h&gt; #include&lt;uchar.h&gt; #include&lt;assert.h&gt; #define MAXW 128 #define MAXC 112 int main(int argc,char **argv) { int readdef = 0; /* flag for reading definition */ size_t offset = 0 /* offset for each part of definition */ ,len = 0; /* length of each line */ char buf[MAXC] = &quot;&quot;; /* read (line) buffer */ char word[MAXW] = &quot;&quot;; /* buffer storing word */ char defn[MAXC] = &quot;&quot;; /* buffer storing definition */ /* open filename given as 1st argument, (or read stdin by default) */ FILE *fp = argc &gt; 1 ? fopen(argv[1],&quot;r&quot;) : stdin; if(!fp){ /* validate file open for reading */ fprintf(stderr,&quot;error: file '%s' open failed\n&quot;,argv[1]); exit(EXIT_FAILURE); } while(fgets(buf,MAXC,fp)) { char *p = buf; /* pointer to parse word &amp; 1st part of defn */ if(*buf == '\n') { defn[offset-1] = 0; printf(&quot;defn:%s\n\n&quot;,defn); readdef = 0; offset= 0; } else if(readdef == 0) { while(*p &amp;&amp; *p != '.') p++; if(p-buf+1 &gt; MAXW){ fprintf(stderr,&quot;error: word exceeds %d chars.\n&quot;,MAXW-1); exit(EXIT_FAILURE); } snprintf(word,p-buf+1,&quot;%s&quot;,buf); /* copy to word */ printf(&quot;word=%s|\n&quot;,word); while(ispunct(*p) || isspace(*p)) p++; len = strlen(p); if(len &amp;&amp; p[len-1] == '\n') p[len-1] = ' '; strcpy(defn,p); offset +=len; readdef = 1; } else{ len = strlen(buf); /*get the line lenfth */ if(len &amp;&amp; buf[len-1] == '\n') /* chk \n, overwite w/' ' */ buf[len-1] = ' '; if(offset + len + 1 &gt; MAXC){ fprintf(stderr,&quot;error: definition exceed %d chars\n&quot;,MAXC-1); // free(buf); exit(EXIT_FAILURE); } snprintf(defn+offset,len+1,&quot;%s&quot;,buf); /* append to defn */ offset += len; /*update offset*/ } } if(fp != stdin) fclose(fp); defn[offset - 1] = 0; printf(&quot;defn: %s\n\n&quot;,defn); exit(EXIT_SUCCESS); } </code></pre> <hr /> <p>valgrind info.</p> <pre><code>error: definition exceed 111 chars ==28017== ==28017== HEAP SUMMARY: ==28017== in use at exit: 472 bytes in 1 blocks ==28017== total heap usage: 3 allocs, 2 frees, 5,592 bytes allocated ==28017== ==28017== 472 bytes in 1 blocks are still reachable in loss record 1 of 1 ==28017== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==28017== by 0x48ED6CD: __fopen_internal (iofopen.c:65) ==28017== by 0x48ED6CD: fopen@@GLIBC_2.2.5 (iofopen.c:86) ==28017== by 0x109285: main (in /home/jian/helloc/a.out) ==28017== ==28017== LEAK SUMMARY: ==28017== definitely lost: 0 bytes in 0 blocks ==28017== indirectly lost: 0 bytes in 0 blocks ==28017== possibly lost: 0 bytes in 0 blocks ==28017== still reachable: 472 bytes in 1 blocks ==28017== suppressed: 0 bytes in 0 blocks ==28017== ==28017== For lists of detected and suppressed errors, rerun with: -s ==28017== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) </code></pre> <p>if MAXC is larger enough, then no LEAK SUMMARY. however if it's smaller, then there is memory leak error.<br /> How can I fix the memory leak error when MAXC is not large enough to hold the string.</p> <p>I also wonder even if <code>dat/definitions.txt</code> first line is empty new line, then <code>defn[offset-1] = 0;</code> would be <code>defn[-1] = 0;</code> but gcc still no error. should i expect error or warning like above array bounds of array char[112]?</p>
[ { "answer_id": 74235855, "author": "ryyker", "author_id": 645128, "author_profile": "https://Stackoverflow.com/users/645128", "pm_score": 0, "selected": false, "text": "buf" }, { "answer_id": 74235896, "author": "John Bollinger", "author_id": 2402272, "author_profile"...
2022/10/28
[ "https://Stackoverflow.com/questions/74234871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15603477/" ]
74,234,882
<p>I want to be able to comment and uncomment lines which are &quot;managed&quot; using a bash script.</p> <p>I am trying to write a script which will update all of the config lines which have the word #managed after them and remove the preceeding # if it exists.</p> <p>The rest of the config file needs to be left unchanged. The config file looks like this:</p> <p><strong>configFile.txt</strong></p> <pre><code>#config1=abc #managed #config2=abc #managed config3=abc #managed config3=abc </code></pre> <p>This is the script I have created so far. It iterates the file, finds lines which contain &quot;#managed&quot; and detects if they are currently commented.</p> <p>I need to then write this back to the file, how do I do that?</p> <p>manage.sh</p> <pre><code>#!/bin/bash while read line; do STR='#managed' if grep -q &quot;$STR&quot; &lt;&lt;&lt; &quot;$line&quot;; then echo &quot;debug - this is managed&quot; firstLetter=${$line:0:1} if [ &quot;$firstLetter&quot; = &quot;#&quot; ]; then echo &quot;Remove the initial # from this line&quot; fi fi echo &quot;$line&quot; done &lt; configFile.txt </code></pre>
[ { "answer_id": 74235855, "author": "ryyker", "author_id": 645128, "author_profile": "https://Stackoverflow.com/users/645128", "pm_score": 0, "selected": false, "text": "buf" }, { "answer_id": 74235896, "author": "John Bollinger", "author_id": 2402272, "author_profile"...
2022/10/28
[ "https://Stackoverflow.com/questions/74234882", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42106/" ]
74,234,893
<p>How do you extract all values containing part of a particular number and then delete them? I have data where the ID contains different lengths and wants to extract all the IDs with a particular number. For example, if the ID contains either &quot;-00&quot; or &quot;02&quot; or &quot;-01&quot; at the end, pull to be able to see the hit rate that includes those—then delete them from the ID. Is there a more effecient way in creating this code?</p> <p>I tried to use the substring function to slice it to get the result, but there is some other ID along with the specified position.</p> <p>Code:</p> <pre><code>Proc sql; Create table work.data1 AS SELECT Product, Amount_sold, Price_per_unit, CASE WHEN Product Contains &quot;Pen&quot; and Lenghth(ID) &gt;= 9 Then ID = SUBSTR(ID,1,9) WHEN Product Contains &quot;Book&quot; and Lenghth(ID) &gt;= 11 Then ID = SUBSTR(ID,1,11) WHEN Product Contains &quot;Folder&quot; and Lenghth(ID) &gt;= 12 Then ID = SUBSTR(ID,1,12) ... END AS ID FROM A Quit; </code></pre> <p>Have:</p> <pre><code>+------------------+-----------------+-------------+----------------+ | ID | Product | Amount_sold | Price_per_unit | +------------------+-----------------+-------------+----------------+ | 123456789 | Pen | 30 | 2 | | 63495837229-01 | Book | 20 | 5 | | ABC134475472 02 | Folder | 29 | 7 | | AB-1235674467-00 | Pencil | 26 | 1 | | 69598346-02 | Correction pen | 15 | 1.50 | | 6970457688 | Highlighter | 15 | 2 | | 584028467 | Color pencil | 15 | 10 | +------------------+-----------------+-------------+----------------+ </code></pre> <p>Wanted the final result:</p> <pre><code>+------------------+-----------------+-------------+----------------+ | ID | Product | Amount_sold | Price_per_unit | +------------------+-----------------+-------------+----------------+ | 123456789 | Pen | 30 | 2 | | 63495837229 | Book | 20 | 5 | | ABC134475472 | Folder | 29 | 7 | | AB-1235674467 | Pencil | 26 | 1 | | 69598346 | Correction pen | 15 | 1.50 | | 6970457688 | Highlighter | 15 | 2 | | 584028467 | Color pencil | 15 | 10 | +------------------+-----------------+-------------+----------------+ </code></pre>
[ { "answer_id": 74235855, "author": "ryyker", "author_id": 645128, "author_profile": "https://Stackoverflow.com/users/645128", "pm_score": 0, "selected": false, "text": "buf" }, { "answer_id": 74235896, "author": "John Bollinger", "author_id": 2402272, "author_profile"...
2022/10/28
[ "https://Stackoverflow.com/questions/74234893", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16204817/" ]
74,234,904
<p>I have an app that allows users to add notes, and I'm trying to add a delete functionality to the page. My route:</p> <pre><code>router.route('/:id').delete((req, res) =&gt; { Note.findByIdAndDelete(req.params.id) .then(() =&gt; res.json('Exercise deleted!')) .catch(err =&gt; res.status(err).json('Error ' + err)) }) </code></pre> <p>works when I test it in Postman, but I haven't managed to get the ObjectId from the database. It throws an error: Invalid status code: <code>CastError: Cast to ObjectId failed for value &quot;undefined&quot; (type string) at path &quot;_id&quot; for model &quot;Note&quot;</code> .</p> <p>This is my Note schema:</p> <pre><code>const noteSchema = new Schema({ category: {type: String, required: false}, title: {type : String, required: true}, content: {type: String, required: true}, noteID: { type: mongoose.SchemaTypes.ObjectId, required: true, index: true } }, { timestamps: true, }) </code></pre> <p>This is my Note component:</p> <pre><code>import React from &quot;react&quot;; function Note(props) { function handleClick() { props.onDelete(props.id); } return ( &lt;div className=&quot;note&quot;&gt; &lt;h1&gt;{props.title}&lt;/h1&gt; &lt;p&gt;{props.content}&lt;/p&gt; &lt;button onClick={handleClick}&gt; Delete &lt;/button&gt; &lt;p&gt;{props.category}&lt;/p&gt; &lt;/div&gt; ); } export default Note </code></pre> <p>my App component:</p> <pre><code>function App() { const [notes, setNotes] = useState([]); useEffect(() =&gt; { fetch('http://localhost:5000/notes') .then(res =&gt; res.json()) .then(json =&gt; setNotes(json)) }, []) function deleteNote(id) { axios.delete('http://localhost:5000/notes/'+id) .then(response =&gt; { console.log(response.data)}); } {notes.map((noteItem, index) =&gt; { return ( &lt;Note key={index} //id={index} title={noteItem.title} content={noteItem.content} category={noteItem.category} onDelete={deleteNote} /&gt; ); </code></pre> <p>I'm not sure where to pass the id from the database, I tried passing it as a parameter in App.js <code>(deleteNote(note.id))</code> or some variation of it, but it doesn't work. Could someone please tell me which step I'm missing to get the ObjectId? I also tried passigng noteItem._id when mapping notes to the Note component, but that deletes all notes at once. I tried these solutions as well: <a href="https://www.stackoverflow.com/">https://stackoverflow.com/questions/71544895/how-do-i-solve-casterror-cast-to-objectid-failed-for-value-undefined-type-s</a> and <a href="https://www.stackoverflow.com/">https://stackoverflow.com/questions/63253129/successfully-delete-an-object-in-mongodb-using-findbyidanddelete-but-returns-an</a> but I still get errors. Thanks in advance!</p>
[ { "answer_id": 74235855, "author": "ryyker", "author_id": 645128, "author_profile": "https://Stackoverflow.com/users/645128", "pm_score": 0, "selected": false, "text": "buf" }, { "answer_id": 74235896, "author": "John Bollinger", "author_id": 2402272, "author_profile"...
2022/10/28
[ "https://Stackoverflow.com/questions/74234904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17965573/" ]
74,234,908
<p>I have some legacy code that I inherited that creates a class on the fly within a method. The type returned is just &lt;class 'module'&gt;. How do I type hint this?</p> <p>I know I can use <code>Any</code>, but I was hoping for something a bit more specific.</p>
[ { "answer_id": 74234981, "author": "Right leg", "author_id": 7051394, "author_profile": "https://Stackoverflow.com/users/7051394", "pm_score": 0, "selected": false, "text": "Type" }, { "answer_id": 74234985, "author": "Daniil Fajnberg", "author_id": 19770795, "author_...
2022/10/28
[ "https://Stackoverflow.com/questions/74234908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7245066/" ]
74,234,914
<p>I have a specific variable in my .env.dev.local SRV_INST=s01</p> <p>Is there a way to use custom env variables in services.yaml in a conditional way similar to when@dev ? I would like to define some services only when SRV_INST=s01 (something like when %env(SRV_INST)% === 's01').</p> <p>I can use services.php, but I wanted to know if there's a way to do this in services.yaml</p>
[ { "answer_id": 74236893, "author": "user13859151", "author_id": 13859151, "author_profile": "https://Stackoverflow.com/users/13859151", "pm_score": 0, "selected": false, "text": "// config/services.yaml\nimports:\n- { resource: 'services_conditional.php' }\n" }, { "answer_id": 74...
2022/10/28
[ "https://Stackoverflow.com/questions/74234914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13859151/" ]
74,234,920
<p>I have this json I need to format it in Typescript or java script. what would be better way to do.</p> <pre><code>var data = { &quot;value 1&quot; : [ { type : String, Dicription : &quot;abc&quot; }, { type : int, Dicription : &quot;xyz&quot; }, { type : String, Dicription : &quot;pqr&quot; }, ] &quot;value 2&quot; : [ { type : String, Dicription : &quot;abc&quot; } ] &quot;value 3&quot; : [ { type : String, Dicription : &quot;abc&quot; }, { type : int, Dicription : &quot;xyz&quot; } } </code></pre> <p>Need Output like this</p> <pre><code>{ { value : value1, type : String, Description : &quot;abc&quot; }, { value : value1, type : int, Dicription : &quot;xyz&quot; }, { value : value1, type : String, Dicription : &quot;pqr&quot; }, { value : value2, type : String, Description : &quot;abc&quot; }, { value : value3, type : String, Description : &quot;abc&quot; }, { value : value3, type : int, Description : &quot;xyz&quot; } } </code></pre> <p>I tried</p> <pre><code>var new = []; Var values = Object.keys(data) values.ForEach(Function(value){ new.push({ 'value' : value }) }); </code></pre> <p>and iterate it, but could not get desired output. I tried to flatten this but I got objects like {value : value , { type: String ,Description : abc}} What should I do to solve it</p>
[ { "answer_id": 74235026, "author": "Ori Drori", "author_id": 5157454, "author_profile": "https://Stackoverflow.com/users/5157454", "pm_score": 2, "selected": false, "text": "Object.entries()" }, { "answer_id": 74318060, "author": "Learner", "author_id": 1918772, "auth...
2022/10/28
[ "https://Stackoverflow.com/questions/74234920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1918772/" ]
74,234,924
<p>Let's assume I've a Visual Studio solution with 50 C# projects.</p> <p><code>Project 1</code> has a native DLL which gets loaded from <code>Project 1</code>.</p> <p>All other projects depend on <code>Project 1</code>.</p> <p>The native DLL has size of 200 MB and the <code>Copy to Output Directory</code> is set to <code>Copy if newer</code>.</p> <p>When I build this solution, the content of <code>Project 1</code> is copied to the <code>bin\Debug</code> and <code>bin\Release</code> folders of all projects. So I'm having 100 copies of this native DLL which has size of 200 MB. So in total 20 GB.</p> <p>How can I avoid that huge size of my solution directory? It would be nice if I could avoid coping the content of <code>Project 1</code> and use a symbolic link instead. But I found no way for it.</p>
[ { "answer_id": 74235056, "author": "Christian.K", "author_id": 21567, "author_profile": "https://Stackoverflow.com/users/21567", "pm_score": 1, "selected": false, "text": "true" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74234924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7556646/" ]
74,234,951
<p>This component doesnt print on a map function, I seted a console.log inside to be sure that the loop iterates and its iterating but nothing is printed</p> <pre><code>import React from 'react'; import TherapeuticResultElement from &quot;./TherapeuticResultElement&quot; function TherapeuticResult() { return ( &lt;div&gt; &lt;div className=&quot;card shadow py-2 mb-4&quot;&gt; &lt;div className=&quot;card-body&quot;&gt; &lt;div id=&quot;&quot;&gt; &lt;div className=&quot;&quot;&gt; &lt;div className=&quot;row&quot;&gt; { window.COMPOSITE_CATEGORIES.map((category) =&gt; { if(category.composites.length &gt; 0){ console.log(category);//info is shown on console &lt;div&gt;AAAAAAA&lt;/div&gt; } }) } &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; ) } export default TherapeuticResult; </code></pre>
[ { "answer_id": 74235056, "author": "Christian.K", "author_id": 21567, "author_profile": "https://Stackoverflow.com/users/21567", "pm_score": 1, "selected": false, "text": "true" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74234951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19939168/" ]
74,234,952
<p>A simple way of reversing a string is as below:</p> <pre><code>const test = 'hello'; let i = 0; let j = test.length - 1; while (i &lt; j) { let temp = test[i]; test[j] = test[i]; test[i] = temp; i++; j--; } console.log(test); </code></pre> <p>If we try to access string using an index it works fine. For example <code>console.log(test[2])</code> returns <code>'l'</code></p> <p>But reversing a string using the method above returns unchanged string <code>'hello'</code>. We need to use an array, reverse it and then join it to return the reversed string. But in that case we will be using an extra space. Can we do it without using an extra space?</p>
[ { "answer_id": 74235034, "author": "Ben Aston", "author_id": 38522, "author_profile": "https://Stackoverflow.com/users/38522", "pm_score": 1, "selected": false, "text": "Array#join" }, { "answer_id": 74235140, "author": "Carsten Massmann", "author_id": 2610061, "autho...
2022/10/28
[ "https://Stackoverflow.com/questions/74234952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1324023/" ]
74,234,963
<p>My json is</p> <pre class="lang-json prettyprint-override"><code>[{&quot;Date&quot;:&quot;2022-10-27&quot;,&quot;Delta&quot;:60,&quot;Comment&quot;:null},{&quot;Date&quot;:&quot;2022-10-26&quot;,&quot;Delta&quot;:60,&quot;Comment&quot;:null},{&quot;Date&quot;:&quot;2022-10-25&quot;,&quot;Delta&quot;:60,&quot;Comment&quot;:null}] </code></pre> <p>I need to check that <strong>all</strong> Date values are greater than the current time. If so, return true, otherwise false.</p> <p>I tried to do something like this:</p> <pre class="lang-sql prettyprint-override"><code>SELECT CASE WHEN EXISTS (SELECT * FROM XXX WHERE Dates &lt; GETDATE()) THEN CAST(0 AS BIT) ELSE CAST(1 AS BIT) END </code></pre> <p>But I need a table XXX with all the <code>Dates</code> from my json. How do I get them?</p> <p>And am I even thinking the right way to do this, or is there a better option?</p>
[ { "answer_id": 74235003, "author": "Stuck at 1337", "author_id": 20091109, "author_profile": "https://Stackoverflow.com/users/20091109", "pm_score": 3, "selected": true, "text": "DECLARE @json nvarchar(max) = N'[\n {\"Date\":\"2022-10-27\",\"Delta\":60,\"Comment\":null},\n {\"Date\":\"...
2022/10/28
[ "https://Stackoverflow.com/questions/74234963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14448434/" ]
74,235,017
<p>I have made an exe file with Python and now I am trying to make an installer for it. I want to add a command in Inno Setup so after the installation it creates a shortcut to a folder in the installed directory (program folder/mixes). I want the shortcut to be on the desktop. I understand that you do it in the <code>[Icons]</code> sections but the examples I found were making a shortcut to an exe file but I want to make a shortcut to a folder. How do I do that? below is the Inno code:</p> <pre><code>#define MyAppName &quot;Blender&quot; #define MyAppVersion &quot;1.5&quot; #define MyAppExeName &quot;Blender.exe&quot; [Setup] AppName={#MyAppName} AppVersion={#MyAppVersion} DefaultDirName={autopf}\Cybercrete DisableProgramGroupPage=yes [Tasks] Name: &quot;desktopicon&quot;; Description: &quot;{cm:CreateDesktopIcon}&quot;; \ GroupDescription: &quot;{cm:AdditionalIcons}&quot;; Flags: unchecked [Dirs] Name: &quot;{app}&quot;; Permissions: users-full [Files] Source: &quot;C:\CyberCrete\Ver 1.5\Output\Blender\{#MyAppExeName}&quot;; DestDir: &quot;{app}&quot;; \ Flags: ignoreversion ... [Icons] Name: &quot;{autoprograms}\{#MyAppName}&quot;; Filename: &quot;{app}\{#MyAppExeName}&quot; Name: &quot;{autodesktop}\{#MyAppName}&quot;; Filename: &quot;{app}\{#MyAppExeName}&quot;; \ Tasks: desktopicon Name: &quot;{commondesktop}\Setup&quot;; Filename: &quot;{app}\Setup.exe&quot;; \ WorkingDir: &quot;{pf}\Program&quot;; IconFilename: &quot;{app}\Setup.ico&quot; [Run] Filename: &quot;{app}\{#MyAppExeName}&quot;; \ Description: &quot;{cm:LaunchProgram,{#StringChange(MyAppName, '&amp;', '&amp;&amp;')}}&quot;; \ Flags: nowait postinstall skipifsilent` </code></pre> <p>I read many forums but they are about making shortcuts to exe files not folders.</p>
[ { "answer_id": 74235003, "author": "Stuck at 1337", "author_id": 20091109, "author_profile": "https://Stackoverflow.com/users/20091109", "pm_score": 3, "selected": true, "text": "DECLARE @json nvarchar(max) = N'[\n {\"Date\":\"2022-10-27\",\"Delta\":60,\"Comment\":null},\n {\"Date\":\"...
2022/10/28
[ "https://Stackoverflow.com/questions/74235017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19717375/" ]
74,235,030
<p>I'm trying to find customers that bought the same item more than once in different days. I got it partially working. I can't get the customer first/last name and item_name without adding it to the group by clause. In addition, I want to include a count if how many times the same uten was purchased on different days.</p> <p>I suspect that group by is probably not the best solution. Would this be better solved using a self JOIN or perhaps a lead?</p> <pre><code>CREATE TABLE customers (CUSTOMER_ID, FIRST_NAME, LAST_NAME) AS SELECT 1, 'Abby', 'Katz' FROM DUAL UNION ALL SELECT 2, 'Lisa', 'Saladino' FROM DUAL UNION ALL SELECT 3, 'Jerry', 'Torchiano' FROM DUAL; CREATE TABLE items (PRODUCT_ID, PRODUCT_NAME) AS SELECT 100, 'Black Shoes' FROM DUAL UNION ALL SELECT 101, 'Brown Shoes' FROM DUAL UNION ALL SELECT 102, 'White Shoes' FROM DUAL; CREATE TABLE purchases (CUSTOMER_ID, PRODUCT_ID, QUANTITY, PURCHASE_DATE) AS SELECT 1, 100, 1, TIMESTAMP'2022-10-11 09:54:48' FROM DUAL UNION ALL SELECT 1, 100, 1, TIMESTAMP '2022-10-11 19:04:18' FROM DUAL UNION ALL SELECT 2, 101,1, TIMESTAMP '2022-10-11 09:54:48' FROM DUAL UNION ALL SELECT 2,101,1, TIMESTAMP '2022-10-17 19:04:18' FROM DUAL UNION ALL SELECT 3, 101,1, TIMESTAMP '2022-10-11 09:54:48' FROM DUAL UNION ALL SELECT 3,102,1, TIMESTAMP '2022-10-17 19:04:18' FROM DUAL; With CTE as ( SELECT customer_id ,product_id ,trunc(purchase_date) FROM purchases GROUP BY customer_id ,product_id ,trunc(purchase_date) ) SELECT customer_id, product_id FROM CTE GROUP BY customer_id ,product_id HAVING COUNT(1)&gt;1 </code></pre>
[ { "answer_id": 74235003, "author": "Stuck at 1337", "author_id": 20091109, "author_profile": "https://Stackoverflow.com/users/20091109", "pm_score": 3, "selected": true, "text": "DECLARE @json nvarchar(max) = N'[\n {\"Date\":\"2022-10-27\",\"Delta\":60,\"Comment\":null},\n {\"Date\":\"...
2022/10/28
[ "https://Stackoverflow.com/questions/74235030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13645606/" ]
74,235,039
<p>Hi i am trying to host a server my raspberry pi with flask but css does not work. It shows plain html. when i try the same thing with same file names, location and same code it works but from my raspberry pi it does not work?</p> <h2>To Fix I Tried (so don't bother saying):</h2> <ul> <li>Tried using static or normal way</li> <li>Tried doing cmd+shift+R</li> <li>Tried changing file names</li> </ul> <p>HTML:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;THD&lt;/title&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;{{ url_for('static', filename='styles.css') }}&quot;&gt; &lt;/head&gt; &lt;html&gt; </code></pre> <p>FLASK:</p> <pre><code>from flask import Flask, render_template app = Flask(__name__) @app.route(&quot;/&quot;) def main_page(): return render_template('learn.html') </code></pre> <p>TREE VIEW:</p> <p><a href="https://i.stack.imgur.com/okyho.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/okyho.png" alt="tree view" /></a></p> <p>Thank You So Much If You Can Fix It.</p>
[ { "answer_id": 74235209, "author": "hase1010", "author_id": 20197902, "author_profile": "https://Stackoverflow.com/users/20197902", "pm_score": -1, "selected": false, "text": "<!DOCTYPE html>\n<html>\n <head>\n <title>THD</title>\n <link rel= \"stylesheet\" type= \"text/...
2022/10/28
[ "https://Stackoverflow.com/questions/74235039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17466522/" ]
74,235,043
<p>I am pretty new to nuxt and faced a task where i should use multiple optional route parameters. I want to keep my app as simple as it can be, so i would avoid using any additional package. As i know nuxt3 routing depends on the folder structure, so here's the problem:</p> <p>Lets say we got a <code>/foo</code> route, where can be 2 optional parameters, <code> paramA</code> and <code> paramB</code></p> <p>This can be done with the following folder structure:</p> <pre><code>pages/ -foo/ --index.vue --[paramA]/ ---index.vue ---[[paramB]].vue </code></pre> <p>It works, but this way the pages are duplicated for each param.</p> <p>What is the best practice for this? Thank you</p>
[ { "answer_id": 74235185, "author": "hatja", "author_id": 19789773, "author_profile": "https://Stackoverflow.com/users/19789773", "pm_score": 0, "selected": false, "text": "pages/\n-foo/\n--[[paramA]]/\n---[[paramB]].vue\n" }, { "answer_id": 74300736, "author": "hatja", "a...
2022/10/28
[ "https://Stackoverflow.com/questions/74235043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19789773/" ]
74,235,053
<p>I am trying to learn Java on my own for only 3 weeks (from YouTube videos and blogs) and this is my first language. I want to write a program to find missing number (s) in an ascending integer array. I found a way, but it only works if the last number in the incrementing array is less than 10. Like 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.</p> <p>I also found other programs on the internet, but they all have the same problem.</p> <p>I tried to write on my own with my limited 3 week knowledge and succeeded. But I think I took the long way. The code is almost 27 lines long.</p> <p>Let me show you the code I have an integer array with 9 elements: [12, 13, 17, 18, 20, 21, 24, 25, 26] and 14, 15, 16, 19, 22, 23 are missing</p> <pre><code>public class Exercises { public static void main(String[] args) { int[] arr = {12, 13, 17, 18, 20, 21, 24, 25, 26}; int len = arr.length; System.out.println(&quot;\nArray source: \n&quot; + Arrays.toString(arr)); //for avoiding ArrayIndexOutOfBoundsException //error I am creating temp. array with 10 elemets //and adding main array elements to temp. array int[] tempArr = new int[len + 1]; for (int i = 0; i &lt; len; i++) { tempArr[i] = arr[i]; } //adding last element to temp. array int max = 0; for (int i = 0; i &lt; tempArr.length; i++) { if (tempArr[i] &gt; max) { max = tempArr[i]; } } tempArr[tempArr.length - 1] = max + 1; System.out.println(&quot;\nMissing number(S): &quot;); for (int i = 0; i &lt; len - 1; i++) { // If it comes to the last loppf main array // this will be use temp. arrays' last element to // compare main array if (i == (len - 1) &amp;&amp; (tempArr[i + 1] - arr[i]) &gt; 1) { System.out.println(tempArr[i]); } else if ((arr[i + 1] - arr[i]) &gt; 1) { for (int a = 1; a &lt;= (arr[i + 1] - arr[i]) - 1; a++) { System.out.println(arr[i] + a); } } } } } </code></pre> <pre><code>Output: Array source: [12, 13, 17, 18, 20, 21, 24, 25, 26] Missing number(S): 14 15 16 19 22 23 </code></pre> <p>I got what I wanted, but is there a more optimal way to do that?</p> <p>Btw if I want to make code more esthetic it becomes huge :D</p> <pre><code>public class Exercises { public static void main(String[] args) { int[] arr = {12, 13, 17, 18, 20, 21, 24, 25, 26}; int len = arr.length; int[] tempArr = new int[len + 1]; int[] correctArr = new int[MathUtils.max(arr) - MathUtils.min(arr) + 1]; int countArr = (MathUtils.max(arr) - (MathUtils.max(arr) - MathUtils.min(arr)) - 1); for (int i = 0; i &lt; correctArr.length; i++) { countArr++; correctArr[i] = countArr; } System.out.println(&quot;\nArray source: \n&quot; + Arrays.toString(arr)); System.out.println(&quot;Source should be: \n&quot; + Arrays.toString(correctArr)); for (int i = 0; i &lt; len; i++) { tempArr[i] = arr[i]; } int max = 0; for (int i = 0; i &lt; tempArr.length; i++) { if (tempArr[i] &gt; max) { max = tempArr[i]; } } tempArr[tempArr.length - 1] = max + 1; int count = 0; for (int i = 0; i &lt; len - 1; i++) { if (i == (len - 1) &amp;&amp; (tempArr[i + 1] - arr[i]) &gt; 1) { count++; } else if ((arr[i + 1] - arr[i]) &gt; 1) { for (int a = 1; a &lt;= (arr[i + 1] - arr[i]) - 1; a++) { count++; } } } if (count == 1) { System.out.println(&quot;\nThere is only one missing number:&quot;); } else if (count &gt; 1) { System.out.println(&quot;\nThere are &quot; + count + &quot; missing numbers:&quot;); } for (int i = 0; i &lt; len - 1; i++) { if (i == (len - 1) &amp;&amp; (tempArr[i + 1] - arr[i]) &gt; 1) { System.out.println(tempArr[i]); } else if ((arr[i + 1] - arr[i]) &gt; 1) { for (int a = 1; a &lt;= (arr[i + 1] - arr[i]) - 1; a++) { System.out.println(arr[i] + a); } } } } } </code></pre> <pre><code>Output: Array source: [12, 13, 17, 18, 20, 21, 24, 25, 26] Source should be: [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26] There are 6 missing numbers: 14 15 16 19 22 23 </code></pre>
[ { "answer_id": 74235208, "author": "Hovercraft Full Of Eels", "author_id": 522444, "author_profile": "https://Stackoverflow.com/users/522444", "pm_score": 2, "selected": true, "text": "arr[i] + " }, { "answer_id": 74235296, "author": "Community", "author_id": -1, "aut...
2022/10/28
[ "https://Stackoverflow.com/questions/74235053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20205518/" ]
74,235,064
<p>I want to send a custom signal with user data. The user data (coming from a <code>GtkEntry</code>) is not filled upon connecting the signal, but is when the signal is emitted.<br /> How can I emit a signal with the content of a <code>GtkEntry</code> as user data?</p> <p>Right now I have a signal handler for the &quot;standard&quot; signal <code>button_press_event</code>. This handler reads the <code>GtkEntry</code>'s and emits the custom signal. This is where I want de <code>GtkEntry</code> data to be sent as user data.</p> <p>I <strong>do not</strong> want to send a pointer to <code>GtkEntry</code>, since the <code>GtkEntry</code> belongs to <code>login_credentials_screen.c</code></p> <p>I have a UI file:</p> <pre><code>&lt;!-- Generated with glade 3.38.2 --&gt; &lt;interface&gt; &lt;requires lib=&quot;gtk+&quot; version=&quot;3.24&quot;/&gt; &lt;object class=&quot;GtkWindow&quot;&gt; &lt;property name=&quot;can-focus&quot;&gt;False&lt;/property&gt; &lt;child&gt; &lt;object class=&quot;GtkBox&quot;&gt; &lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt; &lt;property name=&quot;can-focus&quot;&gt;False&lt;/property&gt; &lt;property name=&quot;halign&quot;&gt;center&lt;/property&gt; &lt;property name=&quot;valign&quot;&gt;center&lt;/property&gt; &lt;property name=&quot;orientation&quot;&gt;vertical&lt;/property&gt; &lt;child&gt; &lt;object class=&quot;GtkLabel&quot;&gt; &lt;property name=&quot;height-request&quot;&gt;80&lt;/property&gt; &lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt; &lt;property name=&quot;can-focus&quot;&gt;False&lt;/property&gt; &lt;property name=&quot;halign&quot;&gt;center&lt;/property&gt; &lt;property name=&quot;valign&quot;&gt;center&lt;/property&gt; &lt;property name=&quot;label&quot; translatable=&quot;yes&quot;&gt;Enter the correct user code and company code to log in&lt;/property&gt; &lt;property name=&quot;justify&quot;&gt;center&lt;/property&gt; &lt;style&gt; &lt;class name=&quot;text_large&quot;/&gt; &lt;/style&gt; &lt;/object&gt; &lt;packing&gt; &lt;property name=&quot;expand&quot;&gt;False&lt;/property&gt; &lt;property name=&quot;fill&quot;&gt;True&lt;/property&gt; &lt;property name=&quot;position&quot;&gt;1&lt;/property&gt; &lt;/packing&gt; &lt;/child&gt; &lt;child&gt; &lt;object class=&quot;GtkBox&quot;&gt; &lt;property name=&quot;height-request&quot;&gt;40&lt;/property&gt; &lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt; &lt;property name=&quot;can-focus&quot;&gt;False&lt;/property&gt; &lt;property name=&quot;halign&quot;&gt;center&lt;/property&gt; &lt;property name=&quot;valign&quot;&gt;center&lt;/property&gt; &lt;property name=&quot;margin-top&quot;&gt;5&lt;/property&gt; &lt;property name=&quot;spacing&quot;&gt;20&lt;/property&gt; &lt;child&gt; &lt;object class=&quot;GtkEntry&quot; id=&quot;user_code_input&quot;&gt; &lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt; &lt;property name=&quot;can-focus&quot;&gt;True&lt;/property&gt; &lt;property name=&quot;placeholder-text&quot; translatable=&quot;yes&quot;&gt;User code&lt;/property&gt; &lt;/object&gt; &lt;packing&gt; &lt;property name=&quot;expand&quot;&gt;False&lt;/property&gt; &lt;property name=&quot;fill&quot;&gt;True&lt;/property&gt; &lt;property name=&quot;position&quot;&gt;0&lt;/property&gt; &lt;/packing&gt; &lt;/child&gt; &lt;child&gt; &lt;object class=&quot;GtkEntry&quot; id=&quot;company_code_input&quot;&gt; &lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt; &lt;property name=&quot;can-focus&quot;&gt;True&lt;/property&gt; &lt;property name=&quot;placeholder-text&quot; translatable=&quot;yes&quot;&gt;Company code&lt;/property&gt; &lt;/object&gt; &lt;packing&gt; &lt;property name=&quot;expand&quot;&gt;False&lt;/property&gt; &lt;property name=&quot;fill&quot;&gt;True&lt;/property&gt; &lt;property name=&quot;position&quot;&gt;1&lt;/property&gt; &lt;/packing&gt; &lt;/child&gt; &lt;/object&gt; &lt;packing&gt; &lt;property name=&quot;expand&quot;&gt;False&lt;/property&gt; &lt;property name=&quot;fill&quot;&gt;True&lt;/property&gt; &lt;property name=&quot;position&quot;&gt;2&lt;/property&gt; &lt;/packing&gt; &lt;/child&gt; &lt;child&gt; &lt;object class=&quot;GtkEventBox&quot; id=&quot;login_button&quot;&gt; &lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt; &lt;property name=&quot;can-focus&quot;&gt;False&lt;/property&gt; &lt;child&gt; &lt;object class=&quot;GtkLabel&quot;&gt; &lt;property name=&quot;width-request&quot;&gt;250&lt;/property&gt; &lt;property name=&quot;height-request&quot;&gt;60&lt;/property&gt; &lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt; &lt;property name=&quot;can-focus&quot;&gt;False&lt;/property&gt; &lt;property name=&quot;halign&quot;&gt;center&lt;/property&gt; &lt;property name=&quot;margin-top&quot;&gt;15&lt;/property&gt; &lt;property name=&quot;label&quot; translatable=&quot;yes&quot;&gt;Log in&lt;/property&gt; &lt;style&gt; &lt;class name=&quot;login_buttons&quot;/&gt; &lt;class name=&quot;text_normal&quot;/&gt; &lt;/style&gt; &lt;/object&gt; &lt;/child&gt; &lt;/object&gt; &lt;packing&gt; &lt;property name=&quot;expand&quot;&gt;False&lt;/property&gt; &lt;property name=&quot;fill&quot;&gt;True&lt;/property&gt; &lt;property name=&quot;position&quot;&gt;3&lt;/property&gt; &lt;/packing&gt; &lt;/child&gt; &lt;/object&gt; &lt;/child&gt; &lt;/object&gt; &lt;/interface&gt; </code></pre> <p>I have <code>main.c</code>:</p> <pre><code>#include &lt;glib.h&gt; #include &lt;gtk/gtk.h&gt; #include &quot;login_credentials_screen.h&quot; void on_button_clicked(GtkWidget *widget, GdkEvent *event, gpointer data); void main(void) { login_cred_subscribe_login_button_callback(on_button_clicked); } void on_button_clicked(GtkWidget *widget, GdkEvent *event, gpointer data) { printf(&quot;Userdata: %s\n&quot;, data); } </code></pre> <p>And <code>login_credentials_screen.c</code>:</p> <pre><code>GtkBuilder *login_credentials_builder; GObject *login_credentials_screen; GObject *user_code_entry; GObject *company_code_entry; void init_login_credentials_screen(void) { login_credentials_builder = gtk_builder_new_from_file(&quot;login_credentials_screen.ui&quot;); login_credentials_screen = gtk_builder_get_object(login_credentials_builder, &quot;login_credentials_screen&quot;); user_code_entry = gtk_builder_get_object(login_credentials_builder, &quot;user_code_input&quot;); company_code_entry = gtk_builder_get_object(login_credentials_builder, &quot;company_code_input&quot;); g_signal_connect(gtk_builder_get_object(login_credentials_builder, &quot;login_button&quot;), &quot;button_press_event&quot;, G_CALLBACK(on_login_button_clicked), &quot;login_button&quot;); g_signal_new(&quot;login-button-clicked&quot;, G_TYPE_OBJECT, G_SIGNAL_RUN_FIRST, 0, NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); } void login_cred_subscribe_login_button_callback(void *function) { g_signal_connect(gtk_builder_get_object(login_credentials_builder, &quot;login_button&quot;), &quot;login-button-clicked&quot;, G_CALLBACK(function), NULL); //NULL needs to be something else? } void on_login_button_clicked(GtkWidget *widget, GdkEvent *event, gpointer data) { printf(&quot;%s\n&quot;, gtk_entry_get_text(GTK_ENTRY(user_code_entry))); printf(&quot;%s\n&quot;, gtk_entry_get_text(GTK_ENTRY(company_code_entry))); g_signal_emit_by_name(widget, &quot;login-button-clicked&quot;, gtk_entry_get_text(GTK_ENTRY(company_code_entry))); } </code></pre>
[ { "answer_id": 74235208, "author": "Hovercraft Full Of Eels", "author_id": 522444, "author_profile": "https://Stackoverflow.com/users/522444", "pm_score": 2, "selected": true, "text": "arr[i] + " }, { "answer_id": 74235296, "author": "Community", "author_id": -1, "aut...
2022/10/28
[ "https://Stackoverflow.com/questions/74235064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7307021/" ]
74,235,118
<p>I want to get a list with variables and filter it</p> <p>I succeeded in removing unnecessary words, but</p> <p>filtered = [] does not work from here. print(filtered) = []</p> <p>What I want is 'USD' or (and) 'EUR' according to the variable in filtered.</p> <p>Append seems to be the problem... I don't know the cause</p> <p>And in the second code, why is the POA not deleted? Can't delete specific characters from list?</p> <pre><code> def test(): response = [{'1': 0, '2': '2A', '3': True, '4': True, 'QA': ['NZDUSD','NZDEUR','NZDYEN','NZDGBP']}] if response == []: return else: response = str(response [0]['QA']) response = response.replace('NZD','') filtered = [] for data in [response]: if data in ['USD','EUR']: filtered.append(data) # print(data) print(filtered) if 'USD' in filtered and 'EUR' in filtered: print ('USDEUR') elif 'USD' in filtered: print ('USD') elif 'EUR' in filtered: print ('EUR') test() </code></pre> <pre><code>def test(): response = [{'1': 0, '2': '2A', '3': True, '4': True, 'QA': ['POAUSD','POAEUR','POAYEN','POAGBP']}] if response == []: return else: response = response [0]['QA'] for i in range(len(response)): if response[i] == 'POA': response[i] = '' # print(response) filtered = [] for data in [response]: if data in ['USD','EUR']: filtered.append(data) print(data) print(filtered) if 'USD' in filtered and 'EUR' in filtered: return print('USDEUR') elif 'USD' in filtered: return print('USD') elif 'EUR' in filtered: return print('EUR') test() </code></pre>
[ { "answer_id": 74235232, "author": "Swifty", "author_id": 20267366, "author_profile": "https://Stackoverflow.com/users/20267366", "pm_score": 2, "selected": true, "text": "...\n else:\n response = response [0]['QA']\n response = [ word.replace('NZD','') for word in respo...
2022/10/28
[ "https://Stackoverflow.com/questions/74235118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19658442/" ]
74,235,120
<p>In the below example the child width grows with smooth transition, but the parent width is abruptly changed!</p> <p>I want both the child width and parent width transition smoothly.</p> <p>*note the parent has max-width specified, but rest it controlled by the content, which is the child.</p> <p>I tried adding transition ease property to the parent div, and expecting that the width change due to the child will smoothly transition here as well.</p> <p>please check <a href="https://codepen.io/abstrekt/pen/qBKdPZe" rel="nofollow noreferrer">https://codepen.io/abstrekt/pen/qBKdPZe</a></p> <pre class="lang-html prettyprint-override"><code>&lt;div class=&quot;parent&quot;&gt; &lt;div class=&quot;child&quot;&gt;this is the child&lt;/div&gt; &lt;/div&gt; &lt;style&gt; .parent { padding: 8px; display: inline-flex; border: 2px solid red; max-width: 300px; transition: width 1s ease; } .child { white-space: nowrap; overflow: hidden; border: 2px solid green; transition: width 1s ease; width: 20px; } .parent:hover&gt;.child { width: 100% } &lt;/style&gt; </code></pre> <p>I've been looking around for answer, but not able to find one for my usecase.</p>
[ { "answer_id": 74235232, "author": "Swifty", "author_id": 20267366, "author_profile": "https://Stackoverflow.com/users/20267366", "pm_score": 2, "selected": true, "text": "...\n else:\n response = response [0]['QA']\n response = [ word.replace('NZD','') for word in respo...
2022/10/28
[ "https://Stackoverflow.com/questions/74235120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11999089/" ]
74,235,136
<p>I am having issues with opening an Excel file from Jupyter Notebooks on my Mac. I previously saved it to my cloud.</p> <p>To create the Excel, I copy my df to Excel and save it. So far so good.</p> <pre><code>path = '/Users/username/name.xlsx' writer = pd.ExcelWriter(path, engine = 'xlsxwriter') df.to_excel(writer, sheet_name = 'Sheet1') writer.save() writer.close() </code></pre> <p>When I then try to launch it, it won't work.</p> <p>Here's my code:</p> <pre><code>import os os.system(&quot;open -a '/Applications/Microsoft Excel.app' path&quot;) </code></pre> <p>All I get is Output 256 in my notebook and Excel won't open.</p> <p>Would anyone know why?</p>
[ { "answer_id": 74235232, "author": "Swifty", "author_id": 20267366, "author_profile": "https://Stackoverflow.com/users/20267366", "pm_score": 2, "selected": true, "text": "...\n else:\n response = response [0]['QA']\n response = [ word.replace('NZD','') for word in respo...
2022/10/28
[ "https://Stackoverflow.com/questions/74235136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14877604/" ]
74,235,139
<p>views.py The issue I have is on the signup function view. What do I write inside the except block to show an error message to the user according to the validationError given.</p> <p>for example: if the error is &quot;Common Password&quot; it should only display common password message to the user and if it is other errors, it should do the same for their independent messages to the user.</p> <p>Thank you in advance.</p> <pre><code>from django.shortcuts import render,redirect from django.contrib import messages from django.contrib.auth import authenticate,login,logout #from django.contrib.auth.models import User from django.core.mail import send_mail from .models import User from django.contrib.auth.password_validation import validate_password,UserAttributeSimilarityValidator,CommonPasswordValidator,MinimumLengthValidator,NumericPasswordValidator # Create your views here. def signup(request): if request.method == &quot;POST&quot;: username = request.POST.get(&quot;username&quot;) fname = request.POST.get(&quot;fname&quot;) lname = request.POST.get(&quot;lname&quot;) email = request.POST.get(&quot;email&quot;) password = request.POST.get(&quot;password&quot;) password2 = request.POST.get(&quot;password2&quot;) if password: try: new = validate_password(password,password_validators=None) except: messages.error(request, ) return redirect('home') #if User.objects.filter(email=email): #messages.error(request, &quot;E-mail already exist!&quot;) #return redirect('home') #if len(username) &gt; 15: #messages.error(request, &quot;Length of username too long!&quot;) #return redirect('home') #if password != password2: #messages.error(request, &quot;Passwords do not match!&quot;) #return redirect('home') #if not password.isalnum(): #messages.error(request, &quot;Password must be alphanumeric!&quot;) #return redirect('home') user = User.objects.create_user(username=username,first_name=fname,last_name=lname,email=email,password=password) # Welcome E-mail #subject = 'Welcome to ADi meals mobile!' #message = 'Hello {fname}, welcome to ADi meals mobile!\nThank you for visiting our website.\n We have also sent you a confirmation email, please confirm your email address to login into your account.\n\nThanking you\nVictoria Oluwaseyi\nC.E.O' #from_email = settings.EMAIL_HOST_USER #to_list = [user.email] #send_mail(subject,message,from_email,to_list,fail_silently=True) messages.success(request,&quot;Your account has been successfully created!&quot;) #user.is_active = True return redirect('authentication:signin') return render(request,'authentication/signup.html') </code></pre>
[ { "answer_id": 74235232, "author": "Swifty", "author_id": 20267366, "author_profile": "https://Stackoverflow.com/users/20267366", "pm_score": 2, "selected": true, "text": "...\n else:\n response = response [0]['QA']\n response = [ word.replace('NZD','') for word in respo...
2022/10/28
[ "https://Stackoverflow.com/questions/74235139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18729235/" ]
74,235,171
<p>I am currently building vscode extension for multiple platform (extension include jre) who do I pass extension name while building vscode extension.</p> <p>I found this <a href="https://code.visualstudio.com/api/working-with-extensions/publishing-extension" rel="nofollow noreferrer">article</a> but in gradle who do I set extension name?</p> <p>Package.json <a href="https://i.stack.imgur.com/ElWZO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ElWZO.png" alt="enter image description here" /></a></p> <p>extension name got overridden with package.json name.</p> <p><strong>build.gradle</strong></p> <pre><code>task buildLinuxExtension(type: NpxTask) { description &quot;Build the vsix extension package&quot; dependsOn compileLinuxExtension command = 'cd' args = ['LinuxExtension'] command = 'vsce' args = ['package'] } `` </code></pre>
[ { "answer_id": 74235232, "author": "Swifty", "author_id": 20267366, "author_profile": "https://Stackoverflow.com/users/20267366", "pm_score": 2, "selected": true, "text": "...\n else:\n response = response [0]['QA']\n response = [ word.replace('NZD','') for word in respo...
2022/10/28
[ "https://Stackoverflow.com/questions/74235171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4209436/" ]
74,235,179
<p>I have an <code>operator.itemgetter()</code> object, e.g.</p> <pre><code>import operator keyfunc = operator.itemgetter(&quot;key1&quot;, &quot;key2&quot;) </code></pre> <p>Now, I pass it around and later I wish to get the list of keys it was created with, e.g.</p> <pre><code># doesn't exist, but should return something like (&quot;key1&quot;, &quot;key2&quot;) keys = keyfunc.keys() </code></pre> <p>The object stores the keys obviously for use with <code>__call__</code>, and it also prints them:</p> <pre><code>&gt;&gt;&gt; print(keyfunc) operator.itemgetter('key1', 'key2') </code></pre> <p>But I don't spot a member that might return those keys in the output of <code>dir(keyfunc)</code>. The documentation also doesn't list an accessor for this query either.</p> <p>Do I need to parse the output of the string representation (or store and pass the keys alongside the object)?</p> <pre><code># this feels a bit hacky import ast keys = ast.literal_eval(repr(keyfunc).replace(&quot;operator.itemgetter&quot;, &quot;&quot;)) </code></pre>
[ { "answer_id": 74235316, "author": "Andrey Sobolev", "author_id": 1027367, "author_profile": "https://Stackoverflow.com/users/1027367", "pm_score": 1, "selected": false, "text": "class itemgetter:\n __slots__ = ('_items', '_call')\n \n def __init__(self, item, *items):\n ...
2022/10/28
[ "https://Stackoverflow.com/questions/74235179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1025391/" ]
74,235,217
<p>For example:</p> <pre><code>&gt;&gt;&gt; a_b = '1/3' &gt;&gt;&gt; c_b = '5/3' &gt;&gt;&gt; get_fractions(a_b, c_b) '1/3 + 5/3 = 6/3'` </code></pre> <p>I'm trying to solve this but it won't work:</p> <pre><code>def get_fractions(a_b: str, c_b: str) -&gt; str: calculate = int(a_b) + int(c_b) return calculate </code></pre>
[ { "answer_id": 74235421, "author": "Maxwell D. Dorliea", "author_id": 12906648, "author_profile": "https://Stackoverflow.com/users/12906648", "pm_score": 1, "selected": false, "text": "def get_fractions(a_b: str, c_b: str) -> str:\n a_b = a_b.split('/')\n a_n, a_d = a_b[0], a_b[1]\...
2022/10/28
[ "https://Stackoverflow.com/questions/74235217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20352144/" ]
74,235,224
<p>I have a file <code>aa.txt</code>:</p> <pre><code>John Norman Robert Anson Christopher Fowler Robert Harris Dan Simmons </code></pre> <p>I want to enter keywords from the keyboard and check them in the file element by line. If true, output the entire line containing that keyword. For example, if I enter the word &quot;John&quot;, it will output &quot;John Norman&quot; How do I write perl script? (I use perl script because this is an exercise that requires the use of perl) Thanks you very much!</p>
[ { "answer_id": 74235402, "author": "William Pursell", "author_id": 140750, "author_profile": "https://Stackoverflow.com/users/140750", "pm_score": 1, "selected": false, "text": "perl" }, { "answer_id": 74236232, "author": "brian d foy", "author_id": 2766176, "author_p...
2022/10/28
[ "https://Stackoverflow.com/questions/74235224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20358122/" ]
74,235,234
<p>I have a list of 6 dataframes, which all contain the same column names. I would like to subset all 6 dataframes based on the column names matching that of a variable in another column (let's call that 'Index') but am getting stuck.</p> <p>Example: 2 of the dataframes in the list (NB - the index is the same for each dataframe therefore only the same columns needs to be selected for each dataframe):</p> <pre><code>[[0]] a_1 b_1 c_1 a_2 b_2 c_2 Index 3 red no 2 yellow yes 1 [[1]] a_1 b_1 c_1 a_2 b_2 c_2 Index 3 red no 2 yellow yes 2 </code></pre> <p>My desired output</p> <pre><code>[[0]] a_1 b_1 c_1 Index 3 red no 1 [[1]] a_2 b_2 c_2 Index 2 yellow yes 2 </code></pre> <p>I tried the code</p> <pre><code>newlist&lt;-lapply(samplelist,function(x) dplyr::select(ends_with(Index))) </code></pre> <p>This generates the error <em>&quot;Error in is_character(match) : object 'Index' not found&quot;</em>. I'm not sure how to best make this code work, or should I try a different approach altogether?</p> <p>Update:</p> <pre><code>dput(samplelist) `1` = structure(list(ID = 12345, Com = structure(8296, class = &quot;Date&quot;), NCom = structure(8533, class = &quot;Date&quot;), a_1 = &quot;Yes&quot;, b_1 = 160, c_1 = 160, d_1 = &quot;No&quot;, e_1 = 0, f_1 = &quot;No&quot;, g_1 = 0, h_1 = &quot;Yes&quot;, a_2 = &quot;Yes&quot;, b_2 = 155, c_2 = 155, d_2 = &quot;No&quot;, e_2 = 0, d_2 = &quot;No&quot;, e_2 = 0, f_2 = &quot;Yes&quot;, Index = &quot;1&quot;, Index_date = structure(9265, class = &quot;Date&quot;)), row.names = 1L, class = &quot;data.frame&quot;)) `2` = structure(list(Patient_ID = 22222, Com = structure(8296, class = &quot;Date&quot;), NCom = structure(8533, class = &quot;Date&quot;), a_1 = &quot;Yes&quot;, b_1 = 160, c_1 = 160, d_1 = &quot;No&quot;, e_1 = 0, f_1 = &quot;No&quot;, g_1 = 0, h_1 = &quot;Yes&quot;, a_2 = &quot;Yes&quot;, b_2 = 155, c_2 = 155, d_2 = &quot;No&quot;, e_2 = 0, d_2 = &quot;No&quot;, e_2 = 0, f_2 = &quot;Yes&quot;, Index = &quot;2&quot;, Index_date = structure(8835, class = &quot;Date&quot;)), row.names = 2L, class = &quot;data.frame&quot;)) </code></pre>
[ { "answer_id": 74235270, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 2, "selected": true, "text": "lapply(samplelist, function(x) select(x, ends_with(x[[\"Index\"]]))) \n\n$`1`\n a_1 b_1 c_1 d_1 e_1 f_1 g_1 h_1\n1 Ye...
2022/10/28
[ "https://Stackoverflow.com/questions/74235234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19586678/" ]
74,235,245
<p>I have 3 different type of<code>html</code> snippets which are part of a bigger part as follows:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;span _ngcontent-dna-c199=&quot;&quot; class=&quot;font-weight-bold&quot;&gt; &lt;span _ngcontent-dna-c199=&quot;&quot; class=&quot;ng-star-inserted&quot;&gt; &lt;span _ngcontent-dna-c199=&quot;&quot; translate=&quot;&quot;&gt; issue_number &lt;/span&gt; 4 Näköispainos &lt;/span&gt; &lt;span _ngcontent-dna-c199=&quot;&quot; class=&quot;ng-star-inserted&quot;&gt; 6.12.1939 &lt;/span&gt; &lt;/span&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;span _ngcontent-sut-c199=&quot;&quot; class=&quot;font-weight-bold&quot;&gt; &lt;span _ngcontent-sut-c199=&quot;&quot; class=&quot;ng-star-inserted&quot;&gt; &lt;span _ngcontent-sut-c199=&quot;&quot; translate=&quot;&quot;&gt; issue_number &lt;/span&gt; 8 &lt;/span&gt; &lt;span _ngcontent-sut-c199=&quot;&quot; class=&quot;ng-star-inserted&quot;&gt; 1998 &lt;/span&gt; &lt;/span&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;span _ngcontent-dgu-c199=&quot;&quot; class=&quot;font-weight-bold&quot;&gt; &lt;span _ngcontent-dgu-c199=&quot;&quot; class=&quot;ng-star-inserted&quot;&gt; 1905 &lt;/span&gt; &lt;/span&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Given the following code:</p> <pre><code>from bs4 import BeautifulSoup soup = BeautifulSoup(html, &quot;lxml&quot;) # html_1, html_2, html_3 res = soup.find(&quot;span&quot;, class_=&quot;font-weight-bold&quot;) print(res.text.split()) </code></pre> <p>I get the following results:</p> <pre><code>['issue_number', '4', 'Näköispainos', '6.12.1939'] # html_1 ['issue_number', '8', '1998'] # html_2 ['1905'] # html_3 </code></pre> <p>However, my desired custom-made list should have 4 elements and looks like this:</p> <pre><code>desired_list = [&quot;issue_number&quot;, &quot;number&quot;, &quot;extension&quot;, &quot;date&quot;] </code></pre> <p>so if there is no info available in html snippet, I'd like to get <code>None</code> or simply <code>&quot;-&quot;</code> in that specific element of my desired custom list as follows:</p> <pre><code>['issue_number', '4', 'Näköispainos', '6.12.1939'] # html_1 ['issue_number', '8', None, '1998'] # html_2 [None, None, None, '1905'] # html_3 </code></pre> <p>Is there anyway to manipulate the result list to obtain the desired list using <code>soup.find()</code>?</p>
[ { "answer_id": 74236778, "author": "d r", "author_id": 19023353, "author_profile": "https://Stackoverflow.com/users/19023353", "pm_score": 0, "selected": false, "text": "from bs4 import BeautifulSoup\n\npages = [\n'''\n<html>\n <body>\n <span _ngcontent-dna-c199=\"\" class=\"font-weight...
2022/10/28
[ "https://Stackoverflow.com/questions/74235245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5437090/" ]
74,235,258
<p>I have two tables Subjectlist and Day. Subject list is m2m in Day. So my problem is I'm creating school timetable. So for each days different subjects to be shown, when i add subjects on each days the order of subject is same.</p> <p>#Models.py</p> <pre><code> class SubjectList(models.Model): subject_name = models.CharField(max_length=25) def __str__(self): return self.subject_name </code></pre> <pre><code>class Day(models.Model): day_name = models.CharField(max_length=15) subject_name = models.ManyToManyField(SubjectList) class_number = models.ForeignKey(AddClass, on_delete=models.CASCADE, null=True, blank=True) start_time = models.TimeField(null=True, blank=True) end_time = models.TimeField(null=True, blank=True) def __str__(self): return self.class_number.class_number </code></pre> <p>#Views.py</p> <pre><code> class TimeTableView(APIView): def get(self, request, id): class_number = AddClass.objects.get(id=id) day = Day.objects.filter(class_number=class_number.id) print(day) serializer = DaySerializer(day, many=True) return Response(serializer.data) </code></pre> <p>I want to do like this</p> <p>Monday - English, maths, science, Social Science Tuesady - Maths, Social Science, Englih, Math's</p> <p>but i get like this</p> <p>Monday - English, maths, science, Social Science Tuesday- English, maths, science, Social Science</p> <p><a href="https://i.stack.imgur.com/Furkc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Furkc.png" alt="enter image description here" /></a></p> <p>both are in same order even if add subjects in different order.</p>
[ { "answer_id": 74236778, "author": "d r", "author_id": 19023353, "author_profile": "https://Stackoverflow.com/users/19023353", "pm_score": 0, "selected": false, "text": "from bs4 import BeautifulSoup\n\npages = [\n'''\n<html>\n <body>\n <span _ngcontent-dna-c199=\"\" class=\"font-weight...
2022/10/28
[ "https://Stackoverflow.com/questions/74235258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16853253/" ]
74,235,283
<p>I have a continually growing dataframe and periodically I want to retrieve the last row.</p> <pre><code># dbdf.info(memory_usage='deep') &lt;class 'pandas.core.frame.DataFrame'&gt; DatetimeIndex: 6652 entries, 2022-10-23 17:15:00-04:00 to 2022-10-28 08:06:00-04:00 Freq: T Data columns (total 4 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 open 6592 non-null float64 1 high 6592 non-null float64 2 low 6592 non-null float64 3 close 6592 non-null float64 dtypes: float64(4) memory usage: 259.8 KB </code></pre> <p>The dataframe doesn't occupy a very large memory footprint, but notwithstanding, I'd like to understand the most efficient method of retrieving the last row to the extent that I can then call <code>.to_dicts()</code> on that last row.</p> <p>I can certainly do something naive like:</p> <pre><code>bars = dbdf.to_dict(orient=&quot;records&quot;) print(bars[-1]) </code></pre> <p>And in this particular case it would likely be just fine given the small size of the dataframe, but if the dataframe was orders of magnitude larger in memory footprint and rows, is there a better way to achieve the same that could also be considered a best common practise regardless as to the dataframe's footprint?</p>
[ { "answer_id": 74235294, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 3, "selected": false, "text": "DataFrame.iloc" }, { "answer_id": 74235379, "author": "Luicfer Ai", "author_id": 18416403, "auth...
2022/10/28
[ "https://Stackoverflow.com/questions/74235283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4907339/" ]
74,235,345
<p>want to use limit in ClickHouse db like param, which goes to me from front, and I want use limit if I receive it, or not use if not receive.</p> <p>I know example in Postgresql:</p> <pre><code>SELECT * FROM table LIMIT CASE WHEN @param &gt; 0 THEN @param END; </code></pre> <p>But I don't know how it make in ClickHouse without concatenation strokes. Cos if I wrote LIMIT in my sql script then I need set some number, else it won't work.</p> <p>SELECT * FROM table LIMIT CASE WHEN @param &gt; 0 THEN @param END;</p> <p>I want limit by condition.</p>
[ { "answer_id": 74235294, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 3, "selected": false, "text": "DataFrame.iloc" }, { "answer_id": 74235379, "author": "Luicfer Ai", "author_id": 18416403, "auth...
2022/10/28
[ "https://Stackoverflow.com/questions/74235345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13286987/" ]
74,235,353
<p>I want to show <strong>different barplots</strong> for the <strong>years</strong> and <strong>gender</strong> with the <strong>mean values of the variables Q1 to Q5</strong>, which should look like a density.</p> <p>I have data that looks like this:</p> <pre><code>data &lt;- data.frame(userid = c(1,1,1,2,2,2,3,3,3), year = c(2013,2014,2015,2013,2014,2015,2013,2014,2015), gender = c(1,1,1,0,0,0,0,0,0), Q1 = c(3,2,3,1,0,1,2,1,0), Q2 = c(4,3,4,2,0,2,1,4,3), Q3 = c(1,2,1,3,5,4,5,4,5), Q4 = c(1,2,1,2,4,3,2,2,1), Q5 = c(1,1,1,2,1,0,0,0,1)) </code></pre> <p>My solution was to <code>filter()</code> for year and gender first and then use <code>summarise()</code>, to get a vector of the means and put this into the <code>barplot()</code> function:</p> <pre><code>data %&gt;% filter(gender==1,year==2013) %&gt;% select(-userid,-gender,-year) %&gt;% summarise_all(mean) %&gt;% as.numeric() %&gt;% barplot() </code></pre> <p>Instead of doing this for every combination of year and gender, is there a more elegant way, using ggplot and <code>facet_wrap()</code>?</p>
[ { "answer_id": 74235439, "author": "Quinten", "author_id": 14282714, "author_profile": "https://Stackoverflow.com/users/14282714", "pm_score": 1, "selected": false, "text": "facet_wrap" }, { "answer_id": 74235461, "author": "mhovd", "author_id": 3212698, "author_profi...
2022/10/28
[ "https://Stackoverflow.com/questions/74235353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20358149/" ]
74,235,378
<p>I have a webhook listener that uses <code>APIRouter</code> to desginate the route for the application on the server. The app should receive a <code>POST</code> request (expecting data in JSON format) and log this to the console. However, I am getting consistent redirects. I have attempted the following with curl:</p> <pre><code>curl -X 'POST' \ 'http://127.0.0.1:8010/webhook' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{&quot;data&quot;: {&quot;UK&quot;:&quot;test&quot;}}' </code></pre> <p>The listener:</p> <pre class="lang-py prettyprint-override"><code>import hmac from logging import Logger, info from fastapi import APIRouter, FastAPI, Header, Request, Response from router.router1 import rout from pydantic import BaseModel WEBHOOK_SECRET = '123-456-789' class WebhookResponse(BaseModel): result: str class WebhookData(BaseModel): body: dict app = FastAPI() rout = APIRouter() @app.get(&quot;/&quot;) async def welcome() -&gt; dict: return { &quot;message&quot;: 'Hello World!' } def printLog(data): info(f&quot;Raw data: {data}&quot;) @rout.post(&quot;/webhook&quot;, response_model=WebhookResponse, status_code=200) async def webhook( webhook_input: WebhookData, request: Request, response: Response, content_length: int = Header(...), x_hook_signature: str = Header(None) ): if content_length &gt; 1_000_000: # To prevent memory allocation attacks Logger.error(f&quot;Content too long ({content_length})&quot;) response.status_code = 400 return {&quot;result&quot;: &quot;Content too long&quot;} if x_hook_signature: raw_input = await request.body() input_hmac = hmac.new( key=WEBHOOK_SECRET.encode(), msg=raw_input, digestmod=&quot;sha512&quot; ) if not hmac.compare_digest( input_hmac.hexdigest(), x_hook_signature ): Logger.error(&quot;Invalid message signature&quot;) response.status_code = 400 return {&quot;result&quot;: &quot;Invalid message signature&quot;} Logger.info(&quot;Message signature checked ok&quot;) else: Logger.info(&quot;No message signature to check&quot;) printLog(webhook_input) return {&quot;result&quot;: &quot;ok&quot;} app.include_router(rout) </code></pre> <p>Curl prints the following:</p> <pre class="lang-json prettyprint-override"><code>{ &quot;detail&quot;: [ { &quot;loc&quot;: [ &quot;body&quot; ], &quot;msg&quot;: &quot;value is not a valid dict&quot;, &quot;type&quot;: &quot;type_error.dict&quot; } ] } </code></pre> <p>With the following printed to console:</p> <pre><code>INFO: 127.0.0.1:50192 - &quot;POST /webhook/ HTTP/1.1&quot; 422 Unprocessable Entity </code></pre>
[ { "answer_id": 74235439, "author": "Quinten", "author_id": 14282714, "author_profile": "https://Stackoverflow.com/users/14282714", "pm_score": 1, "selected": false, "text": "facet_wrap" }, { "answer_id": 74235461, "author": "mhovd", "author_id": 3212698, "author_profi...
2022/10/28
[ "https://Stackoverflow.com/questions/74235378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17663902/" ]
74,235,395
<p><a href="https://i.stack.imgur.com/lA0ch.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lA0ch.png" alt="enter image description here" /></a></p> <p>I'm trying to remove the commas from this data set so they can be converted to <code>int</code> and be summed up all but I can't seem to find any way to do it without introducing spaces to the number values.</p> <p><a href="https://i.stack.imgur.com/r89mu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r89mu.png" alt="enter image description here" /></a></p> <pre><code> parse = g.readlines()[8:] for x in parse: val0 = x.strip(',') val = val0.split(&quot; &quot;) i15.append(val[1]) </code></pre> <p>this is my current code trying to remove the commas.</p>
[ { "answer_id": 74235467, "author": "Kungfu panda", "author_id": 15349625, "author_profile": "https://Stackoverflow.com/users/15349625", "pm_score": 1, "selected": false, "text": "parse = g.readlines()[8:]\nfor x in parse:\n val0 = x.replace(',' , '')\n val = val0.split(\" \")\n ...
2022/10/28
[ "https://Stackoverflow.com/questions/74235395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20356404/" ]
74,235,457
<p>How to use <a href="https://github.com/tengbao/vanta" rel="nofollow noreferrer">Vanta JS</a> from <a href="https://github.com/sveltejs/kit" rel="nofollow noreferrer">SvelteKit</a> project? <br/> I've tried,in <code>+page.svelte</code>,</p> <pre class="lang-html prettyprint-override"><code>&lt;script lang=&quot;ts&quot;&gt; import VANTA from &quot;vanta&quot;; import * as THREE from 'three'; VANTA.NET({ el: &quot;#home-page&quot;, mouseControls: true, ... }) &lt;/script&gt; &lt;div id=&quot;home-page&quot;&gt; ... &lt;/div&gt; </code></pre> <p>But could not import VANTA in that way. <br/> I also tried to use CDN from <code>app.html</code> but no luck.</p> <h2>Edited</h2> <p>Thanks to <a href="https://stackoverflow.com/questions/74235457/how-to-use-vantajs-in-sveltekit/74235837#74235837">answer of H.B.</a>, I could add the Vanta JS background on my SvelteKit page. <br/> However, the rendering result is different with the one of CodePen.</p> <pre class="lang-html prettyprint-override"><code>&lt;script&gt; import * as THREE from 'three'; import NET from 'vanta/dist/vanta.net.min'; function vanta(node) { NET({ el: node, THREE: THREE, mouseControls: true, touchControls: true, gyroControls: false, minHeight: 200.00, minWidth: 200.00, scale: 1.00, scaleMobile: 1.00, color: 0x7accfe, backgroundColor: 0x010f18 }) } &lt;/script&gt; &lt;div use:vanta/&gt; </code></pre> <p>On SvelteKit webapp, <a href="https://i.stack.imgur.com/gvdf1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gvdf1.png" alt="enter image description here" /></a></p> <p>On CodePen, <a href="https://i.stack.imgur.com/DxjBR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DxjBR.png" alt="enter image description here" /></a></p> <p>In the browser console, I got this message: <br/> <code>THREE.Material: 'vertexColors' parameter is undefined.</code></p> <p>I installed Vanta JS and Three.js like this,</p> <pre class="lang-bash prettyprint-override"><code>npm install -D vanta npm install -D three </code></pre>
[ { "answer_id": 74235837, "author": "H.B.", "author_id": 546730, "author_profile": "https://Stackoverflow.com/users/546730", "pm_score": 2, "selected": true, "text": "onMount" }, { "answer_id": 74236409, "author": "DumTux", "author_id": 12570573, "author_profile": "htt...
2022/10/28
[ "https://Stackoverflow.com/questions/74235457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12570573/" ]
74,235,464
<p>I am developing an android app using Jetpack Compose and have a timer implemented using launchedEffect here is some dummy code for clearance</p> <pre><code>LaunchedEffect(key1 = timeLeft) { if(timeLeft &gt; 0) { delay(100L) timeLeft -= 100L } } </code></pre> <p>my problem is that when the app is in the background the LaunchedEffect stops running and the timer is &quot;stuck&quot; on the same value until I return to the app</p>
[ { "answer_id": 74235837, "author": "H.B.", "author_id": 546730, "author_profile": "https://Stackoverflow.com/users/546730", "pm_score": 2, "selected": true, "text": "onMount" }, { "answer_id": 74236409, "author": "DumTux", "author_id": 12570573, "author_profile": "htt...
2022/10/28
[ "https://Stackoverflow.com/questions/74235464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8477849/" ]
74,235,483
<p>We upgraded the mobile development project we are working on to React Native v0.70.3 from 0.66.4 and our build starting to give all sort of issue in our build server after that. Both iOS and Android builds are failing with following error messages.</p> <p><strong>Android:</strong></p> <blockquote> <p>FAILURE: Build failed with an exception.</p> <p>What went wrong: Execution failed for task ':react-native-camera-kit:verifyReleaseResources'. A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action Android resource linking failed ERROR:/Users/jenkinsoffshore/CICDBuilds/workspace/Mobile-Service-Android/node_modules/react-native-camera-kit/android/build/intermediates/merged_res/release/values/values.xml:2784: AAPT: error: resource android:attr/lStar not found.</p> </blockquote> <p><strong>iOS:</strong></p> <blockquote> <p>iOS build ends in success and we can upload to testflight as well. but getting the following error in email and the app crashes in devices.</p> <p>ITMS-90863: Apple silicon Macs support issue - The app links with libraries that are not present on Mac: @rpath/hermes.framework/hermes</p> <p>After you’ve corrected the issues, you can upload a new binary to App Store Connect</p> </blockquote> <p>We upgraded the MacOS version to Ventura and Xcode along with in the build machine. In developer machine both builds work fine.</p> <p>Do we have to do anything specifically after upgrading to React Native 0.70.3?</p>
[ { "answer_id": 74235837, "author": "H.B.", "author_id": 546730, "author_profile": "https://Stackoverflow.com/users/546730", "pm_score": 2, "selected": true, "text": "onMount" }, { "answer_id": 74236409, "author": "DumTux", "author_id": 12570573, "author_profile": "htt...
2022/10/28
[ "https://Stackoverflow.com/questions/74235483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2627777/" ]
74,235,556
<p>How can I <strong>subtract</strong> from the <strong>navbar_height</strong> for example <strong><strong>2rem</strong></strong> in the following function?</p> <pre><code>navbar_height = document.querySelector(&quot;.navbar&quot;).offsetHeight; document.body.style.paddingTop = navbar_height + &quot;px&quot;; </code></pre> <p>Thanks!</p>
[ { "answer_id": 74235626, "author": "Cerbrus", "author_id": 1835379, "author_profile": "https://Stackoverflow.com/users/1835379", "pm_score": 2, "selected": true, "text": "calc" }, { "answer_id": 74235637, "author": "tacoshy", "author_id": 14072420, "author_profile": "...
2022/10/28
[ "https://Stackoverflow.com/questions/74235556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15578124/" ]
74,235,558
<p>I'm trying to get extract the x-value from the maximum y-value in python. This is what I've got so far:</p> <pre><code># reading Hanford and Livingston signals # read hanford measurement h1_name, h1_start_time, h1_strain = read_data(join(path, &quot;H-H1_LOSC_4_V2-1126259446-32.hdf5&quot;)) # read livingston measurement l1_name, l1_start_time, l1_strain = read_data(join(path, &quot;L-L1_LOSC_4_V2-1126259446-32.hdf5&quot;)) # zero-padded FFT or DFT x_hat = np.fft.fftshift(np.fft.fft(sc.hann(len(h1_strain)) * h1_strain)) t = np.linspace(0, 32, len(h1_strain)) plt.figure('h1_strain') sig_xH = plt.plot(t, h1_strain, label='$x_{H}[n]$ signal') plt.xlabel('time [s]') plt.ylabel('strain') plt.legend() plt.figure('l1_strain') sig_xL = plt.plot(t, l1_strain, label='$x_{L}[n]$ signal', color='blue') plt.xlabel('time [s]') plt.ylabel('strain') plt.legend() plt.show() # THIS IS WHERE I WANT THE MAX, MIN AND MEAN VALUE OF THE PLOT BELOW ON THE X-AXIS FOR THE TIME print('2 b)', min(h1_strain), '= minimum value signal h1_strain') print('2 b)', max(h1_strain), '= maximum value signal h1_strain') print('2 b)', np.mean(h1_strain), '= mean value signal h1_strain') print('2 b)', min(l1_strain), '= minimum value signal h1_strain') print('2 b)', max(l1_strain), '= maximum value signal h1_strain') print('2 b)', np.mean(l1_strain), '= mean value signal h1_strain') </code></pre> <p>I´ve tried using the index()-function. This did not work.</p>
[ { "answer_id": 74235626, "author": "Cerbrus", "author_id": 1835379, "author_profile": "https://Stackoverflow.com/users/1835379", "pm_score": 2, "selected": true, "text": "calc" }, { "answer_id": 74235637, "author": "tacoshy", "author_id": 14072420, "author_profile": "...
2022/10/28
[ "https://Stackoverflow.com/questions/74235558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20358171/" ]
74,235,561
<p>I am looking for a way to show a quotation mark at the beginning of each line of a quotation. Is there a way to do this in HTML/CSS?</p> <p>In older, pre-20th century typography, quotation marks were often placed not only at the beginning and the end of a quotation, but also at the beginning of every line of the quoted text (see example below). I would like to mimic this on an HTML-website, but in such a way that the quotation marks stay to the left even if the lines get rearranged, e.g. a smaller screen. Is there a way to do this?</p> <p>Below is an example of the result I want to achieve:</p> <p><a href="https://i.stack.imgur.com/Us847.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Us847.png" alt="enter image description here" /></a></p> <p>(example of multiple quotation marks to the left side of a longer quotation in <em>Het leven van den H. Augustinus</em>)</p>
[ { "answer_id": 74236946, "author": "Yogi", "author_id": 943435, "author_profile": "https://Stackoverflow.com/users/943435", "pm_score": 2, "selected": false, "text": "h4 {\n color: blue;\n margin-bottom: 0;\n}\n\n\n.old-quote {\n display: inline-block;\n position: relative;\n paddin...
2022/10/28
[ "https://Stackoverflow.com/questions/74235561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20358147/" ]
74,235,582
<p>I'm making a dictionary in which the keys will be one-character symbols separates by a space that the user inputs. I'm assuming that I have call the ord value in a separate line but I'm not sure how to correctly phrase it. Below is the code I have currently:</p> <pre class="lang-py prettyprint-override"><code>inp = input() inp = inp.split(&quot; &quot;) d = dict.fromkeys(inp, ord(inp)) print(d) </code></pre>
[ { "answer_id": 74235789, "author": "Ben", "author_id": 458741, "author_profile": "https://Stackoverflow.com/users/458741", "pm_score": 1, "selected": false, "text": "inp = input()\nd = {x: ord(x) for x in inp}\nprint(d)\n" }, { "answer_id": 74235984, "author": "Sefa_Kurtuldu"...
2022/10/28
[ "https://Stackoverflow.com/questions/74235582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20352757/" ]
74,235,645
<p>Need to remove all the text from any given string after the date part, which is mentioned as duration with a hyphen in between</p> <p>For e.g., x = &quot;AB - CEPC - Telephone_BAU_CPM_Link - 20Jan22 - 30Jan22 - Video Package - XXXX - Optimize&quot;</p> <p>Expression I'm currently using: gsub(&quot;[0-9 A-Z a-z]<em>[22] \- [0-9 A-Z a-z]</em>[22].*&quot;, &quot;\1&quot;, x)</p> <p>Output: AB - CEPC - Telephone_BAU_CPM_Link - 20Jan22 - 30Jan22</p> <p>However, the space before &amp; after the hyphen might not be present always, for e.g.,</p> <p>x = &quot;AB - CEPC - Telephone_BAU_CPM_Link - 20Jan22-30Jan22 - Video Package - XXXX - Optimize&quot;</p> <p>The above mentioned regex isn't working in this case</p>
[ { "answer_id": 74235688, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 2, "selected": true, "text": "sub()" }, { "answer_id": 74235795, "author": "AndS.", "author_id": 9778513, "author_profi...
2022/10/28
[ "https://Stackoverflow.com/questions/74235645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20358334/" ]
74,235,647
<p>In my app I'm trying to change the state of route when I click submit in my SignIn component. I want to pass onRouteChange as props. Is the function not being passed to the other component?</p> <p>App:</p> <pre><code>class App extends Component { constructor() { super(); this.state = { route: &quot;signed-out&quot; }; } onRouteChange = () =&gt; { this.setState({ route: &quot;home&quot; }); }; render() { return ( &lt;div class='main'&gt; {this.state.route === &quot;signed-out&quot; ? ( &lt;div&gt; &lt;SignIn onRouteChange={this.onRouteChange}/&gt; &lt;/div&gt; ) : ( &lt;div&gt; &lt;SignOut /&gt; &lt;/div&gt; )} &lt;/div&gt; ); } } </code></pre> <p>SignIn Component:</p> <pre><code> const SignIn = ({ onRouteChange }) =&gt; { return ( &lt;div&gt; &lt;form&gt; &lt;div&gt;Sign In&lt;/div&gt; &lt;div&gt;Email&lt;/div&gt; &lt;input type='email' /&gt; &lt;div&gt;Password&lt;/div&gt; &lt;input type='password' /&gt; &lt;input onClick={onRouteChange} type='submit' /&gt; &lt;/form&gt; &lt;/div&gt; ); }; </code></pre>
[ { "answer_id": 74235688, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 2, "selected": true, "text": "sub()" }, { "answer_id": 74235795, "author": "AndS.", "author_id": 9778513, "author_profi...
2022/10/28
[ "https://Stackoverflow.com/questions/74235647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16838756/" ]
74,235,709
<p>I am trying to enter variables to use in an API call app. When I use the normal python input thing, it works, but I want to be able to enter these via the entry widget with tkinter. When I try to use the tkinter entry widget, it does not work.</p> <p>`</p> <pre><code>import API_test import tkinter from tkinter import * import random import requests from tkinter.ttk import * ##root for Tkinter app root = tkinter.Tk() root.geometry(&quot;1000x400&quot;) with open('inputfile.txt', 'w') as fp: fp.truncate(0) stringvar1 = tkinter.StringVar() stringvar2 = tkinter.StringVar() ##tkinter labels L1 = tkinter.Label(text=&quot;Enter City &quot;,) L2 = tkinter.Label(text = &quot;Enter Cuisine &quot;,) ##tkinter entry rootentry1 = tkinter.Entry(root, textvariable=stringvar1) rootentry2 = tkinter.Entry(root, textvariable=stringvar2) ###buttoninput ##tkinter button ##tkinter label and entry placement L1.grid(row=0,column=0) rootentry1.grid(row=0,column=1) L2.grid(row=1,column=0) rootentry2.grid(row=1,column=1) def inputfile(): locvarentry = stringvar1 catvarentry = stringvar2 with open('inputfile.txt', 'w') as fw: fw.write(str(locvarentry)+ &quot;,&quot;) fw.write(str(catvarentry)+ &quot;,&quot;) B1 = tkinter.Button( root,rtext=&quot;Submit&quot;, command=inputfile) B1.grid(row=3, column=0) </code></pre> <p>The rest of the program has an API call using yelp in a different module and returns a display saying that the number of restaurants in is . I have that covered, but I am not sure how to handle the input. `</p> <p>I tried playing around with variables, using .get() and .set() in different combinations.</p>
[ { "answer_id": 74235688, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 2, "selected": true, "text": "sub()" }, { "answer_id": 74235795, "author": "AndS.", "author_id": 9778513, "author_profi...
2022/10/28
[ "https://Stackoverflow.com/questions/74235709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7577225/" ]
74,235,748
<p>On <code>React Carbon Select component</code> I want to have a default selected option, which can be changed, of course.<br/> In general my goal is to implement edit functionality.<br/> It means user should be able to change already selected option.<br/> I tried with adding the <code>value</code> property directly in <code>Select</code> like <code>value={defaultSelected}</code> or <code>defaultValue={defaultSelected}</code> but it didn't work.</p> <p>Code example.</p> <pre><code>import React, { useState } from 'react'; import { Select, SelectItem } from '@carbon/react'; const options = [ { value: 'apple', text: 'Apple ', }, { value: 'banana', text: 'Banana ', }, { value: 'kiwi', text: 'Kiwi ', }, ]; const SelectCarbon = ({defaultSelected}) =&gt; { const [formData, setFormData] = useState(); const onChange = e =&gt; { setFormData({ ...formData, fruit: e.target.value, }); }; console.log('formData', formData); return ( &lt;&gt; {defaultSelected} &lt;Select id=&quot;select-fruits&quot; onChange={onChange} value={defaultSelected}&gt; &lt;SelectItem text=&quot;select Option&quot; value=&quot;&quot; /&gt; {options.map(option =&gt; ( &lt;SelectItem key={option.value} text={option.value} value={option.value} /&gt; ))} &lt;/Select&gt; &lt;/&gt; ); }; export default SelectCarbon; </code></pre> <p>Any help will be appreciated</p>
[ { "answer_id": 74235688, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 2, "selected": true, "text": "sub()" }, { "answer_id": 74235795, "author": "AndS.", "author_id": 9778513, "author_profi...
2022/10/28
[ "https://Stackoverflow.com/questions/74235748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12971921/" ]
74,235,757
<p>I want to check if tomcat server is really started up. When you start tomcat, you get an entry like &quot;Server startup&quot; in <code>catalina.out</code>. Once I got this, the script should go ahead.</p> <p>That's my code</p> <pre><code> echo &quot;Waiting for Tomcat&quot; if [ $(tail -f /home/0511/myapp/logs/catalina.out | grep &quot;Server startup&quot; | wc -l) -eq 1 ]; then echo &quot;Tomcat started&quot; fi #further code... </code></pre> <p>Output:</p> <pre><code>Waiting for Tomcat | </code></pre> <p>So, I am sure, after 30-60 seconds, the &quot;<code>tail .. | wc -l</code>&quot; gets 1. However, I cannot match it with my code above. Nothing happens, I have to interrupt per CTRL C.</p> <p>What is wrong or is there any better solution for my intention?</p>
[ { "answer_id": 74235838, "author": "Thomas", "author_id": 14637, "author_profile": "https://Stackoverflow.com/users/14637", "pm_score": -1, "selected": false, "text": "grep" }, { "answer_id": 74235904, "author": "Ron", "author_id": 2291328, "author_profile": "https://...
2022/10/28
[ "https://Stackoverflow.com/questions/74235757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3249103/" ]
74,235,764
<p>I've made a stored procedure to get practice with cursors, I've a problem with special characters, for instance, if last_name contains a single quote, I've got an error, I need to escape it in some way, how could I do that? I don't know which special characters are contained in these fields, I've tried with QUOTENAME(d.last_name) but it didn't work</p> <pre><code>CREATE OR alter PROCEDURE list_employees AS BEGIN DECLARE cursore CURSOR FAST_FORWARD FOR SELECT TOP(20) d.id, d.first_name, d.last_name, cd.contact FROM employees d JOIN contacts cd ON cd.fk_employee= d.id ORDER BY d.id; DECLARE @id_employee VARCHAR(36); DECLARE @first_name VARCHAR(50); DECLARE @last_name VARCHAR(50); DECLARE @contact VARCHAR(255); DECLARE @insert_statement varchar(1000); IF OBJECT_ID('dbo.list_employees', 'U') IS NOT NULL BEGIN DROP TABLE dbo.list_employees; END OPEN cursore; FETCH NEXT FROM cursore INTO @id_employee , @first_name , @cognome, @contatto ; if(@@FETCH_STATUS = 0) BEGIN CREATE TABLE dbo.list_employees(id_employee VARCHAR(36), first_name VARCHAR(50), last_name VARCHAR(50), contact VARCHAR(255)) END WHILE @@FETCH_STATUS = 0 BEGIN SET @insert_statement = 'INSERT INTO list_employees SELECT '''+@id_employee +''', '''+@first_name +''', '''+@last_name +''','''+ @contact +'''' exec(@insert_statement ) FETCH NEXT FROM cursore INTO @id_employee , @first_name , @last_name , @contact ; END CLOSE cursore; DEALLOCATE cursore; END; </code></pre>
[ { "answer_id": 74235880, "author": "Sean Lange", "author_id": 3813116, "author_profile": "https://Stackoverflow.com/users/3813116", "pm_score": 2, "selected": false, "text": "create or alter view list_employees as\n SELECT TOP(20) d.id\n , d.first_name\n , d.last_name\n ...
2022/10/28
[ "https://Stackoverflow.com/questions/74235764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12213074/" ]
74,235,773
<p>Currently I have angular app with routing. The routes work fine when accessed from the app, but when I try to copy and paste certain link in a new tab, I get that the module could not be loaded. example <code>http://localhost:4200/updates</code> works fine both opened in the application and in new tab, yet <code>http://localhost:4200/updates/repositories/Test/units</code> (Test is parameter which is passed from the calling component)this url works only in the app, when pasted in a new tab the error that I am seeing is:</p> <p><code>Uncaught SyntaxError: expected expression, got '&lt;' scripts.91672879d55182c59502.js:1</code></p> <p><code>Loading module from “http://localhost:4200/updates/repositories/sumDev/main-es2017.233f600c1169f07fe825.js” was blocked because of a disallowed MIME type (“text/html”).</code></p> <p><code>units Loading failed for the module with source “http://localhost:4200/updates/repositories/sumDev/main-es2017.233f600c1169f07fe825.js”.</code></p> <p>this is my dependency setup:</p> <pre><code> &quot;dependencies&quot;: { &quot;@angular-devkit/build-angular&quot;: &quot;^0.1102.14&quot;, &quot;@angular/animations&quot;: &quot;~11.2.14&quot;, &quot;@angular/cdk&quot;: &quot;^11.2.13&quot;, &quot;@angular/common&quot;: &quot;~11.2.14&quot;, &quot;@angular/compiler&quot;: &quot;~11.2.14&quot;, &quot;@angular/core&quot;: &quot;~11.2.14&quot;, &quot;@angular/forms&quot;: &quot;~11.2.14&quot;, &quot;@angular/localize&quot;: &quot;^11.2.14&quot;, &quot;@angular/material&quot;: &quot;^11.2.13&quot;, &quot;@angular/platform-browser&quot;: &quot;~11.2.14&quot;, &quot;@angular/platform-browser-dynamic&quot;: &quot;~11.2.14&quot;, &quot;@angular/router&quot;: &quot;~11.2.14&quot;, &quot;@auth0/angular-jwt&quot;: &quot;^5.0.2&quot;, &quot;@delite/dlt-icons&quot;: &quot;^1.1.5&quot;, &quot;classlist.js&quot;: &quot;^1.1.20150312&quot;, &quot;hammerjs&quot;: &quot;^2.0.8&quot;, &quot;keycloak-angular&quot;: &quot;^8.2.0&quot;, &quot;keycloak-js&quot;: &quot;^13.0.0&quot;, &quot;net&quot;: &quot;^1.0.2&quot;, &quot;ng-http-loader&quot;: &quot;^5.1.0&quot;, &quot;rxjs&quot;: &quot;~6.6.7&quot;, &quot;sockjs-client&quot;: &quot;^1.6.1&quot;, &quot;stompjs&quot;: &quot;^2.3.3&quot;, &quot;tslib&quot;: &quot;^2.0.0&quot;, &quot;zone.js&quot;: &quot;~0.11.3&quot; }, &quot;devDependencies&quot;: { &quot;@angular/cli&quot;: &quot;~11.2.14&quot;, &quot;@angular/compiler-cli&quot;: &quot;~11.2.14&quot;, &quot;@angular/language-service&quot;: &quot;~11.2.14&quot;, &quot;@types/core-js&quot;: &quot;^2.5.4&quot;, &quot;@types/jasmine&quot;: &quot;~3.6.0&quot;, &quot;@types/jasminewd2&quot;: &quot;~2.0.3&quot;, &quot;@types/node&quot;: &quot;^12.11.1&quot;, &quot;codelyzer&quot;: &quot;^6.0.0&quot;, &quot;jasmine-core&quot;: &quot;~3.6.0&quot;, &quot;jasmine-spec-reporter&quot;: &quot;~5.0.0&quot;, &quot;karma&quot;: &quot;^6.3.4&quot;, &quot;karma-chrome-launcher&quot;: &quot;~3.1.0&quot;, &quot;karma-coverage-istanbul-reporter&quot;: &quot;~3.0.2&quot;, &quot;karma-jasmine&quot;: &quot;~4.0.0&quot;, &quot;karma-jasmine-html-reporter&quot;: &quot;^1.5.0&quot;, &quot;protractor&quot;: &quot;~7.0.0&quot;, &quot;ts-node&quot;: &quot;~7.0.0&quot;, &quot;tslint&quot;: &quot;~6.1.0&quot;, &quot;typescript&quot;: &quot;^4.0.8&quot; } </code></pre> <p>this is the routing module:</p> <pre><code>const routes: Routes = [{ path: '', canActivate: [AuthGuard], children: [ { path: '', redirectTo: &quot;installer&quot;, pathMatch: &quot;full&quot; },{ path: 'updates', component: UpdateRepositoryComponent, children: [ { path: 'repositories/:name/units', component: UnitsComponent, } ] }] }] @NgModule({ imports: [RouterModule.forRoot(routes, {relativeLinkResolution: 'legacy'})], exports: [RouterModule] }) export class AppRoutingModule {} </code></pre> <p>And this is how I navigate <code>this.router.navigate([this.router.url + </code>/repositories/${name}/units<code>]);</code></p>
[ { "answer_id": 74235967, "author": "Mohammed", "author_id": 8973254, "author_profile": "https://Stackoverflow.com/users/8973254", "pm_score": 0, "selected": false, "text": "window.open(url, '_blank');\n" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74235773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4341933/" ]
74,235,780
<p>the Program entry point function is WinMain and it doesn't create a Window so it runs in the background. I want to get a notification when the program is closed like: by the user through task manager or through system shutdown so I can save some progress.</p> <p>something like the windows messages WM_QUITE but I can't access that as far as I know cuz i don't create a window</p>
[ { "answer_id": 74235967, "author": "Mohammed", "author_id": 8973254, "author_profile": "https://Stackoverflow.com/users/8973254", "pm_score": 0, "selected": false, "text": "window.open(url, '_blank');\n" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74235780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15802736/" ]
74,235,784
<p>Please check the codes and let me know , where i made the mistake that submenu of sidebar is not opening on click. Working code to my link is attached.<a href="https://codepen.io/TA0011/pen/yLjWwGQ" rel="nofollow noreferrer">https://codepen.io/TA0011/pen/yLjWwGQ</a>. I tried to do but couldn't, I shall be highly obliged if you can help me in creating submenu of services which is initially kept hidden and i want to display on click by event listener method.</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>//for sidebar const sidebar = document.querySelector('#mySidebar') const toggle = document.querySelector('#sidebar-toggle') toggle.addEventListener('click', toggleSidebar) function toggleSidebar(e) { toggle.classList.toggle('open') sidebar.classList.toggle('open'); } //for sidebar //for sidebar submenu const caretButton = document.querySelectorAll(".caret"); caretButton.forEach((el) =&gt; el.addEventListener("click", (event) =&gt; { const subMenu = event.target.parentElement.querySelector(".sub-menu"); subMenu.classList.toggle("show"); }) );</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>*{ margin:0; padding:0; list-style:none; box-sizing:border-box; text-decoration:none; } header{ height: 50px; width:100%; background: coral; position:fixed; } header img{ height: 40px; width:40px; margin: 5px; } #sidebar-toggle{ display: inline-block; cursor: grab; background: rgba(0, 136,169, 1); border-radius: 50%; padding: 5px 10px; height: 40px; width: 40px; margin-top: 5px; float:right; } #sidebar-toggle div{ width: 20px; height: 2px; background-color: #fff; margin: 6px 0; transition: all 0.3s ease 0s; cursor: grab; } #sidebar-toggle.open .bar4 { transform: translate(0, 8px) rotate(-45deg); } #sidebar-toggle.open .bar5 { opacity: 0; } #sidebar-toggle.open .bar6 { transform: translate(0px, -8px) rotate(45deg); } #mySidebar{ transition:all 0.2s linear; transform:translateX(-250px); display:flex; flex-direction:column; height:calc(100vh - 50px); box-sizing:border-box; top:50px; } /* then a few properties removed and box-sizing added */ .sidebar{ position: fixed; top:0; left: 0; background-color: #fff; width: 15.625rem; box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.75); z-index: 0; transition: all 0.5s ease; } .open.sidebar { display: flex; } .sidebar-nav { flex:1 ; overflow:auto; } #mySidebar.open{ transform:translateX(0); } .sidebar-header{ padding: 0px; width: 100%; background: rgba(0, 136,169, 1); height: 3rem; } .sidebar-header .profile{ display: flex; color: #fff; } .profile .profile-image img{ flex-wrap: wrap; pointer-events: none; border-radius: 50%; width: 40px; float: none; display: block; object-fit: fill; height: 40px; margin-left: 20px; } .profile .profile-name{ display: inline-flex; display: flex; align-items: center; justify-content: center; margin: 0 2px 0 5px; font-size: 14px; font-weight: 600 !important; } .profile .profile-name i{ margin: -2px 5px 0 2px; font-size: 16px; } .profile-stats{ margin: 10px 0; color: #fff; font-size: 12px; display: flex; flex-direction: row; gap: 0.25rem; align-items: center; cursor: pointer; } .profile-stats .stats{ display: flex; flex-direction: column; flex: 1; align-items: center; justify-content: center; } #followerCount, #mediaCount,#followingCount{ font-size: 10px; } .sidebar-nav{ margin: 0; overflow: auto; } .sidebar-nav ul { display:flex; flex-direction: column; justify-content: center; align-items: flex-start; list-style:none; padding: 0 15px; line-height: 30px; box-sizing:border-box; } .sidebar-nav ul li{ width:100%; box-sizing:border-box; color:#007bff; padding: 5px 10px; margin: 1px 0; } .sidebar-nav ul li a{ text-decoration:none; } .sidebar-nav ul .active, .sidebar-nav ul .active a .icon{ background:#007bff; color: #ffffff; border-radius: 10px; } .sidebar-nav ul li:hover, .sidebar-nav ul li:hover a .icon, .sidebar-nav ul li:hover a{ background:#007bff; color: #ffffff; border-radius: 10px; } .sidebar-nav ul li a .icon{ color:#007bff; width:30px; display: inline-block; } .sidebar-nav ul li a .caret{ left: 90px; position: relative; } .sidebar-nav .sidebar-nav-header{ text-transform: uppercase; font-size: 11px; margin: -0.75rem 1.5rem; color:#0c7db1; } .sidebar-footer{ background: #FF7F50; text-align: center; } .sidebar-footer span a{ display: block; padding:.5em 0; color: #fff; background: #FF7F50; font-weight: 600 !important; text-decoration:none; } .sidebar-footer span i{ width: 30px; font-size: 16px; } .sidebar-nav ul .sub-menu{ display:none; } .sidebar-nav ul .sub-menu.show{ display:flex; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.2/css/all.min.css"&gt; &lt;header&gt; &lt;img src="https://www.tailorbrands.com/wp-content/uploads/2020/07/mcdonalds-logo.jpg" class="logo" alt="Logo"&gt; &lt;div id="sidebar-toggle"&gt; &lt;div class="bar4"&gt;&lt;/div&gt; &lt;div class="bar5"&gt;&lt;/div&gt; &lt;div class="bar6"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/header&gt; &lt;div class="sidebar" id="mySidebar"&gt; &lt;div class="sidebar-header"&gt; &lt;div class="profile"&gt; &lt;div class="profile-image"&gt; &lt;img src="https://media-exp1.licdn.com/dms/image/C560BAQHMnA03XDdf3w/company-logo_200_200/0/1519855918965?e=2147483647&amp;v=beta&amp;t=J3kUMZwIphc90TFKH5oOO9Sa9K59fimgJf-s_okU3zs"&gt; &lt;/div&gt; &lt;div class="profile-name"&gt; &lt;i class="fas fa-chess-pawn"&gt;&lt;/i&gt;&lt;span&gt;Umann Goswami&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;&lt;!--sidebar-header--&gt; &lt;div class="sidebar-nav"&gt; &lt;ul&gt; &lt;li class="active"&gt;&lt;a href=""&gt;&lt;span class="icon"&gt;&lt;i class="fas fa-home"&gt;&lt;/i&gt;&lt;/span&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a&gt;&lt;span class="icon"&gt;&lt;i class="fas fa-chart-bar"&gt;&lt;/i&gt;&lt;/span&gt;Services&lt;span class="caret fas fa-angle-down"&lt;/a&gt; &lt;ul class="sub-menu"&gt; &lt;li&gt;&lt;a href=""&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;&lt;span class="icon"&gt;&lt;i class="fas fa-pen-nib"&gt;&lt;/i&gt;&lt;/span&gt;Connect&lt;/a&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;&lt;span class="icon"&gt;&lt;i class="fas fa-file-alt"&gt;&lt;/i&gt;&lt;/span&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;&lt;span class="icon"&gt;&lt;i class="far fa-comments"&gt;&lt;/i&gt;&lt;/span&gt;home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;&lt;span class="icon"&gt;&lt;i class="fas fa-cog"&gt;&lt;/i&gt;&lt;/span&gt;home&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div class="sidebar-nav-header"&gt; Admin &lt;/div&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=""&gt;&lt;span class="icon"&gt;&lt;i class="fas fa-users"&gt;&lt;/i&gt;&lt;/span&gt;home&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div class="sidebar-nav-header"&gt; Profile &lt;/div&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=""&gt;&lt;span class="icon"&gt;&lt;i class="fas fa-user"&gt;&lt;/i&gt;&lt;/span&gt;home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;&lt;span class="icon"&gt;&lt;i class="fas fa-user-edit"&gt;&lt;/i&gt;&lt;/span&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div class="sidebar-nav-header"&gt; Analysis &lt;/div&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=""&gt;&lt;span class="icon"&gt;&lt;i class="fas fa-user"&gt;&lt;/i&gt;&lt;/span&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;&lt;span class="icon"&gt;&lt;i class="fas fa-user-edit"&gt;&lt;/i&gt;&lt;/span&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;&lt;!--sidebar-nav--&gt; &lt;div class="sidebar-footer"&gt; &lt;span&gt;&lt;a href=""&gt;&lt;i class="fas fa-power-off"&gt;&lt;/i&gt;Logout&lt;/span&gt;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt;&lt;!--sidebar--&gt; </code></pre> </div> </div> </p>
[ { "answer_id": 74235967, "author": "Mohammed", "author_id": 8973254, "author_profile": "https://Stackoverflow.com/users/8973254", "pm_score": 0, "selected": false, "text": "window.open(url, '_blank');\n" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74235784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19171988/" ]
74,235,791
<p>im trying to set up universal links in a react-native project, thought this part shouldt have anything to do with react-native.</p> <p>i have uploaded the file correctly at: example.com/.well-known/apple-app-site-association</p> <p>i created a simple html file to test the universal link: <a href="https://example.com/" rel="nofollow noreferrer">open</a></p> <p>but im having a wierd problem where the syntax of the &quot;path&quot; section determines if the universal link works or not.</p> <p>this does not work:</p> <p>syntax 1:</p> <pre><code>&quot;paths&quot;: [ &quot;*&quot; ] </code></pre> <p>syntax 2:</p> <pre><code>&quot;paths&quot;: [&quot;*&quot;] </code></pre> <p>however, this works:</p> <p>syntax 3:</p> <pre><code>&quot;paths&quot;: [ &quot;*&quot; ] </code></pre> <p>i prefer syntax 1, as i think its the most clean one. especially if i start adding more routes. i want this one to work, i dont want to use syntax 2 or 3.</p> <p>i also checked some other websites like facebook and youtube, and they all have the syntax 1, with linebreaks for every path.</p> <p>i cant imagine why linebreaks and spaces have any effect. what could possibly be an explanation for this?</p>
[ { "answer_id": 74400537, "author": "hndvf", "author_id": 12197001, "author_profile": "https://Stackoverflow.com/users/12197001", "pm_score": 1, "selected": true, "text": "applinks" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74235791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12197001/" ]
74,235,806
<p>I have the following lists:</p> <pre><code>l1 = list(range(10)) l2 = [False for i in range(10)] </code></pre> <p>I can merge them into a list of dictionaries by implementing the following code:</p> <pre><code>res = [{l1[i]: l2[i] for i in range(len(l1))}] </code></pre> <p>My result is the following:</p> <pre><code>[{0: False, 1: False, 2: False, 3: False, 4: False, 5: False, 6: False, 7: False, 8: False, 9: False}] </code></pre> <p>I would like to repeat the content of the dictionary <code>x</code> times. For example, if <code>x=2</code> the <code>res</code> list would be the following:</p> <pre><code>[{0: False, 1: False, 2: False, 3: False, 4: False, 5: False, 6: False, 7: False, 8: False, 9: False}, {0: False, 1: False, 2: False, 3: False, 4: False, 5: False, 6: False, 7: False, 8: False, 9: False}] </code></pre> <p>My question is:<br /> How can I repeat the content of the dictionary based on the <code>x</code> number and save the result on the <code>res</code> list?</p> <p>Thanks</p>
[ { "answer_id": 74235856, "author": "Rabinzel", "author_id": 15521392, "author_profile": "https://Stackoverflow.com/users/15521392", "pm_score": 2, "selected": false, "text": "N=3\nres = [{l1[i]: l2[i] for i in range(len(l1))} for _ in range(N)]\nprint(res)\n" }, { "answer_id": 74...
2022/10/28
[ "https://Stackoverflow.com/questions/74235806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10331807/" ]
74,235,846
<p>How can I populate the placeholder [COUNT] in the following Linux find command with total number of files plus folders for each sub-directory inside SomeFolder where am using bash:</p> <pre><code>find '/SomeFolder' -maxdepth 1 -mindepth 1 -type d -printf '%f **[COUNT]**\n' | sort </code></pre>
[ { "answer_id": 74235856, "author": "Rabinzel", "author_id": 15521392, "author_profile": "https://Stackoverflow.com/users/15521392", "pm_score": 2, "selected": false, "text": "N=3\nres = [{l1[i]: l2[i] for i in range(len(l1))} for _ in range(N)]\nprint(res)\n" }, { "answer_id": 74...
2022/10/28
[ "https://Stackoverflow.com/questions/74235846", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2155873/" ]
74,235,898
<p>I am making a website that needs to show charts. For that, I decided to use Chart JS.</p> <p>The problem, is that when I try to load multiple charts on the same page, I am not able to do it.</p> <p>For some reason, it's only loading one chart, but the second one is not doing it.</p> <p>I have check the variables name, and the id, and I don't see where the fail could be at.</p> <p>Thank you!</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;!DOCTYPE html&gt; &lt;html lang="es"&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;Title&lt;/title&gt; &lt;link rel="stylesheet" href="./assets/css/normalize.css"&gt; &lt;link rel="stylesheet" href="./assets/css/style.css"&gt; &lt;/head&gt; &lt;body&gt; &lt;!-- CONTENIDO PRINCIPAL --&gt; &lt;main id="main-content"&gt; &lt;div class="general-chart"&gt; &lt;span&gt;X€&lt;/span&gt;&lt;br&gt; &lt;span style="font-size: 0.9em; font-weight: 400;"&gt;in Octobre&lt;/span&gt; &lt;canvas id="myChart"&gt;&lt;/canvas&gt; &lt;/div&gt; &lt;div class="income-chart"&gt; &lt;canvas id="myChart_second"&gt;&lt;/canvas&gt; &lt;/div&gt; &lt;/main&gt; &lt;!-- CHART JS --&gt; &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.9.1/chart.min.js" integrity="sha512-ElRFoEQdI5Ht6kZvyzXhYG9NqjtkmlkfYk0wr6wHxU9JEHakS7UJZNeml5ALk+8IKlU6jDgMabC3vkumRokgJA==" crossorigin="anonymous" referrerpolicy="no-referrer"&gt; &lt;/script&gt; &lt;!-- Scripts --&gt; &lt;script src="./js/menu.js"&gt;&lt;/script&gt; &lt;!-- GRAFICO SALDO --&gt; &lt;script&gt; const ctx = document.getElementById("myChart").getContext("2d"); const labels = [ '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', ]; //Gradient Fill var gradient = ctx.createLinearGradient(0, 0, 0, 400); gradient.addColorStop(0, 'rgba(105,53,211, 1'); gradient.addColorStop(1, 'rgba(105,53,211, 0.2'); const data = { labels, datasets: [ { data: [211, 326, 165, 350, 420, 370, 500, 376, 415], label: 'Titulo', fill: true, backgroundColor: gradient, borderColor: '#6935D3', pointBackgroundColor: '#4D1BB1', }, ], }; const config = { type: 'line', data: data, options: { responsive: true, plugins: {legend:{display: false}}, scales: { x: { grid: { display: false, drawBorder: false } }, y: { grid: { display: false, drawBorder: false }, ticks: { display: false }, } }, }, }; const myChart = new Chart(ctx, config); &lt;/script&gt; &lt;!-- GRAFICO INGRESOS --&gt; &lt;script&gt; const ctx2 = document.getElementById("myChart_second").getContext("2d"); const labels2 = [ '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', ]; const data2 = { labels2, datasets: [ { data: [211, 326, 165, 350, 420, 370, 500, 376, 415], label: 'Title', fill: true, backgroundColor: gradient, borderColor: '#6935D3', pointBackgroundColor: '#4D1BB1', }, ], }; const config2 = { type: 'line', data: data2, options: { responsive: true, plugins: {legend:{display: false}}, scales: { x: { grid: { display: false, drawBorder: false } }, y: { grid: { display: false, drawBorder: false }, ticks: { display: false }, } }, }, }; const myChart2 = new Chart(ctx2, config2); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74236132, "author": "Junaid Shaikh", "author_id": 17033432, "author_profile": "https://Stackoverflow.com/users/17033432", "pm_score": 3, "selected": true, "text": "const data2 = {\n labels : labels2, //change here\n datasets: [\n ...
2022/10/28
[ "https://Stackoverflow.com/questions/74235898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19730567/" ]
74,235,946
<p>I would like to generate a relatively random list of 20 nouns which all have the same ending, using Spacy. In my case, the language is German, and an example ending could be “-keit”.</p> <p>I believe that Spacy has a large list of words in <code>nlp.vocab</code> for each language within the package, but if I iterate over it, I don’t know if the order will be random or identical for each run.</p> <p>I know that Spacy also has a <code>Corpus</code> object, and I’m wondering if that supports methods more suitable for searching for particular examples of a specific linguistic form.</p> <p>If <code>NLP.Vocab</code> is not a comprehensive word-list over a given language, is there a dataset commonly used in the Spacy universe to load in that contains a complete vocabulary?</p>
[ { "answer_id": 74236132, "author": "Junaid Shaikh", "author_id": 17033432, "author_profile": "https://Stackoverflow.com/users/17033432", "pm_score": 3, "selected": true, "text": "const data2 = {\n labels : labels2, //change here\n datasets: [\n ...
2022/10/28
[ "https://Stackoverflow.com/questions/74235946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17755462/" ]
74,235,952
<p>What is wrong with this code?</p> <pre><code>Data antibiotics; set antibiotics; weight2=(IF weight=999,THEN weight2=.); else weight2 = weight; run;` </code></pre> <p>I'm trying to create a new variable for weight that accounts for missing data in SAS</p>
[ { "answer_id": 74236109, "author": "Stu Sztukowski", "author_id": 5342700, "author_profile": "https://Stackoverflow.com/users/5342700", "pm_score": 2, "selected": false, "text": "if" }, { "answer_id": 74242513, "author": "Richard", "author_id": 1249962, "author_profil...
2022/10/28
[ "https://Stackoverflow.com/questions/74235952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20358599/" ]
74,235,956
<p>I am using a while loop in python in a project and it's not getting any updates and I have to turn it off and on again. Is there a way to make it update?</p> <p>Here's the code:</p> <pre class="lang-py prettyprint-override"><code>import imaplib username =&quot;example@gmail.com&quot; app_password= &quot;example&quot; gmail_host= 'imap.gmail.com' mail = imaplib.IMAP4_SSL(gmail_host) mail.login(username, app_password) mail.select() _, selected_mails = mail.search(None, 'ALL') while True: print({len(selected_mails[0].split())}) </code></pre> <p>Output:</p> <pre class="lang-py prettyprint-override"><code>{19} {19} {19} {19} {19} {19} {19} {19} {19} {19} {19} ... </code></pre> <p>So the output is {19} meaning there are currently 19 emails in my inbox, but when I send one to myself it doesn't update to {20}.</p> <p>How to get it to update(with the current code)?</p>
[ { "answer_id": 74235993, "author": "Juleaume", "author_id": 14990454, "author_profile": "https://Stackoverflow.com/users/14990454", "pm_score": 1, "selected": false, "text": "import imaplib\nusername =\"example@gmail.com\"\napp_password= \"example\"\ngmail_host= 'imap.gmail.com'\nmail = ...
2022/10/28
[ "https://Stackoverflow.com/questions/74235956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17856469/" ]
74,235,958
<p>I run Vim and change my current location all the time via shortcuts.</p> <p>Then when I exit Vim, I want to be in the directory of the file I was in, in the bash shell.</p> <p>How do I go about doing that?</p>
[ { "answer_id": 74237225, "author": "phd", "author_id": 7976758, "author_profile": "https://Stackoverflow.com/users/7976758", "pm_score": 4, "selected": true, "text": "vim" }, { "answer_id": 74247439, "author": "Jetchisel", "author_id": 4452265, "author_profile": "http...
2022/10/28
[ "https://Stackoverflow.com/questions/74235958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/322537/" ]
74,235,962
<p>I try to create a simple exchange rate program that converts one currency to other. It is almost done. After clicking convert button, result should be shown also as span and h1 format, nevertheless, I am able to demonstrate abbreviation of currencies not fullname of them. Their fullnames are in &quot;currencies[i [1&quot;.</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 before = document.querySelector("span") const after = document.querySelector("h1") const input = document.querySelector("input") const select = document.querySelectorAll("select") const converted = document.querySelector("#converted") const convertBtn = document.querySelector("button") fetch("https://api.frankfurter.app/currencies") .then(data =&gt; data.json()) .then(data =&gt; display(data)) //creating currency options for select element const display = data =&gt; { const currencies = (Object.entries(data)) for (let i = 0; i &lt; currencies.length; i++) { select[0].innerHTML += `&lt;option value="${currencies[i][0]}"&gt;${currencies[i][0]}&lt;/option&gt;` select[1].innerHTML += `&lt;option value="${currencies[i][0]}"&gt;${currencies[i][0]}&lt;/option&gt;` } } //event of convert button convertBtn.addEventListener("click", () =&gt; { let filledCurrency = select[0].value let wantedCurrency = select[1].value let value = input.value if (filledCurrency != wantedCurrency) { convert(filledCurrency, wantedCurrency, value) } else { alert("You have chosen same currency") } }) //convert method const convert = (filledCurrency, wantedCurrency, value) =&gt; { const host = "api.frankfurter.app" fetch( `https://${host}/latest?amount=${value}&amp;from=${filledCurrency}&amp;to=${wantedCurrency}` ) .then(value =&gt; value.json()) .then(value =&gt; { converted.value = Object.values(value.rates)[0]; before.textContent = `${input.value} ${filledCurrency} EQUALS` after.textContent = `${input.value} ${wantedCurrency}` }) } //prevent whitespace input input.addEventListener('keypress', function(e) { var key = e.keyCode; if (key === 32) { e.preventDefault(); } });</code></pre> </div> </div> </p> <p><a href="https://i.stack.imgur.com/dbwPn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dbwPn.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74236045, "author": "mplungjan", "author_id": 295783, "author_profile": "https://Stackoverflow.com/users/295783", "pm_score": 1, "selected": false, "text": "const host = \"https://api.frankfurter.app\"\nconst filledCurrency = document.getElementById(\"filledCurrency\");\nc...
2022/10/28
[ "https://Stackoverflow.com/questions/74235962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19802770/" ]
74,235,974
<p>Subsetting on a column with NA returns a whole row of NA. I know there are multiple ways to avoid this; my question is why does this happen at all? For example:</p> <pre><code>&gt; d&lt;-data.frame(a = 1:3, b = c(NA, 2, 5)) &gt; d[d$b == 2,] a b NA NA NA 2 2 2 </code></pre> <p>I would understand if it simply returned row 1 also, but it returns a whole row of NA which never existed in the object I subsetted. This seems strange and unhelpful, and I can't find an explanation of <strong>why</strong> this behavior exists (again, I know how to prevent it).</p>
[ { "answer_id": 74236092, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 3, "selected": true, "text": "d$b == 2" }, { "answer_id": 74236226, "author": "Rui Barradas", "author_id": 8245406, "author_prof...
2022/10/28
[ "https://Stackoverflow.com/questions/74235974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2607106/" ]
74,235,976
<p>I want to not to display the null value fields in template.So How can i achieve this in django?Is there any functions available to do this.</p>
[ { "answer_id": 74236092, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 3, "selected": true, "text": "d$b == 2" }, { "answer_id": 74236226, "author": "Rui Barradas", "author_id": 8245406, "author_prof...
2022/10/28
[ "https://Stackoverflow.com/questions/74235976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20055057/" ]
74,236,003
<p>I am receiving Images using Kafka Consumer. Here it is the snippet:</p> <pre><code>byte[][] message_send = new byte[size_array] [] ; //create matrix System.out.println(&quot;Starting Consuming&quot;); while ((dispatcher.AcceptedNumberJobs &gt; 0) || (dispatcher.queue_size &gt; 0) ) { dispatcher.consumer.subscribe(Collections.singletonList(Topic)); System.out.println(&quot;Polling&quot;); ConsumerRecords&lt;String,byte[]&gt; records = dispatcher.consumer.poll(Duration.ofMillis(10)); int i = 0; for (ConsumerRecord record : records) { dispatcher.AcceptedNumberJobs -= 1; dispatcher.queue_size -= 1; System.out.println(record.getClass()); System.out.println(record.value().getClass()); message_send[i]= java.util.Arrays.copyOf((byte[])record.value(), ((byte[])record.value()).length); </code></pre> <p>The consumer is create as follows:</p> <pre><code> Properties prop = new Properties(); prop.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG , BootstrapServer); prop.setProperty(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName()); prop.setProperty(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName()); prop.setProperty(ConsumerConfig.GROUP_ID_CONFIG, ConsumerID); prop.setProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG , &quot;earliest&quot;); prop.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, 1); KafkaConsumer&lt;String , byte[]&gt; consumer = new KafkaConsumer &lt;String , byte[]&gt;(prop); consumer.subscribe(Arrays.asList(Topic)); </code></pre> <p>When I copy the record to message_send I get the following error:</p> <pre><code>Exception in thread &quot;main&quot; java.lang.ClassCastException: class java.lang.String cannot be cast to class [B (java.lang.String and [B are in module java.base of loader 'bootstrap') </code></pre> <p>Could you help me in this?</p> <hr /> <p>Update: I changed the consumer config with:</p> <pre><code>prop.setProperty(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class.getName()); </code></pre> <p>However I get another weird behaviour, the first image is correctly received, the other elements in the array are null. Could you help me in this? Also, are there reference which are just not reference for apache kafka in Java?</p> <p>So:</p> <p>message_send[0] has a value, the other do not.</p>
[ { "answer_id": 74236092, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 3, "selected": true, "text": "d$b == 2" }, { "answer_id": 74236226, "author": "Rui Barradas", "author_id": 8245406, "author_prof...
2022/10/28
[ "https://Stackoverflow.com/questions/74236003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8759653/" ]
74,236,020
<h1>pip install mysqlclient</h1> <pre><code>Collecting mysqlclient Using cached mysqlclient-2.1.1.tar.gz (88 kB) Preparing metadata (setup.py) ... error error: subprocess-exited-with-error × python setup.py egg_info did not run successfully. │ exit code: 1 ╰─&gt; [16 lines of output] /bin/sh: 1: mysql_config: not found /bin/sh: 1: mariadb_config: not found /bin/sh: 1: mysql_config: not found Traceback (most recent call last): File &quot;&lt;string&gt;&quot;, line 2, in &lt;module&gt; File &quot;&lt;pip-setuptools-caller&gt;&quot;, line 34, in &lt;module&gt; File &quot;/tmp/pip-install-k_urbzi_/mysqlclient_beba1330b6804b2990fa74f56f11c3f5/setup.py&quot;, line 15, in &lt;module&gt; metadata, options = get_config() File &quot;/tmp/pip-install-k_urbzi_/mysqlclient_beba1330b6804b2990fa74f56f11c3f5/setup_posix.py&quot;, line 70, in get_config libs = mysql_config(&quot;libs&quot;) File &quot;/tmp/pip-install-k_urbzi_/mysqlclient_beba1330b6804b2990fa74f56f11c3f5/setup_posix.py&quot;, line 31, in mysql_config raise OSError(&quot;{} not found&quot;.format(_mysql_config_path)) OSError: mysql_config not found mysql_config --version mariadb_config --version mysql_config --libs [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─&gt; See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details. </code></pre> <p>Please help me to fix the error.</p> <h1>python -V</h1> <p>Python 3.9.2</p> <h1>pip list</h1> <p>Package Version</p> <hr /> <p>pip 22.3 pkg_resources 0.0.0 setuptools 65.5.0</p>
[ { "answer_id": 74236092, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 3, "selected": true, "text": "d$b == 2" }, { "answer_id": 74236226, "author": "Rui Barradas", "author_id": 8245406, "author_prof...
2022/10/28
[ "https://Stackoverflow.com/questions/74236020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16796964/" ]
74,236,080
<p>So I have 20 images and I want to put them to a list. But I only know how to do it by appending them one by one which wastes a lot of space. I did try for loop, but I do not know how to make it work.</p> <p>This is what I want to do, but by using a loop:</p> <pre><code>list = [] list.append(image1) list.append(image2) ... list.append(image20) </code></pre> <p>What I have tried:</p> <pre><code>for i in range 20 a = str(i) list.append(image.join(a)) </code></pre> <p>&quot;image is not defined&quot; is the obvious error I get and I understand what is causing it. The &quot;image&quot; is not defined and I am typing it acting as it should be a variable. Is it somehow possible to change the variable &quot;image&quot; into a string, add str(i) onto it, and then change it back to a variable that includes the number? After which I could input it to the append function.</p>
[ { "answer_id": 74236092, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 3, "selected": true, "text": "d$b == 2" }, { "answer_id": 74236226, "author": "Rui Barradas", "author_id": 8245406, "author_prof...
2022/10/28
[ "https://Stackoverflow.com/questions/74236080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20358657/" ]
74,236,084
<p>I was scraping a dynamic page with selenium and I got stuck getting <strong>text 1</strong> and <strong>text 2</strong> in the following example:</p> <p><code>&lt;span class=&quot;class number 1&quot;&gt; text 1 &lt;a href=&quot;link 1&quot;&gt; text 2 &lt;/a&gt; &lt;/span&gt;</code></p> <p>The same happens if the span is instead a div.</p> <hr /> <p>I managed to get text 1 with this python line</p> <p><code>var = driver.find_element(By.CLASS_NAME, &quot;class number 1&quot;).text&quot;</code></p> <p>However, to get text 2, since link 1 is generated, say, randomly, I can't refer to the href in any way!</p> <p>Any help is really appreciated</p>
[ { "answer_id": 74237557, "author": "AbiSaran", "author_id": 7671727, "author_profile": "https://Stackoverflow.com/users/7671727", "pm_score": 2, "selected": false, "text": "driver.find_element(By.XPATH, \".//span[@class='class number 1']/a\").text\n" }, { "answer_id": 74237646, ...
2022/10/28
[ "https://Stackoverflow.com/questions/74236084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14554472/" ]
74,236,089
<p>I have a component which contains 2 divs and i want to show only one div for eg: Show only div 1 on page /contact Show only div 2 on page /profile and /about</p> <p>filter.component.html</p> <pre><code>//div 1 &lt;div&gt; //some content &lt;div&gt; //div 2 &lt;div&gt; //some content &lt;div&gt; </code></pre>
[ { "answer_id": 74237557, "author": "AbiSaran", "author_id": 7671727, "author_profile": "https://Stackoverflow.com/users/7671727", "pm_score": 2, "selected": false, "text": "driver.find_element(By.XPATH, \".//span[@class='class number 1']/a\").text\n" }, { "answer_id": 74237646, ...
2022/10/28
[ "https://Stackoverflow.com/questions/74236089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19610519/" ]
74,236,106
<p>I've just installed IntelliJ Fleet to make the switch from VSCode and I've noticed that in my TypeScript code every time I try to format code (<kbd>Cmd + Opt + L</kbd>) it adds a trailing semicolon to every statement, even though I have no such option enabled in ESLint.</p> <p>How can I disable this?</p>
[ { "answer_id": 74236200, "author": "Archigan", "author_id": 14333778, "author_profile": "https://Stackoverflow.com/users/14333778", "pm_score": 0, "selected": false, "text": "eslintrc.yml" }, { "answer_id": 74236466, "author": "Tobias S.", "author_id": 8613630, "autho...
2022/10/28
[ "https://Stackoverflow.com/questions/74236106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5298491/" ]
74,236,141
<p>Hello I want to transition div's height smoothly when I append an element to it, but I cannot get it to work I read this SO post <a href="https://stackoverflow.com/questions/55729477/smooth-growing-of-div-when-appending-children-using-transitions">smooth growing of div when appending children using transitions</a></p> <p>but it does not answer the question correctly as it is fading in the element opposed to transitioning the div's height that the elements are in</p> <p><a href="http://jsfiddle.net/nexq40oz/" rel="nofollow noreferrer">http://jsfiddle.net/nexq40oz/</a></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>setInterval(function() { var li = document.createElement("li"); li.innerHTML = "item"; document.getElementById("list").appendChild(li); }, 1000);</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>#menu #list { max-height: 300px; transition: max-height 0.15s ease-out; background: #d5d5d5; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="menu"&gt; &lt;ul id="list"&gt; &lt;!-- Create a bunch, or not a bunch, of li's to see the timing. --&gt; &lt;li&gt;item&lt;/li&gt; &lt;li&gt;item&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74236200, "author": "Archigan", "author_id": 14333778, "author_profile": "https://Stackoverflow.com/users/14333778", "pm_score": 0, "selected": false, "text": "eslintrc.yml" }, { "answer_id": 74236466, "author": "Tobias S.", "author_id": 8613630, "autho...
2022/10/28
[ "https://Stackoverflow.com/questions/74236141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18693223/" ]
74,236,166
<p>I have a list e.g. <code>[1,2,3,4,5]</code> where I need to know not only the current element but also the predecessor and successor elements. Is there any map function which can be used as follows:</p> <pre class="lang-hs prettyprint-override"><code>map (\prev cur next -&gt; ...) [1,2,3,4,5] </code></pre> <p>Or maybe you have another idea to solve the problem?</p>
[ { "answer_id": 74236200, "author": "Archigan", "author_id": 14333778, "author_profile": "https://Stackoverflow.com/users/14333778", "pm_score": 0, "selected": false, "text": "eslintrc.yml" }, { "answer_id": 74236466, "author": "Tobias S.", "author_id": 8613630, "autho...
2022/10/28
[ "https://Stackoverflow.com/questions/74236166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9002073/" ]
74,236,173
<p>I understand I can use IIS to set the certificate for the website running on localhost to IIS Express Development Certificate...</p> <p>But how would I do this programmatically using a c# and .net program running on the individuals machine?</p> <p>Or even using powershell.. or a cmd script.. just in a programmatic way that can be executed</p>
[ { "answer_id": 74236200, "author": "Archigan", "author_id": 14333778, "author_profile": "https://Stackoverflow.com/users/14333778", "pm_score": 0, "selected": false, "text": "eslintrc.yml" }, { "answer_id": 74236466, "author": "Tobias S.", "author_id": 8613630, "autho...
2022/10/28
[ "https://Stackoverflow.com/questions/74236173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8262184/" ]
74,236,185
<p>I am trying to deploy my app onto heroku, yet I receive a build erorr where it fails to install the dependencies using npm install. Is there anyway I can install with &quot;legacy-peer-deps&quot;?</p> <p>Thank you so much...</p> <p>I tried editing my procifile file with the following contents in it</p> <pre><code>web: npm install --legacy-peer-deps web: npm start </code></pre>
[ { "answer_id": 74267264, "author": "Chris", "author_id": 354577, "author_profile": "https://Stackoverflow.com/users/354577", "pm_score": 0, "selected": false, "text": "legacy-peer-deps" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74236185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13812185/" ]
74,236,203
<p>I am learning basic conditionals and i'm not 100% sure on why the &amp;&amp; in this case is returning 'false' in console.</p> <p>Is it because the variable is not both 0 and 1.</p> <p>Thank you in advance,</p> <pre><code>let i = 1; if (i == 0 &amp;&amp; i == 1) { console.log('true'); } else { console.log('false'); } </code></pre> <p>I was expecting true.</p> <p>Even if I set <code>var i = 01;</code> it still shows false.</p> <p>I just need a simple explanation why to get it clear in my head :)</p>
[ { "answer_id": 74236235, "author": "Ben Aston", "author_id": 38522, "author_profile": "https://Stackoverflow.com/users/38522", "pm_score": 2, "selected": false, "text": "i" }, { "answer_id": 74236258, "author": "Archigan", "author_id": 14333778, "author_profile": "htt...
2022/10/28
[ "https://Stackoverflow.com/questions/74236203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11969292/" ]
74,236,205
<p>[Podfile][1]``` Error output from CocoaPods: ↳</p> <pre><code>[!] The FlutterFire plugin cloud_firestore for macOS requires a macOS deployment target of 10.12 or later. </code></pre> <p>Exception: Error running pod install</p> <pre><code> Hi, I've been stuck on this problem for a while, I'm trying to connect my flutter app with firebase but as soon as I put firestore on I have this problem. I modified the podfile file by putting the right version but nothing is done. I followed a lot of tutorials but none solved my problem. so please i need help. I created my database on firebase, I configured it with xcode Cocaopods version : 1.11.3 firebase_core: ^2.1.1 cloud_firestore: ^4.0.3 platform :ios, '12.0' Podfile : [1]: https://i.stack.imgur.com/fYqSZ.png </code></pre>
[ { "answer_id": 74236235, "author": "Ben Aston", "author_id": 38522, "author_profile": "https://Stackoverflow.com/users/38522", "pm_score": 2, "selected": false, "text": "i" }, { "answer_id": 74236258, "author": "Archigan", "author_id": 14333778, "author_profile": "htt...
2022/10/28
[ "https://Stackoverflow.com/questions/74236205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20358632/" ]
74,236,208
<p>I have an element which has to be scaled from 100px from the left while already having a scale of 0.5. When transforming the origin it is on 50px on the left side and scaling from the wrong side of the line.</p> <p>When scaling the element I want it to scale from the purple line. Without using the left CSS property.</p> <p>I tried to use this formula but it was slightly off:</p> <p>x + (x * scale)</p> <p><a href="https://i.stack.imgur.com/sFCBw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sFCBw.png" alt="enter image description here" /></a></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>* { margin: 0; padding: 0; } .box { position: relative; width: 100px; height: 100px; margin-top: -10px; } .example-initial { background: blue; transform: scale(0.2); transform-origin: 100px 0px; } .example-wrong { background: green; transform: scale(0.5); transform-origin: 100px 0px; } .example-right { background: red; transform: scale(0.5); transform-origin: 200px 0px; } .transform-origin-line-example { position: absolute; left: 100px; width: 1px; height: 200px; background: purple; top: 0; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="example-initial box"&gt;&lt;/div&gt; &lt;div class="example-wrong box"&gt;&lt;/div&gt; &lt;div class="example-right box"&gt;&lt;/div&gt; &lt;div class="transform-origin-line-example"&gt;&lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74236470, "author": "Dennis Quan", "author_id": 12226091, "author_profile": "https://Stackoverflow.com/users/12226091", "pm_score": 0, "selected": false, "text": "transform: scale(-0.5);" }, { "answer_id": 74236901, "author": "Gifgaar", "author_id": 1710513...
2022/10/28
[ "https://Stackoverflow.com/questions/74236208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8273193/" ]
74,236,222
<p>Let's say I have a string</p> <pre><code>s = &quot;nnbbbnbbbnnnnbb&quot; </code></pre> <p>How would I check the range of &quot;b's&quot; while it's seperated by &quot;n's&quot;. I want it to look like:</p> <pre><code>arr = [(2,5),(6,9),(13,15)] </code></pre>
[ { "answer_id": 74236303, "author": "Riccardo Bucco", "author_id": 5296106, "author_profile": "https://Stackoverflow.com/users/5296106", "pm_score": 1, "selected": false, "text": "itertools.groupby" }, { "answer_id": 74236313, "author": "jvx8ss", "author_id": 11107859, ...
2022/10/28
[ "https://Stackoverflow.com/questions/74236222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16409755/" ]
74,236,245
<p>first, I run the nodeJs server on localhost then I tried to call API's from my real ios device, but I’m getting issues while connecting with local host</p> <p><a href="https://i.stack.imgur.com/5kPh4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5kPh4.png" alt="enter image description here" /></a></p> <p>everything in working fine in case of android device and emulator</p>
[ { "answer_id": 74236315, "author": "Alex", "author_id": 6419172, "author_profile": "https://Stackoverflow.com/users/6419172", "pm_score": 1, "selected": false, "text": "0.0.0.0" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74236245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12460745/" ]
74,236,249
<p>I'm strugling with my form in typescript react. Basicly I created 2 simple components <code>Button</code> and <code>Input</code> and add them to the another component <code>Form</code> where I created a whole form.</p> <p>After submit I should get something like this:</p> <pre><code>telephone: &quot;323423234&quot; email: &quot;tress@wess.com&quot; message: &quot;weklfnwlkf&quot; name: &quot;less&quot; surname: &quot;mess&quot; </code></pre> <p>But after submit I get weird response like this:</p> <pre><code>&quot;&quot;: &quot;323423234&quot; email: &quot;tress@wess.com&quot; message: &quot;weklfnwlkf&quot; name: &quot;less&quot; surname: &quot;mess&quot; telephone: &quot;&quot; </code></pre> <p>It is a little bit werido because I done something like this couple days ago and now idk what to do. There is sample of my <code>Form</code> code</p> <pre><code>const Form = () =&gt; { interface FormDataType { telephone: string; name: string; surname: string; email: string; message: string; } const formData: FormDataType = { telephone: '', name: '', surname: '', email: '', message: '', }; const [responseBody, setResponseBody] = useState&lt;FormDataType&gt;(formData); const clearState = () =&gt; { setResponseBody({ ...formData }); }; const handleChange = (event: React.ChangeEvent&lt;HTMLInputElement&gt;) =&gt; { const { name, value } = event.target; setResponseBody({ ...responseBody, [name]: value }); }; const handleSubmit = (event: React.FormEvent&lt;HTMLFormElement&gt;) =&gt; { event.preventDefault(); console.log(responseBody); clearState(); }; return ( &lt;&gt; &lt;form onSubmit={handleSubmit}&gt; {FormData.map((option) =&gt; ( &lt;Input key={option.name} label={option.label} type={option.type} className={option.className} name={option.name} onChange={(e: React.ChangeEvent&lt;HTMLInputElement&gt;) =&gt; handleChange(e) } /&gt; ))} &lt;div className='div'&gt; &lt;Button type='submit' title={'Simple test'} className={'btn-primary'} /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/&gt; ); }; export default Form; </code></pre> <p>And when I'm invoking in <code>handleSubmit</code> function <code>clearState()</code> it doesn't refresh states in webpage inputs.</p>
[ { "answer_id": 74236315, "author": "Alex", "author_id": 6419172, "author_profile": "https://Stackoverflow.com/users/6419172", "pm_score": 1, "selected": false, "text": "0.0.0.0" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74236249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15032294/" ]
74,236,281
<p><a href="https://i.stack.imgur.com/Ef69i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ef69i.png" alt="enter image description here" /></a></p> <p>I wany to position the image card to overlay the card top border using Bootstrap? without using css.</p> <p>I've tried using CSS :</p> <pre><code>style=&quot;margin: -50px 70px;&quot; </code></pre> <p>but I want to make it with bootstrap</p>
[ { "answer_id": 74236315, "author": "Alex", "author_id": 6419172, "author_profile": "https://Stackoverflow.com/users/6419172", "pm_score": 1, "selected": false, "text": "0.0.0.0" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74236281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20149191/" ]
74,236,305
<p>I have two Double value but different decimal places.</p> <pre><code>123.400 // three decimal places 567.80 // two decimal places </code></pre> <p>I try to convert Double value to String by using DecimalFormat</p> <pre><code>val stringFormat = DecimalFormat(&quot;#,###.000&quot;) println(stringFormat.format(123.400)) println(stringFormat.format(567.80)) val stringFormatZeroAbsent = DecimalFormat(&quot;#,###.###&quot;) println(stringFormatZeroAbsent.format(123.400)) println(stringFormatZeroAbsent.format(567.80)) </code></pre> <p>Since &quot;0&quot; mean Digit and &quot;#&quot; mean Digit with zero shows as absent, so outputs are:</p> <pre><code>123.400 567.800 123.4 567.8 </code></pre> <p>The actual result i want are:</p> <pre><code>123.400 567.80 </code></pre> <p>That the zero not absent.</p>
[ { "answer_id": 74236386, "author": "deHaar", "author_id": 1712135, "author_profile": "https://Stackoverflow.com/users/1712135", "pm_score": 2, "selected": false, "text": "String.format(String, Double)" }, { "answer_id": 74240058, "author": "cactustictacs", "author_id": 13...
2022/10/28
[ "https://Stackoverflow.com/questions/74236305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2817936/" ]
74,236,316
<p>I am querying Bigquery using Grafana, In Grafana i use a text box variable(SrcAddr) to select certain values.</p> <p><code>Select * from flow_tables where SrcAddr = '100.100.100.1'</code></p> <p>if the User did not provide any input then all the IP addresses need to be selected. What value needs to be used to select all the IPs?</p> <p><code>Select * from flow_tables where SrcAddr = 'ANY'</code></p> <p>I tried using *, ANY, &quot;.&quot; but it didnot help.</p>
[ { "answer_id": 74236386, "author": "deHaar", "author_id": 1712135, "author_profile": "https://Stackoverflow.com/users/1712135", "pm_score": 2, "selected": false, "text": "String.format(String, Double)" }, { "answer_id": 74240058, "author": "cactustictacs", "author_id": 13...
2022/10/28
[ "https://Stackoverflow.com/questions/74236316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4494531/" ]
74,236,435
<p>I have a list of time. I want all AM to be PM and all PM to AM.</p> <p>Input<br/> <code>newtimes</code></p> <p>Output<br/> <strong>['10:31 PM', '10:03 PM', '12:26 AM', '07:40 PM', '09:32 PM']</strong></p> <p>Input</p> <pre><code> for items in newtimes: newtimes1 = items.replace('AM','PM').replace('PM','AM') print(newtimes1) </code></pre> <p>Output i am getting:<br/> 10:31 AM<br/> 10:03 AM<br/> 12:26 AM<br/> 07:40 AM<br/> 09:32 AM<br/></p> <p>Am looking for the output such as:<br/> <strong>10:31 AM<br/> 10:03 AM<br/> 12:26 PM<br/> 07:40 AM<br/> 09:32 AM<br/></strong></p>
[ { "answer_id": 74236494, "author": "jprebys", "author_id": 3268228, "author_profile": "https://Stackoverflow.com/users/3268228", "pm_score": 2, "selected": true, "text": "for old_time in old_times:\n if 'AM' in old_time:\n new_time = old_time.replace('AM', 'PM')\n else:\n ...
2022/10/28
[ "https://Stackoverflow.com/questions/74236435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5355986/" ]
74,236,465
<p>How can i calculate these in python?? A = (x**1/1!) - (x**3/3!) + (x**5/5!) - ... - (x**51/51!) B = 1 - (x**2/2!) + (x**4/4!) - ... - (x**50/50!) I tried this code for calculating A and B but<br /> A^2 + B^2 ~= 1<br /> but i get 2.xxxxxxxxx</p> <pre><code>def factorial(n): fac = 1 for i in range(2, n+1): fac *= i return fac def calcA(x): c = True A = 0 for i in range(1, 51, 2): if c: A += (x**i)/factorial(i) else: A -= (x**i)/factorial(i) c = not c return A def calcB(x): B = 1 c = False for i in range(2, 50, 2): if c: B += (x**i)/factorial(i) else: B -= (x**i)/factorial(i) c = not c return B </code></pre> <p>I tried this but output is not correct<br /> it should be almost 1</p>
[ { "answer_id": 74236554, "author": "T C Molenaar", "author_id": 8814131, "author_profile": "https://Stackoverflow.com/users/8814131", "pm_score": 0, "selected": false, "text": "for i in range(10):\n print(i)\n" }, { "answer_id": 74236665, "author": "Cobra", "author_id"...
2022/10/28
[ "https://Stackoverflow.com/questions/74236465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20358901/" ]
74,236,478
<p>I have some css rules in my <a href="https://nextjs.org/docs/basic-features/built-in-css-support#adding-a-global-stylesheet" rel="nofollow noreferrer">global.css</a> file, how do I override these stylings for specific pages?</p>
[ { "answer_id": 74236554, "author": "T C Molenaar", "author_id": 8814131, "author_profile": "https://Stackoverflow.com/users/8814131", "pm_score": 0, "selected": false, "text": "for i in range(10):\n print(i)\n" }, { "answer_id": 74236665, "author": "Cobra", "author_id"...
2022/10/28
[ "https://Stackoverflow.com/questions/74236478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3691484/" ]