maven – Why am I getting `java.lang.AssertionError: Built-in class kotlin.Any is not found` when using `copy` in TeamCity DSL?

Background

I’m trying to create some Teamcity configuration using Kotlin. I’m using a Maven in Intellij when testing the generation of the Teamcity, although I get the same result by using the command mvn teamcity-configs:generate from the command-line.

Problem

The error is:

(ERROR) Runtime error RootProjectId: kotlin.reflect.jvm.internal.impl.builtins.KotlinBuiltIns$3(113): java.lang.AssertionError: Built-in class kotlin.Any is not found

A minimum example: https://gist.github.com/3761e6f3847db9f8f772c9e16663aaa9

Although I’ve taken steps to minimise the provided example, I’m no Maven expert and I’m not sure what else could have been shaved off the POM.xml file.

The problem seems to stem from an attempted use to copy (cf., 1) which seems to trip up Kotlin with some reflection issue. Remove the copy and the generation of the configs works fine.

Research

There are a few places around where this is discussed 2, but I can’t find any that match the issue I’m experiencing or suggest a solution which fixes it for me.

The most interesting one is 4, which is not relevant as it’s regarding moving from Kotlin versions 1.3.x to 1.4.x, however, the discussion has a little on the interdependence of kotlin-stdlib(...), kotlin-reflect and Java itself, from JetBrain developer “Udalov” 5. The details are over my head and may not be relevant here, but it’s the most technical answer I’ve seen addressing this issue.

What I’ve tried

I’ve tried adding kotlin-reflect as an explicit dependency and making sure that kotlin-stdlib-jdk8 is present and correct. I’ve tried varying the Kotlin version from 1.3.70 to 1.3.72 to 1.4.32 with no change to the result.

Any help or insight on this would be appreciated, even if it’s just to advance my understanding of this software stack.

python – How would you have a range of movement within a class in pygame?

I have blitted 4 zombies to the screen in pygame. First, the zombies will wander in a specific region (let us say a 10 x 10 area). And when the player enters any one of the zombie’s areas, the zombie should target the player.

import pygame, random, os
from pygame.locals import *

pygame.init()

scr_width = 1020
scr_height = 510
screen = pygame.display.set_mode((scr_width, scr_height))

clock = pygame.time.Clock()

images = {}
path = 'Desktop/Files/Dungeon Minigame/'
filenames = (f for f in os.listdir(path) if f.endswith('.png'))
for name in filenames:
    imagename = os.path.splitext(name)(0)
    images(imagename) = pygame.image.load(os.path.join(path, name))

pygame.display.set_caption('Dungeon Minigame')

font = pygame.font.SysFont('Times_New_Roman', 27)

white = (240, 240, 240)

fps = 60
lives = 3
score = 0

playerX = 510
playerY = 220
playerxchange = 0
playerychange = 0

def player(x, y):
    screen.blit(images('r_knight'), (playerX, playerY))

class Enemy:
    def __init__(self):
        self.x = random.randint(8, 800)
        self.y = random.randint(8, 440)
        self.moveX = 0
        self.moveY = 0

    def move(self):
        self.speed = 3
    def draw(self):
        screen.blit(images('r_zombie'), (self.x, self.y))

def enemy(x, y):
    screen.blit(images('r_zombie'), (x, y))

enemy_list = ()
for i in range(4):
    new_enemy = Enemy()
    enemy_list.append(new_enemy)

while True:

    screen.blit(images('background'), (0, 0))

    score_text = font.render('Score: ' + str(score), True, white)
    lives_text = font.render('Lives: ', True, white)

    screen.blit(score_text, (20, 20))
    screen.blit(lives_text, (840, 20))

    onpress = pygame.key.get_pressed()

    screen.blit(images('r_knight'), (playerX, playerY))

    if lives == 3:
        screen.blit(images('triple_heart'), (920, 0))

    if lives == 2:
        screen.blit(images('double_heart'), (920, 0))

    if lives == 1:
        screen.blit(images('single_heart'), (920, 0))

    if lives <= 0:
        screen.blit(images('triple_empty_heart'), (920, 0))
        if lives < 0:
            lives = 0

    if onpress(pygame.K_a):
        playerX -= 3
        screen.blit(images('l_knight'), (playerX, playerY))

    if onpress(pygame.K_w):
        playerY -= 3
        screen.blit(images('l_knight'), (playerX, playerY))

    if onpress(pygame.K_d):
        playerX += 3
        screen.blit(images('r_knight'), (playerX, playerY))

    if onpress(pygame.K_s):
        playerY += 3
        screen.blit(images('r_knight'), (playerX, playerY))

    if onpress(pygame.K_w) and onpress(pygame.K_a):
        screen.blit(images('l_knight'), (playerX, playerY))

    if onpress(pygame.K_s) and onpress(pygame.K_a):
        screen.blit(images('l_knight'), (playerX, playerY))

    if onpress(pygame.K_w) and onpress(pygame.K_d):
        screen.blit(images('r_knight'), (playerX, playerY))

    if onpress(pygame.K_s) and onpress(pygame.K_d):
        screen.blit(images('r_knight'), (playerX, playerY))

    if playerX <= -8:
        playerX = -8
    elif playerX >= 965:
        playerX = 965

    if playerY <= 5:
        playerY = 5
    elif playerY >= 440:
        playerY = 440
    
    for enemy in enemy_list:
        enemy.move()

    for enemy in enemy_list:
        enemy.draw()

    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()

    clock.tick(fps)
    pygame.display.update()

Output

8 – Class ‘DrupalCoreRoutingRouteSubscriberBase’ not found

I just figured out that one core module from Drupal 8.9.13 is not found.

The page says that

Fatal error: Class 'DrupalCoreRoutingRouteSubscriberBase' not found in /app/docroot/core/modules/config_translation/src/Routing/RouteSubscriber.php on line 13

I was new to Drupal 8 and it’s a core module.

Thanks for your help

java – Glassfish : Class name is wrong or classpath is not set for : com.mysql.cj.jdbc.Driver Please check the server.log for more details

I build JAVA EE project and choose glassfish as a server and mysql as a database,
when i trying integrate mysql database in glassfish server, there are some errors :
I fill properties database like name , server , PortNumber .. etc.
when I test connection by press on ping button , this message displayed

An error has occurred Ping Connection Pool failed for DemoDatabase.
Class name is wrong or classpath is not set for : com.mysql.cj.jdbc.Driver 
Please check the server.log for more details. An error has occurred    
Ping Connection Pool failed for DemoDatabase.
 Class name is wrong or classpath is not set for : com.mysql.cj.jdbc.Driver Please check the server.log for more details.

this message in Server.log

Cannot find poolName in ping-connection-pool command model, file a bugninjection failed on org.glassfish.connectors.admin.cli.PingConnectionPool.poolName with class java.lang.String

object oriented – Python – Pagination class

I built a small flask app and a lot of routes do need some kind of pagination system. However, in some cases I would like to just display n-2, n-1, n, n+1, n+2 where n is the current page and in some others cases, probably a bigger range. Fo example, in the following picture, the range is 2. I am probably going to merge increase() and decrease() in a single method.

I am not doing any database call here, I just want to perform pagination calculation and return values in a form of a dictionary in order to be used by different flask modules.

Would appreciate a feedback! I am quite new to this industry

enter image description here

import math

class Pagination():
    def __init__(self, total_items, items_per_page, page_range, current_page=0):
        self.total_items = total_items  # total number of article to display in total
        self.items_per_page = items_per_page  # maximum number of article per page
        self.page_range = page_range  # number of previous and next pages to display
        self.current_page = current_page
        self.number_of_pages = math.ceil(
            self.total_items / self.items_per_page)

        # if the current_page is 7 and page_range is 3 then self.following will be (8, 9, 10) and self.previous (4, 5 ,6)
        self.following = list(
            range(self.current_page + 1, self.current_page + self.page_range + 1))

        # empty because by default the current page is 0 so no previous
        self.previous = list()


    def increase(self, quantity):
        if self.current_page + quantity > self.number_of_pages:
            raise ValueError(
                f'The maximum number of pages is {self.number_of_pages}')
        else:
            self.current_page += quantity
            self.following = list()
            self.previous = list()
            for i in range(1, self.page_range + 1):
                new_following_page_number = i + self.current_page
                new_previous_page_number = self.current_page - i
                self.previous.insert(i, new_previous_page_number)

                # make sure the number does not exceed the number of pages 
                if new_following_page_number < self.number_of_pages:
                    self.following.insert(i, new_following_page_number)


    def decrease(self, quantity):
        if self.current_page - quantity < self.number_of_pages:
            raise ValueError(f'The mimimum number of pages is 0')
        else:
            self.current_page -= quantity
            self.following = list()
            self.previous = list()
            for i in range(1, self.page_range + 1):
                new_following_page_number = i + self.current_page
                new_previous_page_number = self.current_page - i
                self.following.insert(i, new_following_page_number)
                if new_previous_page_number > 0:
                    self.previous.insert(i, new_previous_page_number)
       
       
    # method called to set the MongoDB skip amount
    def number_of_previous_items(self):
        if self.current_page == 0:
            return 0
        return self.items_per_page * self.current_page


    # method called to inject variables in the pagination HTML nav
    def dict(self):
        return {
            "current_page": self.current_page,
            "next_page": self.following,
            "previous_page": self.previous,
            "number_of_pages": self.number_of_pages
        }

tmp.py

items_pagination = Pagination(total_items=150, items_per_page=10, page_range=3)
print(render.dict())
render.increase(4)
print(render.dict())

results

{'current_page': 0, 'next_page': (1, 2, 3), 'previous_page': (), 'number_of_pages': 15}
{'current_page': 4, 'next_page': (5, 6, 7), 'previous_page': (3, 2, 1), 'number_of_pages': 15}

    

random – This code is a non-static C# class for rolling a number of dice

Fellow human beings, today I present to you my dice rolling script! Behold, in my amateurish attempt at some raw C# code. Perhaps this will remain here regardless of the dozens of other dice rolling scripts out there.

Contains a ‘for’ loop, a ‘switch’, and a method that returns a value.

I have indeed read through other, similar iterations of this class, and I have found them to be lacking in what I might learn from, usually due to over-complication for my tiny brain, or because it invoked the use of libraries I have yet to hear of.

I did my best to make it easy to read for whichever intrigued person stumbles upon this. I deeply respect and appreciate any who may take the time to offer any criticism on my code. What did I do right? What did I do wrong? I don’t have anyone or anywhere else to share it with.

using System;

namespace C_
{
    class RollDice : Program
    {


        //Variables

        int numOfDice;
        int numOfSides;

        int maxDice = 100;
        int minDice = 1;
        int maxSides = 100;
        int minSides = 1;
        int totalRolled;

        //Start method for number of Dice to throw - take the player input in InputMethod() which returns an int. If returning 0, then restart. Clamp the value between min/max. Continue to next function.

        public void GetDice()
        {
            Console.WriteLine("Welcome to Roll Dice!");
            Console.WriteLine("How many dice do you want to throw?");
            numOfDice = InputMethod();
            if(numOfDice == 0)
            {
                GetDice();
            }
            if (numOfDice > maxDice || numOfDice < minDice)
            {
                numOfDice = Math.Clamp(numOfDice, minDice, maxDice);
                Console.WriteLine($"Number of Dice set to {numOfDice}");
            }

            GetSides();
        }

        // Get the sides of each dice by using a similar process. Roll() for each dice, then sum the totals in RollTotal().

        public void GetSides()
        {
            Console.WriteLine("How many sides does each dice have?");
            numOfSides = InputMethod();
            if(numOfSides == 0)
            {
                GetSides();
            }
            if (numOfSides > maxSides || numOfSides < minSides)
            {
                numOfSides = Math.Clamp(numOfSides, minSides, maxSides);
                Console.WriteLine($"Number of Sides set to {numOfSides}");
            }

            for (int x = 1; x <= numOfDice; x++)
            {
                Roll();
            }

            RollTotal();
        }


        // Create a new Random() instance for the number of sides and add it to the totalRolled variable.

         public void Roll()
        {
            Console.WriteLine(".....");
            Console.WriteLine("Rolling");
            Random r = new Random();
            var result = r.Next(1, numOfSides + 1);
            Console.WriteLine($"You rolled {result}");
            totalRolled += result;
        }
        
        // Output the total and prompt to roll again or quit. Reset the total..

        public void RollTotal()
        {
            Console.WriteLine($"Total sum rolled is {totalRolled}");
            Console.WriteLine(" ");
            Console.WriteLine("Enter 1 to re-roll or 2 to quit.");
            var answer = InputMethod();

            switch (answer)
            {
                case 0:
                RollTotal();
                break; 
            
                case 1:
                totalRolled = 0;
                GetDice();
                break;           
            
                case 2:
                totalRolled = 0;
                Environment.Exit(0);
                break;
            
                default:
                Environment.Exit(0);
                break;
            }
        }

        //Convert the input to an integer if valid and return the value. Else return 0.

        public int InputMethod()
        {
            var input = Console.ReadLine();
            if(!Int32.TryParse(input, out int convertedStringToInt))

            {
                Console.WriteLine("You need to enter a valid number!");
                return 0;
            }
            
            else 
            
            {
                return Convert.ToInt32(input);
            }

        }

    }
}

fa.functional analysis – Is radial part of a Schwartz class function also in Schwartz class?

Let $finmathcal{S}(mathbb{R}^n)$, Schwartz class. Consider the function $g$ defined on $(0,infty)$ by $$g(r)=int_{S^{n-1}}f(rw)dmu(w),$$
where $dmu$ is the normalised surface measure of $S^{n-1}.$

1)Is $sup_r|r^kg(r)|<infty,$ for any $kinmathbb{N}$?

  1. Is $ginmathcal{S}((0,infty))?$

Answer of only (1) will also be appreciated.

algorithms – How to prove that one problem belongs to class P?

Is there any typical proving method when proving that one problem belongs to class P?

For example, when proving that

The problem of finding n to the kth power is the P problem. (Each multiplication can be done in unit time)

If you present an algorithm that can solve this problem with $O (log n)$, can it be a proof?

c++ – OpenGL mesh class and derived primitive class

Introduction

After finishing most of the tutorials on https://learnopengl.com/ I started to encapsulate code in their respective classes and started to write a mesh class and a polygon class as my first primitive geometry object to figure out the structure of my code. There are a few questions about the code I’ll add at the end and apart from them I am looking for possible improvement. Eventually I want to end up with a 2D sprite class and a tilemap class to efficiently render bigger maps. Currently all the code is inlined in header files and I will eventually split it into translation units once I am convinced about my design.

Vertex.hpp

/// Describes a custom vertex format structure that contains position, color,
/// and one set of texture coordinates.
struct FVertex final {
  /// XYZ position.
  glm::vec3 Position;
  /// The vertex color.
  glm::vec3 Color;
  /// UV texture coordinates.
  glm::vec2 TextureCoordinate;
};

Mesh.hpp

/// A mesh is a collection of vertices that define the geometry of an object.
class FMesh final {
public:
  /// Creates a new FMesh.
  explicit FMesh() { initialize(); };

  /// Default destructor.
  ~FMesh() {
    if (!IsInitialized) {
      return;
    }
    glDeleteVertexArrays(1, &VertexArrayHandle);
    glDeleteBuffers(1, &VertexBufferHandle);
    IsInitialized = false;
  }

  /// Deleted copy-constructor.
  FMesh(const FMesh &) = delete;
  /// Deleted move-constructor.
  FMesh(FMesh &&) = delete;
  /// Deleted copy-assignment operator.
  auto operator=(const FMesh &) -> FMesh & = delete;
  /// Deleted move-assignment operator.
  auto operator=(FMesh &&) -> FMesh & = delete;

  /// Draws all vertices of this FMesh.
  /// @param Mode Specifies what kind of primitives to render. Can be one of @p
  /// GL_POINTS, @p GL_LINES, @p GL_LINE_STRIP, @p GL_LINE_LOOP, @p
  /// GL_TRIANGLES, @p GL_TRIANGLE_STRIP or @p GL_TRIANGLE_FAN.
  auto draw(const GLenum Mode) const -> void {
    glBindVertexArray(VertexArrayHandle);
    glDrawArrays(Mode, 0, static_cast<GLint>(Vertices.size()));
  }

  /// Sets the vertex with the specified index of this FMesh.
  /// @param Index Index of the vertex to set.
  /// @param Vertex Vertex data to store at the specified index.
  /// @remark Before using this method you must call setVertexCount() first to
  /// initialize this FMesh.
  auto setVertex(const std::size_t Index, const FVertex &Vertex) -> void {
    assert(Vertices.size() >= 2 &&
           "The FMesh hasn't been initialized with setVertexCount.");
    Vertices.at(Index) = Vertex;
    update();
  }

  /// Sets the number of vertices of this FMesh.
  /// @param Count Number of vertices of this FMesh.
  auto setVertexCount(const std::size_t Count) -> void {
    assert(Count >= 2 && "The FMesh must have at least two vertices.");
    Vertices.resize(Count);
    update();
  }

private:
  /// Initializes the OpenGL objects required for this FMesh.
  auto initialize() -> void {
    if (IsInitialized) {
      return;
    }

    glGenVertexArrays(1, &VertexArrayHandle);
    glGenBuffers(1, &VertexBufferHandle);

    glBindVertexArray(VertexArrayHandle);

    glBindBuffer(GL_ARRAY_BUFFER, VertexBufferHandle);
    glBufferData(GL_ARRAY_BUFFER, Vertices.size() * sizeof(FVertex),
                 Vertices.data(), GL_STATIC_DRAW);

    glEnableVertexAttribArray(0);
    glVertexAttribPointer(0, decltype(FVertex::Position)::length(), GL_FLOAT,
                          GL_FALSE, sizeof(FVertex),
                          getOffsetPtrOf(&FVertex::Position));

    glEnableVertexAttribArray(1);
    glVertexAttribPointer(1, decltype(FVertex::Color)::length(), GL_FLOAT,
                          GL_FALSE, sizeof(FVertex),
                          getOffsetPtrOf(&FVertex::Color));

    glEnableVertexAttribArray(2);
    glVertexAttribPointer(2, decltype(FVertex::TextureCoordinate)::length(),
                          GL_FLOAT, GL_FALSE, sizeof(FVertex),
                          getOffsetPtrOf(&FVertex::TextureCoordinate));

    glBindVertexArray(0);
    glBindBuffer(GL_ARRAY_BUFFER, 0);

    IsInitialized = true;
  }

  /// Recompute the internal geometry of the FMesh. This function must be called
  /// every time the vertices change.
  auto update() const -> void {
    assert(IsInitialized == true &&
           "Cannot update FMesh that is not initialized.");
    glBindBuffer(GL_ARRAY_BUFFER, VertexBufferHandle);
    glBufferData(GL_ARRAY_BUFFER, Vertices.size() * sizeof(FVertex),
                 Vertices.data(), GL_STATIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
  }

  /// Boolean value indicating whether this FMesh has been intialized.
  bool IsInitialized;
  /// OpenGL handle to the vertex buffer object of this FMesh.
  FHandle VertexBufferHandle;
  /// OpenGL handle to the vertex array object of this FMesh.
  FHandle VertexArrayHandle;
  /// List of FVertex objects describing the geometry of this FMesh.
  std::vector<FVertex> Vertices;
};

Polygon.hpp

/// A primitive shape with a finite number of straight line segments that form a
/// closed chain.
class FPolygon final {
public:
  /// Creates a new FPolygon.
  explicit FPolygon() = default;
  /// Default destructor.
  ~FPolygon() = default;

  /// Deleted copy-constructor.
  FPolygon(const FPolygon &) = delete;
  /// Deleted move-constructor.
  FPolygon(FPolygon &&) = delete;
  /// Deleted copy-assignment operator.
  auto operator=(const FPolygon &) -> FPolygon & = delete;
  /// Deleted move-assignment operator.
  auto operator=(FPolygon &&) -> FPolygon & = delete;

  /// Draws this FPolygon.
  auto draw() const -> void { Mesh.draw(GL_TRIANGLE_FAN); }
  /// Gets a reference to the underlying FMesh of this FPolygon.
  /// @return Reference to the underlying FMesh of this FPolygon.
  ((nodiscard)) auto getMesh() -> FMesh & { return Mesh; }

private:
  /// FMesh describing the geometry of this FPolygon.
  FMesh Mesh;
};

Usage

Using and initialization of the FPolygon class looks as follows right now:

Polygon.getMesh().setVertexCount(3);
Polygon.getMesh().setVertex(
    0, FVertex{glm::vec3{0, 0.5, 0}, glm::vec3{1, 0, 0}, glm::vec2{1}});
Polygon.getMesh().setVertex(
    1, FVertex{glm::vec3{0.5, -0.5, 0}, glm::vec3{0, 1, 0}, glm::vec2{1}});
Polygon.getMesh().setVertex(
    2, FVertex{glm::vec3{-0.5, -0.5, 0}, glm::vec3{0, 0, 1}, glm::vec2{1}});

Remarks

  • The FVertex struct already has texture coordinates that are currently unused and I will add the handling later on.
  • No projections or transformation are currently set up, this is just about the very basics to get up and running.

Questions

  1. Right now all meshes would have their own vertex array object even though the data layout, based on FVertex, is identical between all of them. Is it common to use a shared vertex array object or is the overhead of duplicating them negligible?
  2. Considering I want to create classes for sprites and tilemaps I was wondering whether it’s better to inherit from FMesh or add it as a member variable. Is there anything I have to consider for this decision?

How to check for a part of a string in a class NoneType in python?

I have an object with class ‘NoneType’ for which I want to write a condition.
Here are 4 examples of my NoneTypes but in my dataset there are 100 possible combinations:

('Text1','Variant1') 
('Text1','Variant2') 
('Text2','Variant1') 
('Text1','Variant3') 

I want to write the following condition: if NoneType contains (‘Text1’ AND ‘Variant2’) OR (‘Text2’) OR (‘Variant3’) then Feature = True

How could I solve this?

Thank you in advance!