design – How to properly implement Rest Controllers to handle overlapping entities?

I have:

  • A User entity.
  • A Poll entity.

Relationship: User creates polls.

Use-case:
When an arbitrarily user is clicked his/her profile is loaded and shown.
The profile includes a list of polls created by the clicked user.

Which of the following api calls is the proper usage of such a use-case?

  1. website.com/api/users/{username}/polls
  2. website.com/api/polls?username=xxx

Between The Lines:
I currently have a UserController & a PollController.

PollController has:

  • getPolls()
  • createPoll()
  • getPollById()

UserController has functions related to the user, handles api calls starting with /api/users/…

I am trying to figure out which controller should handle the request to get polls by a user.

A script to record oculus rift touch controllers and macro the recorded motion to a number on the number pad

i have a question about recording a specific input from the oculus rift touch motion controllers. is there any way to record a certain movement the the motion controllers make then click a button and have that recording assigned to a keyboard button to allow you to simply push the assigned button and have the recorded motion played back instantly?

For games with controllers (ps4, xbox) for fighter games was it intended to use the d-pad to move and do combos or the joystick?

I have been told to ask my question on this site instead.
Recently I have many people telling me for Mortal Kombat that I should always use the d-pad to move, while I have always been using the joystick.

(for own curiosity) Was the original intention to use the d-pad, and do most people use it as well?

API controllers modeling

I’m developing an API with ASP.NET, but I’m having some questions about the best way I should develop the controller layer for the products.

I’m having these questions because each product will have its own service and its own purchase path, so product1 might have a step 1, step 2 and step 3 to buy and product2 might have another step 1, another step 2 and so on.

But I think it’s not interesting that my frontend has an if(Productid = 1){post("http://url/product1")}else{post("http://url/product2")} I believe it would be better if my frontend just make a post("http://url/product") call and on the backend side I forward the data to the correct service.

I would like to know if there is a cleaner and more sustainable way to develop my API structure and that for each new product I don’t need to add one more if(Productid==3) to direct to the correct route in the frontend but I still don’t have the knowledge of how to best structure this.

Override PS4’s Dualshock Controllers in system controls (Windows 10)

Windows 10. PS4 Dualshock controller. This is not for Unity but for the operating system as a whole.

I want the “O” to be “pressed” if it’s y-axis measures more than 6m/s². (PS4’s built-in accelerometer)

I want that condition to be applied in every game I play BUT the game still sees it as “O”

Is this possible? I am a beginner by the way. Thank you all for your answers. enter image description here

rigidbody – How to Get VR Controller’s Velocity in Unity with SteamVR?

Back when I used Unity 2017 and controller bindings weren’t a thing, I simply attached a rigidbody to my Vive controller and read out the velocity of the rigidbody to know how fast the player was swinging the controller. Now, I’ve updated to Unity 2021.2.0a14, I went through all the effort of modifying my code to work with bindings, and it doesn’t seem like I can get velocity anymore. The rigidbody always reports zero velocity. I can see the World Center of Mass vector changing so I know it registers motion, but it’s just not reporting the velocity anymore. Is there a new setting in Unity I need to turn on to measure things that it doesn’t personally control? Or do the new bindings options have a way to get velocity as an input? Am I forced to calculate it myself now? Thanks!

python – Problema na importação no Flask (Unable to import ‘controllers’ pylint(import-error)

Boa noite, estou começando a programar agora e estou tentando fazer um sistema simples usando o framework Flask, porém durante a organização dos arquivos me deparei com o problema do título, não estou conseguindo importar o default localizado na pasta controllers, onde que eu estou errando?organização do sistema e onde o erro de import está aparecendo

php – Laravel – Naming of models, tables and controllers (when they are related)

I am currently building a system to manage my rental properties, and I am in a bit of a doubt when it comes to naming conventions…

Suppose I have the below setup

  • Properties (A property can have many leases)
  • Leases (A lease belongs to a property)
  • Tenants (A tenant belongs to a lease)
  • Charges (A charge belongs to a lease)

I have currently named it like this:

Model Name | Database Table Name | Controller Name
-----------|---------------------|-----------------------------
Property   | properties          | PropertyController
Lease      | leases              | LeaseController
Tenant     | tenants             | LeaseTenantController
LeaseCharge| lease_charges       | LeaseChargeController

Now I haven’t really given much thought into how I should name these things. But looking at the above, I can now see that I am not following one clear convention.

My question here is, how models/tables/controllers should be named, when they are related to another model.

For example both Tenant and Charge belongs to a lease (and can only exist if they have a lease_id), but should this be made explicit in the naming of the model, database and controllers? Or can these nouns stand alone? E.g.:

Model Name | Database Table Name | Controller Name
-----------|---------------------|-----------------------------
Property   | properties          | PropertyController
Lease      | leases              | LeaseController
Tenant     | tenants             | TenantController
Charge     | charges             | ChargeController

c# – Controllers calling business services – With or without the service locator pattern

I was reading on Constructor injection behavior (ms docs)

I currently have a Transient EmailSenderService that is registered in the DI container.

I have a controller that invokes several business-layer services. One of those business services has a EmailSenderService Dependency, where an email is sent after several business operations are successful.

  • EmailSenderService – Registered in Asp.net Core DI container
  • ControllerA – Controller that calls business services
  • BusinessServiceA – Has a dependency of EmailSenderService

I am trying to figure out the best approach here… should my controller require IServiceProvider as a dependency so I can directly instantiate my BusinessServiceA (with its EmailSenderService dependency) using something like ActivatorUtilities?

If not using the IServiceProvider (service locator pattern), then what are the other options?

Recap:

I have an email provider that I don’t inject to my controllers, but business services that are called by my controllers use that email provider which is registered with the DI container, so instead of specifying my email provider as a dependency in my controller and passing it to data services, would just using GetServiceOrCreateInstance(IServiceProvider) directly be the best approach here?