class feature – Can you use Arcane Bond to cast a spell with a long cast time?

The Drain United Object action says:

During your turn, you get the ability to cast a spell you prepared
today and already issued (Core 205)

Does this mean you can't use this to cast any spells you can't end in a turn? Or is it enough to start casting the spell on that turn? Or can you use this action on the turn you end the spell?

Magento2 Stripe Extension returns: Error not detected: Class & # 39; Stripe PaymentIntent & # 39; Not found

I have installed the Magento2 Stripe extension by following this guide:

The extension is active and I have configured Stripe to send test data. The problem is when I go to the checkout and order the next call to http://app.test/rest/default/V1/guest-carts/oza7bFkKh19JjTYedtbp9AyuneWJjtc9/payment-information returns an error:

Fatal error: Uncaught Error: Class 'StripePaymentIntent' not found in C:laragonwwwappcodeStripeIntegrationPaymentsModelPaymentIntent.php:149 Stack trace: #0 C:laragonwwwappcodeStripeIntegrationPaymentsModelPaymentIntent.php(612): StripeIntegrationPaymentsModelPaymentIntent->create(Object(MagentoQuoteModelQuoteInterceptor), Object(MagentoSalesModelOrderPaymentInterceptor)) #1 C:laragonwwwappcodeStripeIntegrationPaymentsModelPaymentMethod.php(232): StripeIntegrationPaymentsModelPaymentIntent->confirmAndAssociateWithOrder(Object(MagentoSalesModelOrderInterceptor), Object(MagentoSalesModelOrderPaymentInterceptor)) #2 C:laragonwwwgeneratedcodeStripeIntegrationPaymentsModelPaymentMethodInterceptor.php(50): StripeIntegrationPaymentsModelPaymentMethod->capture(Object(MagentoSalesModelOrderPaymentInterceptor), '59.98') #3 C:laragonwwwvendormagentomodule-salesModelOrderPaymentOperationsCaptureOperation.php(82): StripeIntegrationPaymentsModelPaymentMethod in C:laragonwwwappcodeStripeIntegrationPaymentsModelPaymentIntent.php on line 149
{"messages":{"error":({"code":500,"message":"Fatal Error: 'Uncaught Error: Class 'Stripe\PaymentIntent' not found in C:\laragon\www\app\code\StripeIntegration\Payments\Model\PaymentIntent.php:149nStack trace:n#0 C:\laragon\www\app\code\StripeIntegration\Payments\Model\PaymentIntent.php(612): StripeIntegration\Payments\Model\PaymentIntent->create(Object(Magento\Quote\Model\Quote\Interceptor), Object(Magento\Sales\Model\Order\Payment\Interceptor))n#1 C:\laragon\www\app\code\StripeIntegration\Payments\Model\PaymentMethod.php(232): StripeIntegration\Payments\Model\PaymentIntent->confirmAndAssociateWithOrder(Object(Magento\Sales\Model\Order\Interceptor), Object(Magento\Sales\Model\Order\Payment\Interceptor))n#2 C:\laragon\www\generated\code\StripeIntegration\Payments\Model\PaymentMethod\Interceptor.php(50): StripeIntegration\Payments\Model\PaymentMethod->capture(Object(Magento\Sales\Model\Order\Payment\Interceptor), '59.98')n#3 C:\laragon\www\vendor\magento\module-sales\Model\Order\Payment\Operations\CaptureOperation.php(82): StripeIntegration\Payments\Model\PaymentMethod' in 'C:\laragon\www\app\code\StripeIntegration\Payments\Model\PaymentIntent.php' on line 149","trace":"Trace is not available."})}}

I can see in Stripe's webhook records that payment is also being received.

Did I miss something during the installation step that is causing this to happen?

Programming languages: Have Java inventors publicly expressed their regret for hashCode and equals in the Object class?

I was talking to a colleague recently about hashCode and it is the same as methods in the Object class in Java (among other languages). I am of a more theoretical formation, while my colleague is more a pragmatic person.

In my opinion, it makes no sense to have the hashCode and the same methods defined in the Object class. While our personal discussion was quite fun, I am more interested in an official retrospective on this subject of the original inventors of Java. Have you ever publicly expressed your regret for having made the decision? Or have they explicitly defended their decision against criticism in public?

Public statements from people other than the original developers are also welcome, but only from people with at least some level of authority and notoriety.

Thanks in advance!

Java: how to modify a method that dynamically invokes a set of several secondary classes to work for any new secondary class

The following method is used to add objects to a polymorphic array of a file.

Read lines from the file and, based on a specific line that denotes the category of the product object, use the loadFromFile () method of the specific class, before moving on to the next one. We are taught to build programs in a way that allows for future functionality, so I would like to find a way to modify this so that if a new secondary class were created, I would be able to detect that and call the method of that class. instead of the developer needing to add to the switch box every time.

Each secondary class has slightly different attributes, therefore, why this is necessary. I am looking for a more sophisticated and future-proof method.

public void loadFromFile(String fileName) throws FileNotFoundException, IOException, ParseException{
Filename = fileName;
String record;

FileReader reader;

reader = new FileReader(Filename);
BufferedReader bin = new BufferedReader(reader);
record = new String();

while ((record = bin.readLine())!=null)

    case "Electronic":
      ElectronicProduct eProduct = new ElectronicProduct();          

    case "Kitchen":
      KitchenProduct kProduct = new KitchenProduct();          

    case "Food":
      FoodProduct fProduct = new FoodProduct();          

    case "Book":
      BookProduct bProduct = new BookProduct();          

bin =null;    


javascript: is there any better and shorter way to write this code to toggle the css class in voting?

I have this jquery handled buttons. But I think I did it with the if else statements.

I wonder if the code can be more efficient in any way than what I have.

He is mainly voting up and down. So what it does is toggle buttons and insert html

function handleVote(commentid, voted, type){
      url: endpoint + commentid + "/update/",
      method: "PATCH",
      data: { commentid: commentid, voted: voted,  type: type},
      success: function(data){
        if(type === 'down' && voted === 'True'){
          $('.comment-item .down-vote .i-down-'+commentid+'').toggleClass('active-color');
          $('.comment-item .down-vote .i-down-'+commentid+'').toggleClass('opacity-initial');
          $('.comment-item .down-vote .i-down-'+commentid+'').css('opacity', '0.2')
        } else if(type === 'down' && voted === 'False'){
          $('.comment-item .down-vote .i-down-'+commentid+'').toggleClass('active-color');
          $('.comment-item .down-vote .i-down-'+commentid+'').toggleClass('opacity-initial');
        } else if(type === 'up' && voted === 'True'){
          $('.comment-item .up-vote .i-up-'+commentid+'').toggleClass('primary-color');
          $('.comment-item .up-vote .i-up-'+commentid+'').toggleClass('opacity-initial');
          $('.comment-item .up-vote .i-up-'+commentid+'').css('opacity', '0.2')
        } else if(type === 'up' && voted === 'False'){
          $('.comment-item .down-vote .i-up-'+commentid+'').toggleClass('primary-color');
          $('.comment-item .down-vote .i-up-'+commentid+'').toggleClass('opacity-initial');

        $(".comment-vote-down .vote-count-down-" + commentid +"").html(`-${data.num_vote_down}`);
        $(".comment-vote-up .vote-count-up-" + commentid +"").html(`+${data.num_vote_up}`);
      error: function(data){
        var msg = formatErrorMsg(data.responseJSON)
        $("(data-id='" + commentid + "')").closest('div .comment-wrapper').after(msg);

Object-oriented: when is it appropriate to introduce a new abstraction layer in a class hierarchy?

Suppose I am creating a game played on a 2D coordinate grid. The game has 3 types of enemies that move in different ways:

  • Drunkard: moves using type 1.
  • Mummy: moves using type 1 movement, except when it is close to the main character, in which you will use type 2 movement.
  • Ninja: moves using type 3 movement.

These are the ideas that came to mind when organizing the class hierarchy:

Proposal 1

A single base class from where each enemy derives from:

abstract class Enemy:
    public show()   // Called each game tick
    public update() // Called each game tick
    abstract move() // Called in update

class Drunkard extends Enemy:
    private move() // Type 1 movement

class Mummy extends Enemy:
    private move() // Type 1 + type 2 movement

class Ninja extends Enemy:
    private move() // Type 3 movement


  • Viola DRY since the code is not shared between Drunkard Y Mummy.

Proposal 2

Same as proposal 1 but Enemy does more:

abstract class Enemy:
    public show()            // Called each game tick
    public update()          // Called each game tick
    private move()           // Tries alternateMove, if unsuccessful, perform type 1 movement
    abstract alternateMove() // Returns a boolean

class Drunkard extends Enemy:
    private alternateMove(): return False

class Mummy extends Enemy:
    private alternateMove() // Type 2 movement if in range, otherwise return false

class Ninja extends Enemy:
    private alternateMove() // Type 3 movement and return true


  • Ninja It doesn't really just have one movement, so it doesn't really have an "alternative movement." So, Enemy It is a poor representation of all enemies.

Proposal 3

Expanding proposal 2 with a MovementPlanEnemy.

abstract class Enemy:
    public show()   // Called each game tick
    public update() // Called each game tick
    abstract move() // Called in update

class MovementPlanEnemy:
    private move() // Type 1 movement
    abstract alternateMove()

class Drunkard:
    private alternateMove() // Return false

class Mummy:
    private alternateMove() // Tries type 2 movement

class Ninja:
    private move() // Type 3 movement


  • Ugly and possibly oversized.


Proposition 1 is simple but has a lower level of abstraction. Proposition 3 is complex but has a higher level of abstraction.

I understand all about the "composition about inheritance" and how it can solve this whole disaster. However, I have to implement this for a school project that requires us to use inheritance. So, given this restriction, what would be the best way to organize this class hierarchy? Is this just an example of why inheritance is inherently bad?

I guess since my restriction is that I have to use inheritance, I'm really asking the broader question: In general, when is it appropriate to introduce a new abstraction layer at the expense of complicating the architecture of the program?

Edit: updated title.

8 – You cannot set a default theme in a FunctionalJavascript test with class property $ defaultTheme

Trying several ways here to set a default theme to use in the FunctionalJavascript tests and it doesn't work (I'm seeing how they run in the VNC viewer). Bartik always shows.

I also tried to set $ defaultTheme to stark, does not appear either. It's always Bartik. According to the class and the documents, this is compatible.

How can I make my theme default and load? This is the class that my FunctionalJavascript class tests extend:

abstract class WebDriverTestBase extends CoreWebDriverTestBase {

   * {@inheritdoc}
  protected $defaultTheme = 'MYTHEME';

  protected $profile = 'standard';

   * {@inheritdoc}
  protected $strictConfigSchema = FALSE;

   * {@inheritdoc}
  protected function setUp() {
    $this->container->get('theme_installer')->install(('MYTHEME'), TRUE);
    $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'MYTHEME')->save();

object-oriented – OOP paradigm in python – Extend class functionalities

I am a newbie in Python and I am trying to understand how to use the OOP paradigm to improve my scripts. My scripts generally read some data from a formatted csv file and perform some numerical analyzes. Here is a brief example:


This entry is for a script to solve a structural analysis problem. In general, you may want to extend the functionality of the script by adding new features, for example, adding elements, materials, section properties, etc.

My idea is to configure the code in such a way that one can include these functionalities in the easiest possible way.

My solution is to create a class and then extend it using inheritance. Here what I wrote so far:

  • A class for problem properties, called Mesh
  • Two initial instance variables that store the name of the input file and the title (first row of the csv file)
  • A method to read information from the file, called read_input
class Mesh() :
    'class defining the property of the problem'

    def __init__(self) : = None
        self.title = None

    def read_input(self, input_name) : = input_name
        with open( as file :
            self.title = file.readline()

Let's say that one may want to improve the script by including the number of nodes (NODES in the csv file). First I create a class for the node, storing ID and coordinates:

class Node() :
    'class for defining a node'

    def __init__(self, input1 , input2 , input3) :
        self.ID = int(input1)
        self.x = float(input2)
        self.y = float(input3)

Then I add "functionalities" to the class that defines a new secondary class (with the same name of the primary class, because I don't really need a new secondary class, just a redefinition of the initial Mesh class). The new class says:

  • New constructor, using super () to include the constructor of the main class and the new instance variables.
  • Redefinition of the read_input method to include the new lines of the csv file.
class Mesh(Mesh) :
    'Mesh that includes nodal loads'

    def __init__ (self) :
        self.Nnodes = None
        self.nodes = list()

    def read_input(self, input_name) :
        with open( as file :
            while not file.readline().startswith('NNODES') : continue
            self.Nnodes = int( file.readline() )
            for node in range(0,self.Nnodes) :
                ID , x, y = file.readline().split(',')
                self.nodes.append( Node( ID , x, y ) )

Finally, the initialization of the class and the use of the method to read the file:

input = Mesh()

Here my doubts:

  • Is it a good application of the OOP paradigm or have I completely misunderstood the concept?
  • Does it make any sense to call the secondary class with the same name as the primary class? (I didn't find any example in previous questions)
  • Is it a good way to structure the code? Maybe other people than me will modify the code in the future, and I would like to simplify this procedure as much as possible.

I have always used procedural languages, such as C and FORTRAN, and I have no experience in the OOP paradigm.

I modified the code with StackOverflow suggestions

  1. Modification of the class. Mesh, in this way, it must be autonomous.
  2. Class name son different from father.
  3. Use of the data class to define the Node class.


from dataclasses import dataclass

class Mesh() :
    'class defining the property of the problem'

    def __init__(self , input1) :
        self.title = input1

name = 'input_short.txt'''
with open(name) as file :
    mesh1 = Mesh( file.readline() )

#let's add a new functionality
class Node:
    'class for defining a node'

    ID: int
    x: float
    y: float

class Mesh_nodes(Mesh) :
    'Extend Mesh class to account for nodes'

    def __init__(self , input1, input2, input3) :
        self.Nnodes = input2
        self.nodes = input3

name = 'input_short.txt'''
with open(name) as file :
    while not file.readline().startswith('NNODES') : continue
    Nnodes = int( file.readline() )
    nodes = list()
    for node in range(0,Nnodes) :
        ID , x, y = file.readline().split(',')
        nodes.append( Node( int(ID) , float(x), float(y) ) )

mesh1 = Mesh_nodes(name,Nnodes,nodes)

Anyway, my original questions are still valid:

  • Is it a good application of the OOP paradigm or have I completely misunderstood the concept?

  • Is it a good way to structure the code? Maybe other people than me will modify the code in the future, and I would like to simplify this procedure as much as possible.

c # – Better representation of the class type / instance, as opposed to the use of enum

I want to represent the "state" of a thing and use a static representation to refer to it throughout the code. The best representation for this would be an enumeration, but I need polymorphism, so I came up with this:

public interface IStatus {}

public abstract class StatusBase : IStatus where T : StatusBase, new()
    public static T Instance = new T();

public class ActionRelatedStatus : StatusBase {}
public class MovingStatus : ActionRelatedStatus {}

public class LifeRelatedStatus : StatusBase {}
public class HungryStatus : LifeRelatedStatus {}

public class Main
    public IStatus() GetStatuses() { /* ... */ return null; }
    public void AnalyzeLifeStatus(LifeRelatedStatus status) { /* ... */ }
    public void PerformAction(ActionRelatedStatus status) { /* ... */ }
    public void MainMethod()
        var statuses = GetStatuses();

the Main class illustrates the requirements that I have:
– have different "types" of states, such as LifeRelatedStatus Y ActionRelatedStatus that may or may not be together in the same application / software;
– be able to operate in states without knowing the type, such as GetStatuses();
– be able to operate in a specific type of state, such as ActionRelatedStatus or LifeRelatedStatus.

And here comes the part I don't like very much: I am using a static StatusBase instance as a way of referring to a particular state, as in PerformAction(MovingStatus.Instance);.

I could get rid of all the complexity of StatusBase if it operated types of states, but I don't like the idea of ​​using typeof all the time (like PerformAction(typeof(MovingStatus))and, what is worse, lose type security (public void PerformAction(Type type))

Is there a better way to do this?

python – Decorator to instantiate the class in another process


I want to execute some heavy computing tasks in a separate process, so that they do not monopolize the GIL and can make effective use of a multi-core machine.

Where those tasks are pure functions, I would only use the one provided multiprocessing.Pool. However, that does not work so well for the tasks that maintain the state. I will assume an example of a process that is doing data encryption on the fly and pumping it to a file. I would like the keys, the block chaining parameters and the open file identifier (which cannot be pickled and passed between processes) to reside as internal status of some EncryptedWriter object. I wish I could use the public interface of that object in a completely transparent way. But I would like that object to reside in the external process.


To that end, this code creates a decorator @process_wrap_object It involves a class. The new class will generate an external process to instantiate an object from the wrapped class. The external process then calls the methods in it in the required order and returns the associated return values. The coordination object that lives in the original process is responsible for resending these functions.

The function process_wrap_object It is the decorator itself, which takes a class and returns a class.

The function _process_wrap_event_loop it is the one that executes the work process, which is closely coupled to the process_wrap_object.

Finally the function _process_disconnection_detector just check if the process_wrap_object The coordination object has been destroyed, either by normal garbage collection or because the main process was blocked. In any case, you should instruct the work process to close cleanly.


Note that method calls are blocking, as are normal method calls. This means that, by itself, this container will not accelerate anything: it simply does the work elsewhere with more overhead. However, it effectively cooperates with the main process that is divided with a lighter thread within the process.


import inspect
from functools import partial
from multiprocessing import Process, Queue, Pipe
from threading import Thread

CLOSE_CODE = "_close"

def _process_disconnection_detector(pipe, instruction_queue):
    """Watcher thread function that triggers the process to close if its partner dies"""
    except EOFError:
        instruction_queue.put((CLOSE_CODE, (), {}))

def _process_wrap_event_loop(new_cls, instruction_queue, output_queue, pipe, *args, **kwargs):
    cls = new_cls.__wrapped__
    obj = cls(*args, **kwargs)

    routines = inspect.getmembers(obj, inspect.isroutine)
    # Inform the partner class what instructions are valid
    output_queue.put((r(0) for r in routines if not r(0).startswith("_")))
    # and record them for the event loop
    routine_lookup = dict(routines)

    disconnect_monitor = Thread(target=_process_disconnection_detector, args=(pipe, instruction_queue))

    while True:
        instruction, inst_args, inst_kwargs = instruction_queue.get()
        if instruction == CLOSE_CODE:
        inst_op = routine_lookup(instruction)
        res = inst_op(*inst_args, **inst_kwargs)


def process_wrap_object(cls):
    Class decorator which exposes the same public method interface as the original class,
    but the object itself resides and runs on a separate process.
    class NewCls:
        def __init__(self, *args, **kwargs):
            self._instruction_queue = Queue() # Queue format is ({method_name}, {args}, {kwargs})
            self._output_queue = Queue() # Totally generic queue, will carry the return type of the method
            self._pipe1, pipe2 = Pipe() # Just a connection to indicate to the worker process when it can close
            self._process = Process(
                args=((NewCls, self._instruction_queue, self._output_queue, pipe2) + list(args)),

            routine_names = self._output_queue.get()

            assert CLOSE_CODE not in routine_names, "Cannot wrap class with reserved method name."

            for r in routine_names:
                    partial(self.trigger_routine, routine_name=r)

        def trigger_routine(self, routine_name, *trigger_args, **trigger_kwargs):
            self._instruction_queue.put((routine_name, trigger_args, trigger_kwargs))
            return self._output_queue.get()

        def __del__(self):
            # When the holding object gets destroyed,
            # tell the process to shut down.

    for wa in ('__module__', '__name__', '__qualname__', '__doc__'):
        setattr(NewCls, wa, getattr(cls, wa))
    setattr(NewCls, "__wrapped__", cls)

    return NewCls

Sample use:

class EncryptedWriter:
    def __init__(self, filename, key):
        """Details unimportant, perhaps self._file = File(filename)"""
    def write_data(self, data):
        "Details still unimportant, perhaps self._file.write(encrypt(data))"

writer = EncryptedWriter(r"C:UsersJosiahDesktopnotes.priv", 4610)
writer.write_data("This message is top secret and needs some very slow encryption to secure.")

I am looking for a general review of both the high-level approach and the particular implementation, with special interest in any subtlety around multiprocessing or the correct decorator wrapping for classes.

Any suggestions on the additional functionality that would make this decorator noticeably more useful are also welcome. One feature that I am considering, but not yet implemented, is the explicit support for __enter__ Y __exit__ work with with blocks