问:
webhost php: can't manage to relocate to my index page
i am trying to host my website made on php,

i am trying to use hostinger, my index page is located in

root/public/index.php

so i created an htaccess file where i've put this
DirectoryIndex public/index.php

this index page is a router with all my path

but when i try the link i get an HTTP 500 error

can't manage to find how to solve this problem

in visual studio to start my project i had to cd into my public folder then start the localhost server everything works fine,

but i can't manage to get the same result when hosting this project

here is my index file code i don't think it is the problem but i don't know maybe.

<?php

use App\Controllers\AdminController;
use App\Core\Application;
use App\Controllers\AuthController;
use App\Controllers\HomeController;
use App\Controllers\SiteController;

require dirname(__DIR__) . '/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::createImmutable(dirname(__DIR__) . '/');
$dotenv->load();

$config = [
    'smtp' =>
    [
    'host' => $_ENV['SMTP_HOST'],
    'port' => $_ENV['SMTP_PORT'],
    'username' => $_ENV['SMTP_USERNAME'],
    'password' => $_ENV['SMTP_PASSWORD'],
    'from' => $_ENV['SMTP_FROM'],
    'name' => $_ENV['SMTP_FROM_NAME'],
    ],
    'userClass' => \App\Model\User::class,
    'db' => [
        'dsn' => $_ENV['DB_DSN'],
        'user' => $_ENV['DB_USER'],
        'password' => $_ENV['DB_PASSWORD'],

    ]
];

$app = new Application(dirname(__DIR__) , $config);

$app->router->get("/" , [\App\Controllers\BlogController::class , 'index']);
$app->router->post("/" , [\App\Controllers\BlogController::class , 'index']);
$app->router->get("/page/{page:\d+}" , [\App\Controllers\BlogController::class , 'index']);

$app->router->get('/blog-page/{id:\d+}' , [\App\Controllers\BlogController::class, 'articlePage']);

$app->router->get('/contact' , [SiteController::class , 'contact']);
$app->router->post('/contact' , [SiteController::class, 'contact']);

```

and this is how my hostinger folder look like

can't fully post the code because 'it looks like a spam' but it's just a bunch of path

thank you

*EDIT

So i managed to show my page it was my bad, i didn't enable errors so i couldn't see the problem was in my pdo, fixed it,

but here i have a problem
my index page is shown like this
http:www.mywebsite.com/ , it work fine.
But when i try to put let's imagine
http::www.mywebsite.com/store
everything after / will throw me an error 404 ,
i don't know it was working in my localhost, now it doesn't want

if someone have a solution i would be glad.

Body:
i am trying to host my website made on php,

i am trying to use hostinger, my index page is located in

root/public/index.php

so i created an htaccess file where i've put this
DirectoryIndex public/index.php

this index page is a router with all my path

but when i try the link i get an HTTP 500 error

can't manage to find how to solve this problem

in visual studio to start my project i had to cd into my public folder then start the localhost server everything works fine,

but i can't manage to get the same result when hosting this project

here is my index file code i don't think it is the problem but i don't know maybe.

<?php

use App\Controllers\AdminController;
use App\Core\Application;
use App\Controllers\AuthController;
use App\Controllers\HomeController;
use App\Controllers\SiteController;

require dirname(__DIR__) . '/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::createImmutable(dirname(__DIR__) . '/');
$dotenv->load();

$config = [
    'smtp' =>
    [
    'host' => $_ENV['SMTP_HOST'],
    'port' => $_ENV['SMTP_PORT'],
    'username' => $_ENV['SMTP_USERNAME'],
    'password' => $_ENV['SMTP_PASSWORD'],
    'from' => $_ENV['SMTP_FROM'],
    'name' => $_ENV['SMTP_FROM_NAME'],
    ],
    'userClass' => \App\Model\User::class,
    'db' => [
        'dsn' => $_ENV['DB_DSN'],
        'user' => $_ENV['DB_USER'],
        'password' => $_ENV['DB_PASSWORD'],

    ]
];

$app = new Application(dirname(__DIR__) , $config);

$app->router->get("/" , [\App\Controllers\BlogController::class , 'index']);
$app->router->post("/" , [\App\Controllers\BlogController::class , 'index']);
$app->router->get("/page/{page:\d+}" , [\App\Controllers\BlogController::class , 'index']);

$app->router->get('/blog-page/{id:\d+}' , [\App\Controllers\BlogController::class, 'articlePage']);

$app->router->get('/contact' , [SiteController::class , 'contact']);
$app->router->post('/contact' , [SiteController::class, 'contact']);

and this is how my hostinger folder look like

can't fully post the code because 'it looks like a spam' but it's just a bunch of path

thank you

*EDIT

So i managed to show my page it was my bad, i didn't enable errors so i couldn't see the problem was in my pdo, fixed it,

but here i have a problem
my index page is shown like this
http:www.mywebsite.com/ , it work fine.
But when i try to put let's imagine
http::www.mywebsite.com/store
everything after / will throw me an error 404 ,
i don't know it was working in my localhost, now it doesn't want

if someone have a solution i would be glad.


来源: stackexchange

问:
How to apply conditional formatting for specific scenario
I am trying to apply conditional formatting on range. I am trying to do that if cell value is not empty and cell value is more than 2.5 then cell color will be green. if cell value is not empty and cell value is less than 2.5 then cell color will be red.

I tried this way but I am not getting expected result.

How to refer current cell is not blank in formula?

```<code>ExcelAddress formatRangeAddress = new ExcelAddress(_StartPeriod + ":" + _EndPeriod);
var cond1 = ws.ConditionalFormatting.AddLessThan(formatRangeAddress);
cond1.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
cond1.Style.Fill.BackgroundColor.Color = System.Drawing.ColorTranslator.FromHtml("#FF0000");
cond1.Formula = "2.5";

formatRangeAddress = new ExcelAddress(_StartPeriod + ":" + _EndPeriod);
var cond2 = ws.ConditionalFormatting.AddGreaterThan(formatRangeAddress);
cond2.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
cond1.Style.Fill.BackgroundColor.Color = System.Drawing.ColorTranslator.FromHtml("#92D050");
cond2.Formula = "2.5";
</code>```

I am sure i am not able to write exact formula for my scenario. So anyone can help to share formula which should work for my scenario and range of value will have right background color.

ContentLicense: CC BY-SA 4.0

Body:
I am trying to apply conditional formatting on range. I am trying to do that if cell value is not empty and cell value is more than 2.5 then cell color will be green. if cell value is not empty and cell value is less than 2.5 then cell color will be red.

I tried this way but I am not getting expected result.

How to refer current cell is not blank in formula?

ExcelAddress formatRangeAddress = new ExcelAddress(_StartPeriod + ":" + _EndPeriod);
var cond1 = ws.ConditionalFormatting.AddLessThan(formatRangeAddress);
cond1.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
cond1.Style.Fill.BackgroundColor.Color = System.Drawing.ColorTranslator.FromHtml("#FF0000");
cond1.Formula = "2.5";

formatRangeAddress = new ExcelAddress(_StartPeriod + ":" + _EndPeriod);
var cond2 = ws.ConditionalFormatting.AddGreaterThan(formatRangeAddress);
cond2.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
cond1.Style.Fill.BackgroundColor.Color = System.Drawing.ColorTranslator.FromHtml("#92D050");
cond2.Formula = "2.5";

I am sure i am not able to write exact formula for my scenario. So anyone can help to share formula which should work for my scenario and range of value will have right background color.


问:
Hibernate update/insert null on merge parent
i am using hibernate as orm, and i am having a problem with the merge, when i change the puesto from the controller if i change the Set<caracteresitica> with setCaracteristica and update/insert a new object the hibernate would execute an insert on PonderacionNecesaria with null and null object, throwing this error, how can i solve this ?
(I omit setters and getter)

Cannot invoke "b1.capitalHumano.competencia.Competencia.getIdComp()" because "this.competencia" is null
Also if i delete a pre exisiting object of the set all works fine and is deleted, only happend when i add a new object or change old one to new one

Controller

```<code>public void modificarPuesto(PuestoDTO puestoDTO) {
    Puesto puesto = puestoDAO.getById(puestoDTO.getIdPuesto());
    Empresa empresa = empresaDAO.getById(puestoDTO.getIdEmpresa());
    puesto.setNombrePuesto(puestoDTO.getNombrePuesto());
    puesto.setEmpresa(empresa);
    puesto.setDescripcion(puestoDTO.getDescripcionPuesto());
    Set<PonderacionNecesaria> caracteristicas = new HashSet<PonderacionNecesaria>();
    for (PonderacionNecesariaDTO ponderacionNecesariaDTO : puestoDTO.getCaracteristicasDTO()) {
        caracteristicas.add(new PonderacionNecesaria(puesto, ponderacionNecesariaDTO.getPonderacionNecesaria(),
                competenciaDAO.getById(ponderacionNecesariaDTO.getIdComp())));
    }
    puesto.setCaracteristicas(caracteristicas);
    puestoDAO.update(puesto);
}
</code>```

Puesto

```<code>@Entity(name = "Puesto")
@Table(name = "puesto")
public class Puesto {
    @Id
    @Column(name = "idPuesto")
    Integer idPuesto;
    @Column(name = "nombrePuesto")
    String nombrePuesto;
    @Column(name = "descripción")
    String descripcionPuesto;
    @ManyToOne
    @JoinColumn(name = "idEmpresa")
    Empresa empresa;
    @Column(name = "eliminado")
    Boolean eliminado;
}
</code>```

Ponderacion necesaria

```<code>@Entity(name = "PonderacionNecesaria")
@Table(name = "puesto_competencia")
public class PonderacionNecesaria {
    @Id
    @ManyToOne( fetch = FetchType.EAGER, targetEntity = Competencia.class)
    @JoinColumn(name = "idComp" )
    Competencia competencia;
    @Id
    @ManyToOne( fetch = FetchType.EAGER, targetEntity = Puesto.class)
    @JoinColumn(name = "idPuesto" )
    Puesto puesto;
    @Column(name = "ponderaciónNecesaria")
    Integer ponderacionNecesaria;
    }

public PonderacionNecesaria(Puesto puesto, Integer ponderacion, Competencia competencia) {
    this.competencia = competencia;
    this.puesto = puesto;
    this.ponderacionNecesaria = ponderacion;
}
</code>```

}

Competencia

```<code>@Entity(name="Competencia")
@Table(name="competencia")
public class Competencia {
    @Id
    @Column(name="idComp" )
    Integer idComp;
    @Column(name="nombreComp")
    String nombreComp;
    @Column(name="descripción")
    String descripcion;
    @Column(name="eliminado")
    Boolean eliminado;
}
</code>```

puestoDAO

```<code>public void update(Puesto puesto) {
        Session session = new Configuration().configure().addAnnotatedClass(Evaluacion.class).addAnnotatedClass(Puesto.class).addAnnotatedClass(PonderacionNecesaria.class).addAnnotatedClass(Competencia.class).addAnnotatedClass(Empresa.class).buildSessionFactory()
                .openSession();
        Transaction tx = session.getTransaction();
        try {
            tx = session.getTransaction();
            tx.begin();
              session.merge(puesto);
            tx.commit();
        } catch (RuntimeException e) {
            tx.rollback();
            throw e;
        } finally {
            session.close();
        }
    }
</code>```

Body:
i am using hibernate as orm, and i am having a problem with the merge, when i change the puesto from the controller if i change the Set<caracteresitica> with setCaracteristica and update/insert a new object the hibernate would execute an insert on PonderacionNecesaria with null and null object, throwing this error, how can i solve this ?
(I omit setters and getter)

Cannot invoke "b1.capitalHumano.competencia.Competencia.getIdComp()" because "this.competencia" is null
Also if i delete a pre exisiting object of the set all works fine and is deleted, only happend when i add a new object or change old one to new one

Controller

public void modificarPuesto(PuestoDTO puestoDTO) {
    Puesto puesto = puestoDAO.getById(puestoDTO.getIdPuesto());
    Empresa empresa = empresaDAO.getById(puestoDTO.getIdEmpresa());
    puesto.setNombrePuesto(puestoDTO.getNombrePuesto());
    puesto.setEmpresa(empresa);
    puesto.setDescripcion(puestoDTO.getDescripcionPuesto());
    Set<PonderacionNecesaria> caracteristicas = new HashSet<PonderacionNecesaria>();
    for (PonderacionNecesariaDTO ponderacionNecesariaDTO : puestoDTO.getCaracteristicasDTO()) {
        caracteristicas.add(new PonderacionNecesaria(puesto, ponderacionNecesariaDTO.getPonderacionNecesaria(),
                competenciaDAO.getById(ponderacionNecesariaDTO.getIdComp())));
    }
    puesto.setCaracteristicas(caracteristicas);
    puestoDAO.update(puesto);
}

Puesto

@Entity(name = "Puesto")
@Table(name = "puesto")
public class Puesto {
    @Id
    @Column(name = "idPuesto")
    Integer idPuesto;
    @Column(name = "nombrePuesto")
    String nombrePuesto;
    @Column(name = "descripción")
    String descripcionPuesto;
    @ManyToOne
    @JoinColumn(name = "idEmpresa")
    Empresa empresa;
    @Column(name = "eliminado")
    Boolean eliminado;
}

Ponderacion necesaria

@Entity(name = "PonderacionNecesaria")
@Table(name = "puesto_competencia")
public class PonderacionNecesaria {
    @Id
    @ManyToOne( fetch = FetchType.EAGER, targetEntity = Competencia.class)
    @JoinColumn(name = "idComp" )
    Competencia competencia;
    @Id
    @ManyToOne( fetch = FetchType.EAGER, targetEntity = Puesto.class)
    @JoinColumn(name = "idPuesto" )
    Puesto puesto;
    @Column(name = "ponderaciónNecesaria")
    Integer ponderacionNecesaria;
    }

public PonderacionNecesaria(Puesto puesto, Integer ponderacion, Competencia competencia) {
    this.competencia = competencia;
    this.puesto = puesto;
    this.ponderacionNecesaria = ponderacion;
}

}

Competencia

@Entity(name="Competencia")
@Table(name="competencia")
public class Competencia {
    @Id
    @Column(name="idComp" )
    Integer idComp;
    @Column(name="nombreComp")
    String nombreComp;
    @Column(name="descripción")
    String descripcion;
    @Column(name="eliminado")
    Boolean eliminado;
}

puestoDAO

public void update(Puesto puesto) {
        Session session = new Configuration().configure().addAnnotatedClass(Evaluacion.class).addAnnotatedClass(Puesto.class).addAnnotatedClass(PonderacionNecesaria.class).addAnnotatedClass(Competencia.class).addAnnotatedClass(Empresa.class).buildSessionFactory()
                .openSession();
        Transaction tx = session.getTransaction();
        try {
            tx = session.getTransaction();
            tx.begin();
              session.merge(puesto);
            tx.commit();
        } catch (RuntimeException e) {
            tx.rollback();
            throw e;
        } finally {
            session.close();
        }
    }


问:
How can I filter a wordpress custom post loop to only show posts with a relationship to the current post
I want to show a list of stores that have a relationship custom field with the current weed strain but get an error.

Currently the relationship field called strain is set inside a repeater loop called weed_strains so I can also add a price on the store pages

I have it working with some dirty css to hide the following error but would prefer the code was correct

: Invalid argument supplied for foreach() in

Current code

```<code><?php
$id = get_the_ID();
?>

<div class="hidden">
<?php
$args = array(
    'post_type' => 'wpsl_stores',
    'posts_per_page' => -1
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) :
    while ( $the_query->have_posts() ) : $the_query->the_post();
        if( have_rows('weed_strains' ) ):
            while ( have_rows('weed_strains' ) ) : the_row();
                $sub_values = get_sub_field('strain' );
                foreach( $sub_values as $sub_value ) {
                    if ( $sub_value->ID == $id ) :
                    ?>
                        <li class="visible"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
                    <?php endif;
                }
            endwhile;
        endif;
    endwhile;
    wp_reset_postdata();
endif; ?>
</div>
</code>```

Body:
I want to show a list of stores that have a relationship custom field with the current weed strain but get an error.

Currently the relationship field called strain is set inside a repeater loop called weed_strains so I can also add a price on the store pages

I have it working with some dirty css to hide the following error but would prefer the code was correct

: Invalid argument supplied for foreach() in

Current code

<?php
$id = get_the_ID();
?>

<?php
$args = array(
    'post_type' => 'wpsl_stores',
    'posts_per_page' => -1
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) :
    while ( $the_query->have_posts() ) : $the_query->the_post();
        if( have_rows('weed_strains' ) ):
            while ( have_rows('weed_strains' ) ) : the_row();
                $sub_values = get_sub_field('strain' );
                foreach( $sub_values as $sub_value ) {
                    if ( $sub_value->ID == $id ) :
                    ?>

<a href="<?php the_permalink(); ?>"><?php the_title(); ?>

                    <?php endif;
                }
            endwhile;
        endif;
    endwhile;
    wp_reset_postdata();
endif; ?>


问:
Galera Cluster with MariaDB under NAT configuration
I'm trying to configure a Galera Cluster that works under Ubuntu 20.04 of a CTX Proxmox container. At the moment I'm stuck with the following error from the Cluster: "

```<code>WSREP: Recovered position 00000000-0000-0000-0000-000000000000:-1
[Note] /usr/sbin/mysqld (mysqld 10.3.37-MariaDB-0ubuntu0.20.04.1) starting as process 5351 ..
 mariadb.service: Main process exited, code=exited, status=1/FAILURE
</code>```

and I think that the problem is due to a wrong configuration for the NAT.

What I already tried?
I configured two ports, one for the MariaDB server and another one for the two Galera Cluster. I wrote a PREROUTING rule for forwarding it to the correct machine and I tested that the firewall works well.

Any suggestion for the galera.cnf?
Parameters that at the moment I configured are:

wsrep_cluster_address="gcomm://IP-ADDRESS:PORT,IP-ADDRESS2:PORT2";

wsrep_node_address="IP-ADDRESS:PORT:PORT"
and a similar configuration for the second machine.

Body:
I'm trying to configure a Galera Cluster that works under Ubuntu 20.04 of a CTX Proxmox container. At the moment I'm stuck with the following error from the Cluster: "

WSREP: Recovered position 00000000-0000-0000-0000-000000000000:-1
[Note] /usr/sbin/mysqld (mysqld 10.3.37-MariaDB-0ubuntu0.20.04.1) starting as process 5351 ..
 mariadb.service: Main process exited, code=exited, status=1/FAILURE

and I think that the problem is due to a wrong configuration for the NAT.

What I already tried?
I configured two ports, one for the MariaDB server and another one for the two Galera Cluster. I wrote a PREROUTING rule for forwarding it to the correct machine and I tested that the firewall works well.

Any suggestion for the galera.cnf?
Parameters that at the moment I configured are:

wsrep_cluster_address="gcomm://IP-ADDRESS:PORT,IP-ADDRESS2:PORT2";

wsrep_node_address="IP-ADDRESS:PORT:PORT"
and a similar configuration for the second machine.


问:
how to query many-to-many relation with Typeorm Query Builder using subquery
I'm new to typeorm. I have simple entities : Course and User. I have a third table table CourseUserMapper having course_id and user_id referencing to Course and User tables.

i've created subquery selecting user -> name, email, id

```<code>const totalInstructors = this.dataSource
    .createQueryBuilder(User, 'u')
    .select([
        'u.name AS user_name',
        'u.email AS user_email',
        'cs.userId AS user_id',
        'cs.courseId AS courseId',
    ])
    .leftJoin(CourseInstructor, 'cs', 'cs.userId = u.id');
</code>```
```<code>return await this.dataSource
    .createQueryBuilder(Course, 'course')
    .leftJoinAndMapMany(
        'course.users',
        '(' + totalInstructors.getQuery() + ')',
        'instructors',
        'instructors.courseId = course.id',
    )
    .where('course.id = :id', { id: course.id })
    .getMany();
</code>```

but the above query doesn't return users array list

Expected Result:

```<code>[
    {
        "id": 46,
        "title": "course 1",
        "description": "this is test course",
        "users": [
            {
                "id": 9,
                "name":"John Doe",
                "email": "john@email.com"
            },
            {
                "id": 10,
                "name":"Anna",
                "email":"anna@email.com"
            }
        ]
    }
]

</code>```

Tried working with SQL, which seems to return user_name, user_email and user_id

```<code>SELECT
    `course`.`id` AS `course_id`,
    `course`.`title` AS `course_title`,
    `course`.`description` AS `course_description`,
    `instructors`.*
FROM `course` `course`
    LEFT JOIN `chapter` `chapter`
        ON `chapter`.`course_id` = `course`.`id`
    LEFT JOIN (
        SELECT
            `u`.`name` AS user_name,
            `u`.`email` AS user_email,
            `cs`.`user_id` AS user_id,
            `cs`.`course_id` AS course_id
        FROM `users` `u`
            LEFT JOIN `course_users` `cs`
                ON `cs`.`user_id` = `u`.`id`
        ) `instructors`
        ON instructors.course_id = `course`.`id`
WHERE ( `course`.`id` = 40 )
</code>```

Can i know what i'm doing wrong with Typeorm.

Thanks in advance!!

Body:
I'm new to typeorm. I have simple entities : Course and User. I have a third table table CourseUserMapper having course_id and user_id referencing to Course and User tables.

i've created subquery selecting user -> name, email, id

const totalInstructors = this.dataSource
    .createQueryBuilder(User, 'u')
    .select([
        'u.name AS user_name',
        'u.email AS user_email',
        'cs.userId AS user_id',
        'cs.courseId AS courseId',
    ])
    .leftJoin(CourseInstructor, 'cs', 'cs.userId = u.id');

return await this.dataSource
    .createQueryBuilder(Course, 'course')
    .leftJoinAndMapMany(
        'course.users',
        '(' + totalInstructors.getQuery() + ')',
        'instructors',
        'instructors.courseId = course.id',
    )
    .where('course.id = :id', { id: course.id })
    .getMany();

but the above query doesn't return users array list

Expected Result:

[
    {
        "id": 46,
        "title": "course 1",
        "description": "this is test course",
        "users": [
            {
                "id": 9,
                "name":"John Doe",
                "email": "john@email.com"
            },
            {
                "id": 10,
                "name":"Anna",
                "email":"anna@email.com"
            }
        ]
    }
]

Tried working with SQL, which seems to return user_name, user_email and user_id

SELECT
    `course`.`id` AS `course_id`,
    `course`.`title` AS `course_title`,
    `course`.`description` AS `course_description`,
    `instructors`.*
FROM `course` `course`
    LEFT JOIN `chapter` `chapter`
        ON `chapter`.`course_id` = `course`.`id`
    LEFT JOIN (
        SELECT
            `u`.`name` AS user_name,
            `u`.`email` AS user_email,
            `cs`.`user_id` AS user_id,
            `cs`.`course_id` AS course_id
        FROM `users` `u`
            LEFT JOIN `course_users` `cs`
                ON `cs`.`user_id` = `u`.`id`
        ) `instructors`
        ON instructors.course_id = `course`.`id`
WHERE ( `course`.`id` = 40 )

Can i know what i'm doing wrong with Typeorm.

Thanks in advance!!


问:
VBA - ModelTable get all SQL queries
I'm trying to document some legacy Excel documents for source control ahead of their decommissioning. I need to extract all SQL queries contained within them.

I've been searching for various ways of doing this for a while in either VBA or PowerShell (other options welcomed) and when I thought I had this in place, I realised I'd just returned the source query i.e.

```<code>Dim mt AS ModelTable
Dim wb AS Workbook

Set wb = Workbooks.Open(myFilePath)

        'Get Model Tables and create a file per SQL query
        For Each mt In wb.Model.ModelTables
            sql = mt.SourceWorkbookConnection.OLEDBConnection.CommandText
            Debug.Print sql
        Next
</code>```

When I run the above, I have anywhere between 2 and 10 model tables per Excel file but am only able to return the SQL from the source query that created the connection.

I've tried several variations on the Model object but either get blank, a reference to model, or the same result i.e. just a single query.

For context, the 'EC' connection is our SQL database which is feeding the model tables.

In the UI I see the below:
UI Queries and Connections

EC Details

Most articles, or posts on here refer to adding or updating the queries, whereas I just need to extract them!

Not sure if I'm wording the question appropriately, or what I need to achieve isn't possible.

Any help massively appreciated as constantly going in circles here!

UPDATE

I found a few guides online to do this slightly differently, and to query the model within the workbook via MDX; I've since found that the compatibility of the model is set to 1103 so am unable to use the TMSCHEMA_* DMVs.

Having spent several hours searching yesterday on ways to get the source query/partition query/table query I repeatedly hit dead-ends, am I trying to do the impossible here?

Title: VBA - ModelTable get all SQL queries

Body:
I'm trying to document some legacy Excel documents for source control ahead of their decommissioning. I need to extract all SQL queries contained within them.

I've been searching for various ways of doing this for a while in either VBA or PowerShell (other options welcomed) and when I thought I had this in place, I realised I'd just returned the source query i.e.

Dim mt AS ModelTable
Dim wb AS Workbook

Set wb = Workbooks.Open(myFilePath)

        'Get Model Tables and create a file per SQL query
        For Each mt In wb.Model.ModelTables
            sql = mt.SourceWorkbookConnection.OLEDBConnection.CommandText
            Debug.Print sql
        Next

When I run the above, I have anywhere between 2 and 10 model tables per Excel file but am only able to return the SQL from the source query that created the connection.

I've tried several variations on the Model object but either get blank, a reference to model, or the same result i.e. just a single query.

For context, the 'EC' connection is our SQL database which is feeding the model tables.

In the UI I see the below:
UI Queries and Connections

EC Details

Most articles, or posts on here refer to adding or updating the queries, whereas I just need to extract them!

Not sure if I'm wording the question appropriately, or what I need to achieve isn't possible.

Any help massively appreciated as constantly going in circles here!

UPDATE

I found a few guides online to do this slightly differently, and to query the model within the workbook via MDX; I've since found that the compatibility of the model is set to 1103 so am unable to use the TMSCHEMA_* DMVs.

Having spent several hours searching yesterday on ways to get the source query/partition query/table query I repeatedly hit dead-ends, am I trying to do the impossible here?


问:
footballdata package - FileExistsError: [WinError 183] Cannot create a file when that file already exists
I know this particular question has been asked loads of times but I have searched through and tried multiple approaches to solve this all with the same issue still existing so unfortunately have to ask for help because I cannot solve myself.

I have the following package installed: https://github.com/skagr/footballdata

When trying to read_games I get the dreadful error message. After reading through some of the package it looks as though it should overwrite the data if it already exists but I think this is more of a windows error.

Any help will be appreciated.

I have tried creating a parent structure in the folders but the same error exists. Also tried using Pathlib to say if folder exists=OK but still doesnt solve the error.

edit: Code added.

```<code>import numpy as np
import pandas as pd
import requests
import unidecode
import footballdata as foo
import pathlib
pathlib.Path('C:\\Users\\username\\.spyder-py3\\data').mkdir(parents=True, exist_ok=True)

EPL = foo.MatchHistory('ENG-Premier League', [22]).read_games()
print(EPL.head())
</code>```

As you can see there isnt much to it but getting the error stops anything getting past this point.

thanks

Body:
I know this particular question has been asked loads of times but I have searched through and tried multiple approaches to solve this all with the same issue still existing so unfortunately have to ask for help because I cannot solve myself.

I have the following package installed: https://github.com/skagr/footballdata

When trying to read_games I get the dreadful error message. After reading through some of the package it looks as though it should overwrite the data if it already exists but I think this is more of a windows error.

Any help will be appreciated.

I have tried creating a parent structure in the folders but the same error exists. Also tried using Pathlib to say if folder exists=OK but still doesnt solve the error.

edit: Code added.

import numpy as np
import pandas as pd
import requests
import unidecode
import footballdata as foo
import pathlib
pathlib.Path('C:\\Users\\username\\.spyder-py3\\data').mkdir(parents=True, exist_ok=True)

EPL = foo.MatchHistory('ENG-Premier League', [22]).read_games()
print(EPL.head())

As you can see there isnt much to it but getting the error stops anything getting past this point.

thanks


问:
How could i implement Spring JPA findAll(Specification<T> spec) method?
For unit testing purposes i want to create a fake JPA repository.

While methods like findAll(), findById(id) are easy to implement in java, methods like findAll(Specification spec) are more challenging.

```<code>`
classe FakeJpaRepository implements JpaRepository<Employee, Long> {

private Map<Long, Employee> employees = new HashMap<>();

// other methods implementations omitted

public Optional<Employee> findById(Long id){
    return employees.stream()
    .filter(employee -> employee.getId().equals(id))
    .findFirst();
}

public List<Employee> findAll(Specification<Employee> spec){
   // How could i implement this method ?
}
}
`
</code>```

I tried to find a way to do that in vain, i expect some one to give me solution or example to follow or put me in the way to the solution.

Body:
For unit testing purposes i want to create a fake JPA repository.

While methods like findAll(), findById(id) are easy to implement in java, methods like findAll(Specification spec) are more challenging.

`
classe FakeJpaRepository implements JpaRepository<Employee, Long> {

private Map<Long, Employee> employees = new HashMap<>();

// other methods implementations omitted

public Optional<Employee> findById(Long id){
    return employees.stream()
    .filter(employee -> employee.getId().equals(id))
    .findFirst();
}

public List<Employee> findAll(Specification<Employee> spec){
   // How could i implement this method ?
}
}
`

I tried to find a way to do that in vain, i expect some one to give me solution or example to follow or put me in the way to the solution.


问:
Why does my code add newlines into my csv file? How can I get rid of them?
I have a csv file called doctors.csv containing

```<code>1,John,Smith,Internal Med
2,Jone,Smith,Pediatrics
3,George,Carlos,Cardiology
</code>```

I have code that is going to replace just the first name of one row. It asks for which row they would like to replace and then asks for what they want to replace it with

```<code>file = open("doctors.csv", "r")
x= 0
tmplist = []
for row in file:
    tmplist.append(row)
file.close
for row in tmplist:
    print (x,row)
    x = x+1
rowchange = int(input("Enter the row number to change: "))
makechange= input(str("What is the new first name: "))
file.close()

with open("doctors.csv","r") as doctorcsv:
    r = csv.reader(doctorcsv)
    lines = list(r)
    print (lines)
    lines[rowchange][1]=makechange
    print(lines)

writer = csv.writer(open('doctors.csv', 'w'))
writer.writerows(lines)
</code>```

here's what I have but it introduces newlines into the csv file which would cause issues for other parts of my system like this.

```<code>1,John,Smith,Internal Med

2,Jone,Smith,Pediatrics

3,George,Carlos,Cardiology
</code>```

How can I delete the newlines in the csv file?

Body:
I have a csv file called doctors.csv containing

1,John,Smith,Internal Med
2,Jone,Smith,Pediatrics
3,George,Carlos,Cardiology

I have code that is going to replace just the first name of one row. It asks for which row they would like to replace and then asks for what they want to replace it with

file = open("doctors.csv", "r")
x= 0
tmplist = []
for row in file:
    tmplist.append(row)
file.close
for row in tmplist:
    print (x,row)
    x = x+1
rowchange = int(input("Enter the row number to change: "))
makechange= input(str("What is the new first name: "))
file.close()

with open("doctors.csv","r") as doctorcsv:
    r = csv.reader(doctorcsv)
    lines = list(r)
    print (lines)
    lines[rowchange][1]=makechange
    print(lines)

writer = csv.writer(open('doctors.csv', 'w'))
writer.writerows(lines)

here's what I have but it introduces newlines into the csv file which would cause issues for other parts of my system like this.

1,John,Smith,Internal Med

2,Jone,Smith,Pediatrics

3,George,Carlos,Cardiology

How can I delete the newlines in the csv file?


问:
OWL Protoge Superproperty of (Chain) to produce new Object Property
I've a model that allows users to define entities with myonto:Entity types, and link them via myonto:Relationship nodes, which are attached using myonto:RelationshipEntityFrom and myonto:RelationshipEntityTo object properties (each with a Domain of Relationship and a Range of Entity)

Given that myonto:Relationship has a property :name, what I'd like to do is create an Object Property Class myonto:EntityToEntityRelationship that applies according to the following property chain:

```<code> inverse (RelationshipEntityFrom) o RelationshipEntityTo
</code>```

So far so good - but what I'd really like to do, is create an Object Property according to the above rules, but as a SubClass of myonto:EntityToEntityRelationship using the :name of the myonto:Relationship individual. This allows the user to define these EntityToEntityRelationship properties by creating individuals of type myonto:Relationship.

I can probably do this by means of code as/when these Relationship nodes are created, but I'd rather be able to do it through the reasoner, and have the logic embedded in the ontology.

Is this use of individuals to define and create specific properties (of a particular Super-Type, i.e. SubClasses of Object Properties) something that's possible without recourse to external programming? If so, how would I do this (ideally using Protégé, but if not possible, then directly using owl?

The more sense I can embed into my ontology the better.

To provide more context, here's a version of the sparql query I'm currently running:

```<code>   SELECT ?s ?p ?o
                    WHERE
                    {
                        {
                            ?s ^ myonto:RelationshipEntityFrom/myonto:RelationshipEntityTo  ?o .
                            ?r myonto:RelationshipEntityTo ?o.
                            ?r rdfs:label ?rl .
                            ?r a myonto:Relationship .
                            BIND (?rl as ?p)
                        }
                        UNION
                        {
                            ?q ^ myonto:RelationshipEntityFrom/myonto:RelationshipEntityTo ?s .
                            ?s rdfs:label ?o .
                            BIND (rdfs:label as ?p).

                        }
                        UNION
                        {
                            ?s ^ myonto:RelationshipEntityFrom/myonto:RelationshipEntityTo ?q .
                            ?s rdfs:label ?o .
                            BIND (rdfs:label as ?p).

                        }
                        }
</code>```

Which generates a result that "Object-Property-ises" the Relationship entities ConveysProduct, hasPolicy, residesAt into pseudo-object-properties.

What I'd like to be able to do is some owl-based reasoning that will generate those transformed pseudo-properties, so I can run the following sparql, and get much the same results:

```<code>    select ?s ?p ?o
WHERE
{
    {
    ?s ?p ?o.
    ?p rdfs:SubPropertyOf myonto:EntityToEntityRelationship.
    }
    UNION
    {
    ?s ?q ?r.
    ?q rdfs:SubPropertyOf myonto:EntityToEntityRelationship.
    ?s rdfs:label ?o .
    BIND( rdfs:label ?p) .
    }
    UNION
    {
    ?r ?q ?s.
    ?q rdfs:SubPropertyOf myonto:EntityToEntityRelationship.
    ?s rdfs:label ?o .
    BIND( rdfs:label ?p) .
    }

}
</code>```

(I'm aware the UNION-ed statements to retrieve the labels are a bit clunky, but it's the simplification of that first where clause I'm looking to investigate.

Body:
I've a model that allows users to define entities with myonto:Entity types, and link them via myonto:Relationship nodes, which are attached using myonto:RelationshipEntityFrom and myonto:RelationshipEntityTo object properties (each with a Domain of Relationship and a Range of Entity)

Given that myonto:Relationship has a property :name, what I'd like to do is create an Object Property Class myonto:EntityToEntityRelationship that applies according to the following property chain:

 inverse (RelationshipEntityFrom) o RelationshipEntityTo

So far so good - but what I'd really like to do, is create an Object Property according to the above rules, but as a SubClass of myonto:EntityToEntityRelationship using the :name of the myonto:Relationship individual. This allows the user to define these EntityToEntityRelationship properties by creating individuals of type myonto:Relationship.

I can probably do this by means of code as/when these Relationship nodes are created, but I'd rather be able to do it through the reasoner, and have the logic embedded in the ontology.

Is this use of individuals to define and create specific properties (of a particular Super-Type, i.e. SubClasses of Object Properties) something that's possible without recourse to external programming? If so, how would I do this (ideally using Protégé, but if not possible, then directly using owl?

The more sense I can embed into my ontology the better.

To provide more context, here's a version of the sparql query I'm currently running:

   SELECT ?s ?p ?o
                    WHERE
                    {
                        {
                            ?s ^ myonto:RelationshipEntityFrom/myonto:RelationshipEntityTo  ?o .
                            ?r myonto:RelationshipEntityTo ?o.
                            ?r rdfs:label ?rl .
                            ?r a myonto:Relationship .
                            BIND (?rl as ?p)
                        }
                        UNION
                        {
                            ?q ^ myonto:RelationshipEntityFrom/myonto:RelationshipEntityTo ?s .
                            ?s rdfs:label ?o .
                            BIND (rdfs:label as ?p).

                        }
                        UNION
                        {
                            ?s ^ myonto:RelationshipEntityFrom/myonto:RelationshipEntityTo ?q .
                            ?s rdfs:label ?o .
                            BIND (rdfs:label as ?p).

                        }
                        }

Which generates a result that "Object-Property-ises" the Relationship entities ConveysProduct, hasPolicy, residesAt into pseudo-object-properties.

What I'd like to be able to do is some owl-based reasoning that will generate those transformed pseudo-properties, so I can run the following sparql, and get much the same results:

    select ?s ?p ?o
WHERE
{
    {
    ?s ?p ?o.
    ?p rdfs:SubPropertyOf myonto:EntityToEntityRelationship.
    }
    UNION
    {
    ?s ?q ?r.
    ?q rdfs:SubPropertyOf myonto:EntityToEntityRelationship.
    ?s rdfs:label ?o .
    BIND( rdfs:label ?p) .
    }
    UNION
    {
    ?r ?q ?s.
    ?q rdfs:SubPropertyOf myonto:EntityToEntityRelationship.
    ?s rdfs:label ?o .
    BIND( rdfs:label ?p) .
    }

}

(I'm aware the UNION-ed statements to retrieve the labels are a bit clunky, but it's the simplification of that first where clause I'm looking to investigate.


问:
How can I call a function automatically whenever an endpoint is hit?
I currently have a function that we need to call in every endpoint. I was wondering if there is a good way to make it so I can just have the function get called automatically when any/certain endpoints are hit.

For instance, lets say I have a function in a controller class that returns values here.

```<code>      @GetMapping("/data")
  public Set<Mission> getdata() {
    return dataService.getData();
  }
</code>```

Now in the class DataService, I have to manually call a function at the start to set up.

```<code>  public Set<Data> getData() {
    **functionIHaveToCall.setData();**
    ....
    return data;
  }
</code>```

I have to do that for every end point right now because that function has to execute for a lot of them. Is there a way I can allow a piece of code to just run any time an endpoint is hit? I tried looking into @ModelAttribute and HandlerInterceptor but they don't seem to be quite what I am looking for. Unless I am misunderstanding something. What is a good way to do this?

Body:
I currently have a function that we need to call in every endpoint. I was wondering if there is a good way to make it so I can just have the function get called automatically when any/certain endpoints are hit.

For instance, lets say I have a function in a controller class that returns values here.

      @GetMapping("/data")
  public Set<Mission> getdata() {
    return dataService.getData();
  }

Now in the class DataService, I have to manually call a function at the start to set up.

  public Set<Data> getData() {
    **functionIHaveToCall.setData();**
    ....
    return data;
  }

I have to do that for every end point right now because that function has to execute for a lot of them. Is there a way I can allow a piece of code to just run any time an endpoint is hit? I tried looking into @ModelAttribute and HandlerInterceptor but they don't seem to be quite what I am looking for. Unless I am misunderstanding something. What is a good way to do this?


问:
django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS
I am troubleshooting an NGINX/Django/UWSGI application for a customer, that has been broken beyond expectations. I've been debugging code, and re-writing for 30+ hours now and am at another hurdle that I can't seem to get past on my own.

```<code>[pid: 336873|app: 0|req: 1/1] 198.11.30.68 () {46 vars in 1070 bytes} [Mon Dec  5 10:04:42 2022] GET / => generated 0 bytes in 393 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
announcing my loyalty to the Emperor...
Traceback (most recent call last):
  File "/home/django/django_venv/django_site/wsgi.py", line 26, in application
    get_wsgi_application();
  File "/home/django/django_venv/lib64/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
    WSGIHandler();
  File "/home/django/django_venv/lib64/python3.6/site-packages/django/core/handlers/wsgi.py", line 127, in __init__
    self.load_middleware()
  File "/home/django/django_venv/lib64/python3.6/site-packages/django/core/handlers/base.py", line 40, in load_middleware
    middleware = import_string(middleware_path)
  File "/home/django/django_venv/lib64/python3.6/site-packages/django/utils/module_loading.py", line 17, in import_string
    module = import_module(module_path)
  File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/django/django_venv/lib64/python3.6/site-packages/django/contrib/auth/middleware.py", line 3, in <module>
    from django.contrib.auth.backends import RemoteUserBackend
  File "/home/django/django_venv/lib64/python3.6/site-packages/django/contrib/auth/backends.py", line 2, in <module>
    from django.contrib.auth.models import Permission
  File "/home/django/django_venv/lib64/python3.6/site-packages/django/contrib/auth/models.py", line 5, in <module>
    from django.contrib.contenttypes.models import ContentType
  File "/home/django/django_venv/lib64/python3.6/site-packages/django/contrib/contenttypes/models.py", line 133, in <module>
    class ContentType(models.Model):
  File "/home/django/django_venv/lib64/python3.6/site-packages/django/db/models/base.py", line 116, in __new__
    "INSTALLED_APPS." % (module, name)
RuntimeError: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
[pid: 336874|app: 0|req: 1/2] 198.11.30.68 () {46 vars in 1049 bytes} [Mon Dec  5 10:04:42 2022] GET /favicon.ico => generated 0 bytes in 393 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
announcing my loyalty to the Emperor...
</code>```

So I can't get around this error message, and I am not sure how to move forward.

Also, here is my settings.py. Literally any help would be appreciated. Just going in circles right now.

import django.utils
from pathlib import Path
import six
import localsettings as secret
import urls
import sys
import os
import django
django.setup()
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = <removed for privacy>

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = [<removed for privacy>]
BASE_DIR = Path(__file__).resolve().parent.parent

# Application definition

INSTALLED_APPS = [
    'django.contrib.contenttypes',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.sites',
    'django.contrib.sessions',
    'django.contrib.messages',
    'wsgi.application',
    'acknowledgments.apps.AcknowledgmentsConfig',
    'data_sources.apps.DataSourcesConfig',
    'home.apps.HomeConfig',
    'igv.apps.IgvConfig',
    'organisms.apps.OrganismsConfig',
    'samples.apps.SamplesConfig',
    'search.apps.SearchConfig',
    'summary.apps.SummaryConfig',
    ]
#import django.contrib.contenttypes.models.ContentType
MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'urls'
SITE_ID = 1
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'django_site.templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = "wsgi.application"

# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': secret.db_name,
        'USER': secret.db_user,
        'PASSWORD': secret.db_token,
        'HOST': secret.db_host,
        }
    }

# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = '<removed for privacy>'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_ROOT = os.path.join(BASE_DIR, "static/admin")
STATIC_URL ="static/admin/"

# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
```

Body:
I am troubleshooting an NGINX/Django/UWSGI application for a customer, that has been broken beyond expectations. I've been debugging code, and re-writing for 30+ hours now and am at another hurdle that I can't seem to get past on my own.

[pid: 336873|app: 0|req: 1/1] 198.11.30.68 () {46 vars in 1070 bytes} [Mon Dec  5 10:04:42 2022] GET / => generated 0 bytes in 393 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
announcing my loyalty to the Emperor...
Traceback (most recent call last):
  File "/home/django/django_venv/django_site/wsgi.py", line 26, in application
    get_wsgi_application();
  File "/home/django/django_venv/lib64/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
    WSGIHandler();
  File "/home/django/django_venv/lib64/python3.6/site-packages/django/core/handlers/wsgi.py", line 127, in __init__
    self.load_middleware()
  File "/home/django/django_venv/lib64/python3.6/site-packages/django/core/handlers/base.py", line 40, in load_middleware
    middleware = import_string(middleware_path)
  File "/home/django/django_venv/lib64/python3.6/site-packages/django/utils/module_loading.py", line 17, in import_string
    module = import_module(module_path)
  File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/django/django_venv/lib64/python3.6/site-packages/django/contrib/auth/middleware.py", line 3, in <module>
    from django.contrib.auth.backends import RemoteUserBackend
  File "/home/django/django_venv/lib64/python3.6/site-packages/django/contrib/auth/backends.py", line 2, in <module>
    from django.contrib.auth.models import Permission
  File "/home/django/django_venv/lib64/python3.6/site-packages/django/contrib/auth/models.py", line 5, in <module>
    from django.contrib.contenttypes.models import ContentType
  File "/home/django/django_venv/lib64/python3.6/site-packages/django/contrib/contenttypes/models.py", line 133, in <module>
    class ContentType(models.Model):
  File "/home/django/django_venv/lib64/python3.6/site-packages/django/db/models/base.py", line 116, in __new__
    "INSTALLED_APPS." % (module, name)
RuntimeError: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
[pid: 336874|app: 0|req: 1/2] 198.11.30.68 () {46 vars in 1049 bytes} [Mon Dec  5 10:04:42 2022] GET /favicon.ico => generated 0 bytes in 393 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
announcing my loyalty to the Emperor...

So I can't get around this error message, and I am not sure how to move forward.

Also, here is my settings.py. Literally any help would be appreciated. Just going in circles right now.

import django.utils
from pathlib import Path
import six
import localsettings as secret
import urls
import sys
import os
import django
django.setup()
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = <removed for privacy>

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = [<removed for privacy>]
BASE_DIR = Path(__file__).resolve().parent.parent

# Application definition

INSTALLED_APPS = [
    'django.contrib.contenttypes',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.sites',
    'django.contrib.sessions',
    'django.contrib.messages',
    'wsgi.application',
    'acknowledgments.apps.AcknowledgmentsConfig',
    'data_sources.apps.DataSourcesConfig',
    'home.apps.HomeConfig',
    'igv.apps.IgvConfig',
    'organisms.apps.OrganismsConfig',
    'samples.apps.SamplesConfig',
    'search.apps.SearchConfig',
    'summary.apps.SummaryConfig',
    ]
#import django.contrib.contenttypes.models.ContentType
MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'urls'
SITE_ID = 1
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'django_site.templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = "wsgi.application"

# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': secret.db_name,
        'USER': secret.db_user,
        'PASSWORD': secret.db_token,
        'HOST': secret.db_host,
        }
    }

# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = '<removed for privacy>'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_ROOT = os.path.join(BASE_DIR, "static/admin")
STATIC_URL ="static/admin/"

# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'


问:
VS Code Multi-Root Project Support has stopped working for my project?
I have a Multi-Root Project.  I needed to rebuild my machine and since doing this the Multi-Root Support seems to have stopped working.  I get no Launch Picker or Run Button in the UI.  Any ideas on what needs to be done to resolve this?

Run/Debug Button and Launch Picker missing

I have launch.json files in each sub folder/project But I can find no way to get the IDE to select them?


问:
Using meta_query with custom query vars leads to 404 on pagination with Timber
I have a CPT that I'm filtering with custom query vars associated with ACF fields. Pagination pages lead to 404 whenever the meta_query is active. Any assistance would be appreciated.

On search.php

```<code>if ( $post_type == 'funded_grants' ) {

  $program_type = get_query_var('program_type');
  $contributor = get_query_var('contributor');
  $researchers = get_query_var('researchers');
  $area_of_research = get_query_var('area_of_research');
  $disease_areas = get_query_var('disease_areas');
  $province = get_query_var('province');
  $start_date = get_query_var('start_date');
  $end_date = get_query_var('end_date');

  $meta_query = bc_create_meta_query();

  $args = [
    's' => $text_query,
    'meta_query' => $meta_query,
  ];

  $context['posts'] = new Timber\PostQuery($args);

  Timber::render(['archive-funded_grants.twig'], $context);

}
</code>```

In functions.php

```<code>function filterFundedGrantsSearch($query) {
    if ($query->is_search && $query->get('post_type') == 'funded_grants' && !is_admin() ) {
      $query->set( 'posts_per_page', 5 );
      $query->set( 'paged', (get_query_var('paged')) ? get_query_var('paged') : 1 );
    }
    return $query;
  }

  add_filter('pre_get_posts','filterFundedGrantsSearch');

</code>```

I've tried every possible solution I can find in the docs.

Body:
I have a CPT that I'm filtering with custom query vars associated with ACF fields. Pagination pages lead to 404 whenever the meta_query is active. Any assistance would be appreciated.

On search.php

if ( $post_type == 'funded_grants' ) {

  $program_type = get_query_var('program_type');
  $contributor = get_query_var('contributor');
  $researchers = get_query_var('researchers');
  $area_of_research = get_query_var('area_of_research');
  $disease_areas = get_query_var('disease_areas');
  $province = get_query_var('province');
  $start_date = get_query_var('start_date');
  $end_date = get_query_var('end_date');

  $meta_query = bc_create_meta_query();

  $args = [
    's' => $text_query,
    'meta_query' => $meta_query,
  ];

  $context['posts'] = new Timber\PostQuery($args);

  Timber::render(['archive-funded_grants.twig'], $context);

}

In functions.php

function filterFundedGrantsSearch($query) {
    if ($query->is_search && $query->get('post_type') == 'funded_grants' && !is_admin() ) {
      $query->set( 'posts_per_page', 5 );
      $query->set( 'paged', (get_query_var('paged')) ? get_query_var('paged') : 1 );
    }
    return $query;
  }

  add_filter('pre_get_posts','filterFundedGrantsSearch');

I've tried every possible solution I can find in the docs.


问:
MaxDB SAP SQL Missing keyword WITH on update
Hi there I'm using MaxDB and trying to update a table and I get the error Missing keyword:WITH. Code: -5015.

Here is my SQL:

```<code>UPDATE agm
SET agm_confirm_stat = 'C',
    agm_confirm_usr = 'MEDICWARE',
    agm_confirm_obs = 'Wellon: Confirmado',
    agm_obs = NVL(agm_obs, '') || '\/\/Wellon: Confirmar',
    agm_confirm_dthr = TIMESTAMP
WHERE (agm_pac = '319900')
    AND (
        agm_obs NOT LIKE '%Wellon: Confirmar%'
        OR agm_obs IS NULL
    )
    AND (agm_str_cod = 'FBC')
    AND (agm_hini = '2022-12-07 08:00:00')
    AND (agm_confirm_stat != 'C')
    AND (agm_stat = 'A')
</code>```

Body:
Hi there I'm using MaxDB and trying to update a table and I get the error Missing keyword:WITH. Code: -5015.

Here is my SQL:

UPDATE agm
SET agm_confirm_stat = 'C',
    agm_confirm_usr = 'MEDICWARE',
    agm_confirm_obs = 'Wellon: Confirmado',
    agm_obs = NVL(agm_obs, '') || '\/\/Wellon: Confirmar',
    agm_confirm_dthr = TIMESTAMP
WHERE (agm_pac = '319900')
    AND (
        agm_obs NOT LIKE '%Wellon: Confirmar%'
        OR agm_obs IS NULL
    )
    AND (agm_str_cod = 'FBC')
    AND (agm_hini = '2022-12-07 08:00:00')
    AND (agm_confirm_stat != 'C')
    AND (agm_stat = 'A')


问:
While loop using a probability density function
I want to make a while loop that, until n is not equal to 105, it takes a random value x, and if the value x respects some restrictions, it store that value.
The x has to be between 15 and 33
It also simulates a variable num that has to be a random variable from a uniform distribution betwenn 0 and 1.

```<code>library(ggplot2)
dev.new()
n = 0
set.seed(1684)
x = seq(15, 33, by = 0.1)
f <- function(x) {
  out <- ifelse(
    x < 15 | 33 < x,
    0,
    ifelse(
      15 <= x & x <= 24,
      (2*(x-15))/((33-15)*(24-15)),
      ifelse(
        24 < x & x <= 33,
        (2*(33-x))/((33-15)*(33-24)),
        NA_real_
      )))
  if (any((is.na(out) | is.nan(out)) & (!is.na(x) & !is.nan(x)))) {
    warning("f(x) undefined for some input values")
  }
  out
}

while (n != 105) {
  n = n + 1
  x1 = runif(1, min = 15 , max = 33)
  num = runif(1, min = 0 , max = 1)
  if ((num < (f(x1)/2/(33-15))) && (num == (18*(f(x1)/2)))) {

    x_accept = c(x_accept, x1)
  }
}
</code>```

I've made this but it doesn't work, the x_accept is just an empty list

Body:
I want to make a while loop that, until n is not equal to 105, it takes a random value x, and if the value x respects some restrictions, it store that value.
The x has to be between 15 and 33
It also simulates a variable num that has to be a random variable from a uniform distribution betwenn 0 and 1.

library(ggplot2)
dev.new()
n = 0
set.seed(1684)
x = seq(15, 33, by = 0.1)
f <- function(x) {
  out <- ifelse(
    x < 15 | 33 < x,
    0,
    ifelse(
      15 <= x & x <= 24,
      (2*(x-15))/((33-15)*(24-15)),
      ifelse(
        24 < x & x <= 33,
        (2*(33-x))/((33-15)*(33-24)),
        NA_real_
      )))
  if (any((is.na(out) | is.nan(out)) & (!is.na(x) & !is.nan(x)))) {
    warning("f(x) undefined for some input values")
  }
  out
}

while (n != 105) {
  n = n + 1
  x1 = runif(1, min = 15 , max = 33)
  num = runif(1, min = 0 , max = 1)
  if ((num < (f(x1)/2/(33-15))) && (num == (18*(f(x1)/2)))) {

    x_accept = c(x_accept, x1)
  }
}

I've made this but it doesn't work, the x_accept is just an empty list


问:
Laravel on IIS with shared network drive
I'm running a Laravel app on IIS and everything is working fine except for one thing. We have a large media server on another machine that's housing years of picture and video uploads. We don't want to move that server or its contents for various reasons so we created a mapped network drive to that folder. In Laravel, I have a disc set up this way:

```<code>       'network' => [
            'driver' => 'local',
            'root' => '\\\\I:'
        ],
</code>```

(I have also tried the UNC path of \\\\My-Server-Name\ but that still has the same outcomes)

In my controller, I try to access like this:

```<code>return Image::make(Storage::disk('network')->get("/Production/Storage/{$request->imgpath}"))->response();
</code>```

When that controller hits, it gives me a very confusing error:
 Unable to create a directory at \\I:

so FIRST question: why is it giving me a CREATE error when trying to READ a file?

Next question: if I create a test route in my web.php file that looks like this:

```<code>Route::get('/test', function () {
    $directories = glob("I:\\" . '/*', GLOB_ONLYDIR);
    print_r($directories);
});
</code>```

it will return an empty array. HOWEVER, if I put this code into a php file on the desktop and run it like this:

```<code><?php
$directories = glob("I:\\" . '/*' , GLOB_ONLYDIR);
print_r($directories);

?>
</code>```

then use php my-test-script.php in the command line, it will return the array of directories.

So some sort of issue is happening between what php is trying to do within the project itself and what it's able to do when running "directly" on the windows system through CLI.

I should also mention that if I change the path in my route test to C:\ instead of the mapped drive of I:\, it works fine and returns the array of subdirectories. So it's only an error with the mapped drive within the Laravel application itself.

I've spent two weeks trying to debug this if anyone can help me.

Body:
I'm running a Laravel app on IIS and everything is working fine except for one thing. We have a large media server on another machine that's housing years of picture and video uploads. We don't want to move that server or its contents for various reasons so we created a mapped network drive to that folder. In Laravel, I have a disc set up this way:

       'network' => [
            'driver' => 'local',
            'root' => '\\\\I:'
        ],

(I have also tried the UNC path of \\\\My-Server-Name\ but that still has the same outcomes)

In my controller, I try to access like this:

return Image::make(Storage::disk('network')->get("/Production/Storage/{$request->imgpath}"))->response();

When that controller hits, it gives me a very confusing error:
 Unable to create a directory at \\I:

so FIRST question: why is it giving me a CREATE error when trying to READ a file?

Next question: if I create a test route in my web.php file that looks like this:

Route::get('/test', function () {
    $directories = glob("I:\\" . '/*', GLOB_ONLYDIR);
    print_r($directories);
});

it will return an empty array. HOWEVER, if I put this code into a php file on the desktop and run it like this:

<?php
$directories = glob("I:\\" . '/*' , GLOB_ONLYDIR);
print_r($directories);

?>

then use php my-test-script.php in the command line, it will return the array of directories.

So some sort of issue is happening between what php is trying to do within the project itself and what it's able to do when running "directly" on the windows system through CLI.

I should also mention that if I change the path in my route test to C:\ instead of the mapped drive of I:\, it works fine and returns the array of subdirectories. So it's only an error with the mapped drive within the Laravel application itself.

I've spent two weeks trying to debug this if anyone can help me.


问:
Qt Opengl configuration for Windows CE
I am trying to configure Qt using the OpenGL parameter for a custom WinCE SDK, but I get a compiler error. I found a similar error faced in the http://www.qtcentre.org/threads/37052-WinCE-OpenGL-ES-build-error?s=7aa5ac49753e1c3f1e0b624bb9134faa post.

The link says to install OpenGL SDK from Imagination Technology, link the library, and include the file to solve the error.

When I tried the mentioned steps, I got linker errors.

link /LIBPATH:"c:\Qt\4.7.4_2\lib" /LIBPATH:"c:\Qt\4.7.4_2\lib" /NOLOGO /
      NODEFAULTLIB:OLDNAMES.LIB /DEBUG /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:THUMB /DLL /
      SAFESEH:NO /VERSION:4.74 /OUT:....\lib\QtGuid4.dll @C:\DOCUME~1\VARUN~1.JAJ\LOC
      ALS~1\Temp\nm8796.tmp

      Creating library ....\lib\QtGuid4.lib and object ....\lib\QtGuid4.exp
      qegl.obj : error LNK2019: unresolved external symbol __imp_eglBindAPI referenced
       in function "public: bool __cdecl QEglContext::createContext(class QEglContext
      *,class QEglProperties const *)" (?createContext@QEglContext@@QAA_NPAV1@PBVQEglP
      roperties@@@Z)

      ....\lib\QtGuid4.dll : fatal error LNK1120: 1 unresolved externals
      NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\VC\ce\bi
      n\x86_arm\link.EXE"' : return code '0x460'

      Stop.

      NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\VC\BIN\n
      make.exe"' : return code '0x2'
      Stop.

      NMAKE : fatal error U1077: 'cd' : return code '0x2'
      Stop.

Has anyone faced similar problems?  Could you please suggest me what to do?

ContentLicense: CC BY-SA 3.0

Title: Qt Opengl configuration for Windows CE


问:
how to use rowspan in python-tkinter
I am trying to make a question game that you can pick the right question by click it.

but the problem is when i am doing a pack to my question my everything is ok but i don't want to use a pack

i want to use a grid when i use a grid without evry thing it work but when i add to the grid <exemple.grid(row=0, rowspan = 3)>

its dont work to me, i want to put evry question in  a diffrent line but i dont know the problem somebody can help me pls?

```<code>from tkinter import *
from PIL import Image,ImageTk

root = Tk()
root.title('Question')
img_icon = PhotoImage(file='images\\Gallery.ico')
root.tk.call('wm', 'iconphoto', root._w, img_icon)

# this are the question
# question number 1: what is banana color?| question number 2: baby born how every one called him?|
# 3 question: what is 2+2*2+2|| 4 question = what is 10*25/15*0*15+1

question = [
    ("Blue", "Baby", "6", "1"),
    ("Yellow", "Sweetie", "8", "-1"),
    ("Green", "Cute", "10", "0"),
]

    #Create the question
for qus1, qus2, qus3, qus4 in question:
    qus_show_one = Radiobutton(root, text=qus1)
    qus_show_two = Radiobutton(root, text=qus2)
    qus_show_three = Radiobutton(root, text=qus3)
    qus_show_four = Radiobutton(root, text=qus4)

# Show the question

    # this is don't work
    qus_show_one.grid(row=0, rowspan=3, column=0)
    #the two here work
    qus_show_two.pack()
    qus_show_one.grid()
# qus_show_one.grid()

root.mainloop()
</code>```

Title: how to use rowspan in python-tkinter

Body:
I am trying to make a question game that you can pick the right question by click it.

but the problem is when i am doing a pack to my question my everything is ok but i don't want to use a pack

i want to use a grid when i use a grid without evry thing it work but when i add to the grid <exemple.grid(row=0, rowspan = 3)>

its dont work to me, i want to put evry question in  a diffrent line but i dont know the problem somebody can help me pls?

from tkinter import *
from PIL import Image,ImageTk

root = Tk()
root.title('Question')
img_icon = PhotoImage(file='images\\Gallery.ico')
root.tk.call('wm', 'iconphoto', root._w, img_icon)

# this are the question
# question number 1: what is banana color?| question number 2: baby born how every one called him?|
# 3 question: what is 2+2*2+2|| 4 question = what is 10*25/15*0*15+1

question = [
    ("Blue", "Baby", "6", "1"),
    ("Yellow", "Sweetie", "8", "-1"),
    ("Green", "Cute", "10", "0"),
]

    #Create the question
for qus1, qus2, qus3, qus4 in question:
    qus_show_one = Radiobutton(root, text=qus1)
    qus_show_two = Radiobutton(root, text=qus2)
    qus_show_three = Radiobutton(root, text=qus3)
    qus_show_four = Radiobutton(root, text=qus4)

# Show the question

    # this is don't work
    qus_show_one.grid(row=0, rowspan=3, column=0)
    #the two here work
    qus_show_two.pack()
    qus_show_one.grid()
# qus_show_one.grid()

root.mainloop()