qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,176,686 | <p>I want two classes to 'include' each other in their variables.</p>
<pre class="lang-cpp prettyprint-override"><code>#include <vector>
class Bar;
class Foo {
public:
Bar b1;
};
class Bar {
public:
std::vector<Foo> f1;
};
</code></pre>
<p>I get this error <code>error: field 'b1' has incomplete type 'Bar'</code> while trying to compile. What's going wrong?</p>
| [
{
"answer_id": 74176703,
"author": "Chris",
"author_id": 15261315,
"author_profile": "https://Stackoverflow.com/users/15261315",
"pm_score": 1,
"selected": false,
"text": "Bar"
},
{
"answer_id": 74176717,
"author": "thedemons",
"author_id": 13253010,
"author_profile":... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74176686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14830457/"
] |
74,176,701 | <p>I have these 10 numeric vectors. For simplicity, each containing 5 elements</p>
<pre><code>a <- c(1,2,3,4,5)
b <- c(1,2,3,4,6)
c <- c(1,2,3,4,6)
d <- c(1,2,3,4,6)
e <- c(6,2,9,7,3)
f <- c(7,3,5,7,6)
g <- c(7,9,3,4,0)
h <- c(4,6,4,6,9)
i <- c(8,8,5,3,8)
j <- c(2,1,1,2,3)
</code></pre>
<p>I want to find 3 most related/similar vectors. It must be vector b, c, d.</p>
<p>Additionally, I also hoping to get another vectors composition besides the "most related" one (b, c, d). In this case, could be: <code>(a, b, c)</code>, <code>(a, b, d)</code>, <code>(a, c, d )</code>.
The level of relation/similarity itself should have <code>score</code> so I can find the most similar, second most similar etc.</p>
<p><strong>Expected output</strong> is like this, more or less</p>
<pre><code>similarity_rank vectors similarity_score (example)
1 b, c, d 0.99
2 a, b, c 0.8
etc.
</code></pre>
<p><strong>My trial so far:</strong>
I'm using pairwise correlation. It can find the relation between vectors but only 2 vectors. I want to get "similarity score" for those 3 vector (or for general purpose, n vectors)</p>
<p><strong>Rules:</strong></p>
<ul>
<li>n: Number of desired vectors</li>
<li>N: Number of all vectors</li>
<li>N > n</li>
<li>All vectors are numeric</li>
</ul>
<p><strong>Question:</strong>
What is the best method to do that? (R code will be amazing, R Package will be great, or only the method name is enough so I can learn about it)</p>
| [
{
"answer_id": 74176703,
"author": "Chris",
"author_id": 15261315,
"author_profile": "https://Stackoverflow.com/users/15261315",
"pm_score": 1,
"selected": false,
"text": "Bar"
},
{
"answer_id": 74176717,
"author": "thedemons",
"author_id": 13253010,
"author_profile":... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74176701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14767090/"
] |
74,176,729 | <p>How to change initial iterator value of my loop to debug in VScode?</p>
<p>Example: I want debug my code starting i=10. How do I do to select this argument to my debugging? I'm loosing so many time clicking in "Step Over" to investigate my code. I'm using language C</p>
<p><img src="https://i.stack.imgur.com/LtRNg.png" alt="Image VSCode" /></p>
| [
{
"answer_id": 74176802,
"author": "Programmerabc",
"author_id": 16441984,
"author_profile": "https://Stackoverflow.com/users/16441984",
"pm_score": 2,
"selected": true,
"text": "if(i>=k){code}"
},
{
"answer_id": 74177381,
"author": "Mike Lischke",
"author_id": 1137174,
... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74176729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20234352/"
] |
74,176,740 | <p>I am looking to implement a retry mechanism using <code>retry-axios</code>. I have successfully installed the package in the node project.</p>
<pre><code>const baseUrl = `https://mock.codes/500`
const myAxiosInstance = axios.create();
myAxiosInstance.defaults.raxConfig = {
retry: 5,
retryDelay: 5000,
backoffType: 'static',
instance:myAxiosInstance,
onRetryAttempt: err => {
const cfg = rax.getConfig(err);
console.log(`Retry attempt #${cfg.currentRetryAttempt}`);
}
};
const interceptorId = rax.attach(myAxiosInstance);
const res = await myAxiosInstance.get(`${baseUrl}`);
</code></pre>
<p>The retry operation has been attempted only once. afterward, I got <code>Invalid character in header content [\"0\"]</code> error.</p>
<p>I need to start retrying the operation if the response is 500 or 400.</p>
<p>Thanks is advance</p>
| [
{
"answer_id": 74229997,
"author": "Trishant Pahwa",
"author_id": 6072570,
"author_profile": "https://Stackoverflow.com/users/6072570",
"pm_score": 1,
"selected": false,
"text": "const axios = require(\"axios\");\n\nconst baseUrl = `https://mock.codes/500`\nlet retryCount = 0; ... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74176740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6720372/"
] |
74,176,743 | <p>I've created a custom button and set two images, one is for normal, and the other is for the selected mode. But the voice-over always says the normal image name text when the button is not selected. I've tried a lot but could not disable it.</p>
<p>When I disable the button imageView accessibility it is not working.</p>
<pre><code>button.imageView?.isAccessibilityElement = false
</code></pre>
<p>When I disable the button accessibility, the voice-over is not working in accessibility mode.</p>
<pre><code>button.isAccessibilityElement = false
</code></pre>
<p>If I remove the '.normal' mode image then it works, but normal mode image functionality is not considered/worked there. I'm surfing a lot. Help anyone and thanks in advance.</p>
<p>Code:</p>
<pre><code>self.setImage(UIImage.init(named: imageName1), for: .normal)
self.setImage(UIImage.init(named: imageName1), for: .selected)
</code></pre>
| [
{
"answer_id": 74229997,
"author": "Trishant Pahwa",
"author_id": 6072570,
"author_profile": "https://Stackoverflow.com/users/6072570",
"pm_score": 1,
"selected": false,
"text": "const axios = require(\"axios\");\n\nconst baseUrl = `https://mock.codes/500`\nlet retryCount = 0; ... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74176743",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20318823/"
] |
74,176,777 | <p>when I execute this in my win10 I get this error.
But when I am using:</p>
<p>dirs = os.listdir(path)
for file in dirs:
print(file)</p>
<p>I can see all the files in dir, I need help!</p>
<p>error: Raw_Files = os.listdir()
TypeError: listdir() takes exactly 1 argument (0 given)</p>
<pre><code>def ransomeencrypt(file_name):
Lock = Fernet (key)
with open (file_name, 'rb') as file:
data = file.read ( )
protected = Lock.encrypt (data)
with open (file_name, 'wb') as file:
file.write (protected)
def ransomedecrypt(file_name):
Unlock = Fernet (key)
with open (file_name, 'rb') as file:
data = file.read ( )
decoded = Unlock.decrypt (data)
with open (file_name, 'wb') as file:
file.write (decoded)
Raw_Files = os.listdir()
Files = list()
for File in Raw_Files:
if File.endswith('.txt', '.pdf', '.doc', '.docx', '.ppt', '.ppx', '.xls', '.xlsx'):
Files.append (File)
function = ransomeencrypt
for File in Files:
function (file)
</code></pre>
| [
{
"answer_id": 74176790,
"author": "kotatsuyaki",
"author_id": 12122460,
"author_profile": "https://Stackoverflow.com/users/12122460",
"pm_score": 2,
"selected": true,
"text": "os.listdir"
},
{
"answer_id": 74176794,
"author": "goodwin",
"author_id": 11683167,
"author... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74176777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12247219/"
] |
74,176,793 | <p>I have created a simply WCF web service and require WCF Security with username/password added to the service and have read through the following MS documentation <a href="https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-use-a-custom-user-name-and-password-validator" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-use-a-custom-user-name-and-password-validator</a> to try and do so.</p>
<p>However, I am getting the error below when I run the project and go to http://localhost:50533/Service.svc:</p>
<pre><code>Server Error in '/' Application.
Could not load file or assembly 'CustomUserNameValidator' or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'CustomUserNameValidator' or one of its dependencies. The system cannot find the file specified.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'CustomUserNameValidator' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = CustomUserNameValidator
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: CustomUserNameValidator | Domain ID: 6
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Users/xxxx/source/repos/Misc/WCFDummyService/WCFDummyService/
LOG: Initial PrivatePath = C:\Users\xxxx\source\repos\Misc\WCFDummyService\WCFDummyService\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\xxxx\source\repos\Misc\WCFDummyService\WCFDummyService\web.config
LOG: Using host configuration file: C:\Users\xxxx\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/xxxx/AppData/Local/Temp/Temporary ASP.NET Files/vs/2193ee9a/db4d60f6/CustomUserNameValidator.DLL.
LOG: Attempting download of new URL file:///C:/Users/xxxx/AppData/Local/Temp/Temporary ASP.NET Files/vs/2193ee9a/db4d60f6/CustomUserNameValidator/CustomUserNameValidator.DLL.
LOG: Attempting download of new URL file:///C:/Users/xxxx/source/repos/Misc/WCFDummyService/WCFDummyService/bin/CustomUserNameValidator.DLL.
LOG: Attempting download of new URL file:///C:/Users/xxxx/source/repos/Misc/WCFDummyService/WCFDummyService/bin/CustomUserNameValidator/CustomUserNameValidator.DLL.
LOG: Attempting download of new URL file:///C:/Users/xxxx/AppData/Local/Temp/Temporary ASP.NET Files/vs/2193ee9a/db4d60f6/CustomUserNameValidator.EXE.
LOG: Attempting download of new URL file:///C:/Users/xxxx/AppData/Local/Temp/Temporary ASP.NET Files/vs/2193ee9a/db4d60f6/CustomUserNameValidator/CustomUserNameValidator.EXE.
LOG: Attempting download of new URL file:///C:/Users/xxxx/source/repos/Misc/WCFDummyService/WCFDummyService/bin/CustomUserNameValidator.EXE.
LOG: Attempting download of new URL file:///C:/Users/xxxx/source/repos/Misc/WCFDummyService/WCFDummyService/bin/CustomUserNameValidator/CustomUserNameValidator.EXE.
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'CustomUserNameValidator' or one of its dependencies. The system cannot find the file specified.]
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +71
System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) +41
System.Type.GetType(String typeName, Boolean throwOnError) +35
System.ServiceModel.Configuration.UserNameServiceElement.ApplyConfiguration(UserNamePasswordServiceCredential userName) +356
System.ServiceModel.Configuration.ServiceCredentialsElement.ApplyConfiguration(ServiceCredentials behavior) +128
System.ServiceModel.Configuration.ServiceCredentialsElement.CreateBehavior() +165
System.ServiceModel.Description.ConfigLoader.LoadBehaviors(ServiceModelExtensionCollectionElement`1 behaviorElement, KeyedByTypeCollection`1 behaviors, Boolean commonBehaviors) +204
System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress, Boolean skipHost) +13502205
System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection) +74
System.ServiceModel.ServiceHostBase.ApplyConfiguration() +188
System.ServiceModel.ServiceHost.ApplyConfiguration() +65
System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) +188
System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses) +49
System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) +153
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) +34
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +538
System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +1489
System.ServiceModel.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) +53
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +666
[ServiceActivationException: The service '/Service.svc' cannot be activated due to an exception during compilation. The exception message is: Could not load file or assembly 'CustomUserNameValidator' or one of its dependencies. The system cannot find the file specified..]
System.Runtime.AsyncResult.End(IAsyncResult result) +513025
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +182
System.ServiceModel.Activation.ServiceHttpHandler.EndProcessRequest(IAsyncResult result) +12
System.Web.CallHandlerExecutionStep.InvokeEndHandler(IAsyncResult ar) +161
System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +128
</code></pre>
<p>I have noticed this error only appears due to adding the following into my Web.Config file</p>
<pre><code> <serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="WCFDummyService.CustomUserNameValidator, CustomUserNameValidator" />
</serviceCredentials>
</code></pre>
<p>I've modified the value in customUserNamePasswordValidatorType numerous times to try and fix it but the error still comes up or a similar one.</p>
<p>See below for the full Web.Config file.</p>
<pre><code><?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.6"/>
<httpRuntime targetFramework="4.6"/>
<pages>
<namespaces>
<add namespace="System.Runtime.Serialization"/>
<add namespace="System.ServiceModel"/>
<add namespace="System.ServiceModel.Web"/>
</namespaces>
</pages>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Binding1">
<security mode="Transport">
<message clientCredentialType="UserName" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="WCFDummyService.CustomUserNameValidator, CustomUserNameValidator" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
</code></pre>
<p>The Code is simply the default WCF Service code you get out of the box when creating a new WCF Service project in Visual Studio and I've just added a new CustomUserNameValidator class.</p>
<p><a href="https://i.stack.imgur.com/3wu9h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3wu9h.png" alt="enter image description here" /></a></p>
<p>If you want to see this class, here is the code for it:</p>
<pre><code>Imports System.IdentityModel.Selectors
Public Class CustomUserNameValidator
Inherits UserNamePasswordValidator
Public Overrides Sub Validate(ByVal userName As String, ByVal password As String)
If userName Is Nothing OrElse password Is Nothing Then
Throw New ArgumentNullException()
End If
If Not (userName = "user" AndAlso password = "pass123") Then
Throw New FaultException("Unknown Username or Incorrect Password")
End If
End Sub
End Class
</code></pre>
<p>Also, this is all that shows in Properties for the file.</p>
<p><a href="https://i.stack.imgur.com/M2Mr2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M2Mr2.png" alt="enter image description here" /></a></p>
<p>If you can please help with the error, that would be very much appreciated.</p>
| [
{
"answer_id": 74176790,
"author": "kotatsuyaki",
"author_id": 12122460,
"author_profile": "https://Stackoverflow.com/users/12122460",
"pm_score": 2,
"selected": true,
"text": "os.listdir"
},
{
"answer_id": 74176794,
"author": "goodwin",
"author_id": 11683167,
"author... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74176793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19295218/"
] |
74,176,810 | <pre><code><Nav>
<Nav.Item>
<strong>Categories</strong>
</Nav.Item>
{
categories.map((category) =>
(
<Nav.Item key={category}>
{/* <Link
to={`/search?category=${category}`}
onClick={() => setSidebarOpen(false)}
>
{category}
</Link> */}
<LinkContainer
to={`/search?category=${category}`}
onClick={() => setSidebarOpen(false)}
>
<Nav.Link>{category}</Nav.Link>
</LinkContainer>
</Nav.Item>
))
}
</Nav>
</code></pre>
<p>Hi i'm getting this error and the thing is i used this kind of code before and i didnt get any error at all, and I don't get any error when using just the Link(the one that is commented out) but when I use this container i get this error
<a href="https://i.stack.imgur.com/JrL6N.png" rel="nofollow noreferrer">Uncaught Error: Cannot include a '?' character in a manually specified <code>to.pathname</code> field [{"pathname":"/search?category=Cameras"}]. Please separate it out to the <code>to.search</code> field. Alternatively you may provide the full path as a string in and the router will parse it for you.</a></p>
| [
{
"answer_id": 74252839,
"author": "VQH-cmd",
"author_id": 13088139,
"author_profile": "https://Stackoverflow.com/users/13088139",
"pm_score": 1,
"selected": false,
"text": "6.4.2"
},
{
"answer_id": 74555891,
"author": "VQH-cmd",
"author_id": 13088139,
"author_profile... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74176810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18150722/"
] |
74,176,817 | <p>format</p>
<pre class="lang-js prettyprint-override"><code>const messages = {
en: {
message: {
hello: '{msg} world'
}
}
}
</code></pre>
<p>usage</p>
<pre class="lang-html prettyprint-override"><code><p>{{ $t('message.hello', { msg: 'hello' }) }}</p>
<!-- I don't want to input the second param {msg: 'hello'} -->
</code></pre>
<p>how can I set the default value for 'msg' and no need to input <code>{msg: 'hello'}</code> in every <code>$t</code> function?</p>
| [
{
"answer_id": 74177073,
"author": "Yue JIN",
"author_id": 13326361,
"author_profile": "https://Stackoverflow.com/users/13326361",
"pm_score": 0,
"selected": false,
"text": "const messages = {\n en: {\n message: {\n world: '{msg} world',\n helloWorld: 'Hello world'\n }\n... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74176817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7139906/"
] |
74,176,840 | <p>This post is more of a type of confirmation post rather than a particular question.</p>
<p>I read up some answers on this site and other places to clear up my confusion regarding pointers of type, ex- int(*)[size] which are pointers to an array. From what I've understood, there are some basic differences which I concluded on - 1) pointer arithmetic, 2) dereferencing . I wrote up this code to differentiate between int* and int(*)[size].</p>
<pre><code>int arr1[5] {} ;
int (*ptr1) [5] = &arr1 ;
(*ptr1)[3] = 40 ;
cout << ptr1 << endl ;
cout << ptr1[3] << endl;
cout << ptr1 + 3 << endl ;
int arr2[5] {} ;
int* ptr2 = arr2 ;
ptr2[3] = 40 ;
cout << ptr2 << endl ;
cout << ptr2[3] <<endl ;
cout << ptr2 + 3 << endl ;
</code></pre>
<p>Output :
<a href="https://i.stack.imgur.com/U4tiX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U4tiX.png" alt="enter image description here" /></a></p>
<p>On observing the output of arithmetic on int(*)[size] its evident that when we add say i to it , it jumps over a block of 4*size*i memory whereas the int* jumps over a 4*i memory block. Also in int* the expression of the form ptr2[i] is equivalent to *(ptr2+i) but in pointers of type int(*)[size] this is not the case ptr1[i] is equivalent to (ptr1 + i) and to replicate the action of ptr2[i] we have to do (*ptr1)[i] in this case.</p>
<p>Are there anymore significant differences between the pointers of such type and which pointer amongst them should be preferred and why ?
Please correct my analysis if I have gone wrong somewhere .</p>
| [
{
"answer_id": 74176892,
"author": "Jason Liam",
"author_id": 12002570,
"author_profile": "https://Stackoverflow.com/users/12002570",
"pm_score": 0,
"selected": false,
"text": "ptr1[3]"
},
{
"answer_id": 74176905,
"author": "molbdnilo",
"author_id": 404970,
"author_pr... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74176840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13702003/"
] |
74,176,842 | <p>I've already developed and deployed <strong>ReactJS</strong> app with separated front and backend (Laravel).</p>
<p>I'm facing issue with sharing pages with dynamic data due to the disability of react to dynamically generating meta tags, No dynamic preview , no dynamic title .</p>
<p>After searching the web for days the only stable solution found is migrating to NextJs.</p>
<p>my question is can i migrate ( <strong>partially</strong> ) to Nextjs ?</p>
<p>using Nextjs router for only the sharable pages and preserve the react router for the rest pages?
or any other solution other than nextjs for that issue ?</p>
| [
{
"answer_id": 74176892,
"author": "Jason Liam",
"author_id": 12002570,
"author_profile": "https://Stackoverflow.com/users/12002570",
"pm_score": 0,
"selected": false,
"text": "ptr1[3]"
},
{
"answer_id": 74176905,
"author": "molbdnilo",
"author_id": 404970,
"author_pr... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74176842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7876285/"
] |
74,176,847 | <p>May I ask which condition I should use to check the files A or B or both exist then execute the expression A or B or Both?</p>
<pre><code>if or while or try...
</code></pre>
<p><a href="https://i.stack.imgur.com/4RhmF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4RhmF.jpg" alt="enter image description here" /></a>
Thanks</p>
| [
{
"answer_id": 74176865,
"author": "learner",
"author_id": 17658327,
"author_profile": "https://Stackoverflow.com/users/17658327",
"pm_score": 1,
"selected": false,
"text": "os.path.isfile"
},
{
"answer_id": 74176866,
"author": "CutePoison",
"author_id": 6224975,
"aut... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74176847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6115054/"
] |
74,176,875 | <p>My goal is to connect my laravel project to firestore firebase. I will be needing the grpc in order to continue it. However my problem is the .dll cant be found. I already uploaded the .dll file in ext folder.
<a href="https://i.stack.imgur.com/euO9e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/euO9e.png" alt="enter image description here" /></a></p>
<p>I also included it in my php.ini file.
<a href="https://i.stack.imgur.com/W6t1N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W6t1N.png" alt="enter image description here" /></a></p>
<p>still getting the same error
<a href="https://i.stack.imgur.com/Ncgo0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ncgo0.png" alt="enter image description here" /></a></p>
<p>I dont know if its the version og php and grpc is conflicting.</p>
<p>After applying the comments' suggestions:
<a href="https://i.stack.imgur.com/tdgTo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tdgTo.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74259275,
"author": "nice_dev",
"author_id": 4964822,
"author_profile": "https://Stackoverflow.com/users/4964822",
"pm_score": 3,
"selected": true,
"text": "php_"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74176875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20252963/"
] |
74,176,912 | <p>I have a dataset that looks like this:</p>
<pre><code> Product Patient_ID
1 A 1
2 A 1
3 A 1
4 A 3
5 D 3
6 D 4
7 D 5
8 E 5
9 E 6
10 F 7
11 G 8
</code></pre>
<p>Where I'd like to count the number of <strong>unique</strong> individuals who have used a product. In other words, I would like to get a frequency for the 'Product' column, based on unique 'Patient IDs'.</p>
<p>My desired dataset would look something like this:</p>
<pre><code> Product Freq
1 A 2
2 D 3
3 E 2
4 F 1
5 G 1
</code></pre>
<p>How can I go about doing this?</p>
<p>Reproducible data:</p>
<pre><code>test_data<-data.frame(Product=c("A","A","A","A","D","D","D","E","E","F","G"),Patient_ID=c("1","1","1","3","3","4","5","5","6","7","8"))
</code></pre>
| [
{
"answer_id": 74177094,
"author": "badgorilla",
"author_id": 13012620,
"author_profile": "https://Stackoverflow.com/users/13012620",
"pm_score": 0,
"selected": false,
"text": "rez<-as.data.frame(table(test_data[!duplicated(paste0(test_data$Product,test_data$Patient_ID)),\"Product\"]))\n... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74176912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19232898/"
] |
74,176,945 | <p>The following shortcut is created in <em>SendTo</em> and calls a PowerShell script. I want this script to be invisible (<code>-WindowStyle Hidden</code>) as the script uses <code>Add-Type -AssemblyName System.Windows.Forms; $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{ InitialDirectory = $parent }</code> and processes results based on the item selected in the <code>OpenFileDialog</code>.</p>
<pre><code>$oShell = New-Object -ComObject Shell.Application
$lnk = $WScriptShell.CreateShortcut("$Env:AppData\Microsoft\Windows\SendTo\Get Info.lnk")
$lnk.TargetPath = "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe"
$lnk.Arguments = "-WindowStyle Hidden -NoProfile -File `"C:\Scripts\Get Info.ps1`""
$lnk.Save()
</code></pre>
<p>However, the script is not silent, and throws up a blue PowerShell window briefly before the <code>OpenFileDialog</code>. How can I make the script completely silent when called by the shortcut?</p>
| [
{
"answer_id": 74177045,
"author": "Santiago Squarzon",
"author_id": 15339544,
"author_profile": "https://Stackoverflow.com/users/15339544",
"pm_score": 3,
"selected": true,
"text": ".ps1"
},
{
"answer_id": 74191639,
"author": "YorSubs",
"author_id": 524587,
"author_p... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74176945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/524587/"
] |
74,176,947 | <p>I Have one text file and I want to replaces all matches in each line, so I defined Pattern and I loop through to the text file after I want to write the result in another file, unfortunately my pattern is only replace first occurrence of the word what did |I do in a wrong way?
Content of text file:
<em>"testebook kok o testebook\ntestbbb1232 joj ds testbbb1232"</em></p>
<pre><code>using System.Text.RegularExpressions;
string filePath = "test.txt";
string fileNewPath = "test1.txt";
string ma = @"^test[0-9a-zA-Z]+";
string newString = string.Empty;
using(StreamReader sr = new(filePath)){
string line = sr.ReadLine();
while (line != null){
while(Regex.IsMatch(line, ma) != false){
line = Regex.Replace(line, ma, "");
}
newString += line + "\n";
line = sr.ReadLine();
}
}
using(StreamWriter sw = new(fileNewPath)){
sw.WriteLine(newString);
}
</code></pre>
| [
{
"answer_id": 74177045,
"author": "Santiago Squarzon",
"author_id": 15339544,
"author_profile": "https://Stackoverflow.com/users/15339544",
"pm_score": 3,
"selected": true,
"text": ".ps1"
},
{
"answer_id": 74191639,
"author": "YorSubs",
"author_id": 524587,
"author_p... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74176947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10979398/"
] |
74,176,955 | <p>I do have one table with 2 columns and another with 2 columns</p>
<p>employee(id, transaction_date),
employee_1(id, transaction_date)</p>
<p>Below is the query i tried, but it's returning an error</p>
<pre><code>SELECT COUNT(DISTINCT id) / COUNT(DISTINCT id) FROM employee, employee_1
</code></pre>
<p>Error is</p>
<pre><code>SQL Error [2028] [42601]: SQL compilation error:
ambiguous column name 'id'
</code></pre>
<p>Can anyone help me with this?</p>
| [
{
"answer_id": 74177045,
"author": "Santiago Squarzon",
"author_id": 15339544,
"author_profile": "https://Stackoverflow.com/users/15339544",
"pm_score": 3,
"selected": true,
"text": ".ps1"
},
{
"answer_id": 74191639,
"author": "YorSubs",
"author_id": 524587,
"author_p... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74176955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18158837/"
] |
74,176,960 | <p>Is there a way to make the default <code>Enum.ToString()</code> to convert to snake_case instead of PascalCase? And that change to be global, so I don't have to do that all over again.</p>
<pre class="lang-cs prettyprint-override"><code>public enum SpellTypes
{
HorizonFocus
}
public sealed class Settings
{
public Settings(SpellTypes types)
{
TypeString = types.ToString(); // actual: HorizonFocus, expected: horizon_focus
}
public string TypeString { get; }
}
</code></pre>
<h2>In addition</h2>
<p>I tried the following with <code>Macross.Json.Extensions</code> but it didn't apply the changes to the TypeString.</p>
<pre class="lang-cs prettyprint-override"><code>[JsonConverter(typeof(JsonStringEnumMemberConverter))]
public enum SpellTypes
{
[EnumMember(Value = "horizon_focus")]
HorizonFocus
}
</code></pre>
| [
{
"answer_id": 74177045,
"author": "Santiago Squarzon",
"author_id": 15339544,
"author_profile": "https://Stackoverflow.com/users/15339544",
"pm_score": 3,
"selected": true,
"text": ".ps1"
},
{
"answer_id": 74191639,
"author": "YorSubs",
"author_id": 524587,
"author_p... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74176960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13677853/"
] |
74,176,995 | <p>The Stripe documentation <a href="https://stripe.com/docs/customer-management/integrate-customer-portal" rel="nofollow noreferrer">here</a> describes how to create a Customer Portal Configuration.</p>
<p>This is what the example code looks like:</p>
<pre><code>StripeConfiguration.ApiKey = "....";
var options = new ConfigurationCreateOptions
{
BusinessProfile = new ConfigurationBusinessProfileOptions
{
Headline = "Cactus Practice partners with Stripe for simplified billing.",
},
Features = new ConfigurationFeaturesOptions
{
InvoiceHistory = new ConfigurationFeaturesInvoiceHistoryOptions
{
Enabled = true,
},
},
};
var service = new ConfigurationService();
await service.CreateAsync(options);
</code></pre>
<p>I'd rather not hit the Stripe API to create a new Configuration every time I want to generate a Customer Portal Session for my customers.</p>
<p>So my question is, can I cache the configuration server-side and use the same Customer Portal Configuration for all customers?</p>
<p>Or is there some kind of expiry or limitation on the configuration?</p>
| [
{
"answer_id": 74177045,
"author": "Santiago Squarzon",
"author_id": 15339544,
"author_profile": "https://Stackoverflow.com/users/15339544",
"pm_score": 3,
"selected": true,
"text": ".ps1"
},
{
"answer_id": 74191639,
"author": "YorSubs",
"author_id": 524587,
"author_p... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74176995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8532656/"
] |
74,177,010 | <p>If I <code>clear()</code> my local list (<code>mList</code>) it also clearing <code>companion</code>'s Mutablelist (<code>list</code>)
Why this happening explanation's are welcome :)</p>
<p>I've a class with <code>companion</code> like this :</p>
<pre><code>class Data {
companion object {
var list:MutableList<String> = ArrayList()
}
}
</code></pre>
<p>If I create my local list something like this :</p>
<pre><code>fun main() {
// some dummy data
Data.list.add("Lion")
Data.list.add("Cat")
Data.list.add("Dog")
Data.list.add("Cheetah")
// my local mList
val mList = Data.list
println("Before Clearing : mList = $mList\n list = ${Data.list}")
mList.clear()
println("After Clearing : mList = $mList\n list = ${Data.list}")
}
</code></pre>
<p><strong>OutPut</strong></p>
<pre class="lang-bash prettyprint-override"><code>Before Clearing : mList = [Lion, Cat, Dog, Cheetah]
list = [Lion, Cat, Dog, Cheetah]
After Clearing : mList = []
list = []
</code></pre>
<p>As You can see in output if I <code>clear()</code> local <code>mList</code> it is clearing <code>companion</code>'s list Why it is ?</p>
<p>if I do this same with some other things like <code>double</code> it is not happening like this example -</p>
<pre><code>// same Data class's
...
var pi = 3.14
...
</code></pre>
<p>If change local <code>mPi</code> it doesn't change <code>pi</code> :</p>
<pre><code>var mPi = Data.pi
println("Before Assigning to New value mPi = $mPi and pi = ${Data.pi}")
mPi = 319.12
println("After Assigning to New value mPi = $mPi and pi = ${Data.pi}")
</code></pre>
<p>2nd Output</p>
<pre class="lang-bash prettyprint-override"><code>Before Assigning to New value mPi = 3.14 and pi = 3.14
After Assigning to New value mPi = 319.12 and pi = 3.14
</code></pre>
<p>Link of <a href="https://pl.kotl.in/rmO-R-um_" rel="nofollow noreferrer">Kotlin Playground</a></p>
<p>Why it is happening? I'd like to know :)</p>
| [
{
"answer_id": 74177188,
"author": "Bilal Naeem",
"author_id": 9090647,
"author_profile": "https://Stackoverflow.com/users/9090647",
"pm_score": 3,
"selected": true,
"text": "new"
},
{
"answer_id": 74181014,
"author": "Tenfour04",
"author_id": 506796,
"author_profile"... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20298837/"
] |
74,177,099 | <p>I am writing to a file, then reading it back right after:</p>
<pre><code>await FileIO.WriteTextAsync(file, command, Windows.Storage.Streams.UnicodeEncoding.Utf8);
var readFile = await ApplicationData.Current.TemporaryFolder.GetFileAsync(WEB_LOG);
</code></pre>
<p>However, <code>GetFileAsync</code> throws a <code>FileNotFoundException</code> because the file hasn't appeared yet. If I use the debugger and wait a little after <code>WriteTextAsync</code> finishes, I can see the file appear in the folder and <code>GetFileAsync</code> does not throw an exception. How can I wait for the file to be fully written to and appear in the folder so that <code>GetFileAsync</code> does not throw an exception?</p>
| [
{
"answer_id": 74177693,
"author": "Roy Li - MSFT",
"author_id": 8443430,
"author_profile": "https://Stackoverflow.com/users/8443430",
"pm_score": 3,
"selected": true,
"text": " var target= await ApplicationData.Current.TemporaryFolder.TryGetItemAsync(\"FileName\");\n\n if (targe... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177099",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/355023/"
] |
74,177,117 | <pre><code>public function actionItemsenbale($organization_id) {
$items = Item::updateAll(['is_rtm_enable' => SharedConstant::VALUE_ZERO])->andWhere(['organization_id' => $organization_id]);
return (new ApiResponse)->success(['item' => $items]);
}
</code></pre>
| [
{
"answer_id": 74177160,
"author": "thevikas",
"author_id": 434616,
"author_profile": "https://Stackoverflow.com/users/434616",
"pm_score": 1,
"selected": false,
"text": "updateAll"
},
{
"answer_id": 74290610,
"author": "Karlis Pokkers",
"author_id": 7202135,
"author_... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10871442/"
] |
74,177,119 | <p>I've got the following table structure for storing IPs (PostgreSQL 11.14):</p>
<pre><code>CREATE TABLE ips (
ip INET
);
INSERT INTO ips VALUES ('10.0.0.4');
INSERT INTO ips VALUES ('10.0.0.0/24');
INSERT INTO ips VALUES ('10.1.0.0/23');
INSERT INTO ips VALUES ('10.1.0.0/27');
</code></pre>
<p>I need to know which network range is duplicate to find overlapping network entries.</p>
| [
{
"answer_id": 74177151,
"author": "Tim Biegeleisen",
"author_id": 1863229,
"author_profile": "https://Stackoverflow.com/users/1863229",
"pm_score": 0,
"selected": false,
"text": "SUBSTRING()"
},
{
"answer_id": 74177819,
"author": "Zegarek",
"author_id": 5298879,
"aut... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20319098/"
] |
74,177,141 | <p>I am trying to make a graph showing the average temp in Australia from 1950 to 2000. My dataset contains a "Country" table which contains Australia but also other countries as well. The dataset also includes years and average temp for every country. How would I go about excluding all the other data to make a graph just for Australia?</p>
<p><a href="https://i.stack.imgur.com/RiM6x.jpg" rel="nofollow noreferrer">Example of the dataset</a></p>
| [
{
"answer_id": 74177151,
"author": "Tim Biegeleisen",
"author_id": 1863229,
"author_profile": "https://Stackoverflow.com/users/1863229",
"pm_score": 0,
"selected": false,
"text": "SUBSTRING()"
},
{
"answer_id": 74177819,
"author": "Zegarek",
"author_id": 5298879,
"aut... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20319181/"
] |
74,177,172 | <p>I'm using flutter, and I'm loading in a locally stored JSON file like so:</p>
<pre class="lang-dart prettyprint-override"><code>Future<String> loadJson(String file) async {
final jsonData = await rootBundle.loadString("path/to/$file.json");
return jsonData;
}
</code></pre>
<p>The problem is that this returns a <code>Future<String></code> and I'm unable to extract the actual JSON data (as a <code>String</code>) from it.</p>
<p>I call <code>loadJson</code> in the Widget build method like so:</p>
<pre class="lang-dart prettyprint-override"><code>@override
Widget build(BuildContext context) {
final data = ModalRoute.of(context)!.settings.arguments as Map;
final file = data["file"];
String jsonData = loadJson(file); // The issue is here
return Scaffold (/* -- Snip -- */);
}
</code></pre>
<p>How would I go about doing this? Any help is appreciated.</p>
| [
{
"answer_id": 74177370,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 2,
"selected": true,
"text": "loadJson"
},
{
"answer_id": 74177386,
"author": "Tahir",
"author_id": 6340327,
"author_prof... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19173765/"
] |
74,177,179 | <p>I have a tiny C# program which listen to the outlook with ItemAdd event, every time I start the program, it will malfunction after a few days run, for example I start the program on Monday, it will be failure on Thursday, or Wednesday, then it has to be restarted.<br>
What's going on behind the scene? And how to fix it?
<br>This should not be RAM issue? Because I have 32G RAM.<br>
Win10 21H1, Outlook 2016, .net framework 4.7.2</p>
<p>=========================================</p>
<p>Problem solved, I give up the COM-way handling and adopt MailKit, things are getting straight and clear.</p>
<pre><code>public partial class Form2 : Form
{
private NameSpace _ns;
private readonly ApplicationClass _outlook = new ApplicationClass();
private readonly StringProcessor _processor = new StringProcessor();
private Items _items;
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
try
{
Main();
}
catch (System.Exception ex)
{
}
}
private void Main()
{
try
{
_ns = _outlook.GetNamespace("MAPI");
MAPIFolder myFolder;
if (Environment.UserName == XmlService.UserName)
{
var box = XmlService.Inbox;
myFolder = GetFolderItem(box);
}
else
{
myFolder = _ns.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
}
if (myFolder != null)
{
_items = myFolder.Items;
_items.ItemAdd += Items_ItemAdd;
}
else
{
Loger.PrintLog("Can not get folder");
}
}
catch (System.Exception e)
{
Loger.PrintLog(e.Message);
}
}
private void Items_ItemAdd(object item)
{}
}
</code></pre>
| [
{
"answer_id": 74177370,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 2,
"selected": true,
"text": "loadJson"
},
{
"answer_id": 74177386,
"author": "Tahir",
"author_id": 6340327,
"author_prof... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19569140/"
] |
74,177,184 | <p>I have Tibetan word and it's POS, as below:</p>
<pre><code>སྩོལ་ VERB
སྐབས་ NOUN
ཆོས་ NOUN
ཞུ་བ་ VERB
ཚོས་ NOUN
དེབ་ NOUN
</code></pre>
<p>how can i extract only the pos as shown :</p>
<pre><code>VERB
NOUN
NOUN
VERB
NOUN
NOUN
</code></pre>
<p>code I tried :</p>
<pre><code>file = # given input file containing word and pos
for line in file:
word = line.split(' ')[0]
pos = line.split(' ')[2]
</code></pre>
<p>above code is not showing the desired result, if you guys have any idea, would help alot!</p>
| [
{
"answer_id": 74177370,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 2,
"selected": true,
"text": "loadJson"
},
{
"answer_id": 74177386,
"author": "Tahir",
"author_id": 6340327,
"author_prof... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17946386/"
] |
74,177,214 | <p>Hoping someone can help me here - i believe i am close to the solution.</p>
<p>I have a dataframe, of which i have am using .count() in order to return a series of all column names of my dataframe, and each of their respective non-NAN value counts.</p>
<p>Example dataframe:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: left;">feature_1</th>
<th style="text-align: center;">feature_2</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">1</td>
<td style="text-align: center;">1</td>
</tr>
<tr>
<td style="text-align: left;">2</td>
<td style="text-align: center;">NaN</td>
</tr>
<tr>
<td style="text-align: left;">3</td>
<td style="text-align: center;">2</td>
</tr>
<tr>
<td style="text-align: left;">4</td>
<td style="text-align: center;">NaN</td>
</tr>
<tr>
<td style="text-align: left;">5</td>
<td style="text-align: center;">3</td>
</tr>
</tbody>
</table>
</div>
<p>Example result for .count() here would output a series that looks like:</p>
<p>feature_1 5</p>
<p>feature_2 3</p>
<p>I am now trying to get this data into a dataframe, with the column names "Feature" and "Count". To have the expected output look like this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: left;">Feature</th>
<th style="text-align: center;">Count</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">feature_1</td>
<td style="text-align: center;">5</td>
</tr>
<tr>
<td style="text-align: left;">feature_2</td>
<td style="text-align: center;">3</td>
</tr>
</tbody>
</table>
</div>
<p>I am using .to_frame() to push the series to a dataframe in order to add column names. Full code:</p>
<pre><code>df = data.count()
df = df.to_frame()
df.columns = ['Feature', 'Count']
</code></pre>
<p>However receiving this error message - "ValueError: Length mismatch: Expected axis has 1 elements, new values have 2 elements", as if though it is not recognising the actual column names (Feature) as a column with values.</p>
<p>How can i get it to recognise both Feature and Count columns to be able to add column names to them?</p>
| [
{
"answer_id": 74177370,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 2,
"selected": true,
"text": "loadJson"
},
{
"answer_id": 74177386,
"author": "Tahir",
"author_id": 6340327,
"author_prof... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20319213/"
] |
74,177,234 | <p>I recently checked the internal code of viewModelScope which is</p>
<p><code>CloseableCoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)</code></p>
<p>So my question is does the block inside the viewModelScope really runs on Main thread if yes, then how or which scope should I use to access or run DB operation inside view model? Because DB operation should run on background thread</p>
| [
{
"answer_id": 74177370,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 2,
"selected": true,
"text": "loadJson"
},
{
"answer_id": 74177386,
"author": "Tahir",
"author_id": 6340327,
"author_prof... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18125775/"
] |
74,177,249 | <p>I am using krakend-ce 1.4 and influx 1.X
I have configured grafana dashboard and hoping to see dashboard panels for all the layers.
There are 4 layers as per dashboard.</p>
<ul>
<li>Router</li>
<li>Proxy</li>
<li>Backend</li>
<li>System</li>
</ul>
<p><a href="https://i.stack.imgur.com/UVsYR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UVsYR.png" alt="enter image description here" /></a></p>
<p>I see router panels data is getting charted as expected. But for other panels I see empty charts. <code>"No Data to show"</code>
<a href="https://i.stack.imgur.com/IV7o5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IV7o5.png" alt="enter image description here" /></a></p>
<p>my configuration for krakend-metrics and influx modules is as follows:</p>
<pre><code>"github_com/devopsfaith/krakend-metrics": {
"collection_time": "30s",
"proxy_disabled": false,
"router_disabled": false,
"backend_disabled": false,
"endpoint_disabled": false,
"listen_address": "127.0.0.1:8090"
},
"github_com/letgoapp/krakend-influx":{
"address":"http://influxdb-service:80",
"ttl":"25s",
"buffer_size":0,
"db": "krakend",
"username": "admin",
"password": "adminadmin"
}
</code></pre>
<p>I also added opencensus as follows:</p>
<pre><code>"github_com/devopsfaith/krakend-opencensus": {
"sample_rate": 100,
"reporting_period": 1,
"enabled_layers": {
"backend": true,
"router": true,
"pipe": true
},
"influxdb": {
"address": "http://influxdb-service:80",
"db": "krakend",
"timeout": "1s",
"username": "admin",
"password": "adminadmin"
}
}
</code></pre>
<p>I thought may be my data is not ending up in influxDB, so I went in and checked what does it have. <code>show measurements</code> give me following output, and all measurements does have some data.
<a href="https://i.stack.imgur.com/cJeNE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cJeNE.png" alt="enter image description here" /></a></p>
<p>I am using grafana dashboard ID 5722. which is specified in docs.</p>
<p>how can I change my setup so that panels for proxy, backend and system shows charts?</p>
<p><strong>__________________________</strong></p>
<p><strong>UPDATE</strong></p>
<ul>
<li>I upgrade krakend to version 2.1</li>
<li>Removed opencensus metrics exporter</li>
<li>Now using dashboard <code>15029</code> per krakend 2.1.2 documentation.</li>
</ul>
<p>I still do not see other layer charts getting populated.</p>
<p>PS: I have checked what metrics are getting exposed on <code>http://krakend-host:8090/__stats</code> I see layer.backend and layer.pipe metrics.</p>
<p><strong>__________________________</strong></p>
<p><strong>UPDATE 2</strong></p>
<p>I was also checking for other available dashboards which can work. I stumbled upon this one <a href="https://github.com/letgoapp/krakend-influx/blob/master/examples/grafana-dashboard.json" rel="nofollow noreferrer">https://github.com/letgoapp/krakend-influx/blob/master/examples/grafana-dashboard.json</a></p>
<p>I see 2 more panels showing up. but not all of them.</p>
| [
{
"answer_id": 74177370,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 2,
"selected": true,
"text": "loadJson"
},
{
"answer_id": 74177386,
"author": "Tahir",
"author_id": 6340327,
"author_prof... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2223459/"
] |
74,177,254 | <p>Hi I am new to Scala and I am using intellij Idea. I am trying to filestream a text file running Scala cluster on Hadoop-Spark. My main goal is to count only words (without any special characters) in a key, value format.</p>
<p>I found <a href="https://stackoverflow.com/questions/28837908/apache-spark-regex-extract-words-from-rdd">apache-spark regex extract words from rdd</a> article where they use findAllIn() function with regex but not sure if I am using it correctly in my code.</p>
<p>When I built my project and generate the jar file to run it in Spark I manually provide the text file and it seems that it runs and count words but it also seems that it enters in a loop as it processed the file infinitely. I thought it should process it only once.</p>
<p>Can someone tell me why this may be happening? or is it a better way to achieve my goal?</p>
<p>Part of my text is:</p>
<pre><code>It wlll only take a day,' he said. The others disagreed.
It's too fragile," 289 they said disapprovingly 23 age, but he refused to listen. Not
quite so lazy, the second little pig went in search of planks of seasoned 12 hola, 1256 23.
</code></pre>
<p>My code is:</p>
<pre><code>package streaming
import org.apache.spark.SparkConf
import org.apache.spark.streaming.{Seconds, StreamingContext}
object NetworkWordCount {
def main(args: Array[String]): Unit = {
if (args.length < 1) {
System.err.println("Usage: HdfsWordCount <directory>")
System.exit(1)
}
//StreamingExamples.setStreamingLogLevels()
val sparkConf = new SparkConf().setAppName("HdfsWordCount").setMaster("local")
// Create the context
val ssc = new StreamingContext(sparkConf, Seconds(5))
// Create the FileInputDStream on the directory and use the
// stream to count words in new files created
val lines = ssc.textFileStream(args(0))
val sep_words = lines.flatMap("[a-zA-Z]+".r.findAllIn(_))
val wordCounts = sep_words.map(x => (x, 1)).reduceByKey(_ + _)
wordCounts.saveAsTextFiles("hdfs:///user/test/task1.txt")
wordCounts.print()
ssc.start()
ssc.awaitTermination()
}
}
</code></pre>
<p>My expected output is something like below but as mentioned before it keeps repeating:</p>
<pre><code>22/10/24 05:11:40 INFO ShuffleBlockFetcherIterator: Started 0 remote fetches in 0 ms
22/10/24 05:11:40 INFO Executor: Finished task 0.0 in stage 27.0 (TID 20). 1529 bytes result sent to driver
22/10/24 05:11:40 INFO TaskSetManager: Finished task 0.0 in stage 27.0 (TID 20) in 18 ms on localhost (executor driver) (1/1)
22/10/24 05:11:40 INFO TaskSchedulerImpl: Removed TaskSet 27.0, whose tasks have all completed, from pool
22/10/24 05:11:40 INFO DAGScheduler: ResultStage 27 (print at NetworkWordCount.scala:28) finished in 0.031 s
22/10/24 05:11:40 INFO DAGScheduler: Job 13 finished: print at NetworkWordCount.scala:28, took 0.036092 s
-------------------------------------------
Time: 1666588300000 ms
-------------------------------------------
(heaped,1)
(safe,1)
(became,1)
(For,1)
(ll,1)
(it,1)
(Let,1)
(Open,1)
(others,1)
(pack,1)
...
22/10/24 05:11:40 INFO JobScheduler: Finished job streaming job 1666588300000 ms.1 from job set of time 1666588300000 ms
22/10/24 05:11:40 INFO JobScheduler: Total delay: 0.289 s for time 1666588300000 ms (execution: 0.222 s)
22/10/24 05:11:40 INFO ShuffledRDD: Removing RDD 40 from persistence list
22/10/24 05:11:40 INFO BlockManager: Removing RDD 40
22/10/24 05:11:40 INFO MapPartitionsRDD: Removing RDD 39 from persistence list
22/10/24 05:11:40 INFO BlockManager: Removing RDD 39
</code></pre>
<p>Additionally, I notice that when I only use split() function without any regex neither findAllIn() function it process the file only once as expected, but of course it only splits the text by spaces.</p>
<p>Something like this:</p>
<pre><code>val lines = ssc.textFileStream(args(0))
val words = lines.flatMap(_.split(" "))
val wordCounts = words.map(x => (x, 1)).reduceByKey(_ + _)
</code></pre>
<p>I almost forgot if you can explain also the meaning of the usage of underscores in code will help me a lot. I am having some problems to understand that part too.</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 74177370,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 2,
"selected": true,
"text": "loadJson"
},
{
"answer_id": 74177386,
"author": "Tahir",
"author_id": 6340327,
"author_prof... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20006588/"
] |
74,177,268 | <p>In my model, I have a book and review class and I want to calculate the average rating. I use aggregate and Avg for that.
What I want is to display the list of books with their average rating.</p>
<p>models.py</p>
<pre><code>class Book(models.Model):
author = models.ManyToManyField(Author, related_name='books')
title = models.CharField(max_length=200)
description = models.TextField(max_length=3000)
price = models.DecimalField(max_digits=6, decimal_places=2)
publisher = models.CharField(max_length=200)
language = models.CharField(max_length=200)
pages = models.PositiveSmallIntegerField()
isbn = models.CharField(max_length=13, validators=[validate_isbn(), MaxLengthValidator(13)])
cover_image = models.ImageField(upload_to='books/images')
publish = models.BooleanField(default=True)
@property
def average_rating(self):
avg_rating = Review.objects.filter(book_id=self.id).aggregate(Avg('rating'))
return avg_rating['rating__avg']
def __str__(self):
return self.title
class Review(models.Model):
RATING = [
(1, 1),
(2, 2),
(3, 3),
(4, 4),
(5, 5),
]
book = models.ForeignKey(Book, on_delete=models.CASCADE, related_name='reviews')
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
description = models.TextField()
rating = models.PositiveSmallIntegerField(choices=RATING, default=5)
date_added = models.DateField(auto_now_add=True)
objects = ReviewManager()
def __str__(self):
return f"{self.user.username} {self.book.title}"
</code></pre>
<p>Now for each book, I have one extra query
<a href="https://i.stack.imgur.com/HCh5W.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HCh5W.jpg" alt="enter image description here" /></a></p>
<p>How can I fix this issue?</p>
| [
{
"answer_id": 74177370,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 2,
"selected": true,
"text": "loadJson"
},
{
"answer_id": 74177386,
"author": "Tahir",
"author_id": 6340327,
"author_prof... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10468368/"
] |
74,177,270 | <p>New to move and sui.</p>
<p>I am trying to follow the documentation on Sui and attempted to use the command <code>sui move build</code> to build my move package.</p>
<p>I encountered this error:</p>
<pre><code>Failed to build Move modules: "Unable to resolve packages for package 'my_first_package'".
</code></pre>
<p>Attached picture below shows:</p>
<ol>
<li>my folder structure in local.</li>
<li>the content of the .toml file.</li>
<li>sui cloned locally pointing to <code>devnet</code> branch.</li>
</ol>
<p><a href="https://i.stack.imgur.com/2iZba.jpg" rel="nofollow noreferrer">attached picture</a></p>
| [
{
"answer_id": 74177370,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 2,
"selected": true,
"text": "loadJson"
},
{
"answer_id": 74177386,
"author": "Tahir",
"author_id": 6340327,
"author_prof... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19504610/"
] |
74,177,273 | <p>I'm trying to find a method of getting <code>GetChildItem</code> to include all .xml files found in subfolders, but exclude the .xml files found in the base folder.</p>
<p>My folder structure looks like this:</p>
<pre><code>MySubFolder\IncludeThis.xml
MySubFolder\AlsoIncludeThis.xml
AnotherSubFolder\IncludeThis.xml
AnotherSubFolder\AlsoIncludeThis.xml
ExcludeThis.xml
AlsoExcludeThis.xml
</code></pre>
<p>I've tried using <code>-Include</code> and <code>-Exclude</code> arguments, without any luck, as these arguments seem to only work on file types and cannot be set to work only on certain folders.</p>
<p>Anyone know how to get <code>GetChildItem</code> to filter out the .xml files from the base folder only?</p>
<p>PS) I won't know the names of the sub folders that exist, when using the command.</p>
| [
{
"answer_id": 74177328,
"author": "Toni",
"author_id": 19895159,
"author_profile": "https://Stackoverflow.com/users/19895159",
"pm_score": 2,
"selected": true,
"text": "#Get list of subfolders\n$folders = get-childitem -Path [path] -Directory\n\n#Get xml files in subdirectories\n$xmlFil... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/803021/"
] |
74,177,308 | <p>The problem:</p>
<p>Given an array of integers <code>nums</code> containing <code>n + 1</code> integers where each integer is in the range <code>[1, n]</code> inclusive.</p>
<p>There is only one repeated number in <code>nums</code>, return this repeated number.</p>
<p>You must solve the problem without modifying the array <code>nums</code> and uses only constant
extra space.</p>
<p>Here is one of the possible solution using binary search</p>
<pre><code>class Solution(object):
def findDuplicate(self, nums):
beg, end = 1, len(nums)-1
while beg + 1 <= end:
mid, count = (beg + end)//2, 0
for num in nums:
if num <= mid: count += 1
if count <= mid:
beg = mid + 1
else:
end = mid
return end
</code></pre>
<pre><code>Example 1:
Input: nums = [1,3,4,2,2]
Output: 2
</code></pre>
<pre><code>Example 2:
Input: nums = [3,1,3,4,2]
Output: 3
</code></pre>
<p>Can someone please explain this solution for me? I understand the code but I don't understand the logic behind this. In particular, I do not understand how to construct the if statements (lines 7 - 13). Why and how do you know that when <code>num <= mid</code> then I need to do <code>count += 1</code> and so on. Many thanks.</p>
| [
{
"answer_id": 74177686,
"author": "Grismar",
"author_id": 4390160,
"author_profile": "https://Stackoverflow.com/users/4390160",
"pm_score": 3,
"selected": true,
"text": "nums == [1, 3, 4, 2, 2]"
},
{
"answer_id": 74177698,
"author": "fas",
"author_id": 3365922,
"auth... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10824975/"
] |
74,177,313 | <p>so i have two arrays of object like this:</p>
<pre><code>var lab =[
{ label: '1', value: 42 },
{ label: '2', value: 55 },
{ label: '3', value: 51 },
{ label: '4', value: 22 }
];
var val = [ { label: '1', value: 42 },
{ label: '2', value: 55 },
];
lab.forEach(labs=>{
val.forEach(vals=>{
labs["columns"]=vals.value
})
})
console.log(lab)
</code></pre>
<p>i try to get the value like this</p>
<pre><code>[ { label: '1', value: 42, columns: {42,55} },
{ label: '2', value: 55, columns:{42,55} },
{ label: '3', value: 51, columns: {42,55} },
{ label: '4', value: 22, columns: {42,55} } ]
</code></pre>
<p>but after i ran the code i get the value that i am not wanted like this:</p>
<pre><code>[ { label: '1', value: 42, columns: 55 },
{ label: '2', value: 55, columns: 55 },
{ label: '3', value: 51, columns: 55 },
{ label: '4', value: 22, columns: 55 } ]
</code></pre>
<p>where do i did wrong actually on the loop..</p>
| [
{
"answer_id": 74177607,
"author": "JS24",
"author_id": 16136595,
"author_profile": "https://Stackoverflow.com/users/16136595",
"pm_score": 0,
"selected": false,
"text": "var lab =[\n { label: '1', value: 42 },\n { label: '2', value: 55 },\n { label: '3', value: 51 },\n { label: '4',... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16136595/"
] |
74,177,320 | <p>i am wrtiting this code to get information about top movies and also download the image blong to the movie but on some image they downloaded but their size are 0 but they have size on disk when i kilick on the link of the image that i cant download it well its opening well and there is no problem in link
for exampele this is one of the link that images :
<a href="https://static.stacker.com/s3fs-public/styles/slide_desktop/s3/00000116_4_0.png" rel="nofollow noreferrer">https://static.stacker.com/s3fs-public/styles/slide_desktop/s3/00000116_4_0.png</a></p>
<pre><code>import requests
from bs4 import BeautifulSoup
import pandas as pd
URL = "https://stacker.com/stories/1587/100-best-movies-all-time"
count = 0
local_description = ""
movie_data = []
data = requests.get(URL).text
soap = BeautifulSoup(data, "html.parser")
titles = soap.find_all(name="h2", class_="ct-slideshow__slide__text-container__caption")[1:]
description = soap.find_all(name="div", class_="ct-slideshow__slide__text-container__description")[1:]
images = soap.find_all(name="img", typeof="foaf:Image")[6:106]
for num in range(100):
movie_name = titles[num].getText().replace("\n", "")
local_des = description[num].find_all(name="p")[1:]
for s in local_des:
local_description = s.getText().replace(" ", "")
local_data = {"title": movie_name, "description": local_description}
movie_data.append(local_data)
movie_image_link = images[num].get("src")
response = requests.get(movie_image_link)
with open(f"images/{movie_name}.png", 'wb') as f:
f.write(response.content)
count += 1
print(count)
data_collected = pd.DataFrame(movie_data)
data_collected.to_csv("Data/100_movie.csv", index=False)
</code></pre>
| [
{
"answer_id": 74178601,
"author": "Stink",
"author_id": 19408629,
"author_profile": "https://Stackoverflow.com/users/19408629",
"pm_score": 2,
"selected": true,
"text": "movie_name.replace(\":\", \"\")\n"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19408629/"
] |
74,177,348 | <p>When using color.id from the plotrix package, is it possible to get ONLY a single colour returned not a vector of colours?
see this example:</p>
<pre><code>color.id("#A1A295")
</code></pre>
<p>this returns:
"gray62" "grey62"</p>
<p>Is there a way (or another package) that simply returns a single colour name?</p>
<p>Thanks.</p>
| [
{
"answer_id": 74177629,
"author": "AlienDeg",
"author_id": 4208407,
"author_profile": "https://Stackoverflow.com/users/4208407",
"pm_score": 2,
"selected": true,
"text": "get_color_name <- function(color_hex) {\n out = vector(length = length(color_hex))\n \n for(i in seq_along(color_... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17740389/"
] |
74,177,352 | <pre><code>CREATE OR REPLACE TYPE a IS OBJECT
(
b integer,
c varchar2(10)
);
/
declare
cursor ca return a is select 1,'e' from dual;
va a;
begin
null;
for cur in ca
loop
DBMS_OUTPUT.PUT_LINE('do nothing');
end loop;
end;
</code></pre>
<blockquote>
<p>ORA-03113: end-of-file on communication channel
Process ID: 803778
Session ID: 64 Serial number: 4181</p>
</blockquote>
<p>the loop as only one element and fast nothing is done in the loop.
But I get the error end-of-file communication channel</p>
<p>As @littlefoot said it works fine if I use a record defined in a package or no record at all. I don't know why it doesn't work with an object</p>
<p><a href="https://dbfiddle.uk/GSILu77p" rel="nofollow noreferrer">code</a></p>
| [
{
"answer_id": 74177629,
"author": "AlienDeg",
"author_id": 4208407,
"author_profile": "https://Stackoverflow.com/users/4208407",
"pm_score": 2,
"selected": true,
"text": "get_color_name <- function(color_hex) {\n out = vector(length = length(color_hex))\n \n for(i in seq_along(color_... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8458083/"
] |
74,177,392 | <p>Hi I have a dictionary that is currently the one below:</p>
<pre><code>dictionary={1:'a',2:'b',3:'c'}
</code></pre>
<p>my desired output is to have a dictionary with the highest keys to the left and the lowest keys to the right like below:</p>
<pre><code>dictionary={3:'c',2:'b',1:'a'}
</code></pre>
<p>how do you do that in python 3.7?</p>
| [
{
"answer_id": 74177629,
"author": "AlienDeg",
"author_id": 4208407,
"author_profile": "https://Stackoverflow.com/users/4208407",
"pm_score": 2,
"selected": true,
"text": "get_color_name <- function(color_hex) {\n out = vector(length = length(color_hex))\n \n for(i in seq_along(color_... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19286514/"
] |
74,177,396 | <p>I have a list of dataframes. Each is build up as followed:
<a href="https://i.stack.imgur.com/ku8mY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ku8mY.png" alt="Dataframe" /></a></p>
<p>No i want to extract the dataframes beginning at a certain time.</p>
<pre><code>Collection=[]
for i in range(len(subdfs)):
if any(subdfs[i]['Zeitpunkt'][subdfs[i]['Zeitpunkt'].dt.hour.eq(12)]):
Collection.append(subdfs[i]['Zeitpunkt'])
</code></pre>
<p>With this code i am able to extract every dataframe where the hour 12 appears. But i only want the dataframes where the hour 12 is in the <strong>first</strong> row.</p>
| [
{
"answer_id": 74177629,
"author": "AlienDeg",
"author_id": 4208407,
"author_profile": "https://Stackoverflow.com/users/4208407",
"pm_score": 2,
"selected": true,
"text": "get_color_name <- function(color_hex) {\n out = vector(length = length(color_hex))\n \n for(i in seq_along(color_... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20291779/"
] |
74,177,404 | <p>I am using <a href="https://pub.dev/packages/printing" rel="nofollow noreferrer">printing 5.9.3</a> flutter package to preview html in pdf format.I want to share that pdf to spesific whatsapp number.How can i do that.</p>
<pre><code> Future<Uint8List> doc = Printing.convertHtml(
format: PdfPageFormat.a4,
html: htmlString
);
sahreOnWhatsapp(String phoneNumber,Uint8List doc){
//share doc to wahtsapp number
}
</code></pre>
| [
{
"answer_id": 74177629,
"author": "AlienDeg",
"author_id": 4208407,
"author_profile": "https://Stackoverflow.com/users/4208407",
"pm_score": 2,
"selected": true,
"text": "get_color_name <- function(color_hex) {\n out = vector(length = length(color_hex))\n \n for(i in seq_along(color_... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15732885/"
] |
74,177,410 | <p>The following query is giving me time with date but i need only date .How do I do?</p>
<pre><code>$data = DB::table('kahanighar_ivr.kahani_cdr')
->select(DB::raw('count(*) as a'),'dst','calldate as ibdate',DB::raw('"kahani" as ser'))
->where('dst','like','%7787%')
->wheredate('calldate','>=',"$request->start")
->wheredate('calldate','<=',"$request->end")
->groupBy('dst')->groupBy('calldate')
->union(DB::table('kids_ivr.kids_cdr')
->select(DB::raw('count(*) as a'),'dst','calldate as ibdate',DB::raw('"kids" as ser'))
->where('dst','like','%7787%')
->wheredate('calldate','>=',"$request->start")
->wheredate('calldate','<=',"$request->end")
->groupBy('dst')->groupBy('calldate'))
->union(DB::table('news_ivr.news_cdr')
->select(DB::raw('count(*) as a'),'dst','calldate as ibdate',DB::raw('"news" as ser'))
->where('dst','like','%7787%')
->wheredate('calldate','>=',"$request->start")
->wheredate('calldate','<=',"$request->end")
->groupBy('dst')->groupBy('calldate'));
</code></pre>
| [
{
"answer_id": 74177629,
"author": "AlienDeg",
"author_id": 4208407,
"author_profile": "https://Stackoverflow.com/users/4208407",
"pm_score": 2,
"selected": true,
"text": "get_color_name <- function(color_hex) {\n out = vector(length = length(color_hex))\n \n for(i in seq_along(color_... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19124962/"
] |
74,177,425 | <p>How to create a validator from the textbox class or create new textbox, rather than dragging the textbox from the toolbox</p>
<pre><code>private void Form1_Load(object sender, EventArgs e)
{
createTextpass();
// Creating and setting the properties of TextBox1
TextBox textboxUsername = new TextBox();
textboxUsername.Location = new Point(420, 50);
textboxUsername.Size = new Size (300,30);
textboxUsername.Name = "text_user";
this.Controls.Add(textboxUsername);
TextBox textboxPassword = new TextBox();
textboxPassword.Location = new Point(420, 80);
textboxPassword.Size = new Size(300, 30);
textboxPassword.Name = "text_pass";
this.Controls.Add(textboxPassword);
TextBox textboxMail = new TextBox();
textboxMail.Location = new Point(420, 110);
textboxMail.Size = new Size(300, 30);
textboxMail.Name = "text_mail";
this.Controls.Add(textboxMail);
}
</code></pre>
| [
{
"answer_id": 74177629,
"author": "AlienDeg",
"author_id": 4208407,
"author_profile": "https://Stackoverflow.com/users/4208407",
"pm_score": 2,
"selected": true,
"text": "get_color_name <- function(color_hex) {\n out = vector(length = length(color_hex))\n \n for(i in seq_along(color_... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4938595/"
] |
74,177,487 | <p>I am using <code>signInWithCustomToken()</code> after initiating it on the server.</p>
<pre><code>async function signinWithToken(data, sendResponse) {
const { token } = data;
console.log(token);
signInWithCustomToken(auth, token)
.then((user) => {
console.log(user);
sendResponse({ success: true, user });
})
.catch((err) => {
sendResponse({ success: false, message: err.message
});
});
</code></pre>
<p>}</p>
<p>The problem is that the user object returned doesn't include the user details like displayName, email, etc...</p>
<p><a href="https://i.stack.imgur.com/AB2U9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AB2U9.png" alt="enter image description here" /></a></p>
<p>Is there something I could do about it?</p>
| [
{
"answer_id": 74177790,
"author": "Renaud Tarnec",
"author_id": 3371862,
"author_profile": "https://Stackoverflow.com/users/3371862",
"pm_score": 0,
"selected": false,
"text": "signInWithCustomToken()"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17350392/"
] |
74,177,500 | <p>My audio player on phone is showing "SQLite exception" and crashed. It needs external storage permission but I don't have a memory card. How to resolve this error?</p>
<p>Exception:</p>
<blockquote>
<p>android.database.sqlite.SQLiteException: no such column: date_addedDESC (Sqlite code 1 SQLITE_ERROR): , while compiling: SELECT _id, _display_name, duration, _size, album_id FROM audio WHERE ((is_pending=0) AND (is_trashed=0) AND (volume_name IN ( 'external_primary' ))) AND (date_addedDESC), (OS error - 2:No such file or directory)</p>
</blockquote>
<p>Main activity :</p>
<pre><code>private void fetchPlayer() {
//define a list to carry players
List<player> mPlayer = new ArrayList<> ();
Uri mediaStoreUri;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
mediaStoreUri = MediaStore.Audio.Media.getContentUri (MediaStore.VOLUME_EXTERNAL);
}else{
mediaStoreUri = MediaStore.Audio.Media. EXTERNAL_CONTENT_URI;
}
// define projection
String[] projection = new String[]{
MediaStore.Audio.Media._ID,
MediaStore.Audio.Media.DISPLAY_NAME,
MediaStore.Audio.Media.DURATION,
MediaStore.Audio.Media.SIZE,
MediaStore.Audio.Media.ALBUM_ID,
};
// order
String sortOrder = MediaStore.Audio.Media.DATE_ADDED + " DESC ";
// get the players
try (Cursor cursor = getContentResolver ().query (mediaStoreUri,projection,sortOrder,null,null)) {
// cache cursor indices
int idColumn = cursor.getColumnIndexOrThrow (MediaStore.Audio.Media._ID);
int nameColumn = cursor.getColumnIndexOrThrow (MediaStore.Audio.Media.DISPLAY_NAME);
int durationColumn = cursor.getColumnIndexOrThrow (MediaStore.Audio.Media.DURATION);
int sizeColumn = cursor.getColumnIndexOrThrow (MediaStore.Audio.Media.SIZE);
int albumColumn = cursor.getColumnIndexOrThrow (MediaStore.Audio.Media.ALBUM_ID);
//clear the previous loaded before adding loading again
while (cursor.moveToNext ()){
//get the values of a column for a given audio file
long id = cursor.getLong(idColumn );
String name = cursor.getString (nameColumn);
int duration = cursor.getInt (durationColumn);
int size = cursor.getInt (sizeColumn);
long albumId = cursor.getLong (albumColumn);
// player Uri
Uri uri = ContentUris.withAppendedId (MediaStore.Audio.Media.EXTERNAL_CONTENT_URI , id );
// album artwork uri
Uri albumArtWorkUri = ContentUris.withAppendedId (Uri.parse("content:// media/external/audio/albumart") , albumId);
// remove mp3 extension from players name
name = name.substring (0 , name.lastIndexOf ("."));
//player item
player player = new player (name , uri , albumArtWorkUri , size , duration , id );
//add player item to play list
mPlayer.add(player);
}
//display player
showPlayers(mPlayer);
}
}
private void showPlayers(List<player> mPlayer){
if(mPlayer.size () == 0){
Toast.makeText (this , "No Players" , Toast.LENGTH_SHORT ).show ();
return;
}
// save players
allPlayer.clear ();
allPlayer.addAll (mPlayer);
//update the tools bar title
String title = getResources ().getString (R.string.app_name) + "." + mPlayer.size ();
Objects.requireNonNull (getSupportActionBar ()).setTitle (title);
//layout manager
LinearLayoutManager layoutManager = new LinearLayoutManager (this);
recyclerView.setLayoutManager (layoutManager);
//players adapter
playerAdapter = new playerAdapter (this , mPlayer);
//set the adapter to recycleView
recyclerView.setAdapter (playerAdapter);
}
}
</code></pre>
| [
{
"answer_id": 74177790,
"author": "Renaud Tarnec",
"author_id": 3371862,
"author_profile": "https://Stackoverflow.com/users/3371862",
"pm_score": 0,
"selected": false,
"text": "signInWithCustomToken()"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19278199/"
] |
74,177,517 | <p><a href="https://i.stack.imgur.com/guuNz.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/guuNz.jpg" alt="enter image description here" /></a></p>
<p>As you see on the sample picture, I set autofilter on column <strong>B</strong> and excluded the value <code>B</code>.<br>
I need to get the visible range except the first row, with using <code>UsedRange</code> and SpecialCells(xlCellTypeVisible) method.<br>
I tried the below three codes, but it either add additional row or throw an error:<br></p>
<pre><code>Sub Get_Range_of_two_non_contiguous_filtered_criteria_except_First_Row()
Dim ws As Worksheet, rng As Range
Set ws = ThisWorkbook.ActiveSheet
Set rng = ws.UsedRange.Offset(1).SpecialCells(xlCellTypeVisible)
Debug.Print rng.Address 'Addtional Row is added to rng ($A$2:$B$3,$A$6:$B$8)
Set rng = Intersect(ws.Cells, ws.UsedRange.Offset(1).SpecialCells(xlCellTypeVisible))
Debug.Print rng.Address 'Addtional Row is added to rng $A$2:$B$3,$A$6:$B$8
Dim crg As Range: Set crg = ws.UsedRange.SpecialCells(xlCellTypeVisible)
Set crg = crg.Offset(1, 0).Resize(crg.Rows.Count - 1, crg.Columns.Count) 'Error: Application-defined or object-defined error
Debug.Print crg.Address
End Sub
</code></pre>
<p>This is the only method I found that it works correctly:<br></p>
<pre><code>Dim LastRow As Long
LastRow = ws.Cells(Rows.Count, "A").End(xlUp).Row
Set rng = ws.Range("A2:B" & LastRow).SpecialCells(xlCellTypeVisible)
Debug.Print rng.Address
</code></pre>
<p>In Advance, thanks for all your help and comments.</p>
| [
{
"answer_id": 74177738,
"author": "Ike",
"author_id": 16578424,
"author_profile": "https://Stackoverflow.com/users/16578424",
"pm_score": 0,
"selected": false,
"text": " Dim crg as range, a As Range\n With ws.UsedRange.SpecialCells(xlCellTypeVisible)\n For Each a In .Areas\... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177517",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15586050/"
] |
74,177,518 | <p>I want to create responsive multiple forms <strong>(form1, form2, and form3)</strong> with the same pages using framer motion. However, when I create the state <code>value</code> and want to make it change when the user fills the form by using setValue in handleChange, the value of the state is not updated correctly as I want. When the user fills <code>Select Protocol</code> the filled form is not updated on the user screen but the state is changed. Moreover, when the user fills <code>Select number of hops</code> after that, the <code>link level</code> state is deleted. I have no idea how to fix this problem.</p>
<pre><code>import React, { useState, useEffect } from "react";
import { motion, AnimatePresence } from "framer-motion";
export default function ExperC() {
// state that I want to collect user fill form
const [value, setValue] = useState({
link_level: "",
hop_select: "",
num_hop: "",
location_1: "",
location_2: "",
photon_loss: "",
dep: "",
gate_error: "",
coherent: "",
mea_error: "",
trajectory: "",
});
const handleChangeLinklevel = (e) => {
setValue({ ...value, link_level: e.target.value });
};
const handleChangeHop = (e) => {
setValue({ ...value, hop_select: e.target.value });
};
// jsx of form 1
const form1 = (
<form action="" className="w-[140%]">
<div className="flex space-x-2">
<h1 className="text-[#fff] text-4xl">Configure your </h1>
<h1 className="text-[#ad73f1] text-4xl">Qwanta network</h1>
</div>
<p className="mt-5 mb-2 text-gray-400">Select Protocol</p>
<select
className="w-full h-8 text-black bg-white"
onChange={handleChangeLinklevel}
value={value.link_level}
>
<option value="" disabled selected>
Select your protocol
</option>
<option value="0G">0 Generation (0G)</option>
<option value="1G">1G-Ss-Dp (1G)</option>
<option value="2G-NCX">2G-NonLocal-CNOT (2G-NCX)</option>
<option value="HG-DE">1-2G-Directed-Encoded, (HG-DE)</option>
<option value="HG-E2E-PE">HG-E2E-PurifiedEncoded</option>
<option value="Design own protocol">Design own protocol</option>
</select>
{useEffect(() => {
console.log("test", value);
})}
<p className="mt-5 mb-2 text-gray-400">Select number of hops</p>
<select
className="w-full h-8 text-black bg-white"
onChange={handleChangeHop}
value={value.hop_select}
>
<option value="" disabled selected>
2^n hops
</option>
<option value="2">2 hops, 3 nodes</option>
<option value="4">4 hops, 5 nodes</option>
<option value="8">8 hops, 9 nodes</option>
</select>
</form>
);
const form2 = <>This is form 2</>
const form3 = <>This is form 3</>;
// for responsive slide between form using framer motion
const experitem = [
{ name: "config1", icon: "test1", form: form1 },
{ name: "config2", icon: "test2", form: form2 },
{ name: "config3", icon: "test3", form: form3 },
];
const [selectedTab, setSelectedTab] = useState(experitem[0]);
return (
<div className="flex flex-col w-[800px] h-[600px] absolute top-[150px] bg-[#262626] left-1/3 rounded-xl overflow-hidden">
<nav className="bg-gray1 pt-3 px-3 rounded-t-xl h-[60px]">
<ul className="flex w-full">
{experitem.map((item, index) => (
<motion.li
key={index}
className={`text-white list-none cursor-pointer rounded-t-xl w-full p-3 relative bg-[#262626] h-[70px] flex justify-between align-middle flex-1 min-w-0
`}
onClick={() => setSelectedTab(item)}
initial={{ y: 0 }}
whileHover={{ y: -5 }}
>
{item.name}
{/* {item == selectedTab ? (
<div className="absolute -bottom-[2px] left-0 right-0 h-[1px] bg-blue-500" />
) : null} */}
</motion.li>
))}
</ul>
</nav>
<main className="bg-[#262626] flex justify-left align-middle flex-grow mt-6 ml-5">
<AnimatePresence exitBeforeEnter>
<motion.div
key={selectedTab ? selectedTab.name : "empty"}
initial={{ x: -100, opacity: 0 }}
animate={{ x: 0, opacity: 1 }}
exit={{ x: -10, opacity: 0 }}
transition={{ duration: 0.2 }}
>
{selectedTab ? selectedTab.form : null}
</motion.div>
</AnimatePresence>
</main>
</div>
);
}
</code></pre>
<p><a href="https://i.stack.imgur.com/g58MO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g58MO.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/K5NMm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K5NMm.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74177738,
"author": "Ike",
"author_id": 16578424,
"author_profile": "https://Stackoverflow.com/users/16578424",
"pm_score": 0,
"selected": false,
"text": " Dim crg as range, a As Range\n With ws.UsedRange.SpecialCells(xlCellTypeVisible)\n For Each a In .Areas\... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16142770/"
] |
74,177,533 | <p>I am following a tutorial to use Custom Widgest in FlutterFlow, re-using dependencies from pub.dev. However many people in the YouTube comments (including myself) hit an error whilst trying to compile the custom widget. The widget is an official Flutter.Dev widget for a video player.</p>
<p>I have tried searching for this error, however most responses involve installing more packages and restarting Android Studio etc, however this error is happening within FlutterFlow itself, which I haven't seen an answer for.</p>
<p><a href="https://i.stack.imgur.com/K2iLg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K2iLg.png" alt="FlutterFlow code with error" /></a></p>
<p>Original tutorial:
<a href="https://www.youtube.com/watch?v=jM2gwA2VHyc&ab_channel=JamesNoCode" rel="nofollow noreferrer">https://www.youtube.com/watch?v=jM2gwA2VHyc&ab_channel=JamesNoCode</a></p>
<p>Pub.dev link:
<a href="https://pub.dev/packages/video_player/example" rel="nofollow noreferrer">https://pub.dev/packages/video_player/example</a></p>
<p>Thankyou in advance!</p>
| [
{
"answer_id": 74177738,
"author": "Ike",
"author_id": 16578424,
"author_profile": "https://Stackoverflow.com/users/16578424",
"pm_score": 0,
"selected": false,
"text": " Dim crg as range, a As Range\n With ws.UsedRange.SpecialCells(xlCellTypeVisible)\n For Each a In .Areas\... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4701874/"
] |
74,177,550 | <p>I'm trying to access the latest state in other setState function, cant figure out the correct way of doing it for a functional component</p>
<p>without accessing the latest state <code>setMoviesList</code>set state as undefined and causes issues</p>
<p><strong>state</strong></p>
<pre class="lang-js prettyprint-override"><code> const [movies, setMoviesList] = useState();
const [currentGenre, setcurrentGenre] = useState();
const [page, setPage] = useState(1);
const [genreList, setGenreList] = useState();
const [nextPage, setNextPage] = useState(false);
const [previousMovieList, setPreviousMovieList] = useState();
</code></pre>
<pre class="lang-js prettyprint-override"><code> useEffect(() => {
async function getMovies(currentGenre, page) {
if (currentGenre) {
const data = await rawAxios.get(
`https://api.themoviedb.org/3/discover/movie?api_key=f4872214e631fc876cb43e6e30b7e731&language=en-US&sort_by=popularity.desc&include_adult=false&include_video=false&page=${page}&with_genres=${currentGenre}`
);
setPreviousMovieList((previousMovieList) => {
if (!previousMovieList) return [data.data];
else {
if (nextPage) {
console.log(previousMovieList);
setNextPage(false);
return [...previousMovieList, data.data];
}
}
});
setMoviesList(previousMovieList.results);
} else {
const data = await rawAxios.get(
`https://api.themoviedb.org/3/discover/movie?api_key=f4872214e631fc876cb43e6e30b7e731&language=en-US&sort_by=popularity.desc&include_adult=false&include_video=false&page=${page}`
);
if (!previousMovieList) {
console.log('!previousMovieList', previousMovieList);
console.log('!data', data.data);
setPreviousMovieList(previousMovieList)
} else {
if (nextPage) {
console.log('else', previousMovieList);
setNextPage(false);
setPreviousMovieList([...previousMovieList, data.data])
// return [...previousMovieList, data.data];
}
}
setMoviesList(previousMovieList.results);
}
}
getMovies(currentGenre, page);
}, [currentGenre, page, setMoviesList, nextPage]);
</code></pre>
<p><em>want to access latest <code>previousMovieList</code> here</em></p>
<p><code>setMoviesList(previousMovieList.results); </code></p>
| [
{
"answer_id": 74177647,
"author": "DannyMoshe",
"author_id": 4426072,
"author_profile": "https://Stackoverflow.com/users/4426072",
"pm_score": 3,
"selected": true,
"text": "previousMovieList"
},
{
"answer_id": 74177691,
"author": "SamJeff",
"author_id": 14942763,
"au... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11199128/"
] |
74,177,571 | <p>I have a huge data in excel sheet in which i have to see if a word (part 1) or (part 2) comes in any cell in Column A it should copy this specific word (Part 1) (part 2) in Column b, otherwise it returns with (blank) or (-)</p>
<p>I am able to search and copy if there is a word (Part 1) in cell by using the formula =if(isnumber(search("Part 1",A1)),"Part 1","-") but i am not able to look two criteria.</p>
<p>please see e.g. in screenshot.</p>
<p><a href="https://i.stack.imgur.com/jWnlO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jWnlO.png" alt="Screenshot" /></a></p>
<p>Is there any solution or if anyone can guide.</p>
| [
{
"answer_id": 74177652,
"author": "Ike",
"author_id": 16578424,
"author_profile": "https://Stackoverflow.com/users/16578424",
"pm_score": 2,
"selected": false,
"text": "=IFERROR(MID(A1,FIND(\"Part \",A1), 6),\"-\")"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20141828/"
] |
74,177,574 | <p>I need the user in my app to click on an add button and it should create a basic Table on the screen. I have the code for the table in Scaffold and a FAB that doesn't do anything yet. What should I write in onPressed for it to add my table on the screen?</p>
<p>Here is my code if you need it:</p>
<pre><code> @override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title:const Text("Table"),
),
floatingActionButton: FloatingActionButton(
highlightElevation: 50,
onPressed: () {},
child: const Icon(Icons.add),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
margin: const EdgeInsets.all(20),
child: Table(
border: const TableBorder(top: BorderSide(), bottom: BorderSide(), left: BorderSide(), right: BorderSide(),
horizontalInside: BorderSide(color: Colors.blue, style: BorderStyle.solid),
verticalInside: BorderSide(color: Colors.blue, style: BorderStyle.solid)),
children: const [
TableRow(children: [
Padding(padding: EdgeInsets.all(10.0),),
Padding(padding: EdgeInsets.all(10.0),)
]),
TableRow(children: [
Padding(padding: EdgeInsets.all(10.0),),
Padding(padding: EdgeInsets.all(10.0),)
]),
TableRow(children: [
Padding(padding: EdgeInsets.all(10.0),),
Padding(padding: EdgeInsets.all(10.0),)
]),
TableRow(children: [
Padding(padding: EdgeInsets.all(10.0),),
Padding(padding: EdgeInsets.all(10.0),)
]),
],
),
),
]
),
),
);
} ```
</code></pre>
| [
{
"answer_id": 74177632,
"author": "My Car",
"author_id": 16124033,
"author_profile": "https://Stackoverflow.com/users/16124033",
"pm_score": 3,
"selected": true,
"text": "List<Widget> children = [];\n"
},
{
"answer_id": 74177840,
"author": "Maria Grigoryan",
"author_id":... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19870812/"
] |
74,177,603 | <p>I have a simple function that will remove the spaces from a char array.</p>
<pre><code>char removeSpaces(char input[])
{
char output[128];
int counter = 0; // the for loop will keep track of out position in "input", this will keep track of our position in "output"
for (int n = 0; n < strlen(input); n++)
{
if (input[n] != ' ') // if a character is not a space
{
//add it too the new list
output[counter] = input[n];
counter++;
}
// if it is a space, do nothing
}
return output;
}
</code></pre>
<p>But when I run it it exits with code <code>-1073741819</code> after the last iteration</p>
| [
{
"answer_id": 74177632,
"author": "My Car",
"author_id": 16124033,
"author_profile": "https://Stackoverflow.com/users/16124033",
"pm_score": 3,
"selected": true,
"text": "List<Widget> children = [];\n"
},
{
"answer_id": 74177840,
"author": "Maria Grigoryan",
"author_id":... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18323484/"
] |
74,177,637 | <p>I am using a <code>BroadcastReceiver</code> in my code. The code in the <code>onReceive()</code> is not asynchronous but I am not sure it will always last less than 10 seconds, because, as specified <a href="https://developer.android.com/training/articles/perf-anr.html" rel="nofollow noreferrer">here</a>, an ANR will be raised.</p>
<p>I am looking to implement a simple WorkManager to make sure the instructions will be executed even when they require more than 10 seconds, but it is unclear to me how to use it in this context. I don't want the task to be scheduled, I'd like them to be executed as soon as a Broadcast is received (just like how it works in the <code>onReceive()</code>).</p>
<p>Thank you in advance!</p>
| [
{
"answer_id": 74177632,
"author": "My Car",
"author_id": 16124033,
"author_profile": "https://Stackoverflow.com/users/16124033",
"pm_score": 3,
"selected": true,
"text": "List<Widget> children = [];\n"
},
{
"answer_id": 74177840,
"author": "Maria Grigoryan",
"author_id":... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19297836/"
] |
74,177,639 | <p>I am trying to follow the approach given in this <a href="https://stackoverflow.com/questions/74173946/factory-pattern-using-a-hashmap-and-functional-approach">answer</a> of my earlier question:<br />
But the code does not compile:</p>
<pre><code>public interface Processor <T> {
class Builder {
private T t = null; // assign default values
private String firstName = null;
private String lastName = null;
private String cc = null;
}
List<Person> process();
}
</code></pre>
<p>I get the error</p>
<pre><code>com.foo.Processor.this can not be referenced from a static context
</code></pre>
<p>How can I make the code compile so I can try out the approach of that answer?</p>
| [
{
"answer_id": 74177733,
"author": "knittl",
"author_id": 112968,
"author_profile": "https://Stackoverflow.com/users/112968",
"pm_score": 2,
"selected": false,
"text": "Processor"
},
{
"answer_id": 74179633,
"author": "DuncG",
"author_id": 4712734,
"author_profile": "... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9055634/"
] |
74,177,640 | <p>I receive different strings as arguments, there may be several of them.
I check in the if block if there are more than 1 argument, then I need to return the sum of the lengths of the lines that were passed in the function arguments. How can i do this?</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 strSum = (...args) => {
let sum = 0;
if (args.length > 1) {
args.forEach((item) => {
});
}
return sum;
};
console.log(strSum('hello', 'hi', 'my name', 'is')); //16</code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74177733,
"author": "knittl",
"author_id": 112968,
"author_profile": "https://Stackoverflow.com/users/112968",
"pm_score": 2,
"selected": false,
"text": "Processor"
},
{
"answer_id": 74179633,
"author": "DuncG",
"author_id": 4712734,
"author_profile": "... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20291334/"
] |
74,177,689 | <p>I have data as follows:</p>
<pre><code>l = list(list(mtcars), list(mtcars))
</code></pre>
<p><strong>Please note</strong> the difference with the data below</p>
<p>I would like to apply <a href="https://stackoverflow.com/a/47443701/8071608">this solution</a>:</p>
<pre><code># list of data frames:
l = list(mtcars, mtcars)
# vector of column names I would like to extract
my_names = c("mpg", "wt", "am")
# these columns might be at different positions in the data frames
result = lapply(l, "[", , my_names)
</code></pre>
<p>But the data frames in my example are a level deeper. I am having some trouble adapting the above solution to my data.</p>
<p>How could I adapt the syntax to get the columns from a list of listed data frames</p>
| [
{
"answer_id": 74177733,
"author": "knittl",
"author_id": 112968,
"author_profile": "https://Stackoverflow.com/users/112968",
"pm_score": 2,
"selected": false,
"text": "Processor"
},
{
"answer_id": 74179633,
"author": "DuncG",
"author_id": 4712734,
"author_profile": "... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8071608/"
] |
74,177,710 | <p>The function:</p>
<pre><code>
def thefunction():
exec("x = 'text'")
return x
print(thefunction())
</code></pre>
<p>and it doesnt work...
this is for python 3</p>
| [
{
"answer_id": 74177736,
"author": "Joran Beasley",
"author_id": 541038,
"author_profile": "https://Stackoverflow.com/users/541038",
"pm_score": 0,
"selected": false,
"text": "def thefunction():\n my_locals = locals()\n exec(\"x = 'text'\",globals(),my_locals)\n return my_locals['x... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20293396/"
] |
74,177,715 | <p>As mentioned in the title I have an encoding issue in Excel. It requires special characters and also some letters.
I will show you an example: 1st being a good one and 2nd a bad one.
1st example
<a href="https://i.stack.imgur.com/6pxlk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6pxlk.jpg" alt="enter image description here" /></a></p>
<p>After I refresh the Excel workbook my special characters become something like the following.
2nd example
<a href="https://i.stack.imgur.com/fc019.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fc019.jpg" alt="enter image description here" /></a></p>
<p>Sadly my work around right now is, using one of my colleagues Mac, to go in and refresh the workbook again and the special characters get fixed.</p>
<p>These Excel workbooks are created by a Microsoft Power Automate flow, and checking every excel file he creates in order to fix this issue, is waste of time.</p>
<p>Does anyone have any suggestions about how to fix this.</p>
<p>Sincerely, Daniel</p>
| [
{
"answer_id": 74177736,
"author": "Joran Beasley",
"author_id": 541038,
"author_profile": "https://Stackoverflow.com/users/541038",
"pm_score": 0,
"selected": false,
"text": "def thefunction():\n my_locals = locals()\n exec(\"x = 'text'\",globals(),my_locals)\n return my_locals['x... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20018180/"
] |
74,177,729 | <p>While learning haskell with <a href="https://haskellbook.com/" rel="nofollow noreferrer">Haskell Programming from first principles</a> found an exercise that puzzles me.</p>
<p>Here is the short version:</p>
<pre><code>For the following definition:
a) i :: Num a => a
i = 1
b) Try replacing the type signature with the following:
i :: a
</code></pre>
<p>The replacement gives me an error:</p>
<pre><code>error:
• No instance for (Num a) arising from the literal ‘1’
Possible fix:
add (Num a) to the context of
the type signature for:
i' :: forall a. a
• In the expression: 1
In an equation for ‘i'’: i' = 1
|
38 | i' = 1
| ^
</code></pre>
<p>It is more or less clear for me how Num constraint arises.
What is not clear why assigning <code>1</code> to polymorphic variable <code>i'</code> gives the error.</p>
<p>Why this works:</p>
<pre><code>id 1
</code></pre>
<p>while this one doesn't:</p>
<pre><code>i' :: a
i' = 1
id i'
</code></pre>
<p>Should it be possible to assign a more specific value to a less specific and lose some type info if there are no issues?</p>
| [
{
"answer_id": 74179224,
"author": "leftaroundabout",
"author_id": 745903,
"author_profile": "https://Stackoverflow.com/users/745903",
"pm_score": 4,
"selected": true,
"text": "class Object {};\n\nclass Num: Object { public: Num add(...){...} };\n\nclass Int: Num { int i; ... };\n"
},
... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1641854/"
] |
74,177,754 | <p>last time I've gotten some help on making a website name generator. I feel bad but i'm stuck at the moment and I need some help again to improve it. in my code there's a <code>.txt</code> file called combined which included these lines.</p>
<p><a href="https://i.stack.imgur.com/8Qn8T.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8Qn8T.png" alt="Test Output" /></a></p>
<p>After that i created a variable to add to the domain</p>
<pre><code>web = 'web'
suffix = 'co.id'
</code></pre>
<p>And then i write it out so that the it would print the line output to the <code>Combined.txt</code></p>
<pre><code>output_count = 50
subdomain_count = 2
for i in range(output_count):
out = []
for j in range(subdomain_count):
out.append(random.choice(Test))
out.append(web)
out.append(suffix)
Example.write('.'.join(out)+"\n")
with open("dictionaries/examples.txt") as f:
websamples = [line.rstrip() for line in f]
</code></pre>
<p><a href="https://i.stack.imgur.com/btdWt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/btdWt.png" alt="Combined.txt" /></a></p>
<p>I want the output where instead of just <code>login.download.web.co.id</code> there would be more variety like <code>login-download.web.co.id</code> or <code>login.download-web.co.id</code> In the code i used <code>Example.write('.'.join(out)+"\n")</code> so that the<code>.</code> would be a separator for each characters. I was thinking of adding more, by making a similar code line and save it to a different <code>.txt</code> files but I feel like it would be too long. Is there a way where I can variate each character separation with this symbol <code>-</code> or <code>_</code> instead of just a <code>.</code> in the output?</p>
<p>Thanks!</p>
| [
{
"answer_id": 74177879,
"author": "Alpa",
"author_id": 20299137,
"author_profile": "https://Stackoverflow.com/users/20299137",
"pm_score": 0,
"selected": false,
"text": "import random\nseperators = ['-', '_', '.']\n\nExample.write(random.choice(seperators).join(out)+\"\\n\")\n"
},
{... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20183167/"
] |
74,177,794 | <p>The routing function was called in a <strong>service</strong>. I'm getting this warning:</p>
<pre><code>Navigation triggered outside Angular zone, did you forget to call 'ngZone.run()'?
</code></pre>
<p><strong>However I can not call <code>this.ngZone.run(...)</code> because I need the event when the routing was completed.</strong> By default <code>ngZone.run() => void</code> does not return any value.</p>
<p>The function looks like this:</p>
<pre><code>private handleRedirectRouting(): Observable<boolean> {
return this.route.queryParamMap.pipe(
switchMap((params) => {
if (params.get('_redirect')) {
const route = params.get('_redirect');
return from(this.router.navigate([route]));
} else if (this.router.url.includes('auth/login')) {
const route = '/';
return from(this.router.navigate([route]));
}
return of(true);
})
);
}
</code></pre>
<p>How can I resolve it?</p>
| [
{
"answer_id": 74177964,
"author": "btx",
"author_id": 4986557,
"author_profile": "https://Stackoverflow.com/users/4986557",
"pm_score": 0,
"selected": false,
"text": "this.ngZone.run<Observable<boolean>>(() => {\n return from(this.router.navigate([route]));\n})\n"
},
{
"answer... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4986557/"
] |
74,177,821 | <p>I have wrote this code in PHP to compile an XML file with parameters that are in URL.
But when the XML file is already created instead of adding the new data at the bottom of file inside the root element, overwrite it and delete all old data.
Where is the problem?</p>
<p>I have seen some examples online but I can't figure out how fix it.</p>
<p>I need to verify if file already exist and then add the element?</p>
<p>Or I need to read it and then add again the old elements and new?</p>
<p>I don't know very well dom so I can't figure out</p>
<pre><code><?php
$FOL = $_GET["FOL"];
$NUM = $_GET["NUM"];
$DAT = $_GET["DAT"];
$ZON = $_GET["ZON"];
$TIP = $_GET["TIP"];
$COM = $_GET["COM"];
$dom = new DOMDocument();
$dom->encoding = 'utf-8';
$dom->xmlVersion = '1.0';
$dom->formatOutput = true;
$xml_file_name = "$NUM.xml";
$xmlString = file_get_contents($xml_file_name);
$dom->loadXML($xmlString);
$loaded_xml = $dom->getElementsByTagName('Territorio');
$territorio_node = $dom->createElement('Territorio');
$child_node_NOM = $dom->createElement('NOM', "$NOM");
$territorio_node->appendChild($child_node_NOM);
$child_node_NUM = $dom->createElement('NUM', "$NUM");
$territorio_node->appendChild($child_node_NUM);
$child_node_DAT = $dom->createElement('DAT', "$DAT");
$territorio_node->appendChild($child_node_DAT);
$child_node_ZON = $dom->createElement('ZON', "$ZON");
$territorio_node->appendChild($child_node_ZON);
$dom->appendChild($territorio_node);
$child_node_TIP = $dom->createElement('TIP', "$TIP");
$territorio_node->appendChild($child_node_TIP);
$child_node_COM = $dom->createElement('COM', "$COM");
$territorio_node->appendChild($child_node_COM);
$dom->appendChild($territorio_node);
$dom->save($FOL.'/'.$xml_file_name);
echo "$xml_file_name creato correttamente";
?>
</code></pre>
| [
{
"answer_id": 74177964,
"author": "btx",
"author_id": 4986557,
"author_profile": "https://Stackoverflow.com/users/4986557",
"pm_score": 0,
"selected": false,
"text": "this.ngZone.run<Observable<boolean>>(() => {\n return from(this.router.navigate([route]));\n})\n"
},
{
"answer... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6634742/"
] |
74,177,877 | <p>I've got a class Student with constructor for name of student.
I want to easily generate an array of all students with names 'Student 1', Student 2', ...</p>
<p>I was thinking two for loops:</p>
<pre><code> function generateNames (studentAmount) {
for (let i = 0; i < studentAmount; i++) {
generateNicknames.push('Student' + [i + 1])
}
return generateNicknames
}
let allStudents = []
function generateStudents(arrayOfNames) {
for (let j = 0; j < arrayOfNnames.length; j++) {
allStudents.push(new Student(arrayOfNames[j]))
}
return allStudents
}
</code></pre>
<p>The first one generates an array with ['Student 1', 'Student 2', ] etc. But the second one only generates '[Student, Student, Student...]</p>
<p>Any suggestions?</p>
| [
{
"answer_id": 74177964,
"author": "btx",
"author_id": 4986557,
"author_profile": "https://Stackoverflow.com/users/4986557",
"pm_score": 0,
"selected": false,
"text": "this.ngZone.run<Observable<boolean>>(() => {\n return from(this.router.navigate([route]));\n})\n"
},
{
"answer... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18575114/"
] |
74,177,881 | <p>I am reading data from sensor over time and I need to check whether it is trending upwards. I know how to do that, but sensor at some point reaches max value and starts over and I need to be able to ignore this rollover. How to correctly deal with this so that I correctly find the data trend, but also correctly deal with the overflow at the same time. Examples of data that I could receive include (overflows at 255):</p>
<pre><code>data = [191, 198, 204, 217, 230, 241, 255, 17, 32, 67, 90, 117]
</code></pre>
<pre><code>data = [113, 182, 201, 9, 74, 91, 148, 182, 231, 41, 72, 100]
</code></pre>
| [
{
"answer_id": 74177964,
"author": "btx",
"author_id": 4986557,
"author_profile": "https://Stackoverflow.com/users/4986557",
"pm_score": 0,
"selected": false,
"text": "this.ngZone.run<Observable<boolean>>(() => {\n return from(this.router.navigate([route]));\n})\n"
},
{
"answer... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9085936/"
] |
74,177,883 | <p>I'm trying to encrypt binary data with AES in .Net 6.0. Unfortunately, the decryption does not bring back the original data:</p>
<pre><code>public static byte[] Encrypt(byte[] plainBytes)
{
using (var aes = System.Security.Cryptography.Aes.Create())
{
byte[] cipherBytes;
using (MemoryStream cipherStream = new MemoryStream())
using (CryptoStream cryptoStream = new CryptoStream(cipherStream, aes.CreateEncryptor(aes.Key, aes.IV), CryptoStreamMode.Write))
{
cryptoStream.Write(plainBytes, 0, plainBytes.Length);
cryptoStream.FlushFinalBlock();
cipherStream.Seek(0, SeekOrigin.Begin);
cipherBytes = new byte[cipherStream.Length];
cipherStream.Read(cipherBytes, 0, cipherBytes.Length);
}
byte[] wrongPlainBytes;
using (MemoryStream cipherStream = new MemoryStream(cipherBytes))
using (CryptoStream cryptoStream = new CryptoStream(cipherStream, aes.CreateDecryptor(aes.Key, aes.IV), CryptoStreamMode.Read))
{
wrongPlainBytes = cipherStream.ToArray();
}
bool shouldBeTrue = plainBytes.Equals(wrongPlainBytes);
return cipherBytes;
}
}
</code></pre>
<p>After executing this code, <code>shouldBeTrue</code> should be <code>true</code>, but it's <code>false</code>. Also, <code>plainBytes.Length</code> is different from <code>wrongPlainBytes.Length</code>.</p>
<p><strong>What do I wrong while encryption / decryption?</strong></p>
| [
{
"answer_id": 74178412,
"author": "Evk",
"author_id": 5311735,
"author_profile": "https://Stackoverflow.com/users/5311735",
"pm_score": 1,
"selected": false,
"text": "Read"
},
{
"answer_id": 74178453,
"author": "mkmkmk",
"author_id": 20154538,
"author_profile": "http... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20138168/"
] |
74,177,888 | <p>I'm trying to rewrite the <code>List.length</code> function without using recursion. Here's my code:</p>
<pre><code>(* given *)
type 'a list =
| []
| (::) of 'a * 'a list
let nil : 'a list = []
let cons (hd : 'a) (tl : 'a list): 'a list = hd :: tl
let length (ls : 'a list): int =
let i = fold_left(fun x y -> Fun.const 1 :: y) [] ls in
fold_left(fun x y -> x + y) 0 i
</code></pre>
<p>OCaml gave me an error on the last line <code>fold_left(fun x y -> x + y) 0 i</code> and saying my <code>i</code> here has <code>type ('a -> int) list</code> but an expression was expected of <code>type int list</code>, is there any way I can fix this? Thank you!</p>
| [
{
"answer_id": 74177999,
"author": "jthulhu",
"author_id": 5956261,
"author_profile": "https://Stackoverflow.com/users/5956261",
"pm_score": 3,
"selected": true,
"text": "Fun.const"
},
{
"answer_id": 74184445,
"author": "Chris",
"author_id": 15261315,
"author_profile"... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20154064/"
] |
74,177,889 | <p>I have this code that should show a counter while a background task is running:</p>
<pre><code>@Composable fun startIt() {
val scope = rememberCoroutineScope()
val running = remember { mutableStateOf(false) }
Button({ scope.launch { task(running) } }) {
Text("start")
}
if (running.value) Counter()
}
@Composable private fun Counter() {
val count = remember { mutableStateOf(0) }
LaunchedEffect(Unit) {
while (true) {
delay(100.milliseconds)
count.value += 1
}
}
Text(count.toString())
}
private suspend fun task(running: MutableState<Boolean>) {
running.value = true
coroutineScope {
launch {
// some code that blocks this thread
}
}
running.value = false
}
</code></pre>
<p>If I understand correctly, the <code>coroutineScope</code> block in <code>task</code> should unblock the main thread, so that the <code>LaunchedEffect</code> in <code>Counter</code> can run. But that block never gets past the first <code>delay</code>, and never returns or gets cancelled. The counter keeps showing 0 until the task finishes.</p>
<p>How do I allow Compose to update the UI properly?</p>
| [
{
"answer_id": 74181867,
"author": "Tenfour04",
"author_id": 506796,
"author_profile": "https://Stackoverflow.com/users/506796",
"pm_score": 0,
"selected": false,
"text": "coroutineScope"
},
{
"answer_id": 74185519,
"author": "Benjamin Charais",
"author_id": 7729375,
... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8681/"
] |
74,177,895 | <p>So I want to change the value attribute of this dropdown option in the select form using JS DOM.</p>
<pre><code><select name="Party">
<option id="partyreg" value="Party">Party</option>
</select>
</code></pre>
<p>However this doesn't seem to work:</p>
<pre><code>document.getElementById("partyreg").value = partyCode;
</code></pre>
<p>Any ideas?</p>
| [
{
"answer_id": 74177942,
"author": "KIKO Software",
"author_id": 3986005,
"author_profile": "https://Stackoverflow.com/users/3986005",
"pm_score": 0,
"selected": false,
"text": "partyCode"
},
{
"answer_id": 74178018,
"author": "DSDmark",
"author_id": 16517581,
"author... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74177895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9622736/"
] |
74,178,005 | <p>I'm working on PN5180 module to read data from my ePassport (ICAO 9303). I can send RATS - ATS, PPS, so technically, now i can exchange data using APDU command. Firstly, i tried to select LDS1 but however i tried, i always get SW1 SW2 = 0x67 0x00, which means "Wrong length".</p>
<p>Here my code trace:</p>
<p>RATS: 0xE0 0x80</p>
<p>ATS: 0E 78 77 D4 03 4D 4B 6A 43 4F 53 2D 33 37</p>
<p>PPS: 0xD0 0x11 0x00</p>
<p>PPS_resp: 0xD0</p>
<p>APDU_SELECT: 0x0A 0x00 0x00 0x00 0xA4 0x04 0x0C 0x07 0xA0 0x00 0x00 0x02 0x47 0x10 0x01</p>
<p>APDU_SELECT_resp: 0x0A 0x00 0x67 0x00</p>
<p>So maybe my INF in APDU_SELECT is incorrect, but the problem is i have used PN532 to communicate, i could read my ePassport with the same INF (using InlistPassiveTarget and InDataExchange).</p>
<p>If anyone see this post and worked with PN5180 or smart card before, pls let me know.</p>
| [
{
"answer_id": 74187713,
"author": "Maarten Bodewes",
"author_id": 589259,
"author_profile": "https://Stackoverflow.com/users/589259",
"pm_score": 0,
"selected": false,
"text": "1110"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19749918/"
] |
74,178,014 | <p>html looks like:</p>
<pre><code><div class='a'>
<p class='subA'><p>
<p class='subA'><p>
</div>
<div class='b'>
<p class='subA'><p>
<p class='subA'><p>
<div>
</code></pre>
<p>how to remove .subA::after styles for only div with class 'a'?</p>
| [
{
"answer_id": 74178107,
"author": "Mina",
"author_id": 11887902,
"author_profile": "https://Stackoverflow.com/users/11887902",
"pm_score": -1,
"selected": true,
"text": "subA"
},
{
"answer_id": 74178130,
"author": "Quentin",
"author_id": 19068,
"author_profile": "htt... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18671377/"
] |
74,178,016 | <pre><code>expenses = [
('Dinner', 80),
('Car repair', 120),
('csgo skins', 200)
]
# Version with for-loop
sum = 0
for expense in expenses:
sum += expense[1]
print(sum)
# Version using lambda+reduce
sum2 = reduce((lambda a, b: a[1] + b[1]), expenses)
print(sum2)
</code></pre>
<p>I'm trying to obtain, with <code>lambda</code> and <code>reduce</code>, the same result that I had with the for-loop version.</p>
<p>If the <code>expenses</code> list contains only 2 items, everything works fine, but if I add more I get this error:</p>
<pre><code>Traceback (most recent call last):
File "r:\Developing\_Python\lambda_map_filter_reduce.py", line 44, in <module>
sum2 = reduce((lambda a, b: a[1] + b[1]), expenses)
File "r:\Developing\_Python\lambda_map_filter_reduce.py", line 44, in <lambda>
sum2 = reduce((lambda a, b: a[1] + b[1]), expenses)
TypeError: 'int' object is not subscriptable
</code></pre>
<p>What is the correct way of doing this?</p>
| [
{
"answer_id": 74178107,
"author": "Mina",
"author_id": 11887902,
"author_profile": "https://Stackoverflow.com/users/11887902",
"pm_score": -1,
"selected": true,
"text": "subA"
},
{
"answer_id": 74178130,
"author": "Quentin",
"author_id": 19068,
"author_profile": "htt... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178016",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18556190/"
] |
74,178,057 | <p>Hello I want to show how I will change the text style of this in the list of strings
١۷ع in last line</p>
<p>static final List Fatiha = [
'اَلْحَمْدُ لِلّٰهِ رَبِّ الْعٰلَمِیْنَۙ۱',
'الرَّحْمٰنِ الرَّحِیْمِۙ۲',
'مٰلِكِ یَوْمِ الدِّیْنِؕ۳',
'اِیَّاكَ نَعْبُدُ وَ اِیَّاكَ نَسْتَعِیْنُؕ۴',
'اِهْدِنَا الصِّرَاطَ الْمُسْتَقِیْمَۙ۵',
'صِرَاطَ الَّذِیْنَ اَنْعَمْتَ عَلَیْهِمْ ۙ۬ۦ',
'غَیْرِ الْمَغْضُوْبِ عَلَیْهِمْ وَ لَا الضَّآلِّیْنَ۠١۷ع'
];</p>
| [
{
"answer_id": 74178107,
"author": "Mina",
"author_id": 11887902,
"author_profile": "https://Stackoverflow.com/users/11887902",
"pm_score": -1,
"selected": true,
"text": "subA"
},
{
"answer_id": 74178130,
"author": "Quentin",
"author_id": 19068,
"author_profile": "htt... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17579670/"
] |
74,178,095 | <p>I want to make a grouping function, that could be reusable by many others.
Here is a concrete example :</p>
<p>I made a function to group by <code>Numero</code></p>
<pre><code>public static List<Meb> GroupByNumber(this List<Meb> listMeb)
{
return listMeb.GroupBy(x => new { x.Numero })
.Select(cl => new Meb
{
ID = -1,
IdUser = cl.First().IdUser,
Barre = cl.First().Barre,
CNC = cl.First().CNC,
// ... and so long
}).OrderBy(x => x.Numero).ThenBy(x => x.Avancement).ToList();
}
</code></pre>
<p>Then another grouping by <code>CNC</code></p>
<pre><code>public static List<Meb> GroupByCNC(this List<Meb> listMeb)
{
return listMeb.GroupBy(x => new { x.CNC })
.Select(cl => new Meb
{
ID = -1,
IdUser = cl.First().IdUser,
Barre = cl.First().Barre,
CNC = cl.First().CNC,
// ... and so long
}).OrderBy(x => x.Numero).ThenBy(x => x.Avancement).ToList();
}
</code></pre>
<p>The problem is in the group function, I have a lot of attributes following (around 40).
So, when I want to change the way I want to make grouping (evolution of code), I need to do it in each GroupBy function. (I also can have many sometimes).</p>
<p>So, I'm looking a way I could write the function only once, then call it changing only the <code>GroupBy(x => new { x.Numero })</code> part.</p>
| [
{
"answer_id": 74178107,
"author": "Mina",
"author_id": 11887902,
"author_profile": "https://Stackoverflow.com/users/11887902",
"pm_score": -1,
"selected": true,
"text": "subA"
},
{
"answer_id": 74178130,
"author": "Quentin",
"author_id": 19068,
"author_profile": "htt... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7310000/"
] |
74,178,109 | <p>I have several divs, which I'm not going to put in v-for, but still need to unique reference them. For @click id attribute works well.</p>
<pre><code><div v-bind:class="setAreaStyle('CAR')" @click="setFocus($event)" id="CAR">
</code></pre>
<p>But is there a way I can use element id, <strong>without click event</strong>, as reference in called function, so setAreaStyle would received 'CAR' as argument?</p>
<pre><code><div v-bind:class="setAreaStyle(id)" id="CAR">
</code></pre>
| [
{
"answer_id": 74178580,
"author": "Guillaume",
"author_id": 4348019,
"author_profile": "https://Stackoverflow.com/users/4348019",
"pm_score": 0,
"selected": false,
"text": "id"
},
{
"answer_id": 74178642,
"author": "Cerceis",
"author_id": 10828081,
"author_profile": ... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1291543/"
] |
74,178,150 | <p>How can I flatten the last layer of a nested list?</p>
<pre><code>lista = [['a'],['b']]
listb = [['c']]
nested = [lista, listb]
# [[['a'], ['b']], [['c']]]
# how to get [['a', 'b'], ['c']]?
[[x for x in y] for y in nested]
# gives [[['a'], ['b']], [['c']]]
</code></pre>
<p>I tried with unpacking but it is disallowed in list comprehension.</p>
<p>For more context, the reason the last elements are always 1-element list is that I get this result by using:</p>
<pre><code>[myfunc(x) for x in y for y in other_nested_list]
</code></pre>
| [
{
"answer_id": 74178170,
"author": "PangolinPaws",
"author_id": 12825882,
"author_profile": "https://Stackoverflow.com/users/12825882",
"pm_score": 1,
"selected": false,
"text": "+"
},
{
"answer_id": 74178178,
"author": "Dmitriy Neledva",
"author_id": 16786350,
"autho... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5224236/"
] |
74,178,151 | <p>So i have a function, which returns a combination of strings (multiple values). I need to extract everything that is followed by char "DL:". But only that.</p>
<p>So before extraction:</p>
<pre><code>**pck_import.GETdocnumber(XML_DATA)**
________________________________________
DL:2212200090001 Pr:8222046017
________________________________________
Obj:020220215541 DL:1099089729
________________________________________
DL:DST22017260
________________________________________
DL:22122000123964 Pr:8222062485
________________________________________
DL:22122000108599
________________________________________
Obj:0202200015539 DL:2100001688
</code></pre>
<p>In every case, i'll need the "number" after char "DL:". The "DL:" can be alone, can be at first place (between multiple values), also can be the last string. Also in some cases, the "DL:" value contains char, too.</p>
<p>So, output:</p>
<pre><code>**OUTPUT**
______________
2212200090001
______________
1099089729
______________
DST22017260
______________
22122000123964
______________
22122000108599
______________
2100001688
</code></pre>
<p>I tried:</p>
<pre><code>substr(pck_import.GETdocnumber(XML_DATA),
instr(pck_import.GETdocnumber(XML_DATA),
'DL:') + 3))
</code></pre>
<p>That returns "Pr:", too.</p>
| [
{
"answer_id": 74178320,
"author": "Littlefoot",
"author_id": 9097906,
"author_profile": "https://Stackoverflow.com/users/9097906",
"pm_score": 2,
"selected": false,
"text": "SQL> with test (col) as\n 2 (select\n 3 '________________________________________\n 4 DL:2212200090001 Pr... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17389935/"
] |
74,178,164 | <p>Is there a good way to do display a maintenance page when visiting any route of my SvelteKit website?</p>
<p>My app is hosted on Vercel, for those who want to know.</p>
<p>What I've tried so far:</p>
<ul>
<li>Set an environment variable called <code>MAINTENANCE_MODE</code> with a value <code>1</code> in Vercel.</li>
<li>For development purposes I've set this in my .env file to <code>VITE_MAINTENANCE_MODE</code> and called with <code>import.meta.env.VITE_MAINTENANCE_MODE</code>.</li>
</ul>
<p>Then inside <code>+layout.server.js</code> I have the following code to redirect to <code>/maintenance</code> route</p>
<pre class="lang-js prettyprint-override"><code>import { redirect } from "@sveltejs/kit";
export async function load({ url }) {
const { pathname } = url;
// Replace import.meta.env.VITE_MAINTENANCE_MODE with process.env.MAINTENANCE_MODE in Production
if (import.meta.env.VITE_MAINTENANCE_MODE == 1) {
if (pathname == "/maintenance") return;
throw redirect(307, "/maintenance");
} else {
if (pathname == "/maintenance") {
throw redirect(307, "/");
};
};
};
</code></pre>
<p>What I've also tried is just throwing an <code>error</code> in <code>+layout.server.js</code> with the following:</p>
<pre class="lang-js prettyprint-override"><code>import { error } from "@sveltejs/kit";
export async function load() {
if (import.meta.env.VITE_MAINTENANCE_MODE == 1) {
throw error(503, "Scheduled for maintenance");
};
};
</code></pre>
<p>However this just uses SvelteKit's static fallback error page and not <code>+error.svelte</code>. I've tried creating <code>src/error.html</code> in the hope to create a custom error page for <code>+layout.svelte</code> but couldn't get it to work.
I would like to use a custom page to display "Down for maintenance", but I don't want to create an endpoint for every route in my app to check if the <code>MAINTENANCE_MODE</code> is set to 1.</p>
<p>Any help is appreciated</p>
| [
{
"answer_id": 74179267,
"author": "H.B.",
"author_id": 546730,
"author_profile": "https://Stackoverflow.com/users/546730",
"pm_score": 3,
"selected": true,
"text": "handle"
},
{
"answer_id": 74181717,
"author": "Mikko Ohtamaa",
"author_id": 315168,
"author_profile": ... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178164",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9649723/"
] |
74,178,190 | <p>I have a query that selects some data that I would like to use to create an incremental table. Something like:</p>
<pre><code>{{
config(
materialized='incremental',
unique_key='customer_id'
)
}}
SELECT
customer_id,
email,
updated_at,
first_name,
last_name
FROM data
</code></pre>
<p>The input data has duplicate customers in it. If I read the documentation correctly, then records with the same unique_key should be seen as the same record. They should be updated instead of creating duplicates in the final table. However, I am seeing duplicates in the final table instead. What am I doing wrong?</p>
<p>I am using Snowflake as a datawarehouse.</p>
| [
{
"answer_id": 74179267,
"author": "H.B.",
"author_id": 546730,
"author_profile": "https://Stackoverflow.com/users/546730",
"pm_score": 3,
"selected": true,
"text": "handle"
},
{
"answer_id": 74181717,
"author": "Mikko Ohtamaa",
"author_id": 315168,
"author_profile": ... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20319858/"
] |
74,178,211 | <p>How can I convert the <code>hexstring</code> into the form of <code>hexint</code> below?</p>
<pre><code>string hexstring = "0x67";
int hexint = 0x67;
</code></pre>
| [
{
"answer_id": 74179267,
"author": "H.B.",
"author_id": 546730,
"author_profile": "https://Stackoverflow.com/users/546730",
"pm_score": 3,
"selected": true,
"text": "handle"
},
{
"answer_id": 74181717,
"author": "Mikko Ohtamaa",
"author_id": 315168,
"author_profile": ... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7434294/"
] |
74,178,231 | <p>while applying class to div it is working but in case of span tag it shows absurd result
the class attribute is working good in case of div tag</p>
<pre><code><html>
<head>
<style>
.city {
background-color: tomato;
color: black;
border: 2px solid black;
margin: 20px;
padding: 20px;
}
</style>
</head>
<body>
<div class="city">
<h2>London</h2>
<p>London is the capital of England.</p>
</div>
<div class="city">
<h2>Paris</h2>
<p>Paris is the capital of France.</p>
</div>
<div class="city">
<h2>Tokyo</h2>
<p>Tokyo is the capital of Japan.</p>
</div>
<span class="city">
<h2>London</h2>
<p>London is the capital of England.</p>
</span>
</body>
</html>
</code></pre>
<p>output: <a href="https://i.stack.imgur.com/yYlcJ.png" rel="nofollow noreferrer">the output of the code is give below in the image attached to link</a></p>
| [
{
"answer_id": 74178341,
"author": "Andrei Fedorov",
"author_id": 6641198,
"author_profile": "https://Stackoverflow.com/users/6641198",
"pm_score": 0,
"selected": false,
"text": ".city {\n background-color: tomato;\n color: black;\n border: 2px solid black;\n margin: 20px;\n padding... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20319929/"
] |
74,178,242 | <p>I have a dataset like this (df)</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>Community</th>
<th>Time</th>
<th>BIP</th>
<th>EXP</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>1</td>
<td>BF</td>
<td>12000</td>
<td>500</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>DF</td>
<td>NA</td>
<td>NA</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>AF</td>
<td>8000</td>
<td>NA</td>
</tr>
<tr>
<td>2</td>
<td>1</td>
<td>BF</td>
<td>13000</td>
<td>300</td>
</tr>
<tr>
<td>2</td>
<td>1</td>
<td>DF</td>
<td>12000</td>
<td>200</td>
</tr>
<tr>
<td>2</td>
<td>1</td>
<td>AF</td>
<td>11000</td>
<td>120</td>
</tr>
</tbody>
</table>
</div>
<p>This df has 40'000 observations. I would like to find out which of these situation in the time column (BF= Before financial crisis; DF = during finance crisis; AF= After Finance Crisis) has the most missing data in all the columns BIP and EXP?</p>
<p>I gave the following code to find out how many missing data are in BIP and EXP</p>
<pre><code>sapply(df, function(x) sum(is.na(x)))
</code></pre>
<p>It shows that BIP has 55 missing data and EXP has 34 missing data. But no information for the time situation.</p>
<p>Could someone please help?</p>
| [
{
"answer_id": 74178259,
"author": "Maël",
"author_id": 13460602,
"author_profile": "https://Stackoverflow.com/users/13460602",
"pm_score": 2,
"selected": true,
"text": "aggregate"
},
{
"answer_id": 74183624,
"author": "akrun",
"author_id": 3732271,
"author_profile": ... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,178,248 | <p>I have some Maple code below that I'm trying to convert to Sage (which is some kind of Python) code.</p>
<p>This is the Maple code</p>
<pre><code>restart:
m:=15:
a:=array(1..m):
eqn:=array(1..m):
expr:=sum(a['i']*u^('i'-1),'i'=1..m)-
product((1-u^'i')^(-a['i']),'i'=1..m):
for i from 1 to m do eqn[i]:=coeff(series(expr,u=0,m+2),u,i-1);
od:
sols:=solve({seq(eqn[i],i=1..m)},{seq(a[i],i=1..m)}):
assign(sols):
print(a);
</code></pre>
<p>This is the output for this code:</p>
<pre><code>[1, 1, 2, 4, 9, 20, 48, 115, 286, 719, 1842, 4766, 12486, 32973, 87811]
</code></pre>
<p>This is the Sage code I have already:</p>
<pre><code>u = var('u')
m = 15
a = [var(f"a_{i}") for i in range(1,m+1)]
eqn = [var(f"e_{i}") for i in range(1,m+1)]
expr = sum(a[i]*u^(i-1) for i in range(1,m)) - product((1-u^i)^(-a[i]) for i in range(1,m))
print(expr)
for i in range(0,m):
# eqn[i] = taylor(expr,u,0,m+2).coefficients(sparse=False)[i]
</code></pre>
<p>When I uncomment the code in the for-loop, I get <code>IndexError: list index out of range</code>.</p>
<p>I tried the CodeGeneration tool:</p>
<pre><code>CodeGeneration:-Python(i -> coeff(series(expr, u = 0, m + 2), u, i - 1), output = embed);
CodeGeneration:-Python(sols -> assign(sols), output = embed);
</code></pre>
<p>This however gives me</p>
<pre><code>Warning, the function names {coeff, series} are not recognized in the target language
Warning, the function names {assign} are not recognized in the target language
</code></pre>
<p>And it gives as output thus no useful code, since coeff and series don't exist:</p>
<pre><code>cg0 = lambda i: coeff(series(expr, u == 0, m + 2), u, i - 1)
cg2 = lambda sols: assign(sols)
</code></pre>
<p>The question is now: what are the equivalent expressions for <code>coeff</code>, <code>series</code> and <code>assign</code>?</p>
| [
{
"answer_id": 74178451,
"author": "Dronakuul",
"author_id": 19953747,
"author_profile": "https://Stackoverflow.com/users/19953747",
"pm_score": 0,
"selected": false,
"text": "Traceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nNameError: name 'var' is not define... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13085223/"
] |
74,178,283 | <p><em>I'm trying to run this program but it is showing me "Thread 0 has 0 prime numbers" in the console followed by "Killed" after 5 minutes. Moreover, it is very slow. Please help me develop and correct this code.</em></p>
<pre><code>import time
Nthreads=4
maxNumber=3000000
starting_range=0
ending_range=0
division=0
lst=[]
def prime(x, y):
prime_list = []
for i in range(x, y):
if i == 0 or i == 1:
continue
else:
for j in range(2, int(i/2)+1):
if i % j == 0:
break
else:
prime_list.append(i)
return prime_list
def func_thread(x, y):
out.append(prime(x, y))
thread_list = []
results = len(lst)
for i in range(Nthreads):
devision=maxNumber//Nthreads
starting_range = (i-1)*division+1
ending_range = i*devision
lst = prime(starting_range, ending_range)
print(" Thread ", i, " has ", len(lst), " prime numbers." )
thread = threading.Thread(target=func_thread, args=(i, results))
thread_list.append(thread)
for thread in thread_list:
thread.start()
for thread in thread_list:
thread.join()```
</code></pre>
| [
{
"answer_id": 74178451,
"author": "Dronakuul",
"author_id": 19953747,
"author_profile": "https://Stackoverflow.com/users/19953747",
"pm_score": 0,
"selected": false,
"text": "Traceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nNameError: name 'var' is not define... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178283",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20319856/"
] |
74,178,308 | <p>I have created a middleware in laravel! like below</p>
<pre><code><?php
namespace App\Http\Middleware;
use Carbon\Carbon;
use Closure;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Log;
use phpDocumentor\Reflection\Types\String_;
class SystemActivityLogger
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return Response|RedirectResponse
*/
public function handle(Request $request, Closure $next)
{
Log::channel('rabbitmq_elk')->info($this->prepareLogData($request));
return $next($request);
}
/**
* Prepare log data and log it
* @param Request $request
* @return string
*/
private function prepareLogData(Request $request)
{
return json_encode([
'ip' => $request->ip(),
'url' => $request->url(),
'agent' => $request->userAgent(),
'date' => Carbon::now()->toDateTimeString(),
'params' => $request->query(),
]);
}
}
</code></pre>
<p>this middleware is for logging and I want that <code>prepareLogData()</code> returned json type and i can search it in kibana discover with KQL syntax
this is my <code>sdamiii.conf</code> file</p>
<pre><code>input {
rabbitmq {
host => "localhost"
port => 5672
heartbeat => 30
queue => "system_logs"
durable => "true"
user => "guest"
password => "guest"
vhost => "/"
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "my-index-000001"
data_stream => "false"
}
}
</code></pre>
<p>After running <code>bin/logstash -f conf.d/sdamiii.conf</code> command and requesting Laravel, I get this output in Kiabana.</p>
<p><a href="https://i.stack.imgur.com/uLeFD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uLeFD.png" alt="enter image description here" /></a></p>
<p>but I do not search by KQL syntax for example i want search <code>message.ip</code> I do not receive<br />
any results
How can I solve this problem???</p>
| [
{
"answer_id": 74178451,
"author": "Dronakuul",
"author_id": 19953747,
"author_profile": "https://Stackoverflow.com/users/19953747",
"pm_score": 0,
"selected": false,
"text": "Traceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nNameError: name 'var' is not define... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19200854/"
] |
74,178,311 | <p>I want learn Non-matric multidimensional scale, I have these data downloaded from <a href="https://cougrstats.wordpress.com/2019/12/11/non-metric-multidimensional-scaling-nmds-in-r/" rel="nofollow noreferrer">https://cougrstats.wordpress.com/2019/12/11/non-metric-multidimensional-scaling-nmds-in-r/</a>
data are</p>
<pre><code>library(vegan)
dput(orders)
structure(list(Amphipoda = c(0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 2L, 0L, 0L, 39L, 0L, 0L, 0L, 0L, 0L,
8L, 10L, 52L, 11L, 51L, 14L, 96L, 7L, 93L, 0L, 29L, 4L, 0L, 0L,
0L, 0L, 0L, 0L, 4L, 0L, 0L, 0L, 36L, 10L, 5L, 15L, 14L, 3L, 11L,
6L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L,
0L, 0L, 0L, 2L, 4L, 4L, 3L, 4L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 3L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L,
5L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 54L, 51L, 47L, 212L,
26L, 51L, 0L, 0L, 4L, 0L, 0L, 0L, 4L, 6L, 14L, 34L, 8L, 284L,
1L, 2L, 6L, 92L, 134L, 98L, 38L, 8L, 116L, 0L, 0L, 8L, 264L,
104L, 114L, 138L, 152L, 42L, 46L, 10L, 67L, 25L, 0L, 0L, 1L,
12L, 0L, 26L, 0L, 67L, 456L, 7L, 2L, 46L, 155L, 82L, 124L, 596L,
0L, 36L, 1L, 1L, 588L, 0L, 0L, 16L, 0L, 0L, 470L, 0L, 6L, 262L,
2L, 476L, 0L, 6L, 14L, 0L, 342L, 0L, 6L, 4L, 24L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 0L, 6L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 74L, 170L, 37L, 228L, 144L, 21L, 189L, 117L, 45L, 132L, 108L,
35L, 0L, 0L, 0L, 0L, 0L, 0L), Coleoptera = c(42L, 5L, 7L, 14L,
2L, 43L, 7L, 2L, 15L, 5L, 6L, 23L, 25L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 1L, 0L, 0L, 2L, 0L, 1L, 0L, 0L, 0L, 142L, 96L, 202L, 306L,
917L, 748L, 139L, 148L, 115L, 216L, 0L, 0L, 1L, 0L, 0L, 0L, 0L,
0L, 12L, 36L, 48L, 30L, 10L, 12L, 11L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 3L, 0L, 0L, 0L,
0L, 0L, 381L, 397L, 229L, 51L, 266L, 102L, 201L, 189L, 80L, 292L,
271L, 583L, 641L, 318L, 729L, 520L, 582L, 262L, 59L, 209L, 134L,
139L, 108L, 79L, 99L, 96L, 13L, 60L, 22L, 15L, 27L, 1L, 11L,
2L, 3L, 3L, 6L, 1L, 1L, 0L, 20L, 48L, 129L, 82L, 16L, 70L, 114L,
77L, 190L, 27L, 163L, 125L, 244L, 43L, 70L, 88L, 202L, 52L, 39L,
70L, 10L, 5L, 26L, 108L, 37L, 38L, 81L, 5L, 52L, 14L, 33L, 0L,
26L, 12L, 41L, 3L, 5L, 15L, 1L, 10L, 18L, 31L, 40L, 22L, 23L,
21L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 4L, 17L, 7L, 59L, 21L, 0L, 84L,
41L, 95L, 83L, 52L, 100L, 90L, 34L, 31L, 19L, 27L, 51L, 62L,
7L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L,
0L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 4L, 6L, 0L, 0L, 0L, 2L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 6L, 0L, 6L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L,
0L, 2L, 2L, 0L, 0L, 0L, 0L, 0L, 4L, 0L, 0L, 29L, 68L, 119L, 156L,
114L, 73L, 81L, 115L, 5L, 0L, 2L, 0L, 0L, 0L, 0L, 0L, 0L, 1L,
0L, 4L, 131L, 135L, 102L, 219L, 165L, 207L, 149L, 105L, 147L,
195L, 332L, 316L, 22L, 55L, 17L, 12L, 50L, 49L), Diptera = c(210L,
54L, 336L, 80L, 210L, 647L, 171L, 948L, 1495L, 751L, 877L, 912L,
1130L, 170L, 105L, 72L, 26L, 190L, 138L, 91L, 46L, 96L, 39L,
49L, 66L, 87L, 82L, 69L, 29L, 548L, 1240L, 810L, 999L, 521L,
784L, 504L, 800L, 1190L, 360L, 539L, 331L, 742L, 1041L, 742L,
154L, 787L, 479L, 411L, 1181L, 1350L, 1423L, 747L, 1827L, 1758L,
2L, 172L, 1L, 278L, 145L, 250L, 121L, 294L, 121L, 219L, 254L,
278L, 305L, 269L, 212L, 248L, 229L, 229L, 225L, 311L, 236L, 209L,
257L, 226L, 655L, 440L, 416L, 39L, 398L, 323L, 461L, 670L, 934L,
401L, 686L, 619L, 1043L, 1578L, 767L, 432L, 1754L, 1228L, 2164L,
585L, 1336L, 933L, 928L, 454L, 833L, 928L, 745L, 604L, 69L, 1052L,
1228L, 15L, 1835L, 1459L, 1408L, 170L, 1367L, 146L, 14L, 164L,
101L, 780L, 779L, 259L, 537L, 576L, 480L, 1076L, 577L, 119L,
58L, 853L, 529L, 724L, 1329L, 381L, 194L, 428L, 1240L, 1349L,
29L, 42L, 249L, 881L, 1122L, 456L, 837L, 162L, 751L, 281L, 421L,
36L, 803L, 553L, 562L, 1769L, 151L, 1019L, 34L, 158L, 736L, 472L,
254L, 666L, 853L, 1175L, 795L, 1627L, 1229L, 960L, 1659L, 1719L,
713L, 0L, 5L, 216L, 199L, 335L, 64L, 466L, 98L, 1385L, 1162L,
1545L, 1457L, 1215L, 614L, 1247L, 1697L, 620L, 895L, 1297L, 902L,
12L, 264L, 76L, 4L, 2L, 36L, 44L, 2L, 326L, 6L, 66L, 9L, 70L,
13L, 2L, 8L, 0L, 0L, 11L, 42L, 2L, 2L, 4L, 2L, 70L, 4L, 120L,
138L, 126L, 14L, 1L, 93L, 10L, 40L, 3L, 15L, 186L, 54L, 304L,
12L, 34L, 34L, 8L, 296L, 80L, 50L, 36L, 0L, 0L, 10L, 40L, 4L,
0L, 0L, 98L, 68L, 2L, 0L, 7L, 8L, 6L, 186L, 148L, 0L, 6L, 14L,
106L, 0L, 0L, 2L, 2L, 62L, 4L, 4L, 318L, 742L, 1099L, 298L, 553L,
867L, 716L, 556L, 91L, 154L, 89L, 16L, 114L, 21L, 49L, 130L,
46L, 94L, 58L, 349L, 967L, 828L, 857L, 765L, 847L, 459L, 725L,
731L, 409L, 432L, 805L, 565L, 967L, 953L, 1398L, 999L, 1081L,
1104L), Ephemeroptera = c(27L, 9L, 2L, 1L, 0L, 38L, 11L, 4L,
234L, 3L, 1L, 218L, 44L, 0L, 0L, 0L, 0L, 1L, 8L, 1L, 2L, 3L,
23L, 5L, 7L, 6L, 8L, 3L, 3L, 173L, 718L, 1264L, 825L, 464L, 478L,
456L, 816L, 481L, 811L, 652L, 146L, 686L, 563L, 372L, 190L, 419L,
158L, 63L, 244L, 141L, 267L, 236L, 100L, 99L, 0L, 0L, 0L, 10L,
3L, 1L, 0L, 3L, 0L, 14L, 9L, 0L, 5L, 5L, 1L, 29L, 21L, 0L, 45L,
29L, 1L, 14L, 9L, 1L, 134L, 300L, 15L, 46L, 170L, 272L, 100L,
325L, 146L, 436L, 544L, 27L, 9L, 40L, 41L, 103L, 63L, 84L, 103L,
629L, 133L, 584L, 74L, 25L, 191L, 489L, 212L, 304L, 118L, 78L,
76L, 0L, 20L, 238L, 373L, 4L, 69L, 3L, 0L, 0L, 121L, 266L, 273L,
104L, 209L, 356L, 203L, 461L, 53L, 60L, 5L, 130L, 25L, 135L,
163L, 56L, 81L, 884L, 358L, 432L, 32L, 98L, 1L, 26L, 18L, 10L,
11L, 1L, 68L, 3L, 9L, 0L, 32L, 5L, 41L, 106L, 85L, 240L, 27L,
15L, 113L, 613L, 786L, 572L, 394L, 306L, 84L, 0L, 76L, 11L, 11L,
261L, 192L, 40L, 35L, 30L, 266L, 34L, 7L, 293L, 41L, 167L, 253L,
103L, 93L, 233L, 362L, 408L, 173L, 440L, 145L, 162L, 11L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 0L, 8L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 467L, 430L, 177L, 291L, 392L,
231L, 82L, 361L, 29L, 0L, 31L, 0L, 16L, 0L, 3L, 17L, 8L, 15L,
27L, 45L, 111L, 82L, 133L, 163L, 96L, 85L, 76L, 72L, 121L, 127L,
69L, 109L, 443L, 221L, 114L, 421L, 183L, 156L), Hemiptera = c(27L,
2L, 1L, 1L, 0L, 3L, 1L, 0L, 10L, 6L, 0L, 8L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 3L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L,
0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L,
0L, 1L, 2L, 0L, 0L, 1L, 0L, 1L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 1L, 0L, 0L, 4L, 2L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L,
2L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 5L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 1L, 0L, 3L, 0L, 0L, 2L, 10L, 0L, 0L, 0L, 2L, 2L, 50L, 8L,
47L, 0L, 320L, 98L, 5L, 0L, 287L, 314L, 16L, 14L, 236L, 14L,
2L, 627L, 279L, 6L, 254L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
1L, 0L, 0L, 0L, 0L, 0L, 16L, 4L, 0L, 8L, 12L, 36L, 6L, 14L, 104L,
0L, 5L, 94L, 10L, 0L, 82L, 10L, 94L, 48L, 2L, 0L, 2L, 44L, 8L,
6L, 0L, 16L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 2L, 0L, 2L, 0L, 1L, 20L, 1L, 4L, 1L, 1L, 1L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), Trichoptera = c(0L,
0L, 11L, 0L, 4L, 1L, 0L, 25L, 3L, 2L, 3L, 0L, 9L, 0L, 0L, 2L,
2L, 12L, 12L, 7L, 8L, 4L, 8L, 1L, 11L, 9L, 12L, 15L, 10L, 307L,
332L, 224L, 92L, 210L, 213L, 239L, 195L, 75L, 372L, 5L, 6L, 12L,
14L, 12L, 2L, 17L, 35L, 30L, 33L, 17L, 13L, 33L, 10L, 8L, 0L,
0L, 0L, 26L, 4L, 3L, 4L, 7L, 1L, 22L, 7L, 6L, 11L, 4L, 10L, 35L,
11L, 4L, 61L, 21L, 6L, 19L, 17L, 16L, 417L, 250L, 225L, 34L,
375L, 396L, 84L, 188L, 55L, 55L, 98L, 1145L, 713L, 342L, 2387L,
1404L, 908L, 685L, 44L, 692L, 691L, 101L, 35L, 14L, 296L, 145L,
44L, 274L, 62L, 31L, 49L, 1L, 135L, 24L, 219L, 2L, 60L, 6L, 0L,
0L, 120L, 31L, 126L, 68L, 62L, 182L, 153L, 27L, 61L, 31L, 51L,
153L, 185L, 190L, 174L, 372L, 170L, 81L, 180L, 218L, 3L, 22L,
5L, 161L, 23L, 10L, 54L, 1L, 22L, 11L, 17L, 0L, 19L, 12L, 74L,
13L, 29L, 64L, 1L, 1L, 1L, 193L, 561L, 97L, 112L, 241L, 19L,
9L, 14L, 16L, 5L, 5L, 5L, 71L, 22L, 75L, 239L, 44L, 16L, 346L,
31L, 169L, 353L, 120L, 117L, 187L, 361L, 210L, 28L, 181L, 53L,
19L, 3L, 0L, 0L, 0L, 0L, 3L, 0L, 10L, 26L, 4L, 0L, 18L, 0L, 0L,
0L, 0L, 0L, 1L, 0L, 1L, 20L, 0L, 0L, 0L, 22L, 11L, 8L, 10L, 4L,
0L, 0L, 5L, 2L, 5L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 8L,
4L, 13L, 0L, 0L, 2L, 0L, 4L, 0L, 1L, 0L, 0L, 0L, 4L, 0L, 0L,
0L, 0L, 0L, 24L, 0L, 0L, 0L, 2L, 0L, 1L, 0L, 0L, 2L, 0L, 0L,
107L, 230L, 52L, 14L, 46L, 44L, 29L, 85L, 7L, 0L, 11L, 0L, 2L,
0L, 0L, 5L, 3L, 4L, 0L, 7L, 90L, 97L, 166L, 243L, 160L, 62L,
122L, 72L, 297L, 139L, 102L, 145L, 40L, 19L, 16L, 12L, 3L, 7L
), Trombidiformes = c(6L, 1L, 59L, 1L, 4L, 16L, 3L, 1L, 3L, 2L,
2L, 49L, 12L, 0L, 0L, 0L, 1L, 2L, 3L, 8L, 1L, 8L, 10L, 11L, 0L,
15L, 1L, 5L, 8L, 31L, 31L, 59L, 48L, 111L, 155L, 153L, 116L,
102L, 210L, 4L, 3L, 2L, 2L, 4L, 0L, 6L, 5L, 52L, 215L, 76L, 107L,
103L, 116L, 100L, 0L, 0L, 0L, 0L, 0L, 2L, 3L, 0L, 0L, 1L, 0L,
2L, 1L, 0L, 2L, 1L, 0L, 4L, 1L, 5L, 10L, 3L, 0L, 1L, 5L, 19L,
7L, 5L, 13L, 7L, 8L, 2L, 2L, 6L, 0L, 1L, 0L, 0L, 0L, 3L, 1L,
2L, 0L, 0L, 0L, 50L, 21L, 22L, 41L, 26L, 4L, 70L, 2L, 8L, 16L,
0L, 48L, 35L, 6L, 3L, 16L, 6L, 2L, 0L, 7L, 8L, 43L, 17L, 9L,
26L, 32L, 24L, 52L, 16L, 39L, 34L, 26L, 29L, 6L, 51L, 53L, 75L,
198L, 93L, 49L, 29L, 37L, 59L, 92L, 45L, 66L, 4L, 38L, 33L, 36L,
2L, 116L, 31L, 70L, 9L, 32L, 8L, 2L, 8L, 8L, 80L, 92L, 51L, 187L,
75L, 130L, 143L, 128L, 83L, 80L, 67L, 76L, 0L, 2L, 1L, 47L, 14L,
0L, 105L, 14L, 52L, 50L, 54L, 20L, 54L, 48L, 34L, 6L, 47L, 23L,
10L, 2L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 16L, 2L, 8L, 0L, 13L, 8L, 0L, 0L, 29L, 12L, 2L, 2L, 3L, 1L,
0L, 44L, 23L, 1L, 12L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 2L, 0L,
0L, 0L, 0L, 0L, 0L, 8L, 0L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 0L,
36L, 0L, 2L, 2L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 0L,
23L, 93L, 26L, 257L, 61L, 36L, 179L, 56L, 20L, 0L, 61L, 0L, 66L,
0L, 3L, 0L, 3L, 0L, 0L, 27L, 66L, 76L, 113L, 44L, 30L, 15L, 16L,
18L, 23L, 39L, 95L, 41L, 37L, 28L, 45L, 22L, 21L, 9L), Tubificida = c(20L,
0L, 13L, 1L, 34L, 77L, 11L, 379L, 147L, 184L, 267L, 197L, 313L,
2L, 1L, 10L, 1L, 2L, 9L, 15L, 25L, 9L, 4L, 7L, 21L, 20L, 4L,
30L, 3L, 17L, 11L, 15L, 0L, 2L, 8L, 139L, 133L, 292L, 158L, 94L,
13L, 42L, 73L, 53L, 81L, 79L, 277L, 15L, 2L, 14L, 42L, 54L, 41L,
59L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 15L, 112L, 0L, 7L, 18L,
1L, 15L, 18L, 4L, 5L, 67L, 0L, 9L, 41L, 4L, 0L, 0L, 0L, 0L, 0L,
1L, 1L, 0L, 0L, 0L, 0L, 2L, 34L, 5L, 33L, 5L, 22L, 25L, 48L,
0L, 3L, 16L, 9L, 0L, 152L, 10L, 1L, 13L, 4L, 0L, 25L, 1L, 65L,
3L, 10L, 18L, 11L, 33L, 13L, 38L, 0L, 29L, 36L, 21L, 10L, 11L,
16L, 16L, 73L, 2L, 0L, 538L, 773L, 88L, 347L, 58L, 54L, 0L, 2L,
14L, 0L, 0L, 5L, 23L, 12L, 60L, 10L, 13L, 21L, 14L, 8L, 2L, 29L,
4L, 5L, 23L, 11L, 21L, 41L, 196L, 128L, 0L, 0L, 0L, 0L, 0L, 9L,
5L, 3L, 67L, 19L, 3L, 7L, 0L, 0L, 3L, 3L, 4L, 0L, 14L, 3L, 77L,
188L, 73L, 78L, 163L, 13L, 73L, 13L, 20L, 61L, 33L, 2L, 0L, 0L,
0L, 0L, 0L, 12L, 410L, 124L, 80L, 0L, 42L, 1L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 116L, 0L, 0L, 1L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 14L,
8L, 2L, 0L, 0L, 0L, 0L, 0L, 6L, 2L, 3L, 96L, 0L, 10L, 148L, 12L,
17L, 2L, 0L, 0L, 18L, 0L, 0L, 0L, 2L, 2L, 0L, 2L, 3L, 2L, 0L,
34L, 16L, 0L, 24L, 0L, 82L, 0L, 0L, 0L, 0L, 18L, 0L, 0L, 6L,
18L, 39L, 41L, 16L, 27L, 31L, 27L, 44L, 0L, 136L, 5L, 32L, 0L,
256L, 164L, 305L, 224L, 244L, 160L, 63L, 63L, 68L, 37L, 209L,
52L, 47L, 51L, 81L, 12L, 45L, 49L, 1L, 28L, 0L, 0L, 22L, 1L),
aquaticSiteType = c("stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "lake", "lake", "lake", "lake",
"lake", "lake", "lake", "lake", "lake", "lake", "lake", "lake",
"lake", "lake", "lake", "lake", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "lake", "lake", "lake",
"lake", "lake", "lake", "lake", "lake", "lake", "lake", "lake",
"lake", "lake", "lake", "lake", "lake", "lake", "lake", "lake",
"lake", "lake", "lake", "lake", "lake", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "lake", "lake", "lake", "lake",
"lake", "lake", "lake", "lake", "lake", "lake", "lake", "lake",
"lake", "lake", "lake", "lake", "lake", "lake", "lake", "lake",
"lake", "lake", "lake", "lake", "lake", "lake", "lake", "lake",
"lake", "lake", "lake", "lake", "lake", "lake", "lake", "lake",
"lake", "lake", "lake", "lake", "lake", "lake", "lake", "lake",
"lake", "lake", "lake", "lake", "lake", "lake", "lake", "lake",
"lake", "lake", "lake", "lake", "lake", "lake", "lake", "lake",
"lake", "lake", "lake", "lake", "lake", "lake", "lake", "lake",
"lake", "lake", "lake", "lake", "lake", "lake", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "lake", "lake", "lake", "lake", "lake", "lake",
"lake", "lake", "lake", "lake", "lake", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream", "stream",
"stream", "stream", "stream", "stream", "stream")), class = "data.frame", row.names = c(NA,
-303L))
</code></pre>
<p>I run the NMDS code using the code below</p>
<pre><code>set.seed(1)
metaMDS(comm = orders[,1:8], # Define the community data
distance = "bray", # Specify a bray-curtis distance
try = 100) # Number of iterations
</code></pre>
<p>It worked properly, when i assign it to another object, there is no solution</p>
<pre><code>set.seed(1)
nmds = metaMDS(comm = orders[,1:8], # Define the community data
distance = "bray", # Specify a bray-curtis distance
try = 100) # Number of iterations
Best solution was not repeated -- monoMDS stopping criteria:
2: no. of iterations >= maxit
16: stress ratio > sratmax
2: scale factor of the gradient < sfgrmin
</code></pre>
<p>why is this happenning? i also tried with several seeds and without seeds also, but the problem is the same.</p>
<p>and then when i tried the score value to data frame</p>
<pre><code>data_scores = as.data.frame(scores(nmds))
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, :
arguments imply differing number of rows: 303, 8
</code></pre>
<p>Why I am getting this error?</p>
| [
{
"answer_id": 74181698,
"author": "Jari Oksanen",
"author_id": 3035595,
"author_profile": "https://Stackoverflow.com/users/3035595",
"pm_score": 1,
"selected": false,
"text": "metaMDS"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14711964/"
] |
74,178,335 | <h6>views.py</h6>
<pre><code>from django.views.generic import ListView
from .models import Staff
class StaffListView(ListView):
model = Staff
template_name = 'staff/staff_list.html'
def get_queryset(self):
return Staff.objects.filter(websites__path=self.kwargs['web'])
</code></pre>
<h6>urls.py</h6>
<pre><code>urlpatterns = [
path('admin/', admin.site.urls),
path('<str:web>/staff/', include('staff.urls')),
# I want to set web=chemical, if url is http://127.0.0.1:8000/staff
]
</code></pre>
| [
{
"answer_id": 74181698,
"author": "Jari Oksanen",
"author_id": 3035595,
"author_profile": "https://Stackoverflow.com/users/3035595",
"pm_score": 1,
"selected": false,
"text": "metaMDS"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4382305/"
] |
74,178,349 | <p>I am have following code which works well in TSQL:</p>
<pre><code>BEGIN
IF NOT EXISTS (select * from tblDCUSTOM where id = 'All Customers')
BEGIN
INSERT INTO tblDCUSTOM
(ID
,Name
,English
)
SELECT 'All Customers','All Customers','All Customers'
END
END
</code></pre>
<p>Now, I need to have this functionality in an custom environment, where SQL-92 is used - so no EXISTS (<em>edit: not true, EXISTS works in SQL-92</em>) or BEGIN-END is possible. Any Ideas?</p>
| [
{
"answer_id": 74178688,
"author": "Lukáš Tomšů",
"author_id": 7199785,
"author_profile": "https://Stackoverflow.com/users/7199785",
"pm_score": 0,
"selected": false,
"text": "EXISTS"
},
{
"answer_id": 74180340,
"author": "Nick.McDermaid",
"author_id": 1690193,
"autho... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7199785/"
] |
74,178,354 | <p>I want to move some special object in the list to the bottom of it.
I tried to used below code to implement it but it shows last assignment is never been used...
I have walkaround but I really want to know why my code is wrong?
After the method proceed the list I passed in, it still the old sequence. No impact...</p>
<pre><code>private void moveNullBrokerToEnd(List<Broker> brokers) {
if (brokers != null) {
List<Broker> nullTypeBrokers = new ArrayList<>();
List<Broker> commonBrokers = new ArrayList<>();
for (Broker broker : brokers) {
if (broker.getMemberType()==null) {
nullTypeBrokers.add(broker);
} else {
commonBrokers.add(broker);
}
}
brokers = ListUtils.union(commonBrokers, nullTypeBrokers);
}
</code></pre>
<p>}</p>
<p><a href="https://i.stack.imgur.com/zoDjM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zoDjM.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74178688,
"author": "Lukáš Tomšů",
"author_id": 7199785,
"author_profile": "https://Stackoverflow.com/users/7199785",
"pm_score": 0,
"selected": false,
"text": "EXISTS"
},
{
"answer_id": 74180340,
"author": "Nick.McDermaid",
"author_id": 1690193,
"autho... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10481910/"
] |
74,178,362 | <p>I need to ping several IPs a not all at once but one by one.
My problem is that I do not want to use the same if else clause for every IP address.
As you can see I have only done it for <code>10.10.10.5</code>
but i do not want to repeat it for every other IP i know it is bad practice but i have no idea how to write a algorithm or something similar for it.
I also need to send this info (PASS/FAIL) to a MariaDB database.
Could someone please show me how i can write an algorithm or a function to iterate through the IPs but still save the result of each IP and send it to the database.
Examples would be much appreciated</p>
<pre><code> def pingPreflash(self):
self.reachable = 'PASS'
self.unreachable = 'FAIL'
self.preflash = subprocess.run(["ping","-n","2", "10.10.10.2"],stderr=subprocess.PIPE, stdout=subprocess.PIPE)
self.p1 = subprocess.run(["ping","-n","2", "192.168.11.10"],stderr=subprocess.PIPE, stdout=subprocess.PIPE)
self.p2 = subprocess.run(["ping","-n","2", "192.168.12.10"],stderr=subprocess.PIPE, stdout=subprocess.PIPE)
self.p3 = subprocess.run(["ping","-n","2", "192.168.13.10"],stderr=subprocess.PIPE, stdout=subprocess.PIPE)
self.p4 = subprocess.run(["ping","-n","2", "192.168.14.10"],stderr=subprocess.PIPE, stdout=subprocess.PIPE)
self.software = subprocess.run(["ping","-n","2", "192.168.100.2"],stderr=subprocess.PIPE, stdout=subprocess.PIPE)
if self.preflash.returncode == 0:
if("unreachable" in str(self.preflash.stdout)):
self.preflashesult = self.unreachable
print('10.10.10.5', self.preflashesult)
else:
self.preflashesult = self.reachable
print('10.10.10.5', self.preflashesult)
elif self.preflash.returncode == 1:
self.preflashesult = self.unreachable
print('10.10.10.5', self.preflashesult)
</code></pre>
| [
{
"answer_id": 74178403,
"author": "krock",
"author_id": 353852,
"author_profile": "https://Stackoverflow.com/users/353852",
"pm_score": 2,
"selected": false,
"text": "ip_addressses = [.....]\nfor ip in ip_addresses:\n supprocess.run(...)\n"
},
{
"answer_id": 74178464,
"au... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17128344/"
] |
74,178,394 | <p>When using Flutter and Riverpod, how do I update its values from my business logic?</p>
<p>I understand that I can get and set values from the UI side.</p>
<pre><code>class XxxNotifier extends StateNotifier<String> {
XxxNotifier() : super("");
}
final xxxProvider = StateNotifierProvider<XxxNotifier, int>((ref) {
return XxxNotifier();
});
class MyApp extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
// getValue
final String value = ref.watch(xxxProvider);
// setValue
context.read(xxxProvider).state = "val";
return Container();
}
}
</code></pre>
<p>This method requires a context or ref.</p>
<p>How do I get or set these states from the business logic side?</p>
<p>Passing a context or ref from the UI side to the business logic side might do that, but I saw no point in separating the UI and business logic. Perhaps another method exists.</p>
<p>Perhaps I am mistaken about something. You can point it out to me.</p>
| [
{
"answer_id": 74178616,
"author": "Ruble",
"author_id": 17991131,
"author_profile": "https://Stackoverflow.com/users/17991131",
"pm_score": 2,
"selected": true,
"text": "ref"
},
{
"answer_id": 74178740,
"author": "Tayormi",
"author_id": 7652436,
"author_profile": "ht... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178394",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5528270/"
] |
74,178,404 | <p>I have a dataframe like the following:</p>
<pre><code>sample<-c("A", "B", "C", "D")
x<-c(1,2,7,1)
y<-c(1,5,4,2)
df <- data.frame(sample,x,y)
</code></pre>
<p>and my desired output should be something like this:</p>
<pre><code> x y
min 1 1
max 7 5
</code></pre>
<p>I tried</p>
<pre><code>df_min <- apply(df[, c(2,3)], 2, FUN = min, na.rm = TRUE)
df_max <- apply(df[, c(2,3)], 2, FUN = max, na.rm = TRUE)
</code></pre>
<p>but how do I get that into something that looks like my desired output dataframe?</p>
| [
{
"answer_id": 74178448,
"author": "Maël",
"author_id": 13460602,
"author_profile": "https://Stackoverflow.com/users/13460602",
"pm_score": 3,
"selected": true,
"text": "range"
},
{
"answer_id": 74179250,
"author": "jay.sf",
"author_id": 6574038,
"author_profile": "ht... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7952111/"
] |
74,178,422 | <p>For instance, I have a <code>div</code>, that is <code>10 000px by 10 000px</code> and I want it to fit on any screen, like its height and width would be <code>10 000px</code> and not just <code>100%</code>, but the scroll bar wouldn't be there and I <strong>wouldn't</strong> be able to scroll until the <code>div</code>'s bottom and right side</p>
| [
{
"answer_id": 74178488,
"author": "Imri Harlev",
"author_id": 14957121,
"author_profile": "https://Stackoverflow.com/users/14957121",
"pm_score": 0,
"selected": false,
"text": "position: absolute"
},
{
"answer_id": 74178525,
"author": "João Paulo Macedo",
"author_id": 11... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20197693/"
] |
74,178,427 | <p>I am listing features of a building. But I don't want to display features that are not available. The availability values are stored in database. And I am using custom scrollview.</p>
<p>I have attached the image where it was initially. It shows not available when the database says so. But I don't want that feature to appear when it is not available. My method of doing so gives a null space in that area, which is not my goal.</p>
<p>I just only want to display features that are avialable.</p>
<p>Here is the code :</p>
<pre><code>SliverGrid(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
childAspectRatio: MediaQuery.of(context).size.width /
(MediaQuery.of(context).size.height / 2.5),
),
delegate: SliverChildListDelegate(
[
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
decoration: BoxDecoration(
borderRadius:
const BorderRadius.all(Radius.circular(15)),
border: Border.all(
color: Colors.grey,
width: 1.0,
),
color: Colors.white,
boxShadow: const <BoxShadow>[
BoxShadow(
color: Color.fromARGB(255, 255, 255, 255),
blurRadius: 0.0,
spreadRadius: -2,
offset: Offset(2.0, 0.0),
),
],
),
//width: 70.0,
//height: 100,
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Center(
child: Column(
children: [
const Icon(
Icons.bed,
color: Colors.grey,
size: 20,
),
const Text('Bedroom',
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.w500,
fontSize: 12)),
Text(flat.room,
style: const TextStyle(
color: Colors.grey,
fontWeight: FontWeight.w500,
fontSize: 10))
],
),
),
),
),
),
flat.ewa == "Included"
? Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
decoration: BoxDecoration(
borderRadius:
const BorderRadius.all(Radius.circular(15)),
border: Border.all(
color: Colors.grey,
width: 1.0,
),
color: Colors.white,
boxShadow: const <BoxShadow>[
BoxShadow(
color: Color.fromARGB(255, 255, 255, 255),
blurRadius: 0.0,
spreadRadius: -2,
offset: Offset(2.0, 0.0),
),
],
),
//width: 120.0,
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Center(
child: Column(
children: [
const Icon(
Icons.electric_bolt,
color: Colors.grey,
size: 20,
),
const Text('EWA',
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.w500,
fontSize: 12)),
Text(flat.ewa,
style: const TextStyle(
color: Colors.grey,
fontWeight: FontWeight.w500,
fontSize: 10))
],
),
),
),
),
)
: null,
//const SliverToBoxAdapter(child: SizedBox.shrink()),
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
decoration: BoxDecoration(
borderRadius:
const BorderRadius.all(Radius.circular(15)),
border: Border.all(
color: Colors.grey,
width: 1.0,
),
color: Colors.white,
boxShadow: const <BoxShadow>[
BoxShadow(
color: Color.fromARGB(255, 255, 255, 255),
blurRadius: 0.0,
spreadRadius: -2,
offset: Offset(2.0, 0.0),
),
],
),
//width: 130.0,
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Center(
child: Column(
children: [
const Icon(
Icons.chair,
color: Colors.grey,
size: 20,
),
const Text('Furnished',
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.w500,
fontSize: 12)),
Text(flat.furnished,
style: const TextStyle(
color: Colors.grey,
fontWeight: FontWeight.w500,
fontSize: 10))
],
),
),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
decoration: BoxDecoration(
borderRadius:
const BorderRadius.all(Radius.circular(15)),
border: Border.all(
color: Colors.grey,
width: 1.0,
),
color: Colors.white,
boxShadow: const <BoxShadow>[
BoxShadow(
color: Color.fromARGB(255, 255, 255, 255),
blurRadius: 0.0,
spreadRadius: -2,
offset: Offset(2.0, 0.0),
),
],
),
//width: 130.0,
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Center(
child: Column(
children: [
const Icon(
Icons.yard,
color: Colors.grey,
size: 20,
),
const Text('Garden',
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.w500,
fontSize: 12)),
Text(
flat.garden == "true"
? 'Available'
: 'Not Available',
style: const TextStyle(
color: Colors.grey,
fontWeight: FontWeight.w500,
fontSize: 10))
],
),
),
),
),
),
],
),
),
</code></pre>
<p><a href="https://i.stack.imgur.com/3uMKI.png" rel="nofollow noreferrer">Initial State</a>
<a href="https://i.stack.imgur.com/J3lxe.png" rel="nofollow noreferrer">New Error state</a></p>
| [
{
"answer_id": 74178478,
"author": "Just a Person",
"author_id": 15494398,
"author_profile": "https://Stackoverflow.com/users/15494398",
"pm_score": 0,
"selected": false,
"text": "child: someCondition ? Column(...): null"
},
{
"answer_id": 74178585,
"author": "Fugipe",
"a... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13734207/"
] |
74,178,432 | <p>Clicking on the button handler named handleDelivered immediately doesnt effect updatedQuantity.
For example - by default quantity = 10 which is initial value of updatedQuantity,
after clicking handleDelivered it should decrease value by 1 and should print on the console "updatedQuantity after delivered 9" but its showing</p>
<p><strong><strong>updatedQuantity after delivered 10</strong>
<strong>updatedQuantity before delivered 9</strong></strong></p>
<p><strong>Code :</strong></p>
<pre><code>const { name, artist, img, description, price, quantity, supplier } = album;
const [updatedQuantity, setupdatedQuantity] = useState(quantity);
useEffect(() => {
setupdatedQuantity(quantity)
}, [quantity])
console.log("updatedQuantity before delivered", updatedQuantity);
const handleDelivered = () => {
if (updatedQuantity > 0) {
setupdatedQuantity(updatedQuantity - 1);
console.log("updatedQuantity after delivered", updatedQuantity);
}
</code></pre>
| [
{
"answer_id": 74178537,
"author": "Harrison",
"author_id": 15291770,
"author_profile": "https://Stackoverflow.com/users/15291770",
"pm_score": 1,
"selected": false,
"text": "prev"
},
{
"answer_id": 74178804,
"author": "rymanso",
"author_id": 6716421,
"author_profile"... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6295249/"
] |
74,178,462 | <p>I'm following the example of "Thinking in Swift UI" book.</p>
<p>I'm creating an Observable Object</p>
<pre><code>final class Contact: ObservableObject, Identifiable {
let id = UUID()
@Published var name: String
@Published var city: String
@Published var profile: String
init(name: String, city: String, profile: String) {
self.name = name
self.city = city
self.profile = profile
}
}
</code></pre>
<p>Content View is defined as list of Button which selects the contact. And it stores the contacts as normal array property</p>
<pre><code>struct ContentView: View {
@State var selection: Contact?
var contacts: [Contact]
var body: some View {
HStack {
ForEach(contacts) { contact in
Button(contact.name) {
self.selection = contact
}
}
}
if let c = selection {
Detail2(contact: c)
}
}
}
</code></pre>
<p>And here we have Detail View which calls the id modifier to change the identify of the view and supposedly make "onAppear" be called again - which doesn't work</p>
<pre><code>struct Detail: View {
@ObservedObject var contact: Contact
@StateObject var loader = ImageLoader()
var body: some View {
HStack {
loader.imageView
VStack {
Text(contact.name).bold()
Text(contact.city)
}
}
.id(contact.id)
.onAppear {
loader.load(image: contact.profile)
}
}
}
</code></pre>
<p>And here I mocked the Loader</p>
<pre><code>class ImageLoader: ObservableObject {
var image: String = ""
init() {
print("Initializer of Image Loader was called")
}
func load(image: String) {
print("Brrr.... loading image")
print("The image is: \(image)")
self.image = image
}
}
</code></pre>
<p>The app is defined as Content View which passes the array of contacts:</p>
<pre><code>@main
struct SwiftUILearning2App: App {
var body: some Scene {
WindowGroup {
ContentView(contacts: [ Contact(name: "name1", city: "city1", profile: "profile_1"),
Contact(name: "name2", city: "city2", profile: "profile_2")])
}
}
}
</code></pre>
<p>Why doesn't onAppear - and in effect load.loader( ) is not called when the new contact is assigned?
According to the book <code>.id(contact.id)</code> modifier called on Detail View should be able to make onAppear to be called again.</p>
<p>After the example without the <code>.id(contact.id</code> modifier the book states:</p>
<p>"Upon first try, this seems to work, but when we change the contact object (for example, by selecting a different person) the view never reloads the image. The simplest way to solve this problem is by telling SwiftUI that it should change the identity of the view:"</p>
<p>Here is a link to full code:
<a href="https://gist.github.com/pbrewczynski/63f2dfdba96dec2efcf7d81d304622f6" rel="nofollow noreferrer">https://gist.github.com/pbrewczynski/63f2dfdba96dec2efcf7d81d304622f6</a></p>
| [
{
"answer_id": 74180037,
"author": "Luca Petra",
"author_id": 11090441,
"author_profile": "https://Stackoverflow.com/users/11090441",
"pm_score": 2,
"selected": false,
"text": " .onChange(of: contact) { newValue in\n loader.load(image: newValue.profile)\n }\n"
},
{
"... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178462",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1364174/"
] |
74,178,482 | <p>I need method that can find component implements interface T.
I have this method but i does not work correctly. It should work like TryGetComponent(out Interface interface). Can you help?</p>
<pre><code>public T RaycastFindComponent<T>(T targetType) where T : Type
{
RaycastHit2D[] raycastHits = Physics2D.RaycastAll(_mainCamera.ScreenToWorldPoint(Input.mousePosition), new Vector2());
foreach (RaycastHit2D raycastHit in raycastHits)
{
foreach (MonoBehaviour component in raycastHit.transform.GetComponents(typeof(MonoBehaviour)))
{
Type componentType = component.GetType();
Debug.Log($"GetComponent = {componentType is T}"); //true
if (componentType is T)
{
return component as T; //null but (componentType is T = true)
}
}
}
return null;
}
</code></pre>
<p>It works if I use concrete Interface:</p>
<pre><code>public Interface RaycastFindComponent()
{
RaycastHit2D[] raycastHits = Physics2D.RaycastAll(_mainCamera.ScreenToWorldPoint(Input.mousePosition), new Vector2());
foreach (RaycastHit2D raycastHit in raycastHits)
{
foreach (MonoBehaviour component in raycastHit.transform.GetComponents(typeof(Interface)))
{
Type componentType = component.GetType();
Debug.Log($"GetComponent = {componentType is Interface}"); //true
if (componentType is T)
{
return component as Interface; //(Interface)component
}
}
}
return null;
}
</code></pre>
| [
{
"answer_id": 74180037,
"author": "Luca Petra",
"author_id": 11090441,
"author_profile": "https://Stackoverflow.com/users/11090441",
"pm_score": 2,
"selected": false,
"text": " .onChange(of: contact) { newValue in\n loader.load(image: newValue.profile)\n }\n"
},
{
"... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20295026/"
] |
74,178,490 | <p>I have the following code in Java :</p>
<pre><code>int a=5,b=10,c;
c = ++b * ++a - a++ ;
System.out.println(c);
</code></pre>
<p>Now referring to the Java operators precedence table :-</p>
<p><a href="https://i.stack.imgur.com/KQRc9.png" rel="nofollow noreferrer">Table</a></p>
<p>We will first evaluate the postfix a++ and then prefix ++a and ++b, which gives us :</p>
<p>c= 11 * 7 - 5
= 72</p>
<p>But this answer is wrong, and the correct answer is 60
What am I doing here?</p>
| [
{
"answer_id": 74178619,
"author": "Just a Person",
"author_id": 15494398,
"author_profile": "https://Stackoverflow.com/users/15494398",
"pm_score": 1,
"selected": false,
"text": "++a"
},
{
"answer_id": 74178742,
"author": "Dawood ibn Kareem",
"author_id": 1081110,
"a... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20040346/"
] |
74,178,493 | <p>I'm trying to add a "contact us" form to my existing "contact us" page using a model form and class based views.
First I've created the model below:</p>
<pre><code>class ContactUsForm(models.Model):
first_name = models.CharField(max_length=200, blank=False, null=False)
last_name = models.CharField(max_length=200, blank=False, null=False)
email = models.EmailField(blank=False, null=False)
subject = models.CharField(max_length=250, blank=False, null=False)
message_body = models.TextField()
def __str__(self):
return self.subject
</code></pre>
<p>Then I've created my form in forms.py as below:</p>
<pre><code>class ContactForm(ModelForm):
class Meta:
model = ContactUsForm
fields = "__all__"
</code></pre>
<p>My previously existing contact page view is as below:</p>
<pre><code>class ContactUsPageView(ListView):
"""
In this view we are fetching site data from database, in a function named
get_context_data. In this function, we filter the model for objects that contains
the word 'تماس', therefore fetching data referring to the about page only.
After that the context list is sent to the template, and there with a for loop
and an if statement, each key, value set is chosen for the proper place.
"""
model = SiteDataKeyValue
template_name: str = "core/contact-us.html"
def get_context_data(self, **kwargs):
context = super(ContactUsPageView, self).get_context_data(**kwargs)
context["contact_page_data"] = self.model.objects.filter(key__icontains="تماس")
return context
</code></pre>
<p>Now, I have no idea how to proceed. How am I supposed to add this form to my view, then send it along with the <code>contact_page_data</code> to the template, and how to style it (styling is not the question here and I'll deal with it as soon as the view is complete.).</p>
| [
{
"answer_id": 74179324,
"author": "Lucas Grugru",
"author_id": 16984466,
"author_profile": "https://Stackoverflow.com/users/16984466",
"pm_score": 0,
"selected": false,
"text": "class ContactUsPageView(FormView):\n\n form_class = ContactForm\n template_name: str = \"core/contact-u... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4429265/"
] |
74,178,607 | <p>I have the following data:</p>
<pre><code> date_ user_id
2021-10-05 123
2021-10-05 234
2021-10-05 345
2021-10-06 123
2021-10-06 234
2021-10-06 111
2021-10-07 123
2021-10-07 234
2021-10-07 111
2021-10-07 122
</code></pre>
<p>which is produced by this piece of code:</p>
<pre><code>select
date('2021-10-05') as date_, '123' as user_id
union all select date('2021-10-05'), '234'
union all select date('2021-10-05'), '345'
union all select date('2021-10-06'), '123'
union all select date('2021-10-06'), '234'
union all select date('2021-10-06'), '111'
union all select date('2021-10-07'), '123'
union all select date('2021-10-07'), '234'
union all select date('2021-10-07'), '111'
union all select date('2021-10-07'), '122'
</code></pre>
<p>What I want to do is to calculate the rolling count distinct of the <code>user_id</code> field for the previous rows of <strong>each date</strong>. The result should be this:</p>
<pre><code> date_ rolling_count_distinct
2021-10-05 3
2021-10-06 4
2021-10-07 5
</code></pre>
<p>It's like running the following piece of code, but for all dates in the <code>where</code> clause (<code>'2021-10-05'</code>, <code>'2021-10-06'</code>, <code>'2021-10-07'</code>):</p>
<pre><code>with table_1 as (
select
date('2021-10-05') as date_, '123' as user_id
union all select date('2021-10-05'), '234'
union all select date('2021-10-05'), '345'
union all select date('2021-10-06'), '123'
union all select date('2021-10-06'), '234'
union all select date('2021-10-06'), '111'
union all select date('2021-10-07'), '123'
union all select date('2021-10-07'), '234'
union all select date('2021-10-07'), '111'
union all select date('2021-10-07'), '122'
)
select
count(distinct user_id) as rolling_count_distinct
from table_1
where date_ <= '2021-10-05'
</code></pre>
| [
{
"answer_id": 74179324,
"author": "Lucas Grugru",
"author_id": 16984466,
"author_profile": "https://Stackoverflow.com/users/16984466",
"pm_score": 0,
"selected": false,
"text": "class ContactUsPageView(FormView):\n\n form_class = ContactForm\n template_name: str = \"core/contact-u... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14501269/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.