foos | FOOS 's Overcoming Operating System
kandi X-RAY | foos Summary
kandi X-RAY | foos Summary
FOOS still remains as a hobbyist research purpose operating system, so use it wisely.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of foos
foos Key Features
foos Examples and Code Snippets
Community Discussions
Trending Discussions on foos
QUESTION
I have several Excel files where several people send some information, but as people is too creative, they didn't preserve all the Excel template as instructed, so some files have 10 columns, others have 12, and so on.
There's a column that has only two possible values, "foo" and "bar", but it's not always in the same column, and the column aren't always named the same, so you can have "Thing" in column 12 and "THING (foo/bar)" in column 9
I'm writting a script to clean all this data (almost 200 files), and I need to get the foos and bars.
So my question is, is there a way to look in the dataframe for this patterns and tell me in which column are they?
Once I get in which column are the foos and bars, the rest of the problem is trivial, since the first column is always right, so I could use my extracted dataframe as df[[0, n]]
where n is where the foos and bars are
Currently what I'm doing is iterating over the column names like:
...ANSWER
Answered 2022-Feb-17 at 05:28You can test whether "foo"
and "bar"
are in particular column and if they are the only values which might be a bit cleaner:
QUESTION
I recently started writing my first SwiftUI app and ran into an design issue, which can be demonstrated by the simple code below. I know what the issue is, but I wonder why it occurred and what's the recommended way to address it.
In the demo, there are two views. The first is a list view, the second is a detail view. The detail view contains a button to delete the item being displayed. Clicking on the button crashes the app due to the forced unwrapping in the detail view. I didn't expect the crash, because from my understanding when the data model changes, SwiftUI should regenerate the entire view hierarchy. That is, it calls ContentView.body
, which calls FooListView.body
, which goes through items in the data model and creates NavigationLink
for each item.
Since the data model has been changed, there is only one item left. So I don't think SwiftUI would create FooDetailView
(or call its body) for the item deleted. If so, how come the FooDetailView
code crashed? I tried to debug the code but didn't find much useful information. I believe the FooDetailView
that crashed the app is the one that contained the deleted item. That I don't understand. Since SwiftUI regenerates view hierarchy, how could that old view left uncleaned up?
Can anyone explain a bit how you understand it? And how do you address the issue? I currently think out two ways. The first is to pass all the params needed by detail view to avoid accessing data model. But I don't think this approach scales. The second is to not use forced wrapping. That should work fine, but I doubt if this is the recommended way to do it.
BTW, another similar setup to generate the crash is to use three views: list view -> detail view -> delete view. When user clicks on button in delete view, the detail view will crash.
Thanks.
Update:
- SwiftUI may recall an existing view's body which contains stale data.
@jrturton I was aware that changes to @EnvironmentObject
would cause view's body get called. What I didn't realize was that SwiftUI migtht recalled an existing view's body which contain stale data. I never read any discussion about this on the net. Do you know why SwiftUI do that?
I had always thought that when state changes, SwiftUI would regenerate the entire view hierarchy from top down by calling Content.body
. If it was so, FooDetailView
would always has the up-to-date data when it gets called and there wouldn't be the issue. I had the understanding because SwiftUI is advertised as a state driven architecture, and app developers are supposed to declare the UI based on the current state. By "current" I mean the new state, not the previous state. That's the reason why I thought it should be fine to use forced unwrapping.
- I doubt if passing all params to detail view is a general solution.
First, this doesn't scale well. For example, suppose Foo
is associated with another struct Bar
(that is, Foo
has a property containing Bar
's id) and we want to display Bar's name in detail view, then we will need to add bar name to the params. For a complicated Item, its detail view may contain a lot of things which are determined at runtime, it will be hard to prepare everything ahead by the caller.
More importantly, once we pass these params to detail view, they are effectively outside data model and can easily go stale. It would be issue if user performs delete action using these stale data.
- Passing binding doesn't solve the crash issue on its own.
@lorem-ipsum, thanks for your suggestion on using binding. I wasn't aware that ForEach
can take binding. What's more, I have also beening think if it's good practice to pass binding, instead of regular params, in SwiftUI (I don't know that anwser yet).
That said, passing binding doesn't solve the crash issue on its own, because when the data model changes, SwiftUI still recalls the existing detail view's body which contain stale data.
- The solution?
I think the root cause is that, although SwiftUI is advertised as a state driven architecture, a view's body may get called with stale data. So the data model's api should deal with invalid params. Hornestly speaking, this isn't a design decison which I prefer to. I usually think the caller should only pass valid params to data model API. Otherwise it's an architecture issue that should be resolved on the caller side in the first place. Unfortunately it seems that's the case with SwiftUI.
(Note: Thank all for pointing out that deletion code should be in data model. I knew that. I didn't do it because I spent long time investigating the issue in my app and was exhausted when I prepared the example code.)
...ANSWER
Answered 2022-Jan-28 at 14:02@EnvironmentObject
values are all observed objects, and when you delete the item from the array, you are triggering observing views to re-render. In your example, the re-rendering of the detail view is performed before that of the list, so your detail view's body is recalculated even though it is about to be removed from the screen.
Your instinct to pass more parameters in is sensible - it would make sense to pass in the entire Foo
, and add a dataModel.delete(foo)
method so you're not exposing how your data model stores its data.
QUESTION
I'm looking to do replacements in unknown third-party inputs in strings that sometimes have quotes among them.
I want to replace a wholeword whereever it occurs unless it's in double or single-quotes, and unless the quote is escaped.
Example: Replacing FOO by BAR
Input:
...ANSWER
Answered 2022-Feb-07 at 10:48If I am understanding your requirements correctly, you may try this regex for your cases:
QUESTION
It is possible to neglect some elements during Collectors.groupingBy
or Collectors.partitioningBy
?
Of course I know I can place a .filter()
anywhere in a stream. But my problem is that I have to run a rather complex and expensive evaluation, to decide in which "group" my objects should be divided into.
Moreover, there are always many objects that I would want to neglect during collecting.
Example: imagine a List
, that I want to split into 2 lists. That's easy, but how can I additionally neglect all objects that don't fit into my evaluated condition?
ANSWER
Answered 2022-Feb-02 at 15:08To reuse the result of complexEvaluation in both filter
and groupingBy
, you can call before filtering and store the result in a wrapper class.
QUESTION
I have a bug in my code which I don't quite understand. According to the documentation, std::vector.back()
returns a reference to the last element in the container, so here's what I did: (live here)
ANSWER
Answered 2022-Jan-29 at 17:47What's happening here is that when you .emplace_back(1)
the std::vector
does not have enough space for two elements, so it has to reallocate, copy/move all the existing elements to the new allocation, then emplace_back
the new one. Hence you see the only existing element being destroyed from the old allocation.
This goes away if you .reserve(2)
before the loop: https://godbolt.org/z/oj8fWhznP
QUESTION
I have a vector x
of type Eigen::VectorXi
with more than 2^31-1 entries, which I would like to return to R. I can do that by copying x
entry-wisely to a new vector of type Rcpp::IntegerVector
, but that seems to be quite slow.
I am wondering:
- whether there is a more efficient workaround;
- why in the following reproducible example
Rcpp::wrap(x)
doesn't work.
test.cpp
...ANSWER
Answered 2022-Jan-16 at 16:36Rcpp::wrap
is dispatching to a method for Eigen matrices and vectors implemented in RcppEigen
. That method doesn't appear to support long vectors, currently. (Edit: It now does; see below.)
The error about negative length is thrown by allocVector3
here. It arises when allocVector3
is called with a negative value for its argument length
. My guess is that Rcpp::wrap
tries to represent 2^31
as an int
, resulting in integer overflow. Maybe this happens here?
In any case, you seem to have stumbled on a bug, so you might consider sharing your example with the RcppEigen
maintainers on GitHub. (Edit: Never mind - I've just submitted a patch.) (Edit: Patched now, if you'd like to build RcppEigen
from sources [commit 5fd125e or later] in order to update your Rcpp::wrap
.)
Attempting to answer your first question, I compared your two approaches with my own based on std::memcpy
. The std::memcpy
approach supports long vectors and is only slightly slower than Rcpp::wrap
.
std::memcpy
approach
The C arrays beneath Eigen::VectorXi x
and Rcpp::IntegerVector y
have the same type (int
) and length (n
), so they contain the same number of bytes. You can use std::memcpy
to copy that number of bytes from one's memory address to other's without a for
loop. The hard part is knowing how to obtain the addresses. Eigen::VectorXi
has a member function data
that returns the address of the underlying int
array. R objects of integer type use INTEGER
from the R API, which does the same thing.
QUESTION
I have the following code that deletes the signal during one of the callbacks from the signal:
...ANSWER
Answered 2022-Jan-15 at 17:13 // delete the foos here, where we will be calling from below
QUESTION
I am trying to create a select query with a simple where-clause using Haskell's beam. From https://haskell-beam.github.io/beam/user-guide/queries/select/#where-clause, I believed that this would work:
...ANSWER
Answered 2021-Dec-30 at 14:31On the offending line, bar :: Word32
(per the signature of selectFoosByBar
).
I think _fooBar foo
is a Columnar (something) Word32
.
The error message says the problem is with the first arg to ==.
, but looking at the type of ==.
, I think you could change either side to get agreement.
Why is bar :: Word32
? It makes intuitive sense; you're trying to filter by a word so the arg should be a word. That suggests that you probably want to do something to _fooBar foo
to get a Word32
"out of" it. That might be a straightforward function, but more likely it's going to be the opposite: somehow lifting your ==. bar
operation up into the "query expression" space.
QUESTION
In a pipeline like
...ANSWER
Answered 2021-Nov-19 at 20:10To be clear: As originally reported for Unix and then for Windows, PowerShell's current behavior (as of v7.2) should be considered a bug that will hopefully be fixed: PowerShell should detect when an native (external program) has exited and should stop all upstream commands in that event.
The following shows a generic workaround, which, however, invariably slows things down and has a limitation:
- As of v7.2, PowerShell unfortunately doesn't offer a public feature to stop upstream commands (see GitHub feature request #); internally, it uses a private exception, as used by
Select-Object -First
, for instance. The function below uses reflection and ad-hoc-compiled C# code to throw this exception (as also demonstrated in this answer). This means that a performance penalty for the compilation is paid on first invocation of the function in a session.
Define the function nw
("native wrapper"), whose source code is below, and then invoke it as follows, for instance:
On Windows (assumes WSL; omit
-Verbose
to suppress verbose output):
QUESTION
is it somehow possible to use the new searable
in combination with a @FetchRequest
?
I have a code like this:
...ANSWER
Answered 2021-Jul-27 at 17:55WWDC 2021 Bring Core Data Concurrency to Swift and SwiftUI has a great example of this right around minute 21:33
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install foos
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page