arrays – Mock error response in combine to test error handling

I have a service mock setup, but i want to be able to set it up to return an error so i can test that scenario too

class PostsServiceMock: PostsServiceProtocol {

  var posts: (Post) = (.mock())

  var getPostsCallCount = 0

  func getPosts() -> AnyPublisher<(Post), APIError> {

    getPostsCallCount += 1

    return Just(posts)
      .setFailureType(to: APIError.self)
      .eraseToAnyPublisher()
  }

  func reset() {
    getPostsCallCount = 0
  }
}

How can i do this

How to combine 2 quaternions?

  1. It’s possible to combine 2 quaternions without converting to eulers?
    For example:

q1{w1, x1, y1, z1} (euler: 45, 30, 60)

q2{w2, x2, y2, z2} (euler: 20, 15, 80)

I need to result, where values are combination of previous 2 rotations:
q3 = {w3, x3, y3, z3} (euler (20, 30, 80))

  1. It’s possible to set rotation around some axis to zero?

design – Right way to combine data between Mongo and DynamoDB

I am looking for a way of dealing with the following situation:

1- Have an items collection in MongoDB

2- Have a users collection in DynamoDB

3- Each document in the items collection has a “reference” to a user or multiple users via an id attribute of the DynamoDB.

4- I need to query the items collection and populate each item with metadata from the user table (In each item, I have to replace the id reference/s with user metadata)

5- The DynamoDB has to remain as the main source of truth for the users, and can’t move the MongoDB data over.

I’m wondering what would be the best solution for this.

At the moment I’m thinking of two options:

  • One is getting the items from MongoDB, getting the users ids, query all the users from DynamoDB and inserting the user’s data in the items. As the items are somewhat a complex collection, there is a lot of potential to introduce new bugs and making it hard to maintain in the future.

  • Second one is copying the DynamoDB users to MongoDB and querying directly in MongoDB. The issue here is that the collection has to be kept in sync all the time and I’m not convinced about having the same data in different places due to the increased complexity.

As no approach is 100% perfect, just wondering if there could be a better way to do this.

Which option (or other) would be the way to go?

worksheet function – Extract and combine data from huge Excel tables

I receive huge metadata excels (mastersheets with minimum 100.000 rows up until 1 million; columns vary from 10 to 30) containing data that I would need to extract based on a unique identifier (present in the first column of my master sheet).
For the moment I use LOOKUP to look for my unique identifier and extract the associated column I would need for my new sheet. However, As I extract more than 1 column (from 3 to 6), the calculation is extremely slow (30 minutes or more to calculate my sheet).

I use this formula
=IF(IF(LOOKUP(A2;STORED_NAME)=A2;”yes”;”no”)=”yes”;TRIM(LOOKUP(A2;STORED_NAME;FILENAME));”#####”)

I have tried also with VLOOKUP but the calculation is also extremely slow. Filtering is also another nightmare and it takes forever.

Do you have any advice? Should I keep using Excel and use another formula? Or maybe should I look into something different (another program, another language, etc) that can also automatize the process?

Thanks in advance

Combine sublists of nested list when the first two list elements are equal

New to Mathematica, I have a nested list with the following structure:

{ {A,B,C,D,E,F},{a,b,c,d,e,f},{H,I,K,K,L,M},.......} 

All sublists are of equal length. I want to combine these sublists such that when A=a and B=b, the third list element C is replaced with the mean of C and c, element D is replaced with the mean of D and d, and so on through the last element of the sublists. The completed list would have the following form:

{{A,B,Mean[C,c],Mean[D,d],Mean[E,e],Mean[F,f]},....} 

Thanks.

animation – How to combine and export multiple NLA tracks of 2 armatures (Blender) to Unity?

As per first experience I created multiple tracks (and also “added” more animation to first tracks thinking I edit them but instead I just created more tracks for same animations) for 2 armatures (1 armature hands, 2 armature gun)

enter image description here

How can I export those to Unity properly? When I export in Unity all I see this:

enter image description here

In Unity my gun animations does not affect animations of hands (in Blender wrist bones is child of gun root, and gun root is child of hands root) and some animations are not even there…

Can I somehow bake multiple strips of 2 armatures to one animation so that in Unity it will be perceived as 1 animation for the whole object?

api design – Should I combine or separate APIs for related but distinct entities?

Right now I’m working on a project that’s basically a marketplace. The project separates backend (Django + DRF) and frontend where frontend can hit different endpoints based on user interactions with web interface.

The project has two distinct but related entities:

So original engineers decided to combine a lot of business logic into common APIs without separating who is interacting with the endpoint – buyer or supplier.
So you hit the API, it calls this or that view and then the view (using service layers) filters out the results based on which group this user belongs to.

On one hand this reduces the number of endpoints, routes and somewhat helps to reduce code duplication.

But on the other hand, when I have to refactor a method I have to mentally trace both entities interacting with this API which introduces a lot of complexity into the code logic.

To me code simplicity and “understandability” is more important than DRY – I can deal with code not being DRY by breaking out part of the code into modules or in the worst case by leveraging my RegEx skills together with pretty powerful “Search and Replace” functionality of PyCharm.

So is there a preferable way to design APIs in this regard?
Are there any advantages to combination of API’s that I’m not seeing?

design – How to combine data from multiple sources into the same object?

I’ve been running into a common pattern when requesting data from multiple sources:

  1. Have a list of objects from one source (e.g. a list of Cars) with an id property and a few other properties populated (e.g. make, model, year).

  2. Call some service (second source) with the list of Car ids to get data for a few other Car properties (e.g. lastOwner, lastPurchasedDate). The service returns list of CarSupplementalDatas that have the Car‘s id, lastOwner, lastPurchaseDate.

  3. Add data from the service (second source) to the object from the first (e.g. the CarSupplementalData to the Car data by:)

    for (Car car : cars) {
    
        for (CarSupplementalData supplemental : supplementals) {
    
            if (car.getId() == supplemental.getCarId()) {
    
                car.setLastOwner(supplmental.getLastOwner());
                car.setLastPurchaseDate(supplmental.getLastPurchaseDate());
            }
         }
    }
    

The problem is that this boilerplate code / pattern is repeated many times in my application. Ideally, I would like to get rid of the nested looping and checking if ids match.

The only way I know to eliminate the inner looping and id matching is to change the service (second source) to take only one Car id:

for (Car car : cars) {            
    CarSupplementalData supplemental = carSupplementalService.getData(car.getId());
    //I know I have the supplemental data for this car. No id matching needed.
    car.setLastOwner(supplmental.getLastOwner());
    car.setLastPurchaseDate(supplmental.getLastPurchaseDate());
}

When performance is not an issue, is this the way to handle this pattern? When performance is an issue, is there some better way to avoid the boilerplate code induced by this pattern?

software – How can I combine multiple cameras into one?

I have recently read the book “Eyes In The Sky” which talks about WAMI systems (wide-area motion imagery). I was wondering how I would go about doing what was done for one of the Gorgon Stare prototypes, that being taking multiple phone cameras and have them all feed to a computer to be stitched together (basically it’s like taking a large panoramic image in one photo). How could I connect a camera module to a computer or something like raspberry pi?