tag removed – Equivalence classes properties proof, when [a] ∩ [b] ̸= ∅ then [a] = [b]?

Fix an inetger n > 1. Let R ⊆ Z × Z be the equivalence relation on Z defined by
R = {(a, b) : a = b + kn for some k ∈ Z}. Recall, for a ∈ Z we have (a) = {b ∈ Z : (a, b) ∈ R}.
Fix a, b ∈ Z show that if (a) ∩ (b) ̸= ∅ then (a) = (b) as follows:
(i) What does (a) ∩ (b) ̸= ∅ mean?
(ii) If x ∈ (a) then there is y ∈ (b) such that (x,y) ∈ R; deduce that (a)⊆(b)
(iii) Repeat argument of (ii) to show that (b) ⊆ (a).

gr.group theory – Conjugacy classes in reductive group under adjoint action of parabolic subgroup

Given a reductive group $G$ over a finite field and a parabolic subgroup $P$ , I wonder what are the orbits in $G$ under the adjoint action of $P$. This should be standard, but I can only find results on the orbits inside $P$.

Actually, I would like to know which (say) permutation representations of the parabolic $Pto operatorname{Sym}(Omega)$ admit an extension to a $P$-equivariant map of sets $Gto operatorname{Sym}(Omega)$. But I do not know in which context this question falls.

I would already be very happy for an answer in the case $G=operatorname{GL}_3(mathbb{F}_p)$ and the $(2,1)$– parabolic $P=(operatorname{GL}_2(mathbb{F}_p)times operatorname{GL}_2(mathbb{F}_p))ltimes mathbb{F}_p^2$. I want to play around with a group-theoretic version of connection and parallel transport on the Grassmanian $operatorname{Gr}(3,2)$ over $mathbb{F}_p$.

Thanks and greetings,

8 – How can I get list of classes implementing particular interface?

I need to have a list of classes implementing Drupal 8 User Auth Interface & be able to reference a particular implementation class (such as Facebook Auth). How do I do this please? I don’t want to directly modify the core Drupal 8 User Auth class which is currently the only class implementing the User Auth Interface.

How to get list of classes implementing particular interface in Drupal 8?

I need to have a list of classes implementing Drupal 8 User Auth Interface & be able to reference a particular implementation class (such as Facebook Auth). How do I do this please? I don’t want to directly modify the core Drupal 8 User Auth class which is currently the only class implementing the User Auth Interface.

c# – How to properly format classes for JSON deserialization with JSON.net for Unity?

I am creating an inventory system and decided to keep a master list of all the items. The goal is to use JSON.net to parse the item list and populate the database of items. The JSON item list looks like:


        "Consumables": {
            "0" : {
                "ID" : "TP_Small",
                "Icon" : "Sprites/porridge.png",
                "Name" : "Small Tan Pill's Porridge",
                "Consumable" : true,
                "Cooldown": 0,
                "Duration": 3,
                "Effect Description" : "Restores 100 health.",
                "Description" : "A hearty drinkable meal from everyone's favorite hypercellulose gelatin timelord!!!",
                "SFX": "{eb4e9ad8-c6ac-414f-8d5e-c3d012ca6ae6}",
                "Bonuses" : {
                    "HP": 100,
                    "Stamina": 100,
                    "Tolerance": 20,
                    "Attack": 4


        "Equipment": {

        "Abilities" : {


And this is the structure of the classes we are using to match the JSON:

    public class Items
        public List<ItemCategory> type { get; set; }

    public class ItemCategory
        public List<ItemBase> id { get; set; }

    public class ItemBase
        string ID { get; set; }
        string Icon { get; set; }
        string Name { get; set; }
        bool Consumable { get; set; }
        int Cooldown { get; set; }
        int Duration { get; set; }
        string EffectDescription { get; set; }
        string Description { get; set; }
        string SFX { get; set; }
        StatBonus Bonuses { get; set; }

    public class StatBonus
        int HP { get; set; }
        int Stamina { get; set; }
        int Tolerance { get; set; }
        int Attack { get; set; }

However, when I use the debugger, it seems everything but the root class is null and the root class’s value is the “InventoryItems+items”, with InventoryItems being the name of the file.

How can I access an item by it’s number in the list? So items -> Consumables -> 0 and that element’s fields

The deserialization code:

TextAsset json = Resources.Load<TextAsset>("itemList");

        itemList = new Items();

        itemList = JsonConvert.DeserializeObject<Items>(json.text);

        foreach(ItemCategory cat in itemList.type)
            foreach(ItemBase b in cat.id)

c# – Best practice when handling conditions and results within classes?

The method below needs to perform a set of operations in order to achieve a result. Neither the operations nor the result are relevant to the question. As you can see some smaller simpler operations have been split out into smaller private methods. I have left out the params and details for simplicity.

In my opinion the method is too big and would seem prone to bugs, however on the other hand I think its fairly clean and neat considering these operations must happen and the user needs to know if something hasn’t worked out. Its also my opinion that its fairly readable but i feel like i might be missing something.

Is there a better, more SOLID approach to handling this, or is this about as clean as it gets?

This class itself does nothing except coordinate a few services as shown below and return some feedback.
For a moment I considered the class may be ‘doing’ too much, but I am unable to see how splitting this further will result in cleaner code. in the end there is still going to be a class that needs to coordinate everything.

public Result AddSomething()
     var data = await _repo.Get<Data>();

     if (data.PropertyA) 
         return new Result().Fail("Fail message");  //1

     if (ConditionA(data ) && data.PropertyB) 
         return new Result().Fail("Another fail message");    //2

     SomeClass someClass = CreateSomeClass();


     var resultOne= _serviceA.Execute(someClass);

     if (resultOne.IsOk == false)
         return new Result().Fail(resultOne.Message);   //3

     var resultTwo = _serviceB.Execute(someClass);

     if (resultTwo .IsOk == false)
         return new Result().Fail(resultTwo .Message);    //4


     SetMorePropsTwo(someClass, data);

     await CompressAndSave(someClass, data);


     await _repo.CreateOrUpdate(data);

     await _repo.SaveChangesAsync();

     await _eventService.LogEvent(o => //some info taken from data);   

    return new Result().Ok("It all worked out");   //5

private SomeClass CreateSomeClass()()

private void SetPropsOnSomeClass(//)

private void SetMoreProps(//)

private void SetMorePropsTwo(//)

private async Task CompressAndSave(//)
    await _serviceC.Add(//);
    await _serviceC.Compress(//);
    await _serviceC.Save(//);

And an over simplified version of the Result class:

public class Result
    public bool IsOk {get; private set;}
    public string Message {get; private set;}

    public Result Ok()
        IsOk = true;

    public Result Fail(string message)
        IsOk = false;
        Message = message;



Is there a cleaner, more SOLID approach to handling these situations?

I cannot seem to find a solution that sits well with me. Perhaps I am over thinking the problem or I simply lack the knowledge to implement a more ‘correct’ and clean approach.

PS. I understand ‘correct’ is subjective but I am looking to improve my code in as many possible ways provided it offers enough value to the next developer.

c# – Retornar uma instância inserida pelo DI do .net core em outras classes fora do construtor

Bom dia!

Gostaria de saber se há a possibilidade de retornar uma instância inserida pelo IServiceCollection do DI no .net core em qualquer outro local do sistema.

Por exemplo:

Em meu Startup.cs, inicio uma classe padrão de comunicação com o banco de dados (classe abaixo – os dados de conexão foram suprimidos):

 public class MongoConnector
    private readonly IMongoDatabase mongoDatabase;

    public MongoConnector()
      mongoDatabase = new MongoClient("").GetDatabase("");  

    public IMongoDatabase getDatabase(){
      return mongoDatabase;


  public class Startup
    public Startup(IConfiguration configuration)
      Configuration = configuration;

    public IConfiguration Configuration { get; }

    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)

Após isto, estou construindo alguns factories que deverão receber esta mesma instância já inicializada no Startup.cs. Em algumas funcões deste factory, eu necessito do MongoConnector, como abaixo, para realizar as minhas regras:

    public string getSourceByToken() {
      var database = MongoConnector.getDatabase();

Não posso utilizar pelo construtor pois o factory que possui o evento acima será inicializado através de outra classe do sistema, e que não também não possuir relação com o DI. Sem falar que não gostaria de inicializar TODAS as classes do sistema no DI do Startup, e muito menos ficar passando parâmetros desde o Controller.

Alguém poderia me ajudar?


object oriented – Resource management classes in C++ game

This is a part of simple sfml C++ game, but I think neither the library nor the language is that much crucial here. I am mainly worried about the design.

I have a class template ResourceHolder<Key, Resource> to hold one type of Resource such as texture or sound, inside a map. A key is usually an enum but can be anything.

I also have a class ResourceManager that keeps all available ResourceHolders in one place.

A simplified class diagram:

enter image description here

I am providing the full code for those classes:


template <typename Key, typename Resource>
class ResourceHolder {
    explicit ResourceHolder(std::string resourcesDir = "../resources/")
            : resourcesDir{std::move(resourcesDir)}

    template <typename... Args>
    void insert(const Key& key, Args&&... args) {
        auto resPtr = std::make_unique<Resource>();
        if (!resPtr->loadFromFile(resourcesDir + std::forward<Args>(args)...)) {
            ///* todo: should I e.g. "throw ErrorLoadingResource" here? */
        resources.emplace(key, std::move(resPtr));

    Resource& get(const Key& key) const {
        if (auto resource = resources.find(key); resource != std::end(resources)) {
            return *(resource->second);
        } throw std::invalid_argument{"No such resource id."};

    void erase(const Key& key) noexcept {
        if (auto found = resources.find(key); found != std::end(resources)) {

    void eraseAll() {

    std::string resourcesDir;
    std::unordered_map<Key, std::unique_ptr<Resource>> resources;

    template <typename... Args>
    ResourceHolder& operator+=(const ResourceInserter<Key, Args...>& inserter) {
        insert(std::move(inserter.key), std::move(std::get<Args>(inserter.args)...));
        return *this;

    inline const Resource& operator()(const Key& key) const {
        return get(std::move(key));

    inline Resource& operator()(const Key& key) {
        return get(std::move(key));

    auto& getResources() const {
        return resources;

    auto& getResourcesDir() const {
        return resourcesDir;

    void setResourcesDir(std::string newPath) {
        resourcesDir = std::move(newPath);

    template <typename... Args>
    void msgErrorLoading(const Args... args) {
         std::cerr << "Failed loading resource: { Type: "" << typeid(Resource).name()<< "", File name: "";
        (std::cerr << ... << args) << "" }" << std::endl;


class ResourceManager {

    ResourceHolder<res::Texture, sf::Texture> textures;
    ResourceHolder<res::Sound, sf::SoundBuffer> sounds{"../resources/sound/"};

    void loadTextures();
    void loadSounds();

    auto& getTextures() {
        return textures;

    auto& getSounds() {
        return sounds;


ResourceManager::ResourceManager() {

void ResourceManager::loadTextures() {
    textures.insert(res::Texture::Wizard, "wizard.png");
    textures.insert(res::Texture::Gray,   "gray.png");
    textures.insert(res::Texture::Orange, "orange.png");

void ResourceManager::loadSounds() {
    sounds += ResourceInserter(res::Sound::Bullet, "boing.wav");
    sounds += ResourceInserter(res::Sound::Bing,   "boing_long.wav");
    sounds += ResourceInserter(res::Sound::Poof,   "poof.wav");


/** Operator += must take one argument
 *  This is a proxy class for operator+=
 *  You can use operator+= instead of insert() as an alternative insertion method

template <typename Key, typename... Args>
class ResourceInserter {
    explicit ResourceInserter(Key&& key, Args&&... args)
            : key{std::forward<Key>(key)}
            , args{std::forward<Args>(args)...}

    Key key;
    std::tuple<Args...> args;

template <typename T, typename... Args>
ResourceInserter(T&&, Args&&... args) -> ResourceInserter<T, Args...>;


namespace res {
    enum class Texture {

    enum class Sound {

Some basic usage (inside parent/caller/owner class):

auto wizardTexture = textures.get(res::Texture::Wizard);
auto bulletSound   = sounds(res::Sound::Bullet);

I am not asking for a deep-throughout review as I imagine it’d take too much off of your time.

I have few questions, answering any of them would be absolutely helpful.

  1. Whatever you think of that looks smelly or problematic, please do let me know.
  2. What’s wrong with my design from OOP/design patterns point of view? (I am especially worried about the part where I am inserting all the resources inside ResourceManager.cpp)
  3. What’s wrong with my code from C++ point of view? (I am especially interested in parts where I attempted using move semantics/perfect forwarding e.g. insert method or operator+=)
  4. Is there something confusing related to naming identifiers?

The reason why I am using enums as keys is that it works as a sort of connection interface for both insertion and then retrieval of the resource. If I insert a resource of key Enum_Type::Enum_Item, then I can also retrieve it using the same key.

I’d rather not hardcode the insertion process inside ResourceManager.cpp, and preferably keep it in a separate file, but the fact that I am using Enum as a key is kind of an obstacle here for me. Not sure how to fix it.

Thanks a lot!

web development – PHP: What code should be removed to its own helper class and where should such classes be located in the filesystem?

The following is an example requesting an explanation for one specific file in one specific filesystem, not helper classes generally.

I have configured a LEPP stack on a CentOS server. The server hosts an API which is built using Slim PHP Framework. There is an official skeleton repo on Slim’s github.

The repo has a basic file structure which is clearly defined as follows:

│   ├───Actions
│   │   ├───User
│   │   │   ├───ListUsersAction.php
│   │   │   ├───UserAction.php
│   │   │   └───ViewUserAction.php
│   │   ├───Action.php
│   │   ├───ActionError.php
│   │   └───ActionPayload.php
│   ├───Handlers
│   │   ├───HttpErrorHandler.php
│   │   └───ShutdownHandler.php
│   ├───Middleware
│   │   └───SessionMiddleware.php
│   └───ResponseEmitter
│       └───ResponseEmitter.php
│   ├───DomainException
│   │   ├───DomainException.php
│   │   └───DomainRecordNotFoundException.php
│   └───User
│       ├───User.php
│       ├───UserNotFoundException.php
│       └───UserRepository.php
│   └───Persistence
│       └───User
│           └───InMemoryUserRepository.php

I have added my own endpoints to this, for example a ‘ViewWordAction’ class which utilises a ‘PostgresWordRepository’ class and returns dictionary definitions for a single word found within a database table when the /dict?word={word} endpoint.

This action is excluded from the file structure for clarity. There are various other endpoints which I will add, used to analyse word data.

I have a separate class called ‘RegExHelper’ which separates punctuation, recognises ends of sentences and other similar functions. In previous versions of my application, the file structure was a mess and did not follow proper conventions, so this and similar classes were stored in a ‘Helper’ folder within the src directory. This class will be shared amongst various other classes across multiple endpoints.

I would like to know where to store this helper class and which naming conventions to use. I presume that the class should be refactored as ‘RegExHander’ and stored in a src/Application/Handlers/RegEx directory, although I cannot find any guides or documentation which explain the proper file structure for this example.

Are any two complexity classes equipped with an oracle to solve the halting problem equivalent?

Thanks for contributing an answer to Computer Science Stack Exchange!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.

To learn more, see our tips on writing great answers.